diff --git a/.clang-tidy b/.clang-tidy index fd8c681c4..5199de39f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -144,4 +144,39 @@ readability-static-accessed-through-instance, readability-static-definition-in-anonymous-namespace, readability-string-compare, readability-uniqueptr-delete-release, -readability-use-anyofallof' \ No newline at end of file +readability-use-anyofallof, +readability-identifier-naming' +CheckOptions: + readability-identifier-naming.ClassCase: CamelCase + readability-identifier-naming.StructCase: CamelCase + readability-identifier-naming.EnumCase: CamelCase + readability-identifier-naming.UnionCase: CamelCase + readability-identifier-naming.TypeAliasCase: CamelCase + readability-identifier-naming.TypeAliasIgnoredRegexp: '^(const_)?(reverse_)?iterator$|^const_(reference|pointer)$|^(value|size|difference|reference|pointer)_type$' + readability-identifier-naming.UsingCase: CamelCase + readability-identifier-naming.UsingIgnoredRegexp: '^(const_)?(reverse_)?iterator$|^const_(reference|pointer)$|^(value|size|difference|reference|pointer)_type$' + readability-identifier-naming.StaticVariableCase: lower_case + readability-identifier-naming.StaticVariableSuffix: _ + readability-identifier-naming.TemplateParameterCase: CamelCase + readability-identifier-naming.EnumConstantCase: lower_case + readability-identifier-naming.ConstantCase: lower_case + readability-identifier-naming.ConstexprVariableCase: lower_case + readability-identifier-naming.ClassConstantCase: lower_case + readability-identifier-naming.StaticConstantCase: lower_case + readability-identifier-naming.GlobalConstantCase: lower_case + readability-identifier-naming.LocalConstantCase: lower_case + readability-identifier-naming.VariableCase: lower_case + readability-identifier-naming.ParameterCase: lower_case + readability-identifier-naming.LocalVariableCase: lower_case + readability-identifier-naming.MemberCase: lower_case + readability-identifier-naming.PrivateMemberSuffix: _ + readability-identifier-naming.ProtectedMemberSuffix: _ + readability-identifier-naming.FunctionCase: lower_case + readability-identifier-naming.ClassMethodCase: lower_case + readability-identifier-naming.GlobalFunctionCase: lower_case + readability-identifier-naming.NamespaceCase: lower_case + readability-identifier-naming.MacroDefinitionIgnoredRegexp: '.*' + # Qt and third-party (OFX) virtual overrides / framework callbacks keep + # their original names — renaming them would break the override. + readability-identifier-naming.FunctionIgnoredRegexp: '^(.*Event|eventFilter|sizeHint|minimumSizeHint|heightForWidth|hasHeightForWidth|initializeGL|resizeGL|paintGL|readData|writeData|readLineData|itemChange|boundingRect|sceneEvent|drawForeground|drawBackground|createEditor|setEditorData|setModelData|updateEditorGeometry|editorEvent|canFetchMore|fetchMore|mimeData|mimeTypes|dropMimeData|canDropMimeData|supportedDropActions|supportedDragActions|roleNames|connectNotify|disconnectNotify|initStyleOption|isSequential|showPopup|hidePopup|inputMethodQuery|viewportEvent|scrollContentsBy|updateGeometries|keyboardSearch|startDrag|viewOptions|setSelection|currentChanged|selectionChanged|createWidget|deleteWidget|createMimeDataFromSelection|canInsertFromMimeData|insertFromMimeData|dropIndicatorPosition|qHash|get[A-Z].*|set[A-Z].*|can[A-Z].*|calc[A-Z].*|is[A-Z].*|.*Action|new.*|addParam|multiThread.*|mutex.*|timeLine.*|editBegin|editEnd|freeMem|copyFrom|deleteKey|deleteAllKeys|makeDescriptor|initDescriptor|initParamDescriptor|loadFromPlugin|examineOutArgs|paramChangedByPlugin|saveXML|verifyMagic|pluginSupported|loadingStatus|confirmPlugin|callEntry|mainEntry|deriveV|integrateV|getV|setV|swapBuffers|loadTexture|flushOpenGLResources|clearPersistentMessage|progressStart|progressEnd|progressUpdate|beginXmlParsing|endXmlParsing|xmlCharacterHandler|xmlElementBegin|xmlElementEnd)$' + readability-identifier-naming.ClassMethodIgnoredRegexp: '^(.*Event|eventFilter|sizeHint|minimumSizeHint|heightForWidth|hasHeightForWidth|initializeGL|resizeGL|paintGL|readData|writeData|readLineData|itemChange|boundingRect|sceneEvent|drawForeground|drawBackground|createEditor|setEditorData|setModelData|updateEditorGeometry|editorEvent|canFetchMore|fetchMore|mimeData|mimeTypes|dropMimeData|canDropMimeData|supportedDropActions|supportedDragActions|roleNames|connectNotify|disconnectNotify|initStyleOption|isSequential|showPopup|hidePopup|inputMethodQuery|viewportEvent|scrollContentsBy|updateGeometries|keyboardSearch|startDrag|viewOptions|setSelection|currentChanged|selectionChanged|createWidget|deleteWidget|createMimeDataFromSelection|canInsertFromMimeData|insertFromMimeData|dropIndicatorPosition|get[A-Z].*|set[A-Z].*|can[A-Z].*|calc[A-Z].*|is[A-Z].*|.*Action|new.*|addParam|multiThread.*|mutex.*|timeLine.*|editBegin|editEnd|freeMem|copyFrom|deleteKey|deleteAllKeys|makeDescriptor|initDescriptor|initParamDescriptor|loadFromPlugin|examineOutArgs|paramChangedByPlugin|saveXML|verifyMagic|pluginSupported|loadingStatus|confirmPlugin|callEntry|mainEntry|deriveV|integrateV|getV|setV|swapBuffers|loadTexture|flushOpenGLResources|clearPersistentMessage|progressStart|progressEnd|progressUpdate|beginXmlParsing|endXmlParsing|xmlCharacterHandler|xmlElementBegin|xmlElementEnd)$' \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6fedd8155..02b6cf5c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,12 +20,15 @@ submitted should abide by the following standards: with the following project-specific exceptions and notes: * Indentation uses **tabs**, not spaces. * Documentation comments should use **Javadoc-style** (`/** ... */`) where appropriate. -* The naming rules below are retained from the original Olive codebase: - * `lowercase_underscored_variable_names` - * `lowercase_underscored_functions()` or `SentenceCaseFunctions()` - * `class SentenceCaseClassesAndStructs {}` - * `kSentenceCaseConstants` prepended with a lowercase `k` - * `UPPERCASE_UNDERSCORED_MACROS` for variables or same style as functions for macro functions - * `class_member_variables_` end with a `_` +* Naming rules (enforced by `readability-identifier-naming` in `.clang-tidy`): + * Types (`class`, `struct`, `enum`, type aliases, template parameters): `PascalCase` + * Functions, variables, member variables: `snake_case` + * Private/protected members: trailing underscore, `class_member_variables_` + * Constants and enum values: `snake_case` (e.g. `k_dry_run_interval`, `k_linear`); `ALL_CAPS` is reserved for macros — save the fear for things that are actually dangerous + * Macros: `OAK_ALL_CAPS` (project prefix), and avoid them when a constant or function will do + * File names: all lowercase, `mystring.h` / `mystring.cpp` + * Namespaces: short `snake_case` + * Getters: same name as the private member without the trailing underscore (`foo_` → `foo()`); setters: `set_foo()` + * Exception: Qt and third-party (e.g. OpenFX) virtual overrides and framework callbacks keep their original names (`paintEvent`, `getParams`, ...) — renaming them would break the override * 100 column limit (where it doesn't impair readability) * Unix line endings (only LF no CRLF) diff --git a/app/audio/audiolevelmeter.cpp b/app/audio/audiolevelmeter.cpp index af85abafb..88c4fbd10 100644 --- a/app/audio/audiolevelmeter.cpp +++ b/app/audio/audiolevelmeter.cpp @@ -29,7 +29,7 @@ namespace olive { AudioLevelMeter::Stats -AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples) +AudioLevelMeter::analyze_sample_buffer(const core::SampleBuffer &samples) { Stats stats; @@ -63,9 +63,9 @@ AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples) ChannelStats channel_stats; channel_stats.peak_linear = peak; - channel_stats.peak_db = LinearToDb(peak); + channel_stats.peak_db = linear_to_db(peak); channel_stats.rms_linear = rms; - channel_stats.rms_db = LinearToDb(rms); + channel_stats.rms_db = linear_to_db(rms); channel_stats.vu_db = channel_stats.rms_db; stats.channels[channel] = channel_stats; @@ -76,24 +76,24 @@ AudioLevelMeter::AnalyzeSampleBuffer(const core::SampleBuffer &samples) stats.silence = qFuzzyIsNull(stats.max_peak_linear); stats.integrated_lufs = - PowerToLufs(total_square / static_cast(total_samples)); + power_to_lufs(total_square / static_cast(total_samples)); return stats; } -double AudioLevelMeter::LinearToDb(double linear) +double AudioLevelMeter::linear_to_db(double linear) { if (linear <= 0.0) { - return Decibel::MINIMUM; + return Decibel::minimum; } - return Decibel::fromLinear(linear); + return Decibel::from_linear(linear); } -double AudioLevelMeter::PowerToLufs(double mean_square) +double AudioLevelMeter::power_to_lufs(double mean_square) { if (mean_square <= 0.0) { - return Decibel::MINIMUM; + return Decibel::minimum; } // BS.1770 loudness uses K-weighted mean square. This first pass stores the diff --git a/app/audio/audiolevelmeter.h b/app/audio/audiolevelmeter.h index 06d0442f8..56a2c31f1 100644 --- a/app/audio/audiolevelmeter.h +++ b/app/audio/audiolevelmeter.h @@ -18,8 +18,8 @@ ***/ -#ifndef AUDIOLEVELMETER_H -#define AUDIOLEVELMETER_H +#ifndef OAK_AUDIOLEVELMETER_H +#define OAK_AUDIOLEVELMETER_H #include @@ -45,13 +45,13 @@ public: bool silence = true; }; - static Stats AnalyzeSampleBuffer(const core::SampleBuffer &samples); + static Stats analyze_sample_buffer(const core::SampleBuffer &samples); private: - static double LinearToDb(double linear); - static double PowerToLufs(double mean_square); + static double linear_to_db(double linear); + static double power_to_lufs(double mean_square); }; } -#endif // AUDIOLEVELMETER_H +#endif // OAK_AUDIOLEVELMETER_H diff --git a/app/audio/audiomanager.cpp b/app/audio/audiomanager.cpp index 115491456..712565530 100644 --- a/app/audio/audiomanager.cpp +++ b/app/audio/audiomanager.cpp @@ -34,14 +34,14 @@ namespace olive AudioManager *AudioManager::instance_ = nullptr; -void AudioManager::CreateInstance() +void AudioManager::create_instance() { if (instance_ == nullptr) { instance_ = new AudioManager(); } } -void AudioManager::DestroyInstance() +void AudioManager::destroy_instance() { delete instance_; instance_ = nullptr; @@ -52,18 +52,18 @@ AudioManager *AudioManager::instance() return instance_; } -void AudioManager::SetOutputNotifyInterval(int n) +void AudioManager::set_output_notify_interval(int n) { output_buffer_->set_notify_interval(n); } -int OutputCallback(const void *input, void *output, unsigned long frameCount, - const PaStreamCallbackTimeInfo *timeInfo, - PaStreamCallbackFlags statusFlags, void *userData) +int output_callback(const void *input, void *output, unsigned long frame_count, + const PaStreamCallbackTimeInfo *time_info, + PaStreamCallbackFlags status_flags, void *user_data) { - PreviewAudioDevice *device = static_cast(userData); + PreviewAudioDevice *device = static_cast(user_data); - qint64 max_read = frameCount * device->bytes_per_frame(); + qint64 max_read = frame_count * device->bytes_per_frame(); qint64 read_count = device->read(reinterpret_cast(output), max_read); if (read_count < max_read) { @@ -74,23 +74,23 @@ int OutputCallback(const void *input, void *output, unsigned long frameCount, return paContinue; } -int InputCallback(const void *input, void *output, unsigned long frameCount, - const PaStreamCallbackTimeInfo *timeInfo, - PaStreamCallbackFlags statusFlags, void *userData) +int input_callback(const void *input, void *output, unsigned long frame_count, + const PaStreamCallbackTimeInfo *time_info, + PaStreamCallbackFlags status_flags, void *user_data) { - FFmpegEncoder *f = static_cast(userData); + FFmpegEncoder *f = static_cast(user_data); AudioParams our_params = f->params().audio_params(); our_params.set_format( f->params().audio_params().format().to_packed_equivalent()); - f->WriteAudioData(our_params, reinterpret_cast(&input), - frameCount); + f->write_audio_data(our_params, reinterpret_cast(&input), + frame_count); return paContinue; } -bool AudioManager::PushToOutput(const AudioParams ¶ms, +bool AudioManager::push_to_output(const AudioParams ¶ms, const QByteArray &samples, QString *error) { if (output_device_ == paNoDevice) { @@ -102,14 +102,14 @@ bool AudioManager::PushToOutput(const AudioParams ¶ms, if (output_params_ != params || output_stream_ == nullptr) { output_params_ = params; - CloseOutputStream(); + close_output_stream(); - PaStreamParameters p = GetPortAudioParams(params, output_device_); + PaStreamParameters p = get_port_audio_params(params, output_device_); PaError r = Pa_OpenStream(&output_stream_, nullptr, &p, output_params_.sample_rate(), paFramesPerBufferUnspecified, paNoFlag, - OutputCallback, output_buffer_); + output_callback, output_buffer_); if (r != paNoError) { // Unhandled error //qCritical() << "Failed to open output stream:" << Pa_GetErrorText(r); @@ -136,59 +136,59 @@ bool AudioManager::PushToOutput(const AudioParams ¶ms, return true; } -void AudioManager::ClearBufferedOutput() +void AudioManager::clear_buffered_output() { output_buffer_->clear(); } -PaSampleFormat AudioManager::GetPortAudioSampleFormat(SampleFormat fmt) +PaSampleFormat AudioManager::get_port_audio_sample_format(SampleFormat fmt) { switch (fmt) { - case SampleFormat::U8: - case SampleFormat::U8P: + case SampleFormat::u8: + case SampleFormat::u8_p: return paUInt8; - case SampleFormat::S16: - case SampleFormat::S16P: + case SampleFormat::s16: + case SampleFormat::s16_p: return paInt16; - case SampleFormat::S32: - case SampleFormat::S32P: + case SampleFormat::s32: + case SampleFormat::s32_p: return paInt32; - case SampleFormat::F32: - case SampleFormat::F32P: + case SampleFormat::f32: + case SampleFormat::f32_p: return paFloat32; - case SampleFormat::S64: - case SampleFormat::S64P: - case SampleFormat::F64: - case SampleFormat::F64P: - case SampleFormat::INVALID: - case SampleFormat::COUNT: + case SampleFormat::s64: + case SampleFormat::s64_p: + case SampleFormat::f64: + case SampleFormat::f64_p: + case SampleFormat::invalid: + case SampleFormat::count: break; } return 0; } -void AudioManager::CloseOutputStream() +void AudioManager::close_output_stream() { if (output_stream_) { if (Pa_IsStreamActive(output_stream_)) { - StopOutput(); + stop_output(); } Pa_CloseStream(output_stream_); output_stream_ = nullptr; } } -void AudioManager::StopOutput() +void AudioManager::stop_output() { // Abort the stream so playback stops immediately if (output_stream_) { Pa_AbortStream(output_stream_); - ClearBufferedOutput(); + clear_buffered_output(); } } -void AudioManager::SetOutputDevice(PaDeviceIndex device) +void AudioManager::set_output_device(PaDeviceIndex device) { if (device == paNoDevice) { qInfo() << "No output device found"; @@ -201,12 +201,12 @@ void AudioManager::SetOutputDevice(PaDeviceIndex device) output_device_ = device; - CloseOutputStream(); + close_output_stream(); - emit OutputParamsChanged(); + emit output_params_changed(); } -void AudioManager::SetInputDevice(PaDeviceIndex device) +void AudioManager::set_input_device(PaDeviceIndex device) { if (device == paNoDevice) { qInfo() << "No input device found"; @@ -220,14 +220,14 @@ void AudioManager::SetInputDevice(PaDeviceIndex device) input_device_ = device; } -void AudioManager::HardReset() +void AudioManager::hard_reset() { - CloseOutputStream(); + close_output_stream(); Pa_Terminate(); Pa_Initialize(); } -bool AudioManager::StartRecording(const EncodingParams ¶ms, +bool AudioManager::start_recording(const EncodingParams ¶ms, QString *error_str) { if (input_device_ == paNoDevice) { @@ -235,18 +235,18 @@ bool AudioManager::StartRecording(const EncodingParams ¶ms, } input_encoder_ = new FFmpegEncoder(params); - if (!input_encoder_->Open()) { + if (!input_encoder_->open()) { qCritical() << "Failed to open encoder for recording"; return false; } PaStreamParameters p = - GetPortAudioParams(params.audio_params(), input_device_); + get_port_audio_params(params.audio_params(), input_device_); PaError r = Pa_OpenStream(&input_stream_, &p, nullptr, params.audio_params().sample_rate(), paFramesPerBufferUnspecified, paNoFlag, - InputCallback, input_encoder_); + input_callback, input_encoder_); if (r == paNoError) { //const PaStreamInfo* info = Pa_GetStreamInfo(input_stream_); r = Pa_StartStream(input_stream_); @@ -259,11 +259,11 @@ bool AudioManager::StartRecording(const EncodingParams ¶ms, *error_str = Pa_GetErrorText(r); } - StopRecording(); + stop_recording(); return false; } -void AudioManager::StopRecording() +void AudioManager::stop_recording() { if (input_stream_) { if (Pa_IsStreamActive(input_stream_)) { @@ -275,14 +275,14 @@ void AudioManager::StopRecording() } if (input_encoder_) { - input_encoder_->Close(); + input_encoder_->close(); delete input_encoder_; input_encoder_ = nullptr; } } #ifdef Q_OS_LINUX -static bool IsPreferredLinuxAudioHostApi(const PaHostApiInfo *info) +static bool is_preferred_linux_audio_host_api(const PaHostApiInfo *info) { if (!info) { return false; @@ -294,7 +294,7 @@ static bool IsPreferredLinuxAudioHostApi(const PaHostApiInfo *info) name.contains(QStringLiteral("PulseAudio"), Qt::CaseInsensitive); } -static PaDeviceIndex GetPreferredLinuxAudioDevice(bool is_output_device) +static PaDeviceIndex get_preferred_linux_audio_device(bool is_output_device) { // Prefer sound servers that provide mixing and desktop integration // (PipeWire, JACK, PulseAudio) over plain ALSA defaults, which often @@ -328,16 +328,16 @@ static PaDeviceIndex GetPreferredLinuxAudioDevice(bool is_output_device) } #endif -PaDeviceIndex AudioManager::FindConfigDeviceByName(bool is_output_device) +PaDeviceIndex AudioManager::find_config_device_by_name(bool is_output_device) { QString entry = is_output_device ? QStringLiteral("AudioOutput") : QStringLiteral("AudioInput"); - return FindDeviceByName(OLIVE_CONFIG_STR(entry).toString(), + return find_device_by_name(OAK_CONFIG_STR(entry).toString(), is_output_device); } -PaDeviceIndex AudioManager::FindDeviceByName(const QString &s, +PaDeviceIndex AudioManager::find_device_by_name(const QString &s, bool is_output_device) { PaDeviceIndex exact_match = paNoDevice; @@ -367,7 +367,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s, if (matched_info) { const PaHostApiInfo *host_api = Pa_GetHostApiInfo(matched_info->hostApi); - if (IsPreferredLinuxAudioHostApi(host_api)) { + if (is_preferred_linux_audio_host_api(host_api)) { // Keep an explicit choice that already uses a preferred API. return exact_match; } @@ -375,7 +375,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s, // Upgrade a non-preferred (e.g. ALSA) match to a preferred backend // when one is available. PaDeviceIndex preferred = - GetPreferredLinuxAudioDevice(is_output_device); + get_preferred_linux_audio_device(is_output_device); if (preferred != paNoDevice) { qInfo() << "Overriding saved audio device" << s << "with preferred Linux audio device" @@ -388,7 +388,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s, } } - return GetPreferredLinuxAudioDevice(is_output_device); + return get_preferred_linux_audio_device(is_output_device); #else if (exact_match != paNoDevice) { return exact_match; @@ -399,7 +399,7 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s, #endif } -PaStreamParameters AudioManager::GetPortAudioParams(const AudioParams ¶ms, +PaStreamParameters AudioManager::get_port_audio_params(const AudioParams ¶ms, PaDeviceIndex device) { PaStreamParameters p; @@ -407,7 +407,7 @@ PaStreamParameters AudioManager::GetPortAudioParams(const AudioParams ¶ms, p.channelCount = params.channel_count(); p.device = device; p.hostApiSpecificStreamInfo = nullptr; - p.sampleFormat = GetPortAudioSampleFormat(params.format()); + p.sampleFormat = get_port_audio_sample_format(params.format()); if (device >= 0 && device < Pa_GetDeviceCount()) { p.suggestedLatency = Pa_GetDeviceInfo(device)->defaultLowOutputLatency; @@ -432,24 +432,24 @@ AudioManager::AudioManager() Pa_Initialize(); // Get device from config - PaDeviceIndex output_device = FindConfigDeviceByName(true); - PaDeviceIndex input_device = FindConfigDeviceByName(false); + PaDeviceIndex output_device = find_config_device_by_name(true); + PaDeviceIndex input_device = find_config_device_by_name(false); qDebug() << "AudioManager: selected output device index=" << output_device << "input device index=" << input_device; - SetOutputDevice(output_device); - SetInputDevice(input_device); + set_output_device(output_device); + set_input_device(input_device); output_buffer_ = new PreviewAudioDevice(this); output_buffer_->open(PreviewAudioDevice::ReadWrite); - connect(output_buffer_, &PreviewAudioDevice::Notify, this, - &AudioManager::OutputNotify); + connect(output_buffer_, &PreviewAudioDevice::notify, this, + &AudioManager::output_notify); } AudioManager::~AudioManager() { - CloseOutputStream(); + close_output_stream(); Pa_Terminate(); } diff --git a/app/audio/audiomanager.h b/app/audio/audiomanager.h index 86ea5ed31..24245a1af 100644 --- a/app/audio/audiomanager.h +++ b/app/audio/audiomanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUDIOMANAGER_H -#define AUDIOMANAGER_H +#ifndef OAK_AUDIOMANAGER_H +#define OAK_AUDIOMANAGER_H #include #include @@ -46,61 +46,61 @@ namespace olive class AudioManager : public QObject { Q_OBJECT public: - static void CreateInstance(); - static void DestroyInstance(); + static void create_instance(); + static void destroy_instance(); static AudioManager *instance(); - void SetOutputNotifyInterval(int n); + void set_output_notify_interval(int n); - bool PushToOutput(const AudioParams ¶ms, const QByteArray &samples, + bool push_to_output(const AudioParams ¶ms, const QByteArray &samples, QString *error = nullptr); - void ClearBufferedOutput(); + void clear_buffered_output(); - void StopOutput(); + void stop_output(); - PaDeviceIndex GetOutputDevice() const + PaDeviceIndex get_output_device() const { return output_device_; } - PaDeviceIndex GetInputDevice() const + PaDeviceIndex get_input_device() const { return input_device_; } - void SetOutputDevice(PaDeviceIndex device); + void set_output_device(PaDeviceIndex device); - void SetInputDevice(PaDeviceIndex device); + void set_input_device(PaDeviceIndex device); - void HardReset(); + void hard_reset(); - bool StartRecording(const EncodingParams ¶ms, + bool start_recording(const EncodingParams ¶ms, QString *error_str = nullptr); - void StopRecording(); + void stop_recording(); - static PaDeviceIndex FindConfigDeviceByName(bool is_output_device); - static PaDeviceIndex FindDeviceByName(const QString &s, + static PaDeviceIndex find_config_device_by_name(bool is_output_device); + static PaDeviceIndex find_device_by_name(const QString &s, bool is_output_device); - static PaStreamParameters GetPortAudioParams(const AudioParams &p, + static PaStreamParameters get_port_audio_params(const AudioParams &p, PaDeviceIndex device); signals: - void OutputNotify(); + void output_notify(); - void OutputParamsChanged(); + void output_params_changed(); private: AudioManager(); virtual ~AudioManager() override; - static PaSampleFormat GetPortAudioSampleFormat(SampleFormat fmt); + static PaSampleFormat get_port_audio_sample_format(SampleFormat fmt); - void CloseOutputStream(); + void close_output_stream(); static AudioManager *instance_; @@ -117,4 +117,4 @@ private: } -#endif // AUDIOMANAGER_H +#endif // OAK_AUDIOMANAGER_H diff --git a/app/audio/audioprocessor.cpp b/app/audio/audioprocessor.cpp index be6113f7a..a6e4dd60e 100644 --- a/app/audio/audioprocessor.cpp +++ b/app/audio/audioprocessor.cpp @@ -38,7 +38,7 @@ namespace olive * If the mask is zero, fall back to a default layout derived from the * channel count (stereo when unknown). */ -static AudioParams FixChannelLayout(const AudioParams ¶ms) +static AudioParams fix_channel_layout(const AudioParams ¶ms) { AudioParams result = params; @@ -66,10 +66,10 @@ AudioProcessor::AudioProcessor() AudioProcessor::~AudioProcessor() { - Close(); + close(); } -bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to, +bool AudioProcessor::open(const AudioParams &from, const AudioParams &to, double tempo) { if (graph_) { @@ -77,8 +77,8 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to, return false; } - AudioParams from_fixed = FixChannelLayout(from); - AudioParams to_fixed = FixChannelLayout(to); + AudioParams from_fixed = fix_channel_layout(from); + AudioParams to_fixed = fix_channel_layout(to); qDebug() << "AudioProcessor::Open: from sample_rate=" << from_fixed.sample_rate() << "channels=" @@ -92,13 +92,13 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to, config.in_sample_rate = from_fixed.sample_rate(); config.in_channel_layout_mask = from_fixed.channel_layout(); config.in_sample_format = - FFmpegUtils::GetFFmpegSampleFormat(from_fixed.format()); + FFmpegUtils::get_f_fmpeg_sample_format(from_fixed.format()); config.in_channels = from_fixed.channel_count(); config.out_sample_rate = to_fixed.sample_rate(); config.out_channel_layout_mask = to_fixed.channel_layout(); config.out_sample_format = - FFmpegUtils::GetFFmpegSampleFormat(to_fixed.format()); + FFmpegUtils::get_f_fmpeg_sample_format(to_fixed.format()); config.out_channels = to_fixed.channel_count(); config.out_is_planar = to_fixed.format().is_planar() ? 1 : 0; @@ -113,7 +113,7 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to, out_frame_ = fb_frame_alloc(); if (!out_frame_) { qCritical() << "Failed to allocate output frame"; - Close(); + close(); return false; } @@ -123,7 +123,7 @@ bool AudioProcessor::Open(const AudioParams &from, const AudioParams &to, return true; } -void AudioProcessor::Close() +void AudioProcessor::close() { if (graph_) { fb_audio_graph_free(&graph_); @@ -134,10 +134,10 @@ void AudioProcessor::Close() } } -int AudioProcessor::Convert(float **in, int nb_in_samples, +int AudioProcessor::convert(float **in, int nb_in_samples, AudioProcessor::Buffer *output) { - if (!IsOpen()) { + if (!is_open()) { qCritical() << "Tried to convert on closed processor"; return -1; } @@ -197,7 +197,7 @@ int AudioProcessor::Convert(float **in, int nb_in_samples, return r; } -void AudioProcessor::Flush() +void AudioProcessor::flush() { int r = fb_audio_graph_push(graph_, nullptr, 0); if (r < 0) { diff --git a/app/audio/audioprocessor.h b/app/audio/audioprocessor.h index a5e88c112..bc08a7fec 100644 --- a/app/audio/audioprocessor.h +++ b/app/audio/audioprocessor.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUDIOPROCESSOR_H -#define AUDIOPROCESSOR_H +#ifndef OAK_AUDIOPROCESSOR_H +#define OAK_AUDIOPROCESSOR_H #include #include @@ -43,20 +43,20 @@ public: DISABLE_COPY_MOVE(AudioProcessor) - bool Open(const AudioParams &from, const AudioParams &to, + bool open(const AudioParams &from, const AudioParams &to, double tempo = 1.0); - void Close(); + void close(); - bool IsOpen() const + bool is_open() const { return graph_; } using Buffer = QVector; - int Convert(float **in, int nb_in_samples, AudioProcessor::Buffer *output); + int convert(float **in, int nb_in_samples, AudioProcessor::Buffer *output); - void Flush(); + void flush(); const AudioParams &from() const { @@ -79,4 +79,4 @@ private: } -#endif // AUDIOPROCESSOR_H +#endif // OAK_AUDIOPROCESSOR_H diff --git a/app/audio/audiosynchronizer.cpp b/app/audio/audiosynchronizer.cpp index 7ce2e9a32..c5c81443a 100644 --- a/app/audio/audiosynchronizer.cpp +++ b/app/audio/audiosynchronizer.cpp @@ -23,9 +23,9 @@ namespace olive { -AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime( +AudioSynchronizer::Placement AudioSynchronizer::place_by_source_time( const SourceClip &reference, const SourceClip &candidate, - const core::rational &reference_timeline_in) + const core::Rational &reference_timeline_in) { Placement placement; if (!reference.has_source_start_time || !candidate.has_source_start_time || @@ -34,9 +34,9 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime( return placement; } - const core::rational reference_head_source = + const core::Rational reference_head_source = reference.source_start_time + reference.media_in; - const core::rational candidate_head_source = + const core::Rational candidate_head_source = candidate.source_start_time + candidate.media_in; placement.timeline_in = @@ -45,8 +45,8 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceBySourceTime( return placement; } -AudioSynchronizer::Placement AudioSynchronizer::PlaceByWaveformOffset( - const core::rational &reference_timeline_in, +AudioSynchronizer::Placement AudioSynchronizer::place_by_waveform_offset( + const core::Rational &reference_timeline_in, int64_t candidate_offset_samples, int sample_rate) { Placement placement; @@ -55,7 +55,7 @@ AudioSynchronizer::Placement AudioSynchronizer::PlaceByWaveformOffset( } placement.timeline_in = reference_timeline_in + - core::rational::fromDouble( + core::Rational::from_double( static_cast(candidate_offset_samples) / static_cast(sample_rate)); placement.valid = !placement.timeline_in.isNaN(); diff --git a/app/audio/audiosynchronizer.h b/app/audio/audiosynchronizer.h index f32b6665b..96d5a0626 100644 --- a/app/audio/audiosynchronizer.h +++ b/app/audio/audiosynchronizer.h @@ -18,8 +18,8 @@ ***/ -#ifndef AUDIOSYNCHRONIZER_H -#define AUDIOSYNCHRONIZER_H +#ifndef OAK_AUDIOSYNCHRONIZER_H +#define OAK_AUDIOSYNCHRONIZER_H #include @@ -31,25 +31,25 @@ namespace olive class AudioSynchronizer { public: struct SourceClip { - core::rational source_start_time; - core::rational media_in; + core::Rational source_start_time; + core::Rational media_in; bool has_source_start_time = false; }; struct Placement { - core::rational timeline_in; + core::Rational timeline_in; bool valid = false; }; static Placement - PlaceBySourceTime(const SourceClip &reference, const SourceClip &candidate, - const core::rational &reference_timeline_in); + place_by_source_time(const SourceClip &reference, const SourceClip &candidate, + const core::Rational &reference_timeline_in); static Placement - PlaceByWaveformOffset(const core::rational &reference_timeline_in, + place_by_waveform_offset(const core::Rational &reference_timeline_in, int64_t candidate_offset_samples, int sample_rate); }; } -#endif // AUDIOSYNCHRONIZER_H +#endif // OAK_AUDIOSYNCHRONIZER_H diff --git a/app/audio/audiovisualwaveform.cpp b/app/audio/audiovisualwaveform.cpp index 95a3544e7..148b20afa 100644 --- a/app/audio/audiovisualwaveform.cpp +++ b/app/audio/audiovisualwaveform.cpp @@ -29,19 +29,19 @@ namespace olive { -const rational AudioVisualWaveform::kMinimumSampleRate = rational(1, 8); -const rational AudioVisualWaveform::kMaximumSampleRate = 1024; +const Rational AudioVisualWaveform::k_minimum_sample_rate = Rational(1, 8); +const Rational AudioVisualWaveform::k_maximum_sample_rate = 1024; AudioVisualWaveform::AudioVisualWaveform() : channels_(0) { - for (rational i = kMinimumSampleRate; i <= kMaximumSampleRate; i *= 2) { + for (Rational i = k_minimum_sample_rate; i <= k_maximum_sample_rate; i *= 2) { mipmapped_data_.insert({ i, Sample() }); } } -void AudioVisualWaveform::OverwriteSamplesFromBuffer( - const SampleBuffer &samples, int sample_rate, const rational &start, +void AudioVisualWaveform::overwrite_samples_from_buffer( + const SampleBuffer &samples, int sample_rate, const Rational &start, double target_rate, Sample &data, size_t &start_index, size_t &samples_length) { @@ -64,16 +64,16 @@ void AudioVisualWaveform::OverwriteSamplesFromBuffer( size_t(qRound64((double(i + channels_) * chunk_size))) / channels_, samples.sample_count()); - Sample summary = SumSamples(samples, src_start, src_end - src_start); + Sample summary = sum_samples(samples, src_start, src_end - src_start); memcpy(&data.data()[i + start_index], summary.data(), summary.size() * sizeof(SamplePerChannel)); } } -void AudioVisualWaveform::OverwriteSamplesFromMipmap( +void AudioVisualWaveform::overwrite_samples_from_mipmap( const AudioVisualWaveform::Sample &input, double input_sample_rate, - size_t &input_start, size_t &input_length, const rational &start, + size_t &input_start, size_t &input_length, const Rational &start, double output_rate, AudioVisualWaveform::Sample &output_data) { size_t start_index = time_to_samples(start, output_rate); @@ -91,7 +91,7 @@ void AudioVisualWaveform::OverwriteSamplesFromMipmap( for (size_t i = 0; i < samples_length; i += channels_) { Sample summary = - ReSumSamples(&input.data()[input_start + (i * chunk_size)], + re_sum_samples(&input.data()[input_start + (i * chunk_size)], chunk_size * channels_, channels_); memcpy(&output_data.data()[i + start_index], summary.data(), @@ -102,31 +102,31 @@ void AudioVisualWaveform::OverwriteSamplesFromMipmap( input_length = samples_length; } -void AudioVisualWaveform::ValidateVirtualStart(const rational &new_start) +void AudioVisualWaveform::validate_virtual_start(const Rational &new_start) { if (length_ == 0) { virtual_start_ = new_start; } else if (virtual_start_ > new_start) { - TrimIn(new_start - virtual_start_); + trim_in(new_start - virtual_start_); } } -void AudioVisualWaveform::OverwriteSamples(const SampleBuffer &samples, +void AudioVisualWaveform::overwrite_samples(const SampleBuffer &samples, int sample_rate, - const rational &start) + const Rational &start) { if (!channels_) { qWarning() << "Failed to write samples - channel count is zero"; return; } - ValidateVirtualStart(start); + validate_virtual_start(start); // Process the largest mipmap directly for the samples auto current_mipmap = mipmapped_data_.rbegin(); size_t input_start, input_length; - OverwriteSamplesFromBuffer(samples, sample_rate, start - virtual_start_, - current_mipmap->first.toDouble(), + overwrite_samples_from_buffer(samples, sample_rate, start - virtual_start_, + current_mipmap->first.to_double(), current_mipmap->second, input_start, input_length); @@ -139,37 +139,37 @@ void AudioVisualWaveform::OverwriteSamples(const SampleBuffer &samples, break; } - OverwriteSamplesFromMipmap( - previous_mipmap->second, previous_mipmap->first.toDouble(), + overwrite_samples_from_mipmap( + previous_mipmap->second, previous_mipmap->first.to_double(), input_start, input_length, start - virtual_start_, - current_mipmap->first.toDouble(), current_mipmap->second); + current_mipmap->first.to_double(), current_mipmap->second); } - rational sample_length(samples.sample_count(), sample_rate); + Rational sample_length(samples.sample_count(), sample_rate); length_ = qMax(length_, start + sample_length); } -void AudioVisualWaveform::OverwriteSums(const AudioVisualWaveform &sums, - const rational &dest, - const rational &offset, - const rational &length) +void AudioVisualWaveform::overwrite_sums(const AudioVisualWaveform &sums, + const Rational &dest, + const Rational &offset, + const Rational &length) { - ValidateVirtualStart(dest); + validate_virtual_start(dest); for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) { - rational rate = it->first; + Rational rate = it->first; Sample &our_arr = it->second; const Sample &their_arr = sums.mipmapped_data_.at(rate); - double rate_dbl = rate.toDouble(); + double rate_dbl = rate.to_double(); // Get our destination sample size_t our_start_index = time_to_samples(dest - virtual_start_, rate_dbl); // Get our source sample, indexing with the SOURCE's channel count - size_t their_start_index = std::floor(offset.toDouble() * rate_dbl) * + size_t their_start_index = std::floor(offset.to_double() * rate_dbl) * sums.channel_count(); if (their_start_index >= their_arr.size()) { continue; @@ -201,17 +201,17 @@ void AudioVisualWaveform::OverwriteSums(const AudioVisualWaveform &sums, length)); } -void AudioVisualWaveform::OverwriteSilence(const rational &start, - const rational &length) +void AudioVisualWaveform::overwrite_silence(const Rational &start, + const Rational &length) { - ValidateVirtualStart(start); + validate_virtual_start(start); for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) { - rational rate = it->first; + Rational rate = it->first; Sample &our_arr = it->second; - double rate_dbl = rate.toDouble(); + double rate_dbl = rate.to_double(); // Get our destination sample size_t our_start_index = @@ -231,7 +231,7 @@ void AudioVisualWaveform::OverwriteSilence(const rational &start, length_ = qMax(length_, start + length); } -void AudioVisualWaveform::TrimIn(rational length) +void AudioVisualWaveform::trim_in(Rational length) { if (length == 0) { return; @@ -245,8 +245,8 @@ void AudioVisualWaveform::TrimIn(rational length) } for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) { - rational rate = it->first; - double rate_dbl = rate.toDouble(); + Rational rate = it->first; + double rate_dbl = rate.to_double(); Sample &data = it->second; size_t chop_length = time_to_samples(length, rate_dbl); @@ -262,40 +262,40 @@ void AudioVisualWaveform::TrimIn(rational length) } if (!negative) { - length_ = qMax(rational(0), length_ - length); + length_ = qMax(Rational(0), length_ - length); } // Prepending grows the data before the existing start, so the absolute // end (which length_ tracks) is unchanged } -AudioVisualWaveform AudioVisualWaveform::Mid(const rational &offset) const +AudioVisualWaveform AudioVisualWaveform::mid(const Rational &offset) const { AudioVisualWaveform mid = *this; - mid.TrimIn(offset - virtual_start_); + mid.trim_in(offset - virtual_start_); return mid; } -AudioVisualWaveform AudioVisualWaveform::Mid(const rational &offset, - const rational &length) const +AudioVisualWaveform AudioVisualWaveform::mid(const Rational &offset, + const Rational &length) const { AudioVisualWaveform mid = *this; - mid.TrimRange(offset - virtual_start_, length); + mid.trim_range(offset - virtual_start_, length); return mid; } -void AudioVisualWaveform::Resize(const rational &length) +void AudioVisualWaveform::resize(const Rational &length) { if (length_ == length) { return; } for (auto it = mipmapped_data_.begin(); it != mipmapped_data_.end(); it++) { - rational rate = it->first; - double rate_dbl = rate.toDouble(); + Rational rate = it->first; + double rate_dbl = rate.to_double(); Sample &data = it->second; size_t chop_length = time_to_samples(length, rate_dbl); @@ -306,20 +306,20 @@ void AudioVisualWaveform::Resize(const rational &length) length_ = length; } -void AudioVisualWaveform::TrimRange(const rational &in, const rational &length) +void AudioVisualWaveform::trim_range(const Rational &in, const Rational &length) { - TrimIn(in); - Resize(length); + trim_in(in); + resize(length); } AudioVisualWaveform::Sample -AudioVisualWaveform::GetSummaryFromTime(const rational &start, - const rational &length) const +AudioVisualWaveform::get_summary_from_time(const Rational &start, + const Rational &length) const { // Find mipmap that requires - auto using_mipmap = GetMipmapForScale(length.flipped().toDouble()); + auto using_mipmap = get_mipmap_for_scale(length.flipped().to_double()); - double rate_dbl = using_mipmap->first.toDouble(); + double rate_dbl = using_mipmap->first.to_double(); size_t start_sample = time_to_samples(start - virtual_start_, rate_dbl); size_t sample_length = time_to_samples(length, rate_dbl); @@ -333,7 +333,7 @@ AudioVisualWaveform::GetSummaryFromTime(const rational &start, sample_length = qMin(sample_length, size_t(available)); if (sample_length > 0) { - return ReSumSamples(&mipmap_data.data()[start_sample], + return re_sum_samples(&mipmap_data.data()[start_sample], sample_length, channels_); } } @@ -342,7 +342,7 @@ AudioVisualWaveform::GetSummaryFromTime(const rational &start, return AudioVisualWaveform::Sample(channel_count(), { 0, 0 }); } -void ExpandMinMaxChannel(const float *a, size_t length, float &min_val, +void expand_min_max_channel(const float *a, size_t length, float &min_val, float &max_val) { #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) @@ -387,7 +387,7 @@ void ExpandMinMaxChannel(const float *a, size_t length, float &min_val, } AudioVisualWaveform::Sample -AudioVisualWaveform::SumSamples(const SampleBuffer &samples, size_t start_index, +AudioVisualWaveform::sum_samples(const SampleBuffer &samples, size_t start_index, size_t length) { int channels = samples.audio_params().channel_count(); @@ -395,7 +395,7 @@ AudioVisualWaveform::SumSamples(const SampleBuffer &samples, size_t start_index, for (int channel = 0; channel < samples.audio_params().channel_count(); channel++) { - ExpandMinMaxChannel(samples.data(channel) + start_index, length, + expand_min_max_channel(samples.data(channel) + start_index, length, summed_samples[channel].min, summed_samples[channel].max); } @@ -409,7 +409,7 @@ AudioVisualWaveform::SumSamples(const SampleBuffer &samples, size_t start_index, } AudioVisualWaveform::Sample -AudioVisualWaveform::ReSumSamples(const SamplePerChannel *samples, +AudioVisualWaveform::re_sum_samples(const SamplePerChannel *samples, size_t nb_samples, int nb_channels) { AudioVisualWaveform::Sample summed_samples(nb_channels); @@ -437,7 +437,7 @@ template inline int round_away_from_zero(T t) return (t < 0) ? std::floor(t) : std::ceil(t); } -void AudioVisualWaveform::DrawSample(QPainter *painter, const Sample &sample, +void AudioVisualWaveform::draw_sample(QPainter *painter, const Sample &sample, int x, int y, int height, bool rectified) { if (sample.empty()) { @@ -475,19 +475,19 @@ void AudioVisualWaveform::DrawSample(QPainter *painter, const Sample &sample, } } -void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect, +void AudioVisualWaveform::draw_waveform(QPainter *painter, const QRect &rect, const double &scale, const AudioVisualWaveform &samples, - const rational &start_time) + const Rational &start_time) { if (samples.mipmapped_data_.empty()) { return; } - auto using_mipmap = samples.GetMipmapForScale(scale); + auto using_mipmap = samples.get_mipmap_for_scale(scale); - rational rate = using_mipmap->first; - double rate_dbl = rate.toDouble(); + Rational rate = using_mipmap->first; + double rate_dbl = rate.to_double(); const Sample &arr = using_mipmap->second; size_t start_sample_index = @@ -509,7 +509,7 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect, size_t start = qMax(rect.x(), -top_left.x()); size_t end = qMin(rect.right(), -top_left.x() + viewport.width()); - bool rectified = OLIVE_CONFIG("RectifiedWaveforms").toBool(); + bool rectified = OAK_CONFIG("RectifiedWaveforms").toBool(); for (size_t i = start; i < end; i++) { sample_index = next_sample_index; @@ -526,7 +526,7 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect, samples.channel_count())); if (summary_index != sample_index) { - summary = AudioVisualWaveform::ReSumSamples( + summary = AudioVisualWaveform::re_sum_samples( &arr.at(sample_index), qMax(size_t(samples.channel_count()), next_sample_index - sample_index), @@ -534,14 +534,14 @@ void AudioVisualWaveform::DrawWaveform(QPainter *painter, const QRect &rect, summary_index = sample_index; } - DrawSample(painter, summary, i, rect.y(), rect.height(), rectified); + draw_sample(painter, summary, i, rect.y(), rect.height(), rectified); } } -size_t AudioVisualWaveform::time_to_samples(const rational &time, +size_t AudioVisualWaveform::time_to_samples(const Rational &time, double sample_rate) const { - return time_to_samples(time.toDouble(), sample_rate); + return time_to_samples(time.to_double(), sample_rate); } size_t AudioVisualWaveform::time_to_samples(const double &time, @@ -550,13 +550,13 @@ size_t AudioVisualWaveform::time_to_samples(const double &time, return std::floor(time * sample_rate) * channels_; } -std::map::const_iterator -AudioVisualWaveform::GetMipmapForScale(double scale) const +std::map::const_iterator +AudioVisualWaveform::get_mipmap_for_scale(double scale) const { // Find largest mipmap for this scale (or the largest if we don't find one sufficient) for (auto it = mipmapped_data_.cbegin(); it != mipmapped_data_.cend(); it++) { - if (it->first.toDouble() >= scale) { + if (it->first.to_double() >= scale) { return it; } } diff --git a/app/audio/audiovisualwaveform.h b/app/audio/audiovisualwaveform.h index 860c0bdc8..267eaf6a1 100644 --- a/app/audio/audiovisualwaveform.h +++ b/app/audio/audiovisualwaveform.h @@ -19,8 +19,8 @@ ***/ -#ifndef SUMSAMPLES_H -#define SUMSAMPLES_H +#ifndef OAK_SUMSAMPLES_H +#define OAK_SUMSAMPLES_H #include #include @@ -58,7 +58,7 @@ public: channels_ = channels; } - const rational &length() const + const Rational &length() const { return length_; } @@ -68,8 +68,8 @@ public: * * Starting at `start`, writes samples over anything in the buffer, expanding it if necessary. */ - void OverwriteSamples(const SampleBuffer &samples, int sample_rate, - const rational &start = 0); + void overwrite_samples(const SampleBuffer &samples, int sample_rate, + const Rational &start = 0); /** * @brief Replaces sums at a certain range in this visual waveform @@ -90,74 +90,74 @@ public: * * Maximum length of `sums` to overwrite with. */ - void OverwriteSums(const AudioVisualWaveform &sums, const rational &dest, - const rational &offset = 0, const rational &length = 0); + void overwrite_sums(const AudioVisualWaveform &sums, const Rational &dest, + const Rational &offset = 0, const Rational &length = 0); - void OverwriteSilence(const rational &start, const rational &length); + void overwrite_silence(const Rational &start, const Rational &length); - void TrimIn(rational length); + void trim_in(Rational length); - AudioVisualWaveform Mid(const rational &offset) const; - AudioVisualWaveform Mid(const rational &offset, - const rational &length) const; + AudioVisualWaveform mid(const Rational &offset) const; + AudioVisualWaveform mid(const Rational &offset, + const Rational &length) const; - void Resize(const rational &length); + void resize(const Rational &length); - void TrimRange(const rational &in, const rational &length); + void trim_range(const Rational &in, const Rational &length); - Sample GetSummaryFromTime(const rational &start, - const rational &length) const; + Sample get_summary_from_time(const Rational &start, + const Rational &length) const; - static Sample SumSamples(const SampleBuffer &samples, size_t start_index, + static Sample sum_samples(const SampleBuffer &samples, size_t start_index, size_t length); - static Sample ReSumSamples(const SamplePerChannel *samples, + static Sample re_sum_samples(const SamplePerChannel *samples, size_t nb_samples, int nb_channels); - static void DrawSample(QPainter *painter, const Sample &sample, int x, + static void draw_sample(QPainter *painter, const Sample &sample, int x, int y, int height, bool rectified); - static void DrawWaveform(QPainter *painter, const QRect &rect, + static void draw_waveform(QPainter *painter, const QRect &rect, const double &scale, const AudioVisualWaveform &samples, - const rational &start_time); + const Rational &start_time); // Must be a power of 2 - static const rational kMinimumSampleRate; - static const rational kMaximumSampleRate; + static const Rational k_minimum_sample_rate; + static const Rational k_maximum_sample_rate; private: - void OverwriteSamplesFromBuffer(const SampleBuffer &samples, - int sample_rate, const rational &start, + void overwrite_samples_from_buffer(const SampleBuffer &samples, + int sample_rate, const Rational &start, double target_rate, Sample &data, size_t &start_index, size_t &samples_length); - void OverwriteSamplesFromMipmap(const Sample &input, + void overwrite_samples_from_mipmap(const Sample &input, double input_sample_rate, size_t &input_start, size_t &input_length, - const rational &start, double output_rate, + const Rational &start, double output_rate, Sample &output_data); - size_t time_to_samples(const rational &time, double sample_rate) const; + size_t time_to_samples(const Rational &time, double sample_rate) const; size_t time_to_samples(const double &time, double sample_rate) const; - std::map::const_iterator - GetMipmapForScale(double scale) const; + std::map::const_iterator + get_mipmap_for_scale(double scale) const; - void ValidateVirtualStart(const rational &new_start); + void validate_virtual_start(const Rational &new_start); - rational virtual_start_; + Rational virtual_start_; int channels_; - std::map mipmapped_data_; + std::map mipmapped_data_; - rational length_; + Rational length_; }; } Q_DECLARE_METATYPE(olive::AudioVisualWaveform) -#endif // SUMSAMPLES_H +#endif // OAK_SUMSAMPLES_H diff --git a/app/audio/audiowaveformsync.cpp b/app/audio/audiowaveformsync.cpp index 033b25767..5b7d341d3 100644 --- a/app/audio/audiowaveformsync.cpp +++ b/app/audio/audiowaveformsync.cpp @@ -27,7 +27,7 @@ namespace olive { QVector -AudioWaveformSync::ExtractRmsEnvelope(const core::SampleBuffer &samples, +AudioWaveformSync::extract_rms_envelope(const core::SampleBuffer &samples, size_t window_samples) { QVector envelope; @@ -64,7 +64,7 @@ AudioWaveformSync::ExtractRmsEnvelope(const core::SampleBuffer &samples, return envelope; } -AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateOffset( +AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_offset( const core::SampleBuffer &reference, const core::SampleBuffer &candidate, size_t window_samples, int64_t max_offset_samples) { @@ -73,26 +73,26 @@ AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateOffset( } const QVector reference_envelope = - ExtractRmsEnvelope(reference, window_samples); + extract_rms_envelope(reference, window_samples); const QVector candidate_envelope = - ExtractRmsEnvelope(candidate, window_samples); + extract_rms_envelope(candidate, window_samples); const int64_t max_offset_windows = max_offset_samples / static_cast(window_samples); - return EstimateEnvelopeOffset(reference_envelope, candidate_envelope, + return estimate_envelope_offset(reference_envelope, candidate_envelope, window_samples, max_offset_windows); } -AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset( +AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_envelope_offset( const QVector &reference, const QVector &candidate, size_t window_samples, int64_t max_offset_windows) { - return EstimateEnvelopeOffset(reference, candidate, QVector(), + return estimate_envelope_offset(reference, candidate, QVector(), QVector(), window_samples, max_offset_windows); } -AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset( +AudioWaveformSync::OffsetResult AudioWaveformSync::estimate_envelope_offset( const QVector &reference, const QVector &candidate, const QVector &reference_valid, const QVector &candidate_valid, size_t window_samples, int64_t max_offset_windows) @@ -185,7 +185,7 @@ AudioWaveformSync::OffsetResult AudioWaveformSync::EstimateEnvelopeOffset( return result; } -AudioWaveformSync::StretchOffsetResult AudioWaveformSync::EstimateStretchAndOffset( +AudioWaveformSync::StretchOffsetResult AudioWaveformSync::estimate_stretch_and_offset( const QVector &reference, const QVector &candidate, const QVector &reference_valid, const QVector &candidate_valid, size_t window_samples, int64_t max_offset_windows, double min_rate, @@ -226,7 +226,7 @@ AudioWaveformSync::StretchOffsetResult AudioWaveformSync::EstimateStretchAndOffs (candidate_valid.at(lower) && candidate_valid.at(upper))); } - const OffsetResult offset = EstimateEnvelopeOffset( + const OffsetResult offset = estimate_envelope_offset( reference, resampled, reference_valid, resampled_valid, window_samples, max_offset_windows); diff --git a/app/audio/audiowaveformsync.h b/app/audio/audiowaveformsync.h index d8bb0035b..1ae13c0ef 100644 --- a/app/audio/audiowaveformsync.h +++ b/app/audio/audiowaveformsync.h @@ -18,8 +18,8 @@ ***/ -#ifndef AUDIOWAVEFORMSYNC_H -#define AUDIOWAVEFORMSYNC_H +#ifndef OAK_AUDIOWAVEFORMSYNC_H +#define OAK_AUDIOWAVEFORMSYNC_H #include @@ -48,15 +48,15 @@ public: bool valid = false; }; - static QVector ExtractRmsEnvelope(const core::SampleBuffer &samples, + static QVector extract_rms_envelope(const core::SampleBuffer &samples, size_t window_samples); - static OffsetResult EstimateOffset(const core::SampleBuffer &reference, + static OffsetResult estimate_offset(const core::SampleBuffer &reference, const core::SampleBuffer &candidate, size_t window_samples, int64_t max_offset_samples); - static OffsetResult EstimateEnvelopeOffset(const QVector &reference, + static OffsetResult estimate_envelope_offset(const QVector &reference, const QVector &candidate, size_t window_samples, int64_t max_offset_windows); @@ -71,7 +71,7 @@ public: * waveform cache have not been generated yet. Empty masks are treated as * "all windows valid". */ - static OffsetResult EstimateEnvelopeOffset(const QVector &reference, + static OffsetResult estimate_envelope_offset(const QVector &reference, const QVector &candidate, const QVector &reference_valid, const QVector &candidate_valid, @@ -89,7 +89,7 @@ public: * callers should bound max_offset_windows to a sensible range. */ static StretchOffsetResult - EstimateStretchAndOffset(const QVector &reference, + estimate_stretch_and_offset(const QVector &reference, const QVector &candidate, const QVector &reference_valid, const QVector &candidate_valid, size_t window_samples, @@ -99,4 +99,4 @@ public: } -#endif // AUDIOWAVEFORMSYNC_H +#endif // OAK_AUDIOWAVEFORMSYNC_H diff --git a/app/cli/cliexport/cliexportmanager.h b/app/cli/cliexport/cliexportmanager.h index ca5abb240..a5ca202d5 100644 --- a/app/cli/cliexport/cliexportmanager.h +++ b/app/cli/cliexport/cliexportmanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef CLIEXPORTMANAGER_H -#define CLIEXPORTMANAGER_H +#ifndef OAK_CLIEXPORTMANAGER_H +#define OAK_CLIEXPORTMANAGER_H #include "task/export/export.h" @@ -34,4 +34,4 @@ public: } -#endif // CLIEXPORTMANAGER_H +#endif // OAK_CLIEXPORTMANAGER_H diff --git a/app/cli/cliprogress/cliprogressdialog.cpp b/app/cli/cliprogress/cliprogressdialog.cpp index 8d6859a01..2ce069653 100644 --- a/app/cli/cliprogress/cliprogressdialog.cpp +++ b/app/cli/cliprogress/cliprogressdialog.cpp @@ -32,10 +32,10 @@ CLIProgressDialog::CLIProgressDialog(const QString &title, QObject *parent) , progress_(-1) , drawn_(false) { - SetProgress(0); + set_progress(0); } -void CLIProgressDialog::Update() +void CLIProgressDialog::update() { if (drawn_) { // We've been here before, do a carriage return back to the start of the terminal line @@ -102,12 +102,12 @@ void CLIProgressDialog::Update() std::cout << percent << "% " << std::endl << std::flush; } -void CLIProgressDialog::SetProgress(double p) +void CLIProgressDialog::set_progress(double p) { if (progress_ != p) { progress_ = p; - Update(); + update(); } } diff --git a/app/cli/cliprogress/cliprogressdialog.h b/app/cli/cliprogress/cliprogressdialog.h index 53597607b..511c1c383 100644 --- a/app/cli/cliprogress/cliprogressdialog.h +++ b/app/cli/cliprogress/cliprogressdialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef CLIPROGRESSDIALOG_H -#define CLIPROGRESSDIALOG_H +#ifndef OAK_CLIPROGRESSDIALOG_H +#define OAK_CLIPROGRESSDIALOG_H #include #include @@ -35,10 +35,10 @@ public: CLIProgressDialog(const QString &title, QObject *parent = nullptr); public slots: - void SetProgress(double p); + void set_progress(double p); private: - void Update(); + void update(); QString title_; @@ -49,4 +49,4 @@ private: } -#endif // CLIPROGRESSDIALOG_H +#endif // OAK_CLIPROGRESSDIALOG_H diff --git a/app/cli/clitask/clitaskdialog.cpp b/app/cli/clitask/clitaskdialog.cpp index f1eccf94f..a5ce016a6 100644 --- a/app/cli/clitask/clitaskdialog.cpp +++ b/app/cli/clitask/clitaskdialog.cpp @@ -25,15 +25,15 @@ namespace olive { CLITaskDialog::CLITaskDialog(Task *task, QObject *parent) - : CLIProgressDialog(task->GetTitle(), parent) + : CLIProgressDialog(task->get_title(), parent) , task_(task) { - connect(task_, &Task::ProgressChanged, this, &CLITaskDialog::SetProgress); + connect(task_, &Task::progress_changed, this, &CLITaskDialog::set_progress); } -bool CLITaskDialog::Run() +bool CLITaskDialog::run() { - return task_->Start(); + return task_->start(); } } diff --git a/app/cli/clitask/clitaskdialog.h b/app/cli/clitask/clitaskdialog.h index 29e33fc5f..d74b0efb2 100644 --- a/app/cli/clitask/clitaskdialog.h +++ b/app/cli/clitask/clitaskdialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef CLITASKDIALOG_H -#define CLITASKDIALOG_H +#ifndef OAK_CLITASKDIALOG_H +#define OAK_CLITASKDIALOG_H #include "cli/cliprogress/cliprogressdialog.h" #include "task/task.h" @@ -33,7 +33,7 @@ class CLITaskDialog : public CLIProgressDialog { public: CLITaskDialog(Task *task, QObject *parent = nullptr); - bool Run(); + bool run(); private: Task *task_; @@ -41,4 +41,4 @@ private: } -#endif // CLITASKDIALOG_H +#endif // OAK_CLITASKDIALOG_H diff --git a/app/codec/conformmanager.cpp b/app/codec/conformmanager.cpp index a14f5f37c..4aca62442 100644 --- a/app/codec/conformmanager.cpp +++ b/app/codec/conformmanager.cpp @@ -27,7 +27,7 @@ namespace olive ConformManager *ConformManager::instance_ = nullptr; -ConformManager::Conform ConformManager::GetConformState( +ConformManager::Conform ConformManager::get_conform_state( const QString &decoder_id, const QString &cache_path, const Decoder::CodecStream &stream, const AudioParams ¶ms, bool wait) { @@ -36,9 +36,9 @@ ConformManager::Conform ConformManager::GetConformState( // Return existing conform if exists QVector filenames = - GetConformedFilename(cache_path, stream, params); - if (AllConformsExist(filenames)) { - return { kConformExists, filenames, nullptr }; + get_conformed_filename(cache_path, stream, params); + if (all_conforms_exist(filenames)) { + return { k_conform_exists, filenames, nullptr }; } ConformTask *conforming_task = nullptr; @@ -63,10 +63,10 @@ ConformManager::Conform ConformManager::GetConformState( conforming_task = new ConformTask(decoder_id, stream, params, working_filenames); - connect(conforming_task, &ConformTask::Finished, this, - &ConformManager::ConformTaskFinished); + connect(conforming_task, &ConformTask::finished, this, + &ConformManager::conform_task_finished); conforming_task->moveToThread(TaskManager::instance()->thread()); - QMetaObject::invokeMethod(TaskManager::instance(), "AddTask", + QMetaObject::invokeMethod(TaskManager::instance(), "add_task", Qt::QueuedConnection, Q_ARG(Task *, conforming_task)); @@ -77,15 +77,15 @@ ConformManager::Conform ConformManager::GetConformState( if (wait) { do { conform_done_condition_.wait(&mutex_); - } while (!AllConformsExist(filenames)); - return { kConformExists, filenames, nullptr }; + } while (!all_conforms_exist(filenames)); + return { k_conform_exists, filenames, nullptr }; } - return { kConformGenerating, QVector(), conforming_task }; + return { k_conform_generating, QVector(), conforming_task }; } QVector -ConformManager::GetConformedFilename(const QString &cache_path, +ConformManager::get_conformed_filename(const QString &cache_path, const Decoder::CodecStream &stream, const AudioParams ¶ms) { @@ -94,7 +94,7 @@ ConformManager::GetConformedFilename(const QString &cache_path, for (int i = 0; i < filenames.size(); i++) { QString index_fn = QStringLiteral("%1-%2.%3.%4.%5.%6.pcm") - .arg(FileFunctions::GetUniqueFileIdentifier(stream.filename()), + .arg(FileFunctions::get_unique_file_identifier(stream.filename()), QString::number(stream.stream()), QString::number(params.sample_rate()), QString::number(params.format()), @@ -107,7 +107,7 @@ ConformManager::GetConformedFilename(const QString &cache_path, return filenames; } -bool ConformManager::AllConformsExist(const QVector &filenames) +bool ConformManager::all_conforms_exist(const QVector &filenames) { foreach (const QString &fn, filenames) { if (!QFileInfo::exists(fn)) { @@ -118,7 +118,7 @@ bool ConformManager::AllConformsExist(const QVector &filenames) return true; } -void ConformManager::ConformTaskFinished(Task *task, bool succeeded) +void ConformManager::conform_task_finished(Task *task, bool succeeded) { QMutexLocker locker(&mutex_); @@ -146,7 +146,7 @@ void ConformManager::ConformTaskFinished(Task *task, bool succeeded) conform_done_condition_.wakeAll(); locker.unlock(); - emit ConformReady(); + emit conform_ready(); } else { // Failed, just delete the working filename if exists for (int i = 0; i < data.working_filename.size(); i++) { diff --git a/app/codec/conformmanager.h b/app/codec/conformmanager.h index c310a07ef..184672016 100644 --- a/app/codec/conformmanager.h +++ b/app/codec/conformmanager.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef CONFORMMANAGER_H -#define CONFORMMANAGER_H +#ifndef OAK_CONFORMMANAGER_H +#define OAK_CONFORMMANAGER_H #include #include @@ -31,14 +31,14 @@ namespace olive class ConformManager : public QObject { Q_OBJECT public: - static void CreateInstance() + static void create_instance() { if (!instance_) { instance_ = new ConformManager(); } } - static void DestroyInstance() + static void destroy_instance() { delete instance_; instance_ = nullptr; @@ -49,7 +49,7 @@ public: return instance_; } - enum ConformState { kConformExists, kConformGenerating }; + enum ConformState { k_conform_exists, k_conform_generating }; struct Conform { ConformState state; @@ -62,13 +62,13 @@ public: * * Thread-safe. */ - Conform GetConformState(const QString &decoder_id, + Conform get_conform_state(const QString &decoder_id, const QString &cache_path, const Decoder::CodecStream &stream, const AudioParams ¶ms, bool wait); signals: - void ConformReady(); + void conform_ready(); private: ConformManager() = default; @@ -93,16 +93,16 @@ private: * @brief Get the destination filename of an audio stream conformed to a set of parameters */ static QVector - GetConformedFilename(const QString &cache_path, + get_conformed_filename(const QString &cache_path, const Decoder::CodecStream &stream, const AudioParams ¶ms); - static bool AllConformsExist(const QVector &filenames); + static bool all_conforms_exist(const QVector &filenames); private slots: - void ConformTaskFinished(Task *task, bool succeeded); + void conform_task_finished(Task *task, bool succeeded); }; } // namespace olive -#endif // CONFORMMANAGER_H +#endif // OAK_CONFORMMANAGER_H diff --git a/app/codec/decoder.cpp b/app/codec/decoder.cpp index 8592a1dd2..753386c54 100644 --- a/app/codec/decoder.cpp +++ b/app/codec/decoder.cpp @@ -33,26 +33,26 @@ namespace olive { -const rational Decoder::kAnyTimecode = RATIONAL_MIN; +const Rational Decoder::k_any_timecode = RATIONAL_MIN; Decoder::Decoder() : cached_texture_(nullptr) { - UpdateLastAccessed(); + update_last_accessed(); } -void Decoder::IncrementAccessTime(qint64 t) +void Decoder::increment_access_time(qint64 t) { last_accessed_ += t; } -bool Decoder::Open(const CodecStream &stream) +bool Decoder::open(const CodecStream &stream) { QMutexLocker locker(&mutex_); - UpdateLastAccessed(); + update_last_accessed(); - if (stream_.IsValid()) { + if (stream_.is_valid()) { // Decoder is already open. Return TRUE if the stream is the stream we have, or FALSE if not. if (stream_ == stream) { return true; @@ -63,13 +63,13 @@ bool Decoder::Open(const CodecStream &stream) } } else { // Stream was not open, try opening it now - if (!stream.IsValid()) { + if (!stream.is_valid()) { // Cannot open null stream qCritical() << "Decoder attempted to open null stream"; return false; } - if (!stream.Exists()) { + if (!stream.exists()) { // Cannot open file that doesn't exist qCritical() << "Decoder attempted to open file that doesn't exist"; return false; @@ -79,36 +79,36 @@ bool Decoder::Open(const CodecStream &stream) stream_ = stream; // Try open internal - if (OpenInternal()) { + if (open_internal()) { return true; } else { // Unset stream qCritical() << "Failed to open" << stream_.filename() << "stream" << stream_.stream(); - CloseInternal(); - stream_.Reset(); + close_internal(); + stream_.reset(); return false; } } } -TexturePtr Decoder::RetrieveVideo(const RetrieveVideoParams &p) +TexturePtr Decoder::retrieve_video(const RetrieveVideoParams &p) { QMutexLocker locker(&mutex_); - UpdateLastAccessed(); + update_last_accessed(); - if (!stream_.IsValid()) { + if (!stream_.is_valid()) { qCritical() << "Can't retrieve video on a closed decoder"; return nullptr; } - if (!SupportsVideo()) { + if (!supports_video()) { qCritical() << "Decoder doesn't support video"; return nullptr; } - if (p.cancelled && p.cancelled->IsCancelled()) { + if (p.cancelled && p.cancelled->is_cancelled()) { return nullptr; } @@ -117,110 +117,110 @@ TexturePtr Decoder::RetrieveVideo(const RetrieveVideoParams &p) return cached_texture_; } - cached_texture_ = RetrieveVideoInternal(p); + cached_texture_ = retrieve_video_internal(p); cached_time_ = p.time; cached_divider_ = p.divider; return cached_texture_; } -FramePtr Decoder::RetrieveVideoFrame(const RetrieveVideoParams &p) +FramePtr Decoder::retrieve_video_frame(const RetrieveVideoParams &p) { QMutexLocker locker(&mutex_); - UpdateLastAccessed(); + update_last_accessed(); - if (!stream_.IsValid()) { + if (!stream_.is_valid()) { qCritical() << "Can't retrieve video frame on a closed decoder"; return nullptr; } - if (!SupportsVideo()) { + if (!supports_video()) { qCritical() << "Decoder doesn't support video"; return nullptr; } - if (p.cancelled && p.cancelled->IsCancelled()) { + if (p.cancelled && p.cancelled->is_cancelled()) { return nullptr; } - return RetrieveVideoFrameInternal(p); + return retrieve_video_frame_internal(p); } Decoder::RetrieveAudioStatus -Decoder::RetrieveAudio(SampleBuffer &dest, const TimeRange &range, +Decoder::retrieve_audio(SampleBuffer &dest, const TimeRange &range, const AudioParams ¶ms, const QString &cache_path, LoopMode loop_mode, RenderMode::Mode mode) { QMutexLocker locker(&mutex_); - UpdateLastAccessed(); + update_last_accessed(); - if (!stream_.IsValid()) { + if (!stream_.is_valid()) { qCritical() << "Can't retrieve audio on a closed decoder"; - return kInvalid; + return k_invalid; } - if (!SupportsAudio()) { + if (!supports_audio()) { qCritical() << "Decoder doesn't support audio"; - return kInvalid; + return k_invalid; } if (params.sample_rate() <= 0 || params.channel_count() <= 0) { qWarning() << "Invalid audio parameters, skipping audio retrieve"; - return kInvalid; + return k_invalid; } // Get conform state from ConformManager ConformManager::Conform conform = - ConformManager::instance()->GetConformState( - id(), cache_path, stream_, params, (mode == RenderMode::kOnline)); - if (conform.state == ConformManager::kConformGenerating) { + ConformManager::instance()->get_conform_state( + id(), cache_path, stream_, params, (mode == RenderMode::k_online)); + if (conform.state == ConformManager::k_conform_generating) { // If we need the task, it's available in `conform.task` - return kWaitingForConform; + return k_waiting_for_conform; } // See if we got the conform - if (RetrieveAudioFromConform(dest, conform.filenames, range, loop_mode, + if (retrieve_audio_from_conform(dest, conform.filenames, range, loop_mode, params)) { - return kOK; + return k_ok; } else { - return kUnknownError; + return k_unknown_error; } } -qint64 Decoder::GetLastAccessedTime() +qint64 Decoder::get_last_accessed_time() { return last_accessed_; } -void Decoder::Close() +void Decoder::close() { QMutexLocker locker(&mutex_); - UpdateLastAccessed(); + update_last_accessed(); cached_texture_ = nullptr; - if (stream_.IsValid()) { - CloseInternal(); - stream_.Reset(); + if (stream_.is_valid()) { + close_internal(); + stream_.reset(); } else { qWarning() << "Tried to close a decoder that wasn't open"; } } -bool Decoder::ConformAudio(const QVector &output_filenames, +bool Decoder::conform_audio(const QVector &output_filenames, const AudioParams ¶ms, CancelAtom *cancelled) { - return ConformAudioInternal(output_filenames, params, cancelled); + return conform_audio_internal(output_filenames, params, cancelled); } /* * DECODER STATIC PUBLIC MEMBERS */ -QVector Decoder::ReceiveListOfAllDecoders() +QVector Decoder::receive_list_of_all_decoders() { QVector decoders; @@ -232,14 +232,14 @@ QVector Decoder::ReceiveListOfAllDecoders() return decoders; } -DecoderPtr Decoder::CreateFromID(const QString &id) +DecoderPtr Decoder::create_from_id(const QString &id) { if (id.isEmpty()) { return nullptr; } // Create list to iterate through - QVector decoder_list = ReceiveListOfAllDecoders(); + QVector decoder_list = receive_list_of_all_decoders(); foreach (DecoderPtr d, decoder_list) { if (d->id() == id) { @@ -250,18 +250,18 @@ DecoderPtr Decoder::CreateFromID(const QString &id) return nullptr; } -void Decoder::SignalProcessingProgress(int64_t ts, int64_t duration) +void Decoder::signal_processing_progress(int64_t ts, int64_t duration) { if (duration != FB_NOPTS_VALUE && duration != 0) { - emit IndexProgress(static_cast(ts) / + emit index_progress(static_cast(ts) / static_cast(duration)); } } -QString Decoder::TransformImageSequenceFileName(const QString &filename, +QString Decoder::transform_image_sequence_file_name(const QString &filename, const int64_t &number) { - int digit_count = GetImageSequenceDigitCount(filename); + int digit_count = get_image_sequence_digit_count(filename); QFileInfo file_info(filename); @@ -276,7 +276,7 @@ QString Decoder::TransformImageSequenceFileName(const QString &filename, file_info.fileName().replace(original_basename, new_basename)); } -int Decoder::GetImageSequenceDigitCount(const QString &filename) +int Decoder::get_image_sequence_digit_count(const QString &filename) { QString basename = QFileInfo(filename).completeBaseName(); @@ -294,9 +294,9 @@ int Decoder::GetImageSequenceDigitCount(const QString &filename) return digit_count; } -int64_t Decoder::GetImageSequenceIndex(const QString &filename) +int64_t Decoder::get_image_sequence_index(const QString &filename) { - int digit_count = GetImageSequenceDigitCount(filename); + int digit_count = get_image_sequence_digit_count(filename); QFileInfo file_info(filename); @@ -308,19 +308,19 @@ int64_t Decoder::GetImageSequenceIndex(const QString &filename) return number_only.toLongLong(); } -TexturePtr Decoder::RetrieveVideoInternal(const RetrieveVideoParams &p) +TexturePtr Decoder::retrieve_video_internal(const RetrieveVideoParams &p) { Q_UNUSED(p) return nullptr; } -FramePtr Decoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) +FramePtr Decoder::retrieve_video_frame_internal(const RetrieveVideoParams &p) { Q_UNUSED(p) return nullptr; } -bool Decoder::ConformAudioInternal(const QVector &filenames, +bool Decoder::conform_audio_internal(const QVector &filenames, const AudioParams ¶ms, CancelAtom *cancelled) { @@ -330,14 +330,14 @@ bool Decoder::ConformAudioInternal(const QVector &filenames, return false; } -bool Decoder::RetrieveAudioFromConform( +bool Decoder::retrieve_audio_from_conform( SampleBuffer &sample_buffer, const QVector &conform_filenames, TimeRange range, LoopMode loop_mode, const AudioParams &input_params) { PlanarFileDevice input; if (input.open(conform_filenames, QFile::ReadOnly)) { // Offset range by audio start offset - range -= GetAudioStartOffset(); + range -= get_audio_start_offset(); qint64 read_index = input_params.time_to_bytes(range.in()) / input_params.channel_count(); @@ -348,7 +348,7 @@ bool Decoder::RetrieveAudioFromConform( input_params.bytes_per_sample_per_channel(); while (write_index < buffer_length_in_bytes) { - if (loop_mode == LoopMode::kLoopModeLoop) { + if (loop_mode == LoopMode::k_loop_mode_loop) { while (read_index >= input.size()) { read_index -= input.size(); } @@ -391,7 +391,7 @@ bool Decoder::RetrieveAudioFromConform( return false; } -void Decoder::UpdateLastAccessed() +void Decoder::update_last_accessed() { last_accessed_ = QDateTime::currentMSecsSinceEpoch(); } diff --git a/app/codec/decoder.h b/app/codec/decoder.h index 8bb0bf4c9..5995e6277 100644 --- a/app/codec/decoder.h +++ b/app/codec/decoder.h @@ -19,8 +19,8 @@ ***/ -#ifndef DECODER_H -#define DECODER_H +#ifndef OAK_DECODER_H +#define OAK_DECODER_H #include #include @@ -43,7 +43,7 @@ using DecoderPtr = std::shared_ptr; #define DECODER_DEFAULT_DESTRUCTOR(x) \ virtual ~x() override \ { \ - CloseInternal(); \ + close_internal(); \ } /** @@ -65,7 +65,7 @@ using DecoderPtr = std::shared_ptr; class Decoder : public QObject { Q_OBJECT public: - enum RetrieveState { kReady, kFailedToOpen, kIndexUnavailable }; + enum RetrieveState { k_ready, k_failed_to_open, k_index_unavailable }; Decoder(); @@ -74,16 +74,16 @@ public: */ virtual QString id() const = 0; - virtual bool SupportsVideo() + virtual bool supports_video() { return false; } - virtual bool SupportsAudio() + virtual bool supports_audio() { return false; } - void IncrementAccessTime(qint64 t); + void increment_access_time(qint64 t); class CodecStream { public: @@ -100,17 +100,17 @@ public: { } - bool IsValid() const + bool is_valid() const { return !filename_.isEmpty() && stream_ >= 0; } - bool Exists() const + bool exists() const { return QFileInfo::exists(filename_); } - void Reset() + void reset() { *this = CodecStream(); } @@ -152,18 +152,18 @@ public: * already open and the stream == the stream provided. Returns FALSE if the stream couldn't * be opened OR if already open and the stream is NOT the same. */ - bool Open(const CodecStream &stream); + bool open(const CodecStream &stream); - static const rational kAnyTimecode; + static const Rational k_any_timecode; struct RetrieveVideoParams { Renderer *renderer = nullptr; - rational time; + Rational time; int divider = 1; - PixelFormat maximum_format = PixelFormat::INVALID; + PixelFormat maximum_format = PixelFormat::invalid; CancelAtom *cancelled = nullptr; - VideoParams::ColorRange force_range = VideoParams::kColorRangeDefault; - VideoParams::Interlacing src_interlacing = VideoParams::kInterlaceNone; + VideoParams::ColorRange force_range = VideoParams::k_color_range_default; + VideoParams::Interlacing src_interlacing = VideoParams::k_interlace_none; }; /** @@ -176,7 +176,7 @@ public: * * This function is thread safe and can only run while the decoder is open. \see Open() */ - TexturePtr RetrieveVideo(const RetrieveVideoParams &p); + TexturePtr retrieve_video(const RetrieveVideoParams &p); /** * @brief Retrieves a decoded video frame in CPU memory. @@ -184,13 +184,13 @@ public: * Used by render-process isolation to decode media in the main process and pass packed pixel * data to workers through shared memory. */ - FramePtr RetrieveVideoFrame(const RetrieveVideoParams &p); + FramePtr retrieve_video_frame(const RetrieveVideoParams &p); enum RetrieveAudioStatus { - kInvalid = -1, - kOK, - kWaitingForConform, - kUnknownError + k_invalid = -1, + k_ok, + k_waiting_for_conform, + k_unknown_error }; /** @@ -202,14 +202,14 @@ public: * This function is thread safe and can only run while the decoder is open. \see Open() */ RetrieveAudioStatus - RetrieveAudio(SampleBuffer &dest, const TimeRange &range, + retrieve_audio(SampleBuffer &dest, const TimeRange &range, const AudioParams ¶ms, const QString &cache_path, LoopMode loop_mode, RenderMode::Mode mode); /** * @brief Determine the last time this decoder instance was used in any way */ - qint64 GetLastAccessedTime(); + qint64 get_last_accessed_time(); /** * @brief Generate a Footage object from a file @@ -222,7 +222,7 @@ public: * * This function is re-entrant. */ - virtual FootageDescription Probe(const QString &filename, + virtual FootageDescription probe(const QString &filename, CancelAtom *cancelled) const = 0; /** @@ -230,12 +230,12 @@ public: * * This function is thread safe and can only run while the decoder is open. \see Open() */ - void Close(); + void close(); /** * @brief Conform audio stream */ - bool ConformAudio(const QVector &output_filenames, + bool conform_audio(const QVector &output_filenames, const AudioParams ¶ms, CancelAtom *cancelled = nullptr); @@ -246,16 +246,16 @@ public: * * A Decoder instance or nullptr if a Decoder with this ID does not exist */ - static DecoderPtr CreateFromID(const QString &id); + static DecoderPtr create_from_id(const QString &id); - static QString TransformImageSequenceFileName(const QString &filename, + static QString transform_image_sequence_file_name(const QString &filename, const int64_t &number); - static int GetImageSequenceDigitCount(const QString &filename); + static int get_image_sequence_digit_count(const QString &filename); - static int64_t GetImageSequenceIndex(const QString &filename); + static int64_t get_image_sequence_index(const QString &filename); - static QVector ReceiveListOfAllDecoders(); + static QVector receive_list_of_all_decoders(); protected: /** @@ -267,10 +267,10 @@ protected: * decoder is not open yet and that the footage stream was from that sub-classes probe function. * * Return TRUE if everything opened successfully and the decoder is ready to work. Otherwise, - * return FALSE. If this function returns false, Decoder will call CloseInternal to clean any + * return FALSE. If this function returns false, Decoder will call close_internal to clean any * memory allocated during OpenInternal. */ - virtual bool OpenInternal() = 0; + virtual bool open_internal() = 0; /** * @brief Internal close function @@ -278,7 +278,7 @@ protected: * Sub-classes must override this function. Function should be able to safely clear all allocated * memory. It may be called even if Open() didn't complete or RetrieveVideo() was never called. */ - virtual void CloseInternal() = 0; + virtual void close_internal() = 0; /** * @brief Internal frame retrieval function @@ -286,15 +286,15 @@ protected: * Sub-classes must override this function IF they support video. Function is already mutexed * so sub-classes don't need to worry about thread safety. */ - virtual TexturePtr RetrieveVideoInternal(const RetrieveVideoParams &p); + virtual TexturePtr retrieve_video_internal(const RetrieveVideoParams &p); - virtual FramePtr RetrieveVideoFrameInternal(const RetrieveVideoParams &p); + virtual FramePtr retrieve_video_frame_internal(const RetrieveVideoParams &p); - virtual bool ConformAudioInternal(const QVector &filenames, + virtual bool conform_audio_internal(const QVector &filenames, const AudioParams ¶ms, CancelAtom *cancelled); - void SignalProcessingProgress(int64_t ts, int64_t duration); + void signal_processing_progress(int64_t ts, int64_t duration); /** * @brief Return currently open stream @@ -306,7 +306,7 @@ protected: return stream_; } - virtual rational GetAudioStartOffset() const + virtual Rational get_audio_start_offset() const { return 0; } @@ -316,12 +316,12 @@ signals: * @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if * available */ - void IndexProgress(double); + void index_progress(double); private: - void UpdateLastAccessed(); + void update_last_accessed(); - bool RetrieveAudioFromConform(SampleBuffer &sample_buffer, + bool retrieve_audio_from_conform(SampleBuffer &sample_buffer, const QVector &conform_filenames, TimeRange range, LoopMode loop_mode, const AudioParams ¶ms); @@ -333,7 +333,7 @@ private: std::atomic_int64_t last_accessed_; TexturePtr cached_texture_; - rational cached_time_; + Rational cached_time_; int cached_divider_; }; @@ -343,4 +343,4 @@ uint qHash(Decoder::CodecStream stream, uint seed = 0); Q_DECLARE_METATYPE(olive::Decoder::RetrieveState) -#endif // DECODER_H +#endif // OAK_DECODER_H diff --git a/app/codec/encoder.cpp b/app/codec/encoder.cpp index 4300031da..498c963dd 100644 --- a/app/codec/encoder.cpp +++ b/app/codec/encoder.cpp @@ -30,9 +30,9 @@ namespace olive { -const QRegularExpression Encoder::kImageSequenceContainsDigits = +const QRegularExpression Encoder::k_image_sequence_contains_digits = QRegularExpression(QStringLiteral("\\[[#]+\\]")); -const QRegularExpression Encoder::kImageSequenceRemoveDigits = +const QRegularExpression Encoder::k_image_sequence_remove_digits = QRegularExpression(QStringLiteral("[\\-\\.\\ \\_]?\\[[#]+\\]")); Encoder::Encoder(const EncodingParams ¶ms) @@ -45,18 +45,18 @@ const EncodingParams &Encoder::params() const return params_; } -QString Encoder::GetFilenameForFrame(const rational &frame) +QString Encoder::get_filename_for_frame(const Rational &frame) { if (params().video_is_image_sequence()) { // Transform! int64_t frame_index = Timecode::time_to_timestamp( frame, params().video_params().frame_rate_as_time_base()); - int digits = GetImageSequencePlaceholderDigitCount(params().filename()); + int digits = get_image_sequence_placeholder_digit_count(params().filename()); QString frame_index_str = QStringLiteral("%1").arg(frame_index, digits, 10, QChar('0')); QString f = params_.filename(); - f.replace(kImageSequenceContainsDigits, frame_index_str); + f.replace(k_image_sequence_contains_digits, frame_index_str); return f; } else { // Keep filename @@ -64,9 +64,9 @@ QString Encoder::GetFilenameForFrame(const rational &frame) } } -int Encoder::GetImageSequencePlaceholderDigitCount(const QString &filename) +int Encoder::get_image_sequence_placeholder_digit_count(const QString &filename) { - int start = filename.indexOf(kImageSequenceContainsDigits); + int start = filename.indexOf(k_image_sequence_contains_digits); int digit_count = 0; for (int i = start + 1; i < filename.size(); i++) { if (filename.at(i) == '#') { @@ -78,14 +78,14 @@ int Encoder::GetImageSequencePlaceholderDigitCount(const QString &filename) return digit_count; } -bool Encoder::FilenameContainsDigitPlaceholder(const QString &filename) +bool Encoder::filename_contains_digit_placeholder(const QString &filename) { - return filename.contains(kImageSequenceContainsDigits); + return filename.contains(k_image_sequence_contains_digits); } -QString Encoder::FilenameRemoveDigitPlaceholder(QString filename) +QString Encoder::filename_remove_digit_placeholder(QString filename) { - return filename.remove(kImageSequenceRemoveDigits); + return filename.remove(k_image_sequence_remove_digits); } EncodingParams::EncodingParams() @@ -100,24 +100,24 @@ EncodingParams::EncodingParams() , audio_bit_rate_(0) , subtitles_enabled_(false) , subtitles_are_sidecar_(false) - , video_scaling_method_(kStretch) + , video_scaling_method_(k_stretch) , has_custom_range_(false) { } -QDir EncodingParams::GetPresetPath() +QDir EncodingParams::get_preset_path() { - return QDir(FileFunctions::GetConfigurationLocation()) + return QDir(FileFunctions::get_configuration_location()) .filePath(QStringLiteral("exportpresets")); } -QStringList EncodingParams::GetListOfPresets() +QStringList EncodingParams::get_list_of_presets() { - QDir d = EncodingParams::GetPresetPath(); + QDir d = EncodingParams::get_preset_path(); return d.entryList(QDir::Files); } -void EncodingParams::EnableVideo(const VideoParams &video_params, +void EncodingParams::enable_video(const VideoParams &video_params, const ExportCodec::Codec &vcodec) { video_enabled_ = true; @@ -125,7 +125,7 @@ void EncodingParams::EnableVideo(const VideoParams &video_params, video_codec_ = vcodec; } -void EncodingParams::EnableAudio(const AudioParams &audio_params, +void EncodingParams::enable_audio(const AudioParams &audio_params, const ExportCodec::Codec &acodec) { audio_enabled_ = true; @@ -133,13 +133,13 @@ void EncodingParams::EnableAudio(const AudioParams &audio_params, audio_codec_ = acodec; } -void EncodingParams::EnableSubtitles(const ExportCodec::Codec &scodec) +void EncodingParams::enable_subtitles(const ExportCodec::Codec &scodec) { subtitles_enabled_ = true; subtitles_codec_ = scodec; } -void EncodingParams::EnableSidecarSubtitles(const ExportFormat::Format &sfmt, +void EncodingParams::enable_sidecar_subtitles(const ExportFormat::Format &sfmt, const ExportCodec::Codec &scodec) { subtitles_enabled_ = true; @@ -148,24 +148,24 @@ void EncodingParams::EnableSidecarSubtitles(const ExportFormat::Format &sfmt, subtitles_codec_ = scodec; } -void EncodingParams::DisableVideo() +void EncodingParams::disable_video() { video_enabled_ = false; } -void EncodingParams::DisableAudio() +void EncodingParams::disable_audio() { audio_enabled_ = false; } -void EncodingParams::DisableSubtitles() +void EncodingParams::disable_subtitles() { subtitles_enabled_ = false; } -bool EncodingParams::Load(QXmlStreamReader *reader) +bool EncodingParams::load(QXmlStreamReader *reader) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("export")) { int version = 0; @@ -178,7 +178,7 @@ bool EncodingParams::Load(QXmlStreamReader *reader) switch (version) { case 1: - return LoadV1(reader); + return load_v1(reader); } } else { reader->skipCurrentElement(); @@ -188,26 +188,26 @@ bool EncodingParams::Load(QXmlStreamReader *reader) return false; } -bool EncodingParams::Load(QIODevice *device) +bool EncodingParams::load(QIODevice *device) { QXmlStreamReader reader(device); - return Load(&reader); + return load(&reader); } -void EncodingParams::Save(QIODevice *device) const +void EncodingParams::save(QIODevice *device) const { QXmlStreamWriter writer(device); - Save(&writer); + save(&writer); } -void EncodingParams::Save(QXmlStreamWriter *writer) const +void EncodingParams::save(QXmlStreamWriter *writer) const { writer->writeStartDocument(); writer->writeStartElement(QStringLiteral("export")); writer->writeAttribute(QStringLiteral("version"), - QString::number(kEncoderParamsVersion)); + QString::number(k_encoder_params_version)); writer->writeTextElement(QStringLiteral("filename"), filename_); writer->writeTextElement(QStringLiteral("format"), @@ -217,10 +217,10 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const QString::number(has_custom_range_)); writer->writeTextElement( QStringLiteral("customrangein"), - QString::fromStdString(custom_range_.in().toString())); + QString::fromStdString(custom_range_.in().to_string())); writer->writeTextElement( QStringLiteral("customrangeout"), - QString::fromStdString(custom_range_.out().toString())); + QString::fromStdString(custom_range_.out().to_string())); writer->writeStartElement(QStringLiteral("video")); @@ -239,10 +239,10 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const writer->writeTextElement( QStringLiteral("pixelaspect"), QString::fromStdString( - video_params_.pixel_aspect_ratio().toString())); + video_params_.pixel_aspect_ratio().to_string())); writer->writeTextElement( QStringLiteral("timebase"), - QString::fromStdString(video_params_.time_base().toString())); + QString::fromStdString(video_params_.time_base().to_string())); writer->writeTextElement(QStringLiteral("divider"), QString::number(video_params_.divider())); writer->writeTextElement(QStringLiteral("bitrate"), @@ -332,77 +332,77 @@ void EncodingParams::Save(QXmlStreamWriter *writer) const writer->writeEndDocument(); } -Encoder *Encoder::CreateFromID(Type id, const EncodingParams ¶ms) +Encoder *Encoder::create_from_id(Type id, const EncodingParams ¶ms) { switch (id) { - case kEncoderTypeNone: + case k_encoder_type_none: break; - case kEncoderTypeFFmpeg: + case k_encoder_type_f_fmpeg: return new FFmpegEncoder(params); - case kEncoderTypeOIIO: + case k_encoder_type_oiio: return new OIIOEncoder(params); } return nullptr; } -Encoder::Type Encoder::GetTypeFromFormat(ExportFormat::Format f) +Encoder::Type Encoder::get_type_from_format(ExportFormat::Format f) { switch (f) { - case ExportFormat::kFormatDNxHD: - case ExportFormat::kFormatMatroska: - case ExportFormat::kFormatQuickTime: - case ExportFormat::kFormatMPEG4Video: - case ExportFormat::kFormatMPEG4Audio: - case ExportFormat::kFormatWAV: - case ExportFormat::kFormatAIFF: - case ExportFormat::kFormatMP3: - case ExportFormat::kFormatFLAC: - case ExportFormat::kFormatOgg: - case ExportFormat::kFormatWebM: - case ExportFormat::kFormatSRT: - return kEncoderTypeFFmpeg; - case ExportFormat::kFormatOpenEXR: - case ExportFormat::kFormatPNG: - case ExportFormat::kFormatTIFF: - return kEncoderTypeOIIO; - case ExportFormat::kFormatCount: + case ExportFormat::k_format_d_nx_hd: + case ExportFormat::k_format_matroska: + case ExportFormat::k_format_quick_time: + case ExportFormat::k_format_mpe_g4_video: + case ExportFormat::k_format_mpe_g4_audio: + case ExportFormat::k_format_wav: + case ExportFormat::k_format_aiff: + case ExportFormat::k_format_m_p3: + case ExportFormat::k_format_flac: + case ExportFormat::k_format_ogg: + case ExportFormat::k_format_web_m: + case ExportFormat::k_format_srt: + return k_encoder_type_f_fmpeg; + case ExportFormat::k_format_open_exr: + case ExportFormat::k_format_png: + case ExportFormat::k_format_tiff: + return k_encoder_type_oiio; + case ExportFormat::k_format_count: break; } - return kEncoderTypeNone; + return k_encoder_type_none; } -Encoder *Encoder::CreateFromFormat(ExportFormat::Format f, +Encoder *Encoder::create_from_format(ExportFormat::Format f, const EncodingParams ¶ms) { - return CreateFromID(GetTypeFromFormat(f), params); + return create_from_id(get_type_from_format(f), params); } -Encoder *Encoder::CreateFromParams(const EncodingParams ¶ms) +Encoder *Encoder::create_from_params(const EncodingParams ¶ms) { - return CreateFromFormat(params.format(), params); + return create_from_format(params.format(), params); } -QStringList Encoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const +QStringList Encoder::get_pixel_formats_for_codec(ExportCodec::Codec c) const { return QStringList(); } std::vector -Encoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const +Encoder::get_sample_formats_for_codec(ExportCodec::Codec c) const { return std::vector(); } QMatrix4x4 -EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method, +EncodingParams::generate_matrix(EncodingParams::VideoScalingMethod method, int source_width, int source_height, int dest_width, int dest_height) { QMatrix4x4 preview_matrix; - if (method == EncodingParams::kStretch) { + if (method == EncodingParams::k_stretch) { return preview_matrix; } @@ -415,7 +415,7 @@ EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method, return preview_matrix; } - if ((export_ar > source_ar) == (method == EncodingParams::kFit)) { + if ((export_ar > source_ar) == (method == EncodingParams::k_fit)) { preview_matrix.scale(source_ar / export_ar, 1.0F); } else { preview_matrix.scale(1.0F, export_ar / source_ar); @@ -424,11 +424,11 @@ EncodingParams::GenerateMatrix(EncodingParams::VideoScalingMethod method, return preview_matrix; } -bool EncodingParams::LoadV1(QXmlStreamReader *reader) +bool EncodingParams::load_v1(QXmlStreamReader *reader) { - rational custom_range_in, custom_range_out; + Rational custom_range_in, custom_range_out; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("filename")) { filename_ = reader->readElementText(); } else if (reader->name() == QStringLiteral("format")) { @@ -438,10 +438,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader) has_custom_range_ = reader->readElementText().toInt(); } else if (reader->name() == QStringLiteral("customrangein")) { custom_range_in = - rational::fromString(reader->readElementText().toStdString()); + Rational::from_string(reader->readElementText().toStdString()); } else if (reader->name() == QStringLiteral("customrangeout")) { custom_range_out = - rational::fromString(reader->readElementText().toStdString()); + Rational::from_string(reader->readElementText().toStdString()); } else if (reader->name() == QStringLiteral("video")) { XMLAttributeLoop(reader, attr) { @@ -450,7 +450,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader) } } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("codec")) { video_codec_ = static_cast( reader->readElementText().toInt()); @@ -462,10 +462,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader) video_params_.set_format(static_cast( reader->readElementText().toInt())); } else if (reader->name() == QStringLiteral("pixelaspect")) { - video_params_.set_pixel_aspect_ratio(rational::fromString( + video_params_.set_pixel_aspect_ratio(Rational::from_string( reader->readElementText().toStdString())); } else if (reader->name() == QStringLiteral("timebase")) { - video_params_.set_time_base(rational::fromString( + video_params_.set_time_base(Rational::from_string( reader->readElementText().toStdString())); } else if (reader->name() == QStringLiteral("divider")) { video_params_.set_divider( @@ -488,7 +488,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader) video_is_image_sequence_ = reader->readElementText().toInt(); } else if (reader->name() == QStringLiteral("color")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("output")) { color_transform_ = reader->readElementText(); } else { @@ -499,10 +499,10 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader) video_scaling_method_ = static_cast( reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("opts")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("entry")) { QString key, value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("key")) { key = reader->readElementText(); } else if (reader->name() == @@ -534,7 +534,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader) } } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("codec")) { audio_codec_ = static_cast( reader->readElementText().toInt()); @@ -566,7 +566,7 @@ bool EncodingParams::LoadV1(QXmlStreamReader *reader) } } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("sidecar")) { subtitles_are_sidecar_ = reader->readElementText().toInt(); } else if (reader->name() == QStringLiteral("sidecarformat")) { diff --git a/app/codec/encoder.h b/app/codec/encoder.h index 73e0ead51..efc3c5273 100644 --- a/app/codec/encoder.h +++ b/app/codec/encoder.h @@ -19,8 +19,8 @@ ***/ -#ifndef ENCODER_H -#define ENCODER_H +#ifndef OAK_ENCODER_H +#define OAK_ENCODER_H #include #include @@ -43,34 +43,34 @@ using EncoderPtr = std::shared_ptr; class EncodingParams { public: - enum VideoScalingMethod { kFit, kStretch, kCrop }; + enum VideoScalingMethod { k_fit, k_stretch, k_crop }; EncodingParams(); - static QDir GetPresetPath(); - static QStringList GetListOfPresets(); + static QDir get_preset_path(); + static QStringList get_list_of_presets(); - bool IsValid() const + bool is_valid() const { return video_enabled_ || audio_enabled_ || subtitles_enabled_; } - void SetFilename(const QString &filename) + void set_filename(const QString &filename) { filename_ = filename; } - void EnableVideo(const VideoParams &video_params, + void enable_video(const VideoParams &video_params, const ExportCodec::Codec &vcodec); - void EnableAudio(const AudioParams &audio_params, + void enable_audio(const AudioParams &audio_params, const ExportCodec::Codec &acodec); - void EnableSubtitles(const ExportCodec::Codec &scodec); - void EnableSidecarSubtitles(const ExportFormat::Format &sfmt, + void enable_subtitles(const ExportCodec::Codec &scodec); + void enable_sidecar_subtitles(const ExportFormat::Format &sfmt, const ExportCodec::Codec &scodec); - void DisableVideo(); - void DisableAudio(); - void DisableSubtitles(); + void disable_video(); + void disable_audio(); + void disable_subtitles(); const ExportFormat::Format &format() const { @@ -219,20 +219,20 @@ public: return subtitles_codec_; } - const rational &GetExportLength() const + const Rational &get_export_length() const { return export_length_; } - void SetExportLength(const rational &export_length) + void set_export_length(const Rational &export_length) { export_length_ = export_length; } - bool Load(QIODevice *device); - bool Load(QXmlStreamReader *reader); + bool load(QIODevice *device); + bool load(QXmlStreamReader *reader); - void Save(QIODevice *device) const; - void Save(QXmlStreamWriter *writer) const; + void save(QIODevice *device) const; + void save(QXmlStreamWriter *writer) const; bool has_custom_range() const { @@ -258,20 +258,20 @@ public: video_scaling_method_ = video_scaling_method; } - static QMatrix4x4 GenerateMatrix(VideoScalingMethod method, + static QMatrix4x4 generate_matrix(VideoScalingMethod method, int source_width, int source_height, int dest_width, int dest_height); private: - static const int kEncoderParamsVersion = 1; + static const int k_encoder_params_version = 1; - bool LoadV1(QXmlStreamReader *reader); + bool load_v1(QXmlStreamReader *reader); QString filename_; - ExportFormat::Format format_ = ExportFormat::kFormatCount; + ExportFormat::Format format_ = ExportFormat::k_format_count; bool video_enabled_; - ExportCodec::Codec video_codec_ = ExportCodec::kCodecCount; + ExportCodec::Codec video_codec_ = ExportCodec::k_codec_count; VideoParams video_params_; QHash video_opts_; int64_t video_bit_rate_; @@ -284,16 +284,16 @@ private: ColorTransform color_transform_; bool audio_enabled_; - ExportCodec::Codec audio_codec_ = ExportCodec::kCodecCount; + ExportCodec::Codec audio_codec_ = ExportCodec::k_codec_count; AudioParams audio_params_; int64_t audio_bit_rate_; bool subtitles_enabled_; bool subtitles_are_sidecar_; - ExportFormat::Format subtitle_sidecar_fmt_ = ExportFormat::kFormatCount; - ExportCodec::Codec subtitles_codec_ = ExportCodec::kCodecCount; + ExportFormat::Format subtitle_sidecar_fmt_ = ExportFormat::k_format_count; + ExportCodec::Codec subtitles_codec_ = ExportCodec::k_codec_count; - rational export_length_; + Rational export_length_; VideoScalingMethod video_scaling_method_; bool has_custom_range_; @@ -305,7 +305,7 @@ class Encoder : public QObject { public: Encoder(const EncodingParams ¶ms); - enum Type { kEncoderTypeNone = -1, kEncoderTypeFFmpeg, kEncoderTypeOIIO }; + enum Type { k_encoder_type_none = -1, k_encoder_type_f_fmpeg, k_encoder_type_oiio }; /** * @brief Create a Encoder instance using a Encoder ID @@ -314,53 +314,53 @@ public: * * A Encoder instance or nullptr if a Decoder with this ID does not exist */ - static Encoder *CreateFromID(Type id, const EncodingParams ¶ms); + static Encoder *create_from_id(Type id, const EncodingParams ¶ms); - static Type GetTypeFromFormat(ExportFormat::Format f); + static Type get_type_from_format(ExportFormat::Format f); - static Encoder *CreateFromFormat(ExportFormat::Format f, + static Encoder *create_from_format(ExportFormat::Format f, const EncodingParams ¶ms); - static Encoder *CreateFromParams(const EncodingParams ¶ms); + static Encoder *create_from_params(const EncodingParams ¶ms); - virtual QStringList GetPixelFormatsForCodec(ExportCodec::Codec c) const; + virtual QStringList get_pixel_formats_for_codec(ExportCodec::Codec c) const; virtual std::vector - GetSampleFormatsForCodec(ExportCodec::Codec c) const; + get_sample_formats_for_codec(ExportCodec::Codec c) const; const EncodingParams ¶ms() const; - virtual PixelFormat GetDesiredPixelFormat() const + virtual PixelFormat get_desired_pixel_format() const { - return PixelFormat::INVALID; + return PixelFormat::invalid; } - const QString &GetError() const + const QString &get_error() const { return error_; } - QString GetFilenameForFrame(const rational &frame); + QString get_filename_for_frame(const Rational &frame); - static int GetImageSequencePlaceholderDigitCount(const QString &filename); + static int get_image_sequence_placeholder_digit_count(const QString &filename); - static bool FilenameContainsDigitPlaceholder(const QString &filename); - static QString FilenameRemoveDigitPlaceholder(QString filename); + static bool filename_contains_digit_placeholder(const QString &filename); + static QString filename_remove_digit_placeholder(QString filename); - static const QRegularExpression kImageSequenceContainsDigits; - static const QRegularExpression kImageSequenceRemoveDigits; + static const QRegularExpression k_image_sequence_contains_digits; + static const QRegularExpression k_image_sequence_remove_digits; public slots: - virtual bool Open() = 0; + virtual bool open() = 0; - virtual bool WriteFrame(olive::FramePtr frame, - olive::core::rational time) = 0; - virtual bool WriteAudio(const olive::SampleBuffer &audio) = 0; - virtual bool WriteSubtitle(const SubtitleBlock *sub_block) = 0; + virtual bool write_frame(olive::FramePtr frame, + olive::core::Rational time) = 0; + virtual bool write_audio(const olive::SampleBuffer &audio) = 0; + virtual bool write_subtitle(const SubtitleBlock *sub_block) = 0; - virtual void Close() = 0; + virtual void close() = 0; protected: - void SetError(const QString &err) + void set_error(const QString &err) { error_ = err; } @@ -373,4 +373,4 @@ private: } -#endif // ENCODER_H +#endif // OAK_ENCODER_H diff --git a/app/codec/exportcodec.cpp b/app/codec/exportcodec.cpp index 4dc676b50..ded4411de 100644 --- a/app/codec/exportcodec.cpp +++ b/app/codec/exportcodec.cpp @@ -27,109 +27,109 @@ extern "C" { namespace olive { -QString ExportCodec::GetCodecName(ExportCodec::Codec c) +QString ExportCodec::get_codec_name(ExportCodec::Codec c) { switch (c) { - case kCodecDNxHD: + case k_codec_d_nx_hd: return tr("DNxHD"); - case kCodecH264: + case k_codec_h264: return tr("H.264"); - case kCodecH264rgb: + case k_codec_h264rgb: return tr("H.264 RGB"); - case kCodecH265: + case k_codec_h265: return tr("H.265"); - case kCodecOpenEXR: + case k_codec_open_exr: return tr("OpenEXR"); - case kCodecPNG: + case k_codec_png: return tr("PNG"); - case kCodecProRes: + case k_codec_pro_res: return tr("ProRes"); - case kCodecCineform: + case k_codec_cineform: return tr("Cineform"); - case kCodecTIFF: + case k_codec_tiff: return tr("TIFF"); - case kCodecMP2: + case k_codec_m_p2: return tr("MP2"); - case kCodecMP3: + case k_codec_m_p3: return tr("MP3"); - case kCodecAAC: + case k_codec_aac: return tr("AAC"); - case kCodecPCM: + case k_codec_pcm: return tr("PCM (Uncompressed)"); - case kCodecFLAC: + case k_codec_flac: return tr("FLAC"); - case kCodecOpus: + case k_codec_opus: return tr("Opus"); - case kCodecVorbis: + case k_codec_vorbis: return tr("Vorbis"); - case kCodecVP9: + case k_codec_v_p9: return tr("VP9"); - case kCodecAV1: + case k_codec_a_v1: return tr("AV1"); - case kCodecSRT: + case k_codec_srt: return tr("SubRip SRT"); - case kCodecCount: + case k_codec_count: break; } return tr("Unknown"); } -bool ExportCodec::IsCodecAStillImage(ExportCodec::Codec c) +bool ExportCodec::is_codec_a_still_image(ExportCodec::Codec c) { switch (c) { - case kCodecDNxHD: - case kCodecH264: - case kCodecH264rgb: - case kCodecH265: - case kCodecProRes: - case kCodecCineform: - case kCodecMP2: - case kCodecMP3: - case kCodecAAC: - case kCodecPCM: - case kCodecVorbis: - case kCodecOpus: - case kCodecFLAC: - case kCodecVP9: - case kCodecAV1: - case kCodecSRT: + case k_codec_d_nx_hd: + case k_codec_h264: + case k_codec_h264rgb: + case k_codec_h265: + case k_codec_pro_res: + case k_codec_cineform: + case k_codec_m_p2: + case k_codec_m_p3: + case k_codec_aac: + case k_codec_pcm: + case k_codec_vorbis: + case k_codec_opus: + case k_codec_flac: + case k_codec_v_p9: + case k_codec_a_v1: + case k_codec_srt: return false; - case kCodecOpenEXR: - case kCodecPNG: - case kCodecTIFF: + case k_codec_open_exr: + case k_codec_png: + case k_codec_tiff: return true; - case kCodecCount: + case k_codec_count: break; } return false; } -bool ExportCodec::IsCodecLossless(Codec c) +bool ExportCodec::is_codec_lossless(Codec c) { switch (c) { - case kCodecPCM: - case kCodecFLAC: + case k_codec_pcm: + case k_codec_flac: return true; - case kCodecDNxHD: - case kCodecH264: - case kCodecH264rgb: - case kCodecH265: - case kCodecProRes: - case kCodecCineform: - case kCodecMP2: - case kCodecMP3: - case kCodecAAC: - case kCodecVorbis: - case kCodecOpus: - case kCodecVP9: - case kCodecAV1: - case kCodecSRT: - case kCodecOpenEXR: - case kCodecPNG: - case kCodecTIFF: - case kCodecCount: + case k_codec_d_nx_hd: + case k_codec_h264: + case k_codec_h264rgb: + case k_codec_h265: + case k_codec_pro_res: + case k_codec_cineform: + case k_codec_m_p2: + case k_codec_m_p3: + case k_codec_aac: + case k_codec_vorbis: + case k_codec_opus: + case k_codec_v_p9: + case k_codec_a_v1: + case k_codec_srt: + case k_codec_open_exr: + case k_codec_png: + case k_codec_tiff: + case k_codec_count: break; } diff --git a/app/codec/exportcodec.h b/app/codec/exportcodec.h index 7970475ad..345e370c0 100644 --- a/app/codec/exportcodec.h +++ b/app/codec/exportcodec.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTCODEC_H -#define EXPORTCODEC_H +#ifndef OAK_EXPORTCODEC_H +#define OAK_EXPORTCODEC_H #include #include @@ -36,36 +36,36 @@ class ExportCodec : public QObject { public: // Only append to this list (never insert) because indexes are used in serialized files enum Codec { - kCodecDNxHD, - kCodecH264, - kCodecH264rgb, - kCodecH265, - kCodecOpenEXR, - kCodecPNG, - kCodecProRes, - kCodecCineform, - kCodecTIFF, - kCodecVP9, - kCodecMP2, - kCodecMP3, - kCodecAAC, - kCodecPCM, - kCodecOpus, - kCodecVorbis, - kCodecFLAC, - kCodecSRT, - kCodecAV1, + k_codec_d_nx_hd, + k_codec_h264, + k_codec_h264rgb, + k_codec_h265, + k_codec_open_exr, + k_codec_png, + k_codec_pro_res, + k_codec_cineform, + k_codec_tiff, + k_codec_v_p9, + k_codec_m_p2, + k_codec_m_p3, + k_codec_aac, + k_codec_pcm, + k_codec_opus, + k_codec_vorbis, + k_codec_flac, + k_codec_srt, + k_codec_a_v1, - kCodecCount + k_codec_count }; - static QString GetCodecName(Codec c); + static QString get_codec_name(Codec c); - static bool IsCodecAStillImage(Codec c); + static bool is_codec_a_still_image(Codec c); - static bool IsCodecLossless(Codec c); + static bool is_codec_lossless(Codec c); }; } -#endif // EXPORTCODEC_H +#endif // OAK_EXPORTCODEC_H diff --git a/app/codec/exportformat.cpp b/app/codec/exportformat.cpp index a1bd3b18e..9e5844c7a 100644 --- a/app/codec/exportformat.cpp +++ b/app/codec/exportformat.cpp @@ -26,206 +26,206 @@ namespace olive { -QString ExportFormat::GetName(olive::ExportFormat::Format f) +QString ExportFormat::get_name(olive::ExportFormat::Format f) { switch (f) { - case kFormatDNxHD: + case k_format_d_nx_hd: return tr("DNxHD"); - case kFormatMatroska: + case k_format_matroska: return tr("Matroska Video"); - case kFormatMPEG4Video: + case k_format_mpe_g4_video: return tr("MPEG-4 Video"); - case kFormatMPEG4Audio: + case k_format_mpe_g4_audio: return tr("MPEG-4 Audio"); - case kFormatOpenEXR: + case k_format_open_exr: return tr("OpenEXR"); - case kFormatPNG: + case k_format_png: return tr("PNG"); - case kFormatTIFF: + case k_format_tiff: return tr("TIFF"); - case kFormatQuickTime: + case k_format_quick_time: return tr("QuickTime"); - case kFormatWAV: + case k_format_wav: return tr("Wave Audio"); - case kFormatAIFF: + case k_format_aiff: return tr("AIFF"); - case kFormatMP3: + case k_format_m_p3: return tr("MP3"); - case kFormatFLAC: + case k_format_flac: return tr("FLAC"); - case kFormatOgg: + case k_format_ogg: return tr("Ogg"); - case kFormatWebM: + case k_format_web_m: return tr("WebM"); - case kFormatSRT: + case k_format_srt: return tr("SubRip SRT"); - case kFormatCount: + case k_format_count: break; } return tr("Unknown"); } -QString ExportFormat::GetExtension(ExportFormat::Format f) +QString ExportFormat::get_extension(ExportFormat::Format f) { switch (f) { - case kFormatDNxHD: + case k_format_d_nx_hd: return QStringLiteral("mxf"); - case kFormatMatroska: + case k_format_matroska: return QStringLiteral("mkv"); - case kFormatMPEG4Video: + case k_format_mpe_g4_video: return QStringLiteral("mp4"); - case kFormatMPEG4Audio: + case k_format_mpe_g4_audio: return QStringLiteral("m4a"); - case kFormatOpenEXR: + case k_format_open_exr: return QStringLiteral("exr"); - case kFormatPNG: + case k_format_png: return QStringLiteral("png"); - case kFormatTIFF: + case k_format_tiff: return QStringLiteral("tiff"); - case kFormatQuickTime: + case k_format_quick_time: return QStringLiteral("mov"); - case kFormatWAV: + case k_format_wav: return QStringLiteral("wav"); - case kFormatAIFF: + case k_format_aiff: return QStringLiteral("aiff"); - case kFormatMP3: + case k_format_m_p3: return QStringLiteral("mp3"); - case kFormatFLAC: + case k_format_flac: return QStringLiteral("flac"); - case kFormatOgg: + case k_format_ogg: return QStringLiteral("ogg"); - case kFormatWebM: + case k_format_web_m: return QStringLiteral("webm"); - case kFormatSRT: + case k_format_srt: return QStringLiteral("srt"); - case kFormatCount: + case k_format_count: break; } return QString(); } -QList ExportFormat::GetVideoCodecs(ExportFormat::Format f) +QList ExportFormat::get_video_codecs(ExportFormat::Format f) { switch (f) { - case kFormatDNxHD: - return { ExportCodec::kCodecDNxHD }; - case kFormatMatroska: - return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb, - ExportCodec::kCodecH265, ExportCodec::kCodecVP9 }; - case kFormatMPEG4Video: - return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb, - ExportCodec::kCodecH265 }; - case kFormatOpenEXR: - return { ExportCodec::kCodecOpenEXR }; - case kFormatPNG: - return { ExportCodec::kCodecPNG }; - case kFormatTIFF: - return { ExportCodec::kCodecTIFF }; - case kFormatQuickTime: - return { ExportCodec::kCodecH264, ExportCodec::kCodecH264rgb, - ExportCodec::kCodecH265, ExportCodec::kCodecProRes, - ExportCodec::kCodecCineform }; - case kFormatWebM: - return { ExportCodec::kCodecAV1, ExportCodec::kCodecVP9 }; - case kFormatOgg: - case kFormatWAV: - case kFormatMPEG4Audio: - case kFormatAIFF: - case kFormatMP3: - case kFormatFLAC: - case kFormatSRT: - case kFormatCount: + case k_format_d_nx_hd: + return { ExportCodec::k_codec_d_nx_hd }; + case k_format_matroska: + return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb, + ExportCodec::k_codec_h265, ExportCodec::k_codec_v_p9 }; + case k_format_mpe_g4_video: + return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb, + ExportCodec::k_codec_h265 }; + case k_format_open_exr: + return { ExportCodec::k_codec_open_exr }; + case k_format_png: + return { ExportCodec::k_codec_png }; + case k_format_tiff: + return { ExportCodec::k_codec_tiff }; + case k_format_quick_time: + return { ExportCodec::k_codec_h264, ExportCodec::k_codec_h264rgb, + ExportCodec::k_codec_h265, ExportCodec::k_codec_pro_res, + ExportCodec::k_codec_cineform }; + case k_format_web_m: + return { ExportCodec::k_codec_a_v1, ExportCodec::k_codec_v_p9 }; + case k_format_ogg: + case k_format_wav: + case k_format_mpe_g4_audio: + case k_format_aiff: + case k_format_m_p3: + case k_format_flac: + case k_format_srt: + case k_format_count: break; } return {}; } -QList ExportFormat::GetAudioCodecs(ExportFormat::Format f) +QList ExportFormat::get_audio_codecs(ExportFormat::Format f) { switch (f) { // Video/audio formats - case kFormatDNxHD: - return { ExportCodec::kCodecPCM }; - case kFormatMatroska: - return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, - ExportCodec::kCodecMP3, ExportCodec::kCodecPCM, - ExportCodec::kCodecVorbis, ExportCodec::kCodecOpus, - ExportCodec::kCodecFLAC }; - case kFormatMPEG4Video: - case kFormatMPEG4Audio: - return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, - ExportCodec::kCodecMP3 }; - case kFormatQuickTime: - return { ExportCodec::kCodecAAC, ExportCodec::kCodecMP2, - ExportCodec::kCodecMP3, ExportCodec::kCodecPCM }; - case kFormatWebM: - return { ExportCodec::kCodecOpus, ExportCodec::kCodecAAC, - ExportCodec::kCodecMP2, ExportCodec::kCodecMP3, - ExportCodec::kCodecPCM, ExportCodec::kCodecVorbis }; + case k_format_d_nx_hd: + return { ExportCodec::k_codec_pcm }; + case k_format_matroska: + return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2, + ExportCodec::k_codec_m_p3, ExportCodec::k_codec_pcm, + ExportCodec::k_codec_vorbis, ExportCodec::k_codec_opus, + ExportCodec::k_codec_flac }; + case k_format_mpe_g4_video: + case k_format_mpe_g4_audio: + return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2, + ExportCodec::k_codec_m_p3 }; + case k_format_quick_time: + return { ExportCodec::k_codec_aac, ExportCodec::k_codec_m_p2, + ExportCodec::k_codec_m_p3, ExportCodec::k_codec_pcm }; + case k_format_web_m: + return { ExportCodec::k_codec_opus, ExportCodec::k_codec_aac, + ExportCodec::k_codec_m_p2, ExportCodec::k_codec_m_p3, + ExportCodec::k_codec_pcm, ExportCodec::k_codec_vorbis }; // Audio only formats - case kFormatWAV: - return { ExportCodec::kCodecPCM }; - case kFormatAIFF: - return { ExportCodec::kCodecPCM }; - case kFormatMP3: - return { ExportCodec::kCodecMP3 }; - case kFormatFLAC: - return { ExportCodec::kCodecFLAC }; - case kFormatOgg: - return { ExportCodec::kCodecOpus, ExportCodec::kCodecVorbis, - ExportCodec::kCodecPCM }; + case k_format_wav: + return { ExportCodec::k_codec_pcm }; + case k_format_aiff: + return { ExportCodec::k_codec_pcm }; + case k_format_m_p3: + return { ExportCodec::k_codec_m_p3 }; + case k_format_flac: + return { ExportCodec::k_codec_flac }; + case k_format_ogg: + return { ExportCodec::k_codec_opus, ExportCodec::k_codec_vorbis, + ExportCodec::k_codec_pcm }; // Video only formats - case kFormatOpenEXR: - case kFormatPNG: - case kFormatTIFF: - case kFormatSRT: - case kFormatCount: + case k_format_open_exr: + case k_format_png: + case k_format_tiff: + case k_format_srt: + case k_format_count: break; } return {}; } -QList ExportFormat::GetSubtitleCodecs(Format f) +QList ExportFormat::get_subtitle_codecs(Format f) { switch (f) { - case kFormatDNxHD: - case kFormatMPEG4Video: - case kFormatMPEG4Audio: - case kFormatOpenEXR: - case kFormatQuickTime: - case kFormatPNG: - case kFormatTIFF: - case kFormatWAV: - case kFormatAIFF: - case kFormatMP3: - case kFormatFLAC: - case kFormatOgg: - case kFormatWebM: - case kFormatCount: + case k_format_d_nx_hd: + case k_format_mpe_g4_video: + case k_format_mpe_g4_audio: + case k_format_open_exr: + case k_format_quick_time: + case k_format_png: + case k_format_tiff: + case k_format_wav: + case k_format_aiff: + case k_format_m_p3: + case k_format_flac: + case k_format_ogg: + case k_format_web_m: + case k_format_count: break; - case kFormatMatroska: - case kFormatSRT: - return { ExportCodec::kCodecSRT }; + case k_format_matroska: + case k_format_srt: + return { ExportCodec::k_codec_srt }; } return {}; } -QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f, +QStringList ExportFormat::get_pixel_formats_for_codec(ExportFormat::Format f, ExportCodec::Codec c) { - Encoder *e = Encoder::CreateFromFormat(f, EncodingParams()); + Encoder *e = Encoder::create_from_format(f, EncodingParams()); QStringList list; if (e) { - list = e->GetPixelFormatsForCodec(c); + list = e->get_pixel_formats_for_codec(c); delete e; } @@ -233,13 +233,13 @@ QStringList ExportFormat::GetPixelFormatsForCodec(ExportFormat::Format f, } std::vector -ExportFormat::GetSampleFormatsForCodec(Format format, ExportCodec::Codec c) +ExportFormat::get_sample_formats_for_codec(Format format, ExportCodec::Codec c) { std::vector f; - Encoder *e = Encoder::CreateFromFormat(format, EncodingParams()); + Encoder *e = Encoder::create_from_format(format, EncodingParams()); if (e) { - f = e->GetSampleFormatsForCodec(c); + f = e->get_sample_formats_for_codec(c); delete e; } diff --git a/app/codec/exportformat.h b/app/codec/exportformat.h index d1e1bcb3a..59975a51e 100644 --- a/app/codec/exportformat.h +++ b/app/codec/exportformat.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTFORMAT_H -#define EXPORTFORMAT_H +#ifndef OAK_EXPORTFORMAT_H +#define OAK_EXPORTFORMAT_H #include #include @@ -36,36 +36,36 @@ class ExportFormat : public QObject { public: // Only append to this list (never insert) because indexes are used in serialized files enum Format { - kFormatDNxHD, - kFormatMatroska, - kFormatMPEG4Video, - kFormatOpenEXR, - kFormatQuickTime, - kFormatPNG, - kFormatTIFF, - kFormatWAV, - kFormatAIFF, - kFormatMP3, - kFormatFLAC, - kFormatOgg, - kFormatWebM, - kFormatSRT, - kFormatMPEG4Audio, + k_format_d_nx_hd, + k_format_matroska, + k_format_mpe_g4_video, + k_format_open_exr, + k_format_quick_time, + k_format_png, + k_format_tiff, + k_format_wav, + k_format_aiff, + k_format_m_p3, + k_format_flac, + k_format_ogg, + k_format_web_m, + k_format_srt, + k_format_mpe_g4_audio, - kFormatCount + k_format_count }; - static QString GetName(Format f); - static QString GetExtension(Format f); - static QList GetVideoCodecs(ExportFormat::Format f); - static QList GetAudioCodecs(ExportFormat::Format f); - static QList GetSubtitleCodecs(ExportFormat::Format f); + static QString get_name(Format f); + static QString get_extension(Format f); + static QList get_video_codecs(ExportFormat::Format f); + static QList get_audio_codecs(ExportFormat::Format f); + static QList get_subtitle_codecs(ExportFormat::Format f); - static QStringList GetPixelFormatsForCodec(Format f, ExportCodec::Codec c); + static QStringList get_pixel_formats_for_codec(Format f, ExportCodec::Codec c); static std::vector - GetSampleFormatsForCodec(Format f, ExportCodec::Codec c); + get_sample_formats_for_codec(Format f, ExportCodec::Codec c); }; } -#endif // EXPORTFORMAT_H +#endif // OAK_EXPORTFORMAT_H diff --git a/app/codec/ffmpeg/ffmpegdecoder.cpp b/app/codec/ffmpeg/ffmpegdecoder.cpp index b5e3c87f0..ddd2100d4 100644 --- a/app/codec/ffmpeg/ffmpegdecoder.cpp +++ b/app/codec/ffmpeg/ffmpegdecoder.cpp @@ -40,16 +40,16 @@ namespace olive { -static FramePtr CopyPackedAVFrameToFrame(const AVFramePtr &src, +static FramePtr copy_packed_av_frame_to_frame(const AVFramePtr &src, PixelFormat format, int channel_count, - const rational ×tamp) + const Rational ×tamp) { if (!src || !src->data(0)) { return nullptr; } VideoParams params(src->width(), src->height(), format, channel_count); - FramePtr frame = Frame::Create(); + FramePtr frame = Frame::create(); frame->set_video_params(params); frame->set_timestamp(timestamp); if (!frame->allocate()) { @@ -57,7 +57,7 @@ static FramePtr CopyPackedAVFrameToFrame(const AVFramePtr &src, } const int row_bytes = params.effective_width() * - VideoParams::GetBytesPerPixel(format, channel_count); + VideoParams::get_bytes_per_pixel(format, channel_count); for (int y = 0; y < frame->height(); y++) { memcpy(frame->data() + y * frame->linesize_bytes(), src->data(0) + y * src->linesize(0), size_t(row_bytes)); @@ -66,34 +66,34 @@ static FramePtr CopyPackedAVFrameToFrame(const AVFramePtr &src, return frame; } -static VideoParams::Interlacing FFmpegFieldOrderToOlive(int fo) +static VideoParams::Interlacing f_fmpeg_field_order_to_olive(int fo) { switch (fo) { - case FB_FIELD_ORDER_TT: - return VideoParams::kInterlacedTopFirst; - case FB_FIELD_ORDER_BB: - return VideoParams::kInterlacedBottomFirst; - case FB_FIELD_ORDER_PROGRESSIVE: + case fb_field_order_tt: + return VideoParams::k_interlaced_top_first; + case fb_field_order_bb: + return VideoParams::k_interlaced_bottom_first; + case fb_field_order_progressive: default: - return VideoParams::kInterlaceNone; + return VideoParams::k_interlace_none; } } -QVariant Yuv2RgbShader; -QVariant DeinterlaceShader; +QVariant yuv2_rgb_shader; +QVariant deinterlace_shader; namespace { -int CancelThunk(void *userdata) +int cancel_thunk(void *userdata) { CancelAtom *cancelled = static_cast(userdata); - return (cancelled && cancelled->IsCancelled()) ? 1 : 0; + return (cancelled && cancelled->is_cancelled()) ? 1 : 0; } -TimecodeMetadata::SourceTime ExtractSourceStartTime(FBProbe *probe, +TimecodeMetadata::SourceTime extract_source_start_time(FBProbe *probe, int stream_index, - const rational &timebase, + const Rational &timebase, int sample_rate) { char buf[1024]; @@ -101,7 +101,7 @@ TimecodeMetadata::SourceTime ExtractSourceStartTime(FBProbe *probe, if (fb_probe_get_metadata(probe, stream_index, "timecode", buf, sizeof(buf)) == 1) { TimecodeMetadata::SourceTime parsed = - TimecodeMetadata::FromTimecodeString(QString::fromUtf8(buf), + TimecodeMetadata::from_timecode_string(QString::fromUtf8(buf), timebase); if (parsed.valid) { return parsed; @@ -111,7 +111,7 @@ TimecodeMetadata::SourceTime ExtractSourceStartTime(FBProbe *probe, if (fb_probe_get_metadata(probe, stream_index, "time_reference", buf, sizeof(buf)) == 1) { TimecodeMetadata::SourceTime parsed = - TimecodeMetadata::FromBwfTimeReference(QString::fromUtf8(buf), + TimecodeMetadata::from_bwf_time_reference(QString::fromUtf8(buf), sample_rate); if (parsed.valid) { return parsed; @@ -123,10 +123,10 @@ TimecodeMetadata::SourceTime ExtractSourceStartTime(FBProbe *probe, struct SubtitleReadContext { SubtitleParams *sub; - rational time_base; + Rational time_base; }; -void SubtitleReadThunk(int64_t pts, int64_t duration, const char *text, +void subtitle_read_thunk(int64_t pts, int64_t duration, const char *text, int text_size, void *userdata) { SubtitleReadContext *ctx = static_cast(userdata); @@ -149,13 +149,13 @@ FFmpegDecoder::FFmpegDecoder() , stream_start_time_(0) , stream_duration_(0) , format_start_time_(FB_NOPTS_VALUE) - , input_sample_format_(FB_SAMPLE_FMT_NONE) + , input_sample_format_(fb_sample_fmt_none) , input_sample_rate_(0) , input_channel_layout_mask_(0) { } -bool FFmpegDecoder::OpenInternal() +bool FFmpegDecoder::open_internal() { instance_ = fb_decoder_create(); if (!instance_) { @@ -172,7 +172,7 @@ bool FFmpegDecoder::OpenInternal() return false; } - stream_time_base_ = rational(info.time_base_num, info.time_base_den); + stream_time_base_ = Rational(info.time_base_num, info.time_base_den); stream_start_time_ = info.start_time; stream_duration_ = info.duration; format_start_time_ = fb_decoder_get_format_start_time(instance_); @@ -181,7 +181,7 @@ bool FFmpegDecoder::OpenInternal() input_channel_layout_mask_ = info.channel_layout_mask; // Store one second in the source's timebase - second_ts_ = qRound64(stream_time_base_.flipped().toDouble()); + second_ts_ = qRound64(stream_time_base_.flipped().to_double()); working_packet_ = fb_packet_alloc(); return true; @@ -191,67 +191,67 @@ bool FFmpegDecoder::OpenInternal() return false; } -TexturePtr FFmpegDecoder::ProcessFrameIntoTexture(AVFramePtr f, +TexturePtr FFmpegDecoder::process_frame_into_texture(AVFramePtr f, const RetrieveVideoParams &p, const AVFramePtr original) { // Determine native format - int ideal_fmt = FFmpegUtils::GetCompatibleBridgePixelFormat(f->format()); - PixelFormat native_fmt = GetNativePixelFormat(ideal_fmt); - int native_channels = GetNativeChannelCount(ideal_fmt); + int ideal_fmt = FFmpegUtils::get_compatible_bridge_pixel_format(f->format()); + PixelFormat native_fmt = get_native_pixel_format(ideal_fmt); + int native_channels = get_native_channel_count(ideal_fmt); // Determine pixel aspect ratio int sar_num, sar_den; - rational pixel_aspect_ratio(1, 1); + Rational pixel_aspect_ratio(1, 1); if (fb_decoder_guess_sample_aspect_ratio(instance_, nullptr, &sar_num, &sar_den) == 0 && sar_den != 0) { - pixel_aspect_ratio = rational(sar_num, sar_den); + pixel_aspect_ratio = Rational(sar_num, sar_den); } // Set up video params VideoParams vp(original->width(), original->height(), native_fmt, native_channels, pixel_aspect_ratio, - VideoParams::kInterlaceNone, p.divider); + VideoParams::k_interlace_none, p.divider); // For YUV formats, force the output texture to F32 RGBA for maximum precision switch (f->format()) { - case FB_PIX_FMT_YUV420P: - case FB_PIX_FMT_YUV422P: - case FB_PIX_FMT_YUV444P: - case FB_PIX_FMT_YUV420P10LE: - case FB_PIX_FMT_YUV422P10LE: - case FB_PIX_FMT_YUV444P10LE: - case FB_PIX_FMT_YUV420P12LE: - case FB_PIX_FMT_YUV422P12LE: - case FB_PIX_FMT_YUV444P12LE: - vp.set_format(PixelFormat::F32); - vp.set_channel_count(VideoParams::kRGBAChannelCount); + case fb_pix_fmt_yu_v420_p: + case fb_pix_fmt_yu_v422_p: + case fb_pix_fmt_yu_v444_p: + case fb_pix_fmt_yu_v420_p10_le: + case fb_pix_fmt_yu_v422_p10_le: + case fb_pix_fmt_yu_v444_p10_le: + case fb_pix_fmt_yu_v420_p12_le: + case fb_pix_fmt_yu_v422_p12_le: + case fb_pix_fmt_yu_v444_p12_le: + vp.set_format(PixelFormat::f32); + vp.set_channel_count(VideoParams::k_rgba_channel_count); break; default: break; } // Create texture - TexturePtr tex = p.renderer->CreateTexture(vp); + TexturePtr tex = p.renderer->create_texture(vp); switch (f->format()) { - case FB_PIX_FMT_YUV420P: - case FB_PIX_FMT_YUV422P: - case FB_PIX_FMT_YUV444P: - case FB_PIX_FMT_YUV420P10LE: - case FB_PIX_FMT_YUV422P10LE: - case FB_PIX_FMT_YUV444P10LE: - case FB_PIX_FMT_YUV420P12LE: - case FB_PIX_FMT_YUV422P12LE: - case FB_PIX_FMT_YUV444P12LE: { + case fb_pix_fmt_yu_v420_p: + case fb_pix_fmt_yu_v422_p: + case fb_pix_fmt_yu_v444_p: + case fb_pix_fmt_yu_v420_p10_le: + case fb_pix_fmt_yu_v422_p10_le: + case fb_pix_fmt_yu_v444_p10_le: + case fb_pix_fmt_yu_v420_p12_le: + case fb_pix_fmt_yu_v422_p12_le: + case fb_pix_fmt_yu_v444_p12_le: { // Run through YUV to RGB shader - if (Yuv2RgbShader.isNull()) { + if (yuv2_rgb_shader.isNull()) { // Compile shader - Yuv2RgbShader = p.renderer->CreateNativeShader( - ShaderCode(FileFunctions::ReadFileAsString( + yuv2_rgb_shader = p.renderer->create_native_shader( + ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/yuv2rgb.frag")))); - if (Yuv2RgbShader.isNull()) { + if (yuv2_rgb_shader.isNull()) { return nullptr; } } @@ -259,22 +259,22 @@ TexturePtr FFmpegDecoder::ProcessFrameIntoTexture(AVFramePtr f, int px_size; int bits_per_pixel; switch (f->format()) { - case FB_PIX_FMT_YUV420P: - case FB_PIX_FMT_YUV422P: - case FB_PIX_FMT_YUV444P: + case fb_pix_fmt_yu_v420_p: + case fb_pix_fmt_yu_v422_p: + case fb_pix_fmt_yu_v444_p: default: px_size = 1; bits_per_pixel = 8; break; - case FB_PIX_FMT_YUV420P10LE: - case FB_PIX_FMT_YUV422P10LE: - case FB_PIX_FMT_YUV444P10LE: + case fb_pix_fmt_yu_v420_p10_le: + case fb_pix_fmt_yu_v422_p10_le: + case fb_pix_fmt_yu_v444_p10_le: px_size = 2; bits_per_pixel = 10; break; - case FB_PIX_FMT_YUV420P12LE: - case FB_PIX_FMT_YUV422P12LE: - case FB_PIX_FMT_YUV444P12LE: + case fb_pix_fmt_yu_v420_p12_le: + case fb_pix_fmt_yu_v422_p12_le: + case fb_pix_fmt_yu_v444_p12_le: px_size = 2; bits_per_pixel = 12; break; @@ -286,98 +286,98 @@ TexturePtr FFmpegDecoder::ProcessFrameIntoTexture(AVFramePtr f, plane_params.set_channel_count(1); plane_params.set_format(native_fmt); - TexturePtr y_plane = p.renderer->CreateTexture( + TexturePtr y_plane = p.renderer->create_texture( plane_params, hw_in->data(0), hw_in->linesize(0) / px_size); - y_plane->handleFrame(hw_in); + y_plane->handle_frame(hw_in); switch (f->format()) { - case FB_PIX_FMT_YUV420P: - case FB_PIX_FMT_YUV422P: - case FB_PIX_FMT_YUV420P10LE: - case FB_PIX_FMT_YUV422P10LE: - case FB_PIX_FMT_YUV420P12LE: - case FB_PIX_FMT_YUV422P12LE: + case fb_pix_fmt_yu_v420_p: + case fb_pix_fmt_yu_v422_p: + case fb_pix_fmt_yu_v420_p10_le: + case fb_pix_fmt_yu_v422_p10_le: + case fb_pix_fmt_yu_v420_p12_le: + case fb_pix_fmt_yu_v422_p12_le: plane_params.set_width(plane_params.width() / 2); break; } switch (f->format()) { - case FB_PIX_FMT_YUV420P: - case FB_PIX_FMT_YUV420P10LE: - case FB_PIX_FMT_YUV420P12LE: + case fb_pix_fmt_yu_v420_p: + case fb_pix_fmt_yu_v420_p10_le: + case fb_pix_fmt_yu_v420_p12_le: plane_params.set_height(plane_params.height() / 2); break; } - TexturePtr u_plane = p.renderer->CreateTexture( + TexturePtr u_plane = p.renderer->create_texture( plane_params, hw_in->data(1), hw_in->linesize(1) / px_size); - u_plane->handleFrame(hw_in); + u_plane->handle_frame(hw_in); - TexturePtr v_plane = p.renderer->CreateTexture( + TexturePtr v_plane = p.renderer->create_texture( plane_params, hw_in->data(2), hw_in->linesize(2) / px_size); - v_plane->handleFrame(hw_in); + v_plane->handle_frame(hw_in); ShaderJob job; - job.Insert(QStringLiteral("y_channel"), - NodeValue(NodeValue::kTexture, + job.insert(QStringLiteral("y_channel"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(y_plane))); - job.Insert(QStringLiteral("u_channel"), - NodeValue(NodeValue::kTexture, + job.insert(QStringLiteral("u_channel"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(u_plane))); - job.Insert(QStringLiteral("v_channel"), - NodeValue(NodeValue::kTexture, + job.insert(QStringLiteral("v_channel"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(v_plane))); - job.Insert(QStringLiteral("bits_per_pixel"), - NodeValue(NodeValue::kInt, bits_per_pixel)); - job.Insert(QStringLiteral("full_range"), - NodeValue(NodeValue::kBoolean, - hw_in->color_range() == FB_COLOR_RANGE_JPEG)); + job.insert(QStringLiteral("bits_per_pixel"), + NodeValue(NodeValue::k_int, bits_per_pixel)); + job.insert(QStringLiteral("full_range"), + NodeValue(NodeValue::k_boolean, + hw_in->color_range() == fb_color_range_jpeg)); double yuv_coeffs[4]; fb_get_yuv_coefficients(hw_in->colorspace(), yuv_coeffs); - job.Insert(QStringLiteral("yuv_crv"), - NodeValue(NodeValue::kFloat, yuv_coeffs[0])); - job.Insert(QStringLiteral("yuv_cgu"), - NodeValue(NodeValue::kFloat, yuv_coeffs[2])); - job.Insert(QStringLiteral("yuv_cgv"), - NodeValue(NodeValue::kFloat, yuv_coeffs[3])); - job.Insert(QStringLiteral("yuv_cbu"), - NodeValue(NodeValue::kFloat, yuv_coeffs[1])); + job.insert(QStringLiteral("yuv_crv"), + NodeValue(NodeValue::k_float, yuv_coeffs[0])); + job.insert(QStringLiteral("yuv_cgu"), + NodeValue(NodeValue::k_float, yuv_coeffs[2])); + job.insert(QStringLiteral("yuv_cgv"), + NodeValue(NodeValue::k_float, yuv_coeffs[3])); + job.insert(QStringLiteral("yuv_cbu"), + NodeValue(NodeValue::k_float, yuv_coeffs[1])); - tex = p.renderer->CreateTexture(vp); - p.renderer->BlitToTexture(Yuv2RgbShader, job, tex.get(), false); + tex = p.renderer->create_texture(vp); + p.renderer->blit_to_texture(yuv2_rgb_shader, job, tex.get(), false); break; } - case FB_PIX_FMT_RGBA: - case FB_PIX_FMT_RGBA64LE: + case fb_pix_fmt_rgba: + case fb_pix_fmt_rgb_a64_le: // RGBA can be uploaded directly to the texture - tex->handleFrame(f); - tex->Upload(f->data(0), f->linesize(0) / vp.GetBytesPerPixel()); + tex->handle_frame(f); + tex->upload(f->data(0), f->linesize(0) / vp.get_bytes_per_pixel()); break; - case FB_PIX_FMT_RGBAF32LE: + case fb_pix_fmt_rgba_f32_le: // RGBA F32 can be uploaded directly to the texture - tex->handleFrame(f); - tex->Upload(f->data(0), f->linesize(0) / vp.GetBytesPerPixel()); + tex->handle_frame(f); + tex->upload(f->data(0), f->linesize(0) / vp.get_bytes_per_pixel()); break; } // Deinterlace if necessary - if (p.src_interlacing != VideoParams::kInterlaceNone) { - if (DeinterlaceShader.isNull()) { + if (p.src_interlacing != VideoParams::k_interlace_none) { + if (deinterlace_shader.isNull()) { // Compile shader - DeinterlaceShader = p.renderer->CreateNativeShader( - ShaderCode(FileFunctions::ReadFileAsString( + deinterlace_shader = p.renderer->create_native_shader( + ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/deinterlace2.frag")))); - if (DeinterlaceShader.isNull()) { + if (deinterlace_shader.isNull()) { return nullptr; } } int fr_num, fr_den; - rational frame_rate_tb; + Rational frame_rate_tb; if (fb_decoder_guess_frame_rate(instance_, original->handle(), &fr_num, &fr_den) == 0 && fr_num != 0) { - frame_rate_tb = rational(fr_num, fr_den); + frame_rate_tb = Rational(fr_num, fr_den); } // Double frame rate for interlaced fields @@ -387,28 +387,28 @@ TexturePtr FFmpegDecoder::ProcessFrameIntoTexture(AVFramePtr f, frame_rate_tb.flip(); int64_t req = Timecode::time_to_timestamp( - p.time + rational(format_start_time_, FB_TIME_BASE), frame_rate_tb); + p.time + Rational(format_start_time_, FB_TIME_BASE), frame_rate_tb); int64_t frm = Timecode::rescale_timestamp(original->pts(), stream_time_base_, frame_rate_tb); bool first = (req == frm); bool top_first = - (p.src_interlacing == VideoParams::kInterlacedTopFirst); + (p.src_interlacing == VideoParams::k_interlaced_top_first); int interlacing = (first == top_first) ? 1 : 2; - TexturePtr deinterlaced = p.renderer->CreateTexture(tex->params()); + TexturePtr deinterlaced = p.renderer->create_texture(tex->params()); ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), - NodeValue(NodeValue::kTexture, tex)); - job.Insert(QStringLiteral("interlacing"), - NodeValue(NodeValue::kInt, interlacing)); - job.Insert(QStringLiteral("pixel_height"), - NodeValue(NodeValue::kInt, original->height())); + job.insert(QStringLiteral("ove_maintex"), + NodeValue(NodeValue::k_texture, tex)); + job.insert(QStringLiteral("interlacing"), + NodeValue(NodeValue::k_int, interlacing)); + job.insert(QStringLiteral("pixel_height"), + NodeValue(NodeValue::k_int, original->height())); - p.renderer->BlitToTexture(DeinterlaceShader, job, deinterlaced.get(), + p.renderer->blit_to_texture(deinterlace_shader, job, deinterlaced.get(), false); tex = deinterlaced; @@ -417,25 +417,25 @@ TexturePtr FFmpegDecoder::ProcessFrameIntoTexture(AVFramePtr f, return tex; } -TexturePtr FFmpegDecoder::RetrieveVideoInternal(const RetrieveVideoParams &p) +TexturePtr FFmpegDecoder::retrieve_video_internal(const RetrieveVideoParams &p) { - if (AVFramePtr f = RetrieveFrame(p.time, p.cancelled)) { - if (p.cancelled && p.cancelled->IsCancelled()) { + if (AVFramePtr f = retrieve_frame(p.time, p.cancelled)) { + if (p.cancelled && p.cancelled->is_cancelled()) { return nullptr; } AVFramePtr original = f; // Disregard "JPEG" pixel formats because we allow the user to override that - f->set_format(FFmpegUtils::ConvertJPEGSpaceToRegularSpace(f->format())); + f->set_format(FFmpegUtils::convert_jpeg_space_to_regular_space(f->format())); // Force frame's color range to whatever it's set to in Olive - f->set_color_range(p.force_range == VideoParams::kColorRangeFull ? - FB_COLOR_RANGE_JPEG : - FB_COLOR_RANGE_MPEG); + f->set_color_range(p.force_range == VideoParams::k_color_range_full ? + fb_color_range_jpeg : + fb_color_range_mpeg); // Perform any CPU processing required - AVFramePtr ptr = PreProcessFrame(f, p); + AVFramePtr ptr = pre_process_frame(f, p); f = std::move(ptr); if (!f) { qWarning() << "PreProcessFrame failed"; @@ -443,7 +443,7 @@ TexturePtr FFmpegDecoder::RetrieveVideoInternal(const RetrieveVideoParams &p) } // Finally, perform any GPU processing required - TexturePtr texture = ProcessFrameIntoTexture(f, p, original); + TexturePtr texture = process_frame_into_texture(f, p, original); if (!texture) { qWarning() << "ProcessFrameIntoTexture returned null"; @@ -455,36 +455,36 @@ TexturePtr FFmpegDecoder::RetrieveVideoInternal(const RetrieveVideoParams &p) return nullptr; } -FramePtr FFmpegDecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) +FramePtr FFmpegDecoder::retrieve_video_frame_internal(const RetrieveVideoParams &p) { - if (AVFramePtr f = RetrieveFrame(p.time, p.cancelled)) { - if (p.cancelled && p.cancelled->IsCancelled()) { + if (AVFramePtr f = retrieve_frame(p.time, p.cancelled)) { + if (p.cancelled && p.cancelled->is_cancelled()) { return nullptr; } - f->set_format(FFmpegUtils::ConvertJPEGSpaceToRegularSpace(f->format())); - f->set_color_range(p.force_range == VideoParams::kColorRangeFull ? - FB_COLOR_RANGE_JPEG : - FB_COLOR_RANGE_MPEG); + f->set_format(FFmpegUtils::convert_jpeg_space_to_regular_space(f->format())); + f->set_color_range(p.force_range == VideoParams::k_color_range_full ? + fb_color_range_jpeg : + fb_color_range_mpeg); - AVFramePtr dest = CreateAVFramePtr(); + AVFramePtr dest = create_av_frame_ptr(); dest->set_width(f->width()); dest->set_height(f->height()); - dest->set_format(p.maximum_format == PixelFormat::U8 ? - FB_PIX_FMT_RGBA : - FB_PIX_FMT_RGBA64LE); + dest->set_format(p.maximum_format == PixelFormat::u8 ? + fb_pix_fmt_rgba : + fb_pix_fmt_rgb_a64_le); dest->set_color_range(f->color_range()); dest->set_colorspace(f->colorspace()); if (p.divider > 1) { dest->set_width( - VideoParams::GetScaledDimension(dest->width(), p.divider)); + VideoParams::get_scaled_dimension(dest->width(), p.divider)); dest->set_height( - VideoParams::GetScaledDimension(dest->height(), p.divider)); + VideoParams::get_scaled_dimension(dest->height(), p.divider)); } int r = dest->get_buffer(0); if (r < 0) { - FFmpegError(r); + f_fmpeg_error(r); return nullptr; } @@ -498,12 +498,12 @@ FramePtr FFmpegDecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) } fb_scaler_set_colorspace(cpu_scaler, dest->colorspace(), - dest->color_range() == FB_COLOR_RANGE_JPEG); + dest->color_range() == fb_color_range_jpeg); r = fb_scaler_scale_frame(cpu_scaler, dest->handle(), f->handle()); fb_scaler_free(&cpu_scaler); if (r < 0) { - FFmpegError(r); + f_fmpeg_error(r); return nullptr; } @@ -513,7 +513,7 @@ FramePtr FFmpegDecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) // management shader later multiplies RGB by alpha, producing black. // Ensure alpha is opaque for source formats that have no alpha. if (!fb_pix_fmt_has_alpha(f->format())) { - const int bpc = (dest->format() == FB_PIX_FMT_RGBA) ? 1 : 2; + const int bpc = (dest->format() == fb_pix_fmt_rgba) ? 1 : 2; const int stride = dest->linesize(0); for (int y = 0; y < dest->height(); ++y) { uchar *row = dest->data(0) + y * stride; @@ -527,36 +527,36 @@ FramePtr FFmpegDecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) } } - return CopyPackedAVFrameToFrame(dest, - dest->format() == FB_PIX_FMT_RGBA ? - PixelFormat::U8 : - PixelFormat::U16, - VideoParams::kRGBAChannelCount, p.time); + return copy_packed_av_frame_to_frame(dest, + dest->format() == fb_pix_fmt_rgba ? + PixelFormat::u8 : + PixelFormat::u16, + VideoParams::k_rgba_channel_count, p.time); } return nullptr; } -void FFmpegDecoder::CloseInternal() +void FFmpegDecoder::close_internal() { if (working_packet_) { fb_packet_free(&working_packet_); working_packet_ = nullptr; } - ClearFrameCache(); - FreeScaler(); + clear_frame_cache(); + free_scaler(); if (instance_) { fb_decoder_free(&instance_); } } -rational FFmpegDecoder::GetAudioStartOffset() const +Rational FFmpegDecoder::get_audio_start_offset() const { if (instance_) { - rational fmt_start = rational(format_start_time_, FB_TIME_BASE); - rational str_start = stream_time_base_ * stream_start_time_; + Rational fmt_start = Rational(format_start_time_, FB_TIME_BASE); + Rational str_start = stream_time_base_ * stream_start_time_; return str_start - fmt_start; } else { return 0; @@ -568,7 +568,7 @@ QString FFmpegDecoder::id() const return QStringLiteral("ffmpeg"); } -FootageDescription FFmpegDecoder::Probe(const QString &filename, +FootageDescription FFmpegDecoder::probe(const QString &filename, CancelAtom *cancelled) const { // Return value @@ -587,8 +587,8 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, // Handle open error if (error_code == 0) { int64_t footage_duration = fb_probe_get_duration(probe); - TimecodeMetadata::SourceTime source_start_time = ExtractSourceStartTime( - probe, -1, rational(1, FB_TIME_BASE), 0); + TimecodeMetadata::SourceTime source_start_time = extract_source_start_time( + probe, -1, Rational(1, FB_TIME_BASE), 0); bool duration_guessed_from_bitrate = fb_probe_duration_from_bitrate(probe) != 0; @@ -607,10 +607,10 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, continue; } - rational stream_tb(info.time_base_num, info.time_base_den); + Rational stream_tb(info.time_base_num, info.time_base_den); if (!source_start_time.valid) { - source_start_time = ExtractSourceStartTime(probe, i, stream_tb, + source_start_time = extract_source_start_time(probe, i, stream_tb, info.sample_rate); } @@ -619,15 +619,15 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, continue; } - if (info.codec_type == FB_MEDIA_TYPE_VIDEO) { + if (info.codec_type == fb_media_type_video) { // Read at least two frames to get more information about this video stream VideoParams::Interlacing interlacing = - VideoParams::kInterlaceNone; - rational pixel_aspect_ratio(1, 1); - rational frame_rate(info.avg_frame_rate_num, + VideoParams::k_interlace_none; + Rational pixel_aspect_ratio(1, 1); + Rational frame_rate(info.avg_frame_rate_num, info.avg_frame_rate_den); int compatible_pix_fmt = - FFmpegUtils::GetCompatibleBridgePixelFormat(info.pixel_format); + FFmpegUtils::get_compatible_bridge_pixel_format(info.pixel_format); bool image_is_still = false; int64_t stream_duration = info.duration; @@ -640,16 +640,16 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, FBVideoStreamDetails details; if (fb_probe_video_stream_details(filename_c, i, &details, decode_full_duration, - CancelThunk, + cancel_thunk, cancelled) == 0) { - interlacing = FFmpegFieldOrderToOlive(details.field_order); + interlacing = f_fmpeg_field_order_to_olive(details.field_order); if (details.pixel_aspect_den != 0) { - pixel_aspect_ratio = rational(details.pixel_aspect_num, + pixel_aspect_ratio = Rational(details.pixel_aspect_num, details.pixel_aspect_den); } if (details.frame_rate_num != 0 && details.frame_rate_den != 0) { - frame_rate = rational(details.frame_rate_num, + frame_rate = Rational(details.frame_rate_num, details.frame_rate_den); } image_is_still = details.is_still != 0; @@ -663,26 +663,26 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, stream.set_width(info.width); stream.set_height(info.height); stream.set_video_type(image_is_still ? - VideoParams::kVideoTypeStill : - VideoParams::kVideoTypeVideo); - stream.set_format(GetNativePixelFormat(compatible_pix_fmt)); + VideoParams::k_video_type_still : + VideoParams::k_video_type_video); + stream.set_format(get_native_pixel_format(compatible_pix_fmt)); stream.set_channel_count( - GetNativeChannelCount(compatible_pix_fmt)); + get_native_channel_count(compatible_pix_fmt)); stream.set_interlacing(interlacing); stream.set_pixel_aspect_ratio(pixel_aspect_ratio); stream.set_frame_rate(frame_rate); stream.set_start_time(info.start_time); stream.set_time_base(stream_tb); stream.set_duration(stream_duration); - stream.set_color_range(info.color_range == FB_COLOR_RANGE_JPEG ? - VideoParams::kColorRangeFull : - VideoParams::kColorRangeLimited); + stream.set_color_range(info.color_range == fb_color_range_jpeg ? + VideoParams::k_color_range_full : + VideoParams::k_color_range_limited); stream.set_premultiplied_alpha(false); - desc.AddVideoStream(stream); + desc.add_video_stream(stream); image_is_still ? still_streams++ : video_streams++; - } else if (info.codec_type == FB_MEDIA_TYPE_AUDIO) { + } else if (info.codec_type == fb_media_type_audio) { int64_t stream_duration = info.duration; if (stream_duration == FB_NOPTS_VALUE || @@ -692,13 +692,13 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, duration_guessed_from_bitrate) { int64_t decoded_duration = FB_NOPTS_VALUE; if (fb_probe_audio_stream_duration( - filename_c, i, &decoded_duration, CancelThunk, + filename_c, i, &decoded_duration, cancel_thunk, cancelled) == 0) { stream_duration = decoded_duration; } } else { stream_duration = Timecode::rescale_timestamp_ceil( - footage_duration, rational(1, FB_TIME_BASE), + footage_duration, Rational(1, FB_TIME_BASE), stream_tb); } } @@ -708,29 +708,29 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, stream.set_channel_layout(info.channel_layout_mask); stream.set_sample_rate(info.sample_rate); stream.set_format( - FFmpegUtils::GetNativeSampleFormat(info.sample_format)); + FFmpegUtils::get_native_sample_format(info.sample_format)); stream.set_time_base(stream_tb); stream.set_duration(stream_duration); - desc.AddAudioStream(stream); + desc.add_audio_stream(stream); audio_streams++; - } else if (info.codec_type == FB_MEDIA_TYPE_SUBTITLE) { + } else if (info.codec_type == fb_media_type_subtitle) { // The bridge limits this to SRT, matching our historical behavior SubtitleParams sub; SubtitleReadContext ctx = { &sub, stream_tb }; if (fb_probe_read_subtitle_stream(filename_c, i, - SubtitleReadThunk, + subtitle_read_thunk, &ctx) == 0) { - desc.AddSubtitleStream(sub); + desc.add_subtitle_stream(sub); } } } - desc.SetStreamCount(stream_count); + desc.set_stream_count(stream_count); if (source_start_time.valid) { - desc.SetSourceStartTime(source_start_time.time, + desc.set_source_start_time(source_start_time.time, source_start_time.source); } @@ -739,7 +739,7 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, // imported a song with embedded album art that most people don't care about. We'll keep the // stills referenced in case users do, but we'll default them to disabled so they're // easier to work with. - for (VideoParams &vp : desc.GetVideoStreams()) { + for (VideoParams &vp : desc.get_video_streams()) { vp.set_enabled(false); } } @@ -751,14 +751,14 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename, return desc; } -QString FFmpegDecoder::FFmpegError(int error_code) +QString FFmpegDecoder::f_fmpeg_error(int error_code) { char err[1024]; fb_error_string(error_code, err, 512); return QStringLiteral("%1 %2").arg(QString::number(error_code), err); } -bool FFmpegDecoder::ConformAudioInternal(const QVector &filenames, +bool FFmpegDecoder::conform_audio_internal(const QVector &filenames, const AudioParams ¶ms, CancelAtom *cancelled) { @@ -777,7 +777,7 @@ bool FFmpegDecoder::ConformAudioInternal(const QVector &filenames, // Create resampler FBResampler *resampler = fb_resampler_create( params.channel_layout(), - FFmpegUtils::GetFFmpegSampleFormat(params.format()), + FFmpegUtils::get_f_fmpeg_sample_format(params.format()), params.sample_rate(), input_channel_layout_mask_, input_sample_format_, input_sample_rate_); if (!resampler) { @@ -797,7 +797,7 @@ bool FFmpegDecoder::ConformAudioInternal(const QVector &filenames, if (!(duration == 0 || duration == FB_NOPTS_VALUE)) { // Rescale from format timebase to stream timebase duration = Timecode::rescale_timestamp_ceil( - duration, rational(1, FB_TIME_BASE), stream_time_base_); + duration, Rational(1, FB_TIME_BASE), stream_time_base_); } } @@ -809,7 +809,7 @@ bool FFmpegDecoder::ConformAudioInternal(const QVector &filenames, while (true) { // Check if we have a `cancelled` ptr and its value - if (cancelled && cancelled->IsCancelled()) { + if (cancelled && cancelled->is_cancelled()) { break; } @@ -866,7 +866,7 @@ bool FFmpegDecoder::ConformAudioInternal(const QVector &filenames, break; } - SignalProcessingProgress(fb_frame_get_best_effort_timestamp(frame), + signal_processing_progress(fb_frame_get_best_effort_timestamp(frame), duration); } @@ -883,63 +883,63 @@ bool FFmpegDecoder::ConformAudioInternal(const QVector &filenames, return success; } -PixelFormat FFmpegDecoder::GetNativePixelFormat(int pix_fmt) +PixelFormat FFmpegDecoder::get_native_pixel_format(int pix_fmt) { switch (pix_fmt) { - case FB_PIX_FMT_RGB24: - case FB_PIX_FMT_RGBA: - return PixelFormat::U8; - case FB_PIX_FMT_RGB48LE: - case FB_PIX_FMT_RGBA64LE: - return PixelFormat::U16; - case FB_PIX_FMT_RGBF32LE: - case FB_PIX_FMT_RGBAF32LE: - return PixelFormat::F32; + case fb_pix_fmt_rg_b24: + case fb_pix_fmt_rgba: + return PixelFormat::u8; + case fb_pix_fmt_rg_b48_le: + case fb_pix_fmt_rgb_a64_le: + return PixelFormat::u16; + case fb_pix_fmt_rgb_f32_le: + case fb_pix_fmt_rgba_f32_le: + return PixelFormat::f32; default: - return PixelFormat::INVALID; + return PixelFormat::invalid; } } -int FFmpegDecoder::GetNativeChannelCount(int pix_fmt) +int FFmpegDecoder::get_native_channel_count(int pix_fmt) { switch (pix_fmt) { - case FB_PIX_FMT_RGB24: - case FB_PIX_FMT_RGB48LE: - case FB_PIX_FMT_RGBF32LE: - return VideoParams::kRGBChannelCount; - case FB_PIX_FMT_RGBA: - case FB_PIX_FMT_RGBA64LE: - case FB_PIX_FMT_RGBAF32LE: - return VideoParams::kRGBAChannelCount; + case fb_pix_fmt_rg_b24: + case fb_pix_fmt_rg_b48_le: + case fb_pix_fmt_rgb_f32_le: + return VideoParams::k_rgb_channel_count; + case fb_pix_fmt_rgba: + case fb_pix_fmt_rgb_a64_le: + case fb_pix_fmt_rgba_f32_le: + return VideoParams::k_rgba_channel_count; default: return 0; } } -bool FFmpegDecoder::IsPixelFormatGLSLCompatible(int f) +bool FFmpegDecoder::is_pixel_format_glsl_compatible(int f) { // NOTE: We don't include RGB24 or RGB48 here because those are slow on the GPU and performance // should be better if we convert to RGBA on the CPU beforehand switch (f) { - case FB_PIX_FMT_YUV420P: - case FB_PIX_FMT_YUV422P: - case FB_PIX_FMT_YUV444P: - case FB_PIX_FMT_YUV420P10LE: - case FB_PIX_FMT_YUV422P10LE: - case FB_PIX_FMT_YUV444P10LE: - case FB_PIX_FMT_YUV420P12LE: - case FB_PIX_FMT_YUV422P12LE: - case FB_PIX_FMT_YUV444P12LE: - case FB_PIX_FMT_RGBA: - case FB_PIX_FMT_RGBA64LE: - case FB_PIX_FMT_RGBAF32LE: + case fb_pix_fmt_yu_v420_p: + case fb_pix_fmt_yu_v422_p: + case fb_pix_fmt_yu_v444_p: + case fb_pix_fmt_yu_v420_p10_le: + case fb_pix_fmt_yu_v422_p10_le: + case fb_pix_fmt_yu_v444_p10_le: + case fb_pix_fmt_yu_v420_p12_le: + case fb_pix_fmt_yu_v422_p12_le: + case fb_pix_fmt_yu_v444_p12_le: + case fb_pix_fmt_rgba: + case fb_pix_fmt_rgb_a64_le: + case fb_pix_fmt_rgba_f32_le: return true; default: return false; } } -void FFmpegDecoder::ClearFrameCache() +void FFmpegDecoder::clear_frame_cache() { if (!cached_frames_.empty()) { cached_frames_.clear(); @@ -948,21 +948,21 @@ void FFmpegDecoder::ClearFrameCache() } } -AVFramePtr FFmpegDecoder::PreProcessFrame(AVFramePtr f, +AVFramePtr FFmpegDecoder::pre_process_frame(AVFramePtr f, const RetrieveVideoParams &p) { // In pre-processing, we try to achieve the following: // - If a divider is being used, scale down the image // - If a pixel format is not compatible with the GLSL shader, convert it to RGBA ourselves - if (p.divider == 1 && IsPixelFormatGLSLCompatible(f->format())) { + if (p.divider == 1 && is_pixel_format_glsl_compatible(f->format())) { // No CPU processing required, the user wants this in full resolution and the pixel format can // be converted on the GPU return f; } // Some scaling and/or format conversion needs to be done - AVFramePtr dest = CreateAVFramePtr(); + AVFramePtr dest = create_av_frame_ptr(); dest->set_width(f->width()); dest->set_height(f->height()); @@ -971,24 +971,24 @@ AVFramePtr FFmpegDecoder::PreProcessFrame(AVFramePtr f, dest->set_colorspace(f->colorspace()); if (p.divider > 1) { dest->set_width( - VideoParams::GetScaledDimension(dest->width(), p.divider)); + VideoParams::get_scaled_dimension(dest->width(), p.divider)); dest->set_height( - VideoParams::GetScaledDimension(dest->height(), p.divider)); + VideoParams::get_scaled_dimension(dest->height(), p.divider)); } - if (!IsPixelFormatGLSLCompatible(dest->format())) { - dest->set_format(FFmpegUtils::GetCompatibleBridgePixelFormat(dest->format(), + if (!is_pixel_format_glsl_compatible(dest->format())) { + dest->set_format(FFmpegUtils::get_compatible_bridge_pixel_format(dest->format(), p.maximum_format)); } // swscale does not support RGBAF32 as output, fallback to RGBA64 - if (dest->format() == FB_PIX_FMT_RGBAF32LE) { - dest->set_format(FB_PIX_FMT_RGBA64LE); + if (dest->format() == fb_pix_fmt_rgba_f32_le) { + dest->set_format(fb_pix_fmt_rgb_a64_le); } int r = dest->get_buffer(0); if (r < 0) { - FFmpegError(r); + f_fmpeg_error(r); return nullptr; } @@ -1001,7 +1001,7 @@ AVFramePtr FFmpegDecoder::PreProcessFrame(AVFramePtr f, scaler_colrange_ != dest->color_range() || scaler_colspace_ != dest->colorspace()) { // Scaler must be recreated, destroy current if it exists - FreeScaler(); + free_scaler(); // Cache info scaler_src_width_ = f->width(); @@ -1022,40 +1022,40 @@ AVFramePtr FFmpegDecoder::PreProcessFrame(AVFramePtr f, // Set the scaler's colorspace details fb_scaler_set_colorspace( scaler_, scaler_colspace_, - scaler_colrange_ == FB_COLOR_RANGE_JPEG); + scaler_colrange_ == fb_color_range_jpeg); } r = fb_scaler_scale_frame(scaler_, dest->handle(), f->handle()); if (r < 0) { - FFmpegError(r); + f_fmpeg_error(r); return nullptr; } return dest; } -AVFramePtr FFmpegDecoder::RetrieveFrame(const rational &time, +AVFramePtr FFmpegDecoder::retrieve_frame(const Rational &time, CancelAtom *cancelled) { int64_t target_ts = Timecode::time_to_timestamp(time, stream_time_base_); if (format_start_time_ != FB_NOPTS_VALUE) { target_ts += Timecode::rescale_timestamp(format_start_time_, - rational(1, FB_TIME_BASE), + Rational(1, FB_TIME_BASE), stream_time_base_); } const int64_t min_seek = 0; - int64_t seek_ts = std::max(min_seek, target_ts - MaximumQueueSize()); + int64_t seek_ts = std::max(min_seek, target_ts - maximum_queue_size()); bool still_seeking = false; - if (time != kAnyTimecode) { + if (time != k_any_timecode) { // If the frame wasn't in the frame cache, see if this frame cache is too old to use if (cached_frames_.empty() || (target_ts < cached_frames_.front()->pts() || target_ts > cached_frames_.back()->pts() + 2 * second_ts_)) { - ClearFrameCache(); + clear_frame_cache(); fb_decoder_seek(instance_, seek_ts); if (seek_ts == min_seek) { @@ -1065,7 +1065,7 @@ AVFramePtr FFmpegDecoder::RetrieveFrame(const rational &time, still_seeking = true; } else { // Search cache for frame - AVFramePtr cached_frame = GetFrameFromCache(target_ts); + AVFramePtr cached_frame = get_frame_from_cache(target_ts); if (cached_frame) { return cached_frame; } @@ -1079,19 +1079,19 @@ AVFramePtr FFmpegDecoder::RetrieveFrame(const rational &time, while (true) { // Break out of loop if we've cancelled - if (cancelled && cancelled->IsCancelled()) { + if (cancelled && cancelled->is_cancelled()) { break; } if (!filtered) { - filtered = CreateAVFramePtr(); + filtered = create_av_frame_ptr(); } // Pull from the decoder ret = fb_decoder_get_frame(instance_, working_packet_, filtered->handle()); - if (cancelled && cancelled->IsCancelled()) { + if (cancelled && cancelled->is_cancelled()) { break; } @@ -1126,7 +1126,7 @@ AVFramePtr FFmpegDecoder::RetrieveFrame(const rational &time, if (cached_frames_.empty()) { if (!retried_after_eof) { retried_after_eof = true; - ClearFrameCache(); + clear_frame_cache(); fb_decoder_seek(instance_, min_seek); cache_at_zero_ = true; still_seeking = true; @@ -1143,8 +1143,8 @@ AVFramePtr FFmpegDecoder::RetrieveFrame(const rational &time, } else { // Cut down to thread count - 1 before we acquire a new frame - if (cached_frames_.size() > size_t(MaximumQueueSize())) { - RemoveFirstFrame(); + if (cached_frames_.size() > size_t(maximum_queue_size())) { + remove_first_frame(); } // Store frame before just in case @@ -1156,13 +1156,13 @@ AVFramePtr FFmpegDecoder::RetrieveFrame(const rational &time, } // Transfer hardware decoded frames to system memory before caching. - filtered = TransferHardwareFrame(filtered); + filtered = transfer_hardware_frame(filtered); // Append this frame and signal to other threads that a new frame has arrived cached_frames_.push_back(filtered); // If this is a valid frame, see if this or the frame before it are the one we need - if (filtered->pts() == target_ts || time == kAnyTimecode) { + if (filtered->pts() == target_ts || time == k_any_timecode) { return_frame = filtered; break; } else if (filtered->pts() > target_ts) { @@ -1184,7 +1184,7 @@ AVFramePtr FFmpegDecoder::RetrieveFrame(const rational &time, return return_frame; } -AVFramePtr FFmpegDecoder::TransferHardwareFrame(AVFramePtr f) +AVFramePtr FFmpegDecoder::transfer_hardware_frame(AVFramePtr f) { if (!fb_decoder_hwaccel_enabled(instance_) || !fb_frame_is_hw(f->handle())) { @@ -1201,7 +1201,7 @@ AVFramePtr FFmpegDecoder::TransferHardwareFrame(AVFramePtr f) int ret = fb_frame_hw_transfer_data(sw_frame, f->handle()); if (ret < 0) { qWarning() << "Failed to transfer hardware frame to system memory:" - << FFmpegError(ret); + << f_fmpeg_error(ret); fb_frame_free(&sw_frame); return nullptr; } @@ -1210,20 +1210,20 @@ AVFramePtr FFmpegDecoder::TransferHardwareFrame(AVFramePtr f) if (ret < 0) { qWarning() << "Failed to copy frame properties during hardware transfer:" - << FFmpegError(ret); + << f_fmpeg_error(ret); } - return CreateAVFramePtr(sw_frame); + return create_av_frame_ptr(sw_frame); } -void FFmpegDecoder::FreeScaler() +void FFmpegDecoder::free_scaler() { if (scaler_) { fb_scaler_free(&scaler_); } } -AVFramePtr FFmpegDecoder::GetFrameFromCache(const int64_t &t) const +AVFramePtr FFmpegDecoder::get_frame_from_cache(const int64_t &t) const { if (t < cached_frames_.front()->pts()) { if (cache_at_zero_) { @@ -1257,13 +1257,13 @@ AVFramePtr FFmpegDecoder::GetFrameFromCache(const int64_t &t) const return nullptr; } -void FFmpegDecoder::RemoveFirstFrame() +void FFmpegDecoder::remove_first_frame() { cached_frames_.pop_front(); cache_at_zero_ = false; } -int FFmpegDecoder::MaximumQueueSize() +int FFmpegDecoder::maximum_queue_size() { // Fairly arbitrary size. This used to need to be the number of current threads to ensure any // thread that arrived would have its frame available, but if we only have one render thread, diff --git a/app/codec/ffmpeg/ffmpegdecoder.h b/app/codec/ffmpeg/ffmpegdecoder.h index 7019b8c60..e0356de2a 100644 --- a/app/codec/ffmpeg/ffmpegdecoder.h +++ b/app/codec/ffmpeg/ffmpegdecoder.h @@ -19,8 +19,8 @@ ***/ -#ifndef FFMPEGDECODER_H -#define FFMPEGDECODER_H +#ifndef OAK_FFMPEGDECODER_H +#define OAK_FFMPEGDECODER_H #include @@ -53,30 +53,30 @@ public: virtual QString id() const override; - virtual bool SupportsVideo() override + virtual bool supports_video() override { return true; } - virtual bool SupportsAudio() override + virtual bool supports_audio() override { return true; } - virtual FootageDescription Probe(const QString &filename, + virtual FootageDescription probe(const QString &filename, CancelAtom *cancelled) const override; protected: - virtual bool OpenInternal() override; + virtual bool open_internal() override; virtual TexturePtr - RetrieveVideoInternal(const RetrieveVideoParams &p) override; + retrieve_video_internal(const RetrieveVideoParams &p) override; virtual FramePtr - RetrieveVideoFrameInternal(const RetrieveVideoParams &p) override; - virtual bool ConformAudioInternal(const QVector &filenames, + retrieve_video_frame_internal(const RetrieveVideoParams &p) override; + virtual bool conform_audio_internal(const QVector &filenames, const AudioParams ¶ms, CancelAtom *cancelled) override; - virtual void CloseInternal() override; + virtual void close_internal() override; - virtual rational GetAudioStartOffset() const override; + virtual Rational get_audio_start_offset() const override; private: /** @@ -87,32 +87,32 @@ private: * * @param error_code */ - static QString FFmpegError(int error_code); + static QString f_fmpeg_error(int error_code); - void FreeScaler(); + void free_scaler(); - AVFramePtr TransferHardwareFrame(AVFramePtr f); + AVFramePtr transfer_hardware_frame(AVFramePtr f); - static PixelFormat GetNativePixelFormat(int pix_fmt); - static int GetNativeChannelCount(int pix_fmt); + static PixelFormat get_native_pixel_format(int pix_fmt); + static int get_native_channel_count(int pix_fmt); - static bool IsPixelFormatGLSLCompatible(int f); + static bool is_pixel_format_glsl_compatible(int f); - AVFramePtr GetFrameFromCache(const int64_t &t) const; + AVFramePtr get_frame_from_cache(const int64_t &t) const; - void ClearFrameCache(); + void clear_frame_cache(); - AVFramePtr PreProcessFrame(AVFramePtr f, const RetrieveVideoParams &p); + AVFramePtr pre_process_frame(AVFramePtr f, const RetrieveVideoParams &p); - TexturePtr ProcessFrameIntoTexture(AVFramePtr f, + TexturePtr process_frame_into_texture(AVFramePtr f, const RetrieveVideoParams &p, const AVFramePtr original); - AVFramePtr RetrieveFrame(const rational &time, CancelAtom *cancelled); + AVFramePtr retrieve_frame(const Rational &time, CancelAtom *cancelled); - void RemoveFirstFrame(); + void remove_first_frame(); - static int MaximumQueueSize(); + static int maximum_queue_size(); FBScaler *scaler_; int scaler_src_width_; @@ -137,7 +137,7 @@ private: // Stream parameters cached on open (the stream object itself lives // inside the bridge library) - rational stream_time_base_; + Rational stream_time_base_; int64_t stream_start_time_; int64_t stream_duration_; int64_t format_start_time_; @@ -148,4 +148,4 @@ private: } -#endif // FFMPEGDECODER_H +#endif // OAK_FFMPEGDECODER_H diff --git a/app/codec/ffmpeg/ffmpegencoder.cpp b/app/codec/ffmpeg/ffmpegencoder.cpp index 0dacd9176..54de69731 100644 --- a/app/codec/ffmpeg/ffmpegencoder.cpp +++ b/app/codec/ffmpeg/ffmpegencoder.cpp @@ -38,12 +38,12 @@ FFmpegEncoder::FFmpegEncoder(const EncodingParams ¶ms) { } -QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const +QStringList FFmpegEncoder::get_pixel_formats_for_codec(ExportCodec::Codec c) const { QStringList pix_fmts; - int bridge_codec = ExportCodecToBridge(c); - if (bridge_codec != FB_CODEC_NONE) { + int bridge_codec = export_codec_to_bridge(c); + if (bridge_codec != fb_codec_none) { int count = fb_encoder_codec_get_pixel_formats(bridge_codec, nullptr, 0); if (count > 0) { @@ -60,19 +60,19 @@ QStringList FFmpegEncoder::GetPixelFormatsForCodec(ExportCodec::Codec c) const } std::vector -FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const +FFmpegEncoder::get_sample_formats_for_codec(ExportCodec::Codec c) const { std::vector f; - if (c == ExportCodec::kCodecPCM) { + if (c == ExportCodec::k_codec_pcm) { // FFmpeg lists these as separate codecs so we need custom functionality here // We list signed 16 first because ExportDialog will always use the first element by default // (because first element is the "default" in FFmpeg) - f = { SampleFormat::S16, SampleFormat::U8, SampleFormat::S32, - SampleFormat::S64, SampleFormat::F32, SampleFormat::F64 }; + f = { SampleFormat::s16, SampleFormat::u8, SampleFormat::s32, + SampleFormat::s64, SampleFormat::f32, SampleFormat::f64 }; } else { - int bridge_codec = ExportCodecToBridge(c); - if (bridge_codec != FB_CODEC_NONE) { + int bridge_codec = export_codec_to_bridge(c); + if (bridge_codec != fb_codec_none) { int count = fb_encoder_codec_get_sample_formats(bridge_codec, nullptr, 0); if (count > 0) { @@ -81,8 +81,8 @@ FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const count); for (int fmt : fmts) { SampleFormat native = - FFmpegUtils::GetNativeSampleFormat(fmt); - if (native != SampleFormat::INVALID) { + FFmpegUtils::get_native_sample_format(fmt); + if (native != SampleFormat::invalid) { f.push_back(native); } } @@ -93,7 +93,7 @@ FFmpegEncoder::GetSampleFormatsForCodec(ExportCodec::Codec c) const return f; } -bool FFmpegEncoder::Open() +bool FFmpegEncoder::open() { if (open_) { return true; @@ -117,7 +117,7 @@ bool FFmpegEncoder::Open() // Set up video if it's enabled if (params().video_enabled()) { config.video_enabled = 1; - config.video_codec = ExportCodecToBridge(params().video_codec()); + config.video_codec = export_codec_to_bridge(params().video_codec()); config.video_width = params().video_params().width(); config.video_height = params().video_params().height(); config.video_pixel_aspect_num = @@ -141,17 +141,17 @@ bool FFmpegEncoder::Open() // This is the format we will need to convert the frame to for the bridge to understand it video_conversion_fmt_ = - FFmpegUtils::GetCompatiblePixelFormat(native_pixel_fmt); + FFmpegUtils::get_compatible_pixel_format(native_pixel_fmt); // These are the equivalent pixel formats as bridge pixel formats - int src_alpha_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat( - video_conversion_fmt_, VideoParams::kRGBAChannelCount); - int src_noalpha_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat( - video_conversion_fmt_, VideoParams::kRGBChannelCount); + int src_alpha_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format( + video_conversion_fmt_, VideoParams::k_rgba_channel_count); + int src_noalpha_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format( + video_conversion_fmt_, VideoParams::k_rgb_channel_count); - if (src_alpha_pix_fmt == FB_PIX_FMT_NONE || - src_noalpha_pix_fmt == FB_PIX_FMT_NONE) { - SetError( + if (src_alpha_pix_fmt == fb_pix_fmt_none || + src_noalpha_pix_fmt == fb_pix_fmt_none) { + set_error( tr("Failed to find suitable pixel format for this buffer")); return false; } @@ -160,19 +160,19 @@ bool FFmpegEncoder::Open() config.video_color_range = params().video_params().color_range() == - VideoParams::kColorRangeFull ? - FB_COLOR_RANGE_JPEG : - FB_COLOR_RANGE_MPEG; + VideoParams::k_color_range_full ? + fb_color_range_jpeg : + fb_color_range_mpeg; switch (params().video_params().interlacing()) { - case VideoParams::kInterlacedTopFirst: - config.video_field_order = FB_FIELD_ORDER_TT; + case VideoParams::k_interlaced_top_first: + config.video_field_order = fb_field_order_tt; break; - case VideoParams::kInterlacedBottomFirst: - config.video_field_order = FB_FIELD_ORDER_BB; + case VideoParams::k_interlaced_bottom_first: + config.video_field_order = fb_field_order_bb; break; default: - config.video_field_order = FB_FIELD_ORDER_PROGRESSIVE; + config.video_field_order = fb_field_order_progressive; break; } @@ -207,11 +207,11 @@ bool FFmpegEncoder::Open() // Set up audio if it's enabled if (params().audio_enabled()) { config.audio_enabled = 1; - config.audio_codec = ExportCodecToBridge(params().audio_codec()); + config.audio_codec = export_codec_to_bridge(params().audio_codec()); config.audio_sample_rate = params().audio_params().sample_rate(); config.audio_channel_layout_mask = params().audio_params().channel_layout(); - config.audio_sample_format = FFmpegUtils::GetFFmpegSampleFormat( + config.audio_sample_format = FFmpegUtils::get_f_fmpeg_sample_format( params().audio_params().format()); config.audio_bit_rate = params().audio_bit_rate(); } @@ -219,8 +219,8 @@ bool FFmpegEncoder::Open() // Set up subtitles if they're enabled if (params().subtitles_enabled()) { config.subtitles_enabled = 1; - config.subtitle_codec = ExportCodecToBridge(params().subtitles_codec()); - subtitle_header = SubtitleParams::GenerateASSHeader().toUtf8(); + config.subtitle_codec = export_codec_to_bridge(params().subtitles_codec()); + subtitle_header = SubtitleParams::generate_ass_header().toUtf8(); config.subtitle_header = reinterpret_cast(subtitle_header.constData()); config.subtitle_header_size = subtitle_header.size(); @@ -228,12 +228,12 @@ bool FFmpegEncoder::Open() encoder_ = fb_encoder_create(&config); if (!encoder_) { - SetError(tr("Failed to create encoder")); + set_error(tr("Failed to create encoder")); return false; } if (fb_encoder_open(encoder_) != 0) { - SetErrorFromBridge(); + set_error_from_bridge(); fb_encoder_free(&encoder_); return false; } @@ -242,29 +242,29 @@ bool FFmpegEncoder::Open() return true; } -bool FFmpegEncoder::WriteFrame(FramePtr frame, rational time) +bool FFmpegEncoder::write_frame(FramePtr frame, Rational time) { // We may need to convert this frame to a frame that the bridge will understand if (frame->format() != video_conversion_fmt_) { frame = frame->convert(video_conversion_fmt_); } - int src_pix_fmt = FFmpegUtils::GetFFmpegPixelFormat(frame->format(), + int src_pix_fmt = FFmpegUtils::get_f_fmpeg_pixel_format(frame->format(), frame->channel_count()); int r = fb_encoder_write_video_frame( encoder_, frame->width(), frame->height(), src_pix_fmt, reinterpret_cast(frame->data()), - frame->linesize_bytes(), time.toDouble()); + frame->linesize_bytes(), time.to_double()); if (r != 0) { - SetErrorFromBridge(); + set_error_from_bridge(); return false; } return true; } -bool FFmpegEncoder::WriteAudio(const SampleBuffer &audio) +bool FFmpegEncoder::write_audio(const SampleBuffer &audio) { if (!audio.is_allocated()) { return true; @@ -284,50 +284,50 @@ bool FFmpegEncoder::WriteAudio(const SampleBuffer &audio) int r = fb_encoder_write_audio( encoder_, channel_data.data(), audio.audio_params().channel_count(), - FFmpegUtils::GetFFmpegSampleFormat(audio.audio_params().format()), + FFmpegUtils::get_f_fmpeg_sample_format(audio.audio_params().format()), audio_params.sample_rate(), audio_params.channel_layout(), int64_t(audio.sample_count())); if (r != 0) { - SetErrorFromBridge(); + set_error_from_bridge(); return false; } return true; } -bool FFmpegEncoder::WriteAudioData(const AudioParams &audio_params, +bool FFmpegEncoder::write_audio_data(const AudioParams &audio_params, const uint8_t **data, int input_sample_count) { int r = fb_encoder_write_audio( encoder_, data, audio_params.channel_count(), - FFmpegUtils::GetFFmpegSampleFormat(audio_params.format()), + FFmpegUtils::get_f_fmpeg_sample_format(audio_params.format()), audio_params.sample_rate(), audio_params.channel_layout(), input_sample_count); if (r != 0) { - SetErrorFromBridge(); + set_error_from_bridge(); return false; } return true; } -bool FFmpegEncoder::WriteSubtitle(const SubtitleBlock *sub_block) +bool FFmpegEncoder::write_subtitle(const SubtitleBlock *sub_block) { - QByteArray utf8_sub = sub_block->GetText().toUtf8(); + QByteArray utf8_sub = sub_block->get_text().toUtf8(); int r = fb_encoder_write_subtitle(encoder_, utf8_sub.constData(), - sub_block->in().toDouble(), - sub_block->length().toDouble()); + sub_block->in().to_double(), + sub_block->length().to_double()); if (r != 0) { - SetErrorFromBridge(); + set_error_from_bridge(); return false; } return true; } -void FFmpegEncoder::Close() +void FFmpegEncoder::close() { if (encoder_) { // Flushes encoders, writes the trailer, and frees everything @@ -337,57 +337,57 @@ void FFmpegEncoder::Close() open_ = false; } -void FFmpegEncoder::SetErrorFromBridge() +void FFmpegEncoder::set_error_from_bridge() { - SetError(QString::fromUtf8(fb_encoder_get_error(encoder_))); + set_error(QString::fromUtf8(fb_encoder_get_error(encoder_))); } -int FFmpegEncoder::ExportCodecToBridge(ExportCodec::Codec c) +int FFmpegEncoder::export_codec_to_bridge(ExportCodec::Codec c) { switch (c) { - case ExportCodec::kCodecH264: - return FB_CODEC_H264; - case ExportCodec::kCodecH264rgb: - return FB_CODEC_H264RGB; - case ExportCodec::kCodecDNxHD: - return FB_CODEC_DNXHD; - case ExportCodec::kCodecProRes: - return FB_CODEC_PRORES; - case ExportCodec::kCodecCineform: - return FB_CODEC_CINEFORM; - case ExportCodec::kCodecH265: - return FB_CODEC_H265; - case ExportCodec::kCodecVP9: - return FB_CODEC_VP9; - case ExportCodec::kCodecAV1: - return FB_CODEC_AV1; - case ExportCodec::kCodecOpenEXR: - return FB_CODEC_OPENEXR; - case ExportCodec::kCodecPNG: - return FB_CODEC_PNG; - case ExportCodec::kCodecTIFF: - return FB_CODEC_TIFF; - case ExportCodec::kCodecMP2: - return FB_CODEC_MP2; - case ExportCodec::kCodecMP3: - return FB_CODEC_MP3; - case ExportCodec::kCodecAAC: - return FB_CODEC_AAC; - case ExportCodec::kCodecPCM: - return FB_CODEC_PCM; - case ExportCodec::kCodecFLAC: - return FB_CODEC_FLAC; - case ExportCodec::kCodecOpus: - return FB_CODEC_OPUS; - case ExportCodec::kCodecVorbis: - return FB_CODEC_VORBIS; - case ExportCodec::kCodecSRT: - return FB_CODEC_SRT; - case ExportCodec::kCodecCount: + case ExportCodec::k_codec_h264: + return fb_codec_h264; + case ExportCodec::k_codec_h264rgb: + return fb_codec_h264_rgb; + case ExportCodec::k_codec_d_nx_hd: + return fb_codec_dnxhd; + case ExportCodec::k_codec_pro_res: + return fb_codec_prores; + case ExportCodec::k_codec_cineform: + return fb_codec_cineform; + case ExportCodec::k_codec_h265: + return fb_codec_h265; + case ExportCodec::k_codec_v_p9: + return fb_codec_v_p9; + case ExportCodec::k_codec_a_v1: + return fb_codec_a_v1; + case ExportCodec::k_codec_open_exr: + return fb_codec_openexr; + case ExportCodec::k_codec_png: + return fb_codec_png; + case ExportCodec::k_codec_tiff: + return fb_codec_tiff; + case ExportCodec::k_codec_m_p2: + return fb_codec_m_p2; + case ExportCodec::k_codec_m_p3: + return fb_codec_m_p3; + case ExportCodec::k_codec_aac: + return fb_codec_aac; + case ExportCodec::k_codec_pcm: + return fb_codec_pcm; + case ExportCodec::k_codec_flac: + return fb_codec_flac; + case ExportCodec::k_codec_opus: + return fb_codec_opus; + case ExportCodec::k_codec_vorbis: + return fb_codec_vorbis; + case ExportCodec::k_codec_srt: + return fb_codec_srt; + case ExportCodec::k_codec_count: break; } - return FB_CODEC_NONE; + return fb_codec_none; } } diff --git a/app/codec/ffmpeg/ffmpegencoder.h b/app/codec/ffmpeg/ffmpegencoder.h index 90187651e..28120008f 100644 --- a/app/codec/ffmpeg/ffmpegencoder.h +++ b/app/codec/ffmpeg/ffmpegencoder.h @@ -19,8 +19,8 @@ ***/ -#ifndef FFMPEGENCODER_H -#define FFMPEGENCODER_H +#ifndef OAK_FFMPEGENCODER_H +#define OAK_FFMPEGENCODER_H #include @@ -42,26 +42,26 @@ public: FFmpegEncoder(const EncodingParams ¶ms); virtual QStringList - GetPixelFormatsForCodec(ExportCodec::Codec c) const override; + get_pixel_formats_for_codec(ExportCodec::Codec c) const override; virtual std::vector - GetSampleFormatsForCodec(ExportCodec::Codec c) const override; + get_sample_formats_for_codec(ExportCodec::Codec c) const override; - virtual bool Open() override; + virtual bool open() override; - virtual bool WriteFrame(olive::FramePtr frame, - olive::core::rational time) override; + virtual bool write_frame(olive::FramePtr frame, + olive::core::Rational time) override; - virtual bool WriteAudio(const olive::SampleBuffer &audio) override; + virtual bool write_audio(const olive::SampleBuffer &audio) override; - bool WriteAudioData(const AudioParams &audio_params, const uint8_t **data, + bool write_audio_data(const AudioParams &audio_params, const uint8_t **data, int input_sample_count); - virtual bool WriteSubtitle(const SubtitleBlock *sub_block) override; + virtual bool write_subtitle(const SubtitleBlock *sub_block) override; - virtual void Close() override; + virtual void close() override; - virtual PixelFormat GetDesiredPixelFormat() const override + virtual PixelFormat get_desired_pixel_format() const override { return video_conversion_fmt_; } @@ -70,9 +70,9 @@ private: /** * @brief Copy the last error message from the bridge into the encoder error state */ - void SetErrorFromBridge(); + void set_error_from_bridge(); - static int ExportCodecToBridge(ExportCodec::Codec c); + static int export_codec_to_bridge(ExportCodec::Codec c); FBEncoder *encoder_; @@ -83,4 +83,4 @@ private: } -#endif // FFMPEGENCODER_H +#endif // OAK_FFMPEGENCODER_H diff --git a/app/codec/frame.cpp b/app/codec/frame.cpp index 56fa0bbf3..61c7963d9 100644 --- a/app/codec/frame.cpp +++ b/app/codec/frame.cpp @@ -44,7 +44,7 @@ Frame::~Frame() destroy(); } -FramePtr Frame::Create() +FramePtr Frame::create() { return std::make_shared(); } @@ -60,10 +60,10 @@ void Frame::set_video_params(const VideoParams ¶ms) linesize_ = generate_linesize_bytes(width(), params_.format(), params_.channel_count()); - linesize_pixels_ = linesize_ / params_.GetBytesPerPixel(); + linesize_pixels_ = linesize_ / params_.get_bytes_per_pixel(); } -FramePtr Frame::Interlace(FramePtr top, FramePtr bottom) +FramePtr Frame::interlace(FramePtr top, FramePtr bottom) { if (top->video_params() != bottom->video_params()) { qCritical() @@ -71,7 +71,7 @@ FramePtr Frame::Interlace(FramePtr top, FramePtr bottom) return nullptr; } - FramePtr interlaced = Frame::Create(); + FramePtr interlaced = Frame::create(); interlaced->set_video_params(top->video_params()); interlaced->allocate(); @@ -91,7 +91,7 @@ int Frame::generate_linesize_bytes(int width, PixelFormat format, int channel_count) { // Align to 32 bytes (not sure if this is necessary?) - return VideoParams::GetBytesPerPixel(format, channel_count) * + return VideoParams::get_bytes_per_pixel(format, channel_count) * ((width + 31) & ~31); } @@ -102,7 +102,7 @@ Color Frame::get_pixel(int x, int y) const } int byte_offset = - y * linesize_bytes() + x * video_params().GetBytesPerPixel(); + y * linesize_bytes() + x * video_params().get_bytes_per_pixel(); return Color(reinterpret_cast(data_ + byte_offset), video_params().format(), video_params().channel_count()); @@ -120,9 +120,9 @@ void Frame::set_pixel(int x, int y, const Color &c) } int byte_offset = - y * linesize_bytes() + x * video_params().GetBytesPerPixel(); + y * linesize_bytes() + x * video_params().get_bytes_per_pixel(); - c.toData(reinterpret_cast(data_ + byte_offset), + c.to_data(reinterpret_cast(data_ + byte_offset), video_params().format(), video_params().channel_count()); } @@ -140,7 +140,7 @@ bool Frame::allocate() } data_size_ = linesize_ * height(); - data_ = FrameManager::Allocate(data_size_); + data_ = FrameManager::allocate(data_size_); return true; } @@ -148,7 +148,7 @@ bool Frame::allocate() void Frame::destroy() { if (is_allocated()) { - FrameManager::Deallocate(data_size_, data_); + FrameManager::deallocate(data_size_, data_); data_size_ = 0; data_ = nullptr; @@ -162,7 +162,7 @@ FramePtr Frame::convert(PixelFormat format) const params.set_format(format); // Create new frame - FramePtr converted = Frame::Create(); + FramePtr converted = Frame::create(); converted->set_video_params(params); converted->set_timestamp(timestamp_); converted->allocate(); @@ -170,16 +170,16 @@ FramePtr Frame::convert(PixelFormat format) const // Do the conversion through OIIO for convenience OIIO::ImageBuf src( OIIO::ImageSpec(width(), height(), channel_count(), - OIIOUtils::GetOIIOBaseTypeFromFormat(this->format()))); + OIIOUtils::get_oiio_base_type_from_format(this->format()))); - OIIOUtils::FrameToBuffer(this, &src); + OIIOUtils::frame_to_buffer(this, &src); OIIO::ImageBuf dst(OIIO::ImageSpec( converted->width(), converted->height(), channel_count(), - OIIOUtils::GetOIIOBaseTypeFromFormat(format))); + OIIOUtils::get_oiio_base_type_from_format(format))); if (dst.copy_pixels(src)) { - OIIOUtils::BufferToFrame(&dst, converted.get()); + OIIOUtils::buffer_to_frame(&dst, converted.get()); return converted; } else { return nullptr; diff --git a/app/codec/frame.h b/app/codec/frame.h index a6e9d313b..ed3b61dca 100644 --- a/app/codec/frame.h +++ b/app/codec/frame.h @@ -19,8 +19,8 @@ ***/ -#ifndef FRAME_H -#define FRAME_H +#ifndef OAK_FRAME_H +#define OAK_FRAME_H #include #include @@ -46,12 +46,12 @@ public: DISABLE_COPY_MOVE(Frame) - static FramePtr Create(); + static FramePtr create(); const VideoParams &video_params() const; void set_video_params(const VideoParams ¶ms); - static FramePtr Interlace(FramePtr top, FramePtr bottom); + static FramePtr interlace(FramePtr top, FramePtr bottom); static int generate_linesize_bytes(int width, PixelFormat format, int channel_count); @@ -93,14 +93,14 @@ public: /** * @brief Get frame's timestamp. * - * This timestamp is always a rational that will equate to the time in seconds. + * This timestamp is always a Rational that will equate to the time in seconds. */ - const rational ×tamp() const + const Rational ×tamp() const { return timestamp_; } - void set_timestamp(const rational ×tamp) + void set_timestamp(const Rational ×tamp) { timestamp_ = timestamp; } @@ -161,7 +161,7 @@ private: char *data_; int data_size_; - rational timestamp_; + Rational timestamp_; int linesize_; @@ -172,4 +172,4 @@ private: Q_DECLARE_METATYPE(olive::FramePtr) -#endif // FRAME_H +#endif // OAK_FRAME_H diff --git a/app/codec/oiio/oiiodecoder.cpp b/app/codec/oiio/oiiodecoder.cpp index 76f03fa12..7d672f0fd 100644 --- a/app/codec/oiio/oiiodecoder.cpp +++ b/app/codec/oiio/oiiodecoder.cpp @@ -32,7 +32,7 @@ namespace olive { -QStringList OIIODecoder::supported_formats_; +QStringList OIIODecoder::supported_formats; OIIODecoder::OIIODecoder() : image_(nullptr) @@ -44,7 +44,7 @@ QString OIIODecoder::id() const return QStringLiteral("oiio"); } -FootageDescription OIIODecoder::Probe(const QString &filename, +FootageDescription OIIODecoder::probe(const QString &filename, CancelAtom *cancelled) const { Q_UNUSED(cancelled) @@ -53,7 +53,7 @@ FootageDescription OIIODecoder::Probe(const QString &filename, // Filter out any file extensions that aren't expected to work - sometimes OIIO will crash trying // to open a file that it can't if it's given one - if (!FileTypeIsSupported(filename)) { + if (!file_type_is_supported(filename)) { return desc; } @@ -77,7 +77,7 @@ FootageDescription OIIODecoder::Probe(const QString &filename, for (i = 0; in->seek_subimage(i, 0); i++) { OIIO::ImageSpec spec = in->spec(); - VideoParams video_params = GetVideoParamsFromImageSpec(spec); + VideoParams video_params = get_video_params_from_image_spec(spec); video_params.set_stream_index(i); @@ -104,10 +104,10 @@ FootageDescription OIIODecoder::Probe(const QString &filename, // likely reduces the fidelity? video_params.set_premultiplied_alpha(true); - desc.AddVideoStream(video_params); + desc.add_video_stream(video_params); } - desc.SetStreamCount(i); + desc.set_stream_count(i); // If we're here, we have a successful image open in->close(); @@ -115,26 +115,26 @@ FootageDescription OIIODecoder::Probe(const QString &filename, return desc; } -bool OIIODecoder::OpenInternal() +bool OIIODecoder::open_internal() { // If we can open the filename provided, assume everything is working - return OpenImageHandler(stream().filename(), stream().stream()); + return open_image_handler(stream().filename(), stream().stream()); } -TexturePtr OIIODecoder::RetrieveVideoInternal(const RetrieveVideoParams &p) +TexturePtr OIIODecoder::retrieve_video_internal(const RetrieveVideoParams &p) { - FramePtr frame = RetrieveVideoFrameInternal(p); + FramePtr frame = retrieve_video_frame_internal(p); if (!frame) { return nullptr; } - return p.renderer->CreateTexture(frame->video_params(), frame->data(), + return p.renderer->create_texture(frame->video_params(), frame->data(), frame->linesize_pixels()); } -FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) +FramePtr OIIODecoder::retrieve_video_frame_internal(const RetrieveVideoParams &p) { - VideoParams vp = GetVideoParamsFromImageSpec(image_->spec()); + VideoParams vp = get_video_params_from_image_spec(image_->spec()); vp.set_divider(p.divider); if (!buffer_.is_allocated() || last_params_.divider != p.divider) { @@ -154,7 +154,7 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) buf.scanline_stride(), buf.z_stride()); // Roughly downsample image for divider (for some reason OIIO::ImageBufAlgo::resample failed here) - int px_sz = vp.GetBytesPerPixel(); + int px_sz = vp.get_bytes_per_pixel(); for (int dst_y = 0; dst_y < buffer_.height(); dst_y++) { int src_y = dst_y * buf.spec().height / buffer_.height(); @@ -171,15 +171,15 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) } // Force F32 output for all still images - if (vp.format() != PixelFormat::F32) { - FramePtr f32_frame = buffer_.convert(PixelFormat::F32); + if (vp.format() != PixelFormat::f32) { + FramePtr f32_frame = buffer_.convert(PixelFormat::f32); if (f32_frame) { f32_frame->set_timestamp(p.time); return f32_frame; } } - FramePtr frame = Frame::Create(); + FramePtr frame = Frame::create(); frame->set_video_params(buffer_.video_params()); frame->set_timestamp(p.time); if (!frame->allocate()) { @@ -190,19 +190,19 @@ FramePtr OIIODecoder::RetrieveVideoFrameInternal(const RetrieveVideoParams &p) return frame; } -void OIIODecoder::CloseInternal() +void OIIODecoder::close_internal() { - CloseImageHandle(); + close_image_handle(); } -bool OIIODecoder::FileTypeIsSupported(const QString &fn) +bool OIIODecoder::file_type_is_supported(const QString &fn) { // We prioritize OIIO over FFmpeg to pick up still images more effectively, but some OIIO decoders (notably OpenJPEG) // will segfault entirely if given unexpected data (an MPEG-4 for instance). To workaround this issue, we use OIIO's // "extension_list" attribute and match it with the extension of the file. // Check if we've created the supported formats list, create it if not - if (supported_formats_.isEmpty()) { + if (supported_formats.isEmpty()) { QStringList extension_list = QString::fromStdString(OIIO::get_string_attribute("extension_list")) .split(';'); @@ -211,11 +211,11 @@ bool OIIODecoder::FileTypeIsSupported(const QString &fn) foreach (const QString &ext, extension_list) { QStringList format_and_ext = ext.split(':'); - supported_formats_.append(format_and_ext.at(1).split(',')); + supported_formats.append(format_and_ext.at(1).split(',')); } } - if (!supported_formats_.contains(QFileInfo(fn).suffix(), + if (!supported_formats.contains(QFileInfo(fn).suffix(), Qt::CaseInsensitive)) { return false; } @@ -223,7 +223,7 @@ bool OIIODecoder::FileTypeIsSupported(const QString &fn) return true; } -bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage) +bool OIIODecoder::open_image_handler(const QString &fn, int subimage) { image_ = OIIO::ImageInput::open(fn.toStdString()); @@ -239,16 +239,16 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage) const OIIO::ImageSpec &spec = image_->spec(); // We use RGBA frames because that tends to be the native format of GPUs - pix_fmt_ = OIIOUtils::GetFormatFromOIIOBasetype( + pix_fmt_ = OIIOUtils::get_format_from_oiio_basetype( static_cast(spec.format.basetype)); - if (pix_fmt_ == PixelFormat::INVALID) { + if (pix_fmt_ == PixelFormat::invalid) { qWarning() << "Failed to convert OIIO::ImageDesc to native pixel format"; return false; } - oiio_pix_fmt_ = OIIOUtils::GetOIIOBaseTypeFromFormat(pix_fmt_); + oiio_pix_fmt_ = OIIOUtils::get_oiio_base_type_from_format(pix_fmt_); if (oiio_pix_fmt_ == OIIO::TypeDesc::UNKNOWN) { qCritical() @@ -259,7 +259,7 @@ bool OIIODecoder::OpenImageHandler(const QString &fn, int subimage) return true; } -void OIIODecoder::CloseImageHandle() +void OIIODecoder::close_image_handle() { if (image_) { image_->close(); @@ -270,18 +270,18 @@ void OIIODecoder::CloseImageHandle() } VideoParams -OIIODecoder::GetVideoParamsFromImageSpec(const OIIO::ImageSpec &spec) +OIIODecoder::get_video_params_from_image_spec(const OIIO::ImageSpec &spec) { VideoParams video_params; video_params.set_width(spec.width); video_params.set_height(spec.height); - video_params.set_format(OIIOUtils::GetFormatFromOIIOBasetype( + video_params.set_format(OIIOUtils::get_format_from_oiio_basetype( static_cast(spec.format.basetype))); video_params.set_channel_count(spec.nchannels); video_params.set_pixel_aspect_ratio( - OIIOUtils::GetPixelAspectRatioFromOIIO(spec)); - video_params.set_video_type(VideoParams::kVideoTypeStill); + OIIOUtils::get_pixel_aspect_ratio_from_oiio(spec)); + video_params.set_video_type(VideoParams::k_video_type_still); return video_params; } diff --git a/app/codec/oiio/oiiodecoder.h b/app/codec/oiio/oiiodecoder.h index 662626173..ac42cdb46 100644 --- a/app/codec/oiio/oiiodecoder.h +++ b/app/codec/oiio/oiiodecoder.h @@ -19,8 +19,8 @@ ***/ -#ifndef OIIODECODER_H -#define OIIODECODER_H +#ifndef OAK_OIIODECODER_H +#define OAK_OIIODECODER_H #include #include @@ -39,32 +39,32 @@ public: virtual QString id() const override; - virtual bool SupportsVideo() override + virtual bool supports_video() override { return true; } - virtual FootageDescription Probe(const QString &filename, + virtual FootageDescription probe(const QString &filename, CancelAtom *cancelled) const override; protected: - virtual bool OpenInternal() override; + virtual bool open_internal() override; virtual TexturePtr - RetrieveVideoInternal(const RetrieveVideoParams &p) override; + retrieve_video_internal(const RetrieveVideoParams &p) override; virtual FramePtr - RetrieveVideoFrameInternal(const RetrieveVideoParams &p) override; - virtual void CloseInternal() override; + retrieve_video_frame_internal(const RetrieveVideoParams &p) override; + virtual void close_internal() override; private: std::unique_ptr image_; - static bool FileTypeIsSupported(const QString &fn); + static bool file_type_is_supported(const QString &fn); - bool OpenImageHandler(const QString &fn, int subimage); + bool open_image_handler(const QString &fn, int subimage); - void CloseImageHandle(); + void close_image_handle(); - static VideoParams GetVideoParamsFromImageSpec(const OIIO::ImageSpec &spec); + static VideoParams get_video_params_from_image_spec(const OIIO::ImageSpec &spec); PixelFormat pix_fmt_; OIIO::TypeDesc::BASETYPE oiio_pix_fmt_; @@ -72,9 +72,9 @@ private: Frame buffer_; RetrieveVideoParams last_params_; - static QStringList supported_formats_; + static QStringList supported_formats; }; } -#endif // OIIODECODER_H +#endif // OAK_OIIODECODER_H diff --git a/app/codec/oiio/oiioencoder.cpp b/app/codec/oiio/oiioencoder.cpp index 08c3e71ad..48d6f5a9a 100644 --- a/app/codec/oiio/oiioencoder.cpp +++ b/app/codec/oiio/oiioencoder.cpp @@ -31,21 +31,21 @@ OIIOEncoder::OIIOEncoder(const EncodingParams ¶ms) { } -bool OIIOEncoder::Open() +bool OIIOEncoder::open() { return true; } -bool OIIOEncoder::WriteFrame(FramePtr frame, rational time) +bool OIIOEncoder::write_frame(FramePtr frame, Rational time) { - std::string filename = GetFilenameForFrame(time).toStdString(); + std::string filename = get_filename_for_frame(time).toStdString(); auto output = OIIO::ImageOutput::create(filename); if (!output) { return false; } - OIIO::TypeDesc type = OIIOUtils::GetOIIOBaseTypeFromFormat(frame->format()); + OIIO::TypeDesc type = OIIOUtils::get_oiio_base_type_from_format(frame->format()); OIIO::ImageSpec spec(frame->width(), frame->height(), frame->channel_count(), type); @@ -65,18 +65,18 @@ bool OIIOEncoder::WriteFrame(FramePtr frame, rational time) return true; } -bool OIIOEncoder::WriteAudio(const SampleBuffer &audio) +bool OIIOEncoder::write_audio(const SampleBuffer &audio) { // Do nothing return false; } -bool OIIOEncoder::WriteSubtitle(const SubtitleBlock *sub_block) +bool OIIOEncoder::write_subtitle(const SubtitleBlock *sub_block) { return false; } -void OIIOEncoder::Close() +void OIIOEncoder::close() { // Do nothing } diff --git a/app/codec/oiio/oiioencoder.h b/app/codec/oiio/oiioencoder.h index 1200746d8..a6b4cf101 100644 --- a/app/codec/oiio/oiioencoder.h +++ b/app/codec/oiio/oiioencoder.h @@ -19,8 +19,8 @@ ***/ -#ifndef OIIOENCODER_H -#define OIIOENCODER_H +#ifndef OAK_OIIOENCODER_H +#define OAK_OIIOENCODER_H #include "codec/encoder.h" @@ -33,16 +33,16 @@ public: OIIOEncoder(const EncodingParams ¶ms); public slots: - virtual bool Open() override; + virtual bool open() override; - virtual bool WriteFrame(olive::FramePtr frame, - olive::core::rational time) override; - virtual bool WriteAudio(const SampleBuffer &audio) override; - virtual bool WriteSubtitle(const SubtitleBlock *sub_block) override; + virtual bool write_frame(olive::FramePtr frame, + olive::core::Rational time) override; + virtual bool write_audio(const SampleBuffer &audio) override; + virtual bool write_subtitle(const SubtitleBlock *sub_block) override; - virtual void Close() override; + virtual void close() override; }; } -#endif // OIIOENCODER_H +#endif // OAK_OIIOENCODER_H diff --git a/app/codec/planarfiledevice.h b/app/codec/planarfiledevice.h index 400518848..1b3f935e4 100644 --- a/app/codec/planarfiledevice.h +++ b/app/codec/planarfiledevice.h @@ -19,8 +19,8 @@ ***/ -#ifndef PLANARFILEDEVICE_H -#define PLANARFILEDEVICE_H +#ifndef OAK_PLANARFILEDEVICE_H +#define OAK_PLANARFILEDEVICE_H #include #include @@ -62,4 +62,4 @@ private: } -#endif // PLANARFILEDEVICE_H +#endif // OAK_PLANARFILEDEVICE_H diff --git a/app/codec/proxymanager.cpp b/app/codec/proxymanager.cpp index 2d0d41fde..eb815ffa1 100644 --- a/app/codec/proxymanager.cpp +++ b/app/codec/proxymanager.cpp @@ -34,7 +34,7 @@ namespace olive ProxyManager *ProxyManager::instance_ = nullptr; -bool ProxyParamsEqual(const ProxyManager::ProxyParams &a, +bool proxy_params_equal(const ProxyManager::ProxyParams &a, const ProxyManager::ProxyParams &b) { return a.width == b.width && a.height == b.height && @@ -43,22 +43,22 @@ bool ProxyParamsEqual(const ProxyManager::ProxyParams &a, a.include_audio == b.include_audio; } -QString ProxyManager::GetProxyDirectory(const QString &cache_path) +QString ProxyManager::get_proxy_directory(const QString &cache_path) { return QDir(cache_path).filePath(QStringLiteral("proxy")); } -QString ProxyManager::GetProxyFilename(const QString &cache_path, +QString ProxyManager::get_proxy_filename(const QString &cache_path, const QString &source_filename, int stream_index, const ProxyParams ¶ms) { - const QString proxy_dir = GetProxyDirectory(cache_path); + const QString proxy_dir = get_proxy_directory(cache_path); const QString extension = params.extension.isEmpty() ? QStringLiteral("mp4") : params.extension; const QString filename = QStringLiteral("%1-%2.%3x%4.v%5.a%6.%7") - .arg(FileFunctions::GetUniqueFileIdentifier(source_filename), + .arg(FileFunctions::get_unique_file_identifier(source_filename), QString::number(stream_index), QString::number(params.width), QString::number(params.height), QString::number(params.version), params.include_audio ? QStringLiteral("1") : QStringLiteral("0"), @@ -67,7 +67,7 @@ QString ProxyManager::GetProxyFilename(const QString &cache_path, return QDir(proxy_dir).filePath(filename); } -QString ProxyManager::GetWorkingProxyFilename(const QString &proxy_filename) +QString ProxyManager::get_working_proxy_filename(const QString &proxy_filename) { // Append a recognizable suffix while keeping a standard container extension // so ffmpeg can infer the output format. @@ -75,29 +75,29 @@ QString ProxyManager::GetWorkingProxyFilename(const QString &proxy_filename) } ProxyManager::ProxyState -ProxyManager::GetProxyState(const QString &proxy_filename) +ProxyManager::get_proxy_state(const QString &proxy_filename) { if (QFileInfo::exists(proxy_filename)) { - return kProxyReady; + return k_proxy_ready; } - if (QFileInfo::exists(GetWorkingProxyFilename(proxy_filename))) { - return kProxyGenerating; + if (QFileInfo::exists(get_working_proxy_filename(proxy_filename))) { + return k_proxy_generating; } - return kProxyMissing; + return k_proxy_missing; } -QString ProxyManager::ProxyStateToString(ProxyState state) +QString ProxyManager::proxy_state_to_string(ProxyState state) { switch (state) { - case kProxyMissing: + case k_proxy_missing: return QStringLiteral("missing"); - case kProxyGenerating: + case k_proxy_generating: return QStringLiteral("generating"); - case kProxyReady: + case k_proxy_ready: return QStringLiteral("ready"); - case kProxyFailed: + case k_proxy_failed: return QStringLiteral("failed"); } @@ -105,41 +105,41 @@ QString ProxyManager::ProxyStateToString(ProxyState state) } ProxyManager::ProxyState -ProxyManager::ProxyStateFromString(const QString &state) +ProxyManager::proxy_state_from_string(const QString &state) { if (state == QStringLiteral("generating")) { - return kProxyGenerating; + return k_proxy_generating; } if (state == QStringLiteral("ready")) { - return kProxyReady; + return k_proxy_ready; } if (state == QStringLiteral("failed")) { - return kProxyFailed; + return k_proxy_failed; } - return kProxyMissing; + return k_proxy_missing; } -bool ProxyManager::ProxyFilenameHasAudio(const QString &proxy_filename) +bool ProxyManager::proxy_filename_has_audio(const QString &proxy_filename) { return QFileInfo(proxy_filename).fileName().contains( QStringLiteral(".a1.")); } -ProxyManager::ProxyParams ProxyManager::ProxyParamsFromConfig() +ProxyManager::ProxyParams ProxyManager::proxy_params_from_config() { ProxyParams params; - params.width = OLIVE_CONFIG("ProxyWidth").value(); - params.height = OLIVE_CONFIG("ProxyHeight").value(); - params.crf = OLIVE_CONFIG("ProxyCRF").value(); - params.preset = OLIVE_CONFIG("ProxyPreset").toString(); - params.include_audio = OLIVE_CONFIG("ProxyIncludeAudio").toBool(); + params.width = OAK_CONFIG("ProxyWidth").value(); + params.height = OAK_CONFIG("ProxyHeight").value(); + params.crf = OAK_CONFIG("ProxyCRF").value(); + params.preset = OAK_CONFIG("ProxyPreset").toString(); + params.include_audio = OAK_CONFIG("ProxyIncludeAudio").toBool(); return params; } -QString ProxyManager::FindFFmpegExecutable(const QString &configured_path) +QString ProxyManager::find_f_fmpeg_executable(const QString &configured_path) { // An explicitly configured path takes precedence if it is usable if (!configured_path.isEmpty()) { @@ -187,46 +187,46 @@ QString ProxyManager::FindFFmpegExecutable(const QString &configured_path) } ProxyManager::Proxy -ProxyManager::GetOrStartProxy(const QString &cache_path, +ProxyManager::get_or_start_proxy(const QString &cache_path, const QString &source_filename, int stream_index, const ProxyParams ¶ms) { QMutexLocker locker(&mutex_); const QString filename = - GetProxyFilename(cache_path, source_filename, stream_index, params); - const ProxyState file_state = GetProxyState(filename); - if (file_state == kProxyReady) { - return { kProxyReady, filename, nullptr }; + get_proxy_filename(cache_path, source_filename, stream_index, params); + const ProxyState file_state = get_proxy_state(filename); + if (file_state == k_proxy_ready) { + return { k_proxy_ready, filename, nullptr }; } for (const ProxyData &data : proxying_) { if (data.source_filename == source_filename && data.stream_index == stream_index && - ProxyParamsEqual(data.params, params)) { - return { kProxyGenerating, filename, data.task }; + proxy_params_equal(data.params, params)) { + return { k_proxy_generating, filename, data.task }; } } - if (file_state == kProxyGenerating) { - QFile::remove(GetWorkingProxyFilename(filename)); + if (file_state == k_proxy_generating) { + QFile::remove(get_working_proxy_filename(filename)); } - const QString working_filename = GetWorkingProxyFilename(filename); + const QString working_filename = get_working_proxy_filename(filename); ProxyTask *task = new ProxyTask(source_filename, stream_index, params, working_filename); - connect(task, &Task::Finished, this, &ProxyManager::ProxyTaskFinished); + connect(task, &Task::finished, this, &ProxyManager::proxy_task_finished); task->moveToThread(TaskManager::instance()->thread()); - QMetaObject::invokeMethod(TaskManager::instance(), "AddTask", + QMetaObject::invokeMethod(TaskManager::instance(), "add_task", Qt::QueuedConnection, Q_ARG(Task *, task)); proxying_.append({ source_filename, stream_index, params, task, working_filename, filename }); - return { kProxyGenerating, filename, task }; + return { k_proxy_generating, filename, task }; } -void ProxyManager::ProxyTaskFinished(Task *task, bool succeeded) +void ProxyManager::proxy_task_finished(Task *task, bool succeeded) { QMutexLocker locker(&mutex_); @@ -250,18 +250,18 @@ void ProxyManager::ProxyTaskFinished(Task *task, bool succeeded) QFile::remove(data.finished_filename); if (QFile::rename(data.working_filename, data.finished_filename)) { locker.unlock(); - emit ProxyReady(data.source_filename, data.stream_index, + emit proxy_ready(data.source_filename, data.stream_index, data.finished_filename); - emit ProxyFinished(data.source_filename, data.stream_index, - data.finished_filename, kProxyReady); + emit proxy_finished(data.source_filename, data.stream_index, + data.finished_filename, k_proxy_ready); return; } } QFile::remove(data.working_filename); locker.unlock(); - emit ProxyFinished(data.source_filename, data.stream_index, - data.finished_filename, kProxyFailed); + emit proxy_finished(data.source_filename, data.stream_index, + data.finished_filename, k_proxy_failed); } } diff --git a/app/codec/proxymanager.h b/app/codec/proxymanager.h index a39d5d18a..33a9c13b2 100644 --- a/app/codec/proxymanager.h +++ b/app/codec/proxymanager.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef PROXYMANAGER_H -#define PROXYMANAGER_H +#ifndef OAK_PROXYMANAGER_H +#define OAK_PROXYMANAGER_H #include #include @@ -34,14 +34,14 @@ class ProxyTask; class ProxyManager : public QObject { Q_OBJECT public: - static void CreateInstance() + static void create_instance() { if (!instance_) { instance_ = new ProxyManager(); } } - static void DestroyInstance() + static void destroy_instance() { delete instance_; instance_ = nullptr; @@ -53,10 +53,10 @@ public: } enum ProxyState { - kProxyMissing, - kProxyGenerating, - kProxyReady, - kProxyFailed + k_proxy_missing, + k_proxy_generating, + k_proxy_ready, + k_proxy_failed }; struct ProxyParams { @@ -70,36 +70,36 @@ public: }; struct Proxy { - ProxyState state = kProxyMissing; + ProxyState state = k_proxy_missing; QString filename; ProxyTask *task = nullptr; }; - static QString GetProxyDirectory(const QString &cache_path); + static QString get_proxy_directory(const QString &cache_path); - static QString GetProxyFilename(const QString &cache_path, + static QString get_proxy_filename(const QString &cache_path, const QString &source_filename, int stream_index, const ProxyParams ¶ms); - static QString GetWorkingProxyFilename(const QString &proxy_filename); + static QString get_working_proxy_filename(const QString &proxy_filename); - static ProxyState GetProxyState(const QString &proxy_filename); + static ProxyState get_proxy_state(const QString &proxy_filename); - static QString ProxyStateToString(ProxyState state); + static QString proxy_state_to_string(ProxyState state); - static ProxyState ProxyStateFromString(const QString &state); + static ProxyState proxy_state_from_string(const QString &state); /** * @brief Returns true if a proxy filename generated by GetProxyFilename() * indicates the proxy contains audio streams */ - static bool ProxyFilenameHasAudio(const QString &proxy_filename); + static bool proxy_filename_has_audio(const QString &proxy_filename); /** * @brief Builds proxy parameters from the global application config */ - static ProxyParams ProxyParamsFromConfig(); + static ProxyParams proxy_params_from_config(); /** * @brief Locates an ffmpeg executable for proxy generation @@ -109,16 +109,16 @@ public: * platform-specific install locations. Returns an empty string if no * executable could be found. */ - static QString FindFFmpegExecutable(const QString &configured_path); + static QString find_f_fmpeg_executable(const QString &configured_path); - Proxy GetOrStartProxy(const QString &cache_path, + Proxy get_or_start_proxy(const QString &cache_path, const QString &source_filename, int stream_index, const ProxyParams ¶ms); signals: - void ProxyReady(const QString &source_filename, int stream_index, + void proxy_ready(const QString &source_filename, int stream_index, const QString &proxy_filename); - void ProxyFinished(const QString &source_filename, int stream_index, + void proxy_finished(const QString &source_filename, int stream_index, const QString &proxy_filename, ProxyState state); private: @@ -139,9 +139,9 @@ private: QVector proxying_; private slots: - void ProxyTaskFinished(Task *task, bool succeeded); + void proxy_task_finished(Task *task, bool succeeded); }; } -#endif // PROXYMANAGER_H +#endif // OAK_PROXYMANAGER_H diff --git a/app/codec/timecodemetadata.cpp b/app/codec/timecodemetadata.cpp index c884cf3f0..5f098aaad 100644 --- a/app/codec/timecodemetadata.cpp +++ b/app/codec/timecodemetadata.cpp @@ -29,8 +29,8 @@ namespace olive { TimecodeMetadata::SourceTime -TimecodeMetadata::FromTimecodeString(const QString &timecode, - const core::rational &timebase) +TimecodeMetadata::from_timecode_string(const QString &timecode, + const core::Rational &timebase) { SourceTime result; const QString trimmed = timecode.trimmed(); @@ -40,8 +40,8 @@ TimecodeMetadata::FromTimecodeString(const QString &timecode, bool ok = false; const core::Timecode::Display display = - trimmed.contains(';') ? core::Timecode::kTimecodeDropFrame : - core::Timecode::kTimecodeNonDropFrame; + trimmed.contains(';') ? core::Timecode::k_timecode_drop_frame : + core::Timecode::k_timecode_non_drop_frame; result.time = core::Timecode::timecode_to_time(trimmed.toStdString(), timebase, display, &ok); result.valid = ok; @@ -52,7 +52,7 @@ TimecodeMetadata::FromTimecodeString(const QString &timecode, } TimecodeMetadata::SourceTime -TimecodeMetadata::FromBwfTimeReference(const QString &time_reference, +TimecodeMetadata::from_bwf_time_reference(const QString &time_reference, int sample_rate) { SourceTime result; @@ -75,10 +75,10 @@ TimecodeMetadata::FromBwfTimeReference(const QString &time_reference, const qulonglong rational_limit = static_cast(std::numeric_limits::max()); if (numerator <= rational_limit && denominator <= rational_limit) { - result.time = core::rational(static_cast(numerator), + result.time = core::Rational(static_cast(numerator), static_cast(denominator)); } else { - result.time = core::rational::fromDouble( + result.time = core::Rational::from_double( static_cast(samples) / static_cast(sample_rate)); } result.source = QStringLiteral("bwf_time_reference"); diff --git a/app/codec/timecodemetadata.h b/app/codec/timecodemetadata.h index c78a124a4..57e802010 100644 --- a/app/codec/timecodemetadata.h +++ b/app/codec/timecodemetadata.h @@ -18,8 +18,8 @@ ***/ -#ifndef TIMECODEMETADATA_H -#define TIMECODEMETADATA_H +#ifndef OAK_TIMECODEMETADATA_H +#define OAK_TIMECODEMETADATA_H #include @@ -31,18 +31,18 @@ namespace olive class TimecodeMetadata { public: struct SourceTime { - core::rational time; + core::Rational time; QString source; bool valid = false; }; - static SourceTime FromTimecodeString(const QString &timecode, - const core::rational &timebase); + static SourceTime from_timecode_string(const QString &timecode, + const core::Rational &timebase); - static SourceTime FromBwfTimeReference(const QString &time_reference, + static SourceTime from_bwf_time_reference(const QString &time_reference, int sample_rate); }; } -#endif // TIMECODEMETADATA_H +#endif // OAK_TIMECODEMETADATA_H diff --git a/app/common/CMakeLists.txt b/app/common/CMakeLists.txt index 708a67e36..a33befc8f 100644 --- a/app/common/CMakeLists.txt +++ b/app/common/CMakeLists.txt @@ -22,8 +22,8 @@ target_sources(libolive-editor PRIVATE crashpadinterface.cpp crashpadinterface.h crashpadutils.h - Current.cpp - Current.h + current.cpp + current.h debug.cpp debug.h decibel.h diff --git a/app/common/autoscroll.h b/app/common/autoscroll.h index 13a638a98..425acc628 100644 --- a/app/common/autoscroll.h +++ b/app/common/autoscroll.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUTOSCROLL_H -#define AUTOSCROLL_H +#ifndef OAK_AUTOSCROLL_H +#define OAK_AUTOSCROLL_H #include "common/define.h" @@ -29,9 +29,9 @@ namespace olive class AutoScroll { public: - enum Method { kNone, kPage, kSmooth }; + enum Method { k_none, k_page, k_smooth }; }; } -#endif // AUTOSCROLL_H +#endif // OAK_AUTOSCROLL_H diff --git a/app/common/avframeptr.h b/app/common/avframeptr.h index 8e9170121..e3f6ae24c 100644 --- a/app/common/avframeptr.h +++ b/app/common/avframeptr.h @@ -19,8 +19,8 @@ ***/ -#ifndef AVFRAMEPTR_H -#define AVFRAMEPTR_H +#ifndef OAK_AVFRAMEPTR_H +#define OAK_AVFRAMEPTR_H #include @@ -124,16 +124,16 @@ private: using AVFramePtr = std::shared_ptr; -inline AVFramePtr CreateAVFramePtr(FBFrame *f) +inline AVFramePtr create_av_frame_ptr(FBFrame *f) { return std::make_shared(f); } -inline AVFramePtr CreateAVFramePtr() +inline AVFramePtr create_av_frame_ptr() { return std::make_shared(); } } -#endif // AVFRAMEPTR_H +#endif // OAK_AVFRAMEPTR_H diff --git a/app/common/cancelableobject.h b/app/common/cancelableobject.h index 35a68b40d..15c974384 100644 --- a/app/common/cancelableobject.h +++ b/app/common/cancelableobject.h @@ -19,8 +19,8 @@ ***/ -#ifndef CANCELABLEOBJECT_H -#define CANCELABLEOBJECT_H +#ifndef OAK_CANCELABLEOBJECT_H +#define OAK_CANCELABLEOBJECT_H #include "common/define.h" #include "render/cancelatom.h" @@ -34,20 +34,20 @@ public: { } - void Cancel() + void cancel() { - cancel_.Cancel(); + cancel_.cancel(); CancelEvent(); } - CancelAtom *GetCancelAtom() + CancelAtom *get_cancel_atom() { return &cancel_; } - bool IsCancelled() + bool is_cancelled() { - return cancel_.IsCancelled(); + return cancel_.is_cancelled(); } protected: @@ -61,4 +61,4 @@ private: } -#endif // CANCELABLEOBJECT_H +#endif // OAK_CANCELABLEOBJECT_H diff --git a/app/common/commandlineparser.cpp b/app/common/commandlineparser.cpp index 6969480d5..2201983e0 100644 --- a/app/common/commandlineparser.cpp +++ b/app/common/commandlineparser.cpp @@ -36,7 +36,7 @@ CommandLineParser::~CommandLineParser() } const CommandLineParser::Option * -CommandLineParser::AddOption(const QStringList &strings, +CommandLineParser::add_option(const QStringList &strings, const QString &description, bool takes_arg, const QString &arg_placeholder, bool hidden) { @@ -49,7 +49,7 @@ CommandLineParser::AddOption(const QStringList &strings, } const CommandLineParser::PositionalArgument * -CommandLineParser::AddPositionalArgument(const QString &name, +CommandLineParser::add_positional_argument(const QString &name, const QString &description, bool required) { @@ -60,7 +60,7 @@ CommandLineParser::AddPositionalArgument(const QString &name, return a; } -void CommandLineParser::Process(const QVector &argv) +void CommandLineParser::process(const QVector &argv) { int positional_index = 0; @@ -79,10 +79,10 @@ void CommandLineParser::Process(const QVector &argv) foreach (const QString &s, o.args) { if (!s.compare(arg_basename, Qt::CaseInsensitive)) { // Flag discovered! - o.option->Set(); + o.option->set(); if (o.takes_arg && i + 1 < argv.size()) { - o.option->SetSetting(argv[i + 1]); + o.option->set_setting(argv[i + 1]); i++; } @@ -100,7 +100,7 @@ found_flag: } else { // Must be a positional flag if (positional_index < positional_args_.size()) { - positional_args_[positional_index].option->SetSetting(argv[i]); + positional_args_[positional_index].option->set_setting(argv[i]); positional_index++; } else { qWarning() << "Unknown parameter:" << argv[i]; @@ -109,7 +109,7 @@ found_flag: } } -void CommandLineParser::PrintHelp(const char *filename) +void CommandLineParser::print_help(const char *filename) { printf("%s %s\n", QCoreApplication::applicationName().toUtf8().constData(), QCoreApplication::applicationVersion().toUtf8().constData()); diff --git a/app/common/commandlineparser.h b/app/common/commandlineparser.h index e352e57f1..e0f374844 100644 --- a/app/common/commandlineparser.h +++ b/app/common/commandlineparser.h @@ -19,8 +19,8 @@ ***/ -#ifndef COMMANDLINEPARSER_H -#define COMMANDLINEPARSER_H +#ifndef OAK_COMMANDLINEPARSER_H +#define OAK_COMMANDLINEPARSER_H #include #include @@ -47,12 +47,12 @@ public: public: PositionalArgument() = default; - const QString &GetSetting() const + const QString &get_setting() const { return setting_; } - void SetSetting(const QString &s) + void set_setting(const QString &s) { setting_ = s; } @@ -68,12 +68,12 @@ public: is_set_ = false; } - bool IsSet() const + bool is_set() const { return is_set_; } - void Set() + void set() { is_set_ = true; } @@ -84,18 +84,18 @@ public: CommandLineParser() = default; - const Option *AddOption(const QStringList &strings, + const Option *add_option(const QStringList &strings, const QString &description, bool takes_arg = false, const QString &arg_placeholder = QString(), bool hidden = false); - const PositionalArgument *AddPositionalArgument(const QString &name, + const PositionalArgument *add_positional_argument(const QString &name, const QString &description, bool required = false); - void Process(const QVector &argv); + void process(const QVector &argv); - void PrintHelp(const char *filename); + void print_help(const char *filename); private: struct KnownOption { @@ -119,4 +119,4 @@ private: QVector positional_args_; }; -#endif // COMMANDLINEPARSER_H +#endif // OAK_COMMANDLINEPARSER_H diff --git a/app/common/crashpadinterface.h b/app/common/crashpadinterface.h index 501c3b407..714685d31 100644 --- a/app/common/crashpadinterface.h +++ b/app/common/crashpadinterface.h @@ -18,8 +18,8 @@ ***/ -#ifndef CRASHPAD_INTERFACE_H -#define CRASHPAD_INTERFACE_H +#ifndef OAK_CRASHPAD_INTERFACE_H +#define OAK_CRASHPAD_INTERFACE_H #ifdef USE_CRASHPAD @@ -30,4 +30,4 @@ bool InitializeCrashpad(); #endif // USE_CRASHPAD -#endif // CRASHPAD_INTERFACE_H +#endif // OAK_CRASHPAD_INTERFACE_H diff --git a/app/common/crashpadutils.h b/app/common/crashpadutils.h index 290c10a6e..018936e0e 100644 --- a/app/common/crashpadutils.h +++ b/app/common/crashpadutils.h @@ -19,8 +19,8 @@ ***/ -#ifndef CRASHPADUTILS_H -#define CRASHPADUTILS_H +#ifndef OAK_CRASHPADUTILS_H +#define OAK_CRASHPADUTILS_H #include @@ -38,4 +38,4 @@ #define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x) #endif // BUILDFLAG(IS_WIN) -#endif // CRASHPADUTILS_H +#endif // OAK_CRASHPADUTILS_H diff --git a/app/common/Current.cpp b/app/common/current.cpp similarity index 97% rename from app/common/Current.cpp rename to app/common/current.cpp index 0c3fd1d98..c93a033cb 100644 --- a/app/common/Current.cpp +++ b/app/common/current.cpp @@ -17,6 +17,6 @@ * */ -#include "Current.h" +#include "current.h" Current Current::current; \ No newline at end of file diff --git a/app/common/Current.h b/app/common/current.h similarity index 81% rename from app/common/Current.h rename to app/common/current.h index 312b4eb77..1c2d45438 100644 --- a/app/common/Current.h +++ b/app/common/current.h @@ -17,9 +17,9 @@ * */ -#ifndef CURRENT_H -#define CURRENT_H -#include "pluginSupport/OliveHost.h" +#ifndef OAK_CURRENT_H +#define OAK_CURRENT_H +#include "pluginSupport/olivehost.h" #include "render/videoparams.h" #include "render/job/pluginjob.h" @@ -29,11 +29,11 @@ public: { return current; } - olive::VideoParams ¤tVideoParams() + olive::VideoParams ¤t_video_params() { return currentVideoParams_; } - olive::AudioParams ¤tAudioParams() + olive::AudioParams ¤t_audio_params() { return currentAudioParams_; } @@ -58,17 +58,17 @@ public: return true; } - std::shared_ptr pluginHost() + std::shared_ptr plugin_host() { - return myHost; + return myHost_; } void setPluginHost(std::shared_ptr host) { - myHost = host; + myHost_ = host; } - std::shared_ptr pluginCache() + std::shared_ptr plugin_cache() { return plugin_cache_; } @@ -83,8 +83,8 @@ private: static Current current; olive::VideoParams currentVideoParams_; olive::AudioParams currentAudioParams_; - std::shared_ptr myHost; + std::shared_ptr myHost_; std::shared_ptr plugin_cache_; }; -#endif //CURRENT_H +#endif //OAK_CURRENT_H diff --git a/app/common/debug.cpp b/app/common/debug.cpp index 9922bf1af..0434f6466 100644 --- a/app/common/debug.cpp +++ b/app/common/debug.cpp @@ -24,10 +24,10 @@ namespace olive { -void DebugHandler(QtMsgType type, const QMessageLogContext &context, +void debug_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { - QByteArray localMsg = msg.toLocal8Bit(); + QByteArray local_msg = msg.toLocal8Bit(); const char *msg_type = "UNKNOWN"; switch (type) { @@ -49,7 +49,7 @@ void DebugHandler(QtMsgType type, const QMessageLogContext &context, } //fprintf(stderr, "[%s] %s (%s:%u)\n", msg_type, localMsg.constData(), context.function, context.line); - fprintf(stderr, "[%s] %s\n", msg_type, localMsg.constData()); + fprintf(stderr, "[%s] %s\n", msg_type, local_msg.constData()); #ifdef Q_OS_WINDOWS // Windows still seems to buffer stderr and we want to see debug messages immediately, so here we make sure each line diff --git a/app/common/debug.h b/app/common/debug.h index 2ed0fdcc4..83e7cdaba 100644 --- a/app/common/debug.h +++ b/app/common/debug.h @@ -19,8 +19,8 @@ ***/ -#ifndef DEBUG_H -#define DEBUG_H +#ifndef OAK_DEBUG_H +#define OAK_DEBUG_H #include @@ -29,9 +29,9 @@ namespace olive { -void DebugHandler(QtMsgType type, const QMessageLogContext &context, +void debug_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg); } -#endif // DEBUG_H +#endif // OAK_DEBUG_H diff --git a/app/common/decibel.h b/app/common/decibel.h index e5cc6be04..9918049e3 100644 --- a/app/common/decibel.h +++ b/app/common/decibel.h @@ -19,8 +19,8 @@ ***/ -#ifndef DECIBEL_H -#define DECIBEL_H +#ifndef OAK_DECIBEL_H +#define OAK_DECIBEL_H #include #include @@ -33,20 +33,20 @@ namespace olive class Decibel { public: // In basically all circumstances, this should calculate to 0.0 linear - static constexpr double MINIMUM = -200.0; + static constexpr double minimum = -200.0; - static double fromLinear(double linear) + static double from_linear(double linear) { double v = double(20.0) * std::log10(linear); #ifndef ALLOW_RETURNING_INFINITY if (std::isinf(v)) { - return MINIMUM; + return minimum; } #endif return v; } - static double toLinear(double decibel) + static double to_linear(double decibel) { double to_linear = std::pow(double(10.0), decibel / double(20.0)); @@ -58,47 +58,47 @@ public: } } - static double fromLogarithmic(double logarithmic) + static double from_logarithmic(double logarithmic) { if (logarithmic < 0.001) #ifdef ALLOW_RETURNING_INFINITY return std::numeric_limits::infinity(); #else - return MINIMUM; + return minimum; #endif else if (logarithmic > 0.99) return 0; else - return 20.0 * std::log10(-std::log(1 - logarithmic) / LOG100); + return 20.0 * std::log10(-std::log(1 - logarithmic) / lo_g100); } - static double toLogarithmic(double decibel) + static double to_logarithmic(double decibel) { if (qFuzzyIsNull(decibel)) { return 1; } else { - return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * LOG100); + return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * lo_g100); } } - static double LinearToLogarithmic(double linear) + static double linear_to_logarithmic(double linear) { - return 1 - std::exp(-linear * LOG100); + return 1 - std::exp(-linear * lo_g100); } - static double LogarithmicToLinear(double logarithmic) + static double logarithmic_to_linear(double logarithmic) { if (logarithmic > 0.99) { return 1; } else { - return -std::log(1 - logarithmic) / LOG100; + return -std::log(1 - logarithmic) / lo_g100; } } private: - static constexpr double LOG100 = 4.60517018599; + static constexpr double lo_g100 = 4.60517018599; }; } -#endif // DECIBEL_H +#endif // OAK_DECIBEL_H diff --git a/app/common/define.h b/app/common/define.h index dbd26d09c..ca0685550 100644 --- a/app/common/define.h +++ b/app/common/define.h @@ -19,22 +19,22 @@ ***/ -#ifndef OLIVECOMMONDEFINE_H -#define OLIVECOMMONDEFINE_H +#ifndef OAK_OLIVECOMMONDEFINE_H +#define OAK_OLIVECOMMONDEFINE_H namespace olive { /// The minimum size an icon in ProjectExplorer can be -const int kProjectIconSizeMinimum = 16; +const int k_project_icon_size_minimum = 16; /// The maximum size an icon in ProjectExplorer can be -const int kProjectIconSizeMaximum = 256; +const int k_project_icon_size_maximum = 256; /// The default size an icon in ProjectExplorer can be -const int kProjectIconSizeDefault = 64; +const int k_project_icon_size_default = 64; -const int kBytesInGigabyte = 1073741824; +const int k_bytes_in_gigabyte = 1073741824; } @@ -65,4 +65,4 @@ const int kBytesInGigabyte = 1073741824; DISABLE_COPY(Class) \ DISABLE_MOVE(Class) -#endif // OLIVECOMMONDEFINE_H +#endif // OAK_OLIVECOMMONDEFINE_H diff --git a/app/common/digit.h b/app/common/digit.h index 6f4246a1c..6801f4dff 100644 --- a/app/common/digit.h +++ b/app/common/digit.h @@ -19,15 +19,15 @@ ***/ -#ifndef DIGIT_H -#define DIGIT_H +#ifndef OAK_DIGIT_H +#define OAK_DIGIT_H #include namespace olive { -inline int64_t GetDigitCount(int64_t input) +inline int64_t get_digit_count(int64_t input) { input = std::abs(input); @@ -44,4 +44,4 @@ inline int64_t GetDigitCount(int64_t input) } -#endif // DIGIT_H +#endif // OAK_DIGIT_H diff --git a/app/common/ffmpegutils.cpp b/app/common/ffmpegutils.cpp index 3730a29cf..d3b0fea4b 100644 --- a/app/common/ffmpegutils.cpp +++ b/app/common/ffmpegutils.cpp @@ -24,110 +24,110 @@ namespace olive { -int FFmpegUtils::GetCompatibleBridgePixelFormat(int pix_fmt, +int FFmpegUtils::get_compatible_bridge_pixel_format(int pix_fmt, PixelFormat maximum) { int possible_pix_fmts[4]; - possible_pix_fmts[0] = FB_PIX_FMT_RGBA; + possible_pix_fmts[0] = fb_pix_fmt_rgba; - if (maximum == PixelFormat::U8) { - possible_pix_fmts[1] = FB_PIX_FMT_NONE; + if (maximum == PixelFormat::u8) { + possible_pix_fmts[1] = fb_pix_fmt_none; } else { - possible_pix_fmts[1] = FB_PIX_FMT_RGBA64LE; - if (maximum == PixelFormat::F32) { - possible_pix_fmts[2] = FB_PIX_FMT_RGBAF32LE; - possible_pix_fmts[3] = FB_PIX_FMT_NONE; + possible_pix_fmts[1] = fb_pix_fmt_rgb_a64_le; + if (maximum == PixelFormat::f32) { + possible_pix_fmts[2] = fb_pix_fmt_rgba_f32_le; + possible_pix_fmts[3] = fb_pix_fmt_none; } else { - possible_pix_fmts[2] = FB_PIX_FMT_NONE; + possible_pix_fmts[2] = fb_pix_fmt_none; } } return fb_find_best_pix_fmt_of_list(possible_pix_fmts, pix_fmt); } -SampleFormat FFmpegUtils::GetNativeSampleFormat(int smp_fmt) +SampleFormat FFmpegUtils::get_native_sample_format(int smp_fmt) { switch (smp_fmt) { - case FB_SAMPLE_FMT_U8: - return SampleFormat::U8; - case FB_SAMPLE_FMT_S16: - return SampleFormat::S16; - case FB_SAMPLE_FMT_S32: - return SampleFormat::S32; - case FB_SAMPLE_FMT_S64: - return SampleFormat::S64; - case FB_SAMPLE_FMT_FLT: - return SampleFormat::F32; - case FB_SAMPLE_FMT_DBL: - return SampleFormat::F64; - case FB_SAMPLE_FMT_U8P: - return SampleFormat::U8P; - case FB_SAMPLE_FMT_S16P: - return SampleFormat::S16P; - case FB_SAMPLE_FMT_S32P: - return SampleFormat::S32P; - case FB_SAMPLE_FMT_S64P: - return SampleFormat::S64P; - case FB_SAMPLE_FMT_FLTP: - return SampleFormat::F32P; - case FB_SAMPLE_FMT_DBLP: - return SampleFormat::F64P; + case fb_sample_fmt_u8: + return SampleFormat::u8; + case fb_sample_fmt_s16: + return SampleFormat::s16; + case fb_sample_fmt_s32: + return SampleFormat::s32; + case fb_sample_fmt_s64: + return SampleFormat::s64; + case fb_sample_fmt_flt: + return SampleFormat::f32; + case fb_sample_fmt_dbl: + return SampleFormat::f64; + case fb_sample_fmt_u8_p: + return SampleFormat::u8_p; + case fb_sample_fmt_s16_p: + return SampleFormat::s16_p; + case fb_sample_fmt_s32_p: + return SampleFormat::s32_p; + case fb_sample_fmt_s64_p: + return SampleFormat::s64_p; + case fb_sample_fmt_fltp: + return SampleFormat::f32_p; + case fb_sample_fmt_dblp: + return SampleFormat::f64_p; default: break; } - return SampleFormat::INVALID; + return SampleFormat::invalid; } -int FFmpegUtils::GetFFmpegSampleFormat(const SampleFormat &smp_fmt) +int FFmpegUtils::get_f_fmpeg_sample_format(const SampleFormat &smp_fmt) { switch (smp_fmt) { - case SampleFormat::U8: - return FB_SAMPLE_FMT_U8; - case SampleFormat::S16: - return FB_SAMPLE_FMT_S16; - case SampleFormat::S32: - return FB_SAMPLE_FMT_S32; - case SampleFormat::S64: - return FB_SAMPLE_FMT_S64; - case SampleFormat::F32: - return FB_SAMPLE_FMT_FLT; - case SampleFormat::F64: - return FB_SAMPLE_FMT_DBL; - case SampleFormat::U8P: - return FB_SAMPLE_FMT_U8P; - case SampleFormat::S16P: - return FB_SAMPLE_FMT_S16P; - case SampleFormat::S32P: - return FB_SAMPLE_FMT_S32P; - case SampleFormat::S64P: - return FB_SAMPLE_FMT_S64P; - case SampleFormat::F32P: - return FB_SAMPLE_FMT_FLTP; - case SampleFormat::F64P: - return FB_SAMPLE_FMT_DBLP; - case SampleFormat::INVALID: - case SampleFormat::COUNT: + case SampleFormat::u8: + return fb_sample_fmt_u8; + case SampleFormat::s16: + return fb_sample_fmt_s16; + case SampleFormat::s32: + return fb_sample_fmt_s32; + case SampleFormat::s64: + return fb_sample_fmt_s64; + case SampleFormat::f32: + return fb_sample_fmt_flt; + case SampleFormat::f64: + return fb_sample_fmt_dbl; + case SampleFormat::u8_p: + return fb_sample_fmt_u8_p; + case SampleFormat::s16_p: + return fb_sample_fmt_s16_p; + case SampleFormat::s32_p: + return fb_sample_fmt_s32_p; + case SampleFormat::s64_p: + return fb_sample_fmt_s64_p; + case SampleFormat::f32_p: + return fb_sample_fmt_fltp; + case SampleFormat::f64_p: + return fb_sample_fmt_dblp; + case SampleFormat::invalid: + case SampleFormat::count: break; } - return FB_SAMPLE_FMT_NONE; + return fb_sample_fmt_none; } -int FFmpegUtils::ConvertJPEGSpaceToRegularSpace(int f) +int FFmpegUtils::convert_jpeg_space_to_regular_space(int f) { switch (f) { - case FB_PIX_FMT_YUVJ420P: - return FB_PIX_FMT_YUV420P; - case FB_PIX_FMT_YUVJ422P: - return FB_PIX_FMT_YUV422P; - case FB_PIX_FMT_YUVJ444P: - return FB_PIX_FMT_YUV444P; - case FB_PIX_FMT_YUVJ440P: - return FB_PIX_FMT_YUV440P; - case FB_PIX_FMT_YUVJ411P: - return FB_PIX_FMT_YUV411P; + case fb_pix_fmt_yuv_j420_p: + return fb_pix_fmt_yu_v420_p; + case fb_pix_fmt_yuv_j422_p: + return fb_pix_fmt_yu_v422_p; + case fb_pix_fmt_yuv_j444_p: + return fb_pix_fmt_yu_v444_p; + case fb_pix_fmt_yuv_j440_p: + return fb_pix_fmt_yu_v440_p; + case fb_pix_fmt_yuv_j411_p: + return fb_pix_fmt_yu_v411_p; default: break; } @@ -135,63 +135,63 @@ int FFmpegUtils::ConvertJPEGSpaceToRegularSpace(int f) return f; } -int FFmpegUtils::GetFFmpegPixelFormat(const PixelFormat &pix_fmt, +int FFmpegUtils::get_f_fmpeg_pixel_format(const PixelFormat &pix_fmt, int channel_layout) { - if (channel_layout == VideoParams::kRGBChannelCount) { + if (channel_layout == VideoParams::k_rgb_channel_count) { switch (pix_fmt) { - case PixelFormat::U8: - return FB_PIX_FMT_RGB24; - case PixelFormat::U10: - return FB_PIX_FMT_NONE; - case PixelFormat::U16: - return FB_PIX_FMT_RGB48LE; - case PixelFormat::F16: - return FB_PIX_FMT_RGBF16LE; - case PixelFormat::F32: - return FB_PIX_FMT_RGBF32LE; - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::u8: + return fb_pix_fmt_rg_b24; + case PixelFormat::u10: + return fb_pix_fmt_none; + case PixelFormat::u16: + return fb_pix_fmt_rg_b48_le; + case PixelFormat::f16: + return fb_pix_fmt_rgb_f16_le; + case PixelFormat::f32: + return fb_pix_fmt_rgb_f32_le; + case PixelFormat::invalid: + case PixelFormat::count: break; } - } else if (channel_layout == VideoParams::kRGBAChannelCount) { + } else if (channel_layout == VideoParams::k_rgba_channel_count) { switch (pix_fmt) { - case PixelFormat::U8: - return FB_PIX_FMT_RGBA; - case PixelFormat::U10: - return FB_PIX_FMT_NONE; - case PixelFormat::U16: - return FB_PIX_FMT_RGBA64LE; - case PixelFormat::F16: - return FB_PIX_FMT_RGBAF16LE; - case PixelFormat::F32: - return FB_PIX_FMT_RGBAF32LE; - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::u8: + return fb_pix_fmt_rgba; + case PixelFormat::u10: + return fb_pix_fmt_none; + case PixelFormat::u16: + return fb_pix_fmt_rgb_a64_le; + case PixelFormat::f16: + return fb_pix_fmt_rgba_f16_le; + case PixelFormat::f32: + return fb_pix_fmt_rgba_f32_le; + case PixelFormat::invalid: + case PixelFormat::count: break; } } - return FB_PIX_FMT_NONE; + return fb_pix_fmt_none; } -PixelFormat FFmpegUtils::GetCompatiblePixelFormat(const PixelFormat &pix_fmt) +PixelFormat FFmpegUtils::get_compatible_pixel_format(const PixelFormat &pix_fmt) { switch (pix_fmt) { - case PixelFormat::U8: - return PixelFormat::U8; - case PixelFormat::U10: - return PixelFormat::U8; - case PixelFormat::U16: - case PixelFormat::F16: - case PixelFormat::F32: - return PixelFormat::U16; - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::u8: + return PixelFormat::u8; + case PixelFormat::u10: + return PixelFormat::u8; + case PixelFormat::u16: + case PixelFormat::f16: + case PixelFormat::f32: + return PixelFormat::u16; + case PixelFormat::invalid: + case PixelFormat::count: break; } - return PixelFormat::INVALID; + return PixelFormat::invalid; } } diff --git a/app/common/ffmpegutils.h b/app/common/ffmpegutils.h index 5d823feb3..cf19f618a 100644 --- a/app/common/ffmpegutils.h +++ b/app/common/ffmpegutils.h @@ -19,8 +19,8 @@ ***/ -#ifndef FFMPEGABSTRACTION_H -#define FFMPEGABSTRACTION_H +#ifndef OAK_FFMPEGABSTRACTION_H +#define OAK_FFMPEGABSTRACTION_H #include @@ -50,29 +50,29 @@ public: * taking a single argument, an unscoped enum argument would silently * prefer an int overload over the PixelFormat one. */ - static int GetCompatibleBridgePixelFormat( - int pix_fmt, PixelFormat maximum = PixelFormat::INVALID); + static int get_compatible_bridge_pixel_format( + int pix_fmt, PixelFormat maximum = PixelFormat::invalid); /** * @brief Returns a native pixel format that can be used to convert from a native frame to a bridge frame with minimal data loss */ - static PixelFormat GetCompatiblePixelFormat(const PixelFormat &pix_fmt); + static PixelFormat get_compatible_pixel_format(const PixelFormat &pix_fmt); /** * @brief Returns a bridge pixel format for a given native pixel format */ - static int GetFFmpegPixelFormat(const PixelFormat &pix_fmt, + static int get_f_fmpeg_pixel_format(const PixelFormat &pix_fmt, int channel_layout); /** * @brief Returns a native sample format type for a given bridge sample format */ - static SampleFormat GetNativeSampleFormat(int smp_fmt); + static SampleFormat get_native_sample_format(int smp_fmt); /** * @brief Returns a bridge sample format type for a given native type */ - static int GetFFmpegSampleFormat(const SampleFormat &smp_fmt); + static int get_f_fmpeg_sample_format(const SampleFormat &smp_fmt); /** * @brief Convert "JPEG"/full-range colorspace to its regular counterpart @@ -81,9 +81,9 @@ public: * time being, FFmpeg still uses these JPEG spaces, so for simplicity (since we *are* color_range * aware), we use this function. */ - static int ConvertJPEGSpaceToRegularSpace(int f); + static int convert_jpeg_space_to_regular_space(int f); }; } -#endif // FFMPEGABSTRACTION_H +#endif // OAK_FFMPEGABSTRACTION_H diff --git a/app/common/filefunctions.cpp b/app/common/filefunctions.cpp index 772752d3a..1c25b79c9 100644 --- a/app/common/filefunctions.cpp +++ b/app/common/filefunctions.cpp @@ -33,7 +33,7 @@ namespace olive { -QString FileFunctions::GetUniqueFileIdentifier(const QString &filename) +QString FileFunctions::get_unique_file_identifier(const QString &filename) { QFileInfo info(filename); @@ -53,10 +53,10 @@ QString FileFunctions::GetUniqueFileIdentifier(const QString &filename) return QString(result.toHex()); } -QString FileFunctions::GetConfigurationLocation() +QString FileFunctions::get_configuration_location() { - if (IsPortable()) { - return GetApplicationPath(); + if (is_portable()) { + return get_application_path(); } else { QString s = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); @@ -65,17 +65,17 @@ QString FileFunctions::GetConfigurationLocation() } } -bool FileFunctions::IsPortable() +bool FileFunctions::is_portable() { - return QFileInfo::exists(QDir(GetApplicationPath()).filePath("portable")); + return QFileInfo::exists(QDir(get_application_path()).filePath("portable")); } -QString FileFunctions::GetApplicationPath() +QString FileFunctions::get_application_path() { return QCoreApplication::applicationDirPath(); } -QString FileFunctions::GetTempFilePath() +QString FileFunctions::get_temp_file_path() { QString temp_path = QDir( @@ -89,7 +89,7 @@ QString FileFunctions::GetTempFilePath() return temp_path; } -bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source, +bool FileFunctions::can_copy_directory_without_overwriting(const QString &source, const QString &dest) { QFileInfoList info_list = QDir(source).entryInfoList(); @@ -104,7 +104,7 @@ bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source, QString dest_equivalent = QDir(dest).filePath(info.fileName()); if (info.isDir()) { - if (!CanCopyDirectoryWithoutOverwriting(info.absoluteFilePath(), + if (!can_copy_directory_without_overwriting(info.absoluteFilePath(), dest_equivalent)) { return false; } @@ -116,7 +116,7 @@ bool FileFunctions::CanCopyDirectoryWithoutOverwriting(const QString &source, return true; } -void FileFunctions::CopyDirectory(const QString &source, const QString &dest, +void FileFunctions::copy_directory(const QString &source, const QString &dest, bool overwrite) { QDir d(source); @@ -147,7 +147,7 @@ void FileFunctions::CopyDirectory(const QString &source, const QString &dest, if (info.isDir()) { // Copy dir - CopyDirectory(info.absoluteFilePath(), dest_file_path, overwrite); + copy_directory(info.absoluteFilePath(), dest_file_path, overwrite); } else { // Copy file if (overwrite && QFile::exists(dest_file_path)) { @@ -164,7 +164,7 @@ void FileFunctions::CopyDirectory(const QString &source, const QString &dest, } } -bool FileFunctions::DirectoryIsValid(const QDir &d, +bool FileFunctions::directory_is_valid(const QDir &d, bool try_to_create_if_not_exists) { // Return whether the directory exists, or whether it could be created if it doesn't @@ -172,7 +172,7 @@ bool FileFunctions::DirectoryIsValid(const QDir &d, (try_to_create_if_not_exists && d.mkpath(QStringLiteral("."))); } -QString FileFunctions::EnsureFilenameExtension(QString fn, +QString FileFunctions::ensure_filename_extension(QString fn, const QString &extension) { // No-op if either input is empty @@ -190,7 +190,7 @@ QString FileFunctions::EnsureFilenameExtension(QString fn, return fn; } -QString FileFunctions::ReadFileAsString(const QString &filename) +QString FileFunctions::read_file_as_string(const QString &filename) { QFile f(filename); QString file_data; @@ -202,7 +202,7 @@ QString FileFunctions::ReadFileAsString(const QString &filename) return file_data; } -QString FileFunctions::GetSafeTemporaryFilename(const QString &original) +QString FileFunctions::get_safe_temporary_filename(const QString &original) { int counter = 0; @@ -226,7 +226,7 @@ QString FileFunctions::GetSafeTemporaryFilename(const QString &original) return temp_abs_path; } -bool FileFunctions::RenameFileAllowOverwrite(const QString &from, +bool FileFunctions::rename_file_allow_overwrite(const QString &from, const QString &to) { if (QFileInfo::exists(to) && !QFile::remove(to)) { @@ -243,7 +243,7 @@ bool FileFunctions::RenameFileAllowOverwrite(const QString &from, return true; } -QString FileFunctions::GetAutoRecoveryRoot() +QString FileFunctions::get_auto_recovery_root() { return QDir(QStandardPaths::writableLocation( QStandardPaths::AppLocalDataLocation)) diff --git a/app/common/filefunctions.h b/app/common/filefunctions.h index 4d952b057..cc25eabba 100644 --- a/app/common/filefunctions.h +++ b/app/common/filefunctions.h @@ -19,8 +19,8 @@ ***/ -#ifndef FILEFUNCTIONS_H -#define FILEFUNCTIONS_H +#ifndef OAK_FILEFUNCTIONS_H +#define OAK_FILEFUNCTIONS_H #include #include @@ -41,23 +41,23 @@ public: * In portable mode, any persistent configuration files should be made in a path relative to the application rather * than in the user's home folder. */ - static bool IsPortable(); + static bool is_portable(); - static QString GetUniqueFileIdentifier(const QString &filename); + static QString get_unique_file_identifier(const QString &filename); - static QString GetConfigurationLocation(); + static QString get_configuration_location(); - static QString GetApplicationPath(); + static QString get_application_path(); - static QString GetTempFilePath(); + static QString get_temp_file_path(); - static bool CanCopyDirectoryWithoutOverwriting(const QString &source, + static bool can_copy_directory_without_overwriting(const QString &source, const QString &dest); - static void CopyDirectory(const QString &source, const QString &dest, + static void copy_directory(const QString &source, const QString &dest, bool overwrite = false); - static bool DirectoryIsValid(const QDir &dir, + static bool directory_is_valid(const QDir &dir, bool try_to_create_if_not_exists = true); /** @@ -69,10 +69,10 @@ public: * @return The filename provided either untouched or with the extension appended to it. */ - static QString EnsureFilenameExtension(QString fn, + static QString ensure_filename_extension(QString fn, const QString &extension); - static QString ReadFileAsString(const QString &filename); + static QString read_file_as_string(const QString &filename); /** * @brief Returns a temporary filename that can be used while writing rather than the original @@ -84,15 +84,15 @@ public: * This function returns a slight variant of the filename provided that's guaranteed to not exist * and therefore won't overwrite anything important. */ - static QString GetSafeTemporaryFilename(const QString &original); + static QString get_safe_temporary_filename(const QString &original); /** * @brief Renames a file from `from` to `to`, deleting `to` if such a file already exists first */ - static bool RenameFileAllowOverwrite(const QString &from, + static bool rename_file_allow_overwrite(const QString &from, const QString &to); - inline static QString GetFormattedExecutableForPlatform(QString unformatted) + inline static QString get_formatted_executable_for_platform(QString unformatted) { #ifdef Q_OS_WINDOWS unformatted.append(QStringLiteral(".exe")); @@ -101,9 +101,9 @@ public: return unformatted; } - static QString GetAutoRecoveryRoot(); + static QString get_auto_recovery_root(); }; } -#endif // FILEFUNCTIONS_H +#endif // OAK_FILEFUNCTIONS_H diff --git a/app/common/html.cpp b/app/common/html.cpp index 7ddae2070..1a9b3ec33 100644 --- a/app/common/html.cpp +++ b/app/common/html.cpp @@ -26,15 +26,15 @@ namespace olive { -const QVector Html::kBlockTags = { QStringLiteral("p"), +const QVector Html::k_block_tags = { QStringLiteral("p"), QStringLiteral("div") }; -inline bool StrEquals(const QStringView &a, const QStringView &b) +inline bool str_equals(const QStringView &a, const QStringView &b) { return !a.compare(b, Qt::CaseInsensitive); } -QString Html::DocToHtml(const QTextDocument *doc) +QString Html::doc_to_html(const QTextDocument *doc) { QString html; QXmlStreamWriter writer(&html); @@ -42,7 +42,7 @@ QString Html::DocToHtml(const QTextDocument *doc) //writer.setAutoFormatting(true); for (auto it = doc->begin(); it != doc->end(); it = it.next()) { - WriteBlock(&writer, it); + write_block(&writer, it); } return html; @@ -53,7 +53,7 @@ struct HtmlNode { QTextCharFormat format; }; -QTextCharFormat MergeHtmlFormats(const QVector &stack) +QTextCharFormat merge_html_formats(const QVector &stack) { QTextCharFormat f; @@ -64,7 +64,7 @@ QTextCharFormat MergeHtmlFormats(const QVector &stack) return f; } -void Html::HtmlToDoc(QTextDocument *doc, const QString &html) +void Html::html_to_doc(QTextDocument *doc, const QString &html) { // Empty doc doc->clear(); @@ -90,12 +90,12 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html) if (reader.tokenType() == QXmlStreamReader::StartElement) { QString tag = reader.name().toString().toLower(); - fmt_stack.append({ tag, ReadCharFormat(reader.attributes()) }); - current_fmt = MergeHtmlFormats(fmt_stack); + fmt_stack.append({ tag, read_char_format(reader.attributes()) }); + current_fmt = merge_html_formats(fmt_stack); - if (kBlockTags.contains(tag)) { + if (k_block_tags.contains(tag)) { QTextBlockFormat block_fmt = - ReadBlockFormat(reader.attributes()); + read_block_format(reader.attributes()); if (inside_block) { c.setBlockFormat(block_fmt); c.setBlockCharFormat(current_fmt); @@ -115,9 +115,9 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html) for (int i = fmt_stack.size() - 1; i >= 0; i--) { if (fmt_stack.at(i).tag == tag) { fmt_stack.removeAt(i); - current_fmt = MergeHtmlFormats(fmt_stack); + current_fmt = merge_html_formats(fmt_stack); - if (kBlockTags.contains(tag)) { + if (k_block_tags.contains(tag)) { inside_block = false; } break; @@ -131,7 +131,7 @@ void Html::HtmlToDoc(QTextDocument *doc, const QString &html) } } -void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block) +void Html::write_block(QXmlStreamWriter *writer, const QTextBlock &block) { writer->writeStartElement(QStringLiteral("p")); @@ -160,11 +160,11 @@ void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block) QString style; if (fmt.lineHeightType() != QTextBlockFormat::SingleHeight) { - WriteCSSProperty(&style, QStringLiteral("line-height"), + write_css_property(&style, QStringLiteral("line-height"), QStringLiteral("%1%").arg(fmt.lineHeight())); } - WriteCharFormat(&style, block.charFormat()); + write_char_format(&style, block.charFormat()); if (!style.isEmpty()) { writer->writeAttribute(QStringLiteral("style"), style); @@ -174,14 +174,14 @@ void Html::WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block) if (it != block.end()) { for (; it != block.end(); it++) { - WriteFragment(writer, it.fragment()); + write_fragment(writer, it.fragment()); } } writer->writeEndElement(); // p } -void Html::WriteFragment(QXmlStreamWriter *writer, +void Html::write_fragment(QXmlStreamWriter *writer, const QTextFragment &fragment) { const QTextCharFormat &fmt = fragment.charFormat(); @@ -191,7 +191,7 @@ void Html::WriteFragment(QXmlStreamWriter *writer, // Write CSS attributes QString style; - WriteCharFormat(&style, fmt); + write_char_format(&style, fmt); if (!style.isEmpty()) { writer->writeAttribute(QStringLiteral("style"), style); @@ -211,7 +211,7 @@ void Html::WriteFragment(QXmlStreamWriter *writer, writer->writeEndElement(); // span } -void Html::WriteCSSProperty(QString *style, const QString &key, +void Html::write_css_property(QString *style, const QString &key, const QStringList &values) { QString value; @@ -220,39 +220,39 @@ void Html::WriteCSSProperty(QString *style, const QString &key, v = QStringLiteral("'%1'").arg(v); } - AppendStringAutoSpace(&value, v); + append_string_auto_space(&value, v); } - AppendStringAutoSpace(style, QStringLiteral("%1: %2;").arg(key, value)); + append_string_auto_space(style, QStringLiteral("%1: %2;").arg(key, value)); } -void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt) +void Html::write_char_format(QString *style, const QTextCharFormat &fmt) { QStringList families = fmt.fontFamilies().toStringList(); if (!families.isEmpty()) { - WriteCSSProperty(style, QStringLiteral("font-family"), + write_css_property(style, QStringLiteral("font-family"), families.first()); } if (fmt.hasProperty(QTextFormat::FontPointSize)) { - WriteCSSProperty( + write_css_property( style, QStringLiteral("font-size"), QStringLiteral("%1pt").arg(QString::number(fmt.fontPointSize()))); } if (fmt.hasProperty(QTextFormat::FontWeight)) { - WriteCSSProperty(style, QStringLiteral("font-weight"), + write_css_property(style, QStringLiteral("font-weight"), QString::number(fmt.fontWeight() * 8)); } if (fmt.hasProperty(QTextFormat::FontItalic)) { - WriteCSSProperty(style, QStringLiteral("font-style"), + write_css_property(style, QStringLiteral("font-style"), fmt.fontItalic() ? QStringLiteral("italic") : QStringLiteral("normal")); } if (fmt.hasProperty(QTextFormat::FontStyleName)) { - WriteCSSProperty(style, QStringLiteral("-ove-font-style"), + write_css_property(style, QStringLiteral("-ove-font-style"), fmt.fontStyleName().toString()); } @@ -271,7 +271,7 @@ void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt) } if (!deco.isEmpty()) { - WriteCSSProperty(style, QStringLiteral("text-decoration"), deco); + write_css_property(style, QStringLiteral("text-decoration"), deco); } if (fmt.foreground().style() != Qt::NoBrush) { @@ -288,37 +288,37 @@ void Html::WriteCharFormat(QString *style, const QTextCharFormat &fmt) QString::number(color.alphaF())); } - WriteCSSProperty(style, QStringLiteral("color"), cs); + write_css_property(style, QStringLiteral("color"), cs); } if (fmt.fontCapitalization() != QFont::MixedCase) { if (fmt.fontCapitalization() == QFont::SmallCaps) { - WriteCSSProperty(style, QStringLiteral("font-variant"), + write_css_property(style, QStringLiteral("font-variant"), QStringLiteral("small-caps")); // TODO: Add others } } if (fmt.fontLetterSpacing() != 0.0) { - WriteCSSProperty(style, QStringLiteral("letter-spacing"), + write_css_property(style, QStringLiteral("letter-spacing"), QStringLiteral("%1%").arg( QString::number(fmt.fontLetterSpacing()))); } if (fmt.fontStretch() != 0) { - WriteCSSProperty( + write_css_property( style, QStringLiteral("font-stretch"), QStringLiteral("%1%").arg(QString::number(fmt.fontStretch()))); } } -QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes) +QTextCharFormat Html::read_char_format(const QXmlStreamAttributes &attributes) { QTextCharFormat fmt; foreach (const QXmlStreamAttribute &attr, attributes) { - if (StrEquals(attr.name(), QStringLiteral("style"))) { - auto css = GetCSSFromStyle(attr.value().toString()); + if (str_equals(attr.name(), QStringLiteral("style"))) { + auto css = get_css_from_style(attr.value().toString()); for (auto it = css.begin(); it != css.end(); it++) { const QString &first_val = it.value().first(); @@ -334,15 +334,15 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes) fmt.setFontWeight(first_val.toInt() / 8); } else if (it.key() == QStringLiteral("font-style")) { fmt.setFontItalic( - StrEquals(first_val, QStringLiteral("italic"))); + str_equals(first_val, QStringLiteral("italic"))); } else if (it.key() == QStringLiteral("text-decoration")) { foreach (const QString &v, it.value()) { - if (StrEquals(v, QStringLiteral("underline"))) { + if (str_equals(v, QStringLiteral("underline"))) { fmt.setFontUnderline(true); - } else if (StrEquals(v, + } else if (str_equals(v, QStringLiteral("line-through"))) { fmt.setFontStrikeOut(true); - } else if (StrEquals(v, QStringLiteral("overline"))) { + } else if (str_equals(v, QStringLiteral("overline"))) { fmt.setFontOverline(true); } } @@ -366,7 +366,7 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes) fmt.setForeground(QColor(first_val)); } } else if (it.key() == QStringLiteral("font-variant")) { - if (StrEquals(first_val, QStringLiteral("small-caps"))) { + if (str_equals(first_val, QStringLiteral("small-caps"))) { fmt.setFontCapitalization(QFont::SmallCaps); } } else if (it.key() == QStringLiteral("letter-spacing")) { @@ -387,25 +387,25 @@ QTextCharFormat Html::ReadCharFormat(const QXmlStreamAttributes &attributes) return fmt; } -QTextBlockFormat Html::ReadBlockFormat(const QXmlStreamAttributes &attributes) +QTextBlockFormat Html::read_block_format(const QXmlStreamAttributes &attributes) { QTextBlockFormat block_fmt; foreach (const QXmlStreamAttribute &attr, attributes) { - if (StrEquals(attr.name(), QStringLiteral("align"))) { - if (StrEquals(attr.value(), QStringLiteral("right"))) { + if (str_equals(attr.name(), QStringLiteral("align"))) { + if (str_equals(attr.value(), QStringLiteral("right"))) { block_fmt.setAlignment(Qt::AlignRight); - } else if (StrEquals(attr.value(), QStringLiteral("center"))) { + } else if (str_equals(attr.value(), QStringLiteral("center"))) { block_fmt.setAlignment(Qt::AlignHCenter); - } else if (StrEquals(attr.value(), QStringLiteral("justify"))) { + } else if (str_equals(attr.value(), QStringLiteral("justify"))) { block_fmt.setAlignment(Qt::AlignJustify); } - } else if (StrEquals(attr.name(), QStringLiteral("dir"))) { - if (StrEquals(attr.value(), QStringLiteral("rtl"))) { + } else if (str_equals(attr.name(), QStringLiteral("dir"))) { + if (str_equals(attr.value(), QStringLiteral("rtl"))) { block_fmt.setLayoutDirection(Qt::RightToLeft); } - } else if (StrEquals(attr.name(), QStringLiteral("style"))) { - auto css = GetCSSFromStyle(attr.value().toString()); + } else if (str_equals(attr.name(), QStringLiteral("style"))) { + auto css = get_css_from_style(attr.value().toString()); for (auto it = css.begin(); it != css.end(); it++) { if (it.key() == QStringLiteral("line-height")) { @@ -423,7 +423,7 @@ QTextBlockFormat Html::ReadBlockFormat(const QXmlStreamAttributes &attributes) return block_fmt; } -void Html::AppendStringAutoSpace(QString *s, const QString &append) +void Html::append_string_auto_space(QString *s, const QString &append) { if (!s->isEmpty()) { s->append(QChar(' ')); @@ -432,7 +432,7 @@ void Html::AppendStringAutoSpace(QString *s, const QString &append) s->append(append); } -QMap Html::GetCSSFromStyle(const QString &s) +QMap Html::get_css_from_style(const QString &s) { QMap map; diff --git a/app/common/html.h b/app/common/html.h index 387a1ae4c..dca9690fb 100644 --- a/app/common/html.h +++ b/app/common/html.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef HTML_H -#define HTML_H +#ifndef OAK_HTML_H +#define OAK_HTML_H #include #include @@ -45,39 +45,39 @@ namespace olive */ class Html { public: - static QString DocToHtml(const QTextDocument *doc); + static QString doc_to_html(const QTextDocument *doc); - static void HtmlToDoc(QTextDocument *doc, const QString &html); + static void html_to_doc(QTextDocument *doc, const QString &html); private: - static void WriteBlock(QXmlStreamWriter *writer, const QTextBlock &block); + static void write_block(QXmlStreamWriter *writer, const QTextBlock &block); - static void WriteFragment(QXmlStreamWriter *writer, + static void write_fragment(QXmlStreamWriter *writer, const QTextFragment &fragment); - static void WriteCSSProperty(QString *style, const QString &key, + static void write_css_property(QString *style, const QString &key, const QStringList &value); - static void WriteCSSProperty(QString *style, const QString &key, + static void write_css_property(QString *style, const QString &key, const QString &value) { - WriteCSSProperty(style, key, QStringList({ value })); + write_css_property(style, key, QStringList({ value })); } - static void WriteCharFormat(QString *style, const QTextCharFormat &fmt); + static void write_char_format(QString *style, const QTextCharFormat &fmt); static QTextCharFormat - ReadCharFormat(const QXmlStreamAttributes &attributes); + read_char_format(const QXmlStreamAttributes &attributes); static QTextBlockFormat - ReadBlockFormat(const QXmlStreamAttributes &attributes); + read_block_format(const QXmlStreamAttributes &attributes); - static void AppendStringAutoSpace(QString *s, const QString &append); + static void append_string_auto_space(QString *s, const QString &append); - static QMap GetCSSFromStyle(const QString &s); + static QMap get_css_from_style(const QString &s); - static const QVector kBlockTags; + static const QVector k_block_tags; }; } -#endif // HTML_H +#endif // OAK_HTML_H diff --git a/app/common/jobtime.cpp b/app/common/jobtime.cpp index 058b52a34..0dcaaf486 100644 --- a/app/common/jobtime.cpp +++ b/app/common/jobtime.cpp @@ -28,10 +28,10 @@ QMutex job_time_mutex; JobTime::JobTime() { - Acquire(); + acquire(); } -void JobTime::Acquire() +void JobTime::acquire() { job_time_mutex.lock(); diff --git a/app/common/jobtime.h b/app/common/jobtime.h index 1a51871c8..449153b1e 100644 --- a/app/common/jobtime.h +++ b/app/common/jobtime.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef JOBTIME_H -#define JOBTIME_H +#ifndef OAK_JOBTIME_H +#define OAK_JOBTIME_H #include #include @@ -29,7 +29,7 @@ class JobTime { public: JobTime(); - void Acquire(); + void acquire(); uint64_t value() const { @@ -76,4 +76,4 @@ QDebug operator<<(QDebug debug, const olive::JobTime &r); Q_DECLARE_METATYPE(olive::JobTime) -#endif // JOBTIME_H +#endif // OAK_JOBTIME_H diff --git a/app/common/lerp.h b/app/common/lerp.h index d79ae75d5..8b1eb3b0a 100644 --- a/app/common/lerp.h +++ b/app/common/lerp.h @@ -19,8 +19,8 @@ ***/ -#ifndef LERP_H -#define LERP_H +#ifndef OAK_LERP_H +#define OAK_LERP_H template /** @@ -39,4 +39,4 @@ template T lerp(T a, T b, float t) return (a * (1.0f - t)) + (b * t); } -#endif // LERP_H +#endif // OAK_LERP_H diff --git a/app/common/memorypool.h b/app/common/memorypool.h index 272388707..0968152c6 100644 --- a/app/common/memorypool.h +++ b/app/common/memorypool.h @@ -19,8 +19,8 @@ ***/ -#ifndef MEMORYPOOL_H -#define MEMORYPOOL_H +#ifndef OAK_MEMORYPOOL_H +#define OAK_MEMORYPOOL_H #include #include @@ -435,4 +435,4 @@ private slots: } -#endif // MEMORYPOOL_H +#endif // OAK_MEMORYPOOL_H diff --git a/app/common/ocioutils.cpp b/app/common/ocioutils.cpp index ae420b44e..26bd68df8 100644 --- a/app/common/ocioutils.cpp +++ b/app/common/ocioutils.cpp @@ -24,28 +24,28 @@ namespace olive { -OCIO::BitDepth OCIOUtils::GetOCIOBitDepthFromPixelFormat(PixelFormat format) +ocio::BitDepth OCIOUtils::get_ocio_bit_depth_from_pixel_format(PixelFormat format) { switch (format) { - case PixelFormat::U8: - return OCIO::BIT_DEPTH_UINT8; - case PixelFormat::U10: - return OCIO::BIT_DEPTH_UINT10; - case PixelFormat::U16: - return OCIO::BIT_DEPTH_UINT16; + case PixelFormat::u8: + return ocio::BIT_DEPTH_UINT8; + case PixelFormat::u10: + return ocio::BIT_DEPTH_UINT10; + case PixelFormat::u16: + return ocio::BIT_DEPTH_UINT16; break; - case PixelFormat::F16: - return OCIO::BIT_DEPTH_F16; + case PixelFormat::f16: + return ocio::BIT_DEPTH_F16; break; - case PixelFormat::F32: - return OCIO::BIT_DEPTH_F32; + case PixelFormat::f32: + return ocio::BIT_DEPTH_F32; break; - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; } - return OCIO::BIT_DEPTH_UNKNOWN; + return ocio::BIT_DEPTH_UNKNOWN; } } diff --git a/app/common/ocioutils.h b/app/common/ocioutils.h index bc317c2d9..a756f0d32 100644 --- a/app/common/ocioutils.h +++ b/app/common/ocioutils.h @@ -19,11 +19,11 @@ ***/ -#ifndef OCIOUTILS_H -#define OCIOUTILS_H +#ifndef OAK_OCIOUTILS_H +#define OAK_OCIOUTILS_H #include -namespace OCIO = OCIO_NAMESPACE; +namespace ocio = OCIO_NAMESPACE; #include "render/videoparams.h" @@ -32,9 +32,9 @@ namespace olive class OCIOUtils { public: - static OCIO::BitDepth GetOCIOBitDepthFromPixelFormat(PixelFormat format); + static ocio::BitDepth get_ocio_bit_depth_from_pixel_format(PixelFormat format); }; } -#endif // OCIOUTILS_H +#endif // OAK_OCIOUTILS_H diff --git a/app/common/oiioutils.cpp b/app/common/oiioutils.cpp index a74d42306..e6cc033cf 100644 --- a/app/common/oiioutils.cpp +++ b/app/common/oiioutils.cpp @@ -26,25 +26,25 @@ namespace olive { -void OIIOUtils::FrameToBuffer(const Frame *frame, OIIO::ImageBuf *buf) +void OIIOUtils::frame_to_buffer(const Frame *frame, OIIO::ImageBuf *buf) { buf->set_pixels(OIIO::ROI(), buf->spec().format, frame->const_data(), OIIO::AutoStride, frame->linesize_bytes()); } -void OIIOUtils::BufferToFrame(OIIO::ImageBuf *buf, Frame *frame) +void OIIOUtils::buffer_to_frame(OIIO::ImageBuf *buf, Frame *frame) { buf->get_pixels(OIIO::ROI(), buf->spec().format, frame->data(), OIIO::AutoStride, frame->linesize_bytes()); } -rational OIIOUtils::GetPixelAspectRatioFromOIIO(const OIIO::ImageSpec &spec) +Rational OIIOUtils::get_pixel_aspect_ratio_from_oiio(const OIIO::ImageSpec &spec) { - return rational::fromDouble( + return Rational::from_double( spec.get_float_attribute("PixelAspectRatio", 1)); } -PixelFormat OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type) +PixelFormat OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::BASETYPE type) { switch (type) { case OIIO::TypeDesc::UNKNOWN: @@ -65,16 +65,16 @@ PixelFormat OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type) break; case OIIO::TypeDesc::UINT8: - return PixelFormat::U8; + return PixelFormat::u8; case OIIO::TypeDesc::UINT16: - return PixelFormat::U16; + return PixelFormat::u16; case OIIO::TypeDesc::HALF: - return PixelFormat::F16; + return PixelFormat::f16; case OIIO::TypeDesc::FLOAT: - return PixelFormat::F32; + return PixelFormat::f32; } - return PixelFormat::INVALID; + return PixelFormat::invalid; } } diff --git a/app/common/oiioutils.h b/app/common/oiioutils.h index d4fd18ff3..62fb38741 100644 --- a/app/common/oiioutils.h +++ b/app/common/oiioutils.h @@ -19,8 +19,8 @@ ***/ -#ifndef OIIOUTILS_H -#define OIIOUTILS_H +#ifndef OAK_OIIOUTILS_H +#define OAK_OIIOUTILS_H #include #include @@ -34,36 +34,36 @@ namespace olive class OIIOUtils { public: static OIIO::TypeDesc::BASETYPE - GetOIIOBaseTypeFromFormat(PixelFormat format) + get_oiio_base_type_from_format(PixelFormat format) { switch (format) { - case PixelFormat::U8: + case PixelFormat::u8: return OIIO::TypeDesc::UINT8; - case PixelFormat::U10: + case PixelFormat::u10: return OIIO::TypeDesc::UNKNOWN; - case PixelFormat::U16: + case PixelFormat::u16: return OIIO::TypeDesc::UINT16; - case PixelFormat::F16: + case PixelFormat::f16: return OIIO::TypeDesc::HALF; - case PixelFormat::F32: + case PixelFormat::f32: return OIIO::TypeDesc::FLOAT; - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; } return OIIO::TypeDesc::UNKNOWN; } - static void FrameToBuffer(const Frame *frame, OIIO::ImageBuf *buf); + static void frame_to_buffer(const Frame *frame, OIIO::ImageBuf *buf); - static void BufferToFrame(OIIO::ImageBuf *buf, Frame *frame); + static void buffer_to_frame(OIIO::ImageBuf *buf, Frame *frame); - static PixelFormat GetFormatFromOIIOBasetype(OIIO::TypeDesc::BASETYPE type); + static PixelFormat get_format_from_oiio_basetype(OIIO::TypeDesc::BASETYPE type); - static rational GetPixelAspectRatioFromOIIO(const OIIO::ImageSpec &spec); + static Rational get_pixel_aspect_ratio_from_oiio(const OIIO::ImageSpec &spec); }; } -#endif // OIIOUTILS_H +#endif // OAK_OIIOUTILS_H diff --git a/app/common/otioutils.h b/app/common/otioutils.h index 1a3a32dd0..8ba7dc7a6 100644 --- a/app/common/otioutils.h +++ b/app/common/otioutils.h @@ -18,8 +18,8 @@ ***/ -#ifndef OTIOUTILS_H -#define OTIOUTILS_H +#ifndef OAK_OTIOUTILS_H +#define OAK_OTIOUTILS_H #ifdef USE_OTIO #include diff --git a/app/common/power.h b/app/common/power.h index 46f8e4b5a..e84951ce6 100644 --- a/app/common/power.h +++ b/app/common/power.h @@ -19,8 +19,8 @@ ***/ -#ifndef POWER_H -#define POWER_H +#ifndef OAK_POWER_H +#define OAK_POWER_H #include @@ -55,4 +55,4 @@ uint32_t floor_to_power_of_2(uint32_t x) } -#endif // POWER_H +#endif // OAK_POWER_H diff --git a/app/common/qtutils.cpp b/app/common/qtutils.cpp index 33c1c9f14..7c6f852e6 100644 --- a/app/common/qtutils.cpp +++ b/app/common/qtutils.cpp @@ -26,7 +26,7 @@ namespace olive { -int QtUtils::QFontMetricsWidth(QFontMetrics fm, const QString &s) +int QtUtils::q_font_metrics_width(QFontMetrics fm, const QString &s) { #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) return fm.width(s); @@ -35,7 +35,7 @@ int QtUtils::QFontMetricsWidth(QFontMetrics fm, const QString &s) #endif } -QFrame *QtUtils::CreateHorizontalLine() +QFrame *QtUtils::create_horizontal_line() { QFrame *horizontal_line = new QFrame(); horizontal_line->setFrameShape(QFrame::HLine); @@ -43,14 +43,14 @@ QFrame *QtUtils::CreateHorizontalLine() return horizontal_line; } -QFrame *QtUtils::CreateVerticalLine() +QFrame *QtUtils::create_vertical_line() { - QFrame *l = CreateHorizontalLine(); + QFrame *l = create_horizontal_line(); l->setFrameShape(QFrame::VLine); return l; } -int QtUtils::MsgBox(QWidget *parent, QMessageBox::Icon icon, +int QtUtils::msg_box(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &message, QMessageBox::StandardButtons buttons) { @@ -72,7 +72,7 @@ int QtUtils::MsgBox(QWidget *parent, QMessageBox::Icon icon, return b.exec(); } -QDateTime QtUtils::GetCreationDate(const QFileInfo &info) +QDateTime QtUtils::get_creation_date(const QFileInfo &info) { #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) return info.created(); @@ -85,12 +85,12 @@ QDateTime QtUtils::GetCreationDate(const QFileInfo &info) #endif } -QString QtUtils::GetFormattedDateTime(const QDateTime &dt) +QString QtUtils::get_formatted_date_time(const QDateTime &dt) { return dt.toString(Qt::TextDate); } -QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm, +QStringList QtUtils::word_wrap_string(const QString &s, const QFontMetrics &fm, int bounding_width) { QStringList list; @@ -102,7 +102,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm, QString this_line = lines.at(i); while (this_line.size() > 1 && - QFontMetricsWidth(fm, this_line) >= bounding_width) { + q_font_metrics_width(fm, this_line) >= bounding_width) { int old_size = this_line.size(); int hard_break = -1; @@ -110,7 +110,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm, const QChar &char_test = this_line.at(j); if (char_test.isSpace() || char_test == '-') { - if (QFontMetricsWidth(fm, this_line.left(j)) < + if (q_font_metrics_width(fm, this_line.left(j)) < bounding_width) { if (!char_test.isSpace()) { j++; @@ -128,7 +128,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm, break; } } else if (hard_break == -1 && - QFontMetricsWidth(fm, this_line.left(j)) < + q_font_metrics_width(fm, this_line.left(j)) < bounding_width) { // In case we can't find a better place to split, split at the earliest time the line // goes under the width limit @@ -157,7 +157,7 @@ QStringList QtUtils::WordWrapString(const QString &s, const QFontMetrics &fm, } Qt::KeyboardModifiers -QtUtils::FlipControlAndShiftModifiers(Qt::KeyboardModifiers e) +QtUtils::flip_control_and_shift_modifiers(Qt::KeyboardModifiers e) { if (e & Qt::ControlModifier & Qt::ShiftModifier) { return e; @@ -174,7 +174,7 @@ QtUtils::FlipControlAndShiftModifiers(Qt::KeyboardModifiers e) return e; } -void QtUtils::SetComboBoxData(QComboBox *cb, int data) +void QtUtils::set_combo_box_data(QComboBox *cb, int data) { for (int i = 0; i < cb->count(); i++) { if (cb->itemData(i).toInt() == data) { @@ -184,7 +184,7 @@ void QtUtils::SetComboBoxData(QComboBox *cb, int data) } } -void QtUtils::SetComboBoxData(QComboBox *cb, const QString &data) +void QtUtils::set_combo_box_data(QComboBox *cb, const QString &data) { for (int i = 0; i < cb->count(); i++) { if (cb->itemData(i).toString() == data) { @@ -194,7 +194,7 @@ void QtUtils::SetComboBoxData(QComboBox *cb, const QString &data) } } -QColor QtUtils::toQColor(const core::Color &i) +QColor QtUtils::to_q_color(const core::Color &i) { QColor c; @@ -210,9 +210,9 @@ QColor QtUtils::toQColor(const core::Color &i) namespace core { -uint qHash(const core::rational &r, uint seed) +uint qHash(const core::Rational &r, uint seed) { - return ::qHash(r.toDouble(), seed); + return ::qHash(r.to_double(), seed); } uint qHash(const core::TimeRange &r, uint seed) diff --git a/app/common/qtutils.h b/app/common/qtutils.h index 34673e016..74a97e564 100644 --- a/app/common/qtutils.h +++ b/app/common/qtutils.h @@ -19,8 +19,8 @@ ***/ -#ifndef QTVERSIONABSTRACTION_H -#define QTVERSIONABSTRACTION_H +#ifndef OAK_QTVERSIONABSTRACTION_H +#define OAK_QTVERSIONABSTRACTION_H #include #include @@ -42,30 +42,30 @@ public: * latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for * earlier. */ - static int QFontMetricsWidth(QFontMetrics fm, const QString &s); + static int q_font_metrics_width(QFontMetrics fm, const QString &s); - static QFrame *CreateHorizontalLine(); + static QFrame *create_horizontal_line(); - static QFrame *CreateVerticalLine(); + static QFrame *create_vertical_line(); - static int MsgBox(QWidget *parent, QMessageBox::Icon icon, + static int msg_box(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &message, QMessageBox::StandardButtons buttons = QMessageBox::Ok); - static QDateTime GetCreationDate(const QFileInfo &info); + static QDateTime get_creation_date(const QFileInfo &info); - static QString GetFormattedDateTime(const QDateTime &dt); + static QString get_formatted_date_time(const QDateTime &dt); - static QStringList WordWrapString(const QString &s, const QFontMetrics &fm, + static QStringList word_wrap_string(const QString &s, const QFontMetrics &fm, int bounding_width); static Qt::KeyboardModifiers - FlipControlAndShiftModifiers(Qt::KeyboardModifiers e); + flip_control_and_shift_modifiers(Qt::KeyboardModifiers e); - static void SetComboBoxData(QComboBox *cb, int data); - static void SetComboBoxData(QComboBox *cb, const QString &data); + static void set_combo_box_data(QComboBox *cb, int data); + static void set_combo_box_data(QComboBox *cb, const QString &data); - template static T *GetParentOfType(const QObject *child) + template static T *get_parent_of_type(const QObject *child) { QObject *t = child->parent(); @@ -79,12 +79,12 @@ public: return nullptr; } - static QColor toQColor(const core::Color &c); + static QColor to_q_color(const core::Color &c); /** * @brief Convert a pointer to a value that can be sent between NodeParams */ - static QVariant PtrToValue(void *ptr) + static QVariant ptr_to_value(void *ptr) { return reinterpret_cast(ptr); } @@ -92,7 +92,7 @@ public: /** * @brief Convert a NodeParam value to a pointer of any kind */ - template static T *ValueToPtr(const QVariant &ptr) + template static T *value_to_ptr(const QVariant &ptr) { return reinterpret_cast(ptr.value()); } @@ -101,18 +101,18 @@ public: namespace core { -uint qHash(const core::rational &r, uint seed = 0); +uint qHash(const core::Rational &r, uint seed = 0); uint qHash(const core::TimeRange &r, uint seed = 0); } } -Q_DECLARE_METATYPE(olive::core::rational) +Q_DECLARE_METATYPE(olive::core::Rational) Q_DECLARE_METATYPE(olive::core::Color) Q_DECLARE_METATYPE(olive::core::TimeRange) Q_DECLARE_METATYPE(olive::core::Bezier) Q_DECLARE_METATYPE(olive::core::AudioParams) Q_DECLARE_METATYPE(olive::core::SampleBuffer) -#endif // QTVERSIONABSTRACTION_H +#endif // OAK_QTVERSIONABSTRACTION_H diff --git a/app/common/range.h b/app/common/range.h index 0dc48a0ec..c6ca2f8c0 100644 --- a/app/common/range.h +++ b/app/common/range.h @@ -19,12 +19,12 @@ ***/ -#ifndef RANGE_H -#define RANGE_H +#ifndef OAK_RANGE_H +#define OAK_RANGE_H -template bool InRange(T a, T b, T range) +template bool in_range(T a, T b, T range) { return (a >= b - range && a <= b + range); } -#endif // RANGE_H +#endif // OAK_RANGE_H diff --git a/app/common/ratiodialog.cpp b/app/common/ratiodialog.cpp index d6d5266f2..80c072ede 100644 --- a/app/common/ratiodialog.cpp +++ b/app/common/ratiodialog.cpp @@ -28,7 +28,7 @@ namespace olive { -double GetFloatRatioFromUser(QWidget *parent, const QString &title, bool *ok_in) +double get_float_ratio_from_user(QWidget *parent, const QString &title, bool *ok_in) { QString s; @@ -86,7 +86,7 @@ double GetFloatRatioFromUser(QWidget *parent, const QString &title, bool *ok_in) QCoreApplication::translate( "RatioDialog", "Failed to parse \"%1\" into an aspect ratio. Please format a " - "rational fraction with a ':' or a '/' separator.") + "Rational fraction with a ':' or a '/' separator.") .arg(s), QMessageBox::Ok); } diff --git a/app/common/ratiodialog.h b/app/common/ratiodialog.h index 7c1a80261..7d724a3bf 100644 --- a/app/common/ratiodialog.h +++ b/app/common/ratiodialog.h @@ -19,17 +19,17 @@ ***/ -#ifndef RATIODIALOG_H -#define RATIODIALOG_H +#ifndef OAK_RATIODIALOG_H +#define OAK_RATIODIALOG_H #include namespace olive { -double GetFloatRatioFromUser(QWidget *parent, const QString &title, +double get_float_ratio_from_user(QWidget *parent, const QString &title, bool *ok_in); } -#endif // RATIODIALOG_H +#endif // OAK_RATIODIALOG_H diff --git a/app/common/threadsafemap.h b/app/common/threadsafemap.h index de78078ac..5f9c53f18 100644 --- a/app/common/threadsafemap.h +++ b/app/common/threadsafemap.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef THREADSAFEMAP_H -#define THREADSAFEMAP_H +#ifndef OAK_THREADSAFEMAP_H +#define OAK_THREADSAFEMAP_H #include #include @@ -39,4 +39,4 @@ private: QMap map_; }; -#endif // THREADSAFEMAP_H +#endif // OAK_THREADSAFEMAP_H diff --git a/app/common/tohex.h b/app/common/tohex.h index b0f04191f..8878b6d07 100644 --- a/app/common/tohex.h +++ b/app/common/tohex.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef TOHEX_H -#define TOHEX_H +#ifndef OAK_TOHEX_H +#define OAK_TOHEX_H #include #include @@ -27,11 +27,11 @@ namespace olive { -inline QString ToHex(quint64 t) +inline QString to_hex(quint64 t) { return QStringLiteral("%1").arg(t, 0, 16); } } -#endif // TOHEX_H +#endif // OAK_TOHEX_H diff --git a/app/common/util.h b/app/common/util.h index f5b9cb38d..33d1d3c8d 100644 --- a/app/common/util.h +++ b/app/common/util.h @@ -19,12 +19,12 @@ ***/ -#ifndef UTIL_H -#define UTIL_H +#ifndef OAK_UTIL_H +#define OAK_UTIL_H template inline T mid(T a, T b) { return (a + b) * 0.5; } -#endif // UTIL_H +#endif // OAK_UTIL_H diff --git a/app/common/xmlutils.cpp b/app/common/xmlutils.cpp index 20d0e9044..38ba6b78c 100644 --- a/app/common/xmlutils.cpp +++ b/app/common/xmlutils.cpp @@ -27,13 +27,13 @@ namespace olive { -bool XMLReadNextStartElement(QXmlStreamReader *reader, CancelAtom *cancel_atom) +bool xml_read_next_start_element(QXmlStreamReader *reader, CancelAtom *cancel_atom) { QXmlStreamReader::TokenType token; while ((token = reader->readNext()) != QXmlStreamReader::Invalid && token != QXmlStreamReader::EndDocument && - (!cancel_atom || !cancel_atom->IsCancelled())) { + (!cancel_atom || !cancel_atom->is_cancelled())) { if (reader->isEndElement()) { return false; } else if (reader->isStartElement()) { diff --git a/app/common/xmlutils.h b/app/common/xmlutils.h index 79a653be0..b3a9412d8 100644 --- a/app/common/xmlutils.h +++ b/app/common/xmlutils.h @@ -19,8 +19,8 @@ ***/ -#ifndef XMLREADLOOP_H -#define XMLREADLOOP_H +#ifndef OAK_XMLREADLOOP_H +#define OAK_XMLREADLOOP_H #include @@ -48,9 +48,9 @@ class NodeGroup; * * See also: https://stackoverflow.com/questions/46346450/qt-qxmlstreamreader-always-returns-premature-end-of-document-error */ -bool XMLReadNextStartElement(QXmlStreamReader *reader, +bool xml_read_next_start_element(QXmlStreamReader *reader, CancelAtom *cancel_atom = nullptr); } -#endif // XMLREADLOOP_H +#endif // OAK_XMLREADLOOP_H diff --git a/app/config/config.cpp b/app/config/config.cpp index da9cced50..6acee8ff7 100644 --- a/app/config/config.cpp +++ b/app/config/config.cpp @@ -42,239 +42,239 @@ namespace olive { -Config Config::current_config_; +Config Config::current_config; Config::Config() { - SetDefaults(); + set_defaults(); } -void Config::SetEntryInternal(const QString &key, NodeValue::Type type, +void Config::set_entry_internal(const QString &key, NodeValue::Type type, const QVariant &data) { config_map_[key] = { type, data }; } -QString Config::GetConfigFilePath() +QString Config::get_config_file_path() { - return QDir(FileFunctions::GetConfigurationLocation()) + return QDir(FileFunctions::get_configuration_location()) .filePath(QStringLiteral("config.xml")); } -Config &Config::Current() +Config &Config::current() { - return current_config_; + return current_config; } -void Config::SetDefaults() +void Config::set_defaults() { config_map_.clear(); - SetEntryInternal(QStringLiteral("Style"), NodeValue::kText, - StyleManager::kDefaultStyle); - SetEntryInternal(QStringLiteral("TimecodeDisplay"), NodeValue::kInt, - Timecode::kTimecodeDropFrame); - SetEntryInternal(QStringLiteral("DefaultStillLength"), NodeValue::kRational, - QVariant::fromValue(rational(2))); - SetEntryInternal(QStringLiteral("HoverFocus"), NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("AudioScrubbing"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("Style"), NodeValue::k_text, + StyleManager::k_default_style); + set_entry_internal(QStringLiteral("TimecodeDisplay"), NodeValue::k_int, + Timecode::k_timecode_drop_frame); + set_entry_internal(QStringLiteral("DefaultStillLength"), NodeValue::k_rational, + QVariant::fromValue(Rational(2))); + set_entry_internal(QStringLiteral("HoverFocus"), NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("AudioScrubbing"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("AutorecoveryEnabled"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("AutorecoveryEnabled"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("AutorecoveryInterval"), NodeValue::kInt, + set_entry_internal(QStringLiteral("AutorecoveryInterval"), NodeValue::k_int, 1); - SetEntryInternal(QStringLiteral("AutorecoveryMaximum"), NodeValue::kInt, + set_entry_internal(QStringLiteral("AutorecoveryMaximum"), NodeValue::k_int, 20); - SetEntryInternal(QStringLiteral("DiskCacheSaveInterval"), NodeValue::kInt, + set_entry_internal(QStringLiteral("DiskCacheSaveInterval"), NodeValue::k_int, 10000); - SetEntryInternal(QStringLiteral("Language"), NodeValue::kText, QString()); - SetEntryInternal(QStringLiteral("ScrollZooms"), NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("EnableSeekToImport"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("Language"), NodeValue::k_text, QString()); + set_entry_internal(QStringLiteral("ScrollZooms"), NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("EnableSeekToImport"), NodeValue::k_boolean, false); - SetEntryInternal(QStringLiteral("EditToolAlsoSeeks"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("EditToolAlsoSeeks"), NodeValue::k_boolean, false); - SetEntryInternal(QStringLiteral("EditToolSelectsLinks"), - NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("EnableDragFilesToTimeline"), - NodeValue::kBoolean, true); - SetEntryInternal(QStringLiteral("InvertTimelineScrollAxes"), - NodeValue::kBoolean, true); - SetEntryInternal(QStringLiteral("SelectAlsoSeeks"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("EditToolSelectsLinks"), + NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("EnableDragFilesToTimeline"), + NodeValue::k_boolean, true); + set_entry_internal(QStringLiteral("InvertTimelineScrollAxes"), + NodeValue::k_boolean, true); + set_entry_internal(QStringLiteral("SelectAlsoSeeks"), NodeValue::k_boolean, false); - SetEntryInternal(QStringLiteral("PasteSeeks"), NodeValue::kBoolean, true); - SetEntryInternal(QStringLiteral("SeekAlsoSelects"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("PasteSeeks"), NodeValue::k_boolean, true); + set_entry_internal(QStringLiteral("SeekAlsoSelects"), NodeValue::k_boolean, false); - SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("SetNameWithMarker"), NodeValue::k_boolean, false); - SetEntryInternal(QStringLiteral("AutoSeekToBeginning"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("AutoSeekToBeginning"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("DropFileOnMediaToReplace"), - NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("AddDefaultEffectsToClips"), - NodeValue::kBoolean, true); - SetEntryInternal(QStringLiteral("AutoscaleByDefault"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("DropFileOnMediaToReplace"), + NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("AddDefaultEffectsToClips"), + NodeValue::k_boolean, true); + set_entry_internal(QStringLiteral("AutoscaleByDefault"), NodeValue::k_boolean, false); - SetEntryInternal(QStringLiteral("Autoscroll"), NodeValue::kInt, - AutoScroll::kPage); - SetEntryInternal(QStringLiteral("AutoSelectDivider"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("Autoscroll"), NodeValue::k_int, + AutoScroll::k_page); + set_entry_internal(QStringLiteral("AutoSelectDivider"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("SetNameWithMarker"), NodeValue::k_boolean, false); - SetEntryInternal(QStringLiteral("RectifiedWaveforms"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("RectifiedWaveforms"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("DropWithoutSequenceBehavior"), - NodeValue::kInt, ImportTool::kDWSAsk); - SetEntryInternal(QStringLiteral("Loop"), NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("SplitClipsCopyNodes"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("DropWithoutSequenceBehavior"), + NodeValue::k_int, ImportTool::k_dws_ask); + set_entry_internal(QStringLiteral("Loop"), NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("SplitClipsCopyNodes"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("UseGradients"), NodeValue::kBoolean, true); - SetEntryInternal(QStringLiteral("AutoMergeTracks"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("UseGradients"), NodeValue::k_boolean, true); + set_entry_internal(QStringLiteral("AutoMergeTracks"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("UseSliderLadders"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("UseSliderLadders"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("ShowWelcomeDialog"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("ShowWelcomeDialog"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("ShowClipWhileDragging"), - NodeValue::kBoolean, true); - SetEntryInternal(QStringLiteral("StopPlaybackOnLastFrame"), - NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("UseLegacyColorInInputTab"), - NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("ReassocLinToNonLin"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("ShowClipWhileDragging"), + NodeValue::k_boolean, true); + set_entry_internal(QStringLiteral("StopPlaybackOnLastFrame"), + NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("UseLegacyColorInInputTab"), + NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("ReassocLinToNonLin"), NodeValue::k_boolean, false); - SetEntryInternal(QStringLiteral("PreviewNonFloatDontAskAgain"), - NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("UseGLFinish"), NodeValue::kBoolean, false); - SetEntryInternal(QStringLiteral("GraphicsBackend"), NodeValue::kText, + set_entry_internal(QStringLiteral("PreviewNonFloatDontAskAgain"), + NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("UseGLFinish"), NodeValue::k_boolean, false); + set_entry_internal(QStringLiteral("GraphicsBackend"), NodeValue::k_text, QStringLiteral("opengl")); - SetEntryInternal(QStringLiteral("TimelineThumbnailMode"), NodeValue::kInt, - Timeline::kThumbnailInOut); - SetEntryInternal(QStringLiteral("TimelineWaveformMode"), NodeValue::kInt, - Timeline::kWaveformsEnabled); + set_entry_internal(QStringLiteral("TimelineThumbnailMode"), NodeValue::k_int, + Timeline::k_thumbnail_in_out); + set_entry_internal(QStringLiteral("TimelineWaveformMode"), NodeValue::k_int, + Timeline::k_waveforms_enabled); - SetEntryInternal( - QStringLiteral("DefaultVideoTransition"), NodeValue::kText, + set_entry_internal( + QStringLiteral("DefaultVideoTransition"), NodeValue::k_text, QStringLiteral("org.olivevideoeditor.Olive.crossdissolve")); - SetEntryInternal( - QStringLiteral("DefaultAudioTransition"), NodeValue::kText, + set_entry_internal( + QStringLiteral("DefaultAudioTransition"), NodeValue::k_text, QStringLiteral("org.olivevideoeditor.Olive.crossdissolve")); - SetEntryInternal(QStringLiteral("DefaultTransitionLength"), - NodeValue::kRational, QVariant::fromValue(rational(1))); + set_entry_internal(QStringLiteral("DefaultTransitionLength"), + NodeValue::k_rational, QVariant::fromValue(Rational(1))); - SetEntryInternal(QStringLiteral("DefaultSubtitleSize"), NodeValue::kInt, + set_entry_internal(QStringLiteral("DefaultSubtitleSize"), NodeValue::k_int, 48); - SetEntryInternal(QStringLiteral("DefaultSubtitleFamily"), NodeValue::kText, + set_entry_internal(QStringLiteral("DefaultSubtitleFamily"), NodeValue::k_text, QString()); - SetEntryInternal(QStringLiteral("DefaultSubtitleWeight"), NodeValue::kInt, + set_entry_internal(QStringLiteral("DefaultSubtitleWeight"), NodeValue::k_int, QFont::Bold); - SetEntryInternal(QStringLiteral("AntialiasSubtitles"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("AntialiasSubtitles"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("AutoCacheDelay"), NodeValue::kInt, 1000); + set_entry_internal(QStringLiteral("AutoCacheDelay"), NodeValue::k_int, 1000); - SetEntryInternal(QStringLiteral("CatColor0"), NodeValue::kInt, - ColorCoding::kRed); - SetEntryInternal(QStringLiteral("CatColor1"), NodeValue::kInt, - ColorCoding::kMaroon); - SetEntryInternal(QStringLiteral("CatColor2"), NodeValue::kInt, - ColorCoding::kOrange); - SetEntryInternal(QStringLiteral("CatColor3"), NodeValue::kInt, - ColorCoding::kBrown); - SetEntryInternal(QStringLiteral("CatColor4"), NodeValue::kInt, - ColorCoding::kYellow); - SetEntryInternal(QStringLiteral("CatColor5"), NodeValue::kInt, - ColorCoding::kOlive); - SetEntryInternal(QStringLiteral("CatColor6"), NodeValue::kInt, - ColorCoding::kLime); - SetEntryInternal(QStringLiteral("CatColor7"), NodeValue::kInt, - ColorCoding::kGreen); - SetEntryInternal(QStringLiteral("CatColor8"), NodeValue::kInt, - ColorCoding::kCyan); - SetEntryInternal(QStringLiteral("CatColor9"), NodeValue::kInt, - ColorCoding::kTeal); - SetEntryInternal(QStringLiteral("CatColor10"), NodeValue::kInt, - ColorCoding::kBlue); - SetEntryInternal(QStringLiteral("CatColor11"), NodeValue::kInt, - ColorCoding::kNavy); + set_entry_internal(QStringLiteral("CatColor0"), NodeValue::k_int, + ColorCoding::k_red); + set_entry_internal(QStringLiteral("CatColor1"), NodeValue::k_int, + ColorCoding::k_maroon); + set_entry_internal(QStringLiteral("CatColor2"), NodeValue::k_int, + ColorCoding::k_orange); + set_entry_internal(QStringLiteral("CatColor3"), NodeValue::k_int, + ColorCoding::k_brown); + set_entry_internal(QStringLiteral("CatColor4"), NodeValue::k_int, + ColorCoding::k_yellow); + set_entry_internal(QStringLiteral("CatColor5"), NodeValue::k_int, + ColorCoding::k_olive); + set_entry_internal(QStringLiteral("CatColor6"), NodeValue::k_int, + ColorCoding::k_lime); + set_entry_internal(QStringLiteral("CatColor7"), NodeValue::k_int, + ColorCoding::k_green); + set_entry_internal(QStringLiteral("CatColor8"), NodeValue::k_int, + ColorCoding::k_cyan); + set_entry_internal(QStringLiteral("CatColor9"), NodeValue::k_int, + ColorCoding::k_teal); + set_entry_internal(QStringLiteral("CatColor10"), NodeValue::k_int, + ColorCoding::k_blue); + set_entry_internal(QStringLiteral("CatColor11"), NodeValue::k_int, + ColorCoding::k_navy); - SetEntryInternal(QStringLiteral("AudioOutput"), NodeValue::kText, + set_entry_internal(QStringLiteral("AudioOutput"), NodeValue::k_text, QString()); - SetEntryInternal(QStringLiteral("AudioInput"), NodeValue::kText, QString()); + set_entry_internal(QStringLiteral("AudioInput"), NodeValue::k_text, QString()); - SetEntryInternal(QStringLiteral("AudioOutputSampleRate"), NodeValue::kInt, + set_entry_internal(QStringLiteral("AudioOutputSampleRate"), NodeValue::k_int, 48000); - SetEntryInternal(QStringLiteral("AudioOutputChannelLayout"), - NodeValue::kInt, - QVariant::fromValue(static_cast(kChannelLayoutStereo))); - SetEntryInternal( - QStringLiteral("AudioOutputSampleFormat"), NodeValue::kText, - QString::fromStdString(SampleFormat(SampleFormat::S16).to_string())); + set_entry_internal(QStringLiteral("AudioOutputChannelLayout"), + NodeValue::k_int, + QVariant::fromValue(static_cast(k_channel_layout_stereo))); + set_entry_internal( + QStringLiteral("AudioOutputSampleFormat"), NodeValue::k_text, + QString::fromStdString(SampleFormat(SampleFormat::s16).to_string())); - SetEntryInternal(QStringLiteral("AudioRecordingFormat"), NodeValue::kInt, - ExportFormat::kFormatWAV); - SetEntryInternal(QStringLiteral("AudioRecordingCodec"), NodeValue::kInt, - ExportCodec::kCodecPCM); - SetEntryInternal(QStringLiteral("AudioRecordingSampleRate"), - NodeValue::kInt, 48000); - SetEntryInternal(QStringLiteral("AudioRecordingChannelLayout"), - NodeValue::kInt, - QVariant::fromValue(static_cast(kChannelLayoutStereo))); - SetEntryInternal( - QStringLiteral("AudioRecordingSampleFormat"), NodeValue::kText, - QString::fromStdString(SampleFormat(SampleFormat::S16).to_string())); - SetEntryInternal(QStringLiteral("AudioRecordingBitRate"), NodeValue::kInt, + set_entry_internal(QStringLiteral("AudioRecordingFormat"), NodeValue::k_int, + ExportFormat::k_format_wav); + set_entry_internal(QStringLiteral("AudioRecordingCodec"), NodeValue::k_int, + ExportCodec::k_codec_pcm); + set_entry_internal(QStringLiteral("AudioRecordingSampleRate"), + NodeValue::k_int, 48000); + set_entry_internal(QStringLiteral("AudioRecordingChannelLayout"), + NodeValue::k_int, + QVariant::fromValue(static_cast(k_channel_layout_stereo))); + set_entry_internal( + QStringLiteral("AudioRecordingSampleFormat"), NodeValue::k_text, + QString::fromStdString(SampleFormat(SampleFormat::s16).to_string())); + set_entry_internal(QStringLiteral("AudioRecordingBitRate"), NodeValue::k_int, 320); - SetEntryInternal(QStringLiteral("DiskCacheBehind"), NodeValue::kRational, - QVariant::fromValue(rational(0))); - SetEntryInternal(QStringLiteral("DiskCacheAhead"), NodeValue::kRational, - QVariant::fromValue(rational(60))); + set_entry_internal(QStringLiteral("DiskCacheBehind"), NodeValue::k_rational, + QVariant::fromValue(Rational(0))); + set_entry_internal(QStringLiteral("DiskCacheAhead"), NodeValue::k_rational, + QVariant::fromValue(Rational(60))); - SetEntryInternal(QStringLiteral("ProxyWidth"), NodeValue::kInt, 1280); - SetEntryInternal(QStringLiteral("ProxyHeight"), NodeValue::kInt, 720); - SetEntryInternal(QStringLiteral("ProxyCRF"), NodeValue::kInt, 23); - SetEntryInternal(QStringLiteral("ProxyPreset"), NodeValue::kText, + set_entry_internal(QStringLiteral("ProxyWidth"), NodeValue::k_int, 1280); + set_entry_internal(QStringLiteral("ProxyHeight"), NodeValue::k_int, 720); + set_entry_internal(QStringLiteral("ProxyCRF"), NodeValue::k_int, 23); + set_entry_internal(QStringLiteral("ProxyPreset"), NodeValue::k_text, QStringLiteral("veryfast")); - SetEntryInternal(QStringLiteral("ProxyIncludeAudio"), NodeValue::kBoolean, + set_entry_internal(QStringLiteral("ProxyIncludeAudio"), NodeValue::k_boolean, true); - SetEntryInternal(QStringLiteral("FFmpegPath"), NodeValue::kText, + set_entry_internal(QStringLiteral("FFmpegPath"), NodeValue::k_text, QString()); - SetEntryInternal(QStringLiteral("LUTLibraryPaths"), NodeValue::kText, + set_entry_internal(QStringLiteral("LUTLibraryPaths"), NodeValue::k_text, QString()); - SetEntryInternal(QStringLiteral("DefaultSequenceWidth"), NodeValue::kInt, + set_entry_internal(QStringLiteral("DefaultSequenceWidth"), NodeValue::k_int, 1920); - SetEntryInternal(QStringLiteral("DefaultSequenceHeight"), NodeValue::kInt, + set_entry_internal(QStringLiteral("DefaultSequenceHeight"), NodeValue::k_int, 1080); - SetEntryInternal(QStringLiteral("DefaultSequencePixelAspect"), - NodeValue::kRational, QVariant::fromValue(rational(1))); - SetEntryInternal(QStringLiteral("DefaultSequenceFrameRate"), - NodeValue::kRational, - QVariant::fromValue(rational(1001, 30000))); - SetEntryInternal(QStringLiteral("DefaultSequenceInterlacing"), - NodeValue::kInt, VideoParams::kInterlaceNone); - SetEntryInternal(QStringLiteral("DefaultSequenceAutoCache2"), - NodeValue::kBoolean, true); - SetEntryInternal(QStringLiteral("DefaultSequenceAudioFrequency"), - NodeValue::kInt, 48000); - SetEntryInternal( - QStringLiteral("DefaultSequenceAudioLayout"), NodeValue::kInt, - QVariant::fromValue(static_cast(kChannelLayoutStereo))); + set_entry_internal(QStringLiteral("DefaultSequencePixelAspect"), + NodeValue::k_rational, QVariant::fromValue(Rational(1))); + set_entry_internal(QStringLiteral("DefaultSequenceFrameRate"), + NodeValue::k_rational, + QVariant::fromValue(Rational(1001, 30000))); + set_entry_internal(QStringLiteral("DefaultSequenceInterlacing"), + NodeValue::k_int, VideoParams::k_interlace_none); + set_entry_internal(QStringLiteral("DefaultSequenceAutoCache2"), + NodeValue::k_boolean, true); + set_entry_internal(QStringLiteral("DefaultSequenceAudioFrequency"), + NodeValue::k_int, 48000); + set_entry_internal( + QStringLiteral("DefaultSequenceAudioLayout"), NodeValue::k_int, + QVariant::fromValue(static_cast(k_channel_layout_stereo))); // Online/offline settings - SetEntryInternal(QStringLiteral("OnlinePixelFormat"), NodeValue::kInt, - PixelFormat::F32); - SetEntryInternal(QStringLiteral("OfflinePixelFormat"), NodeValue::kInt, - PixelFormat::F32); + set_entry_internal(QStringLiteral("OnlinePixelFormat"), NodeValue::k_int, + PixelFormat::f32); + set_entry_internal(QStringLiteral("OfflinePixelFormat"), NodeValue::k_int, + PixelFormat::f32); - SetEntryInternal(QStringLiteral("MarkerColor"), NodeValue::kInt, - ColorCoding::kLime); + set_entry_internal(QStringLiteral("MarkerColor"), NodeValue::k_int, + ColorCoding::k_lime); } -void Config::Load() +void Config::load() { - QFile config_file(GetConfigFilePath()); + QFile config_file(get_config_file_path()); if (!config_file.exists()) { return; @@ -287,15 +287,15 @@ void Config::Load() } // Reset to defaults - current_config_.SetDefaults(); + current_config.set_defaults(); QXmlStreamReader reader(&config_file); QString config_version; - while (XMLReadNextStartElement(&reader)) { + while (xml_read_next_start_element(&reader)) { if (reader.name() == QStringLiteral("Configuration")) { - while (XMLReadNextStartElement(&reader)) { + while (xml_read_next_start_element(&reader)) { QString key = reader.name().toString(); QString value = reader.readElementText(); @@ -309,20 +309,20 @@ void Config::Load() } else if (key == QStringLiteral("DefaultSequenceFrameRate") && !config_version.contains('.')) { // 0.1.x stored this value as a float while we now use rationals, we'll use a heuristic to find the closest - // supported rational + // supported Rational qDebug() << " CONFIG: Finding closest match to" << value; double config_fr = value.toDouble(); - const QVector &supported_frame_rates = - VideoParams::kSupportedFrameRates; + const QVector &supported_frame_rates = + VideoParams::k_supported_frame_rates; - rational match = supported_frame_rates.first(); - double match_diff = qAbs(match.toDouble() - config_fr); + Rational match = supported_frame_rates.first(); + double match_diff = qAbs(match.to_double() - config_fr); for (int i = 1; i < supported_frame_rates.size(); i++) { double diff = qAbs( - supported_frame_rates.at(i).toDouble() - config_fr); + supported_frame_rates.at(i).to_double() - config_fr); if (diff < match_diff) { match = supported_frame_rates.at(i); @@ -331,12 +331,12 @@ void Config::Load() } qDebug() - << " CONFIG: Closest match was" << match.toDouble(); + << " CONFIG: Closest match was" << match.to_double(); - current_config_[key] = QVariant::fromValue(match.flipped()); + current_config[key] = QVariant::fromValue(match.flipped()); } else { - current_config_[key] = NodeValue::StringToValue( - current_config_.GetConfigEntryType(key), value, false); + current_config[key] = NodeValue::string_to_value( + current_config.get_config_entry_type(key), value, false); } } @@ -361,17 +361,17 @@ void Config::Load() "use defaults.\n\n%1") .arg(reader.errorString()), QMessageBox::Ok); - current_config_.SetDefaults(); + current_config.set_defaults(); } config_file.close(); } -void Config::Save() +void Config::save() { - QString real_filename = GetConfigFilePath(); + QString real_filename = get_config_file_path(); QString temp_filename = - FileFunctions::GetSafeTemporaryFilename(real_filename); + FileFunctions::get_safe_temporary_filename(real_filename); QFile config_file(temp_filename); @@ -398,14 +398,14 @@ void Config::Save() writer.writeTextElement( "Version", QCoreApplication::applicationVersion().split('-').first()); - QMapIterator iterator(current_config_.config_map_); + QMapIterator iterator(current_config.config_map_); while (iterator.hasNext()) { iterator.next(); - QString value = NodeValue::ValueToString(iterator.value().type, + QString value = NodeValue::value_to_string(iterator.value().type, iterator.value().data, false); - if (iterator.value().type == NodeValue::kNone) { + if (iterator.value().type == NodeValue::k_none) { qWarning() << "Config key" << iterator.key() << "had null type and was discarded"; } else { @@ -419,7 +419,7 @@ void Config::Save() config_file.close(); - if (!FileFunctions::RenameFileAllowOverwrite(temp_filename, + if (!FileFunctions::rename_file_allow_overwrite(temp_filename, real_filename)) { qWarning() << QStringLiteral( @@ -438,7 +438,7 @@ QVariant &Config::operator[](const QString &key) return config_map_[key].data; } -NodeValue::Type Config::GetConfigEntryType(const QString &key) const +NodeValue::Type Config::get_config_entry_type(const QString &key) const { return config_map_[key].type; } diff --git a/app/config/config.h b/app/config/config.h index f3c8fb0bc..ef17644a3 100644 --- a/app/config/config.h +++ b/app/config/config.h @@ -19,8 +19,8 @@ ***/ -#ifndef CONFIG_H -#define CONFIG_H +#ifndef OAK_CONFIG_H +#define OAK_CONFIG_H #include #include @@ -31,24 +31,24 @@ namespace olive { -#define OLIVE_CONFIG(x) Config::Current()[QStringLiteral(x)] -#define OLIVE_CONFIG_STR(x) Config::Current()[x] +#define OAK_CONFIG(x) Config::current()[QStringLiteral(x)] +#define OAK_CONFIG_STR(x) Config::current()[x] class Config { public: - static Config &Current(); + static Config ¤t(); - void SetDefaults(); + void set_defaults(); - static void Load(); + static void load(); - static void Save(); + static void save(); QVariant operator[](const QString &) const; QVariant &operator[](const QString &); - NodeValue::Type GetConfigEntryType(const QString &key) const; + NodeValue::Type get_config_entry_type(const QString &key) const; private: Config(); @@ -58,16 +58,16 @@ private: QVariant data; }; - void SetEntryInternal(const QString &key, NodeValue::Type type, + void set_entry_internal(const QString &key, NodeValue::Type type, const QVariant &data); QMap config_map_; - static Config current_config_; + static Config current_config; - static QString GetConfigFilePath(); + static QString get_config_file_path(); }; } -#endif // CONFIG_H +#endif // OAK_CONFIG_H diff --git a/app/core.cpp b/app/core.cpp index 702fd0561..461a23219 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -83,7 +83,7 @@ namespace { -QStringList FootageVideoExtensions() +QStringList footage_video_extensions() { return QStringList{ QStringLiteral("mp4"), QStringLiteral("mov"), QStringLiteral("m4v"), @@ -94,7 +94,7 @@ QStringList FootageVideoExtensions() }; } -QStringList FootageAudioExtensions() +QStringList footage_audio_extensions() { return QStringList{ QStringLiteral("wav"), QStringLiteral("mp3"), QStringLiteral("flac"), QStringLiteral("aac"), @@ -104,7 +104,7 @@ QStringList FootageAudioExtensions() QStringLiteral("aifc"), QStringLiteral("wma") }; } -QStringList FootageImageExtensions() +QStringList footage_image_extensions() { return QStringList{ QStringLiteral("png"), QStringLiteral("jpg"), QStringLiteral("jpeg"), QStringLiteral("tif"), @@ -113,7 +113,7 @@ QStringList FootageImageExtensions() QStringLiteral("dpx"), QStringLiteral("webp") }; } -QString BuildFootageFilterGroup(const QString &label, +QString build_footage_filter_group(const QString &label, const QStringList &extensions) { QStringList patterns; @@ -126,20 +126,20 @@ QString BuildFootageFilterGroup(const QString &label, patterns.join(QLatin1Char(' '))); } -QString BuildFootageFileDialogFilter() +QString build_footage_file_dialog_filter() { - QStringList all = FootageVideoExtensions() + FootageAudioExtensions() + - FootageImageExtensions(); + QStringList all = footage_video_extensions() + footage_audio_extensions() + + footage_image_extensions(); all.removeDuplicates(); QStringList groups; - groups << BuildFootageFilterGroup(QObject::tr("Common Media Files"), all); - groups << BuildFootageFilterGroup(QObject::tr("Video Files"), - FootageVideoExtensions()); - groups << BuildFootageFilterGroup(QObject::tr("Audio Files"), - FootageAudioExtensions()); - groups << BuildFootageFilterGroup(QObject::tr("Image Files"), - FootageImageExtensions()); + groups << build_footage_filter_group(QObject::tr("Common Media Files"), all); + groups << build_footage_filter_group(QObject::tr("Video Files"), + footage_video_extensions()); + groups << build_footage_filter_group(QObject::tr("Audio Files"), + footage_audio_extensions()); + groups << build_footage_filter_group(QObject::tr("Image Files"), + footage_image_extensions()); return groups.join(QStringLiteral(";;")); } @@ -154,8 +154,8 @@ Core *Core::instance_ = nullptr; Core::Core(const CoreParams ¶ms) : main_window_(nullptr) , open_project_(nullptr) - , tool_(Tool::kPointer) - , addable_object_(Tool::kAddableEmpty) + , tool_(Tool::k_pointer) + , addable_object_(Tool::k_addable_empty) , snapping_(true) , core_params_(params) , magic_(false) @@ -174,32 +174,32 @@ Core *Core::instance() return instance_; } -QString Core::FootageFileDialogFilter() +QString Core::footage_file_dialog_filter() { - return BuildFootageFileDialogFilter(); + return build_footage_file_dialog_filter(); } -QStringList Core::AllowedFootageExtensions() +QStringList Core::allowed_footage_extensions() { - QStringList all = FootageVideoExtensions() + FootageAudioExtensions() + - FootageImageExtensions(); + QStringList all = footage_video_extensions() + footage_audio_extensions() + + footage_image_extensions(); all.removeDuplicates(); return all; } -bool Core::IsFootageExtensionAllowed(const QString &path) +bool Core::is_footage_extension_allowed(const QString &path) { const QString ext = QFileInfo(path).suffix().toLower(); if (ext.isEmpty()) { return false; } - return AllowedFootageExtensions().contains(ext); + return allowed_footage_extensions().contains(ext); } -void Core::DeclareTypesForQt() +void Core::declare_types_for_qt() { - qRegisterMetaType(); + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); @@ -217,40 +217,40 @@ void Core::DeclareTypesForQt() qRegisterMetaType(); } -void Core::Start() +void Core::start() { // Load application config - Config::Load(); + Config::load(); // Set locale based on either startup arg, config, or auto-detect - SetStartupLocale(); + set_startup_locale(); // Declare custom types for Qt signal/slot system - DeclareTypesForQt(); + declare_types_for_qt(); // Set up node factory/library - NodeFactory::Initialize(); + NodeFactory::initialize(); // Set up color manager's default config - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); // Initialize task manager - TaskManager::CreateInstance(); + TaskManager::create_instance(); // Initialize ConformManager - ConformManager::CreateInstance(); + ConformManager::create_instance(); // Initialize ProxyManager - ProxyManager::CreateInstance(); + ProxyManager::create_instance(); // Initialize RenderManager - RenderManager::CreateInstance(); + RenderManager::create_instance(); // Initialize FrameManager - FrameManager::CreateInstance(); + FrameManager::create_instance(); // Initialize project serializers - ProjectSerializer::Initialize(); + ProjectSerializer::initialize(); // // Start application @@ -259,18 +259,18 @@ void Core::Start() qInfo() << "Using Qt version:" << qVersion(); switch (core_params_.run_mode()) { - case CoreParams::kRunNormal: + case CoreParams::k_run_normal: // Start GUI - StartGUI(core_params_.fullscreen()); + start_gui(core_params_.fullscreen()); // If we have a startup - QMetaObject::invokeMethod(this, "OpenStartupProject", + QMetaObject::invokeMethod(this, "open_startup_project", Qt::QueuedConnection); break; - case CoreParams::kHeadlessExport: + case CoreParams::k_headless_export: qInfo() << "Headless export is not fully implemented yet"; break; - case CoreParams::kHeadlessPreCache: + case CoreParams::k_headless_pre_cache: qInfo() << "Headless pre-cache is not fully implemented yet"; break; } @@ -287,36 +287,36 @@ void Core::Start() } } -void Core::Stop() +void Core::stop() { // Assume all projects have closed gracefully and no auto-recovery is necessary autorecovered_projects_.clear(); - SaveUnrecoveredList(); + save_unrecovered_list(); // Save Config - Config::Save(); + Config::save(); - ProjectSerializer::Destroy(); + ProjectSerializer::destroy(); - ConformManager::DestroyInstance(); + ConformManager::destroy_instance(); - ProxyManager::DestroyInstance(); + ProxyManager::destroy_instance(); - FrameManager::DestroyInstance(); + FrameManager::destroy_instance(); - RenderManager::DestroyInstance(); + RenderManager::destroy_instance(); - MenuShared::DestroyInstance(); + MenuShared::destroy_instance(); - TaskManager::DestroyInstance(); + TaskManager::destroy_instance(); - PanelManager::DestroyInstance(); + PanelManager::destroy_instance(); - AudioManager::DestroyInstance(); + AudioManager::destroy_instance(); - DiskManager::DestroyInstance(); + DiskManager::destroy_instance(); - NodeFactory::Destroy(); + NodeFactory::destroy(); delete main_window_; main_window_ = nullptr; @@ -332,7 +332,7 @@ UndoStack *Core::undo_stack() return &undo_stack_; } -void Core::ImportFiles(const QStringList &urls, Folder *parent) +void Core::import_files(const QStringList &urls, Folder *parent) { if (urls.isEmpty()) { QMessageBox::critical(main_window_, tr("Import error"), @@ -345,7 +345,7 @@ void Core::ImportFiles(const QStringList &urls, Folder *parent) filtered_urls.reserve(urls.size()); for (const QString &url : urls) { - if (IsFootageExtensionAllowed(url)) { + if (is_footage_extension_allowed(url)) { filtered_urls.append(url); } else { rejected_urls.append(url); @@ -366,7 +366,7 @@ void Core::ImportFiles(const QStringList &urls, Folder *parent) ProjectImportTask *pim = new ProjectImportTask(parent, filtered_urls); - if (!pim->GetFileCount()) { + if (!pim->get_file_count()) { // No files to import delete pim; return; @@ -375,8 +375,8 @@ void Core::ImportFiles(const QStringList &urls, Folder *parent) TaskDialog *task_dialog = new TaskDialog(pim, tr("Importing..."), main_window()); - connect(task_dialog, &TaskDialog::TaskSucceeded, this, - &Core::ImportTaskComplete); + connect(task_dialog, &TaskDialog::task_succeeded, this, + &Core::import_task_complete); task_dialog->open(); } @@ -386,41 +386,41 @@ const Tool::Item &Core::tool() const return tool_; } -const Tool::AddableObject &Core::GetSelectedAddableObject() const +const Tool::AddableObject &Core::get_selected_addable_object() const { return addable_object_; } -const QString &Core::GetSelectedTransition() const +const QString &Core::get_selected_transition() const { return selected_transition_; } -void Core::SetSelectedAddableObject(const Tool::AddableObject &obj) +void Core::set_selected_addable_object(const Tool::AddableObject &obj) { addable_object_ = obj; - emit AddableObjectChanged(addable_object_); + emit addable_object_changed(addable_object_); } -void Core::SetSelectedTransitionObject(const QString &obj) +void Core::set_selected_transition_object(const QString &obj) { selected_transition_ = obj; } -void Core::ClearOpenRecentList() +void Core::clear_open_recent_list() { recent_projects_.clear(); - SaveRecentProjectsList(); - emit OpenRecentListChanged(); + save_recent_projects_list(); + emit open_recent_list_changed(); } -void Core::CreateNewProject() +void Core::create_new_project() { // If we already have an empty/new project, switch to it - if (CloseProject(false)) { + if (close_project(false)) { Project *p = new Project(); - p->Initialize(); - AddOpenProject(p); + p->initialize(); + add_open_project(p); } } @@ -429,43 +429,43 @@ const bool &Core::snapping() const return snapping_; } -const QStringList &Core::GetRecentProjects() const +const QStringList &Core::get_recent_projects() const { return recent_projects_; } -void Core::SetTool(const Tool::Item &tool) +void Core::set_tool(const Tool::Item &tool) { tool_ = tool; - emit ToolChanged(tool_); + emit tool_changed(tool_); } -void Core::SetSnapping(const bool &b) +void Core::set_snapping(const bool &b) { snapping_ = b; - emit SnappingChanged(snapping_); + emit snapping_changed(snapping_); } -void Core::DialogAboutShow() +void Core::dialog_about_show() { AboutDialog a(false, main_window_); a.exec(); } -void Core::DialogImportShow() +void Core::dialog_import_show() { // Open dialog for user to select files QStringList files = QFileDialog::getOpenFileNames(main_window_, tr("Import footage..."), - QString(), FootageFileDialogFilter()); + QString(), footage_file_dialog_filter()); // Check if the user actually selected files to import if (!files.isEmpty()) { // Locate the most recently focused Project panel (assume that's the panel the user wants to import into) ProjectPanel *active_project_panel = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); Project *active_project; if (active_project_panel == @@ -478,21 +478,21 @@ void Core::DialogImportShow() } // Get the selected folder in this panel - Folder *folder = active_project_panel->GetSelectedFolder(); + Folder *folder = active_project_panel->get_selected_folder(); - ImportFiles(files, folder); + import_files(files, folder); } } -void Core::DialogPreferencesShow(int start_tab) +void Core::dialog_preferences_show(int start_tab) { PreferencesDialog pd(main_window_, start_tab); pd.exec(); } -void Core::DialogProjectPropertiesShow() +void Core::dialog_project_properties_show() { - Project *proj = GetActiveProject(); + Project *proj = get_active_project(); if (proj) { ProjectPropertiesDialog ppd(proj, main_window_); @@ -505,10 +505,10 @@ void Core::DialogProjectPropertiesShow() } } -void Core::DialogExportShow() +void Core::dialog_export_show() { - if (ViewerOutput *viewer = GetSequenceToExport()) { - OpenExportDialogForViewer(viewer, false); + if (ViewerOutput *viewer = get_sequence_to_export()) { + open_export_dialog_for_viewer(viewer, false); } } @@ -521,11 +521,11 @@ bool Core::DialogImportOTIOShow(const QList &sequences) } #endif -void Core::CreateNewFolder() +void Core::create_new_folder() { // Locate the most recently focused Project panel (assume that's the panel the user wants to import into) ProjectPanel *active_project_panel = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); Project *active_project; if (active_project_panel == nullptr // Check that we found a Project panel @@ -537,13 +537,13 @@ void Core::CreateNewFolder() } // Get the selected folder in this panel - Folder *folder = active_project_panel->GetSelectedFolder(); + Folder *folder = active_project_panel->get_selected_folder(); // Create new folder Folder *new_folder = new Folder(); // Set a default name - new_folder->SetLabel(tr("New Folder")); + new_folder->set_label(tr("New Folder")); // Create an undoable command MultiUndoCommand *command = new MultiUndoCommand(); @@ -554,12 +554,12 @@ void Core::CreateNewFolder() Core::instance()->undo_stack()->push(command, tr("Created New Folder")); // Trigger an automatic rename so users can enter the folder name - active_project_panel->Edit(new_folder); + active_project_panel->edit(new_folder); } -void Core::CreateNewSequence() +void Core::create_new_sequence() { - Project *active_project = GetActiveProject(); + Project *active_project = get_active_project(); if (!active_project) { QMessageBox::critical(main_window_, tr("Failed to create new sequence"), @@ -568,13 +568,13 @@ void Core::CreateNewSequence() } // Create new sequence - Sequence *new_sequence = CreateNewSequenceForProject(active_project); + Sequence *new_sequence = create_new_sequence_for_project(active_project); - SequenceDialog sd(new_sequence, SequenceDialog::kNew, main_window_); + SequenceDialog sd(new_sequence, SequenceDialog::k_new, main_window_); // Make sure SequenceDialog doesn't make an undo command for editing the sequence, since we make an undo command for // adding it later on - sd.SetUndoable(false); + sd.set_undoable(false); if (sd.exec() == QDialog::Accepted) { // Create an undoable command @@ -582,7 +582,7 @@ void Core::CreateNewSequence() command->add_child(new NodeAddCommand(active_project, new_sequence)); command->add_child(new FolderAddChild( - GetSelectedFolderInActiveProject(), new_sequence)); + get_selected_folder_in_active_project(), new_sequence)); command->add_child(new NodeSetPositionCommand( new_sequence, new_sequence, Node::Position())); command->add_child(new OpenSequenceCommand(new_sequence)); @@ -599,7 +599,7 @@ void Core::CreateNewSequence() } } -void Core::AddOpenProject(Project *p, bool add_to_recents) +void Core::add_open_project(Project *p, bool add_to_recents) { // Ensure project is not open at the moment if (open_project_ == p) { @@ -608,68 +608,68 @@ void Core::AddOpenProject(Project *p, bool add_to_recents) // If we currently have an empty project, close it first if (open_project_) { - CloseProject(false); + close_project(false); } - SetActiveProject(p); + set_active_project(p); if (!p->filename().isEmpty() && add_to_recents) { - PushRecentlyOpenedProject(p->filename()); + push_recently_opened_project(p->filename()); } } -bool Core::AddOpenProjectFromTask(Task *task, bool add_to_recents) +bool Core::add_open_project_from_task(Task *task, bool add_to_recents) { ProjectLoadBaseTask *load_task = static_cast(task); - if (!load_task->IsCancelled()) { - Project *project = load_task->GetLoadedProject(); + if (!load_task->is_cancelled()) { + Project *project = load_task->get_loaded_project(); - if (ValidateFootageInLoadedProject(project, project->GetSavedURL())) { - AddOpenProject(project, add_to_recents); - main_window_->LoadLayout(load_task->GetLoadedLayout()); + if (validate_footage_in_loaded_project(project, project->get_saved_url())) { + add_open_project(project, add_to_recents); + main_window_->load_layout(load_task->get_loaded_layout()); return true; } else { delete project; - CreateNewProject(); + create_new_project(); } } return false; } -void Core::SetActiveProject(Project *p) +void Core::set_active_project(Project *p) { if (open_project_) { - disconnect(open_project_, &Project::ModifiedChanged, this, - &Core::ProjectWasModified); + disconnect(open_project_, &Project::modified_changed, this, + &Core::project_was_modified); } open_project_ = p; - RenderManager::instance()->SetProject(p); - main_window_->SetProject(p); + RenderManager::instance()->set_project(p); + main_window_->set_project(p); if (open_project_) { - connect(open_project_, &Project::ModifiedChanged, this, - &Core::ProjectWasModified); + connect(open_project_, &Project::modified_changed, this, + &Core::project_was_modified); } } -void Core::ImportTaskComplete(Task *task) +void Core::import_task_complete(Task *task) { ProjectImportTask *import_task = static_cast(task); - MultiUndoCommand *command = import_task->GetCommand(); + MultiUndoCommand *command = import_task->get_command(); - foreach (Footage *f, import_task->GetImportedFootage()) { + foreach (Footage *f, import_task->get_imported_footage()) { // Look for multi-layer images - if (f->GetAudioStreamCount() == 0 && f->GetVideoStreamCount() > 1) { + if (f->get_audio_stream_count() == 0 && f->get_video_stream_count() > 1) { bool all_stills = true; - for (int i = 0; i < f->GetVideoStreamCount(); i++) { - const VideoParams &vs = f->GetVideoParams(i); - if (!(vs.video_type() == VideoParams::kVideoTypeStill && + for (int i = 0; i < f->get_video_stream_count(); i++) { + const VideoParams &vs = f->get_video_params(i); + if (!(vs.video_type() == VideoParams::k_video_type_still && vs.enabled() == (i == 0))) { all_stills = false; } @@ -694,10 +694,10 @@ void Core::ImportTaskComplete(Task *task) d.exec(); if (d.clickedButton() == multi_btn) { - for (int i = 0; i < f->GetVideoStreamCount(); i++) { - VideoParams vs = f->GetVideoParams(i); + for (int i = 0; i < f->get_video_stream_count(); i++) { + VideoParams vs = f->get_video_params(i); vs.set_enabled(!vs.enabled()); - f->SetVideoParams(vs, i); + f->set_video_params(vs, i); } } else if (d.clickedButton() == single_btn) { // Do nothing, footage will already be set up this way @@ -710,20 +710,20 @@ void Core::ImportTaskComplete(Task *task) } } - if (import_task->HasInvalidFiles()) { - ProjectImportErrorDialog d(import_task->GetInvalidFiles(), + if (import_task->has_invalid_files()) { + ProjectImportErrorDialog d(import_task->get_invalid_files(), main_window_); d.exec(); } undo_stack_.push( command, - tr("Imported %1 File(s)").arg(import_task->GetImportedFootage().size())); + tr("Imported %1 File(s)").arg(import_task->get_imported_footage().size())); - main_window_->SelectFootage(import_task->GetImportedFootage()); + main_window_->select_footage(import_task->get_imported_footage()); } -bool Core::ConfirmImageSequence(const QString &filename) +bool Core::confirm_image_sequence(const QString &filename) { QMessageBox mb(main_window_); @@ -739,12 +739,12 @@ bool Core::ConfirmImageSequence(const QString &filename) return (mb.exec() == QMessageBox::Yes); } -void Core::ProjectWasModified(bool e) +void Core::project_was_modified(bool e) { main_window_->setWindowModified(e); } -bool Core::StartHeadlessExport() +bool Core::start_headless_export() { const QString &startup_project = core_params_.startup_project(); @@ -831,7 +831,7 @@ bool Core::StartHeadlessExport() return false; } -void Core::OpenStartupProject() +void Core::open_startup_project() { const QString &startup_project = core_params_.startup_project(); bool startup_project_exists = !startup_project.isEmpty() && @@ -848,27 +848,27 @@ void Core::OpenStartupProject() if (startup_project_exists) { // If a startup project was set and exists, open it now - OpenProjectInternal(startup_project); + open_project_internal(startup_project); } else { // If no load project is set, create a new one on open - CreateNewProject(); + create_new_project(); } } -void Core::AddRecoveryProjectFromTask(Task *task) +void Core::add_recovery_project_from_task(Task *task) { - if (AddOpenProjectFromTask(task, false)) { + if (add_open_project_from_task(task, false)) { ProjectLoadBaseTask *load_task = static_cast(task); - Project *project = load_task->GetLoadedProject(); + Project *project = load_task->get_loaded_project(); // Clearing the filename will force the user to re-save it somewhere else project->set_filename(QString()); // Forcing a UUID regeneration will prevent it from saving auto-recoveries in the same place // the original project did - project->RegenerateUuid(); + project->regenerate_uuid(); // Setting modified will ensure that the program doesn't close and lose the project without // prompting the user first @@ -876,26 +876,26 @@ void Core::AddRecoveryProjectFromTask(Task *task) } } -void Core::StartGUI(bool full_screen) +void Core::start_gui(bool full_screen) { // Set UI style - StyleManager::Init(); + StyleManager::init(); // Set up shared menus - MenuShared::CreateInstance(); + MenuShared::create_instance(); // Since we're starting GUI mode, create a PanelFocusManager (auto-deletes with QObject) - PanelManager::CreateInstance(); + PanelManager::create_instance(); // Initialize audio service - AudioManager::CreateInstance(); + AudioManager::create_instance(); // Initialize disk service - DiskManager::CreateInstance(); + DiskManager::create_instance(); // Connect the PanelFocusManager to the application's focus change signal connect(qApp, &QApplication::focusChanged, PanelManager::instance(), - &PanelManager::FocusChanged); + &PanelManager::focus_changed); KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtWidgets); // Set KDDockWidgets flags @@ -927,14 +927,14 @@ void Core::StartGUI(bool full_screen) #endif // Start autorecovery timer using the config value as its interval - SetAutorecoveryInterval(OLIVE_CONFIG("AutorecoveryInterval").toInt()); + set_autorecovery_interval(OAK_CONFIG("AutorecoveryInterval").toInt()); connect(&autorecovery_timer_, &QTimer::timeout, this, - &Core::SaveAutorecovery); + &Core::save_autorecovery); autorecovery_timer_.start(); // Load recently opened projects list { - QFile recent_projects_file(GetRecentProjectsFilePath()); + QFile recent_projects_file(get_recent_projects_file_path()); if (recent_projects_file.open(QFile::ReadOnly | QFile::Text)) { QString r = QString::fromUtf8(recent_projects_file.readAll()); if (!r.isEmpty()) { @@ -943,11 +943,11 @@ void Core::StartGUI(bool full_screen) recent_projects_file.close(); } - emit OpenRecentListChanged(); + emit open_recent_list_changed(); } } -void Core::SaveProjectInternal(const QString &override_filename) +void Core::save_project_internal(const QString &override_filename) { // Create save manager Task *psm; @@ -967,12 +967,12 @@ void Core::SaveProjectInternal(const QString &override_filename) bool use_compression = !open_project_->filename().endsWith( QStringLiteral(".ovexml"), Qt::CaseInsensitive); psm = new ProjectSaveTask(open_project_, use_compression); - static_cast(psm)->SetLayout( - main_window_->SaveLayout()); + static_cast(psm)->set_layout( + main_window_->save_layout()); if (!override_filename.isEmpty()) { // Set override filename if provided - static_cast(psm)->SetOverrideFilename( + static_cast(psm)->set_override_filename( override_filename); } } @@ -986,36 +986,36 @@ void Core::SaveProjectInternal(const QString &override_filename) // Ideally we could do this in a background thread and show progress in the status bar like // Microsoft Word, but that would be far more complex. If it becomes necessary in the future, // we will look into an approach like that. - if (psm->Start()) { + if (psm->start()) { if (override_filename.isEmpty()) { - ProjectSaveSucceeded(psm); + project_save_succeeded(psm); } } psm->deleteLater(); } -ViewerOutput *Core::GetSequenceToExport() +ViewerOutput *Core::get_sequence_to_export() { // First try the most recently focused time based window TimeBasedPanel *time_panel = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); // If that fails try defaulting to the first timeline (i.e. if a project has just been loaded). - if (!time_panel->GetConnectedViewer()) { + if (!time_panel->get_connected_viewer()) { // Safe to assume there will always be one timeline. time_panel = - PanelManager::instance()->GetPanelsOfType().first(); + PanelManager::instance()->get_panels_of_type().first(); } - if (time_panel && time_panel->GetConnectedViewer()) { - if (time_panel->GetConnectedViewer()->GetLength() == 0) { + if (time_panel && time_panel->get_connected_viewer()) { + if (time_panel->get_connected_viewer()->get_length() == 0) { QMessageBox::critical( main_window_, tr("Error"), tr("This Sequence is empty. There is nothing to export."), QMessageBox::Ok); } else { - return time_panel->GetConnectedViewer(); + return time_panel->get_connected_viewer(); } } else { QMessageBox::critical( @@ -1027,16 +1027,16 @@ ViewerOutput *Core::GetSequenceToExport() return nullptr; } -QString Core::GetAutoRecoveryIndexFilename() +QString Core::get_auto_recovery_index_filename() { return QDir(QStandardPaths::writableLocation( QStandardPaths::AppLocalDataLocation)) .filePath(QStringLiteral("unrecovered")); } -void Core::SaveUnrecoveredList() +void Core::save_unrecovered_list() { - QFile autorecovery_index(GetAutoRecoveryIndexFilename()); + QFile autorecovery_index(get_auto_recovery_index_filename()); if (autorecovered_projects_.isEmpty()) { // Recovery list is empty, delete file if exists @@ -1063,7 +1063,7 @@ void Core::SaveUnrecoveredList() } } -bool Core::RevertProjectInternal(bool by_opening_existing) +bool Core::revert_project_internal(bool by_opening_existing) { if (open_project_->filename().isEmpty()) { QMessageBox::critical( @@ -1091,12 +1091,12 @@ bool Core::RevertProjectInternal(bool by_opening_existing) QString filename = open_project_->filename(); // Close project without prompting to save it - CloseProject(false, true); + close_project(false, true); // NOTE: `open_project_` will be deleted now, so don't try accessing it // Re-open project at the filename - OpenProjectInternal(filename); + open_project_internal(filename); return true; } @@ -1105,37 +1105,37 @@ bool Core::RevertProjectInternal(bool by_opening_existing) return false; } -void Core::SaveRecentProjectsList() +void Core::save_recent_projects_list() { // Save recently opened projects - QFile recent_projects_file(GetRecentProjectsFilePath()); + QFile recent_projects_file(get_recent_projects_file_path()); if (recent_projects_file.open(QFile::WriteOnly | QFile::Text)) { recent_projects_file.write(recent_projects_.join('\n').toUtf8()); recent_projects_file.close(); } } -void Core::SaveAutorecovery() +void Core::save_autorecovery() { - if (OLIVE_CONFIG("AutorecoveryEnabled").toBool()) { + if (OAK_CONFIG("AutorecoveryEnabled").toBool()) { if (open_project_ && !open_project_->has_autorecovery_been_saved()) { QDir project_autorecovery_dir( - QDir(FileFunctions::GetAutoRecoveryRoot()) - .filePath(open_project_->GetUuid().toString())); - if (FileFunctions::DirectoryIsValid(project_autorecovery_dir)) { + QDir(FileFunctions::get_auto_recovery_root()) + .filePath(open_project_->get_uuid().toString())); + if (FileFunctions::directory_is_valid(project_autorecovery_dir)) { QString this_autorecovery_path = project_autorecovery_dir.filePath( QStringLiteral("%1.ove").arg(QString::number( QDateTime::currentSecsSinceEpoch()))); - SaveProjectInternal(this_autorecovery_path); + save_project_internal(this_autorecovery_path); open_project_->set_autorecovery_saved(true); // Keep track of projects that where the "newest" save is the recovery project if (!autorecovered_projects_.contains( - open_project_->GetUuid())) { - autorecovered_projects_.append(open_project_->GetUuid()); + open_project_->get_uuid())) { + autorecovered_projects_.append(open_project_->get_uuid()); } qDebug() << "Saved auto-recovery to:" << this_autorecovery_path; @@ -1151,7 +1151,7 @@ void Core::SaveAutorecovery() } int64_t max_recoveries_per_file = - OLIVE_CONFIG("AutorecoveryMaximum").toLongLong(); + OAK_CONFIG("AutorecoveryMaximum").toLongLong(); // Since we write an extra file, increment total allowed files by 1 max_recoveries_per_file++; @@ -1193,73 +1193,73 @@ void Core::SaveAutorecovery() } // Save index - SaveUnrecoveredList(); + save_unrecovered_list(); } } -void Core::ProjectSaveSucceeded(Task *task) +void Core::project_save_succeeded(Task *task) { - Project *p = static_cast(task)->GetProject(); + Project *p = static_cast(task)->get_project(); - PushRecentlyOpenedProject(p->filename()); + push_recently_opened_project(p->filename()); p->set_modified(false); - autorecovered_projects_.removeOne(p->GetUuid()); - SaveUnrecoveredList(); + autorecovered_projects_.removeOne(p->get_uuid()); + save_unrecovered_list(); - ShowStatusBarMessage(tr("Saved to \"%1\" successfully").arg(p->filename())); + show_status_bar_message(tr("Saved to \"%1\" successfully").arg(p->filename())); } -Project *Core::GetActiveProject() const +Project *Core::get_active_project() const { return open_project_; } -Folder *Core::GetSelectedFolderInActiveProject() const +Folder *Core::get_selected_folder_in_active_project() const { ProjectPanel *active_project_panel = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); if (active_project_panel) { - return active_project_panel->GetSelectedFolder(); + return active_project_panel->get_selected_folder(); } else { return nullptr; } } -Timecode::Display Core::GetTimecodeDisplay() const +Timecode::Display Core::get_timecode_display() const { return static_cast( - OLIVE_CONFIG("TimecodeDisplay").toInt()); + OAK_CONFIG("TimecodeDisplay").toInt()); } -void Core::SetTimecodeDisplay(Timecode::Display d) +void Core::set_timecode_display(Timecode::Display d) { - OLIVE_CONFIG("TimecodeDisplay") = d; + OAK_CONFIG("TimecodeDisplay") = d; - emit TimecodeDisplayChanged(d); + emit timecode_display_changed(d); } -void Core::SetAutorecoveryInterval(int minutes) +void Core::set_autorecovery_interval(int minutes) { // Convert minutes to milliseconds autorecovery_timer_.setInterval(minutes * 60000); } -void Core::CopyStringToClipboard(const QString &s) +void Core::copy_string_to_clipboard(const QString &s) { QGuiApplication::clipboard()->setText(s); } -QString Core::PasteStringFromClipboard() +QString Core::paste_string_from_clipboard() { return QGuiApplication::clipboard()->text(); } -QString Core::GetProjectFilter(bool include_any_filter) +QString Core::get_project_filter(bool include_any_filter) { - static const QVector> FILTERS = { + static const QVector> filters = { // Standard compressed Oak project { tr("Oak Project"), QStringLiteral("ove") }, @@ -1272,32 +1272,32 @@ QString Core::GetProjectFilter(bool include_any_filter) #endif }; - QStringList filters; - filters.reserve(FILTERS.size() + 1); + QStringList filter_strings; + filter_strings.reserve(filters.size() + 1); if (include_any_filter) { QStringList combined; - for (auto it = FILTERS.cbegin(); it != FILTERS.cend(); it++) { + for (auto it = filters.cbegin(); it != filters.cend(); it++) { combined.append(QStringLiteral("*.%1").arg(it->second)); } - filters.append(QStringLiteral("%1 (%2)").arg( + filter_strings.append(QStringLiteral("%1 (%2)").arg( tr("All Supported Projects"), combined.join(' '))); } - for (auto it = FILTERS.cbegin(); it != FILTERS.cend(); it++) { - filters.append(QStringLiteral("%1 (*.%2)").arg(it->first, it->second)); + for (auto it = filters.cbegin(); it != filters.cend(); it++) { + filter_strings.append(QStringLiteral("%1 (*.%2)").arg(it->first, it->second)); } - return filters.join(QStringLiteral(";;")); + return filter_strings.join(QStringLiteral(";;")); } -QString Core::GetRecentProjectsFilePath() +QString Core::get_recent_projects_file_path() { - return QDir(FileFunctions::GetConfigurationLocation()) + return QDir(FileFunctions::get_configuration_location()) .filePath(QStringLiteral("recent")); } -void Core::SetStartupLocale() +void Core::set_startup_locale() { // Set language if (!core_params_.startup_language().isEmpty()) { @@ -1310,31 +1310,31 @@ void Core::SetStartupLocale() } } - QString use_locale = OLIVE_CONFIG("Language").toString(); + QString use_locale = OAK_CONFIG("Language").toString(); if (use_locale.isEmpty()) { // No configured locale, auto-detect the system's locale use_locale = QLocale::system().name(); } - if (!SetLanguage(use_locale)) { + if (!set_language(use_locale)) { qWarning() << "Trying to use locale" << use_locale << "but couldn't find a translation for it"; } } -bool Core::SaveProject() +bool Core::save_project() { if (open_project_->filename().isEmpty()) { - return SaveProjectAs(); + return save_project_as(); } else { - SaveProjectInternal(); + save_project_internal(); return true; } } -void Core::ShowStatusBarMessage(const QString &s, int timeout) +void Core::show_status_bar_message(const QString &s, int timeout) { // The main window only exists after StartGUI(); in tests and other // contexts that construct Core without a window, do nothing. @@ -1343,35 +1343,35 @@ void Core::ShowStatusBarMessage(const QString &s, int timeout) } } -void Core::ClearStatusBarMessage() +void Core::clear_status_bar_message() { main_window_->statusBar()->clearMessage(); } -void Core::OpenRecoveryProject(const QString &filename) +void Core::open_recovery_project(const QString &filename) { - OpenProjectInternal(filename, true); + open_project_internal(filename, true); } -void Core::OpenNodeInViewer(ViewerOutput *viewer) +void Core::open_node_in_viewer(ViewerOutput *viewer) { - main_window_->OpenNodeInViewer(viewer); + main_window_->open_node_in_viewer(viewer); } -void Core::OpenExportDialogForViewer(ViewerOutput *viewer, +void Core::open_export_dialog_for_viewer(ViewerOutput *viewer, bool start_still_image) { ExportDialog *ed = new ExportDialog(viewer, start_still_image, main_window_); connect(ed, &ExportDialog::finished, ed, &ExportDialog::deleteLater); ed->open(); - connect(ed, &ExportDialog::RequestImportFile, this, - &Core::ImportSingleFile); + connect(ed, &ExportDialog::request_import_file, this, + &Core::import_single_file); } -void Core::CheckForAutoRecoveries() +void Core::check_for_auto_recoveries() { - QFile autorecovery_index(GetAutoRecoveryIndexFilename()); + QFile autorecovery_index(get_auto_recovery_index_filename()); if (autorecovery_index.exists()) { // Uh-oh, we have auto-recoveries to prompt if (autorecovery_index.open(QFile::ReadOnly)) { @@ -1387,35 +1387,35 @@ void Core::CheckForAutoRecoveries() autorecovery_index.close(); // Delete recovery index since we don't need it anymore - QFile::remove(GetAutoRecoveryIndexFilename()); + QFile::remove(get_auto_recovery_index_filename()); } else { QMessageBox::critical( main_window_, tr("Auto-Recovery Error"), tr("Found auto-recoveries but failed to load the auto-recovery index. " "Auto-recover projects will have to be opened manually.\n\n" "Your recoverable projects are still available at: %1") - .arg(FileFunctions::GetAutoRecoveryRoot())); + .arg(FileFunctions::get_auto_recovery_root())); } } } -void Core::BrowseAutoRecoveries() +void Core::browse_auto_recoveries() { // List all auto-recovery entries AutoRecoveryDialog ard( tr("The following project versions have been auto-saved:"), - QDir(FileFunctions::GetAutoRecoveryRoot()) + QDir(FileFunctions::get_auto_recovery_root()) .entryList(QDir::Dirs | QDir::NoDotAndDotDot), false, main_window_); ard.exec(); } -void Core::RequestPixelSamplingInViewers(bool e) +void Core::request_pixel_sampling_in_viewers(bool e) { if (e) { if (pixel_sampling_users_ == 0) { // Signal to start pixel sampling - emit ColorPickerEnabled(true); + emit color_picker_enabled(true); } pixel_sampling_users_++; @@ -1424,12 +1424,12 @@ void Core::RequestPixelSamplingInViewers(bool e) if (pixel_sampling_users_ == 0) { // Signal to end pixel sampling - emit ColorPickerEnabled(false); + emit color_picker_enabled(false); } } } -void Core::WarnCacheFull() +void Core::warn_cache_full() { if (!shown_cache_full_warning_ && main_window_) { shown_cache_full_warning_ = true; @@ -1446,12 +1446,12 @@ void Core::WarnCacheFull() } } -bool Core::SaveProjectAs() +bool Core::save_project_as() { QFileDialog fd(main_window_, tr("Save Project As")); fd.setAcceptMode(QFileDialog::AcceptSave); - fd.setNameFilter(GetProjectFilter(false)); + fd.setNameFilter(get_project_filter(false)); if (fd.exec() == QDialog::Accepted) { QString fn = fd.selectedFiles().first(); @@ -1462,11 +1462,11 @@ bool Core::SaveProjectAs() QString extension = name_filter.mid(ext_index, name_filter.size() - ext_index - 1); - fn = FileFunctions::EnsureFilenameExtension(fn, extension); + fn = FileFunctions::ensure_filename_extension(fn, extension); open_project_->set_filename(fn); - SaveProjectInternal(); + save_project_internal(); return true; } @@ -1474,12 +1474,12 @@ bool Core::SaveProjectAs() return false; } -void Core::RevertProject() +void Core::revert_project() { - RevertProjectInternal(false); + revert_project_internal(false); } -void Core::PushRecentlyOpenedProject(const QString &s) +void Core::push_recently_opened_project(const QString &s) { if (s.isEmpty()) { return; @@ -1492,29 +1492,29 @@ void Core::PushRecentlyOpenedProject(const QString &s) } else { recent_projects_.prepend(s); - const int kMaximumRecentProjects = 10; - while (recent_projects_.size() > kMaximumRecentProjects) { + const int k_maximum_recent_projects = 10; + while (recent_projects_.size() > k_maximum_recent_projects) { recent_projects_.removeLast(); } } - SaveRecentProjectsList(); + save_recent_projects_list(); - emit OpenRecentListChanged(); + emit open_recent_list_changed(); } -void Core::OpenProjectInternal(const QString &filename, bool recovery_project) +void Core::open_project_internal(const QString &filename, bool recovery_project) { if (open_project_) { // Comparing QFileInfos will handle case insensitivity and both slash directions on platforms // where this is necessary (not naming any names *cough* Windows) if (QFileInfo(open_project_->filename()) == QFileInfo(filename)) { // This project is already open - bool reverted = RevertProjectInternal(true); + bool reverted = revert_project_internal(true); if (!reverted) { // Calling this will focus attention to the project that the user just tried to re-open - AddOpenProject(open_project_); + add_open_project(open_project_); } // Don't do anything else @@ -1544,24 +1544,24 @@ void Core::OpenProjectInternal(const QString &filename, bool recovery_project) new TaskDialog(load_task, tr("Load Project"), main_window()); if (recovery_project) { - connect(task_dialog, &TaskDialog::TaskSucceeded, this, - &Core::AddRecoveryProjectFromTask); + connect(task_dialog, &TaskDialog::task_succeeded, this, + &Core::add_recovery_project_from_task); } else { - connect(task_dialog, &TaskDialog::TaskSucceeded, this, - &Core::AddOpenProjectFromTaskAndAddToRecents); + connect(task_dialog, &TaskDialog::task_succeeded, this, + &Core::add_open_project_from_task_and_add_to_recents); } task_dialog->open(); } -void Core::ImportSingleFile(const QString &f) +void Core::import_single_file(const QString &f) { - if (Project *p = GetActiveProject()) { - ImportFiles({ f }, p->root()); + if (Project *p = get_active_project()) { + import_files({ f }, p->root()); } } -int Core::CountFilesInFileList(const QFileInfoList &filenames) +int Core::count_files_in_file_list(const QFileInfoList &filenames) { int file_count = 0; @@ -1573,7 +1573,7 @@ int Core::CountFilesInFileList(const QFileInfoList &filenames) QFileInfoList info_list = QDir(f.absoluteFilePath()).entryInfoList(); - file_count += CountFilesInFileList(info_list); + file_count += count_files_in_file_list(info_list); } else { file_count++; } @@ -1582,7 +1582,7 @@ int Core::CountFilesInFileList(const QFileInfoList &filenames) return file_count; } -bool Core::LabelNodes(const QVector &nodes, MultiUndoCommand *parent) +bool Core::label_nodes(const QVector &nodes, MultiUndoCommand *parent) { if (nodes.isEmpty()) { return false; @@ -1590,10 +1590,10 @@ bool Core::LabelNodes(const QVector &nodes, MultiUndoCommand *parent) bool ok; - QString start_label = nodes.first()->GetLabel(); + QString start_label = nodes.first()->get_label(); for (int i = 1; i < nodes.size(); i++) { - if (nodes.at(i)->GetLabel() != start_label) { + if (nodes.at(i)->get_label() != start_label) { // Not all the nodes share the same name, so we'll start with a blank one start_label.clear(); break; @@ -1608,7 +1608,7 @@ bool Core::LabelNodes(const QVector &nodes, MultiUndoCommand *parent) NodeRenameCommand *rename_command = new NodeRenameCommand(); foreach (Node *n, nodes) { - rename_command->AddNode(n, s); + rename_command->add_node(n, s); } if (parent) { @@ -1624,7 +1624,7 @@ bool Core::LabelNodes(const QVector &nodes, MultiUndoCommand *parent) return false; } -Sequence *Core::CreateNewSequenceForProject(const QString &format, +Sequence *Core::create_new_sequence_for_project(const QString &format, Project *project) { Sequence *new_sequence = new Sequence(); @@ -1635,18 +1635,18 @@ Sequence *Core::CreateNewSequenceForProject(const QString &format, do { sequence_name = format.arg(sequence_number); sequence_number++; - } while (project->root()->ChildExistsWithName(sequence_name)); - new_sequence->SetLabel(sequence_name); + } while (project->root()->child_exists_with_name(sequence_name)); + new_sequence->set_label(sequence_name); return new_sequence; } -void Core::OpenProjectFromRecentList(int index) +void Core::open_project_from_recent_list(int index) { const QString &open_fn = recent_projects_.at(index); if (QFileInfo::exists(open_fn)) { - OpenProjectInternal(open_fn); + open_project_internal(open_fn); } else if ( QMessageBox::information( main_window(), tr("Cannot open recent project"), @@ -1655,13 +1655,13 @@ void Core::OpenProjectFromRecentList(int index) QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { recent_projects_.removeAt(index); - SaveRecentProjectsList(); + save_recent_projects_list(); - emit OpenRecentListChanged(); + emit open_recent_list_changed(); } } -bool Core::CloseProject(bool auto_open_new, bool ignore_modified) +bool Core::close_project(bool auto_open_new, bool ignore_modified) { if (open_project_) { if (open_project_->is_modified() && !ignore_modified) { @@ -1688,7 +1688,7 @@ bool Core::CloseProject(bool auto_open_new, bool ignore_modified) return false; } - if (mb.clickedButton() == yes_btn && !SaveProject()) { + if (mb.clickedButton() == yes_btn && !save_project()) { // The save failed, stop closing projects return false; } @@ -1698,34 +1698,34 @@ bool Core::CloseProject(bool auto_open_new, bool ignore_modified) undo_stack_.clear(); Project *tmp = open_project_; - SetActiveProject(nullptr); + set_active_project(nullptr); delete tmp; } // Ensure a project is always active if (auto_open_new) { - CreateNewProject(); + create_new_project(); } return true; } -void Core::CacheActiveSequence(bool in_out_only) +void Core::cache_active_sequence(bool in_out_only) { TimeBasedPanel *p = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); - if (p && p->GetConnectedViewer()) { + if (p && p->get_connected_viewer()) { // Hacky but works for now // Find Viewer attached to this TimeBasedPanel QList all_viewers = - PanelManager::instance()->GetPanelsOfType(); + PanelManager::instance()->get_panels_of_type(); ViewerPanel *found_panel = nullptr; foreach (ViewerPanel *viewer, all_viewers) { - if (viewer->GetConnectedViewer() == p->GetConnectedViewer()) { + if (viewer->get_connected_viewer() == p->get_connected_viewer()) { found_panel = viewer; break; } @@ -1733,9 +1733,9 @@ void Core::CacheActiveSequence(bool in_out_only) if (found_panel) { if (in_out_only) { - found_panel->CacheSequenceInOut(); + found_panel->cache_sequence_in_out(); } else { - found_panel->CacheEntireSequence(); + found_panel->cache_entire_sequence(); } } else { QMessageBox::critical( @@ -1746,7 +1746,7 @@ void Core::CacheActiveSequence(bool in_out_only) } } -QString StripWindowsDriveLetter(QString s) +QString strip_windows_drive_letter(QString s) { // HACK: On Windows, absolute paths are saved with a drive letter (e.g. "C:\video.mp4"). Below, // we use Qt's relative path system to resolve when an entire project may be in a different @@ -1768,15 +1768,15 @@ QString StripWindowsDriveLetter(QString s) return s; } -bool Core::ValidateFootageInLoadedProject(Project *project, +bool Core::validate_footage_in_loaded_project(Project *project, const QString &project_saved_url) { QVector footage_we_couldnt_validate; for (Node *n : project->nodes()) { if (Footage *footage = dynamic_cast(n)) { - QString footage_fn = StripWindowsDriveLetter(footage->filename()); - QString project_fn = StripWindowsDriveLetter(project_saved_url); + QString footage_fn = strip_windows_drive_letter(footage->filename()); + QString project_fn = strip_windows_drive_letter(project_saved_url); if (!QFileInfo::exists(footage_fn) && !project_saved_url.isEmpty()) { @@ -1804,7 +1804,7 @@ bool Core::ValidateFootageInLoadedProject(Project *project, if (QFileInfo::exists(footage->filename())) { // Assume valid - footage->SetValid(); + footage->set_valid(); } else { footage_we_couldnt_validate.append(footage); } @@ -1821,7 +1821,7 @@ bool Core::ValidateFootageInLoadedProject(Project *project, return true; } -bool Core::SetLanguage(const QString &locale) +bool Core::set_language(const QString &locale) { QApplication::removeTranslator(translator_); @@ -1834,18 +1834,18 @@ bool Core::SetLanguage(const QString &locale) return false; } -void Core::OpenProject() +void Core::open_project() { QString file = QFileDialog::getOpenFileName( - main_window_, tr("Open Project"), QString(), GetProjectFilter(true)); + main_window_, tr("Open Project"), QString(), get_project_filter(true)); if (!file.isEmpty()) { - OpenProjectInternal(file); + open_project_internal(file); } } Core::CoreParams::CoreParams() - : mode_(kRunNormal) + : mode_(k_run_normal) , run_fullscreen_(false) , crash_(false) { diff --git a/app/core.h b/app/core.h index c0021e1a6..807a33b83 100644 --- a/app/core.h +++ b/app/core.h @@ -19,8 +19,8 @@ ***/ -#ifndef CORE_H -#define CORE_H +#ifndef OAK_CORE_H +#define OAK_CORE_H #include #include @@ -42,7 +42,7 @@ namespace olive class MainWindow; /** - * @brief The main central Olive application instance + * @brief The main central Olive application instance_ * * This runs both in GUI and CLI modes (and handles what to init based on that). * It also contains various global functions/variables for use throughout Olive. @@ -57,7 +57,7 @@ public: public: CoreParams(); - enum RunMode { kRunNormal, kHeadlessExport, kHeadlessPreCache }; + enum RunMode { k_run_normal, k_headless_export, k_headless_pre_cache }; bool fullscreen() const { @@ -135,9 +135,9 @@ public: */ static Core *instance(); - static QString FootageFileDialogFilter(); - static QStringList AllowedFootageExtensions(); - static bool IsFootageExtensionAllowed(const QString &path); + static QString footage_file_dialog_filter(); + static QStringList allowed_footage_extensions(); + static bool is_footage_extension_allowed(const QString &path); const CoreParams &core_params() const { @@ -149,17 +149,17 @@ public: * * Main application launcher. Parses command line arguments and constructs main window (if entering a GUI mode). */ - void Start(); + void start(); /** * @brief Stop Olive Core * * Ends all threads and frees all memory ready for the application to exit. */ - void Stop(); + void stop(); /** - * @brief Retrieve main window instance + * @brief Retrieve main window instance_ * * @return * @@ -180,7 +180,7 @@ public: * * @param urls */ - void ImportFiles(const QStringList &urls, Folder *parent); + void import_files(const QStringList &urls, Folder *parent); /** * @brief Get the currently active tool @@ -190,12 +190,12 @@ public: /** * @brief Get the currently selected object that the add tool should make (if the add tool is active) */ - const Tool::AddableObject &GetSelectedAddableObject() const; + const Tool::AddableObject &get_selected_addable_object() const; /** * @brief Get the currently selected node that the transition tool should make (if the transition tool is active) */ - const QString &GetSelectedTransition() const; + const QString &get_selected_transition() const; /** * @brief Get current snapping value @@ -205,7 +205,7 @@ public: /** * @brief Returns a list of the most recently opened/saved projects */ - const QStringList &GetRecentProjects() const; + const QStringList &get_recent_projects() const; /** * @brief Get the currently active project @@ -217,92 +217,92 @@ public: * * The active Project file, or nullptr if the heuristic couldn't find one. */ - Project *GetActiveProject() const; - Folder *GetSelectedFolderInActiveProject() const; + Project *get_active_project() const; + Folder *get_selected_folder_in_active_project() const; /** * @brief Gets current timecode display mode */ - Timecode::Display GetTimecodeDisplay() const; + Timecode::Display get_timecode_display() const; /** * @brief Sets current timecode display mode */ - void SetTimecodeDisplay(Timecode::Display d); + void set_timecode_display(Timecode::Display d); /** * @brief Set how frequently an autorecovery should be saved (if the project has changed, see SetProjectModified()) */ - void SetAutorecoveryInterval(int minutes); + void set_autorecovery_interval(int minutes); - static void CopyStringToClipboard(const QString &s); + static void copy_string_to_clipboard(const QString &s); - static QString PasteStringFromClipboard(); + static QString paste_string_from_clipboard(); /** * @brief Recursively count files in a file/directory list */ - static int CountFilesInFileList(const QFileInfoList &filenames); + static int count_files_in_file_list(const QFileInfoList &filenames); /** * @brief Show a dialog to the user to rename a set of nodes */ - bool LabelNodes(const QVector &nodes, + bool label_nodes(const QVector &nodes, MultiUndoCommand *parent = nullptr); /** * @brief Create a new sequence named appropriately for the active project */ - static Sequence *CreateNewSequenceForProject(const QString &format, + static Sequence *create_new_sequence_for_project(const QString &format, Project *project); - static Sequence *CreateNewSequenceForProject(Project *project) + static Sequence *create_new_sequence_for_project(Project *project) { - return CreateNewSequenceForProject(tr("Sequence %1"), project); + return create_new_sequence_for_project(tr("Sequence %1"), project); } /** * @brief Opens a project from the recently opened list */ - void OpenProjectFromRecentList(int index); + void open_project_from_recent_list(int index); /** * @brief Closes a project */ - bool CloseProject(bool auto_open_new, bool ignore_modified = false); + bool close_project(bool auto_open_new, bool ignore_modified = false); /** * @brief Runs a modal cache task on the currently active sequence */ - void CacheActiveSequence(bool in_out_only); + void cache_active_sequence(bool in_out_only); /** * @brief Check each footage object for whether it still exists or has changed */ - bool ValidateFootageInLoadedProject(Project *project, + bool validate_footage_in_loaded_project(Project *project, const QString &project_saved_url); /** * @brief Changes the current language */ - bool SetLanguage(const QString &locale); + bool set_language(const QString &locale); /** * @brief Show message in main window's status bar * * Shorthand for Core::instance()->main_window()->statusBar()->showMessage(); */ - void ShowStatusBarMessage(const QString &s, int timeout = 0); + void show_status_bar_message(const QString &s, int timeout = 0); - void ClearStatusBarMessage(); + void clear_status_bar_message(); - void OpenRecoveryProject(const QString &filename); + void open_recovery_project(const QString &filename); - void OpenNodeInViewer(ViewerOutput *viewer); + void open_node_in_viewer(ViewerOutput *viewer); - void OpenExportDialogForViewer(ViewerOutput *viewer, + void open_export_dialog_for_viewer(ViewerOutput *viewer, bool start_still_image); - bool IsMagicEnabled() const + bool is_magic_enabled() const { return magic_; } @@ -311,56 +311,56 @@ public slots: /** * @brief Starts an open file dialog to load a project from file */ - void OpenProject(); + void open_project(); /** * @brief Saves the current project */ - bool SaveProject(); + bool save_project(); /** * @brief Performs a "save as" on the current project */ - bool SaveProjectAs(); + bool save_project_as(); - void RevertProject(); + void revert_project(); /** * @brief Set the current application-wide tool * * @param tool */ - void SetTool(const Tool::Item &tool); + void set_tool(const Tool::Item &tool); /** * @brief Set the current snapping setting */ - void SetSnapping(const bool &b); + void set_snapping(const bool &b); /** * @brief Show an About dialog */ - void DialogAboutShow(); + void dialog_about_show(); /** * @brief Open the import footage dialog and import the files selected (runs ImportFiles()) */ - void DialogImportShow(); + void dialog_import_show(); /** * @brief Show Preferences dialog */ - void DialogPreferencesShow(int start_tab = 0); + void dialog_preferences_show(int start_tab = 0); /** * @brief Show Project Properties dialog */ - void DialogProjectPropertiesShow(); + void dialog_project_properties_show(); /** * @brief Show Export dialog */ - void DialogExportShow(); + void dialog_export_show(); /** * @brief Show OTIO import dialog @@ -372,42 +372,42 @@ public slots: /** * @brief Create a new folder in the currently active project */ - void CreateNewFolder(); + void create_new_folder(); /** * @brief Create a new sequence in the currently active project */ - void CreateNewSequence(); + void create_new_sequence(); /** * @brief Set the currently selected object that the add tool should make */ - void SetSelectedAddableObject(const Tool::AddableObject &obj); + void set_selected_addable_object(const Tool::AddableObject &obj); /** * @brief Set the currently selected object that the add tool should make */ - void SetSelectedTransitionObject(const QString &obj); + void set_selected_transition_object(const QString &obj); /** * @brief Clears the list of recently opened/saved projects */ - void ClearOpenRecentList(); + void clear_open_recent_list(); /** * @brief Creates a new empty project and opens it */ - void CreateNewProject(); + void create_new_project(); - void CheckForAutoRecoveries(); + void check_for_auto_recoveries(); - void BrowseAutoRecoveries(); + void browse_auto_recoveries(); - void RequestPixelSamplingInViewers(bool e); + void request_pixel_sampling_in_viewers(bool e); - void WarnCacheFull(); + void warn_cache_full(); - void SetMagic(bool e) + void set_magic(bool e) { magic_ = e; } @@ -416,60 +416,60 @@ signals: /** * @brief Signal emitted when the tool is changed from somewhere */ - void ToolChanged(const Tool::Item &tool); + void tool_changed(const Tool::Item &tool); /** * @brief Signal emitted when addable object changes through SetSelectedAddableObject */ - void AddableObjectChanged(Tool::AddableObject o); + void addable_object_changed(Tool::AddableObject o); /** * @brief Signal emitted when the snapping setting is changed */ - void SnappingChanged(const bool &b); + void snapping_changed(const bool &b); /** * @brief Signal emitted when the default timecode display mode changed */ - void TimecodeDisplayChanged(Timecode::Display d); + void timecode_display_changed(Timecode::Display d); /** * @brief Signal emitted when a change is made to the open recent list */ - void OpenRecentListChanged(); + void open_recent_list_changed(); /** * @brief Enable mouse color sampling functionality on all viewers * * This can be slow, so we only turn it on when we need it. */ - void ColorPickerEnabled(bool e); + void color_picker_enabled(bool e); /** * @brief A viewer with color picked enabled has emitted a color */ - void ColorPickerColorEmitted(const Color &reference, const Color &display); + void color_picker_color_emitted(const Color &reference, const Color &display); private: /** * @brief Get the file filter than can be used with QFileDialog to open and save compatible projects */ - static QString GetProjectFilter(bool include_any_filter); + static QString get_project_filter(bool include_any_filter); /** * @brief Returns the filename where the recently opened/saved projects should be stored */ - static QString GetRecentProjectsFilePath(); + static QString get_recent_projects_file_path(); /** * @brief Called only on startup to set the locale */ - void SetStartupLocale(); + void set_startup_locale(); /** * @brief Adds a filename to the top of the recently opened projects list (or moves it if it already exists) */ - void PushRecentlyOpenedProject(const QString &s); + void push_recently_opened_project(const QString &s); /** * @brief Declare custom types/classes for Qt's signal/slot system @@ -477,42 +477,42 @@ private: * Qt's signal/slot system requires types to be declared. In the interest of doing this only at startup, we contain * them all in a function here. */ - void DeclareTypesForQt(); + void declare_types_for_qt(); /** * @brief Start GUI portion of Olive * * Starts services and objects required for the GUI of Olive. It's guaranteed that running without this function will - * create an application instance that is completely valid minus the UI (e.g. for CLI modes). + * create an application instance_ that is completely valid minus the UI (e.g. for CLI modes). */ - void StartGUI(bool full_screen); + void start_gui(bool full_screen); /** * @brief Internal function for saving a project to a file */ - void SaveProjectInternal(const QString &override_filename = QString()); + void save_project_internal(const QString &override_filename = QString()); /** * @brief Retrieves the currently most active sequence for exporting */ - ViewerOutput *GetSequenceToExport(); + ViewerOutput *get_sequence_to_export(); - static QString GetAutoRecoveryIndexFilename(); + static QString get_auto_recovery_index_filename(); - void SaveUnrecoveredList(); + void save_unrecovered_list(); - bool RevertProjectInternal(bool by_opening_existing); + bool revert_project_internal(bool by_opening_existing); - void SaveRecentProjectsList(); + void save_recent_projects_list(); /** * @brief Adds a project to the "open projects" list */ - void AddOpenProject(olive::Project *p, bool add_to_recents = false); + void add_open_project(olive::Project *p, bool add_to_recents = false); - bool AddOpenProjectFromTask(Task *task, bool add_to_recents); + bool add_open_project_from_task(Task *task, bool add_to_recents); - void SetActiveProject(Project *p); + void set_active_project(Project *p); /** * @brief Internal main window object @@ -550,7 +550,7 @@ private: QTimer autorecovery_timer_; /** - * @brief Application-wide undo stack instance + * @brief Application-wide undo stack instance_ */ UndoStack undo_stack_; @@ -565,7 +565,7 @@ private: CoreParams core_params_; /** - * @brief Static singleton core instance + * @brief Static singleton core instance_ */ static Core *instance_; @@ -592,36 +592,36 @@ private: bool shown_cache_full_warning_; private slots: - void SaveAutorecovery(); + void save_autorecovery(); - void ProjectSaveSucceeded(Task *task); + void project_save_succeeded(Task *task); - bool AddOpenProjectFromTaskAndAddToRecents(Task *task) + bool add_open_project_from_task_and_add_to_recents(Task *task) { - return AddOpenProjectFromTask(task, true); + return add_open_project_from_task(task, true); } - void ImportTaskComplete(Task *task); + void import_task_complete(Task *task); - bool ConfirmImageSequence(const QString &filename); + bool confirm_image_sequence(const QString &filename); - void ProjectWasModified(bool e); + void project_was_modified(bool e); - bool StartHeadlessExport(); + bool start_headless_export(); - void OpenStartupProject(); + void open_startup_project(); - void AddRecoveryProjectFromTask(Task *task); + void add_recovery_project_from_task(Task *task); /** * @brief Internal project open */ - void OpenProjectInternal(const QString &filename, + void open_project_internal(const QString &filename, bool recovery_project = false); - void ImportSingleFile(const QString &f); + void import_single_file(const QString &f); }; } -#endif // CORE_H +#endif // OAK_CORE_H diff --git a/app/crashhandler/crashhandler.h b/app/crashhandler/crashhandler.h index b3753a070..57a41a6b0 100644 --- a/app/crashhandler/crashhandler.h +++ b/app/crashhandler/crashhandler.h @@ -19,8 +19,8 @@ ***/ -#ifndef CRASHHANDLERDIALOG_H -#define CRASHHANDLERDIALOG_H +#ifndef OAK_CRASHHANDLERDIALOG_H +#define OAK_CRASHHANDLERDIALOG_H #include #include @@ -79,4 +79,4 @@ private slots: } -#endif // CRASHHANDLERDIALOG_H +#endif // OAK_CRASHHANDLERDIALOG_H diff --git a/app/dialog/about/about.cpp b/app/dialog/about/about.cpp index e173c623b..038d37b05 100644 --- a/app/dialog/about/about.cpp +++ b/app/dialog/about/about.cpp @@ -115,7 +115,7 @@ AboutDialog::AboutDialog(bool welcome_dialog, QWidget *parent) if (!patrons.isEmpty()) { ScrollingLabel *scroll = new ScrollingLabel(patrons); - scroll->StartAnimating(); + scroll->start_animating(); layout->addWidget(scroll); } @@ -150,7 +150,7 @@ AboutDialog::AboutDialog(bool welcome_dialog, QWidget *parent) void AboutDialog::accept() { if (dont_show_again_checkbox_ && dont_show_again_checkbox_->isChecked()) { - OLIVE_CONFIG("ShowWelcomeDialog") = false; + OAK_CONFIG("ShowWelcomeDialog") = false; } QDialog::accept(); diff --git a/app/dialog/about/about.h b/app/dialog/about/about.h index 804635097..9ecd30505 100644 --- a/app/dialog/about/about.h +++ b/app/dialog/about/about.h @@ -19,8 +19,8 @@ ***/ -#ifndef ABOUTDIALOG_H -#define ABOUTDIALOG_H +#ifndef OAK_ABOUTDIALOG_H +#define OAK_ABOUTDIALOG_H #include #include @@ -59,4 +59,4 @@ private: } -#endif // ABOUTDIALOG_H +#endif // OAK_ABOUTDIALOG_H diff --git a/app/dialog/about/patreon.h b/app/dialog/about/patreon.h index 1ecac70d6..9da039ed1 100644 --- a/app/dialog/about/patreon.h +++ b/app/dialog/about/patreon.h @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -#ifndef PATREON_H -#define PATREON_H +#ifndef OAK_PATREON_H +#define OAK_PATREON_H #include QStringList patrons; -#endif // PATREON_H +#endif // OAK_PATREON_H diff --git a/app/dialog/about/scrollinglabel.cpp b/app/dialog/about/scrollinglabel.cpp index 681c10b33..796cac237 100644 --- a/app/dialog/about/scrollinglabel.cpp +++ b/app/dialog/about/scrollinglabel.cpp @@ -28,23 +28,23 @@ namespace olive { -const int ScrollingLabel::kMinLineHeight = 10; +const int ScrollingLabel::k_min_line_height = 10; ScrollingLabel::ScrollingLabel(QWidget *parent) : QWidget(parent) , animate_(0) { timer_.setInterval(50); - connect(&timer_, &QTimer::timeout, this, &ScrollingLabel::AnimationUpdate); + connect(&timer_, &QTimer::timeout, this, &ScrollingLabel::animation_update); } ScrollingLabel::ScrollingLabel(const QStringList &text, QWidget *parent) : ScrollingLabel(parent) { - SetText(text); + set_text(text); } -void ScrollingLabel::SetText(const QStringList &text) +void ScrollingLabel::set_text(const QStringList &text) { text_ = text; @@ -53,10 +53,10 @@ void ScrollingLabel::SetText(const QStringList &text) int width = 0; foreach (const QString &s, text_) { - width = qMax(width, QtUtils::QFontMetricsWidth(fm, s)); + width = qMax(width, QtUtils::q_font_metrics_width(fm, s)); } - setMinimumSize(width, text_height_ * kMinLineHeight); + setMinimumSize(width, text_height_ * k_min_line_height); } void ScrollingLabel::paintEvent(QPaintEvent *e) @@ -82,15 +82,15 @@ void ScrollingLabel::paintEvent(QPaintEvent *e) const QString &s = text_.at(i); - int width = QtUtils::QFontMetricsWidth(fm, s); + int width = QtUtils::q_font_metrics_width(fm, s); p.drawText(half_width / 2 - width / 2, text_y, s); } for (int y = 0; y < text_height_; y++) { double mul = double(y) / double(text_height_); - SetOpacityOfScanLine(map.scanLine(y), map.width(), 4, mul); - SetOpacityOfScanLine(map.scanLine(map.height() - 1 - y), + set_opacity_of_scan_line(map.scanLine(y), map.width(), 4, mul); + set_opacity_of_scan_line(map.scanLine(map.height() - 1 - y), map.width(), 4, mul); } } @@ -99,7 +99,7 @@ void ScrollingLabel::paintEvent(QPaintEvent *e) wp.drawImage(0, 0, map); } -void ScrollingLabel::SetOpacityOfScanLine(uchar *scan_line, int width, +void ScrollingLabel::set_opacity_of_scan_line(uchar *scan_line, int width, int channels, double mul) { for (int x = 0; x < width; x++) { @@ -111,7 +111,7 @@ void ScrollingLabel::SetOpacityOfScanLine(uchar *scan_line, int width, } } -void ScrollingLabel::AnimationUpdate() +void ScrollingLabel::animation_update() { animate_++; diff --git a/app/dialog/about/scrollinglabel.h b/app/dialog/about/scrollinglabel.h index e8a1f7f49..1a12e18cf 100644 --- a/app/dialog/about/scrollinglabel.h +++ b/app/dialog/about/scrollinglabel.h @@ -19,8 +19,8 @@ ***/ -#ifndef SCROLLINGLABEL_H -#define SCROLLINGLABEL_H +#ifndef OAK_SCROLLINGLABEL_H +#define OAK_SCROLLINGLABEL_H #include #include @@ -34,14 +34,14 @@ public: ScrollingLabel(QWidget *parent = nullptr); ScrollingLabel(const QStringList &text, QWidget *parent = nullptr); - void SetText(const QStringList &text); + void set_text(const QStringList &text); - void StartAnimating() + void start_animating() { timer_.start(); } - void StopAnimating() + void stop_animating() { timer_.stop(); } @@ -50,10 +50,10 @@ protected: virtual void paintEvent(QPaintEvent *e) override; private: - static void SetOpacityOfScanLine(uchar *scan_line, int width, int channels, + static void set_opacity_of_scan_line(uchar *scan_line, int width, int channels, double mul); - static const int kMinLineHeight; + static const int k_min_line_height; QStringList text_; @@ -64,9 +64,9 @@ private: int animate_; private slots: - void AnimationUpdate(); + void animation_update(); }; } -#endif // SCROLLINGLABEL_H +#endif // OAK_SCROLLINGLABEL_H diff --git a/app/dialog/actionsearch/actionsearch.cpp b/app/dialog/actionsearch/actionsearch.cpp index fda36c79c..76a13e5e1 100644 --- a/app/dialog/actionsearch/actionsearch.cpp +++ b/app/dialog/actionsearch/actionsearch.cpp @@ -66,30 +66,30 @@ ActionSearch::ActionSearch(QWidget *parent) // moveSelectionUp() and moveSelectionDown() are emitted when the user pressed up or down on the text field. // We override it here to select the upper or lower item in the list. - connect(entry_field, SIGNAL(moveSelectionUp()), this, + connect(entry_field, SIGNAL(move_selection_up()), this, SLOT(move_selection_up())); - connect(entry_field, SIGNAL(moveSelectionDown()), this, + connect(entry_field, SIGNAL(move_selection_down()), this, SLOT(move_selection_down())); layout->addWidget(entry_field); // Construct list of actions - list_widget = new ActionSearchList(this); + list_widget_ = new ActionSearchList(this); // Set list's font to 1.2x its standard font size - QFont list_widget_font = list_widget->font(); + QFont list_widget_font = list_widget_->font(); list_widget_font.setPointSize(qRound(list_widget_font.pointSize() * 1.2)); - list_widget->setFont(list_widget_font); + list_widget_->setFont(list_widget_font); - layout->addWidget(list_widget); + layout->addWidget(list_widget_); - connect(list_widget, SIGNAL(dbl_click()), this, SLOT(perform_action())); + connect(list_widget_, SIGNAL(dbl_click()), this, SLOT(perform_action())); // Instantly focus on the entry field to allow for fully keyboard operation (if this popup was initiated by keyboard // shortcut for example). entry_field->setFocus(); } -void ActionSearch::SetMenuBar(QMenuBar *menu_bar) +void ActionSearch::set_menu_bar(QMenuBar *menu_bar) { menu_bar_ = menu_bar; } @@ -112,7 +112,7 @@ void ActionSearch::search_update(const QString &s, const QString &p, // (and their submenus). // We'll clear all the current items in the list since if we're here, we're just starting. - list_widget->clear(); + list_widget_->clear(); QList menus = menu_bar_->actions(); @@ -125,8 +125,8 @@ void ActionSearch::search_update(const QString &s, const QString &p, // Once we're here, all the recursion/item retrieval is complete. We auto-select the first item for better // keyboard-exclusive functionality. - if (list_widget->count() > 0) { - list_widget->item(0)->setSelected(true); + if (list_widget_->count() > 0) { + list_widget_->item(0)->setSelected(true); } } else { @@ -162,13 +162,13 @@ void ActionSearch::search_update(const QString &s, const QString &p, // If so, we add it to the list widget. QListWidgetItem *item = new QListWidgetItem( QStringLiteral("%1\n(%2)").arg(comp, menu_text), - list_widget); + list_widget_); // Add a pointer to the original QAction in the item's data item->setData(Qt::UserRole + 1, reinterpret_cast(a)); - list_widget->addItem(item); + list_widget_->addItem(item); } } } @@ -179,8 +179,8 @@ void ActionSearch::search_update(const QString &s, const QString &p, void ActionSearch::perform_action() { // Loop over all the items in the list and if we find one that's selected, we trigger it. - QList selected_items = list_widget->selectedItems(); - if (list_widget->count() > 0 && selected_items.size() > 0) { + QList selected_items = list_widget_->selectedItems(); + if (list_widget_->count() > 0 && selected_items.size() > 0) { QListWidgetItem *item = selected_items.at(0); // Get QAction pointer from item's data @@ -200,11 +200,11 @@ void ActionSearch::move_selection_up() // iterating at 1 (instead of 0) to efficiently ignore the first item (since the selection can't go below the very // bottom item). - int lim = list_widget->count(); + int lim = list_widget_->count(); for (int i = 1; i < lim; i++) { - if (list_widget->item(i)->isSelected()) { - list_widget->item(i - 1)->setSelected(true); - list_widget->scrollToItem(list_widget->item(i - 1)); + if (list_widget_->item(i)->isSelected()) { + list_widget_->item(i - 1)->setSelected(true); + list_widget_->scrollToItem(list_widget_->item(i - 1)); break; } } @@ -216,11 +216,11 @@ void ActionSearch::move_selection_down() // one entry before count() to efficiently ignore the item at the end (since the selection can't go below the very // bottom item). - int lim = list_widget->count() - 1; + int lim = list_widget_->count() - 1; for (int i = 0; i < lim; i++) { - if (list_widget->item(i)->isSelected()) { - list_widget->item(i + 1)->setSelected(true); - list_widget->scrollToItem(list_widget->item(i + 1)); + if (list_widget_->item(i)->isSelected()) { + list_widget_->item(i + 1)->setSelected(true); + list_widget_->scrollToItem(list_widget_->item(i + 1)); break; } } @@ -247,11 +247,11 @@ bool ActionSearchEntry::event(QEvent *e) switch (static_cast(e)->key()) { case Qt::Key_Up: e->accept(); - emit moveSelectionUp(); + emit move_selection_up(); return true; case Qt::Key_Down: e->accept(); - emit moveSelectionDown(); + emit move_selection_down(); return true; } break; diff --git a/app/dialog/actionsearch/actionsearch.h b/app/dialog/actionsearch/actionsearch.h index 0234dd638..645954536 100644 --- a/app/dialog/actionsearch/actionsearch.h +++ b/app/dialog/actionsearch/actionsearch.h @@ -19,8 +19,8 @@ ***/ -#ifndef ACTIONSEARCH_H -#define ACTIONSEARCH_H +#ifndef OAK_ACTIONSEARCH_H +#define OAK_ACTIONSEARCH_H #include #include @@ -58,7 +58,7 @@ public: /** * @brief Set the menu bar to use in this action search */ - void SetMenuBar(QMenuBar *menu_bar); + void set_menu_bar(QMenuBar *menu_bar); private slots: /** * @brief Update the list of actions according to a search query @@ -115,7 +115,7 @@ private: /** * @brief Main widget that shows the list of commands */ - ActionSearchList *list_widget; + ActionSearchList *list_widget_; /** * @brief Attached menu bar object @@ -180,14 +180,14 @@ signals: /** * @brief Emitted when the user presses the up arrow key. */ - void moveSelectionUp(); + void move_selection_up(); /** * @brief Emitted when the user presses the down arrow key. */ - void moveSelectionDown(); + void move_selection_down(); }; } -#endif // ACTIONSEARCH_H +#endif // OAK_ACTIONSEARCH_H diff --git a/app/dialog/autorecovery/autorecoverydialog.cpp b/app/dialog/autorecovery/autorecoverydialog.cpp index 0fa7110bc..1a6fdce58 100644 --- a/app/dialog/autorecovery/autorecoverydialog.cpp +++ b/app/dialog/autorecovery/autorecoverydialog.cpp @@ -40,24 +40,24 @@ AutoRecoveryDialog::AutoRecoveryDialog(const QString &message, bool autocheck_latest, QWidget *parent) : QDialog(parent) { - Init(message); + init(message); - PopulateTree(recoveries, autocheck_latest); + populate_tree(recoveries, autocheck_latest); } void AutoRecoveryDialog::accept() { foreach (QTreeWidgetItem *checkable, checkable_items_) { if (checkable->checkState(0) == Qt::Checked) { - QString filename = checkable->data(0, kFilenameRole).toString(); - Core::instance()->OpenRecoveryProject(filename); + QString filename = checkable->data(0, k_filename_role).toString(); + Core::instance()->open_recovery_project(filename); } } super::accept(); } -void AutoRecoveryDialog::Init(const QString &header_text) +void AutoRecoveryDialog::init(const QString &header_text) { QVBoxLayout *layout = new QVBoxLayout(this); @@ -79,11 +79,11 @@ void AutoRecoveryDialog::Init(const QString &header_text) layout->addWidget(buttons); } -void AutoRecoveryDialog::PopulateTree(const QStringList &recoveries, +void AutoRecoveryDialog::populate_tree(const QStringList &recoveries, bool autocheck_latest) { // Each entry in `recoveries` is a directory with 1+ recovery projects in it - QDir autorecovery_root(FileFunctions::GetAutoRecoveryRoot()); + QDir autorecovery_root(FileFunctions::get_auto_recovery_root()); foreach (const QString &recovery_folder, recoveries) { QDir recovery_dir(autorecovery_root.filePath(recovery_folder)); @@ -137,7 +137,7 @@ void AutoRecoveryDialog::PopulateTree(const QStringList &recoveries, } entry_item->setText(0, entry_name); - entry_item->setData(0, kFilenameRole, + entry_item->setData(0, k_filename_role, recovery_dir.filePath(entry)); // Allow to be checked, auto-checking the first entry diff --git a/app/dialog/autorecovery/autorecoverydialog.h b/app/dialog/autorecovery/autorecoverydialog.h index fa09c5d89..16f5ccf97 100644 --- a/app/dialog/autorecovery/autorecoverydialog.h +++ b/app/dialog/autorecovery/autorecoverydialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUTORECOVERYDIALOG_H -#define AUTORECOVERYDIALOG_H +#ifndef OAK_AUTORECOVERYDIALOG_H +#define OAK_AUTORECOVERYDIALOG_H #include #include @@ -40,17 +40,17 @@ public slots: virtual void accept() override; private: - void Init(const QString &header_text); + void init(const QString &header_text); - void PopulateTree(const QStringList &recoveries, bool autocheck); + void populate_tree(const QStringList &recoveries, bool autocheck); QTreeWidget *tree_widget_; QVector checkable_items_; - enum DataRole { kFilenameRole = Qt::UserRole }; + enum DataRole { k_filename_role = Qt::UserRole }; }; } -#endif // AUTORECOVERYDIALOG_H +#endif // OAK_AUTORECOVERYDIALOG_H diff --git a/app/dialog/color/colordialog.cpp b/app/dialog/color/colordialog.cpp index edbafe955..2829ecb7f 100644 --- a/app/dialog/color/colordialog.cpp +++ b/app/dialog/color/colordialog.cpp @@ -56,7 +56,7 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start, hsv_value_gradient_ = new ColorGradientWidget(Qt::Vertical); hsv_value_gradient_->setFixedWidth( - QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("HHH"))); + QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("HHH"))); wheel_layout->addWidget(hsv_value_gradient_); QHBoxLayout *swatch_layout = new QHBoxLayout(); @@ -76,7 +76,7 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start, splitter->addWidget(value_area); color_values_widget_ = new ColorValuesWidget(color_manager_); - color_values_widget_->IgnorePickFrom(this); + color_values_widget_->ignore_pick_from(this); value_layout->addWidget(color_values_widget_); chooser_ = new ColorSpaceChooser(color_manager_); @@ -86,32 +86,32 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start, // Split window 50/50 splitter->setSizes({ INT_MAX, INT_MAX }); - connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, - color_values_widget_, &ColorValuesWidget::SetColor); - connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, - hsv_value_gradient_, &ColorGradientWidget::SetSelectedColor); - connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, swatch_, - &ColorSwatchChooser::SetCurrentColor); - connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, - color_values_widget_, &ColorValuesWidget::SetColor); - connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, - color_wheel_, &ColorWheelWidget::SetSelectedColor); - connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, - swatch_, &ColorSwatchChooser::SetCurrentColor); - connect(color_values_widget_, &ColorValuesWidget::ColorChanged, - hsv_value_gradient_, &ColorGradientWidget::SetSelectedColor); - connect(color_values_widget_, &ColorValuesWidget::ColorChanged, - color_wheel_, &ColorWheelWidget::SetSelectedColor); - connect(color_values_widget_, &ColorValuesWidget::ColorChanged, swatch_, - &ColorSwatchChooser::SetCurrentColor); - connect(swatch_, &ColorSwatchChooser::ColorClicked, hsv_value_gradient_, - &ColorGradientWidget::SetSelectedColor); - connect(swatch_, &ColorSwatchChooser::ColorClicked, color_wheel_, - &ColorWheelWidget::SetSelectedColor); - connect(swatch_, &ColorSwatchChooser::ColorClicked, color_values_widget_, - &ColorValuesWidget::SetColor); + connect(color_wheel_, &ColorWheelWidget::selected_color_changed, + color_values_widget_, &ColorValuesWidget::set_color); + connect(color_wheel_, &ColorWheelWidget::selected_color_changed, + hsv_value_gradient_, &ColorGradientWidget::set_selected_color); + connect(color_wheel_, &ColorWheelWidget::selected_color_changed, swatch_, + &ColorSwatchChooser::set_current_color); + connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed, + color_values_widget_, &ColorValuesWidget::set_color); + connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed, + color_wheel_, &ColorWheelWidget::set_selected_color); + connect(hsv_value_gradient_, &ColorGradientWidget::selected_color_changed, + swatch_, &ColorSwatchChooser::set_current_color); + connect(color_values_widget_, &ColorValuesWidget::color_changed, + hsv_value_gradient_, &ColorGradientWidget::set_selected_color); + connect(color_values_widget_, &ColorValuesWidget::color_changed, + color_wheel_, &ColorWheelWidget::set_selected_color); + connect(color_values_widget_, &ColorValuesWidget::color_changed, swatch_, + &ColorSwatchChooser::set_current_color); + connect(swatch_, &ColorSwatchChooser::color_clicked, hsv_value_gradient_, + &ColorGradientWidget::set_selected_color); + connect(swatch_, &ColorSwatchChooser::color_clicked, color_wheel_, + &ColorWheelWidget::set_selected_color); + connect(swatch_, &ColorSwatchChooser::color_clicked, color_values_widget_, + &ColorValuesWidget::set_color); - connect(color_wheel_, &ColorWheelWidget::DiameterChanged, + connect(color_wheel_, &ColorWheelWidget::diameter_changed, hsv_value_gradient_, &ColorGradientWidget::setFixedHeight); QDialogButtonBox *buttons = @@ -120,17 +120,17 @@ ColorDialog::ColorDialog(ColorManager *color_manager, const ManagedColor &start, connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); layout->addWidget(buttons); - SetColor(start); + set_color(start); - connect(chooser_, &ColorSpaceChooser::ColorSpaceChanged, this, - &ColorDialog::ColorSpaceChanged); - ColorSpaceChanged(chooser_->input(), chooser_->output()); + connect(chooser_, &ColorSpaceChooser::color_space_changed, this, + &ColorDialog::color_space_changed); + color_space_changed(chooser_->input(), chooser_->output()); // Set default size ratio to 2:1 resize(sizeHint().height() * 2, sizeHint().height()); } -void ColorDialog::SetColor(const ManagedColor &start) +void ColorDialog::set_color(const ManagedColor &start) { chooser_->set_input(start.color_input()); chooser_->set_output(start.color_output()); @@ -142,70 +142,70 @@ void ColorDialog::SetColor(const ManagedColor &start) } else { // Convert reference color to the input space - ColorProcessorPtr linear_to_input = ColorProcessor::Create( - color_manager_, color_manager_->GetReferenceColorSpace(), + ColorProcessorPtr linear_to_input = ColorProcessor::create( + color_manager_, color_manager_->get_reference_color_space(), start.color_input()); - managed_start = linear_to_input->ConvertColor(start); + managed_start = linear_to_input->convert_color(start); } - color_wheel_->SetSelectedColor(managed_start); - hsv_value_gradient_->SetSelectedColor(managed_start); - color_values_widget_->SetColor(managed_start); - swatch_->SetCurrentColor(managed_start); + color_wheel_->set_selected_color(managed_start); + hsv_value_gradient_->set_selected_color(managed_start); + color_values_widget_->set_color(managed_start); + swatch_->set_current_color(managed_start); } -ManagedColor ColorDialog::GetSelectedColor() const +ManagedColor ColorDialog::get_selected_color() const { - ManagedColor selected = color_wheel_->GetSelectedColor(); + ManagedColor selected = color_wheel_->get_selected_color(); // Convert to linear and return a linear color if (input_to_ref_processor_) { - selected = input_to_ref_processor_->ConvertColor(selected); + selected = input_to_ref_processor_->convert_color(selected); } - selected.set_color_input(GetColorSpaceInput()); - selected.set_color_output(GetColorSpaceOutput()); + selected.set_color_input(get_color_space_input()); + selected.set_color_output(get_color_space_output()); return selected; } -QString ColorDialog::GetColorSpaceInput() const +QString ColorDialog::get_color_space_input() const { return chooser_->input(); } -ColorTransform ColorDialog::GetColorSpaceOutput() const +ColorTransform ColorDialog::get_color_space_output() const { return chooser_->output(); } -void ColorDialog::ColorSpaceChanged(const QString &input, +void ColorDialog::color_space_changed(const QString &input, const ColorTransform &output) { - input_to_ref_processor_ = ColorProcessor::Create( - color_manager_, input, color_manager_->GetReferenceColorSpace()); + input_to_ref_processor_ = ColorProcessor::create( + color_manager_, input, color_manager_->get_reference_color_space()); - ColorProcessorPtr ref_to_display = ColorProcessor::Create( - color_manager_, color_manager_->GetReferenceColorSpace(), output); + ColorProcessorPtr ref_to_display = ColorProcessor::create( + color_manager_, color_manager_->get_reference_color_space(), output); - ColorProcessorPtr ref_to_input = ColorProcessor::Create( - color_manager_, color_manager_->GetReferenceColorSpace(), input); + ColorProcessorPtr ref_to_input = ColorProcessor::create( + color_manager_, color_manager_->get_reference_color_space(), input); // Display -> reference is the inverse of the display transform. Older OCIO // versions crashed on TRANSFORM_DIR_INVERSE; guard by requiring a valid // processor and fall back to disabling the display tab if creation fails. - ColorProcessorPtr display_to_ref = ColorProcessor::Create( - color_manager_, color_manager_->GetReferenceColorSpace(), output, - ColorProcessor::kInverse); - if (display_to_ref && !display_to_ref->GetProcessor()) { + ColorProcessorPtr display_to_ref = ColorProcessor::create( + color_manager_, color_manager_->get_reference_color_space(), output, + ColorProcessor::k_inverse); + if (display_to_ref && !display_to_ref->get_processor()) { display_to_ref = nullptr; } - color_wheel_->SetColorProcessor(input_to_ref_processor_, ref_to_display); - hsv_value_gradient_->SetColorProcessor(input_to_ref_processor_, + color_wheel_->set_color_processor(input_to_ref_processor_, ref_to_display); + hsv_value_gradient_->set_color_processor(input_to_ref_processor_, ref_to_display); - color_values_widget_->SetColorProcessor( + color_values_widget_->set_color_processor( input_to_ref_processor_, ref_to_display, display_to_ref, ref_to_input); } diff --git a/app/dialog/color/colordialog.h b/app/dialog/color/colordialog.h index 86fc12c1d..6b3ae147b 100644 --- a/app/dialog/color/colordialog.h +++ b/app/dialog/color/colordialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORDIALOG_H -#define COLORDIALOG_H +#ifndef OAK_COLORDIALOG_H +#define OAK_COLORDIALOG_H #include @@ -66,14 +66,14 @@ public: * * The color is always returned in the ColorManager's reference space (usually scene linear). */ - ManagedColor GetSelectedColor() const; + ManagedColor get_selected_color() const; - QString GetColorSpaceInput() const; + QString get_color_space_input() const; - ColorTransform GetColorSpaceOutput() const; + ColorTransform get_color_space_output() const; public slots: - void SetColor(const ManagedColor &c); + void set_color(const ManagedColor &c); private: ColorManager *color_manager_; @@ -91,9 +91,9 @@ private: ColorSwatchChooser *swatch_; private slots: - void ColorSpaceChanged(const QString &input, const ColorTransform &output); + void color_space_changed(const QString &input, const ColorTransform &output); }; } -#endif // COLORDIALOG_H +#endif // OAK_COLORDIALOG_H diff --git a/app/dialog/configbase/configdialogbase.cpp b/app/dialog/configbase/configdialogbase.cpp index 7bed9b1a4..f0d2be6d4 100644 --- a/app/dialog/configbase/configdialogbase.cpp +++ b/app/dialog/configbase/configdialogbase.cpp @@ -65,7 +65,7 @@ ConfigDialogBase::ConfigDialogBase(QWidget *parent) void ConfigDialogBase::accept() { foreach (ConfigDialogBaseTab *tab, tabs_) { - if (!tab->Validate()) { + if (!tab->validate()) { return; } } @@ -73,7 +73,7 @@ void ConfigDialogBase::accept() MultiUndoCommand *command = new MultiUndoCommand(); foreach (ConfigDialogBaseTab *tab, tabs_) { - tab->Accept(command); + tab->accept(command); } Core::instance()->undo_stack()->push(command, tr("Set Configuration")); @@ -83,7 +83,7 @@ void ConfigDialogBase::accept() QDialog::accept(); } -void ConfigDialogBase::AddTab(ConfigDialogBaseTab *tab, const QString &title) +void ConfigDialogBase::add_tab(ConfigDialogBaseTab *tab, const QString &title) { list_widget_->addItem(title); preference_pane_stack_->addWidget(tab); @@ -91,7 +91,7 @@ void ConfigDialogBase::AddTab(ConfigDialogBaseTab *tab, const QString &title) tabs_.append(tab); } -void ConfigDialogBase::SetCurrentTab(int index) +void ConfigDialogBase::set_current_tab(int index) { if (index >= 0 && index < list_widget_->count()) { list_widget_->setCurrentRow(index); diff --git a/app/dialog/configbase/configdialogbase.h b/app/dialog/configbase/configdialogbase.h index c4d2ed0a1..a300f2b90 100644 --- a/app/dialog/configbase/configdialogbase.h +++ b/app/dialog/configbase/configdialogbase.h @@ -19,8 +19,8 @@ ***/ -#ifndef CONFIGBASE_H -#define CONFIGBASE_H +#ifndef OAK_CONFIGBASE_H +#define OAK_CONFIGBASE_H #include #include @@ -36,7 +36,7 @@ class ConfigDialogBase : public QDialog { public: ConfigDialogBase(QWidget *parent = nullptr); - void SetCurrentTab(int index); + void set_current_tab(int index); private slots: /** @@ -45,7 +45,7 @@ private slots: virtual void accept() override; protected: - void AddTab(ConfigDialogBaseTab *tab, const QString &title); + void add_tab(ConfigDialogBaseTab *tab, const QString &title); virtual void AcceptEvent() { @@ -61,4 +61,4 @@ private: } -#endif // CONFIGBASE_H +#endif // OAK_CONFIGBASE_H diff --git a/app/dialog/configbase/configdialogbasetab.cpp b/app/dialog/configbase/configdialogbasetab.cpp index c7b78975f..e032c9032 100644 --- a/app/dialog/configbase/configdialogbasetab.cpp +++ b/app/dialog/configbase/configdialogbasetab.cpp @@ -24,7 +24,7 @@ namespace olive { -bool ConfigDialogBaseTab::Validate() +bool ConfigDialogBaseTab::validate() { return true; } diff --git a/app/dialog/configbase/configdialogbasetab.h b/app/dialog/configbase/configdialogbasetab.h index 4dabebd21..6c6084165 100644 --- a/app/dialog/configbase/configdialogbasetab.h +++ b/app/dialog/configbase/configdialogbasetab.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREFERENCESTAB_H -#define PREFERENCESTAB_H +#ifndef OAK_PREFERENCESTAB_H +#define OAK_PREFERENCESTAB_H #include @@ -34,11 +34,11 @@ class ConfigDialogBaseTab : public QWidget { public: ConfigDialogBaseTab() = default; - virtual bool Validate(); + virtual bool validate(); - virtual void Accept(MultiUndoCommand *parent) = 0; + virtual void accept(MultiUndoCommand *parent) = 0; }; } -#endif // PREFERENCESTAB_H +#endif // OAK_PREFERENCESTAB_H diff --git a/app/dialog/diskcache/diskcachedialog.cpp b/app/dialog/diskcache/diskcachedialog.cpp index 029950241..7bb6306c3 100644 --- a/app/dialog/diskcache/diskcachedialog.cpp +++ b/app/dialog/diskcache/diskcachedialog.cpp @@ -37,7 +37,7 @@ DiskCacheDialog::DiskCacheDialog(DiskCacheFolder *folder, QWidget *parent) int row = 0; - layout->addWidget(new QLabel(tr("Disk Cache: %1").arg(folder->GetPath())), + layout->addWidget(new QLabel(tr("Disk Cache: %1").arg(folder->get_path())), row, 0, 1, 2); setWindowTitle(tr("Disk Cache Settings")); @@ -46,10 +46,10 @@ DiskCacheDialog::DiskCacheDialog(DiskCacheFolder *folder, QWidget *parent) layout->addWidget(new QLabel(tr("Maximum Disk Cache:")), row, 0); maximum_cache_slider_ = new FloatSlider(); - maximum_cache_slider_->SetFormat(tr("%1 GB")); - maximum_cache_slider_->SetMinimum(1.0); - maximum_cache_slider_->SetValue(static_cast(folder->GetLimit()) / - static_cast(kBytesInGigabyte)); + maximum_cache_slider_->set_format(tr("%1 GB")); + maximum_cache_slider_->set_minimum(1.0); + maximum_cache_slider_->set_value(static_cast(folder->get_limit()) / + static_cast(k_bytes_in_gigabyte)); layout->addWidget(maximum_cache_slider_, row, 1); row++; @@ -57,14 +57,14 @@ DiskCacheDialog::DiskCacheDialog(DiskCacheFolder *folder, QWidget *parent) clear_cache_btn_ = new QPushButton(tr("Clear Disk Cache")); connect(clear_cache_btn_, &QPushButton::clicked, this, static_cast( - &DiskCacheDialog::ClearDiskCache)); + &DiskCacheDialog::clear_disk_cache)); layout->addWidget(clear_cache_btn_, row, 1); row++; clear_disk_cache_ = new QCheckBox(tr("Automatically clear disk cache on close")); - clear_disk_cache_->setChecked(folder->GetClearOnClose()); + clear_disk_cache_->setChecked(folder->get_clear_on_close()); layout->addWidget(clear_disk_cache_, row, 1); row++; @@ -81,24 +81,24 @@ DiskCacheDialog::DiskCacheDialog(DiskCacheFolder *folder, QWidget *parent) void DiskCacheDialog::accept() { qint64 new_disk_cache_limit = - qRound64(maximum_cache_slider_->GetValue() * kBytesInGigabyte); - if (new_disk_cache_limit != folder_->GetLimit()) { - folder_->SetLimit(new_disk_cache_limit); + qRound64(maximum_cache_slider_->get_value() * k_bytes_in_gigabyte); + if (new_disk_cache_limit != folder_->get_limit()) { + folder_->set_limit(new_disk_cache_limit); } - if (folder_->GetClearOnClose() != clear_disk_cache_->isChecked()) { - folder_->SetClearOnClose(clear_disk_cache_->isChecked()); + if (folder_->get_clear_on_close() != clear_disk_cache_->isChecked()) { + folder_->set_clear_on_close(clear_disk_cache_->isChecked()); } QDialog::accept(); } -void DiskCacheDialog::ClearDiskCache() +void DiskCacheDialog::clear_disk_cache() { - ClearDiskCache(folder_->GetPath(), this, clear_cache_btn_); + clear_disk_cache(folder_->get_path(), this, clear_cache_btn_); } -void DiskCacheDialog::ClearDiskCache(const QString &path, QWidget *parent, +void DiskCacheDialog::clear_disk_cache(const QString &path, QWidget *parent, QPushButton *clear_btn) { if (QMessageBox::question( @@ -109,7 +109,7 @@ void DiskCacheDialog::ClearDiskCache(const QString &path, QWidget *parent, if (clear_btn) clear_btn->setEnabled(false); - if (DiskManager::instance()->ClearDiskCache(path)) { + if (DiskManager::instance()->clear_disk_cache(path)) { if (clear_btn) clear_btn->setText(tr("Disk Cache Cleared")); } else { diff --git a/app/dialog/diskcache/diskcachedialog.h b/app/dialog/diskcache/diskcachedialog.h index fa56ae143..a5055d6c1 100644 --- a/app/dialog/diskcache/diskcachedialog.h +++ b/app/dialog/diskcache/diskcachedialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef DISKCACHEDIALOG_H -#define DISKCACHEDIALOG_H +#ifndef OAK_DISKCACHEDIALOG_H +#define OAK_DISKCACHEDIALOG_H #include #include @@ -37,7 +37,7 @@ class DiskCacheDialog : public QDialog { public: DiskCacheDialog(DiskCacheFolder *folder, QWidget *parent = nullptr); - static void ClearDiskCache(const QString &path, QWidget *parent, + static void clear_disk_cache(const QString &path, QWidget *parent, QPushButton *clear_btn = nullptr); public slots: @@ -53,9 +53,9 @@ private: QPushButton *clear_cache_btn_; private slots: - void ClearDiskCache(); + void clear_disk_cache(); }; } -#endif // DISKCACHEDIALOG_H +#endif // OAK_DISKCACHEDIALOG_H diff --git a/app/dialog/export/codec/av1section.cpp b/app/dialog/export/codec/av1section.cpp index f30cc6806..b567c2364 100644 --- a/app/dialog/export/codec/av1section.cpp +++ b/app/dialog/export/codec/av1section.cpp @@ -33,7 +33,7 @@ namespace olive { AV1Section::AV1Section(QWidget *parent) - : AV1Section(AV1CRFSection::kDefaultAV1CRF, parent) + : AV1Section(AV1CRFSection::k_default_a_v1_crf, parent) { } @@ -89,15 +89,15 @@ AV1Section::AV1Section(int default_crf, QWidget *parent) compression_method_stack_, &QStackedWidget::setCurrentIndex); } -void AV1Section::AddOpts(EncodingParams *params) +void AV1Section::add_opts(EncodingParams *params) { CompressionMethod method = static_cast( compression_method_stack_->currentIndex()); - if (method == kConstantRateFactor) { + if (method == k_constant_rate_factor) { // Set Quantizer value params->set_video_option(QStringLiteral("qp"), - QString::number(crf_section_->GetValue())); + QString::number(crf_section_->get_value())); } params->set_video_option(QStringLiteral("preset"), @@ -111,27 +111,27 @@ AV1CRFSection::AV1CRFSection(int default_crf, QWidget *parent) layout->setContentsMargins(0, 0, 0, 0); crf_slider_ = new QSlider(Qt::Horizontal); - crf_slider_->setMinimum(kMinimumCRF); - crf_slider_->setMaximum(kMaximumCRF); + crf_slider_->setMinimum(k_minimum_crf); + crf_slider_->setMaximum(k_maximum_crf); crf_slider_->setValue(default_crf); layout->addWidget(crf_slider_); IntegerSlider *crf_input = new IntegerSlider(); - crf_input->setMaximumWidth(QtUtils::QFontMetricsWidth( + crf_input->setMaximumWidth(QtUtils::q_font_metrics_width( crf_input->fontMetrics(), QStringLiteral("HHHH"))); - crf_input->SetMinimum(kMinimumCRF); - crf_input->SetMaximum(kMaximumCRF); - crf_input->SetValue(default_crf); + crf_input->set_minimum(k_minimum_crf); + crf_input->set_maximum(k_maximum_crf); + crf_input->set_value(default_crf); crf_input->SetDefaultValue(default_crf); layout->addWidget(crf_input); connect(crf_slider_, &QSlider::valueChanged, crf_input, - &IntegerSlider::SetValue); - connect(crf_input, &IntegerSlider::ValueChanged, crf_slider_, + &IntegerSlider::set_value); + connect(crf_input, &IntegerSlider::value_changed, crf_slider_, &QSlider::setValue); } -int AV1CRFSection::GetValue() const +int AV1CRFSection::get_value() const { return crf_slider_->value(); } diff --git a/app/dialog/export/codec/av1section.h b/app/dialog/export/codec/av1section.h index 6e741799c..664423909 100644 --- a/app/dialog/export/codec/av1section.h +++ b/app/dialog/export/codec/av1section.h @@ -19,8 +19,8 @@ ***/ -#ifndef AV1SECTION_H -#define AV1SECTION_H +#ifndef OAK_AV1SECTION_H +#define OAK_AV1SECTION_H #include #include @@ -37,13 +37,13 @@ class AV1CRFSection : public QWidget { public: AV1CRFSection(int default_crf, QWidget *parent = nullptr); - int GetValue() const; + int get_value() const; - static const int kDefaultAV1CRF = 30; + static const int k_default_a_v1_crf = 30; private: - static const int kMinimumCRF = 0; - static const int kMaximumCRF = 63; + static const int k_minimum_crf = 0; + static const int k_maximum_crf = 63; QSlider *crf_slider_; }; @@ -52,13 +52,13 @@ class AV1Section : public CodecSection { Q_OBJECT public: enum CompressionMethod { - kConstantRateFactor, + k_constant_rate_factor, }; AV1Section(QWidget *parent = nullptr); AV1Section(int default_crf, QWidget *parent); - virtual void AddOpts(EncodingParams *params) override; + virtual void add_opts(EncodingParams *params) override; private: QStackedWidget *compression_method_stack_; @@ -70,4 +70,4 @@ private: } -#endif // AV1SECTION_H +#endif // OAK_AV1SECTION_H diff --git a/app/dialog/export/codec/cineformsection.cpp b/app/dialog/export/codec/cineformsection.cpp index ff3f5cc88..f0dd1aa61 100644 --- a/app/dialog/export/codec/cineformsection.cpp +++ b/app/dialog/export/codec/cineformsection.cpp @@ -79,14 +79,14 @@ CineformSection::CineformSection(QWidget *parent) layout->addWidget(quality_combobox_, row, 1); } -void CineformSection::AddOpts(EncodingParams *params) +void CineformSection::add_opts(EncodingParams *params) { params->set_video_option( QStringLiteral("quality"), QString::number(quality_combobox_->currentIndex())); } -void CineformSection::SetOpts(const EncodingParams *p) +void CineformSection::set_opts(const EncodingParams *p) { quality_combobox_->setCurrentIndex( p->video_option(QStringLiteral("quality")).toInt()); diff --git a/app/dialog/export/codec/cineformsection.h b/app/dialog/export/codec/cineformsection.h index e76b148a9..8318c5928 100644 --- a/app/dialog/export/codec/cineformsection.h +++ b/app/dialog/export/codec/cineformsection.h @@ -19,8 +19,8 @@ ***/ -#ifndef CINEFORMSECTION_H -#define CINEFORMSECTION_H +#ifndef OAK_CINEFORMSECTION_H +#define OAK_CINEFORMSECTION_H #include @@ -34,9 +34,9 @@ class CineformSection : public CodecSection { public: CineformSection(QWidget *parent = nullptr); - virtual void AddOpts(EncodingParams *params) override; + virtual void add_opts(EncodingParams *params) override; - virtual void SetOpts(const EncodingParams *p) override; + virtual void set_opts(const EncodingParams *p) override; private: QComboBox *quality_combobox_; @@ -44,4 +44,4 @@ private: } -#endif // CINEFORMSECTION_H +#endif // OAK_CINEFORMSECTION_H diff --git a/app/dialog/export/codec/codecsection.h b/app/dialog/export/codec/codecsection.h index 029cf53f1..f5decc7f2 100644 --- a/app/dialog/export/codec/codecsection.h +++ b/app/dialog/export/codec/codecsection.h @@ -19,8 +19,8 @@ ***/ -#ifndef CODECSECTION_H -#define CODECSECTION_H +#ifndef OAK_CODECSECTION_H +#define OAK_CODECSECTION_H #include @@ -34,12 +34,12 @@ class CodecSection : public QWidget { public: CodecSection(QWidget *parent = nullptr); - virtual void AddOpts(EncodingParams *params) + virtual void add_opts(EncodingParams *params) { Q_UNUSED(params) } - virtual void SetOpts(const EncodingParams *p) + virtual void set_opts(const EncodingParams *p) { Q_UNUSED(p) } @@ -47,4 +47,4 @@ public: } -#endif // CODECSECTION_H +#endif // OAK_CODECSECTION_H diff --git a/app/dialog/export/codec/codecstack.cpp b/app/dialog/export/codec/codecstack.cpp index 0d5fdcbbe..cf35adf6c 100644 --- a/app/dialog/export/codec/codecstack.cpp +++ b/app/dialog/export/codec/codecstack.cpp @@ -29,17 +29,17 @@ namespace olive CodecStack::CodecStack(QWidget *parent) : super{ parent } { - connect(this, &CodecStack::currentChanged, this, &CodecStack::OnChange); + connect(this, &CodecStack::currentChanged, this, &CodecStack::on_change); } void CodecStack::addWidget(QWidget *widget) { super::addWidget(widget); - OnChange(currentIndex()); + on_change(currentIndex()); } -void CodecStack::OnChange(int index) +void CodecStack::on_change(int index) { for (int i = 0; i < count(); i++) { if (i == index) { diff --git a/app/dialog/export/codec/codecstack.h b/app/dialog/export/codec/codecstack.h index 2b5dcf780..a8b1697a7 100644 --- a/app/dialog/export/codec/codecstack.h +++ b/app/dialog/export/codec/codecstack.h @@ -19,8 +19,8 @@ ***/ -#ifndef CODECSTACK_H -#define CODECSTACK_H +#ifndef OAK_CODECSTACK_H +#define OAK_CODECSTACK_H #include @@ -37,9 +37,9 @@ public: signals: private slots: - void OnChange(int index); + void on_change(int index); }; } -#endif // CODECSTACK_H +#endif // OAK_CODECSTACK_H diff --git a/app/dialog/export/codec/h264section.cpp b/app/dialog/export/codec/h264section.cpp index 6d53de366..3425a8531 100644 --- a/app/dialog/export/codec/h264section.cpp +++ b/app/dialog/export/codec/h264section.cpp @@ -33,7 +33,7 @@ namespace olive { H264Section::H264Section(QWidget *parent) - : H264Section(H264CRFSection::kDefaultH264CRF, parent) + : H264Section(H264CRFSection::k_default_h264_crf, parent) { } @@ -101,7 +101,7 @@ H264Section::H264Section(int default_crf, QWidget *parent) compression_method_stack_, &QStackedWidget::setCurrentIndex); } -void H264Section::AddOpts(EncodingParams *params) +void H264Section::add_opts(EncodingParams *params) { // FIXME: Implement two-pass @@ -113,24 +113,24 @@ void H264Section::AddOpts(EncodingParams *params) params->set_video_option(QStringLiteral("ove_compressionmethod"), QString::number(method)); - if (method == kConstantRateFactor) { + if (method == k_constant_rate_factor) { // Simply set CRF value params->set_video_option(QStringLiteral("crf"), - QString::number(crf_section_->GetValue())); + QString::number(crf_section_->get_value())); } else { int64_t target_rate, max_rate, min_rate; - if (method == kTargetBitRate) { + if (method == k_target_bit_rate) { // Use user-supplied values for the bit rate - target_rate = bitrate_section_->GetTargetBitRate(); + target_rate = bitrate_section_->get_target_bit_rate(); min_rate = 0; - max_rate = bitrate_section_->GetMaximumBitRate(); + max_rate = bitrate_section_->get_maximum_bit_rate(); } else { // Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second) - int64_t target_fs = filesize_section_->GetFileSize(); + int64_t target_fs = filesize_section_->get_file_size(); target_rate = qRound64(static_cast(target_fs) / - params->GetExportLength().toDouble()); + params->get_export_length().to_double()); min_rate = target_rate; max_rate = target_rate; @@ -151,26 +151,26 @@ void H264Section::AddOpts(EncodingParams *params) QString::number(preset_combobox_->currentIndex())); } -void H264Section::SetOpts(const EncodingParams *p) +void H264Section::set_opts(const EncodingParams *p) { CompressionMethod method = static_cast( p->video_option(QStringLiteral("ove_compressionmethod")).toInt()); compression_method_stack_->setCurrentIndex(method); - if (method == kConstantRateFactor) { - crf_section_->SetValue(p->video_option(QStringLiteral("crf")).toInt()); + if (method == k_constant_rate_factor) { + crf_section_->set_value(p->video_option(QStringLiteral("crf")).toInt()); } else { int64_t target_rate = p->video_bit_rate(); int64_t max_rate = p->video_max_bit_rate(); - if (method == kTargetBitRate) { + if (method == k_target_bit_rate) { // Use user-supplied values for the bit rate - bitrate_section_->SetTargetBitRate(target_rate); - bitrate_section_->SetMaximumBitRate(max_rate); + bitrate_section_->set_target_bit_rate(target_rate); + bitrate_section_->set_maximum_bit_rate(max_rate); } else { // Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second) - filesize_section_->SetFileSize( + filesize_section_->set_file_size( p->video_option(QStringLiteral("ove_targetfilesize")) .toLongLong()); } @@ -184,32 +184,32 @@ H264CRFSection::H264CRFSection(int default_crf, QWidget *parent) layout->setContentsMargins(0, 0, 0, 0); crf_slider_ = new QSlider(Qt::Horizontal); - crf_slider_->setMinimum(kMinimumCRF); - crf_slider_->setMaximum(kMaximumCRF); + crf_slider_->setMinimum(k_minimum_crf); + crf_slider_->setMaximum(k_maximum_crf); crf_slider_->setValue(default_crf); layout->addWidget(crf_slider_); IntegerSlider *crf_input = new IntegerSlider(); - crf_input->setMaximumWidth(QtUtils::QFontMetricsWidth( + crf_input->setMaximumWidth(QtUtils::q_font_metrics_width( crf_input->fontMetrics(), QStringLiteral("HHHH"))); - crf_input->SetMinimum(kMinimumCRF); - crf_input->SetMaximum(kMaximumCRF); - crf_input->SetValue(default_crf); + crf_input->set_minimum(k_minimum_crf); + crf_input->set_maximum(k_maximum_crf); + crf_input->set_value(default_crf); crf_input->SetDefaultValue(default_crf); layout->addWidget(crf_input); connect(crf_slider_, &QSlider::valueChanged, crf_input, - &IntegerSlider::SetValue); - connect(crf_input, &IntegerSlider::ValueChanged, crf_slider_, + &IntegerSlider::set_value); + connect(crf_input, &IntegerSlider::value_changed, crf_slider_, &QSlider::setValue); } -int H264CRFSection::GetValue() const +int H264CRFSection::get_value() const { return crf_slider_->value(); } -void H264CRFSection::SetValue(int c) +void H264CRFSection::set_value(int c) { crf_slider_->setValue(c); } @@ -225,7 +225,7 @@ H264BitRateSection::H264BitRateSection(QWidget *parent) layout->addWidget(new QLabel(tr("Target Bit Rate (Mbps):")), row, 0); target_rate_ = new FloatSlider(); - target_rate_->SetMinimum(0); + target_rate_->set_minimum(0); layout->addWidget(target_rate_, row, 1); row++; @@ -233,7 +233,7 @@ H264BitRateSection::H264BitRateSection(QWidget *parent) layout->addWidget(new QLabel(tr("Maximum Bit Rate (Mbps):")), row, 0); max_rate_ = new FloatSlider(); - max_rate_->SetMinimum(0); + max_rate_->set_minimum(0); layout->addWidget(max_rate_, row, 1); row++; @@ -244,28 +244,28 @@ H264BitRateSection::H264BitRateSection(QWidget *parent) layout->addWidget(two_pass_box, row, 1); // Bit rate defaults - target_rate_->SetValue(16.0); - max_rate_->SetValue(32.0); + target_rate_->set_value(16.0); + max_rate_->set_value(32.0); } -int64_t H264BitRateSection::GetTargetBitRate() const +int64_t H264BitRateSection::get_target_bit_rate() const { - return qRound64(target_rate_->GetValue() * 1000000.0); + return qRound64(target_rate_->get_value() * 1000000.0); } -void H264BitRateSection::SetTargetBitRate(int64_t b) +void H264BitRateSection::set_target_bit_rate(int64_t b) { - target_rate_->SetValue(double(b) * 0.000001); + target_rate_->set_value(double(b) * 0.000001); } -int64_t H264BitRateSection::GetMaximumBitRate() const +int64_t H264BitRateSection::get_maximum_bit_rate() const { - return qRound64(max_rate_->GetValue() * 1000000.0); + return qRound64(max_rate_->get_value() * 1000000.0); } -void H264BitRateSection::SetMaximumBitRate(int64_t b) +void H264BitRateSection::set_maximum_bit_rate(int64_t b) { - max_rate_->SetValue(double(b) * 0.000001); + max_rate_->set_value(double(b) * 0.000001); } H264FileSizeSection::H264FileSizeSection(QWidget *parent) @@ -279,7 +279,7 @@ H264FileSizeSection::H264FileSizeSection(QWidget *parent) layout->addWidget(new QLabel(tr("Target File Size (MB):")), row, 0); file_size_ = new FloatSlider(); - file_size_->SetMinimum(0); + file_size_->set_minimum(0); layout->addWidget(file_size_, row, 1); row++; @@ -290,23 +290,23 @@ H264FileSizeSection::H264FileSizeSection(QWidget *parent) layout->addWidget(two_pass_box, row, 1); // File size defaults - file_size_->SetValue(700.0); + file_size_->set_value(700.0); } -int64_t H264FileSizeSection::GetFileSize() const +int64_t H264FileSizeSection::get_file_size() const { // Convert megabytes to BITS - return qRound64(file_size_->GetValue() * 1024.0 * 1024.0 * 8.0); + return qRound64(file_size_->get_value() * 1024.0 * 1024.0 * 8.0); } -void H264FileSizeSection::SetFileSize(int64_t f) +void H264FileSizeSection::set_file_size(int64_t f) { // Convert bits back to megabytes - file_size_->SetValue(double(f) / 8.0 / 1024.0 / 1024.0); + file_size_->set_value(double(f) / 8.0 / 1024.0 / 1024.0); } H265Section::H265Section(QWidget *parent) - : H264Section(H264CRFSection::kDefaultH265CRF, parent) + : H264Section(H264CRFSection::k_default_h265_crf, parent) { } diff --git a/app/dialog/export/codec/h264section.h b/app/dialog/export/codec/h264section.h index 0a00f18f6..b308b6770 100644 --- a/app/dialog/export/codec/h264section.h +++ b/app/dialog/export/codec/h264section.h @@ -19,8 +19,8 @@ ***/ -#ifndef H264SECTION_H -#define H264SECTION_H +#ifndef OAK_H264SECTION_H +#define OAK_H264SECTION_H #include #include @@ -37,15 +37,15 @@ class H264CRFSection : public QWidget { public: H264CRFSection(int default_crf, QWidget *parent = nullptr); - int GetValue() const; - void SetValue(int c); + int get_value() const; + void set_value(int c); - static constexpr int kDefaultH264CRF = 18; - static constexpr int kDefaultH265CRF = 23; + static constexpr int k_default_h264_crf = 18; + static constexpr int k_default_h265_crf = 23; private: - static constexpr int kMinimumCRF = 0; - static constexpr int kMaximumCRF = 51; + static constexpr int k_minimum_crf = 0; + static constexpr int k_maximum_crf = 51; QSlider *crf_slider_; }; @@ -58,14 +58,14 @@ public: /** * @brief Get user-selected target bit rate (returns in BITS) */ - int64_t GetTargetBitRate() const; - void SetTargetBitRate(int64_t b); + int64_t get_target_bit_rate() const; + void set_target_bit_rate(int64_t b); /** * @brief Get user-selected maximum bit rate (returns in BITS) */ - int64_t GetMaximumBitRate() const; - void SetMaximumBitRate(int64_t b); + int64_t get_maximum_bit_rate() const; + void set_maximum_bit_rate(int64_t b); private: FloatSlider *target_rate_; @@ -81,8 +81,8 @@ public: /** * @brief Returns file size in BITS */ - int64_t GetFileSize() const; - void SetFileSize(int64_t f); + int64_t get_file_size() const; + void set_file_size(int64_t f); private: FloatSlider *file_size_; @@ -92,17 +92,17 @@ class H264Section : public CodecSection { Q_OBJECT public: enum CompressionMethod { - kConstantRateFactor, - kTargetBitRate, - kTargetFileSize + k_constant_rate_factor, + k_target_bit_rate, + k_target_file_size }; H264Section(QWidget *parent = nullptr); H264Section(int default_crf, QWidget *parent); - virtual void AddOpts(EncodingParams *params) override; + virtual void add_opts(EncodingParams *params) override; - virtual void SetOpts(const EncodingParams *p) override; + virtual void set_opts(const EncodingParams *p) override; private: QStackedWidget *compression_method_stack_; @@ -124,4 +124,4 @@ public: } -#endif // H264SECTION_H +#endif // OAK_H264SECTION_H diff --git a/app/dialog/export/codec/imagesection.cpp b/app/dialog/export/codec/imagesection.cpp index 3c53daf90..bfeeab957 100644 --- a/app/dialog/export/codec/imagesection.cpp +++ b/app/dialog/export/codec/imagesection.cpp @@ -39,7 +39,7 @@ ImageSection::ImageSection(QWidget *parent) image_sequence_checkbox_ = new QCheckBox(); connect(image_sequence_checkbox_, &QCheckBox::toggled, this, - &ImageSection::ImageSequenceCheckBoxToggled); + &ImageSection::image_sequence_check_box_toggled); layout->addWidget(image_sequence_checkbox_, row, 1); row++; @@ -47,15 +47,15 @@ ImageSection::ImageSection(QWidget *parent) layout->addWidget(new QLabel(tr("Frame to Export:")), row, 0); frame_slider_ = new RationalSlider(); - frame_slider_->SetMinimum(0); - frame_slider_->SetValue(0); - frame_slider_->SetDisplayType(RationalSlider::kTime); - connect(frame_slider_, &RationalSlider::ValueChanged, this, - &ImageSection::TimeChanged); + frame_slider_->set_minimum(0); + frame_slider_->set_value(0); + frame_slider_->set_display_type(RationalSlider::k_time); + connect(frame_slider_, &RationalSlider::value_changed, this, + &ImageSection::time_changed); layout->addWidget(frame_slider_, row, 1); } -void ImageSection::ImageSequenceCheckBoxToggled(bool e) +void ImageSection::image_sequence_check_box_toggled(bool e) { frame_slider_->setEnabled(!e); } diff --git a/app/dialog/export/codec/imagesection.h b/app/dialog/export/codec/imagesection.h index 779f88eed..cdc192133 100644 --- a/app/dialog/export/codec/imagesection.h +++ b/app/dialog/export/codec/imagesection.h @@ -19,8 +19,8 @@ ***/ -#ifndef IMAGESECTION_H -#define IMAGESECTION_H +#ifndef OAK_IMAGESECTION_H +#define OAK_IMAGESECTION_H #include @@ -35,33 +35,33 @@ class ImageSection : public CodecSection { public: ImageSection(QWidget *parent = nullptr); - bool IsImageSequenceChecked() const + bool is_image_sequence_checked() const { return image_sequence_checkbox_->isChecked(); } - void SetImageSequenceChecked(bool e) + void set_image_sequence_checked(bool e) { image_sequence_checkbox_->setChecked(e); } - void SetTimebase(const rational &r) + void set_timebase(const Rational &r) { - frame_slider_->SetTimebase(r); + frame_slider_->set_timebase(r); } - rational GetTime() const + Rational get_time() const { - return frame_slider_->GetValue(); + return frame_slider_->get_value(); } - void SetTime(const rational &t) + void set_time(const Rational &t) { - frame_slider_->SetValue(t); + frame_slider_->set_value(t); } signals: - void TimeChanged(const rational &t); + void time_changed(const Rational &t); private: QCheckBox *image_sequence_checkbox_; @@ -69,9 +69,9 @@ private: RationalSlider *frame_slider_; private slots: - void ImageSequenceCheckBoxToggled(bool e); + void image_sequence_check_box_toggled(bool e); }; } -#endif // IMAGESECTION_H +#endif // OAK_IMAGESECTION_H diff --git a/app/dialog/export/export.cpp b/app/dialog/export/export.cpp index eace5eeed..ad6bd6037 100644 --- a/app/dialog/export/export.cpp +++ b/app/dialog/export/export.cpp @@ -74,10 +74,10 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, QPushButton *file_browse_btn = new QPushButton(); file_browse_btn->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); - file_browse_btn->setIcon(icon::Folder); + file_browse_btn->setIcon(icon::folder); file_browse_btn->setToolTip(tr("Browse for exported file filename")); connect(file_browse_btn, &QPushButton::clicked, this, - &ExportDialog::BrowseFilename); + &ExportDialog::browse_filename); preferences_layout->addWidget(file_browse_btn, row, 3); row++; @@ -86,11 +86,11 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, preset_lbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); preferences_layout->addWidget(preset_lbl, row, 0); preset_combobox_ = new QComboBox(); - LoadPresets(); + load_presets(); connect( preset_combobox_, static_cast(&QComboBox::currentIndexChanged), - this, &ExportDialog::PresetComboBoxChanged); + this, &ExportDialog::preset_combo_box_changed); preferences_layout->addWidget(preset_combobox_, row, 1, 1, 2); /*QPushButton* preset_load_btn = new QPushButton(); @@ -99,15 +99,15 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, preferences_layout->addWidget(preset_load_btn, row, 2);*/ QPushButton *preset_save_btn = new QPushButton(); - preset_save_btn->setIcon(icon::Save); + preset_save_btn->setIcon(icon::save); preset_save_btn->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); preferences_layout->addWidget(preset_save_btn, row, 3); connect(preset_save_btn, &QPushButton::clicked, this, - &ExportDialog::SavePreset); + &ExportDialog::save_preset); row++; - preferences_layout->addWidget(QtUtils::CreateHorizontalLine(), row, 0, 1, + preferences_layout->addWidget(QtUtils::create_horizontal_line(), row, 0, 1, 4); row++; @@ -117,13 +117,13 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, range_combobox_ = new QComboBox(); range_combobox_->addItem(tr("Entire Sequence")); range_combobox_->addItem(tr("In to Out")); - range_combobox_->setEnabled(viewer_node_->GetWorkArea()->enabled()); + range_combobox_->setEnabled(viewer_node_->get_work_area()->enabled()); preferences_layout->addWidget(range_combobox_, row, 1, 1, 3); row++; - preferences_layout->addWidget(QtUtils::CreateHorizontalLine(), row, 0, 1, + preferences_layout->addWidget(QtUtils::create_horizontal_line(), row, 0, 1, 4); row++; @@ -153,20 +153,20 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, color_manager_ = viewer_node_->project()->color_manager(); video_tab_ = new ExportVideoTab(color_manager_); - AddPreferencesTab(video_tab_, tr("Video")); + add_preferences_tab(video_tab_, tr("Video")); // Set video tab time and make connections - connect(viewer_node, &ViewerOutput::PlayheadChanged, video_tab_, - &ExportVideoTab::SetTime); - connect(video_tab_, &ExportVideoTab::TimeChanged, viewer_node, - &ViewerOutput::SetPlayhead); - video_tab_->SetTime(viewer_node->GetPlayhead()); + connect(viewer_node, &ViewerOutput::playhead_changed, video_tab_, + &ExportVideoTab::set_time); + connect(video_tab_, &ExportVideoTab::time_changed, viewer_node, + &ViewerOutput::set_playhead); + video_tab_->set_time(viewer_node->get_playhead()); audio_tab_ = new ExportAudioTab(); - AddPreferencesTab(audio_tab_, tr("Audio")); + add_preferences_tab(audio_tab_, tr("Audio")); subtitle_tab_ = new ExportSubtitlesTab(); - AddPreferencesTab(subtitle_tab_, tr("Subtitles")); + add_preferences_tab(subtitle_tab_, tr("Subtitles")); preferences_layout->addWidget(preferences_tabs_, row, 0, 1, 4); @@ -206,7 +206,7 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, QPushButton *export_btn = new QPushButton(tr("Export")); btn_layout->addWidget(export_btn); connect(export_btn, &QPushButton::clicked, this, - &ExportDialog::StartExport); + &ExportDialog::start_export); QPushButton *cancel_btn = new QPushButton(tr("Cancel")); btn_layout->addWidget(cancel_btn); @@ -220,7 +220,7 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, QVBoxLayout *preview_layout = new QVBoxLayout(preview_area); preview_layout->addWidget(new QLabel(tr("Preview"))); preview_viewer_ = new ViewerWidget(); - preview_viewer_->ruler()->SetMarkerEditingEnabled(false); + preview_viewer_->ruler()->set_marker_editing_enabled(false); preview_viewer_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); preview_layout->addWidget(preview_viewer_); @@ -230,56 +230,56 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, splitter->setSizes({ 1, 99999 }); // Set default filename - SetDefaultFilename(); + set_default_filename(); // Set defaults - previously_selected_format_ = ExportFormat::kFormatMPEG4Video; - connect(format_combobox_, &ExportFormatComboBox::FormatChanged, this, - &ExportDialog::FormatChanged); + previously_selected_format_ = ExportFormat::k_format_mpe_g4_video; + connect(format_combobox_, &ExportFormatComboBox::format_changed, this, + &ExportDialog::format_changed); - VideoParams vp = viewer_node_->GetVideoParams(); + VideoParams vp = viewer_node_->get_video_params(); video_aspect_ratio_ = static_cast(vp.width()) / static_cast(vp.height()); - connect(video_tab_->width_slider(), &IntegerSlider::ValueChanged, this, - &ExportDialog::ResolutionChanged); + connect(video_tab_->width_slider(), &IntegerSlider::value_changed, this, + &ExportDialog::resolution_changed); - connect(video_tab_->height_slider(), &IntegerSlider::ValueChanged, this, - &ExportDialog::ResolutionChanged); + connect(video_tab_->height_slider(), &IntegerSlider::value_changed, this, + &ExportDialog::resolution_changed); connect( video_tab_->scaling_method_combobox(), static_cast(&QComboBox::currentIndexChanged), - this, &ExportDialog::UpdateViewerDimensions); + this, &ExportDialog::update_viewer_dimensions); connect(video_tab_->maintain_aspect_checkbox(), &QCheckBox::toggled, this, - &ExportDialog::ResolutionChanged); + &ExportDialog::resolution_changed); - connect(video_tab_, &ExportVideoTab::ColorSpaceChanged, preview_viewer_, + connect(video_tab_, &ExportVideoTab::color_space_changed, preview_viewer_, static_cast( - &ViewerWidget::SetColorTransform)); - connect(video_tab_, &ExportVideoTab::ImageSequenceCheckBoxChanged, this, - &ExportDialog::ImageSequenceCheckBoxChanged); + &ViewerWidget::set_color_transform)); + connect(video_tab_, &ExportVideoTab::image_sequence_check_box_changed, this, + &ExportDialog::image_sequence_check_box_changed); // We don't check if the codec supports subtitles because we can always export to a sidecar file - bool has_subtitle_tracks = SequenceHasSubtitles(); + bool has_subtitle_tracks = sequence_has_subtitles(); connect(subtitles_enabled_, &QCheckBox::toggled, subtitle_tab_, &QWidget::setEnabled); subtitles_enabled_->setEnabled(has_subtitle_tracks); // If the viewer already has cached params, use them if (!stills_only_mode_ && - viewer_node_->GetLastUsedEncodingParams().IsValid()) { + viewer_node_->get_last_used_encoding_params().is_valid()) { // This will automatically set the param data - QtUtils::SetComboBoxData(preset_combobox_, kPresetLastUsed); + QtUtils::set_combo_box_data(preset_combobox_, k_preset_last_used); } else { - SetDefaults(); + set_defaults(); } // Set viewer to view the node and set its colorspace - preview_viewer_->ConnectViewerNode(viewer_node_); - preview_viewer_->SetColorMenuEnabled(false); - preview_viewer_->SetColorTransform(video_tab_->CurrentOCIOColorSpace()); + preview_viewer_->connect_viewer_node(viewer_node_); + preview_viewer_->set_color_menu_enabled(false); + preview_viewer_->set_color_transform(video_tab_->current_ocio_color_space()); qApp->installEventFilter(this); @@ -294,21 +294,21 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, subtitle_tab_->setEnabled(subtitles_enabled_->isChecked()); } -rational ExportDialog::GetSelectedTimebase() const +Rational ExportDialog::get_selected_timebase() const { - return video_tab_->GetSelectedFrameRate().flipped(); + return video_tab_->get_selected_frame_rate().flipped(); } -void ExportDialog::SetSelectedTimebase(const rational &r) +void ExportDialog::set_selected_timebase(const Rational &r) { - video_tab_->SetSelectedFrameRate(r.flipped()); + video_tab_->set_selected_frame_rate(r.flipped()); } -void ExportDialog::StartExport() +void ExportDialog::start_export() { if (!video_enabled_->isChecked() && !audio_enabled_->isChecked() && !subtitles_enabled_->isChecked()) { - QtUtils::MsgBox( + QtUtils::msg_box( this, QMessageBox::Critical, tr("Invalid parameters"), tr("Video, audio, and subtitles are disabled. There's nothing to export.")); return; @@ -317,12 +317,12 @@ void ExportDialog::StartExport() // Validate if the entered filename contains the correct extension (the extension is necessary // for both FFmpeg and OIIO to determine the output format) QString necessary_ext = QStringLiteral(".%1").arg( - ExportFormat::GetExtension(format_combobox_->GetFormat())); + ExportFormat::get_extension(format_combobox_->get_format())); QString proposed_filename = filename_edit_->text().trimmed(); // If it doesn't, see if the user wants to append it automatically. If not, we don't abort the export. if (!proposed_filename.endsWith(necessary_ext, Qt::CaseInsensitive)) { - if (QtUtils::MsgBox( + if (QtUtils::msg_box( this, QMessageBox::Warning, tr("Invalid filename"), tr("The filename must contain the extension \"%1\". Would you like to append it " "automatically?") @@ -340,8 +340,8 @@ void ExportDialog::StartExport() // If the directory does not exist, try to create it QDir dest_dir(file_info.path()); - if (!FileFunctions::DirectoryIsValid(dest_dir)) { - QtUtils::MsgBox( + if (!FileFunctions::directory_is_valid(dest_dir)) { + QtUtils::msg_box( this, QMessageBox::Critical, tr("Failed to create output directory"), tr("The intended output directory doesn't exist and Oak Video Editor couldn't create it. " @@ -350,22 +350,22 @@ void ExportDialog::StartExport() } // Validate if this is an image sequence and if the filename contains enough digits - if (video_tab_->IsImageSequenceSet()) { + if (video_tab_->is_image_sequence_set()) { // Ensure filename contains digits - if (!Encoder::FilenameContainsDigitPlaceholder(proposed_filename)) { - QtUtils::MsgBox( + if (!Encoder::filename_contains_digit_placeholder(proposed_filename)) { + QtUtils::msg_box( this, QMessageBox::Critical, tr("Invalid filename"), tr("Export is set to an image sequence, but the filename does not have a section for digits " "(formatted as [#####] where the amount of # is the amount of digits).")); return; } - int64_t frame_count = GetExportLengthInTimebaseUnits(); - int64_t needed_digit_count = GetDigitCount(frame_count); + int64_t frame_count = get_export_length_in_timebase_units(); + int64_t needed_digit_count = get_digit_count(frame_count); int current_digit_count = - Encoder::GetImageSequencePlaceholderDigitCount(proposed_filename); + Encoder::get_image_sequence_placeholder_digit_count(proposed_filename); if (current_digit_count < needed_digit_count) { - QtUtils::MsgBox( + QtUtils::msg_box( this, QMessageBox::Critical, tr("Invalid filename"), tr("Filename doesn't contain enough digits for the amount of frames " "this export will need (need %1 for %n frame(s)).", @@ -377,7 +377,7 @@ void ExportDialog::StartExport() // Validate if the file exists and whether the user wishes to overwrite it if (file_info.exists()) { - if (QtUtils::MsgBox( + if (QtUtils::msg_box( this, QMessageBox::Warning, tr("Confirm Overwrite"), tr("The file \"%1\" already exists. Do you want to overwrite it?") .arg(proposed_filename), @@ -388,50 +388,50 @@ void ExportDialog::StartExport() // Validate video resolution if (video_enabled_->isChecked() && - (video_tab_->GetSelectedCodec() == ExportCodec::kCodecH264 || - video_tab_->GetSelectedCodec() == ExportCodec::kCodecH265) && - (video_tab_->width_slider()->GetValue() % 2 != 0 || - video_tab_->height_slider()->GetValue() % 2 != 0)) { - QtUtils::MsgBox(this, QMessageBox::Critical, tr("Invalid Parameters"), + (video_tab_->get_selected_codec() == ExportCodec::k_codec_h264 || + video_tab_->get_selected_codec() == ExportCodec::k_codec_h265) && + (video_tab_->width_slider()->get_value() % 2 != 0 || + video_tab_->height_slider()->get_value() % 2 != 0)) { + QtUtils::msg_box(this, QMessageBox::Critical, tr("Invalid Parameters"), tr("Width and height must be multiples of 2.")); return; } ExportTask *task = - new ExportTask(viewer_node_, color_manager_, GenerateParams()); + new ExportTask(viewer_node_, color_manager_, generate_params()); if (export_bkg_box_->isChecked()) { // Send to TaskManager to export in background - TaskManager::instance()->AddTask(task); + TaskManager::instance()->add_task(task); this->accept(); } else { // Use modal dialog box TaskDialog *td = new TaskDialog(task, tr("Export"), this); - connect(td, &TaskDialog::TaskSucceeded, this, - &ExportDialog::ExportFinished); + connect(td, &TaskDialog::task_succeeded, this, + &ExportDialog::export_finished); td->open(); } } -void ExportDialog::ExportFinished() +void ExportDialog::export_finished() { TaskDialog *td = static_cast(sender()); - if (td->GetTask()->IsCancelled()) { + if (td->get_task()->is_cancelled()) { // If this task was cancelled, we stay open so the user can potentially queue another export } else { // Accept this dialog and close if (import_file_after_export_->isEnabled() && import_file_after_export_->isChecked()) { QString filename = filename_edit_->text().trimmed(); - emit RequestImportFile(filename); + emit request_import_file(filename); } this->accept(); } } -void ExportDialog::ImageSequenceCheckBoxChanged(bool e) +void ExportDialog::image_sequence_check_box_changed(bool e) { QFileInfo current_fileinfo(filename_edit_->text()); @@ -439,11 +439,11 @@ void ExportDialog::ImageSequenceCheckBoxChanged(bool e) QString suffix = current_fileinfo.suffix(); if (e) { - if (!Encoder::FilenameContainsDigitPlaceholder(basename)) { + if (!Encoder::filename_contains_digit_placeholder(basename)) { basename.append(QStringLiteral("_[#####]")); } } else { - basename = Encoder::FilenameRemoveDigitPlaceholder(basename); + basename = Encoder::filename_remove_digit_placeholder(basename); } // Set filename @@ -454,16 +454,16 @@ void ExportDialog::ImageSequenceCheckBoxChanged(bool e) filename_edit_->setText(current_fileinfo.dir().filePath(basename)); } -void ExportDialog::SavePreset() +void ExportDialog::save_preset() { - ExportSavePresetDialog d(GenerateParams(), this); + ExportSavePresetDialog d(generate_params(), this); if (d.exec() == QDialog::Accepted) { - LoadPresets(); - preset_combobox_->setCurrentText(d.GetSelectedPresetName()); + load_presets(); + preset_combobox_->setCurrentText(d.get_selected_preset_name()); } } -void ExportDialog::PresetComboBoxChanged() +void ExportDialog::preset_combo_box_changed() { if (loading_presets_) { return; @@ -472,16 +472,16 @@ void ExportDialog::PresetComboBoxChanged() QComboBox *c = static_cast(sender()); int preset_number = c->currentData().toInt(); - if (preset_number == kPresetDefault) { - SetDefaults(); - } else if (preset_number == kPresetLastUsed) { - SetParams(viewer_node_->GetLastUsedEncodingParams()); + if (preset_number == k_preset_default) { + set_defaults(); + } else if (preset_number == k_preset_last_used) { + set_params(viewer_node_->get_last_used_encoding_params()); } else { - SetParams(presets_.at(preset_number)); + set_params(presets_.at(preset_number)); } } -void ExportDialog::AddPreferencesTab(QWidget *inner_widget, +void ExportDialog::add_preferences_tab(QWidget *inner_widget, const QString &title) { QScrollArea *scroll_area = new QScrollArea(); @@ -490,14 +490,14 @@ void ExportDialog::AddPreferencesTab(QWidget *inner_widget, preferences_tabs_->addTab(scroll_area, title); } -void ExportDialog::BrowseFilename() +void ExportDialog::browse_filename() { - ExportFormat::Format f = format_combobox_->GetFormat(); + ExportFormat::Format f = format_combobox_->get_format(); QString browsed_fn = QFileDialog::getSaveFileName( this, "", filename_edit_->text().trimmed(), QStringLiteral("%1 (*.%2)") - .arg(ExportFormat::GetName(f), ExportFormat::GetExtension(f)), + .arg(ExportFormat::get_name(f), ExportFormat::get_extension(f)), nullptr, // We don't confirm overwrite here because we do it later @@ -508,12 +508,12 @@ void ExportDialog::BrowseFilename() } } -void ExportDialog::FormatChanged(ExportFormat::Format current_format) +void ExportDialog::format_changed(ExportFormat::Format current_format) { QString current_filename = filename_edit_->text().trimmed(); QString previously_selected_ext = - ExportFormat::GetExtension(previously_selected_format_); - QString currently_selected_ext = ExportFormat::GetExtension(current_format); + ExportFormat::get_extension(previously_selected_format_); + QString currently_selected_ext = ExportFormat::get_extension(current_format); // If the previous extension was added, remove it if (current_filename.endsWith(previously_selected_ext, @@ -530,72 +530,72 @@ void ExportDialog::FormatChanged(ExportFormat::Format current_format) previously_selected_format_ = current_format; // Update video and audio comboboxes - bool has_video_codecs = video_tab_->SetFormat(current_format); + bool has_video_codecs = video_tab_->set_format(current_format); video_enabled_->setChecked(has_video_codecs); video_enabled_->setEnabled(has_video_codecs); - bool has_audio_codecs = audio_tab_->SetFormat(current_format); + bool has_audio_codecs = audio_tab_->set_format(current_format); audio_enabled_->setChecked(has_audio_codecs); audio_enabled_->setEnabled(has_audio_codecs); if (subtitles_enabled_->isEnabled()) { - subtitle_tab_->SetFormat(current_format); + subtitle_tab_->set_format(current_format); } } -void ExportDialog::ResolutionChanged() +void ExportDialog::resolution_changed() { if (video_tab_->maintain_aspect_checkbox()->isChecked()) { // Keep aspect ratio maintained if (sender() == video_tab_->height_slider()) { // Convert height to float - double new_width = video_tab_->height_slider()->GetValue(); + double new_width = video_tab_->height_slider()->get_value(); // Generate width from aspect ratio new_width *= video_aspect_ratio_; // Align to even number and set - video_tab_->width_slider()->SetValue(new_width); + video_tab_->width_slider()->set_value(new_width); } else { // Convert width to float - double new_height = video_tab_->width_slider()->GetValue(); + double new_height = video_tab_->width_slider()->get_value(); // Generate height from aspect ratio new_height /= video_aspect_ratio_; // Align to even number and set - video_tab_->height_slider()->SetValue(new_height); + video_tab_->height_slider()->set_value(new_height); } } - UpdateViewerDimensions(); + update_viewer_dimensions(); } -void ExportDialog::LoadPresets() +void ExportDialog::load_presets() { loading_presets_ = true; preset_combobox_->clear(); presets_.clear(); - preset_combobox_->addItem(tr("Default"), kPresetDefault); + preset_combobox_->addItem(tr("Default"), k_preset_default); - if (viewer_node_->GetLastUsedEncodingParams().IsValid()) { - preset_combobox_->addItem(tr("Last Used"), kPresetLastUsed); + if (viewer_node_->get_last_used_encoding_params().is_valid()) { + preset_combobox_->addItem(tr("Last Used"), k_preset_last_used); } preset_combobox_->insertSeparator(preset_combobox_->count()); - QStringList l = EncodingParams::GetListOfPresets(); + QStringList l = EncodingParams::get_list_of_presets(); presets_.reserve(l.size()); for (const QString &preset : l) { EncodingParams p; - QFile f(EncodingParams::GetPresetPath().filePath(preset)); + QFile f(EncodingParams::get_preset_path().filePath(preset)); if (f.open(QFile::ReadOnly)) { - if (p.Load(&f)) { + if (p.load(&f)) { preset_combobox_->addItem(preset, int(presets_.size())); presets_.push_back(p); } @@ -606,7 +606,7 @@ void ExportDialog::LoadPresets() loading_presets_ = false; } -void ExportDialog::SetDefaultFilename() +void ExportDialog::set_default_filename() { Project *p = viewer_node_->project(); @@ -619,16 +619,16 @@ void ExportDialog::SetDefaultFilename() doc_location = QFileInfo(p->filename()).dir(); } - QString file_location = doc_location.filePath(viewer_node_->GetLabel()); + QString file_location = doc_location.filePath(viewer_node_->get_label()); filename_edit_->setText(file_location); } -bool ExportDialog::SequenceHasSubtitles() const +bool ExportDialog::sequence_has_subtitles() const { if (Sequence *s = dynamic_cast(viewer_node_)) { - TrackList *tl = s->track_list(Track::kSubtitle); - for (Track *t : tl->GetTracks()) { - if (!t->IsMuted() && !t->Blocks().empty()) { + TrackList *tl = s->track_list(Track::k_subtitle); + for (Track *t : tl->get_tracks()) { + if (!t->is_muted() && !t->blocks().empty()) { return true; } } @@ -637,67 +637,67 @@ bool ExportDialog::SequenceHasSubtitles() const return false; } -void ExportDialog::SetDefaults() +void ExportDialog::set_defaults() { if (!stills_only_mode_) { - format_combobox_->SetFormat(ExportFormat::kFormatMPEG4Video); + format_combobox_->set_format(ExportFormat::k_format_mpe_g4_video); } else { - format_combobox_->SetFormat(ExportFormat::kFormatPNG); + format_combobox_->set_format(ExportFormat::k_format_png); } - FormatChanged(format_combobox_->GetFormat()); + format_changed(format_combobox_->get_format()); - VideoParams vp = viewer_node_->GetVideoParams(); - AudioParams ap = viewer_node_->GetAudioParams(); + VideoParams vp = viewer_node_->get_video_params(); + AudioParams ap = viewer_node_->get_audio_params(); - video_tab_->width_slider()->SetValue(vp.width()); + video_tab_->width_slider()->set_value(vp.width()); video_tab_->width_slider()->SetDefaultValue(vp.width()); - video_tab_->height_slider()->SetValue(vp.height()); + video_tab_->height_slider()->set_value(vp.height()); video_tab_->height_slider()->SetDefaultValue(vp.height()); - video_tab_->SetSelectedFrameRate(vp.frame_rate()); - video_tab_->pixel_aspect_combobox()->SetPixelAspectRatio( + video_tab_->set_selected_frame_rate(vp.frame_rate()); + video_tab_->pixel_aspect_combobox()->set_pixel_aspect_ratio( vp.pixel_aspect_ratio()); - video_tab_->pixel_format_field()->SetPixelFormat( + video_tab_->pixel_format_field()->set_pixel_format( static_cast( - OLIVE_CONFIG("OnlinePixelFormat").toInt())); - video_tab_->interlaced_combobox()->SetInterlaceMode(vp.interlacing()); - audio_tab_->sample_rate_combobox()->SetSampleRate(ap.sample_rate()); - audio_tab_->sample_format_combobox()->SetAttemptToRestoreFormat(false); - audio_tab_->channel_layout_combobox()->SetChannelLayout( + OAK_CONFIG("OnlinePixelFormat").toInt())); + video_tab_->interlaced_combobox()->set_interlace_mode(vp.interlacing()); + audio_tab_->sample_rate_combobox()->set_sample_rate(ap.sample_rate()); + audio_tab_->sample_format_combobox()->set_attempt_to_restore_format(false); + audio_tab_->channel_layout_combobox()->set_channel_layout( ap.channel_layout()); - subtitles_enabled_->setChecked(SequenceHasSubtitles()); - subtitle_tab_->SetSidecarFormat(ExportFormat::kFormatSRT); + subtitles_enabled_->setChecked(sequence_has_subtitles()); + subtitle_tab_->set_sidecar_format(ExportFormat::k_format_srt); } -EncodingParams ExportDialog::GenerateParams() const +EncodingParams ExportDialog::generate_params() const { VideoParams video_render_params( - static_cast(video_tab_->width_slider()->GetValue()), - static_cast(video_tab_->height_slider()->GetValue()), - GetSelectedTimebase(), - video_tab_->pixel_format_field()->GetPixelFormat(), - VideoParams::kInternalChannelCount, - video_tab_->pixel_aspect_combobox()->GetPixelAspectRatio(), - video_tab_->interlaced_combobox()->GetInterlaceMode(), 1); + static_cast(video_tab_->width_slider()->get_value()), + static_cast(video_tab_->height_slider()->get_value()), + get_selected_timebase(), + video_tab_->pixel_format_field()->get_pixel_format(), + VideoParams::k_internal_channel_count, + video_tab_->pixel_aspect_combobox()->get_pixel_aspect_ratio(), + video_tab_->interlaced_combobox()->get_interlace_mode(), 1); AudioParams audio_render_params( - audio_tab_->sample_rate_combobox()->GetSampleRate(), - audio_tab_->channel_layout_combobox()->GetChannelLayout(), - audio_tab_->sample_format_combobox()->GetSampleFormat()); + audio_tab_->sample_rate_combobox()->get_sample_rate(), + audio_tab_->channel_layout_combobox()->get_channel_layout(), + audio_tab_->sample_format_combobox()->get_sample_format()); EncodingParams params; - params.set_format(format_combobox_->GetFormat()); - params.SetFilename(filename_edit_->text().trimmed()); - params.SetExportLength(viewer_node_->GetLength()); + params.set_format(format_combobox_->get_format()); + params.set_filename(filename_edit_->text().trimmed()); + params.set_export_length(viewer_node_->get_length()); - if (ExportCodec::IsCodecAStillImage(video_tab_->GetSelectedCodec()) && - !video_tab_->IsImageSequenceSet()) { + if (ExportCodec::is_codec_a_still_image(video_tab_->get_selected_codec()) && + !video_tab_->is_image_sequence_set()) { // Exporting as image without exporting image sequence, only export one frame - rational export_time = video_tab_->GetStillImageTime(); + Rational export_time = video_tab_->get_still_image_time(); params.set_custom_range( - TimeRange(export_time, export_time + GetSelectedTimebase())); - } else if (range_combobox_->currentIndex() == kRangeInToOut) { + TimeRange(export_time, export_time + get_selected_timebase())); + } else if (range_combobox_->currentIndex() == k_range_in_to_out) { // Assume if this combobox is enabled, workarea is enabled - a check that we make in this dialog's constructor - params.set_custom_range(viewer_node_->GetWorkArea()->range()); + params.set_custom_range(viewer_node_->get_work_area()->range()); } if (video_tab_->scaling_method_combobox()->isEnabled()) { @@ -707,109 +707,109 @@ EncodingParams ExportDialog::GenerateParams() const } if (video_enabled_->isChecked()) { - ExportCodec::Codec video_codec = video_tab_->GetSelectedCodec(); + ExportCodec::Codec video_codec = video_tab_->get_selected_codec(); video_render_params.set_color_range(video_tab_->color_range()); - params.EnableVideo(video_render_params, video_codec); + params.enable_video(video_render_params, video_codec); params.set_video_threads(video_tab_->threads()); if (video_tab_->isVisible()) { - video_tab_->GetCodecSection()->AddOpts(¶ms); + video_tab_->get_codec_section()->add_opts(¶ms); } - params.set_color_transform(video_tab_->CurrentOCIOColorSpace()); + params.set_color_transform(video_tab_->current_ocio_color_space()); params.set_video_pix_fmt(video_tab_->pix_fmt()); - params.set_video_is_image_sequence(video_tab_->IsImageSequenceSet()); + params.set_video_is_image_sequence(video_tab_->is_image_sequence_set()); } if (audio_enabled_->isChecked()) { - ExportCodec::Codec audio_codec = audio_tab_->GetCodec(); - params.EnableAudio(audio_render_params, audio_codec); + ExportCodec::Codec audio_codec = audio_tab_->get_codec(); + params.enable_audio(audio_render_params, audio_codec); - params.set_audio_bit_rate(audio_tab_->bit_rate_slider()->GetValue() * + params.set_audio_bit_rate(audio_tab_->bit_rate_slider()->get_value() * 1000); } if (subtitles_enabled_->isEnabled() && subtitles_enabled_->isChecked()) { - if (!subtitle_tab_->GetSidecarEnabled()) { + if (!subtitle_tab_->get_sidecar_enabled()) { // Export subtitles embedded in container - params.EnableSubtitles(subtitle_tab_->GetSubtitleCodec()); + params.enable_subtitles(subtitle_tab_->get_subtitle_codec()); } else { // Export subtitles to a sidecar file - params.EnableSidecarSubtitles(subtitle_tab_->GetSidecarFormat(), - subtitle_tab_->GetSubtitleCodec()); + params.enable_sidecar_subtitles(subtitle_tab_->get_sidecar_format(), + subtitle_tab_->get_subtitle_codec()); } } return params; } -void ExportDialog::SetParams(const EncodingParams &e) +void ExportDialog::set_params(const EncodingParams &e) { - format_combobox_->SetFormat(e.format()); - FormatChanged(format_combobox_->GetFormat()); + format_combobox_->set_format(e.format()); + format_changed(format_combobox_->get_format()); - if (e.has_custom_range() && viewer_node_->GetWorkArea()->enabled()) { - range_combobox_->setCurrentIndex(kRangeInToOut); + if (e.has_custom_range() && viewer_node_->get_work_area()->enabled()) { + range_combobox_->setCurrentIndex(k_range_in_to_out); } - QtUtils::SetComboBoxData(video_tab_->scaling_method_combobox(), + QtUtils::set_combo_box_data(video_tab_->scaling_method_combobox(), e.video_scaling_method()); video_enabled_->setChecked(e.video_enabled()); if (e.video_enabled()) { - video_tab_->width_slider()->SetValue(e.video_params().width()); - video_tab_->height_slider()->SetValue(e.video_params().height()); - SetSelectedTimebase(e.video_params().time_base()); - video_tab_->pixel_format_field()->SetPixelFormat( + video_tab_->width_slider()->set_value(e.video_params().width()); + video_tab_->height_slider()->set_value(e.video_params().height()); + set_selected_timebase(e.video_params().time_base()); + video_tab_->pixel_format_field()->set_pixel_format( e.video_params().format()); - video_tab_->pixel_aspect_combobox()->SetPixelAspectRatio( + video_tab_->pixel_aspect_combobox()->set_pixel_aspect_ratio( e.video_params().pixel_aspect_ratio()); - video_tab_->interlaced_combobox()->SetInterlaceMode( + video_tab_->interlaced_combobox()->set_interlace_mode( e.video_params().interlacing()); - video_tab_->SetSelectedCodec(e.video_codec()); + video_tab_->set_selected_codec(e.video_codec()); - video_tab_->SetColorRange(e.video_params().color_range()); + video_tab_->set_color_range(e.video_params().color_range()); - video_tab_->SetThreads(e.video_threads()); + video_tab_->set_threads(e.video_threads()); if (video_tab_->isVisible()) { - video_tab_->GetCodecSection()->SetOpts(&e); + video_tab_->get_codec_section()->set_opts(&e); } - video_tab_->SetOCIOColorSpace(e.color_transform().output()); + video_tab_->set_ocio_color_space(e.color_transform().output()); - video_tab_->SetPixFmt(e.video_pix_fmt()); + video_tab_->set_pix_fmt(e.video_pix_fmt()); - video_tab_->SetImageSequence(e.video_is_image_sequence()); + video_tab_->set_image_sequence(e.video_is_image_sequence()); } audio_enabled_->setChecked(e.audio_enabled()); if (e.audio_enabled()) { - audio_tab_->sample_rate_combobox()->SetSampleRate( + audio_tab_->sample_rate_combobox()->set_sample_rate( e.audio_params().sample_rate()); - audio_tab_->channel_layout_combobox()->SetChannelLayout( + audio_tab_->channel_layout_combobox()->set_channel_layout( e.audio_params().channel_layout()); - audio_tab_->sample_format_combobox()->SetSampleFormat( + audio_tab_->sample_format_combobox()->set_sample_format( e.audio_params().format()); - audio_tab_->SetCodec(e.audio_codec()); + audio_tab_->set_codec(e.audio_codec()); - audio_tab_->bit_rate_slider()->SetValue(e.audio_bit_rate() / 1000); + audio_tab_->bit_rate_slider()->set_value(e.audio_bit_rate() / 1000); } if (subtitles_enabled_->isEnabled()) { subtitles_enabled_->setChecked(e.subtitles_enabled()); - subtitle_tab_->SetSidecarEnabled(e.subtitles_are_sidecar()); + subtitle_tab_->set_sidecar_enabled(e.subtitles_are_sidecar()); if (e.subtitles_enabled()) { - subtitle_tab_->SetSubtitleCodec(e.subtitles_codec()); + subtitle_tab_->set_subtitle_codec(e.subtitles_codec()); if (e.subtitles_are_sidecar()) { - subtitle_tab_->SetSidecarFormat(e.subtitle_sidecar_fmt()); + subtitle_tab_->set_sidecar_format(e.subtitle_sidecar_fmt()); } } } @@ -833,46 +833,46 @@ bool ExportDialog::eventFilter(QObject *o, QEvent *e) void ExportDialog::done(int r) { - preview_viewer_->ConnectViewerNode(nullptr); + preview_viewer_->connect_viewer_node(nullptr); if (!stills_only_mode_) { - viewer_node_->SetLastUsedEncodingParams(GenerateParams()); + viewer_node_->set_last_used_encoding_params(generate_params()); } super::done(r); } -rational ExportDialog::GetExportLength() const +Rational ExportDialog::get_export_length() const { - if (range_combobox_->currentIndex() == kRangeInToOut) { - return viewer_node_->GetWorkArea()->range().length(); + if (range_combobox_->currentIndex() == k_range_in_to_out) { + return viewer_node_->get_work_area()->range().length(); } else { - return viewer_node_->GetLength(); + return viewer_node_->get_length(); } } -int64_t ExportDialog::GetExportLengthInTimebaseUnits() const +int64_t ExportDialog::get_export_length_in_timebase_units() const { - return Timecode::time_to_timestamp(GetExportLength(), - GetSelectedTimebase()); + return Timecode::time_to_timestamp(get_export_length(), + get_selected_timebase()); } -void ExportDialog::UpdateViewerDimensions() +void ExportDialog::update_viewer_dimensions() { - preview_viewer_->SetViewerResolution( - static_cast(video_tab_->width_slider()->GetValue()), - static_cast(video_tab_->height_slider()->GetValue())); + preview_viewer_->set_viewer_resolution( + static_cast(video_tab_->width_slider()->get_value()), + static_cast(video_tab_->height_slider()->get_value())); - VideoParams vp = viewer_node_->GetVideoParams(); + VideoParams vp = viewer_node_->get_video_params(); - QMatrix4x4 transform = EncodingParams::GenerateMatrix( + QMatrix4x4 transform = EncodingParams::generate_matrix( static_cast( video_tab_->scaling_method_combobox()->currentData().toInt()), vp.width(), vp.height(), - static_cast(video_tab_->width_slider()->GetValue()), - static_cast(video_tab_->height_slider()->GetValue())); + static_cast(video_tab_->width_slider()->get_value()), + static_cast(video_tab_->height_slider()->get_value())); - preview_viewer_->SetMatrix(transform); + preview_viewer_->set_matrix(transform); } } diff --git a/app/dialog/export/export.h b/app/dialog/export/export.h index 8bb30ff3b..912a8d004 100644 --- a/app/dialog/export/export.h +++ b/app/dialog/export/export.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTDIALOG_H -#define EXPORTDIALOG_H +#ifndef OAK_EXPORTDIALOG_H +#define OAK_EXPORTDIALOG_H #include #include @@ -51,11 +51,11 @@ public: { } - rational GetSelectedTimebase() const; - void SetSelectedTimebase(const rational &r); + Rational get_selected_timebase() const; + void set_selected_timebase(const Rational &r); - EncodingParams GenerateParams() const; - void SetParams(const EncodingParams &e); + EncodingParams generate_params() const; + void set_params(const EncodingParams &e); virtual bool eventFilter(QObject *o, QEvent *e) override; @@ -63,30 +63,30 @@ public slots: virtual void done(int r) override; signals: - void RequestImportFile(const QString &s); + void request_import_file(const QString &s); private: - void AddPreferencesTab(QWidget *inner_widget, const QString &title); + void add_preferences_tab(QWidget *inner_widget, const QString &title); - void LoadPresets(); - void SetDefaultFilename(); + void load_presets(); + void set_default_filename(); - bool SequenceHasSubtitles() const; + bool sequence_has_subtitles() const; - void SetDefaults(); + void set_defaults(); ViewerOutput *viewer_node_; ExportFormat::Format previously_selected_format_; - rational GetExportLength() const; - int64_t GetExportLengthInTimebaseUnits() const; + Rational get_export_length() const; + int64_t get_export_length_in_timebase_units() const; - enum RangeSelection { kRangeEntireSequence, kRangeInToOut }; + enum RangeSelection { k_range_entire_sequence, k_range_in_to_out }; enum AutoPreset { - kPresetDefault = -1, - kPresetLastUsed = -2, + k_preset_default = -1, + k_preset_last_used = -2, }; QTabWidget *preferences_tabs_; @@ -120,25 +120,25 @@ private: bool loading_presets_; private slots: - void BrowseFilename(); + void browse_filename(); - void FormatChanged(ExportFormat::Format current_format); + void format_changed(ExportFormat::Format current_format); - void ResolutionChanged(); + void resolution_changed(); - void UpdateViewerDimensions(); + void update_viewer_dimensions(); - void StartExport(); + void start_export(); - void ExportFinished(); + void export_finished(); - void ImageSequenceCheckBoxChanged(bool e); + void image_sequence_check_box_changed(bool e); - void SavePreset(); + void save_preset(); - void PresetComboBoxChanged(); + void preset_combo_box_changed(); }; } -#endif // EXPORTDIALOG_H +#endif // OAK_EXPORTDIALOG_H diff --git a/app/dialog/export/exportadvancedvideodialog.cpp b/app/dialog/export/exportadvancedvideodialog.cpp index c3b5f245a..2102d188d 100644 --- a/app/dialog/export/exportadvancedvideodialog.cpp +++ b/app/dialog/export/exportadvancedvideodialog.cpp @@ -73,9 +73,9 @@ ExportAdvancedVideoDialog::ExportAdvancedVideoDialog( performance_layout->addWidget(new QLabel(tr("Threads:")), row, 0); thread_slider_ = new IntegerSlider(); - thread_slider_->SetMinimum(0); + thread_slider_->set_minimum(0); thread_slider_->SetDefaultValue(0); - thread_slider_->InsertLabelSubstitution(0, tr("Auto")); + thread_slider_->insert_label_substitution(0, tr("Auto")); performance_layout->addWidget(thread_slider_, row, 1); row++; diff --git a/app/dialog/export/exportadvancedvideodialog.h b/app/dialog/export/exportadvancedvideodialog.h index 3f4e216d3..6088cc649 100644 --- a/app/dialog/export/exportadvancedvideodialog.h +++ b/app/dialog/export/exportadvancedvideodialog.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef EXPORTADVANCEDVIDEODIALOG_H -#define EXPORTADVANCEDVIDEODIALOG_H +#ifndef OAK_EXPORTADVANCEDVIDEODIALOG_H +#define OAK_EXPORTADVANCEDVIDEODIALOG_H #include #include @@ -36,12 +36,12 @@ public: int threads() const { - return static_cast(thread_slider_->GetValue()); + return static_cast(thread_slider_->get_value()); } void set_threads(int t) { - thread_slider_->SetValue(t); + thread_slider_->set_value(t); } QString pix_fmt() const @@ -75,4 +75,4 @@ private: } -#endif // EXPORTADVANCEDVIDEODIALOG_H +#endif // OAK_EXPORTADVANCEDVIDEODIALOG_H diff --git a/app/dialog/export/exportaudiotab.cpp b/app/dialog/export/exportaudiotab.cpp index c8a6a056f..23857cb7a 100644 --- a/app/dialog/export/exportaudiotab.cpp +++ b/app/dialog/export/exportaudiotab.cpp @@ -27,7 +27,7 @@ namespace olive { -const int ExportAudioTab::kDefaultBitRate = 320; +const int ExportAudioTab::k_default_bit_rate = 320; ExportAudioTab::ExportAudioTab(QWidget *parent) : QWidget(parent) @@ -45,11 +45,11 @@ ExportAudioTab::ExportAudioTab(QWidget *parent) connect( codec_combobox_, static_cast(&QComboBox::currentIndexChanged), - this, &ExportAudioTab::UpdateSampleFormats); + this, &ExportAudioTab::update_sample_formats); connect( codec_combobox_, static_cast(&QComboBox::currentIndexChanged), - this, &ExportAudioTab::UpdateBitRateEnabled); + this, &ExportAudioTab::update_bit_rate_enabled); layout->addWidget(codec_combobox_, row, 1); row++; @@ -78,48 +78,48 @@ ExportAudioTab::ExportAudioTab(QWidget *parent) layout->addWidget(new QLabel(tr("Bit Rate:")), row, 0); bit_rate_slider_ = new IntegerSlider(); - bit_rate_slider_->SetMinimum(32); - bit_rate_slider_->SetMaximum(320); - bit_rate_slider_->SetValue(kDefaultBitRate); - bit_rate_slider_->SetFormat(tr("%1 kbps")); + bit_rate_slider_->set_minimum(32); + bit_rate_slider_->set_maximum(320); + bit_rate_slider_->set_value(k_default_bit_rate); + bit_rate_slider_->set_format(tr("%1 kbps")); layout->addWidget(bit_rate_slider_, row, 1); outer_layout->addStretch(); } -int ExportAudioTab::SetFormat(ExportFormat::Format format) +int ExportAudioTab::set_format(ExportFormat::Format format) { - QList acodecs = ExportFormat::GetAudioCodecs(format); + QList acodecs = ExportFormat::get_audio_codecs(format); setEnabled(!acodecs.isEmpty()); codec_combobox_->blockSignals(true); codec_combobox_->clear(); foreach (ExportCodec::Codec acodec, acodecs) { - codec_combobox_->addItem(ExportCodec::GetCodecName(acodec), acodec); + codec_combobox_->addItem(ExportCodec::get_codec_name(acodec), acodec); } codec_combobox_->blockSignals(false); fmt_ = format; - UpdateSampleFormats(); - UpdateBitRateEnabled(); + update_sample_formats(); + update_bit_rate_enabled(); return acodecs.size(); } -void ExportAudioTab::UpdateSampleFormats() +void ExportAudioTab::update_sample_formats() { - auto fmts = ExportFormat::GetSampleFormatsForCodec(fmt_, GetCodec()); - sample_format_combobox_->SetAvailableFormats(fmts); + auto fmts = ExportFormat::get_sample_formats_for_codec(fmt_, get_codec()); + sample_format_combobox_->set_available_formats(fmts); } -void ExportAudioTab::UpdateBitRateEnabled() +void ExportAudioTab::update_bit_rate_enabled() { - bool uses_bitrate = !ExportCodec::IsCodecLossless(GetCodec()); + bool uses_bitrate = !ExportCodec::is_codec_lossless(get_codec()); bit_rate_slider_->setEnabled(uses_bitrate); if (!uses_bitrate) { - bit_rate_slider_->SetTristate(); + bit_rate_slider_->set_tristate(); } else { - bit_rate_slider_->SetValue(kDefaultBitRate); + bit_rate_slider_->set_value(k_default_bit_rate); } } diff --git a/app/dialog/export/exportaudiotab.h b/app/dialog/export/exportaudiotab.h index 56d10cb9e..36f9e1fa4 100644 --- a/app/dialog/export/exportaudiotab.h +++ b/app/dialog/export/exportaudiotab.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTAUDIOTAB_H -#define EXPORTAUDIOTAB_H +#ifndef OAK_EXPORTAUDIOTAB_H +#define OAK_EXPORTAUDIOTAB_H #include #include @@ -38,13 +38,13 @@ class ExportAudioTab : public QWidget { public: ExportAudioTab(QWidget *parent = nullptr); - ExportCodec::Codec GetCodec() const + ExportCodec::Codec get_codec() const { return static_cast( codec_combobox_->currentData().toInt()); } - void SetCodec(ExportCodec::Codec c) + void set_codec(ExportCodec::Codec c) { for (int i = 0; i < codec_combobox_->count(); i++) { if (codec_combobox_->itemData(i) == c) { @@ -75,7 +75,7 @@ public: } public slots: - int SetFormat(ExportFormat::Format format); + int set_format(ExportFormat::Format format); private: ExportFormat::Format fmt_; @@ -85,14 +85,14 @@ private: SampleFormatComboBox *sample_format_combobox_; IntegerSlider *bit_rate_slider_; - static const int kDefaultBitRate; + static const int k_default_bit_rate; private slots: - void UpdateSampleFormats(); + void update_sample_formats(); - void UpdateBitRateEnabled(); + void update_bit_rate_enabled(); }; } -#endif // EXPORTAUDIOTAB_H +#endif // OAK_EXPORTAUDIOTAB_H diff --git a/app/dialog/export/exportformatcombobox.cpp b/app/dialog/export/exportformatcombobox.cpp index 3fd1d06c6..f84f19065 100644 --- a/app/dialog/export/exportformatcombobox.cpp +++ b/app/dialog/export/exportformatcombobox.cpp @@ -36,31 +36,31 @@ ExportFormatComboBox::ExportFormatComboBox(Mode mode, QWidget *parent) // Populate combobox formats switch (mode) { - case kShowAllFormats: - custom_menu_->addAction(CreateHeader(icon::Video, tr("Video"))); - PopulateType(Track::kVideo); + case k_show_all_formats: + custom_menu_->addAction(create_header(icon::video, tr("Video"))); + populate_type(Track::k_video); custom_menu_->addSeparator(); - custom_menu_->addAction(CreateHeader(icon::Audio, tr("Audio"))); - PopulateType(Track::kAudio); + custom_menu_->addAction(create_header(icon::audio, tr("Audio"))); + populate_type(Track::k_audio); custom_menu_->addSeparator(); - custom_menu_->addAction(CreateHeader(icon::Subtitles, tr("Subtitle"))); - PopulateType(Track::kSubtitle); + custom_menu_->addAction(create_header(icon::subtitles, tr("Subtitle"))); + populate_type(Track::k_subtitle); break; - case kShowAudioOnly: - PopulateType(Track::kAudio); + case k_show_audio_only: + populate_type(Track::k_audio); break; - case kShowVideoOnly: - PopulateType(Track::kVideo); + case k_show_video_only: + populate_type(Track::k_video); break; - case kShowSubtitlesOnly: - PopulateType(Track::kSubtitle); + case k_show_subtitles_only: + populate_type(Track::k_subtitle); break; } connect(custom_menu_, &Menu::triggered, this, - &ExportFormatComboBox::HandleIndexChange); + &ExportFormatComboBox::handle_index_change); } void ExportFormatComboBox::showPopup() @@ -69,43 +69,43 @@ void ExportFormatComboBox::showPopup() custom_menu_->exec(mapToGlobal(QPoint(0, 0))); } -void ExportFormatComboBox::SetFormat(ExportFormat::Format fmt) +void ExportFormatComboBox::set_format(ExportFormat::Format fmt) { current_ = fmt; clear(); - addItem(ExportFormat::GetName(current_)); + addItem(ExportFormat::get_name(current_)); } -void ExportFormatComboBox::HandleIndexChange(QAction *a) +void ExportFormatComboBox::handle_index_change(QAction *a) { ExportFormat::Format f = static_cast(a->data().toInt()); - SetFormat(f); - emit FormatChanged(f); + set_format(f); + emit format_changed(f); } -void ExportFormatComboBox::PopulateType(Track::Type type) +void ExportFormatComboBox::populate_type(Track::Type type) { - for (int i = 0; i < ExportFormat::kFormatCount; i++) { + for (int i = 0; i < ExportFormat::k_format_count; i++) { ExportFormat::Format f = static_cast(i); - if (type == Track::kVideo && - !ExportFormat::GetVideoCodecs(f).isEmpty()) { + if (type == Track::k_video && + !ExportFormat::get_video_codecs(f).isEmpty()) { // Do nothing - } else if (type == Track::kAudio && - ExportFormat::GetVideoCodecs(f).isEmpty() && - !ExportFormat::GetAudioCodecs(f).isEmpty()) { + } else if (type == Track::k_audio && + ExportFormat::get_video_codecs(f).isEmpty() && + !ExportFormat::get_audio_codecs(f).isEmpty()) { // Do nothing - } else if (type == Track::kSubtitle && - ExportFormat::GetVideoCodecs(f).isEmpty() && - ExportFormat::GetAudioCodecs(f).isEmpty() && - !ExportFormat::GetSubtitleCodecs(f).isEmpty()) { + } else if (type == Track::k_subtitle && + ExportFormat::get_video_codecs(f).isEmpty() && + ExportFormat::get_audio_codecs(f).isEmpty() && + !ExportFormat::get_subtitle_codecs(f).isEmpty()) { // Do nothing } else { continue; } - QString format_name = ExportFormat::GetName(f); + QString format_name = ExportFormat::get_name(f); QAction *a = custom_menu_->addAction(format_name); a->setData(i); @@ -113,7 +113,7 @@ void ExportFormatComboBox::PopulateType(Track::Type type) } } -QWidgetAction *ExportFormatComboBox::CreateHeader(const QIcon &icon, +QWidgetAction *ExportFormatComboBox::create_header(const QIcon &icon, const QString &title) { QWidgetAction *a = new QWidgetAction(this); diff --git a/app/dialog/export/exportformatcombobox.h b/app/dialog/export/exportformatcombobox.h index ec30a38d4..2a5ca29e5 100644 --- a/app/dialog/export/exportformatcombobox.h +++ b/app/dialog/export/exportformatcombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTFORMATCOMBOBOX_H -#define EXPORTFORMATCOMBOBOX_H +#ifndef OAK_EXPORTFORMATCOMBOBOX_H +#define OAK_EXPORTFORMATCOMBOBOX_H #include #include @@ -36,19 +36,19 @@ class ExportFormatComboBox : public QComboBox { Q_OBJECT public: enum Mode { - kShowAllFormats, - kShowAudioOnly, - kShowVideoOnly, - kShowSubtitlesOnly + k_show_all_formats, + k_show_audio_only, + k_show_video_only, + k_show_subtitles_only }; ExportFormatComboBox(Mode mode, QWidget *parent = nullptr); ExportFormatComboBox(QWidget *parent = nullptr) - : ExportFormatComboBox(kShowAllFormats, parent) + : ExportFormatComboBox(k_show_all_formats, parent) { } - ExportFormat::Format GetFormat() const + ExportFormat::Format get_format() const { return current_; } @@ -56,24 +56,24 @@ public: void showPopup(); signals: - void FormatChanged(ExportFormat::Format fmt); + void format_changed(ExportFormat::Format fmt); public slots: - void SetFormat(ExportFormat::Format fmt); + void set_format(ExportFormat::Format fmt); private slots: - void HandleIndexChange(QAction *a); + void handle_index_change(QAction *a); private: - void PopulateType(Track::Type type); + void populate_type(Track::Type type); - QWidgetAction *CreateHeader(const QIcon &icon, const QString &title); + QWidgetAction *create_header(const QIcon &icon, const QString &title); Menu *custom_menu_; - ExportFormat::Format current_ = ExportFormat::kFormatCount; + ExportFormat::Format current_ = ExportFormat::k_format_count; }; } -#endif // EXPORTFORMATCOMBOBOX_H +#endif // OAK_EXPORTFORMATCOMBOBOX_H diff --git a/app/dialog/export/exportsavepresetdialog.cpp b/app/dialog/export/exportsavepresetdialog.cpp index f199ef926..71494cfeb 100644 --- a/app/dialog/export/exportsavepresetdialog.cpp +++ b/app/dialog/export/exportsavepresetdialog.cpp @@ -39,15 +39,15 @@ ExportSavePresetDialog::ExportSavePresetDialog(const EncodingParams &p, name_edit_ = new QLineEdit(); // Populate existing list - QStringList l = EncodingParams::GetListOfPresets(); + QStringList l = EncodingParams::get_list_of_presets(); if (!l.empty()) { - auto list_widget_ = new QListWidget(); + auto list_widget = new QListWidget(); for (const QString &f : l) { - list_widget_->addItem(f); + list_widget->addItem(f); } - connect(list_widget_, &QListWidget::currentTextChanged, name_edit_, + connect(list_widget, &QListWidget::currentTextChanged, name_edit_, &QLineEdit::setText); - layout->addWidget(list_widget_); + layout->addWidget(list_widget); } auto name_layout = new QHBoxLayout(); @@ -78,7 +78,7 @@ void ExportSavePresetDialog::accept() return; } - QDir d(EncodingParams::GetPresetPath()); + QDir d(EncodingParams::get_preset_path()); if (!d.exists()) { d.mkpath(QStringLiteral(".")); } @@ -101,7 +101,7 @@ void ExportSavePresetDialog::accept() return; } - params_.Save(&f); + params_.save(&f); f.close(); diff --git a/app/dialog/export/exportsavepresetdialog.h b/app/dialog/export/exportsavepresetdialog.h index 7206eac29..682364831 100644 --- a/app/dialog/export/exportsavepresetdialog.h +++ b/app/dialog/export/exportsavepresetdialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTSAVEPRESETDIALOG_H -#define EXPORTSAVEPRESETDIALOG_H +#ifndef OAK_EXPORTSAVEPRESETDIALOG_H +#define OAK_EXPORTSAVEPRESETDIALOG_H #include #include @@ -36,7 +36,7 @@ class ExportSavePresetDialog : public QDialog { public: ExportSavePresetDialog(const EncodingParams &p, QWidget *parent = nullptr); - QString GetSelectedPresetName() const + QString get_selected_preset_name() const { return name_edit_->text(); } @@ -52,4 +52,4 @@ private: } -#endif // EXPORTSAVEPRESETDIALOG_H +#endif // OAK_EXPORTSAVEPRESETDIALOG_H diff --git a/app/dialog/export/exportsubtitlestab.cpp b/app/dialog/export/exportsubtitlestab.cpp index 237945d72..257f01463 100644 --- a/app/dialog/export/exportsubtitlestab.cpp +++ b/app/dialog/export/exportsubtitlestab.cpp @@ -43,7 +43,7 @@ ExportSubtitlesTab::ExportSubtitlesTab(QWidget *parent) layout->addWidget(sidecar_format_label_, row, 0); sidecar_format_combobox_ = - new ExportFormatComboBox(ExportFormatComboBox::kShowSubtitlesOnly); + new ExportFormatComboBox(ExportFormatComboBox::k_show_subtitles_only); sidecar_format_combobox_->setVisible(true); layout->addWidget(sidecar_format_combobox_, row, 1); @@ -62,12 +62,12 @@ ExportSubtitlesTab::ExportSubtitlesTab(QWidget *parent) &QWidget::setVisible); } -int ExportSubtitlesTab::SetFormat(ExportFormat::Format format) +int ExportSubtitlesTab::set_format(ExportFormat::Format format) { - auto vcodecs = ExportFormat::GetVideoCodecs(format); - auto acodecs = ExportFormat::GetAudioCodecs(format); + auto vcodecs = ExportFormat::get_video_codecs(format); + auto acodecs = ExportFormat::get_audio_codecs(format); - auto scodecs = ExportFormat::GetSubtitleCodecs(format); + auto scodecs = ExportFormat::get_subtitle_codecs(format); if (!scodecs.empty() && vcodecs.empty() && acodecs.empty()) { // If format supports ONLY scodecs, default this to off and disable it @@ -80,11 +80,11 @@ int ExportSubtitlesTab::SetFormat(ExportFormat::Format format) } scodecs = - ExportFormat::GetSubtitleCodecs(sidecar_format_combobox_->GetFormat()); + ExportFormat::get_subtitle_codecs(sidecar_format_combobox_->get_format()); codec_combobox_->clear(); foreach (ExportCodec::Codec scodec, scodecs) { - codec_combobox_->addItem(ExportCodec::GetCodecName(scodec), scodec); + codec_combobox_->addItem(ExportCodec::get_codec_name(scodec), scodec); } return scodecs.size(); diff --git a/app/dialog/export/exportsubtitlestab.h b/app/dialog/export/exportsubtitlestab.h index ecb3a84bc..03fa7eeb4 100644 --- a/app/dialog/export/exportsubtitlestab.h +++ b/app/dialog/export/exportsubtitlestab.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTSUBTITLESTAB_H -#define EXPORTSUBTITLESTAB_H +#ifndef OAK_EXPORTSUBTITLESTAB_H +#define OAK_EXPORTSUBTITLESTAB_H #include #include @@ -38,35 +38,35 @@ class ExportSubtitlesTab : public QWidget { public: ExportSubtitlesTab(QWidget *parent = nullptr); - bool GetSidecarEnabled() const + bool get_sidecar_enabled() const { return sidecar_checkbox_->isChecked(); } - void SetSidecarEnabled(bool e) + void set_sidecar_enabled(bool e) { sidecar_checkbox_->setChecked(e); } - ExportFormat::Format GetSidecarFormat() const + ExportFormat::Format get_sidecar_format() const { - return sidecar_format_combobox_->GetFormat(); + return sidecar_format_combobox_->get_format(); } - void SetSidecarFormat(ExportFormat::Format f) + void set_sidecar_format(ExportFormat::Format f) { - sidecar_format_combobox_->SetFormat(f); + sidecar_format_combobox_->set_format(f); } - int SetFormat(ExportFormat::Format format); + int set_format(ExportFormat::Format format); - ExportCodec::Codec GetSubtitleCodec() + ExportCodec::Codec get_subtitle_codec() { return static_cast( codec_combobox_->currentData().toInt()); } - void SetSubtitleCodec(ExportCodec::Codec c) + void set_subtitle_codec(ExportCodec::Codec c) { - QtUtils::SetComboBoxData(codec_combobox_, c); + QtUtils::set_combo_box_data(codec_combobox_, c); } private: @@ -80,4 +80,4 @@ private: } -#endif // EXPORTSUBTITLESTAB_H +#endif // OAK_EXPORTSUBTITLESTAB_H diff --git a/app/dialog/export/exportvideotab.cpp b/app/dialog/export/exportvideotab.cpp index 60474c2b3..eb283a89d 100644 --- a/app/dialog/export/exportvideotab.cpp +++ b/app/dialog/export/exportvideotab.cpp @@ -37,49 +37,49 @@ ExportVideoTab::ExportVideoTab(ColorManager *color_manager, QWidget *parent) : QWidget(parent) , color_manager_(color_manager) , threads_(0) - , color_range_(VideoParams::kColorRangeDefault) + , color_range_(VideoParams::k_color_range_default) { QVBoxLayout *outer_layout = new QVBoxLayout(this); - outer_layout->addWidget(SetupResolutionSection()); + outer_layout->addWidget(setup_resolution_section()); - outer_layout->addWidget(SetupCodecSection()); + outer_layout->addWidget(setup_codec_section()); - outer_layout->addWidget(SetupColorSection()); + outer_layout->addWidget(setup_color_section()); outer_layout->addStretch(); } -int ExportVideoTab::SetFormat(ExportFormat::Format format) +int ExportVideoTab::set_format(ExportFormat::Format format) { format_ = format; - QList vcodecs = ExportFormat::GetVideoCodecs(format); + QList vcodecs = ExportFormat::get_video_codecs(format); setEnabled(!vcodecs.isEmpty()); codec_combobox()->clear(); foreach (ExportCodec::Codec vcodec, vcodecs) { - codec_combobox()->addItem(ExportCodec::GetCodecName(vcodec), vcodec); + codec_combobox()->addItem(ExportCodec::get_codec_name(vcodec), vcodec); } return vcodecs.size(); } -bool ExportVideoTab::IsImageSequenceSet() const +bool ExportVideoTab::is_image_sequence_set() const { ImageSection *img_section = dynamic_cast(codec_stack_->currentWidget()); - return (img_section && img_section->IsImageSequenceChecked()); + return (img_section && img_section->is_image_sequence_checked()); } -void ExportVideoTab::SetImageSequence(bool e) const +void ExportVideoTab::set_image_sequence(bool e) const { if (ImageSection *img_section = dynamic_cast(codec_stack_->currentWidget())) { - img_section->SetImageSequenceChecked(e); + img_section->set_image_sequence_checked(e); } } -QWidget *ExportVideoTab::SetupResolutionSection() +QWidget *ExportVideoTab::setup_resolution_section() { int row = 0; @@ -91,7 +91,7 @@ QWidget *ExportVideoTab::SetupResolutionSection() layout->addWidget(new QLabel(tr("Width:")), row, 0); width_slider_ = new IntegerSlider(); - width_slider_->SetMinimum(1); + width_slider_->set_minimum(1); layout->addWidget(width_slider_, row, 1); row++; @@ -99,7 +99,7 @@ QWidget *ExportVideoTab::SetupResolutionSection() layout->addWidget(new QLabel(tr("Height:")), row, 0); height_slider_ = new IntegerSlider(); - height_slider_->SetMinimum(1); + height_slider_->set_minimum(1); layout->addWidget(height_slider_, row, 1); row++; @@ -116,22 +116,22 @@ QWidget *ExportVideoTab::SetupResolutionSection() scaling_method_combobox_ = new QComboBox(); scaling_method_combobox_->setEnabled(false); - scaling_method_combobox_->addItem(tr("Fit"), EncodingParams::kFit); - scaling_method_combobox_->addItem(tr("Stretch"), EncodingParams::kStretch); - scaling_method_combobox_->addItem(tr("Crop"), EncodingParams::kCrop); + scaling_method_combobox_->addItem(tr("Fit"), EncodingParams::k_fit); + scaling_method_combobox_->addItem(tr("Stretch"), EncodingParams::k_stretch); + scaling_method_combobox_->addItem(tr("Crop"), EncodingParams::k_crop); layout->addWidget(scaling_method_combobox_, row, 1); // Automatically enable/disable the scaling method depending on maintain aspect ratio connect(maintain_aspect_checkbox_, &QCheckBox::toggled, this, - &ExportVideoTab::MaintainAspectRatioChanged); + &ExportVideoTab::maintain_aspect_ratio_changed); row++; layout->addWidget(new QLabel(tr("Frame Rate:")), row, 0); frame_rate_combobox_ = new FrameRateComboBox(); - connect(frame_rate_combobox_, &FrameRateComboBox::FrameRateChanged, this, - &ExportVideoTab::UpdateFrameRate); + connect(frame_rate_combobox_, &FrameRateComboBox::frame_rate_changed, this, + &ExportVideoTab::update_frame_rate); layout->addWidget(frame_rate_combobox_, row, 1); row++; @@ -158,15 +158,15 @@ QWidget *ExportVideoTab::SetupResolutionSection() return resolution_group; } -QWidget *ExportVideoTab::SetupColorSection() +QWidget *ExportVideoTab::setup_color_section() { color_space_chooser_ = new ColorSpaceChooser(color_manager_, true, false); - connect(color_space_chooser_, &ColorSpaceChooser::InputColorSpaceChanged, - this, &ExportVideoTab::ColorSpaceChanged); + connect(color_space_chooser_, &ColorSpaceChooser::input_color_space_changed, + this, &ExportVideoTab::color_space_changed); return color_space_chooser_; } -QWidget *ExportVideoTab::SetupCodecSection() +QWidget *ExportVideoTab::setup_codec_section() { int row = 0; @@ -182,7 +182,7 @@ QWidget *ExportVideoTab::SetupCodecSection() connect( codec_combobox_, static_cast(&QComboBox::currentIndexChanged), - this, &ExportVideoTab::VideoCodecChanged); + this, &ExportVideoTab::video_codec_changed); row++; @@ -190,8 +190,8 @@ QWidget *ExportVideoTab::SetupCodecSection() codec_layout->addWidget(codec_stack_, row, 0, 1, 2); image_section_ = new ImageSection(); - connect(image_section_, &ImageSection::TimeChanged, this, - &ExportVideoTab::TimeChanged); + connect(image_section_, &ImageSection::time_changed, this, + &ExportVideoTab::time_changed); codec_stack_->addWidget(image_section_); h264_section_ = new H264Section(); @@ -210,22 +210,22 @@ QWidget *ExportVideoTab::SetupCodecSection() QPushButton *advanced_btn = new QPushButton(tr("Advanced")); connect(advanced_btn, &QPushButton::clicked, this, - &ExportVideoTab::OpenAdvancedDialog); + &ExportVideoTab::open_advanced_dialog); codec_layout->addWidget(advanced_btn, row, 1); return codec_group; } -void ExportVideoTab::MaintainAspectRatioChanged(bool val) +void ExportVideoTab::maintain_aspect_ratio_changed(bool val) { scaling_method_combobox_->setEnabled(!val); } -void ExportVideoTab::OpenAdvancedDialog() +void ExportVideoTab::open_advanced_dialog() { // Find export formats compatible with this encoder QStringList pixel_formats = - ExportFormat::GetPixelFormatsForCodec(format_, GetSelectedCodec()); + ExportFormat::get_pixel_formats_for_codec(format_, get_selected_codec()); ExportAdvancedVideoDialog d(pixel_formats, this); @@ -240,7 +240,7 @@ void ExportVideoTab::OpenAdvancedDialog() } } -void ExportVideoTab::UpdateFrameRate(rational r) +void ExportVideoTab::update_frame_rate(Rational r) { // Convert frame rate to timebase r.flip(); @@ -249,37 +249,37 @@ void ExportVideoTab::UpdateFrameRate(rational r) ImageSection *img = dynamic_cast(codec_stack_->widget(i)); if (img) { - img->SetTimebase(r); + img->set_timebase(r); } } } -void ExportVideoTab::VideoCodecChanged() +void ExportVideoTab::video_codec_changed() { - ExportCodec::Codec codec = GetSelectedCodec(); + ExportCodec::Codec codec = get_selected_codec(); switch (codec) { - case ExportCodec::kCodecH264: - case ExportCodec::kCodecH264rgb: - SetCodecSection(h264_section_); + case ExportCodec::k_codec_h264: + case ExportCodec::k_codec_h264rgb: + set_codec_section(h264_section_); break; - case ExportCodec::kCodecH265: - SetCodecSection(h265_section_); + case ExportCodec::k_codec_h265: + set_codec_section(h265_section_); break; - case ExportCodec::kCodecAV1: - SetCodecSection(av1_section_); + case ExportCodec::k_codec_a_v1: + set_codec_section(av1_section_); break; - case ExportCodec::kCodecCineform: - SetCodecSection(cineform_section_); + case ExportCodec::k_codec_cineform: + set_codec_section(cineform_section_); break; default: - SetCodecSection( - ExportCodec::IsCodecAStillImage(codec) ? image_section_ : nullptr); + set_codec_section( + ExportCodec::is_codec_a_still_image(codec) ? image_section_ : nullptr); } // Set default pixel format QStringList pix_fmts = - ExportFormat::GetPixelFormatsForCodec(format_, codec); + ExportFormat::get_pixel_formats_for_codec(format_, codec); if (!pix_fmts.isEmpty()) { pix_fmt_ = pix_fmts.first(); } else { @@ -287,13 +287,13 @@ void ExportVideoTab::VideoCodecChanged() } } -void ExportVideoTab::SetTime(const rational &time) +void ExportVideoTab::set_time(const Rational &time) { for (int i = 0; i < codec_stack_->count(); i++) { ImageSection *img = dynamic_cast(codec_stack_->widget(i)); if (img) { - img->SetTime(time); + img->set_time(time); } } } diff --git a/app/dialog/export/exportvideotab.h b/app/dialog/export/exportvideotab.h index 024935047..e18826710 100644 --- a/app/dialog/export/exportvideotab.h +++ b/app/dialog/export/exportvideotab.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTVIDEOTAB_H -#define EXPORTVIDEOTAB_H +#ifndef OAK_EXPORTVIDEOTAB_H +#define OAK_EXPORTVIDEOTAB_H #include #include @@ -45,25 +45,25 @@ class ExportVideoTab : public QWidget { public: ExportVideoTab(ColorManager *color_manager, QWidget *parent = nullptr); - int SetFormat(ExportFormat::Format format); + int set_format(ExportFormat::Format format); - bool IsImageSequenceSet() const; - void SetImageSequence(bool e) const; + bool is_image_sequence_set() const; + void set_image_sequence(bool e) const; - rational GetStillImageTime() const + Rational get_still_image_time() const { - return image_section_->GetTime(); + return image_section_->get_time(); } - ExportCodec::Codec GetSelectedCodec() const + ExportCodec::Codec get_selected_codec() const { return static_cast( codec_combobox()->currentData().toInt()); } - void SetSelectedCodec(ExportCodec::Codec c) + void set_selected_codec(ExportCodec::Codec c) { - QtUtils::SetComboBoxData(codec_combobox(), c); + QtUtils::set_combo_box_data(codec_combobox(), c); } QComboBox *codec_combobox() const @@ -91,33 +91,33 @@ public: return scaling_method_combobox_; } - rational GetSelectedFrameRate() const + Rational get_selected_frame_rate() const { - return frame_rate_combobox_->GetFrameRate(); + return frame_rate_combobox_->get_frame_rate(); } - void SetSelectedFrameRate(const rational &fr) + void set_selected_frame_rate(const Rational &fr) { - frame_rate_combobox_->SetFrameRate(fr); - UpdateFrameRate(fr); + frame_rate_combobox_->set_frame_rate(fr); + update_frame_rate(fr); } - QString CurrentOCIOColorSpace() + QString current_ocio_color_space() { return color_space_chooser_->input(); } - void SetOCIOColorSpace(const QString &s) + void set_ocio_color_space(const QString &s) { color_space_chooser_->set_input(s); } - CodecSection *GetCodecSection() const + CodecSection *get_codec_section() const { return static_cast(codec_stack_->currentWidget()); } - void SetCodecSection(CodecSection *section) + void set_codec_section(CodecSection *section) { if (section) { codec_stack_->setVisible(true); @@ -147,7 +147,7 @@ public: return threads_; } - void SetThreads(int t) + void set_threads(int t) { threads_ = t; } @@ -156,7 +156,7 @@ public: { return pix_fmt_; } - void SetPixFmt(const QString &s) + void set_pix_fmt(const QString &s) { pix_fmt_ = s; } @@ -165,27 +165,27 @@ public: { return color_range_; } - void SetColorRange(VideoParams::ColorRange c) + void set_color_range(VideoParams::ColorRange c) { color_range_ = c; } public slots: - void VideoCodecChanged(); + void video_codec_changed(); - void SetTime(const rational &time); + void set_time(const Rational &time); signals: - void ColorSpaceChanged(const QString &colorspace); + void color_space_changed(const QString &colorspace); - void ImageSequenceCheckBoxChanged(bool e); + void image_sequence_check_box_changed(bool e); - void TimeChanged(const rational &time); + void time_changed(const Rational &time); private: - QWidget *SetupResolutionSection(); - QWidget *SetupColorSection(); - QWidget *SetupCodecSection(); + QWidget *setup_resolution_section(); + QWidget *setup_color_section(); + QWidget *setup_codec_section(); QComboBox *codec_combobox_; FrameRateComboBox *frame_rate_combobox_; @@ -218,13 +218,13 @@ private: ExportFormat::Format format_; private slots: - void MaintainAspectRatioChanged(bool val); + void maintain_aspect_ratio_changed(bool val); - void OpenAdvancedDialog(); + void open_advanced_dialog(); - void UpdateFrameRate(rational r); + void update_frame_rate(Rational r); }; } -#endif // EXPORTVIDEOTAB_H +#endif // OAK_EXPORTVIDEOTAB_H diff --git a/app/dialog/footageproperties/footageproperties.cpp b/app/dialog/footageproperties/footageproperties.cpp index 000272c0f..2e1d142ab 100644 --- a/app/dialog/footageproperties/footageproperties.cpp +++ b/app/dialog/footageproperties/footageproperties.cpp @@ -48,14 +48,14 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, { QGridLayout *layout = new QGridLayout(this); - setWindowTitle(tr("\"%1\" Properties").arg(footage_->GetLabelOrName())); + setWindowTitle(tr("\"%1\" Properties").arg(footage_->get_label_or_name())); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); int row = 0; layout->addWidget(new QLabel(tr("Name:")), row, 0); - footage_name_field_ = new QLineEdit(footage_->GetLabel()); + footage_name_field_ = new QLineEdit(footage_->get_label()); layout->addWidget(footage_name_field_, row, 1); row++; @@ -67,7 +67,7 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, QHBoxLayout *start_time_layout = new QHBoxLayout(); source_start_time_enable_ = new QCheckBox(tr("Set")); - source_start_time_enable_->setChecked(footage_->HasSourceStartTime()); + source_start_time_enable_->setChecked(footage_->has_source_start_time()); start_time_layout->addWidget(source_start_time_enable_); source_start_time_spin_ = new QDoubleSpinBox(); @@ -75,15 +75,15 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, source_start_time_spin_->setDecimals(3); source_start_time_spin_->setSuffix(QStringLiteral(" s")); source_start_time_spin_->setValue( - footage_->HasSourceStartTime() ? - footage_->source_start_time().toDouble() : + footage_->has_source_start_time() ? + footage_->source_start_time().to_double() : 0.0); source_start_time_spin_->setEnabled( source_start_time_enable_->isChecked()); start_time_layout->addWidget(source_start_time_spin_, 1); QString detection_note; - if (footage_->HasSourceStartTime()) { + if (footage_->has_source_start_time()) { const QString &source = footage_->source_start_time_source(); detection_note = (source == QStringLiteral("manual")) ? @@ -104,8 +104,8 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, layout->addWidget(new QLabel(tr("Tracks:")), row, 0, 1, 2); row++; - track_list = new QListWidget(); - layout->addWidget(track_list, row, 0, 1, 2); + track_list_ = new QListWidget(); + layout->addWidget(track_list_, row, 0, 1, 2); row++; @@ -114,33 +114,33 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, int first_usable_stream = -1; - for (int i = 0; i < footage_->GetTotalStreamCount(); i++) { - Track::Reference reference = footage_->GetReferenceFromRealIndex(i); + for (int i = 0; i < footage_->get_total_stream_count(); i++) { + Track::Reference reference = footage_->get_reference_from_real_index(i); QString description; bool is_enabled = false; switch (reference.type()) { - case Track::kVideo: { + case Track::k_video: { stacked_widget_->addWidget( new VideoStreamProperties(footage_, reference.index())); - VideoParams vp = footage_->GetVideoParams(reference.index()); + VideoParams vp = footage_->get_video_params(reference.index()); is_enabled = vp.enabled(); - description = Footage::DescribeVideoStream(vp); + description = Footage::describe_video_stream(vp); break; } - case Track::kAudio: { + case Track::k_audio: { stacked_widget_->addWidget( new AudioStreamProperties(footage_, reference.index())); - AudioParams ap = footage_->GetAudioParams(reference.index()); + AudioParams ap = footage_->get_audio_params(reference.index()); is_enabled = ap.enabled(); - description = Footage::DescribeAudioStream(ap); + description = Footage::describe_audio_stream(ap); break; } - case Track::kSubtitle: { - SubtitleParams sp = footage_->GetSubtitleParams(reference.index()); + case Track::k_subtitle: { + SubtitleParams sp = footage_->get_subtitle_params(reference.index()); is_enabled = sp.enabled(); // FIXME: Language? @@ -153,15 +153,15 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, break; } - QListWidgetItem *item = new QListWidgetItem(description, track_list); + QListWidgetItem *item = new QListWidgetItem(description, track_list_); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(is_enabled ? Qt::Checked : Qt::Unchecked); - track_list->addItem(item); + track_list_->addItem(item); if (first_usable_stream == -1 && - (reference.type() == Track::kVideo || - reference.type() == Track::kAudio || - reference.type() == Track::kSubtitle)) { + (reference.type() == Track::k_video || + reference.type() == Track::k_audio || + reference.type() == Track::k_subtitle)) { first_usable_stream = i; } } @@ -176,14 +176,14 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(track_list, &QListWidget::currentRowChanged, stacked_widget_, + connect(track_list_, &QListWidget::currentRowChanged, stacked_widget_, &QStackedWidget::setCurrentIndex); // Auto-select first item that actually has properties if (first_usable_stream >= 0) { - track_list->setCurrentRow(first_usable_stream); + track_list_->setCurrentRow(first_usable_stream); } - track_list->setFocus(); + track_list_->setFocus(); } void FootagePropertiesDialog::accept() @@ -191,7 +191,7 @@ void FootagePropertiesDialog::accept() // Perform sanity check on all pages for (int i = 0; i < stacked_widget_->count(); i++) { if (!static_cast(stacked_widget_->widget(i)) - ->SanityCheck()) { + ->sanity_check()) { // Switch to the failed panel in question stacked_widget_->setCurrentIndex(i); @@ -202,45 +202,45 @@ void FootagePropertiesDialog::accept() MultiUndoCommand *command = new MultiUndoCommand(); - if (footage_->GetLabel() != footage_name_field_->text()) { + if (footage_->get_label() != footage_name_field_->text()) { NodeRenameCommand *nrc = new NodeRenameCommand(); - nrc->AddNode(footage_, footage_name_field_->text()); + nrc->add_node(footage_, footage_name_field_->text()); command->add_child(nrc); } // Apply source start time changes { const bool new_enabled = source_start_time_enable_->isChecked(); - const rational new_time = - rational::fromDouble(source_start_time_spin_->value()); - if (new_enabled != footage_->HasSourceStartTime() || + const Rational new_time = + Rational::from_double(source_start_time_spin_->value()); + if (new_enabled != footage_->has_source_start_time() || (new_enabled && new_time != footage_->source_start_time())) { command->add_child(new FootageSetSourceStartTimeCommand( footage_, new_enabled, new_time, QStringLiteral("manual"))); } } - for (int i = 0; i < footage_->GetTotalStreamCount(); i++) { - Track::Reference reference = footage_->GetReferenceFromRealIndex(i); + for (int i = 0; i < footage_->get_total_stream_count(); i++) { + Track::Reference reference = footage_->get_reference_from_real_index(i); bool new_stream_enabled = - (track_list->item(i)->checkState() == Qt::Checked); + (track_list_->item(i)->checkState() == Qt::Checked); bool old_stream_enabled = new_stream_enabled; switch (reference.type()) { - case Track::kVideo: + case Track::k_video: old_stream_enabled = - footage_->GetVideoParams(reference.index()).enabled(); + footage_->get_video_params(reference.index()).enabled(); break; - case Track::kAudio: + case Track::k_audio: old_stream_enabled = - footage_->GetAudioParams(reference.index()).enabled(); + footage_->get_audio_params(reference.index()).enabled(); break; - case Track::kSubtitle: + case Track::k_subtitle: old_stream_enabled = - footage_->GetSubtitleParams(reference.index()).enabled(); + footage_->get_subtitle_params(reference.index()).enabled(); break; - case Track::kNone: - case Track::kCount: + case Track::k_none: + case Track::k_count: break; } @@ -253,11 +253,11 @@ void FootagePropertiesDialog::accept() for (int i = 0; i < stacked_widget_->count(); i++) { static_cast(stacked_widget_->widget(i)) - ->Accept(command); + ->accept(command); } Core::instance()->undo_stack()->push( - command, tr("Set Footage \"%1\" Properties").arg(footage_->GetLabel())); + command, tr("Set Footage \"%1\" Properties").arg(footage_->get_label())); QDialog::accept(); } @@ -272,7 +272,7 @@ FootagePropertiesDialog::StreamEnableChangeCommand::StreamEnableChangeCommand( } Project * -FootagePropertiesDialog::StreamEnableChangeCommand::GetRelevantProject() const +FootagePropertiesDialog::StreamEnableChangeCommand::get_relevant_project() const { return footage_->project(); } @@ -280,29 +280,29 @@ FootagePropertiesDialog::StreamEnableChangeCommand::GetRelevantProject() const void FootagePropertiesDialog::StreamEnableChangeCommand::redo() { switch (type_) { - case Track::kVideo: { - VideoParams vp = footage_->GetVideoParams(index_); + case Track::k_video: { + VideoParams vp = footage_->get_video_params(index_); old_enabled_ = vp.enabled(); vp.set_enabled(new_enabled_); - footage_->SetVideoParams(vp, index_); + footage_->set_video_params(vp, index_); break; } - case Track::kAudio: { - AudioParams ap = footage_->GetAudioParams(index_); + case Track::k_audio: { + AudioParams ap = footage_->get_audio_params(index_); old_enabled_ = ap.enabled(); ap.set_enabled(new_enabled_); - footage_->SetAudioParams(ap, index_); + footage_->set_audio_params(ap, index_); break; } - case Track::kSubtitle: { - SubtitleParams sp = footage_->GetSubtitleParams(index_); + case Track::k_subtitle: { + SubtitleParams sp = footage_->get_subtitle_params(index_); old_enabled_ = sp.enabled(); sp.set_enabled(new_enabled_); - footage_->SetSubtitleParams(sp, index_); + footage_->set_subtitle_params(sp, index_); break; } - case Track::kNone: - case Track::kCount: + case Track::k_none: + case Track::k_count: break; } } @@ -310,33 +310,33 @@ void FootagePropertiesDialog::StreamEnableChangeCommand::redo() void FootagePropertiesDialog::StreamEnableChangeCommand::undo() { switch (type_) { - case Track::kVideo: { - VideoParams vp = footage_->GetVideoParams(index_); + case Track::k_video: { + VideoParams vp = footage_->get_video_params(index_); vp.set_enabled(old_enabled_); - footage_->SetVideoParams(vp, index_); + footage_->set_video_params(vp, index_); break; } - case Track::kAudio: { - AudioParams ap = footage_->GetAudioParams(index_); + case Track::k_audio: { + AudioParams ap = footage_->get_audio_params(index_); ap.set_enabled(old_enabled_); - footage_->SetAudioParams(ap, index_); + footage_->set_audio_params(ap, index_); break; } - case Track::kSubtitle: { - SubtitleParams sp = footage_->GetSubtitleParams(index_); + case Track::k_subtitle: { + SubtitleParams sp = footage_->get_subtitle_params(index_); sp.set_enabled(old_enabled_); - footage_->SetSubtitleParams(sp, index_); + footage_->set_subtitle_params(sp, index_); break; } - case Track::kNone: - case Track::kCount: + case Track::k_none: + case Track::k_count: break; } } FootagePropertiesDialog::FootageSetSourceStartTimeCommand:: FootageSetSourceStartTimeCommand(Footage *footage, bool enabled, - const rational &time, + const Rational &time, const QString &source) : footage_(footage) , new_enabled_(enabled) @@ -346,7 +346,7 @@ FootagePropertiesDialog::FootageSetSourceStartTimeCommand:: } Project * -FootagePropertiesDialog::FootageSetSourceStartTimeCommand::GetRelevantProject() +FootagePropertiesDialog::FootageSetSourceStartTimeCommand::get_relevant_project() const { return footage_->project(); @@ -354,23 +354,23 @@ FootagePropertiesDialog::FootageSetSourceStartTimeCommand::GetRelevantProject() void FootagePropertiesDialog::FootageSetSourceStartTimeCommand::redo() { - old_enabled_ = footage_->HasSourceStartTime(); + old_enabled_ = footage_->has_source_start_time(); old_time_ = footage_->source_start_time(); old_source_ = footage_->source_start_time_source(); if (new_enabled_) { - footage_->SetSourceStartTime(new_time_, new_source_); + footage_->set_source_start_time(new_time_, new_source_); } else { - footage_->ClearSourceStartTime(); + footage_->clear_source_start_time(); } } void FootagePropertiesDialog::FootageSetSourceStartTimeCommand::undo() { if (old_enabled_) { - footage_->SetSourceStartTime(old_time_, old_source_); + footage_->set_source_start_time(old_time_, old_source_); } else { - footage_->ClearSourceStartTime(); + footage_->clear_source_start_time(); } } diff --git a/app/dialog/footageproperties/footageproperties.h b/app/dialog/footageproperties/footageproperties.h index ea06e8615..758f1d680 100644 --- a/app/dialog/footageproperties/footageproperties.h +++ b/app/dialog/footageproperties/footageproperties.h @@ -19,8 +19,8 @@ ***/ -#ifndef MEDIAPROPERTIESDIALOG_H -#define MEDIAPROPERTIESDIALOG_H +#ifndef OAK_MEDIAPROPERTIESDIALOG_H +#define OAK_MEDIAPROPERTIESDIALOG_H #include #include @@ -64,7 +64,7 @@ private: StreamEnableChangeCommand(Footage *footage, Track::Type type, int index_in_type, bool enabled); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -82,10 +82,10 @@ private: class FootageSetSourceStartTimeCommand : public UndoCommand { public: FootageSetSourceStartTimeCommand(Footage *footage, bool enabled, - const rational &time, + const Rational &time, const QString &source); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -95,11 +95,11 @@ private: Footage *footage_; bool new_enabled_; - rational new_time_; + Rational new_time_; QString new_source_; bool old_enabled_; - rational old_time_; + Rational old_time_; QString old_source_; }; @@ -131,12 +131,12 @@ private: /** * @brief A list widget for listing the tracks in Media */ - QListWidget *track_list; + QListWidget *track_list_; /** * @brief Frame rate to conform to */ - QDoubleSpinBox *conform_fr; + QDoubleSpinBox *conform_fr_; private slots: /** @@ -147,4 +147,4 @@ private slots: } -#endif // MEDIAPROPERTIESDIALOG_H +#endif // OAK_MEDIAPROPERTIESDIALOG_H diff --git a/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp b/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp index 9d4713358..80e3bcf8b 100644 --- a/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp +++ b/app/dialog/footageproperties/streamproperties/audiostreamproperties.cpp @@ -30,7 +30,7 @@ AudioStreamProperties::AudioStreamProperties(Footage *footage, int audio_index) { } -void AudioStreamProperties::Accept(MultiUndoCommand *) +void AudioStreamProperties::accept(MultiUndoCommand *) { Q_UNUSED(footage_) Q_UNUSED(audio_index_) diff --git a/app/dialog/footageproperties/streamproperties/audiostreamproperties.h b/app/dialog/footageproperties/streamproperties/audiostreamproperties.h index a95f25b64..a44c93f88 100644 --- a/app/dialog/footageproperties/streamproperties/audiostreamproperties.h +++ b/app/dialog/footageproperties/streamproperties/audiostreamproperties.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUDIOSTREAMPROPERTIES_H -#define AUDIOSTREAMPROPERTIES_H +#ifndef OAK_AUDIOSTREAMPROPERTIES_H +#define OAK_AUDIOSTREAMPROPERTIES_H #include "node/project/footage/footage.h" #include "streamproperties.h" @@ -32,7 +32,7 @@ class AudioStreamProperties : public StreamProperties { public: AudioStreamProperties(Footage *footage, int audio_index); - virtual void Accept(MultiUndoCommand *parent) override; + virtual void accept(MultiUndoCommand *parent) override; private: Footage *footage_; @@ -42,4 +42,4 @@ private: } -#endif // AUDIOSTREAMPROPERTIES_H +#endif // OAK_AUDIOSTREAMPROPERTIES_H diff --git a/app/dialog/footageproperties/streamproperties/streamproperties.h b/app/dialog/footageproperties/streamproperties/streamproperties.h index 3eb6ff9cb..fa605e39d 100644 --- a/app/dialog/footageproperties/streamproperties/streamproperties.h +++ b/app/dialog/footageproperties/streamproperties/streamproperties.h @@ -19,8 +19,8 @@ ***/ -#ifndef STREAMPROPERTIES_H -#define STREAMPROPERTIES_H +#ifndef OAK_STREAMPROPERTIES_H +#define OAK_STREAMPROPERTIES_H #include @@ -34,11 +34,11 @@ class StreamProperties : public QWidget { public: StreamProperties(QWidget *parent = nullptr); - virtual void Accept(MultiUndoCommand *) + virtual void accept(MultiUndoCommand *) { } - virtual bool SanityCheck() + virtual bool sanity_check() { return true; } @@ -46,4 +46,4 @@ public: } -#endif // STREAMPROPERTIES_H +#endif // OAK_STREAMPROPERTIES_H diff --git a/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp b/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp index f67e3c38e..2f8aa35fe 100644 --- a/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp +++ b/app/dialog/footageproperties/streamproperties/videostreamproperties.cpp @@ -44,10 +44,10 @@ VideoStreamProperties::VideoStreamProperties(Footage *footage, int video_index) video_layout->addWidget(new QLabel(tr("Pixel Aspect:")), row, 0); - VideoParams vp = footage_->GetVideoParams(video_index_); + VideoParams vp = footage_->get_video_params(video_index_); pixel_aspect_combo_ = new PixelAspectRatioComboBox(); - pixel_aspect_combo_->SetPixelAspectRatio(vp.pixel_aspect_ratio()); + pixel_aspect_combo_->set_pixel_aspect_ratio(vp.pixel_aspect_ratio()); video_layout->addWidget(pixel_aspect_combo_, row, 1); row++; @@ -55,7 +55,7 @@ VideoStreamProperties::VideoStreamProperties(Footage *footage, int video_index) video_layout->addWidget(new QLabel(tr("Interlacing:")), row, 0); video_interlace_combo_ = new InterlacedComboBox(); - video_interlace_combo_->SetInterlaceMode(vp.interlacing()); + video_interlace_combo_->set_interlace_mode(vp.interlacing()); video_layout->addWidget(video_interlace_combo_, row, 1); @@ -64,14 +64,14 @@ VideoStreamProperties::VideoStreamProperties(Footage *footage, int video_index) video_layout->addWidget(new QLabel(tr("Color Space:")), row, 0); video_color_space_ = new QComboBox(); - OCIO::ConstConfigRcPtr config = - footage_->project()->color_manager()->GetConfig(); + ocio::ConstConfigRcPtr config = + footage_->project()->color_manager()->get_config(); int number_of_colorspaces = config->getNumColorSpaces(); video_color_space_->addItem(tr("Default (%1)") .arg(footage_->project() ->color_manager() - ->GetDefaultInputColorSpace())); + ->get_default_input_color_space())); for (int i = 0; i < number_of_colorspaces; i++) { QString colorspace = config->getColorSpaceNameByIndex(i); @@ -89,14 +89,14 @@ VideoStreamProperties::VideoStreamProperties(Footage *footage, int video_index) color_range_combo_ = new QComboBox(); color_range_combo_->addItem(tr("Limited (16-235)"), - VideoParams::kColorRangeLimited); + VideoParams::k_color_range_limited); color_range_combo_->addItem(tr("Full (0-255)"), - VideoParams::kColorRangeFull); + VideoParams::k_color_range_full); color_range_combo_->setCurrentIndex(vp.color_range()); video_layout->addWidget(color_range_combo_, row, 1); - if (vp.channel_count() == VideoParams::kRGBAChannelCount) { + if (vp.channel_count() == VideoParams::k_rgba_channel_count) { row++; video_premultiply_alpha_ = new QCheckBox(tr("Premultiplied Alpha")); @@ -106,7 +106,7 @@ VideoStreamProperties::VideoStreamProperties(Footage *footage, int video_index) row++; - if (vp.video_type() == VideoParams::kVideoTypeImageSequence) { + if (vp.video_type() == VideoParams::k_video_type_image_sequence) { QGroupBox *imgseq_group = new QGroupBox(tr("Image Sequence")); QGridLayout *imgseq_layout = new QGridLayout(imgseq_group); @@ -115,8 +115,8 @@ VideoStreamProperties::VideoStreamProperties(Footage *footage, int video_index) imgseq_layout->addWidget(new QLabel(tr("Start Index:")), imgseq_row, 0); imgseq_start_time_ = new IntegerSlider(); - imgseq_start_time_->SetMinimum(0); - imgseq_start_time_->SetValue(vp.start_time()); + imgseq_start_time_->set_minimum(0); + imgseq_start_time_->set_value(vp.start_time()); imgseq_layout->addWidget(imgseq_start_time_, imgseq_row, 1); imgseq_row++; @@ -124,8 +124,8 @@ VideoStreamProperties::VideoStreamProperties(Footage *footage, int video_index) imgseq_layout->addWidget(new QLabel(tr("End Index:")), imgseq_row, 0); imgseq_end_time_ = new IntegerSlider(); - imgseq_end_time_->SetMinimum(0); - imgseq_end_time_->SetValue(vp.start_time() + vp.duration() - 1); + imgseq_end_time_->set_minimum(0); + imgseq_end_time_->set_value(vp.start_time() + vp.duration() - 1); imgseq_layout->addWidget(imgseq_end_time_, imgseq_row, 1); imgseq_row++; @@ -133,14 +133,14 @@ VideoStreamProperties::VideoStreamProperties(Footage *footage, int video_index) imgseq_layout->addWidget(new QLabel(tr("Frame Rate:")), imgseq_row, 0); imgseq_frame_rate_ = new FrameRateComboBox(); - imgseq_frame_rate_->SetFrameRate(vp.frame_rate()); + imgseq_frame_rate_->set_frame_rate(vp.frame_rate()); imgseq_layout->addWidget(imgseq_frame_rate_, imgseq_row, 1); video_layout->addWidget(imgseq_group, row, 0, 1, 2); } } -void VideoStreamProperties::Accept(MultiUndoCommand *parent) +void VideoStreamProperties::accept(MultiUndoCommand *parent) { QString set_colorspace; @@ -148,14 +148,14 @@ void VideoStreamProperties::Accept(MultiUndoCommand *parent) set_colorspace = video_color_space_->currentText(); } - VideoParams vp = footage_->GetVideoParams(video_index_); + VideoParams vp = footage_->get_video_params(video_index_); if ((video_premultiply_alpha_ && video_premultiply_alpha_->isChecked() != vp.premultiplied_alpha()) || set_colorspace != vp.colorspace() || static_cast( video_interlace_combo_->currentIndex()) != vp.interlacing() || - pixel_aspect_combo_->GetPixelAspectRatio() != vp.pixel_aspect_ratio() || + pixel_aspect_combo_->get_pixel_aspect_ratio() != vp.pixel_aspect_ratio() || color_range_combo_->currentData().toInt() != vp.color_range()) { parent->add_child(new VideoStreamChangeCommand( footage_, video_index_, @@ -164,30 +164,30 @@ void VideoStreamProperties::Accept(MultiUndoCommand *parent) set_colorspace, static_cast( video_interlace_combo_->currentIndex()), - pixel_aspect_combo_->GetPixelAspectRatio(), + pixel_aspect_combo_->get_pixel_aspect_ratio(), static_cast( color_range_combo_->currentData().toInt()))); } - if (vp.video_type() == VideoParams::kVideoTypeImageSequence) { + if (vp.video_type() == VideoParams::k_video_type_image_sequence) { int64_t new_dur = - imgseq_end_time_->GetValue() - imgseq_start_time_->GetValue() + 1; + imgseq_end_time_->get_value() - imgseq_start_time_->get_value() + 1; - if (vp.start_time() != imgseq_start_time_->GetValue() || + if (vp.start_time() != imgseq_start_time_->get_value() || vp.duration() != new_dur || - vp.frame_rate() != imgseq_frame_rate_->GetFrameRate()) { + vp.frame_rate() != imgseq_frame_rate_->get_frame_rate()) { parent->add_child(new ImageSequenceChangeCommand( - footage_, video_index_, imgseq_start_time_->GetValue(), new_dur, - imgseq_frame_rate_->GetFrameRate())); + footage_, video_index_, imgseq_start_time_->get_value(), new_dur, + imgseq_frame_rate_->get_frame_rate())); } } } -bool VideoStreamProperties::SanityCheck() +bool VideoStreamProperties::sanity_check() { - if (footage_->GetVideoParams(video_index_).video_type() == - VideoParams::kVideoTypeImageSequence) { - if (imgseq_start_time_->GetValue() >= imgseq_end_time_->GetValue()) { + if (footage_->get_video_params(video_index_).video_type() == + VideoParams::k_video_type_image_sequence) { + if (imgseq_start_time_->get_value() >= imgseq_end_time_->get_value()) { QMessageBox::critical( this, tr("Invalid Configuration"), tr("Image sequence end index must be a value higher than the start index."), @@ -201,7 +201,7 @@ bool VideoStreamProperties::SanityCheck() VideoStreamProperties::VideoStreamChangeCommand::VideoStreamChangeCommand( Footage *footage, int video_index, bool premultiplied, QString colorspace, - VideoParams::Interlacing interlacing, const rational &pixel_ar, + VideoParams::Interlacing interlacing, const Rational &pixel_ar, VideoParams::ColorRange range) : footage_(footage) , video_index_(video_index) @@ -214,14 +214,14 @@ VideoStreamProperties::VideoStreamChangeCommand::VideoStreamChangeCommand( } Project * -VideoStreamProperties::VideoStreamChangeCommand::GetRelevantProject() const +VideoStreamProperties::VideoStreamChangeCommand::get_relevant_project() const { return footage_->project(); } void VideoStreamProperties::VideoStreamChangeCommand::redo() { - VideoParams vp = footage_->GetVideoParams(video_index_); + VideoParams vp = footage_->get_video_params(video_index_); old_premultiplied_ = vp.premultiplied_alpha(); old_colorspace_ = vp.colorspace(); @@ -235,12 +235,12 @@ void VideoStreamProperties::VideoStreamChangeCommand::redo() vp.set_pixel_aspect_ratio(new_pixel_ar_); vp.set_color_range(new_range_); - footage_->SetVideoParams(vp, video_index_); + footage_->set_video_params(vp, video_index_); } void VideoStreamProperties::VideoStreamChangeCommand::undo() { - VideoParams vp = footage_->GetVideoParams(video_index_); + VideoParams vp = footage_->get_video_params(video_index_); vp.set_premultiplied_alpha(old_premultiplied_); vp.set_colorspace(old_colorspace_); @@ -248,12 +248,12 @@ void VideoStreamProperties::VideoStreamChangeCommand::undo() vp.set_pixel_aspect_ratio(old_pixel_ar_); vp.set_color_range(old_range_); - footage_->SetVideoParams(vp, video_index_); + footage_->set_video_params(vp, video_index_); } VideoStreamProperties::ImageSequenceChangeCommand::ImageSequenceChangeCommand( Footage *footage, int video_index, int64_t start_index, int64_t duration, - const rational &frame_rate) + const Rational &frame_rate) : footage_(footage) , video_index_(video_index) , new_start_index_(start_index) @@ -263,14 +263,14 @@ VideoStreamProperties::ImageSequenceChangeCommand::ImageSequenceChangeCommand( } Project * -VideoStreamProperties::ImageSequenceChangeCommand::GetRelevantProject() const +VideoStreamProperties::ImageSequenceChangeCommand::get_relevant_project() const { return footage_->project(); } void VideoStreamProperties::ImageSequenceChangeCommand::redo() { - VideoParams vp = footage_->GetVideoParams(video_index_); + VideoParams vp = footage_->get_video_params(video_index_); old_start_index_ = vp.start_time(); vp.set_start_time(new_start_index_); @@ -282,19 +282,19 @@ void VideoStreamProperties::ImageSequenceChangeCommand::redo() vp.set_frame_rate(new_frame_rate_); vp.set_time_base(new_frame_rate_.flipped()); - footage_->SetVideoParams(vp, video_index_); + footage_->set_video_params(vp, video_index_); } void VideoStreamProperties::ImageSequenceChangeCommand::undo() { - VideoParams vp = footage_->GetVideoParams(video_index_); + VideoParams vp = footage_->get_video_params(video_index_); vp.set_start_time(old_start_index_); vp.set_duration(old_duration_); vp.set_frame_rate(old_frame_rate_); vp.set_time_base(old_frame_rate_.flipped()); - footage_->SetVideoParams(vp, video_index_); + footage_->set_video_params(vp, video_index_); } } diff --git a/app/dialog/footageproperties/streamproperties/videostreamproperties.h b/app/dialog/footageproperties/streamproperties/videostreamproperties.h index a97ad98f8..81fff9275 100644 --- a/app/dialog/footageproperties/streamproperties/videostreamproperties.h +++ b/app/dialog/footageproperties/streamproperties/videostreamproperties.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIDEOSTREAMPROPERTIES_H -#define VIDEOSTREAMPROPERTIES_H +#ifndef OAK_VIDEOSTREAMPROPERTIES_H +#define OAK_VIDEOSTREAMPROPERTIES_H #include #include @@ -38,9 +38,9 @@ class VideoStreamProperties : public StreamProperties { public: VideoStreamProperties(Footage *footage, int video_index); - virtual void Accept(MultiUndoCommand *parent) override; + virtual void accept(MultiUndoCommand *parent) override; - virtual bool SanityCheck() override; + virtual bool sanity_check() override; private: Footage *footage_; @@ -92,10 +92,10 @@ private: VideoStreamChangeCommand(Footage *footage, int video_index, bool premultiplied, QString colorspace, VideoParams::Interlacing interlacing, - const rational &pixel_ar, + const Rational &pixel_ar, VideoParams::ColorRange range); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -108,13 +108,13 @@ private: bool new_premultiplied_; QString new_colorspace_; VideoParams::Interlacing new_interlacing_; - rational new_pixel_ar_; + Rational new_pixel_ar_; VideoParams::ColorRange new_range_; bool old_premultiplied_; QString old_colorspace_; VideoParams::Interlacing old_interlacing_; - rational old_pixel_ar_; + Rational old_pixel_ar_; VideoParams::ColorRange old_range_; }; @@ -122,9 +122,9 @@ private: public: ImageSequenceChangeCommand(Footage *footage, int video_index, int64_t start_index, int64_t duration, - const rational &frame_rate); + const Rational &frame_rate); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -140,11 +140,11 @@ private: int64_t new_duration_; int64_t old_duration_; - rational new_frame_rate_; - rational old_frame_rate_; + Rational new_frame_rate_; + Rational old_frame_rate_; }; }; } -#endif // VIDEOSTREAMPROPERTIES_H +#endif // OAK_VIDEOSTREAMPROPERTIES_H diff --git a/app/dialog/footagerelink/footagerelinkdialog.cpp b/app/dialog/footagerelink/footagerelinkdialog.cpp index 7235567a3..711b49ac0 100644 --- a/app/dialog/footagerelink/footagerelinkdialog.cpp +++ b/app/dialog/footagerelink/footagerelinkdialog.cpp @@ -69,11 +69,11 @@ FootageRelinkDialog::FootageRelinkDialog(const QVector &footage, QPushButton *item_browse_btn = new QPushButton(tr("Browse")); item_browse_btn->setProperty("index", i); connect(item_browse_btn, &QPushButton::clicked, this, - &FootageRelinkDialog::BrowseForFootage); + &FootageRelinkDialog::browse_for_footage); item_actions_layout->addWidget(item_browse_btn); - item->setIcon(0, f->data(Node::ICON).value()); - item->setText(0, f->GetLabel()); + item->setIcon(0, f->data(Node::icon).value()); + item->setText(0, f->get_label()); item->setText(1, f->filename()); table_->addTopLevelItem(item); @@ -94,15 +94,15 @@ FootageRelinkDialog::FootageRelinkDialog(const QVector &footage, setWindowTitle(tr("Relink Footage")); } -void FootageRelinkDialog::UpdateFootageItem(int index) +void FootageRelinkDialog::update_footage_item(int index) { Footage *f = footage_.at(index); QTreeWidgetItem *item = table_->topLevelItem(index); - item->setIcon(0, f->data(Node::ICON).value()); + item->setIcon(0, f->data(Node::icon).value()); item->setText(1, f->filename()); } -void FootageRelinkDialog::BrowseForFootage() +void FootageRelinkDialog::browse_for_footage() { int index = sender()->property("index").toInt(); Footage *f = footage_.at(index); @@ -110,8 +110,8 @@ void FootageRelinkDialog::BrowseForFootage() QFileInfo info(f->filename()); QString new_fn = QFileDialog::getOpenFileName( - this, tr("Relink \"%1\"").arg(f->GetLabel()), info.absolutePath(), - Core::FootageFileDialogFilter()); + this, tr("Relink \"%1\"").arg(f->get_label()), info.absolutePath(), + Core::footage_file_dialog_filter()); // Originally, this function would attempt to filter to the exact filename of the missing file. // However, this would break on Windows if the filename had any spaces in it. The reason is @@ -124,7 +124,7 @@ void FootageRelinkDialog::BrowseForFootage() // We received a new filename if (!new_fn.isEmpty()) { - if (!Core::IsFootageExtensionAllowed(new_fn)) { + if (!Core::is_footage_extension_allowed(new_fn)) { QMessageBox::warning( this, tr("Unsupported media"), tr("This file type is not allowed by the current media type " @@ -142,17 +142,17 @@ void FootageRelinkDialog::BrowseForFootage() // but otherwise we assume the user knows what they're doing here. // Set footage to valid and update icon - f->SetValid(); + f->set_valid(); // Update item visually - UpdateFootageItem(index); + update_footage_item(index); // Check all other footage files for matches for (int it = 0; it < footage_.size(); it++) { Footage *other_footage = footage_.at(it); // Ignore current footage file and footage that's already valid of course - if (index != it && !other_footage->IsValid()) { + if (index != it && !other_footage->is_valid()) { // Get footage path relative to original directory QString relative_to_original = original_dir.relativeFilePath(other_footage->filename()); @@ -168,8 +168,8 @@ void FootageRelinkDialog::BrowseForFootage() // Check if file exists if (QFileInfo::exists(absolute_to_new)) { other_footage->set_filename(absolute_to_new); - other_footage->SetValid(); - UpdateFootageItem(it); + other_footage->set_valid(); + update_footage_item(it); } } } @@ -179,7 +179,7 @@ void FootageRelinkDialog::BrowseForFootage() // jump to that footage so the user knows where it is. int next_invalid = -1; for (int i = 0; i < footage_.size(); i++) { - if (!footage_.at(i)->IsValid()) { + if (!footage_.at(i)->is_valid()) { next_invalid = i; break; } diff --git a/app/dialog/footagerelink/footagerelinkdialog.h b/app/dialog/footagerelink/footagerelinkdialog.h index adb5881b6..454893883 100644 --- a/app/dialog/footagerelink/footagerelinkdialog.h +++ b/app/dialog/footagerelink/footagerelinkdialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef FOOTAGERELINKDIALOG_H -#define FOOTAGERELINKDIALOG_H +#ifndef OAK_FOOTAGERELINKDIALOG_H +#define OAK_FOOTAGERELINKDIALOG_H #include #include @@ -37,16 +37,16 @@ public: QWidget *parent = nullptr); private: - void UpdateFootageItem(int index); + void update_footage_item(int index); QTreeWidget *table_; QVector footage_; private slots: - void BrowseForFootage(); + void browse_for_footage(); }; } -#endif // FOOTAGERELINKDIALOG_H +#endif // OAK_FOOTAGERELINKDIALOG_H diff --git a/app/dialog/keyframeproperties/keyframeproperties.cpp b/app/dialog/keyframeproperties/keyframeproperties.cpp index 1c760437d..912625514 100644 --- a/app/dialog/keyframeproperties/keyframeproperties.cpp +++ b/app/dialog/keyframeproperties/keyframeproperties.cpp @@ -32,7 +32,7 @@ namespace olive { KeyframePropertiesDialog::KeyframePropertiesDialog( - const std::vector &keys, const rational &timebase, + const std::vector &keys, const Rational &timebase, QWidget *parent) : QDialog(parent) , keys_(keys) @@ -47,8 +47,8 @@ KeyframePropertiesDialog::KeyframePropertiesDialog( layout->addWidget(new QLabel("Time:"), row, 0); time_slider_ = new RationalSlider(); - time_slider_->SetDisplayType(RationalSlider::kTime); - time_slider_->SetTimebase(timebase_); + time_slider_->set_display_type(RationalSlider::k_time); + time_slider_->set_timebase(timebase_); layout->addWidget(time_slider_, row, 1); row++; @@ -57,7 +57,7 @@ KeyframePropertiesDialog::KeyframePropertiesDialog( type_select_ = new QComboBox(); connect(type_select_, SIGNAL(currentIndexChanged(int)), this, - SLOT(KeyTypeChanged(int))); + SLOT(key_type_changed(int))); layout->addWidget(type_select_, row, 1); row++; @@ -150,9 +150,9 @@ KeyframePropertiesDialog::KeyframePropertiesDialog( } if (all_same_time) { - time_slider_->SetValue(keys_.front()->time()); + time_slider_->set_value(keys_.front()->time()); } else { - time_slider_->SetTristate(); + time_slider_->set_tristate(); } time_slider_->setEnabled(can_set_time); @@ -162,12 +162,12 @@ KeyframePropertiesDialog::KeyframePropertiesDialog( type_select_->addItem(QStringLiteral("--"), -1); // Ensure UI updates for the index being 0 - KeyTypeChanged(0); + key_type_changed(0); } - type_select_->addItem(tr("Linear"), NodeKeyframe::kLinear); - type_select_->addItem(tr("Hold"), NodeKeyframe::kHold); - type_select_->addItem(tr("Bezier"), NodeKeyframe::kBezier); + type_select_->addItem(tr("Linear"), NodeKeyframe::k_linear); + type_select_->addItem(tr("Hold"), NodeKeyframe::k_hold); + type_select_->addItem(tr("Bezier"), NodeKeyframe::k_bezier); if (all_same_type) { // If all keyframes are the same type, set it here @@ -176,19 +176,19 @@ KeyframePropertiesDialog::KeyframePropertiesDialog( type_select_->setCurrentIndex(i); // Ensure UI updates for this index - KeyTypeChanged(i); + key_type_changed(i); break; } } } - SetUpBezierSlider(bezier_in_x_slider_, all_same_bezier_in_x, + set_up_bezier_slider(bezier_in_x_slider_, all_same_bezier_in_x, keys_.front()->bezier_control_in().x()); - SetUpBezierSlider(bezier_in_y_slider_, all_same_bezier_in_y, + set_up_bezier_slider(bezier_in_y_slider_, all_same_bezier_in_y, keys_.front()->bezier_control_in().y()); - SetUpBezierSlider(bezier_out_x_slider_, all_same_bezier_out_x, + set_up_bezier_slider(bezier_out_x_slider_, all_same_bezier_out_x, keys_.front()->bezier_control_out().x()); - SetUpBezierSlider(bezier_out_y_slider_, all_same_bezier_out_y, + set_up_bezier_slider(bezier_out_y_slider_, all_same_bezier_out_y, keys_.front()->bezier_control_out().y()); row++; @@ -205,11 +205,11 @@ void KeyframePropertiesDialog::accept() { MultiUndoCommand *command = new MultiUndoCommand(); - rational new_time = time_slider_->GetValue(); + Rational new_time = time_slider_->get_value(); int new_type = type_select_->currentData().toInt(); foreach (NodeKeyframe *key, keys_) { - if (time_slider_->isEnabled() && !time_slider_->IsTristate()) { + if (time_slider_->isEnabled() && !time_slider_->is_tristate()) { command->add_child( new NodeParamSetKeyframeTimeCommand(key, new_time)); } @@ -221,14 +221,14 @@ void KeyframePropertiesDialog::accept() if (bezier_group_->isEnabled()) { command->add_child(new KeyframeSetBezierControlPoint( - key, NodeKeyframe::kInHandle, - QPointF(bezier_in_x_slider_->GetValue(), - bezier_in_y_slider_->GetValue()))); + key, NodeKeyframe::k_in_handle, + QPointF(bezier_in_x_slider_->get_value(), + bezier_in_y_slider_->get_value()))); command->add_child(new KeyframeSetBezierControlPoint( - key, NodeKeyframe::kOutHandle, - QPointF(bezier_out_x_slider_->GetValue(), - bezier_out_y_slider_->GetValue()))); + key, NodeKeyframe::k_out_handle, + QPointF(bezier_out_x_slider_->get_value(), + bezier_out_y_slider_->get_value()))); } } @@ -238,20 +238,20 @@ void KeyframePropertiesDialog::accept() QDialog::accept(); } -void KeyframePropertiesDialog::SetUpBezierSlider(FloatSlider *slider, +void KeyframePropertiesDialog::set_up_bezier_slider(FloatSlider *slider, bool all_same, double value) { if (all_same) { - slider->SetValue(value); + slider->set_value(value); } else { - slider->SetTristate(); + slider->set_tristate(); } } -void KeyframePropertiesDialog::KeyTypeChanged(int index) +void KeyframePropertiesDialog::key_type_changed(int index) { bezier_group_->setEnabled(type_select_->itemData(index) == - NodeKeyframe::kBezier); + NodeKeyframe::k_bezier); } } diff --git a/app/dialog/keyframeproperties/keyframeproperties.h b/app/dialog/keyframeproperties/keyframeproperties.h index f0f8b7547..cd4914de3 100644 --- a/app/dialog/keyframeproperties/keyframeproperties.h +++ b/app/dialog/keyframeproperties/keyframeproperties.h @@ -19,8 +19,8 @@ ***/ -#ifndef KEYFRAMEPROPERTIESDIALOG_H -#define KEYFRAMEPROPERTIESDIALOG_H +#ifndef OAK_KEYFRAMEPROPERTIESDIALOG_H +#define OAK_KEYFRAMEPROPERTIESDIALOG_H #include #include @@ -37,18 +37,18 @@ class KeyframePropertiesDialog : public QDialog { Q_OBJECT public: KeyframePropertiesDialog(const std::vector &keys, - const rational &timebase, + const Rational &timebase, QWidget *parent = nullptr); public slots: virtual void accept() override; private: - void SetUpBezierSlider(FloatSlider *slider, bool all_same, double value); + void set_up_bezier_slider(FloatSlider *slider, bool all_same, double value); const std::vector &keys_; - rational timebase_; + Rational timebase_; RationalSlider *time_slider_; @@ -65,9 +65,9 @@ private: FloatSlider *bezier_out_y_slider_; private slots: - void KeyTypeChanged(int index); + void key_type_changed(int index); }; } -#endif // KEYFRAMEPROPERTIESDIALOG_H +#endif // OAK_KEYFRAMEPROPERTIESDIALOG_H diff --git a/app/dialog/markerproperties/markerpropertiesdialog.cpp b/app/dialog/markerproperties/markerpropertiesdialog.cpp index cf4e3468d..3482395d5 100644 --- a/app/dialog/markerproperties/markerpropertiesdialog.cpp +++ b/app/dialog/markerproperties/markerpropertiesdialog.cpp @@ -35,7 +35,7 @@ namespace olive #define super QDialog MarkerPropertiesDialog::MarkerPropertiesDialog( - const std::vector &markers, const rational &timebase, + const std::vector &markers, const Rational &timebase, QWidget *parent) : super(parent) , markers_(markers) @@ -64,18 +64,18 @@ MarkerPropertiesDialog::MarkerPropertiesDialog( } if (markers.size() == 1) { - in_slider_->SetValue(markers.front()->time().in()); - in_slider_->SetDisplayType(RationalSlider::kTime); - in_slider_->SetTimebase(timebase); - out_slider_->SetValue(markers.front()->time().out()); - out_slider_->SetDisplayType(RationalSlider::kTime); - out_slider_->SetTimebase(timebase); + in_slider_->set_value(markers.front()->time().in()); + in_slider_->set_display_type(RationalSlider::k_time); + in_slider_->set_timebase(timebase); + out_slider_->set_value(markers.front()->time().out()); + out_slider_->set_display_type(RationalSlider::k_time); + out_slider_->set_timebase(timebase); } else { // Markers cannot be on the same time, so we disable setting time if multiple markers are selected in_slider_->setEnabled(false); - in_slider_->SetTristate(); + in_slider_->set_tristate(); out_slider_->setEnabled(false); - out_slider_->SetTristate(); + out_slider_->set_tristate(); } layout->addWidget(time_group, row, 0, 1, 2); @@ -87,10 +87,10 @@ MarkerPropertiesDialog::MarkerPropertiesDialog( color_menu_ = new ColorCodingComboBox(); layout->addWidget(color_menu_, row, 1); - color_menu_->SetColor(markers.front()->color()); + color_menu_->set_color(markers.front()->color()); for (size_t i = 1; i < markers.size(); i++) { - if (markers.at(i)->color() != color_menu_->GetSelectedColor()) { - color_menu_->SetColor(-1); + if (markers.at(i)->color() != color_menu_->get_selected_color()) { + color_menu_->set_color(-1); break; } } @@ -100,7 +100,7 @@ MarkerPropertiesDialog::MarkerPropertiesDialog( layout->addWidget(new QLabel(tr("Name:")), row, 0); label_edit_ = new LineEditWithFocusSignal(); - connect(label_edit_, &LineEditWithFocusSignal::Focused, this, + connect(label_edit_, &LineEditWithFocusSignal::focused, this, [this] { label_edit_->setPlaceholderText(QString()); }); layout->addWidget(label_edit_, row, 1); @@ -131,7 +131,7 @@ MarkerPropertiesDialog::MarkerPropertiesDialog( void MarkerPropertiesDialog::accept() { if (in_slider_->isEnabled() && - in_slider_->GetValue() > out_slider_->GetValue()) { + in_slider_->get_value() > out_slider_->get_value()) { QMessageBox::critical( this, tr("Invalid Values"), tr("In point must be less than or equal to out point.")); @@ -140,7 +140,7 @@ void MarkerPropertiesDialog::accept() MultiUndoCommand *command = new MultiUndoCommand(); - int color = color_menu_->GetSelectedColor(); + int color = color_menu_->get_selected_color(); foreach (TimelineMarker *m, markers_) { if (color != -1) { @@ -156,7 +156,7 @@ void MarkerPropertiesDialog::accept() if (markers_.size() == 1) { command->add_child(new MarkerChangeTimeCommand( markers_.front(), - TimeRange(in_slider_->GetValue(), out_slider_->GetValue()))); + TimeRange(in_slider_->get_value(), out_slider_->get_value()))); } Core::instance()->undo_stack()->push(command, tr("Set Marker Properties")); diff --git a/app/dialog/markerproperties/markerpropertiesdialog.h b/app/dialog/markerproperties/markerpropertiesdialog.h index 7d3108fbf..9894f8f07 100644 --- a/app/dialog/markerproperties/markerpropertiesdialog.h +++ b/app/dialog/markerproperties/markerpropertiesdialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef MARKERPROPERTIESDIALOG_H -#define MARKERPROPERTIESDIALOG_H +#ifndef OAK_MARKERPROPERTIESDIALOG_H +#define OAK_MARKERPROPERTIESDIALOG_H #include #include @@ -44,18 +44,18 @@ protected: virtual void focusInEvent(QFocusEvent *e) override { QLineEdit::focusInEvent(e); - emit Focused(); + emit focused(); } signals: - void Focused(); + void focused(); }; class MarkerPropertiesDialog : public QDialog { Q_OBJECT public: MarkerPropertiesDialog(const std::vector &markers, - const rational &timebase, QWidget *parent = nullptr); + const Rational &timebase, QWidget *parent = nullptr); public slots: virtual void accept() override; @@ -74,4 +74,4 @@ private: } -#endif // MARKERPROPERTIESDIALOG_H +#endif // OAK_MARKERPROPERTIESDIALOG_H diff --git a/app/dialog/otioproperties/otiopropertiesdialog.h b/app/dialog/otioproperties/otiopropertiesdialog.h index 22096b819..8397d993b 100644 --- a/app/dialog/otioproperties/otiopropertiesdialog.h +++ b/app/dialog/otioproperties/otiopropertiesdialog.h @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -#ifndef OTIOPROPERTIESDIALOG_H -#define OTIOPROPERTIESDIALOG_H +#ifndef OAK_OTIOPROPERTIESDIALOG_H +#define OAK_OTIOPROPERTIESDIALOG_H #include #include @@ -56,4 +56,4 @@ private slots: } //namespace olive -#endif // OTIOPROPERTIESDIALOG_H +#endif // OAK_OTIOPROPERTIESDIALOG_H diff --git a/app/dialog/preferences/keysequenceeditor.cpp b/app/dialog/preferences/keysequenceeditor.cpp index 6a4b276c8..d2077f0f2 100644 --- a/app/dialog/preferences/keysequenceeditor.cpp +++ b/app/dialog/preferences/keysequenceeditor.cpp @@ -31,31 +31,31 @@ namespace olive KeySequenceEditor::KeySequenceEditor(QWidget *parent, QAction *a) : super(parent) - , action(a) + , action_(a) { - setKeySequence(action->shortcut()); + setKeySequence(action_->shortcut()); } void KeySequenceEditor::set_action_shortcut() { - action->setShortcut(keySequence()); + action_->setShortcut(keySequence()); } void KeySequenceEditor::reset_to_default() { - setKeySequence(action->property("keydefault").toString()); + setKeySequence(action_->property("keydefault").toString()); } QString KeySequenceEditor::action_name() { - return action->property("id").toString(); + return action_->property("id").toString(); } QString KeySequenceEditor::export_shortcut() { QKeySequence ks = keySequence(); - if (ks != action->property("keydefault").value()) { - return action->property("id").toString() + "\t" + ks.toString(); + if (ks != action_->property("keydefault").value()) { + return action_->property("id").toString() + "\t" + ks.toString(); } return nullptr; } diff --git a/app/dialog/preferences/keysequenceeditor.h b/app/dialog/preferences/keysequenceeditor.h index 98b44575c..f9afdfbf7 100644 --- a/app/dialog/preferences/keysequenceeditor.h +++ b/app/dialog/preferences/keysequenceeditor.h @@ -19,8 +19,8 @@ ***/ -#ifndef KEYSEQUENCEEDITOR_H -#define KEYSEQUENCEEDITOR_H +#ifndef OAK_KEYSEQUENCEEDITOR_H +#define OAK_KEYSEQUENCEEDITOR_H #include @@ -106,9 +106,9 @@ private: /** * @brief Internal reference to the linked QAction */ - QAction *action; + QAction *action_; }; } -#endif // KEYSEQUENCEEDITOR_H +#endif // OAK_KEYSEQUENCEEDITOR_H diff --git a/app/dialog/preferences/preferences.cpp b/app/dialog/preferences/preferences.cpp index adbf0fe5b..89ec6a822 100644 --- a/app/dialog/preferences/preferences.cpp +++ b/app/dialog/preferences/preferences.cpp @@ -44,32 +44,32 @@ PreferencesDialog::PreferencesDialog(MainWindow *main_window, int start_tab) { setWindowTitle(tr("Preferences")); - AddTab(new PreferencesGeneralTab(), tr("General")); - AddTab(new PreferencesAppearanceTab(), tr("Appearance")); - AddTab(new PreferencesAudioTab(), tr("Audio")); - AddTab( - new PreferencesBehaviorTab(PreferencesBehaviorTab::kCategoryTimeline), + add_tab(new PreferencesGeneralTab(), tr("General")); + add_tab(new PreferencesAppearanceTab(), tr("Appearance")); + add_tab(new PreferencesAudioTab(), tr("Audio")); + add_tab( + new PreferencesBehaviorTab(PreferencesBehaviorTab::k_category_timeline), tr("Timeline")); - AddTab( - new PreferencesBehaviorTab(PreferencesBehaviorTab::kCategoryPlayback), + add_tab( + new PreferencesBehaviorTab(PreferencesBehaviorTab::k_category_playback), tr("Playback")); - AddTab(new PreferencesBehaviorTab(PreferencesBehaviorTab::kCategoryProject), + add_tab(new PreferencesBehaviorTab(PreferencesBehaviorTab::k_category_project), tr("Project")); - AddTab(new PreferencesBehaviorTab(PreferencesBehaviorTab::kCategoryNodes), + add_tab(new PreferencesBehaviorTab(PreferencesBehaviorTab::k_category_nodes), tr("Nodes")); - AddTab( - new PreferencesBehaviorTab(PreferencesBehaviorTab::kCategoryRendering), + add_tab( + new PreferencesBehaviorTab(PreferencesBehaviorTab::k_category_rendering), tr("Rendering")); - AddTab(new PreferencesDiskTab(), tr("Disk")); - AddTab(new PreferencesLutTab(), tr("LUT")); - AddTab(new PreferencesKeyboardTab(main_window), tr("Keyboard")); + add_tab(new PreferencesDiskTab(), tr("Disk")); + add_tab(new PreferencesLutTab(), tr("LUT")); + add_tab(new PreferencesKeyboardTab(main_window), tr("Keyboard")); - SetCurrentTab(start_tab); + set_current_tab(start_tab); } void PreferencesDialog::AcceptEvent() { - Config::Save(); + Config::save(); } } diff --git a/app/dialog/preferences/preferences.h b/app/dialog/preferences/preferences.h index 8299f3ff8..a8c664770 100644 --- a/app/dialog/preferences/preferences.h +++ b/app/dialog/preferences/preferences.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREFERENCESDIALOG_H -#define PREFERENCESDIALOG_H +#ifndef OAK_PREFERENCESDIALOG_H +#define OAK_PREFERENCESDIALOG_H #include #include @@ -53,4 +53,4 @@ protected: } -#endif // PREFERENCESDIALOG_H +#endif // OAK_PREFERENCESDIALOG_H diff --git a/app/dialog/preferences/tabs/preferencesappearancetab.cpp b/app/dialog/preferences/tabs/preferencesappearancetab.cpp index 17206b90c..d614ab1bb 100644 --- a/app/dialog/preferences/tabs/preferencesappearancetab.cpp +++ b/app/dialog/preferences/tabs/preferencesappearancetab.cpp @@ -52,7 +52,7 @@ PreferencesAppearanceTab::PreferencesAppearanceTab() for (i = themes.cbegin(); i != themes.cend(); i++) { style_combobox_->addItem(i.value(), i.key()); - if (StyleManager::GetStyle() == i.key()) { + if (StyleManager::get_style() == i.key()) { style_combobox_->setCurrentIndex(style_combobox_->count() - 1); } } @@ -68,14 +68,14 @@ PreferencesAppearanceTab::PreferencesAppearanceTab() QGridLayout *color_layout = new QGridLayout(color_group); - for (int i = 0; i < Node::kCategoryCount; i++) { + for (int i = 0; i < Node::k_category_count; i++) { QString cat_name = - Node::GetCategoryName(static_cast(i)); + Node::get_category_name(static_cast(i)); color_layout->addWidget(new QLabel(cat_name), i, 0); ColorCodingComboBox *ccc = new ColorCodingComboBox(); - ccc->SetColor( - OLIVE_CONFIG_STR(QStringLiteral("CatColor%1").arg(i)).toInt()); + ccc->set_color( + OAK_CONFIG_STR(QStringLiteral("CatColor%1").arg(i)).toInt()); color_layout->addWidget(ccc, i, 1); color_btns_.append(ccc); } @@ -93,7 +93,7 @@ PreferencesAppearanceTab::PreferencesAppearanceTab() marker_layout->addWidget(new QLabel("Default Marker Color"), 0, 0); marker_btn_ = new ColorCodingComboBox(); - marker_btn_->SetColor(OLIVE_CONFIG("MarkerColor").toInt()); + marker_btn_->set_color(OAK_CONFIG("MarkerColor").toInt()); marker_layout->addWidget(marker_btn_, 0, 1); appearance_layout->addWidget(marker_group, row, 0, 1, 2); @@ -102,23 +102,23 @@ PreferencesAppearanceTab::PreferencesAppearanceTab() layout->addStretch(); } -void PreferencesAppearanceTab::Accept(MultiUndoCommand *command) +void PreferencesAppearanceTab::accept(MultiUndoCommand *command) { Q_UNUSED(command) QString style_path = style_combobox_->currentData().toString(); - if (style_path != StyleManager::GetStyle()) { - StyleManager::SetStyle(style_path); - OLIVE_CONFIG("Style") = style_path; + if (style_path != StyleManager::get_style()) { + StyleManager::set_style(style_path); + OAK_CONFIG("Style") = style_path; } for (int i = 0; i < color_btns_.size(); i++) { - OLIVE_CONFIG_STR(QStringLiteral("CatColor%1").arg(i)) = - color_btns_.at(i)->GetSelectedColor(); + OAK_CONFIG_STR(QStringLiteral("CatColor%1").arg(i)) = + color_btns_.at(i)->get_selected_color(); } - OLIVE_CONFIG("MarkerColor") = marker_btn_->GetSelectedColor(); + OAK_CONFIG("MarkerColor") = marker_btn_->get_selected_color(); } } diff --git a/app/dialog/preferences/tabs/preferencesappearancetab.h b/app/dialog/preferences/tabs/preferencesappearancetab.h index 6c06043c1..bfe405b44 100644 --- a/app/dialog/preferences/tabs/preferencesappearancetab.h +++ b/app/dialog/preferences/tabs/preferencesappearancetab.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREFERENCESAPPEARANCETAB_H -#define PREFERENCESAPPEARANCETAB_H +#ifndef OAK_PREFERENCESAPPEARANCETAB_H +#define OAK_PREFERENCESAPPEARANCETAB_H #include #include @@ -38,7 +38,7 @@ class PreferencesAppearanceTab : public ConfigDialogBaseTab { public: PreferencesAppearanceTab(); - virtual void Accept(MultiUndoCommand *command) override; + virtual void accept(MultiUndoCommand *command) override; private: /** @@ -53,4 +53,4 @@ private: } -#endif // PREFERENCESAPPEARANCETAB_H +#endif // OAK_PREFERENCESAPPEARANCETAB_H diff --git a/app/dialog/preferences/tabs/preferencesaudiotab.cpp b/app/dialog/preferences/tabs/preferencesaudiotab.cpp index 399f0f4e1..ca9ef0408 100644 --- a/app/dialog/preferences/tabs/preferencesaudiotab.cpp +++ b/app/dialog/preferences/tabs/preferencesaudiotab.cpp @@ -48,15 +48,15 @@ PreferencesAudioTab::PreferencesAudioTab() connect(audio_backend_combobox_, static_cast( &QComboBox::currentIndexChanged), - this, &PreferencesAudioTab::RefreshDevices); + this, &PreferencesAudioTab::refresh_devices); main_layout->addWidget(audio_backend_combobox_, row, 1); audio_tab_layout->addLayout(main_layout); } audio_scrubbing_ = new QCheckBox( - PreferencesBehaviorTab::BehaviorPrefTr("Enable audio scrubbing")); - audio_scrubbing_->setChecked(OLIVE_CONFIG("AudioScrubbing").toBool()); + PreferencesBehaviorTab::behavior_pref_tr("Enable audio scrubbing")); + audio_scrubbing_->setChecked(OAK_CONFIG("AudioScrubbing").toBool()); audio_tab_layout->addWidget(audio_scrubbing_); { @@ -95,8 +95,8 @@ PreferencesAudioTab::PreferencesAudioTab() output_row, 0); output_rate_combo_ = new SampleRateComboBox(); - output_rate_combo_->SetSampleRate( - OLIVE_CONFIG("AudioOutputSampleRate").toInt()); + output_rate_combo_->set_sample_rate( + OAK_CONFIG("AudioOutputSampleRate").toInt()); output_param_layout->addWidget(output_rate_combo_, output_row, 1); @@ -106,8 +106,8 @@ PreferencesAudioTab::PreferencesAudioTab() new QLabel(tr("Channel Layout:")), output_row, 0); output_ch_layout_combo_ = new ChannelLayoutComboBox(); - output_ch_layout_combo_->SetChannelLayout( - OLIVE_CONFIG("AudioOutputChannelLayout").toULongLong()); + output_ch_layout_combo_->set_channel_layout( + OAK_CONFIG("AudioOutputChannelLayout").toULongLong()); output_param_layout->addWidget(output_ch_layout_combo_, output_row, 1); @@ -117,9 +117,9 @@ PreferencesAudioTab::PreferencesAudioTab() output_row, 0); output_fmt_combo_ = new SampleFormatComboBox(); - output_fmt_combo_->SetPackedFormats(); - output_fmt_combo_->SetSampleFormat(SampleFormat::from_string( - OLIVE_CONFIG("AudioOutputSampleFormat") + output_fmt_combo_->set_packed_formats(); + output_fmt_combo_->set_sample_format(SampleFormat::from_string( + OAK_CONFIG("AudioOutputSampleFormat") .toString() .toStdString())); output_param_layout->addWidget(output_fmt_combo_, output_row, @@ -154,32 +154,32 @@ PreferencesAudioTab::PreferencesAudioTab() fmt_layout->addWidget(new QLabel(tr("Format:"))); record_format_combo_ = - new ExportFormatComboBox(ExportFormatComboBox::kShowAudioOnly); + new ExportFormatComboBox(ExportFormatComboBox::k_show_audio_only); record_format_combo_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - record_format_combo_->SetFormat(static_cast( - OLIVE_CONFIG("AudioRecordingFormat").toInt())); + record_format_combo_->set_format(static_cast( + OAK_CONFIG("AudioRecordingFormat").toInt())); fmt_layout->addWidget(record_format_combo_); record_options_ = new ExportAudioTab(); - record_options_->SetFormat(record_format_combo_->GetFormat()); - record_options_->SetCodec(static_cast( - OLIVE_CONFIG("AudioRecordingCodec").toInt())); - record_options_->sample_rate_combobox()->SetSampleRate( - OLIVE_CONFIG("AudioRecordingSampleRate").toInt()); - record_options_->channel_layout_combobox()->SetChannelLayout( - OLIVE_CONFIG("AudioRecordingChannelLayout").toULongLong()); - record_options_->bit_rate_slider()->SetValue( - OLIVE_CONFIG("AudioRecordingBitRate").toInt()); - record_options_->sample_format_combobox()->SetSampleFormat( + record_options_->set_format(record_format_combo_->get_format()); + record_options_->set_codec(static_cast( + OAK_CONFIG("AudioRecordingCodec").toInt())); + record_options_->sample_rate_combobox()->set_sample_rate( + OAK_CONFIG("AudioRecordingSampleRate").toInt()); + record_options_->channel_layout_combobox()->set_channel_layout( + OAK_CONFIG("AudioRecordingChannelLayout").toULongLong()); + record_options_->bit_rate_slider()->set_value( + OAK_CONFIG("AudioRecordingBitRate").toInt()); + record_options_->sample_format_combobox()->set_sample_format( SampleFormat::from_string( - OLIVE_CONFIG("AudioRecordingSampleFormat") + OAK_CONFIG("AudioRecordingSampleFormat") .toString() .toStdString())); recording_layout->addWidget(record_options_); - connect(record_format_combo_, &ExportFormatComboBox::FormatChanged, - record_options_, &ExportAudioTab::SetFormat); + connect(record_format_combo_, &ExportFormatComboBox::format_changed, + record_options_, &ExportAudioTab::set_format); } QHBoxLayout *refresh_layout = new QHBoxLayout(); @@ -190,16 +190,16 @@ PreferencesAudioTab::PreferencesAudioTab() refresh_layout->addWidget(refresh_devices_btn_); connect(refresh_devices_btn_, &QPushButton::clicked, this, - &PreferencesAudioTab::HardRefreshBackends); + &PreferencesAudioTab::hard_refresh_backends); } audio_tab_layout->addStretch(); // Populate lists - RefreshBackends(); + refresh_backends(); } -void PreferencesAudioTab::Accept(MultiUndoCommand *command) +void PreferencesAudioTab::accept(MultiUndoCommand *command) { Q_UNUSED(command) @@ -210,38 +210,38 @@ void PreferencesAudioTab::Accept(MultiUndoCommand *command) audio_input_devices_->currentData().value(); // Get device names, which seem to be the closest thing we have to a "unique identifier" for them - OLIVE_CONFIG("AudioOutput") = audio_output_devices_->currentText(); - OLIVE_CONFIG("AudioInput") = audio_input_devices_->currentText(); + OAK_CONFIG("AudioOutput") = audio_output_devices_->currentText(); + OAK_CONFIG("AudioInput") = audio_input_devices_->currentText(); // Set devices to be used from now on - AudioManager::instance()->SetOutputDevice(output_device); - AudioManager::instance()->SetInputDevice(input_device); + AudioManager::instance()->set_output_device(output_device); + AudioManager::instance()->set_input_device(input_device); - OLIVE_CONFIG("AudioOutputSampleRate") = output_rate_combo_->GetSampleRate(); - OLIVE_CONFIG("AudioOutputChannelLayout") = - QVariant::fromValue(output_ch_layout_combo_->GetChannelLayout()); - OLIVE_CONFIG("AudioOutputSampleFormat") = QString::fromStdString( - output_fmt_combo_->GetSampleFormat().to_string()); + OAK_CONFIG("AudioOutputSampleRate") = output_rate_combo_->get_sample_rate(); + OAK_CONFIG("AudioOutputChannelLayout") = + QVariant::fromValue(output_ch_layout_combo_->get_channel_layout()); + OAK_CONFIG("AudioOutputSampleFormat") = QString::fromStdString( + output_fmt_combo_->get_sample_format().to_string()); - OLIVE_CONFIG("AudioRecordingFormat") = record_format_combo_->GetFormat(); - OLIVE_CONFIG("AudioRecordingCodec") = record_options_->GetCodec(); - OLIVE_CONFIG("AudioRecordingSampleRate") = - record_options_->sample_rate_combobox()->GetSampleRate(); - OLIVE_CONFIG("AudioRecordingChannelLayout") = QVariant::fromValue( - record_options_->channel_layout_combobox()->GetChannelLayout()); - OLIVE_CONFIG("AudioRecordingBitRate") = - QVariant::fromValue(record_options_->bit_rate_slider()->GetValue()); - OLIVE_CONFIG("AudioRecordingSampleFormat") = + OAK_CONFIG("AudioRecordingFormat") = record_format_combo_->get_format(); + OAK_CONFIG("AudioRecordingCodec") = record_options_->get_codec(); + OAK_CONFIG("AudioRecordingSampleRate") = + record_options_->sample_rate_combobox()->get_sample_rate(); + OAK_CONFIG("AudioRecordingChannelLayout") = QVariant::fromValue( + record_options_->channel_layout_combobox()->get_channel_layout()); + OAK_CONFIG("AudioRecordingBitRate") = + QVariant::fromValue(record_options_->bit_rate_slider()->get_value()); + OAK_CONFIG("AudioRecordingSampleFormat") = QString::fromStdString(record_options_->sample_format_combobox() - ->GetSampleFormat() + ->get_sample_format() .to_string()); - emit AudioManager::instance() -> OutputParamsChanged(); + emit AudioManager::instance() -> output_params_changed(); - OLIVE_CONFIG("AudioScrubbing") = audio_scrubbing_->isChecked(); + OAK_CONFIG("AudioScrubbing") = audio_scrubbing_->isChecked(); } -void PreferencesAudioTab::RefreshBackends() +void PreferencesAudioTab::refresh_backends() { audio_backend_combobox_->clear(); for (PaHostApiIndex i = 0, end = Pa_GetHostApiCount(); i < end; i++) { @@ -250,12 +250,12 @@ void PreferencesAudioTab::RefreshBackends() audio_backend_combobox_->addItem(info->name); } - RefreshDevices(); + refresh_devices(); - AttemptToSetDevicesFromConfig(); + attempt_to_set_devices_from_config(); } -void PreferencesAudioTab::RefreshDevices() +void PreferencesAudioTab::refresh_devices() { if (audio_backend_combobox_->count() == 0) { return; @@ -282,19 +282,19 @@ void PreferencesAudioTab::RefreshDevices() } } -void PreferencesAudioTab::HardRefreshBackends() +void PreferencesAudioTab::hard_refresh_backends() { - AudioManager::instance()->HardReset(); - RefreshBackends(); + AudioManager::instance()->hard_reset(); + refresh_backends(); } -void PreferencesAudioTab::AttemptToSetDevicesFromConfig() +void PreferencesAudioTab::attempt_to_set_devices_from_config() { // Load with currently active devices PaDeviceIndex current_output_index = - AudioManager::instance()->GetOutputDevice(); + AudioManager::instance()->get_output_device(); PaDeviceIndex current_input_index = - AudioManager::instance()->GetInputDevice(); + AudioManager::instance()->get_input_device(); const PaDeviceInfo *current_output = nullptr, *current_input = nullptr; if (current_output_index != paNoDevice) { diff --git a/app/dialog/preferences/tabs/preferencesaudiotab.h b/app/dialog/preferences/tabs/preferencesaudiotab.h index 7c82a84ff..c6f365604 100644 --- a/app/dialog/preferences/tabs/preferencesaudiotab.h +++ b/app/dialog/preferences/tabs/preferencesaudiotab.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREFERENCESAUDIOTAB_H -#define PREFERENCESAUDIOTAB_H +#ifndef OAK_PREFERENCESAUDIOTAB_H +#define OAK_PREFERENCESAUDIOTAB_H #include #include @@ -39,7 +39,7 @@ class PreferencesAudioTab : public ConfigDialogBaseTab { public: PreferencesAudioTab(); - virtual void Accept(MultiUndoCommand *command) override; + virtual void accept(MultiUndoCommand *command) override; private: QComboBox *audio_backend_combobox_; @@ -75,15 +75,15 @@ private: QCheckBox *audio_scrubbing_; private slots: - void RefreshBackends(); + void refresh_backends(); - void RefreshDevices(); + void refresh_devices(); - void HardRefreshBackends(); + void hard_refresh_backends(); - void AttemptToSetDevicesFromConfig(); + void attempt_to_set_devices_from_config(); }; } -#endif // PREFERENCESAUDIOTAB_H +#endif // OAK_PREFERENCESAUDIOTAB_H diff --git a/app/dialog/preferences/tabs/preferencesbehaviortab.cpp b/app/dialog/preferences/tabs/preferencesbehaviortab.cpp index 458100665..e24008e4b 100644 --- a/app/dialog/preferences/tabs/preferencesbehaviortab.cpp +++ b/app/dialog/preferences/tabs/preferencesbehaviortab.cpp @@ -36,8 +36,8 @@ PreferencesBehaviorTab::PreferencesBehaviorTab(Category category) layout->setAlignment(Qt::AlignTop); switch (category_) { - case kCategoryTimeline: - AddItems({ + case k_category_timeline: + add_items({ { tr("Auto-Seek to Imported Clips"), QStringLiteral("EnableSeekToImport") }, { tr("Edit Tool Also Seeks"), QStringLiteral("EditToolAlsoSeeks") }, @@ -54,8 +54,8 @@ PreferencesBehaviorTab::PreferencesBehaviorTab(Category category) }); break; - case kCategoryPlayback: - AddItems({ + case k_category_playback: + add_items({ { tr("Ask For Name When Setting Marker"), QStringLiteral("SetNameWithMarker") }, { tr("Automatically rewind at the end of a sequence"), @@ -63,13 +63,13 @@ PreferencesBehaviorTab::PreferencesBehaviorTab(Category category) }); break; - case kCategoryProject: - AddItem(tr("Drop Files on Media to Replace"), + case k_category_project: + add_item(tr("Drop Files on Media to Replace"), QStringLiteral("DropFileOnMediaToReplace")); break; - case kCategoryNodes: - AddItems({ + case k_category_nodes: + add_items({ { tr("Add Default Effects to New Clips"), QStringLiteral("AddDefaultEffectsToClips") }, { tr("Auto-Scale By Default"), @@ -82,7 +82,7 @@ PreferencesBehaviorTab::PreferencesBehaviorTab(Category category) }); break; - case kCategoryRendering: { + case k_category_rendering: { QLabel *backend_label = new QLabel(tr("Graphics Backend")); backend_label->setToolTip( tr("Selects the graphics API Oak should request on next launch. " @@ -96,7 +96,7 @@ PreferencesBehaviorTab::PreferencesBehaviorTab(Category category) graphics_backend_combobox_->addItem(tr("Vulkan (experimental)"), QStringLiteral("vulkan")); const QString current_backend = - OLIVE_CONFIG("GraphicsBackend").toString().toLower(); + OAK_CONFIG("GraphicsBackend").toString().toLower(); const int backend_index = graphics_backend_combobox_->findData( current_backend.isEmpty() ? QStringLiteral("opengl") : current_backend); @@ -108,40 +108,40 @@ PreferencesBehaviorTab::PreferencesBehaviorTab(Category category) backend_layout->addWidget(graphics_backend_combobox_, 1); layout->addLayout(backend_layout); - AddItem(tr("Use glFinish"), QStringLiteral("UseGLFinish")); + add_item(tr("Use glFinish"), QStringLiteral("UseGLFinish")); break; } } } -void PreferencesBehaviorTab::Accept(MultiUndoCommand *command) +void PreferencesBehaviorTab::accept(MultiUndoCommand *command) { Q_UNUSED(command) for (auto it = config_map_.cbegin(); it != config_map_.cend(); ++it) { - OLIVE_CONFIG_STR(it.value()) = it.key()->isChecked(); + OAK_CONFIG_STR(it.value()) = it.key()->isChecked(); } if (graphics_backend_combobox_) { - OLIVE_CONFIG("GraphicsBackend") = + OAK_CONFIG("GraphicsBackend") = graphics_backend_combobox_->currentData().toString(); } } -void PreferencesBehaviorTab::AddItems(const QVector &items) +void PreferencesBehaviorTab::add_items(const QVector &items) { for (const Item &i : items) { - AddItem(i.text, i.config_key, i.tooltip); + add_item(i.text, i.config_key, i.tooltip); } } -QCheckBox *PreferencesBehaviorTab::AddItem(const QString &text, +QCheckBox *PreferencesBehaviorTab::add_item(const QString &text, const QString &config_key, const QString &tooltip) { QCheckBox *checkbox = new QCheckBox(text); checkbox->setToolTip(tooltip); - checkbox->setChecked(OLIVE_CONFIG_STR(config_key).toBool()); + checkbox->setChecked(OAK_CONFIG_STR(config_key).toBool()); config_map_.insert(checkbox, config_key); diff --git a/app/dialog/preferences/tabs/preferencesbehaviortab.h b/app/dialog/preferences/tabs/preferencesbehaviortab.h index 76d30a8ab..978988e47 100644 --- a/app/dialog/preferences/tabs/preferencesbehaviortab.h +++ b/app/dialog/preferences/tabs/preferencesbehaviortab.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREFERENCESBEHAVIORTAB_H -#define PREFERENCESBEHAVIORTAB_H +#ifndef OAK_PREFERENCESBEHAVIORTAB_H +#define OAK_PREFERENCESBEHAVIORTAB_H #include #include @@ -36,18 +36,18 @@ class PreferencesBehaviorTab : public ConfigDialogBaseTab { Q_OBJECT public: enum Category { - kCategoryTimeline, - kCategoryPlayback, - kCategoryProject, - kCategoryNodes, - kCategoryRendering + k_category_timeline, + k_category_playback, + k_category_project, + k_category_nodes, + k_category_rendering }; PreferencesBehaviorTab(Category category); - virtual void Accept(MultiUndoCommand *command) override; + virtual void accept(MultiUndoCommand *command) override; - static QString BehaviorPrefTr(const char *text) + static QString behavior_pref_tr(const char *text) { return QCoreApplication::translate("olive::PreferencesBehaviorTab", text); @@ -60,8 +60,8 @@ private: QString tooltip = QString(); }; - void AddItems(const QVector &items); - QCheckBox *AddItem(const QString &text, const QString &config_key, + void add_items(const QVector &items); + QCheckBox *add_item(const QString &text, const QString &config_key, const QString &tooltip = QString()); QMap config_map_; @@ -73,4 +73,4 @@ private: } -#endif // PREFERENCESBEHAVIORTAB_H +#endif // OAK_PREFERENCESBEHAVIORTAB_H diff --git a/app/dialog/preferences/tabs/preferencesdisktab.cpp b/app/dialog/preferences/tabs/preferencesdisktab.cpp index 0f2d6a9c7..188fe126e 100644 --- a/app/dialog/preferences/tabs/preferencesdisktab.cpp +++ b/app/dialog/preferences/tabs/preferencesdisktab.cpp @@ -38,7 +38,7 @@ PreferencesDiskTab::PreferencesDiskTab() { // Get default disk cache folder default_disk_cache_folder_ = - DiskManager::instance()->GetDefaultCacheFolder(); + DiskManager::instance()->get_default_cache_folder(); QVBoxLayout *outer_layout = new QVBoxLayout(this); @@ -54,7 +54,7 @@ PreferencesDiskTab::PreferencesDiskTab() row, 0); disk_cache_location_ = - new PathWidget(default_disk_cache_folder_->GetPath()); + new PathWidget(default_disk_cache_folder_->get_path()); disk_management_layout->addWidget(disk_cache_location_, row, 1); row++; @@ -62,7 +62,7 @@ PreferencesDiskTab::PreferencesDiskTab() QPushButton *disk_cache_settings_btn = new QPushButton(tr("Disk Cache Settings")); connect(disk_cache_settings_btn, &QPushButton::clicked, this, [this]() { - DiskManager::instance()->ShowDiskCacheSettingsDialog( + DiskManager::instance()->show_disk_cache_settings_dialog( disk_cache_location_->text(), this); }); disk_management_layout->addWidget(disk_cache_settings_btn, row, 1); @@ -78,19 +78,19 @@ PreferencesDiskTab::PreferencesDiskTab() cache_behavior_layout->addWidget(new QLabel(tr("Cache Ahead:")), row, 0); cache_ahead_slider_ = new FloatSlider(); - cache_ahead_slider_->SetFormat(tr("%1 seconds")); - cache_ahead_slider_->SetMinimum(0); - cache_ahead_slider_->SetValue( - OLIVE_CONFIG("DiskCacheAhead").value().toDouble()); + cache_ahead_slider_->set_format(tr("%1 seconds")); + cache_ahead_slider_->set_minimum(0); + cache_ahead_slider_->set_value( + OAK_CONFIG("DiskCacheAhead").value().to_double()); cache_behavior_layout->addWidget(cache_ahead_slider_, row, 1); cache_behavior_layout->addWidget(new QLabel(tr("Cache Behind:")), row, 2); cache_behind_slider_ = new FloatSlider(); - cache_behind_slider_->SetMinimum(0); - cache_behind_slider_->SetFormat(tr("%1 seconds")); - cache_behind_slider_->SetValue( - OLIVE_CONFIG("DiskCacheBehind").value().toDouble()); + cache_behind_slider_->set_minimum(0); + cache_behind_slider_->set_format(tr("%1 seconds")); + cache_behind_slider_->set_value( + OAK_CONFIG("DiskCacheBehind").value().to_double()); cache_behavior_layout->addWidget(cache_behind_slider_, row, 3); row++; @@ -103,25 +103,25 @@ PreferencesDiskTab::PreferencesDiskTab() proxy_layout->addWidget(new QLabel(tr("Proxy Width:")), proxy_row, 0); proxy_width_slider_ = new IntegerSlider(); - proxy_width_slider_->SetMinimum(160); - proxy_width_slider_->SetMaximum(4096); - proxy_width_slider_->SetValue(OLIVE_CONFIG("ProxyWidth").value()); + proxy_width_slider_->set_minimum(160); + proxy_width_slider_->set_maximum(4096); + proxy_width_slider_->set_value(OAK_CONFIG("ProxyWidth").value()); proxy_layout->addWidget(proxy_width_slider_, proxy_row, 1); proxy_layout->addWidget(new QLabel(tr("Proxy Height:")), proxy_row, 2); proxy_height_slider_ = new IntegerSlider(); - proxy_height_slider_->SetMinimum(120); - proxy_height_slider_->SetMaximum(2160); - proxy_height_slider_->SetValue(OLIVE_CONFIG("ProxyHeight").value()); + proxy_height_slider_->set_minimum(120); + proxy_height_slider_->set_maximum(2160); + proxy_height_slider_->set_value(OAK_CONFIG("ProxyHeight").value()); proxy_layout->addWidget(proxy_height_slider_, proxy_row, 3); proxy_row++; proxy_layout->addWidget(new QLabel(tr("Proxy CRF:")), proxy_row, 0); proxy_crf_slider_ = new IntegerSlider(); - proxy_crf_slider_->SetMinimum(0); - proxy_crf_slider_->SetMaximum(51); - proxy_crf_slider_->SetValue(OLIVE_CONFIG("ProxyCRF").value()); + proxy_crf_slider_->set_minimum(0); + proxy_crf_slider_->set_maximum(51); + proxy_crf_slider_->set_value(OAK_CONFIG("ProxyCRF").value()); proxy_layout->addWidget(proxy_crf_slider_, proxy_row, 1); proxy_layout->addWidget(new QLabel(tr("Proxy Preset:")), proxy_row, 2); @@ -136,7 +136,7 @@ PreferencesDiskTab::PreferencesDiskTab() for (const QString &preset : presets) { proxy_preset_combo_->addItem(preset); } - proxy_preset_combo_->setCurrentText(OLIVE_CONFIG("ProxyPreset").toString()); + proxy_preset_combo_->setCurrentText(OAK_CONFIG("ProxyPreset").toString()); proxy_layout->addWidget(proxy_preset_combo_, proxy_row, 3); proxy_row++; @@ -144,7 +144,7 @@ PreferencesDiskTab::PreferencesDiskTab() proxy_include_audio_checkbox_ = new QCheckBox(tr("Include audio in proxies")); proxy_include_audio_checkbox_->setChecked( - OLIVE_CONFIG("ProxyIncludeAudio").toBool()); + OAK_CONFIG("ProxyIncludeAudio").toBool()); proxy_layout->addWidget(proxy_include_audio_checkbox_, proxy_row, 0, 1, 2); proxy_row++; @@ -152,7 +152,7 @@ PreferencesDiskTab::PreferencesDiskTab() proxy_layout->addWidget(new QLabel(tr("ffmpeg Executable:")), proxy_row, 0); proxy_ffmpeg_path_edit_ = - new QLineEdit(OLIVE_CONFIG("FFmpegPath").toString()); + new QLineEdit(OAK_CONFIG("FFmpegPath").toString()); proxy_ffmpeg_path_edit_->setPlaceholderText(tr("Auto-detect")); proxy_layout->addWidget(proxy_ffmpeg_path_edit_, proxy_row, 1); @@ -169,18 +169,18 @@ PreferencesDiskTab::PreferencesDiskTab() outer_layout->addStretch(); } -bool PreferencesDiskTab::Validate() +bool PreferencesDiskTab::validate() { - if (disk_cache_location_->text() != default_disk_cache_folder_->GetPath()) { + if (disk_cache_location_->text() != default_disk_cache_folder_->get_path()) { // Disk cache location is changing // Check if the user is okay with invalidating the current cache - if (!DiskManager::ShowDiskCacheChangeConfirmationDialog(this)) { + if (!DiskManager::show_disk_cache_change_confirmation_dialog(this)) { return false; } // Check validity of the new path - if (!FileFunctions::DirectoryIsValid(disk_cache_location_->text())) { + if (!FileFunctions::directory_is_valid(disk_cache_location_->text())) { QMessageBox::critical( this, tr("Disk Cache"), tr("Failed to set disk cache location. Access was denied.")); @@ -191,28 +191,28 @@ bool PreferencesDiskTab::Validate() return true; } -void PreferencesDiskTab::Accept(MultiUndoCommand *command) +void PreferencesDiskTab::accept(MultiUndoCommand *command) { Q_UNUSED(command) - if (disk_cache_location_->text() != default_disk_cache_folder_->GetPath()) { - default_disk_cache_folder_->SetPath(disk_cache_location_->text()); + if (disk_cache_location_->text() != default_disk_cache_folder_->get_path()) { + default_disk_cache_folder_->set_path(disk_cache_location_->text()); } - OLIVE_CONFIG("DiskCacheBehind") = QVariant::fromValue( - rational::fromDouble(cache_behind_slider_->GetValue())); - OLIVE_CONFIG("DiskCacheAhead") = QVariant::fromValue( - rational::fromDouble(cache_ahead_slider_->GetValue())); + OAK_CONFIG("DiskCacheBehind") = QVariant::fromValue( + Rational::from_double(cache_behind_slider_->get_value())); + OAK_CONFIG("DiskCacheAhead") = QVariant::fromValue( + Rational::from_double(cache_ahead_slider_->get_value())); - OLIVE_CONFIG("ProxyWidth") = - static_cast(proxy_width_slider_->GetValue()); - OLIVE_CONFIG("ProxyHeight") = - static_cast(proxy_height_slider_->GetValue()); - OLIVE_CONFIG("ProxyCRF") = static_cast(proxy_crf_slider_->GetValue()); - OLIVE_CONFIG("ProxyPreset") = proxy_preset_combo_->currentText(); - OLIVE_CONFIG("ProxyIncludeAudio") = + OAK_CONFIG("ProxyWidth") = + static_cast(proxy_width_slider_->get_value()); + OAK_CONFIG("ProxyHeight") = + static_cast(proxy_height_slider_->get_value()); + OAK_CONFIG("ProxyCRF") = static_cast(proxy_crf_slider_->get_value()); + OAK_CONFIG("ProxyPreset") = proxy_preset_combo_->currentText(); + OAK_CONFIG("ProxyIncludeAudio") = proxy_include_audio_checkbox_->isChecked(); - OLIVE_CONFIG("FFmpegPath") = proxy_ffmpeg_path_edit_->text().trimmed(); + OAK_CONFIG("FFmpegPath") = proxy_ffmpeg_path_edit_->text().trimmed(); } } diff --git a/app/dialog/preferences/tabs/preferencesdisktab.h b/app/dialog/preferences/tabs/preferencesdisktab.h index a707f1adb..0cd631d1f 100644 --- a/app/dialog/preferences/tabs/preferencesdisktab.h +++ b/app/dialog/preferences/tabs/preferencesdisktab.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREFERENCESDISKTAB_H -#define PREFERENCESDISKTAB_H +#ifndef OAK_PREFERENCESDISKTAB_H +#define OAK_PREFERENCESDISKTAB_H #include #include @@ -41,9 +41,9 @@ class PreferencesDiskTab : public ConfigDialogBaseTab { public: PreferencesDiskTab(); - virtual bool Validate() override; + virtual bool validate() override; - virtual void Accept(MultiUndoCommand *command) override; + virtual void accept(MultiUndoCommand *command) override; private: PathWidget *disk_cache_location_; @@ -64,4 +64,4 @@ private: } -#endif // PREFERENCESDISKTAB_H +#endif // OAK_PREFERENCESDISKTAB_H diff --git a/app/dialog/preferences/tabs/preferencesgeneraltab.cpp b/app/dialog/preferences/tabs/preferencesgeneraltab.cpp index 43e3172b9..1d3bc1554 100644 --- a/app/dialog/preferences/tabs/preferencesgeneraltab.cpp +++ b/app/dialog/preferences/tabs/preferencesgeneraltab.cpp @@ -53,10 +53,10 @@ PreferencesGeneralTab::PreferencesGeneralTab() QDir language_dir(QStringLiteral(":/ts")); QStringList languages = language_dir.entryList(); foreach (const QString &l, languages) { - AddLanguage(l); + add_language(l); } - QString current_language = OLIVE_CONFIG("Language").toString(); + QString current_language = OAK_CONFIG("Language").toString(); if (current_language.isEmpty()) { // No configured language, use system language current_language = QLocale::system().name(); @@ -86,11 +86,11 @@ PreferencesGeneralTab::PreferencesGeneralTab() // ComboBox indices match enum indices autoscroll_method_ = new QComboBox(); - autoscroll_method_->addItem(tr("None"), AutoScroll::kNone); - autoscroll_method_->addItem(tr("Page Scrolling"), AutoScroll::kPage); + autoscroll_method_->addItem(tr("None"), AutoScroll::k_none); + autoscroll_method_->addItem(tr("Page Scrolling"), AutoScroll::k_page); autoscroll_method_->addItem(tr("Smooth Scrolling"), - AutoScroll::kSmooth); - autoscroll_method_->setCurrentIndex(OLIVE_CONFIG("Autoscroll").toInt()); + AutoScroll::k_smooth); + autoscroll_method_->setCurrentIndex(OAK_CONFIG("Autoscroll").toInt()); timeline_layout->addWidget(autoscroll_method_, row, 1); row++; @@ -100,7 +100,7 @@ PreferencesGeneralTab::PreferencesGeneralTab() rectified_waveforms_ = new QCheckBox(); rectified_waveforms_->setChecked( - OLIVE_CONFIG("RectifiedWaveforms").toBool()); + OAK_CONFIG("RectifiedWaveforms").toBool()); timeline_layout->addWidget(rectified_waveforms_, row, 1); row++; @@ -109,11 +109,11 @@ PreferencesGeneralTab::PreferencesGeneralTab() new QLabel(tr("Default Still Image Length:")), row, 0); default_still_length_ = new RationalSlider(); - default_still_length_->SetMinimum(rational(100, 1000)); - default_still_length_->SetTimebase(rational(100, 1000)); - default_still_length_->SetFormat(tr("%1 seconds")); - default_still_length_->SetValue( - OLIVE_CONFIG("DefaultStillLength").value()); + default_still_length_->set_minimum(Rational(100, 1000)); + default_still_length_->set_timebase(Rational(100, 1000)); + default_still_length_->set_format(tr("%1 seconds")); + default_still_length_->set_value( + OAK_CONFIG("DefaultStillLength").value()); timeline_layout->addWidget(default_still_length_); } @@ -130,7 +130,7 @@ PreferencesGeneralTab::PreferencesGeneralTab() autorecovery_enabled_ = new QCheckBox(); autorecovery_enabled_->setChecked( - OLIVE_CONFIG("AutorecoveryEnabled").toBool()); + OAK_CONFIG("AutorecoveryEnabled").toBool()); autorecovery_layout->addWidget(autorecovery_enabled_, row, 1); row++; @@ -139,12 +139,12 @@ PreferencesGeneralTab::PreferencesGeneralTab() new QLabel(tr("Auto-Recovery Interval:")), row, 0); autorecovery_interval_ = new IntegerSlider(); - autorecovery_interval_->SetMinimum(1); - autorecovery_interval_->SetMaximum(60); - autorecovery_interval_->SetFormat( + autorecovery_interval_->set_minimum(1); + autorecovery_interval_->set_maximum(60); + autorecovery_interval_->set_format( QT_TRANSLATE_N_NOOP("olive::SliderBase", "%n minute(s)"), true); - autorecovery_interval_->SetValue( - OLIVE_CONFIG("AutorecoveryInterval").toLongLong()); + autorecovery_interval_->set_value( + OAK_CONFIG("AutorecoveryInterval").toLongLong()); autorecovery_layout->addWidget(autorecovery_interval_, row, 1); row++; @@ -153,10 +153,10 @@ PreferencesGeneralTab::PreferencesGeneralTab() new QLabel(tr("Maximum Versions Per Project:")), row, 0); autorecovery_maximum_ = new IntegerSlider(); - autorecovery_maximum_->SetMinimum(1); - autorecovery_maximum_->SetMaximum(1000); - autorecovery_maximum_->SetValue( - OLIVE_CONFIG("AutorecoveryMaximum").toLongLong()); + autorecovery_maximum_->set_minimum(1); + autorecovery_maximum_->set_maximum(1000); + autorecovery_maximum_->set_value( + OAK_CONFIG("AutorecoveryMaximum").toLongLong()); autorecovery_layout->addWidget(autorecovery_maximum_, row, 1); row++; @@ -164,50 +164,50 @@ PreferencesGeneralTab::PreferencesGeneralTab() QPushButton *browse_autorecoveries = new QPushButton(tr("Browse Auto-Recoveries")); connect(browse_autorecoveries, &QPushButton::clicked, Core::instance(), - &Core::BrowseAutoRecoveries); + &Core::browse_auto_recoveries); autorecovery_layout->addWidget(browse_autorecoveries, row, 1); } { QGroupBox *behavior_groupbox = - new QGroupBox(PreferencesBehaviorTab::BehaviorPrefTr("Behavior")); + new QGroupBox(PreferencesBehaviorTab::behavior_pref_tr("Behavior")); QVBoxLayout *behavior_layout = new QVBoxLayout(behavior_groupbox); layout->addWidget(behavior_groupbox); hover_focus_ = new QCheckBox( - PreferencesBehaviorTab::BehaviorPrefTr("Enable hover focus")); - hover_focus_->setToolTip(PreferencesBehaviorTab::BehaviorPrefTr( + PreferencesBehaviorTab::behavior_pref_tr("Enable hover focus")); + hover_focus_->setToolTip(PreferencesBehaviorTab::behavior_pref_tr( "Panels will be considered focused when the mouse cursor is over them without having to click them.")); - hover_focus_->setChecked(OLIVE_CONFIG("HoverFocus").toBool()); + hover_focus_->setChecked(OAK_CONFIG("HoverFocus").toBool()); behavior_layout->addWidget(hover_focus_); slider_ladder_ = new QCheckBox( - PreferencesBehaviorTab::BehaviorPrefTr("Enable slider ladder")); - slider_ladder_->setChecked(OLIVE_CONFIG("UseSliderLadders").toBool()); + PreferencesBehaviorTab::behavior_pref_tr("Enable slider ladder")); + slider_ladder_->setChecked(OAK_CONFIG("UseSliderLadders").toBool()); behavior_layout->addWidget(slider_ladder_); - scroll_zooms_ = new QCheckBox(PreferencesBehaviorTab::BehaviorPrefTr( + scroll_zooms_ = new QCheckBox(PreferencesBehaviorTab::behavior_pref_tr( "Scrolling zooms by default")); - scroll_zooms_->setToolTip(PreferencesBehaviorTab::BehaviorPrefTr( + scroll_zooms_->setToolTip(PreferencesBehaviorTab::behavior_pref_tr( "By default, scrolling will move the view around, and holding Ctrl/Cmd will make it zoom instead. " "Enabling this will switch those, scrolling will zoom by default, and holding Ctrl/Cmd will move the view instead.")); - scroll_zooms_->setChecked(OLIVE_CONFIG("ScrollZooms").toBool()); + scroll_zooms_->setChecked(OAK_CONFIG("ScrollZooms").toBool()); behavior_layout->addWidget(scroll_zooms_); } layout->addStretch(); } -void PreferencesGeneralTab::Accept(MultiUndoCommand *command) +void PreferencesGeneralTab::accept(MultiUndoCommand *command) { Q_UNUSED(command) - OLIVE_CONFIG("RectifiedWaveforms") = rectified_waveforms_->isChecked(); + OAK_CONFIG("RectifiedWaveforms") = rectified_waveforms_->isChecked(); - OLIVE_CONFIG("Autoscroll") = autoscroll_method_->currentData(); + OAK_CONFIG("Autoscroll") = autoscroll_method_->currentData(); - OLIVE_CONFIG("DefaultStillLength") = - QVariant::fromValue(default_still_length_->GetValue()); + OAK_CONFIG("DefaultStillLength") = + QVariant::fromValue(default_still_length_->get_value()); QString set_language = language_combobox_->currentData().toString(); if (QLocale::system().name() == set_language) { @@ -216,26 +216,26 @@ void PreferencesGeneralTab::Accept(MultiUndoCommand *command) } // If the language has changed, set it now - if (OLIVE_CONFIG("Language").toString() != set_language) { - OLIVE_CONFIG("Language") = set_language; - Core::instance()->SetLanguage( + if (OAK_CONFIG("Language").toString() != set_language) { + OAK_CONFIG("Language") = set_language; + Core::instance()->set_language( set_language.isEmpty() ? QLocale::system().name() : set_language); } - OLIVE_CONFIG("AutorecoveryEnabled") = autorecovery_enabled_->isChecked(); - OLIVE_CONFIG("AutorecoveryInterval") = - QVariant::fromValue(autorecovery_interval_->GetValue()); - OLIVE_CONFIG("AutorecoveryMaximum") = - QVariant::fromValue(autorecovery_maximum_->GetValue()); - Core::instance()->SetAutorecoveryInterval( - autorecovery_interval_->GetValue()); + OAK_CONFIG("AutorecoveryEnabled") = autorecovery_enabled_->isChecked(); + OAK_CONFIG("AutorecoveryInterval") = + QVariant::fromValue(autorecovery_interval_->get_value()); + OAK_CONFIG("AutorecoveryMaximum") = + QVariant::fromValue(autorecovery_maximum_->get_value()); + Core::instance()->set_autorecovery_interval( + autorecovery_interval_->get_value()); - OLIVE_CONFIG("HoverFocus") = hover_focus_->isChecked(); - OLIVE_CONFIG("UseSliderLadders") = slider_ladder_->isChecked(); - OLIVE_CONFIG("ScrollZooms") = scroll_zooms_->isChecked(); + OAK_CONFIG("HoverFocus") = hover_focus_->isChecked(); + OAK_CONFIG("UseSliderLadders") = slider_ladder_->isChecked(); + OAK_CONFIG("ScrollZooms") = scroll_zooms_->isChecked(); } -void PreferencesGeneralTab::AddLanguage(const QString &locale_name) +void PreferencesGeneralTab::add_language(const QString &locale_name) { language_combobox_->addItem(tr("%1 (%2)").arg( QLocale(locale_name).nativeLanguageName(), locale_name)); diff --git a/app/dialog/preferences/tabs/preferencesgeneraltab.h b/app/dialog/preferences/tabs/preferencesgeneraltab.h index 89f6fdd50..f3c09fa33 100644 --- a/app/dialog/preferences/tabs/preferencesgeneraltab.h +++ b/app/dialog/preferences/tabs/preferencesgeneraltab.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREFERENCESGENERALTAB_H -#define PREFERENCESGENERALTAB_H +#ifndef OAK_PREFERENCESGENERALTAB_H +#define OAK_PREFERENCESGENERALTAB_H #include #include @@ -39,10 +39,10 @@ class PreferencesGeneralTab : public ConfigDialogBaseTab { public: PreferencesGeneralTab(); - virtual void Accept(MultiUndoCommand *command) override; + virtual void accept(MultiUndoCommand *command) override; private: - void AddLanguage(const QString &locale_name); + void add_language(const QString &locale_name); QComboBox *language_combobox_; @@ -65,4 +65,4 @@ private: } -#endif // PREFERENCESGENERALTAB_H +#endif // OAK_PREFERENCESGENERALTAB_H diff --git a/app/dialog/preferences/tabs/preferenceskeyboardtab.cpp b/app/dialog/preferences/tabs/preferenceskeyboardtab.cpp index 4f33a3019..255e60b23 100644 --- a/app/dialog/preferences/tabs/preferenceskeyboardtab.cpp +++ b/app/dialog/preferences/tabs/preferenceskeyboardtab.cpp @@ -81,7 +81,7 @@ PreferencesKeyboardTab::PreferencesKeyboardTab(MainWindow *main_window) setup_kbd_shortcuts(main_window_->menuBar()); } -void PreferencesKeyboardTab::Accept(MultiUndoCommand *command) +void PreferencesKeyboardTab::accept(MultiUndoCommand *command) { Q_UNUSED(command) @@ -90,7 +90,7 @@ void PreferencesKeyboardTab::Accept(MultiUndoCommand *command) key_shortcut_fields_.at(i)->set_action_shortcut(); } - main_window_->SaveLayout(); + main_window_->save_layout(); } void PreferencesKeyboardTab::setup_kbd_shortcuts(QMenuBar *menubar) diff --git a/app/dialog/preferences/tabs/preferenceskeyboardtab.h b/app/dialog/preferences/tabs/preferenceskeyboardtab.h index bc84f4915..3c10ac3a9 100644 --- a/app/dialog/preferences/tabs/preferenceskeyboardtab.h +++ b/app/dialog/preferences/tabs/preferenceskeyboardtab.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREFERENCESKEYBOARDTAB_H -#define PREFERENCESKEYBOARDTAB_H +#ifndef OAK_PREFERENCESKEYBOARDTAB_H +#define OAK_PREFERENCESKEYBOARDTAB_H #include #include @@ -38,7 +38,7 @@ class PreferencesKeyboardTab : public ConfigDialogBaseTab { public: PreferencesKeyboardTab(MainWindow *main_window); - virtual void Accept(MultiUndoCommand *command) override; + virtual void accept(MultiUndoCommand *command) override; private slots: /** @@ -142,4 +142,4 @@ private: } -#endif // PREFERENCESKEYBOARDTAB_H +#endif // OAK_PREFERENCESKEYBOARDTAB_H diff --git a/app/dialog/preferences/tabs/preferencesluttab.cpp b/app/dialog/preferences/tabs/preferencesluttab.cpp index 4952bca0a..5cee0c6bd 100644 --- a/app/dialog/preferences/tabs/preferencesluttab.cpp +++ b/app/dialog/preferences/tabs/preferencesluttab.cpp @@ -46,7 +46,7 @@ PreferencesLutTab::PreferencesLutTab() "these locations when picking a LUT file."))); library_dirs_list_ = new QListWidget(); - library_dirs_list_->addItems(LUTLibrary::GetDirectories()); + library_dirs_list_->addItems(LUTLibrary::get_directories()); library_layout->addWidget(library_dirs_list_); QHBoxLayout *button_layout = new QHBoxLayout(); @@ -74,7 +74,7 @@ PreferencesLutTab::PreferencesLutTab() outer_layout->addStretch(); } -void PreferencesLutTab::Accept(MultiUndoCommand *command) +void PreferencesLutTab::accept(MultiUndoCommand *command) { Q_UNUSED(command) @@ -83,7 +83,7 @@ void PreferencesLutTab::Accept(MultiUndoCommand *command) dirs.append(library_dirs_list_->item(i)->text()); } - LUTLibrary::SetDirectories(dirs); + LUTLibrary::set_directories(dirs); } } diff --git a/app/dialog/preferences/tabs/preferencesluttab.h b/app/dialog/preferences/tabs/preferencesluttab.h index 27bd87b88..feafa0f7c 100644 --- a/app/dialog/preferences/tabs/preferencesluttab.h +++ b/app/dialog/preferences/tabs/preferencesluttab.h @@ -18,8 +18,8 @@ ***/ -#ifndef PREFERENCESLUTTAB_H -#define PREFERENCESLUTTAB_H +#ifndef OAK_PREFERENCESLUTTAB_H +#define OAK_PREFERENCESLUTTAB_H #include @@ -33,7 +33,7 @@ class PreferencesLutTab : public ConfigDialogBaseTab { public: PreferencesLutTab(); - virtual void Accept(MultiUndoCommand *command) override; + virtual void accept(MultiUndoCommand *command) override; private: QListWidget *library_dirs_list_; @@ -41,4 +41,4 @@ private: } -#endif // PREFERENCESLUTTAB_H +#endif // OAK_PREFERENCESLUTTAB_H diff --git a/app/dialog/progress/progress.cpp b/app/dialog/progress/progress.cpp index 93a31452c..0a82bcc7d 100644 --- a/app/dialog/progress/progress.cpp +++ b/app/dialog/progress/progress.cpp @@ -65,20 +65,20 @@ ProgressDialog::ProgressDialog(const QString &message, const QString &title, QPushButton *cancel_btn = new QPushButton(tr("Cancel")); // Signal that derivatives can connect to - connect(cancel_btn, &QPushButton::clicked, this, &ProgressDialog::Cancelled, + connect(cancel_btn, &QPushButton::clicked, this, &ProgressDialog::cancelled, Qt::DirectConnection); // Stop updating the elapsed/remaining timers connect(cancel_btn, &QPushButton::clicked, elapsed_timer_lbl_, - &ElapsedCounterWidget::Stop); + &ElapsedCounterWidget::stop); // Disable the button so that users know they don't need to keep clicking it connect(cancel_btn, &QPushButton::clicked, this, - &ProgressDialog::DisableSenderWidget); + &ProgressDialog::disable_sender_widget); // Prevent the progress bar from continuing to move connect(cancel_btn, &QPushButton::clicked, this, - &ProgressDialog::DisableProgressWidgets); + &ProgressDialog::disable_progress_widgets); cancel_layout->addWidget(cancel_btn); @@ -90,10 +90,10 @@ void ProgressDialog::showEvent(QShowEvent *e) super::showEvent(e); if (first_show_) { - elapsed_timer_lbl_->Start(); + elapsed_timer_lbl_->start(); - Core::instance()->main_window()->SetApplicationProgressStatus( - MainWindow::kProgressShow); + Core::instance()->main_window()->set_application_progress_status( + MainWindow::k_progress_show); first_show_ = false; } @@ -103,15 +103,15 @@ void ProgressDialog::closeEvent(QCloseEvent *e) { super::closeEvent(e); - Core::instance()->main_window()->SetApplicationProgressStatus( - MainWindow::kProgressNone); + Core::instance()->main_window()->set_application_progress_status( + MainWindow::k_progress_none); - elapsed_timer_lbl_->Stop(); + elapsed_timer_lbl_->stop(); first_show_ = true; } -void ProgressDialog::SetProgress(double value) +void ProgressDialog::set_progress(double value) { if (!show_progress_) { return; @@ -120,16 +120,16 @@ void ProgressDialog::SetProgress(double value) int percent = qRound(100.0 * value); bar_->setValue(percent); - elapsed_timer_lbl_->SetProgress(value); + elapsed_timer_lbl_->set_progress(value); - Core::instance()->main_window()->SetApplicationProgressValue(percent); + Core::instance()->main_window()->set_application_progress_value(percent); } -void ProgressDialog::ShowErrorMessage(const QString &title, +void ProgressDialog::show_error_message(const QString &title, const QString &message) { - Core::instance()->main_window()->SetApplicationProgressStatus( - MainWindow::kProgressError); + Core::instance()->main_window()->set_application_progress_status( + MainWindow::k_progress_error); QMessageBox b(this); b.setIcon(QMessageBox::Critical); @@ -140,12 +140,12 @@ void ProgressDialog::ShowErrorMessage(const QString &title, b.exec(); } -void ProgressDialog::DisableSenderWidget() +void ProgressDialog::disable_sender_widget() { static_cast(sender())->setEnabled(false); } -void ProgressDialog::DisableProgressWidgets() +void ProgressDialog::disable_progress_widgets() { show_progress_ = false; } diff --git a/app/dialog/progress/progress.h b/app/dialog/progress/progress.h index 1ebc92f81..244074249 100644 --- a/app/dialog/progress/progress.h +++ b/app/dialog/progress/progress.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROGRESSDIALOG_H -#define PROGRESSDIALOG_H +#ifndef OAK_PROGRESSDIALOG_H +#define OAK_PROGRESSDIALOG_H #include #include @@ -43,13 +43,13 @@ protected: virtual void closeEvent(QCloseEvent *) override; public slots: - void SetProgress(double value); + void set_progress(double value); signals: - void Cancelled(); + void cancelled(); protected: - void ShowErrorMessage(const QString &title, const QString &message); + void show_error_message(const QString &title, const QString &message); private: QProgressBar *bar_; @@ -61,11 +61,11 @@ private: bool first_show_; private slots: - void DisableSenderWidget(); + void disable_sender_widget(); - void DisableProgressWidgets(); + void disable_progress_widgets(); }; } -#endif // PROGRESSDIALOG_H +#endif // OAK_PROGRESSDIALOG_H diff --git a/app/dialog/projectproperties/projectproperties.cpp b/app/dialog/projectproperties/projectproperties.cpp index f0a0a89f0..2cbaf1058 100644 --- a/app/dialog/projectproperties/projectproperties.cpp +++ b/app/dialog/projectproperties/projectproperties.cpp @@ -82,10 +82,10 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(Project *p, QWidget *parent) color_layout->addWidget(new QLabel(tr("Reference Space:")), row, 0); reference_space_ = new QComboBox(this); - reference_space_->addItem(tr("Scene Linear"), OCIO::ROLE_SCENE_LINEAR); + reference_space_->addItem(tr("Scene Linear"), ocio::ROLE_SCENE_LINEAR); reference_space_->addItem(tr("Compositing Log"), - OCIO::ROLE_COMPOSITING_LOG); - QtUtils::SetComboBoxData(reference_space_, p->GetColorReferenceSpace()); + ocio::ROLE_COMPOSITING_LOG); + QtUtils::set_combo_box_data(reference_space_, p->get_color_reference_space()); color_layout->addWidget(reference_space_, row, 1, 1, 2); row++; @@ -93,14 +93,14 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(Project *p, QWidget *parent) QPushButton *browse_btn = new QPushButton(tr("Browse")); color_layout->addWidget(browse_btn, 0, 2); connect(browse_btn, &QPushButton::clicked, this, - &ProjectPropertiesDialog::BrowseForOCIOConfig); + &ProjectPropertiesDialog::browse_for_ocio_config); ocio_filename_->setText( - working_project_->color_manager()->GetConfigFilename()); + working_project_->color_manager()->get_config_filename()); connect(ocio_filename_, &QLineEdit::textChanged, this, - &ProjectPropertiesDialog::OCIOFilenameUpdated); - OCIOFilenameUpdated(); + &ProjectPropertiesDialog::ocio_filename_updated); + ocio_filename_updated(); tabs->addTab(color_group, tr("Color Management")); @@ -116,37 +116,37 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(Project *p, QWidget *parent) QButtonGroup *disk_cache_btn_group = new QButtonGroup(); // Create radio buttons and add to widget and button group - disk_cache_radios_[Project::kCacheUseDefaultLocation] = + disk_cache_radios_[Project::k_cache_use_default_location] = new QRadioButton(tr("Use Default Location")); - disk_cache_radios_[Project::kCacheStoreAlongsideProject] = + disk_cache_radios_[Project::k_cache_store_alongside_project] = new QRadioButton(tr("Store Alongside Project")); - disk_cache_radios_[Project::kCacheCustomPath] = + disk_cache_radios_[Project::k_cache_custom_path] = new QRadioButton(tr("Use Custom Location:")); - for (int i = 0; i < kDiskCacheRadioCount; i++) { + for (int i = 0; i < k_disk_cache_radio_count; i++) { disk_cache_btn_group->addButton(disk_cache_radios_[i]); cache_layout->addWidget(disk_cache_radios_[i]); } // Create custom cache path widget custom_cache_path_ = - new PathWidget(working_project_->GetCustomCachePath(), this); + new PathWidget(working_project_->get_custom_cache_path(), this); custom_cache_path_->setEnabled(false); cache_layout->addWidget(custom_cache_path_); // Ensure custom cache path "enabled" is tied to the radio button being checked - connect(disk_cache_radios_[Project::kCacheCustomPath], + connect(disk_cache_radios_[Project::k_cache_custom_path], &QRadioButton::toggled, custom_cache_path_, &PathWidget::setEnabled); // Check the radio button that should currently be active - disk_cache_radios_[working_project_->GetCacheLocationSetting()] + disk_cache_radios_[working_project_->get_cache_location_setting()] ->setChecked(true); // Add disk cache settings button QPushButton *disk_cache_settings_btn = new QPushButton(tr("Disk Cache Settings")); connect(disk_cache_settings_btn, &QPushButton::clicked, this, - &ProjectPropertiesDialog::OpenDiskCacheSettings); + &ProjectPropertiesDialog::open_disk_cache_settings); cache_layout->addWidget(disk_cache_settings_btn); tabs->addTab(cache_group, tr("Disk Cache")); @@ -175,57 +175,57 @@ void ProjectPropertiesDialog::accept() return; } - if (disk_cache_radios_[Project::kCacheUseDefaultLocation]->isChecked()) { + if (disk_cache_radios_[Project::k_cache_use_default_location]->isChecked()) { // Keep new cache path empty, which means default - } else if (disk_cache_radios_[Project::kCacheStoreAlongsideProject] + } else if (disk_cache_radios_[Project::k_cache_store_alongside_project] ->isChecked()) { // Ensure alongside project path is valid - if (!VerifyPathAndWarnIfBad( + if (!verify_path_and_warn_if_bad( working_project_->get_cache_alongside_project_path())) { return; } } else { // Ensure custom path is valid - if (!VerifyPathAndWarnIfBad(custom_cache_path_->text())) { + if (!verify_path_and_warn_if_bad(custom_cache_path_->text())) { return; } } - if (custom_cache_path_->text() != working_project_->GetCustomCachePath()) { + if (custom_cache_path_->text() != working_project_->get_custom_cache_path()) { // Check if the user is okay with invalidating the current cache - if (!DiskManager::ShowDiskCacheChangeConfirmationDialog(this)) { + if (!DiskManager::show_disk_cache_change_confirmation_dialog(this)) { return; } - working_project_->SetCustomCachePath(custom_cache_path_->text()); + working_project_->set_custom_cache_path(custom_cache_path_->text()); - emit DiskManager::instance() -> InvalidateProject(working_project_); + emit DiskManager::instance() -> invalidate_project(working_project_); } // This should ripple changes throughout the graph/cache that the color config has changed, and // therefore should be done after the cache path is changed - if (working_project_->color_manager()->GetConfigFilename() != + if (working_project_->color_manager()->get_config_filename() != ocio_filename_->text()) { - working_project_->color_manager()->SetConfigFilename( + working_project_->color_manager()->set_config_filename( ocio_filename_->text()); } - if (working_project_->color_manager()->GetDefaultInputColorSpace() != + if (working_project_->color_manager()->get_default_input_color_space() != default_input_colorspace_->currentText()) { - working_project_->color_manager()->SetDefaultInputColorSpace( + working_project_->color_manager()->set_default_input_color_space( default_input_colorspace_->currentText()); } - if (working_project_->GetColorReferenceSpace() != + if (working_project_->get_color_reference_space() != reference_space_->currentData().toString()) { - working_project_->SetColorReferenceSpace( + working_project_->set_color_reference_space( reference_space_->currentData().toString()); } super::accept(); } -bool ProjectPropertiesDialog::VerifyPathAndWarnIfBad(const QString &path) +bool ProjectPropertiesDialog::verify_path_and_warn_if_bad(const QString &path) { - if (!FileFunctions::DirectoryIsValid(path)) { + if (!FileFunctions::directory_is_valid(path)) { QMessageBox mb(this); mb.setWindowModality(Qt::WindowModal); mb.setIcon(QMessageBox::Critical); @@ -240,7 +240,7 @@ bool ProjectPropertiesDialog::VerifyPathAndWarnIfBad(const QString &path) return true; } -void ProjectPropertiesDialog::BrowseForOCIOConfig() +void ProjectPropertiesDialog::browse_for_ocio_config() { QString fn = QFileDialog::getOpenFileName( this, tr("Browse for OpenColorIO configuration")); @@ -249,35 +249,35 @@ void ProjectPropertiesDialog::BrowseForOCIOConfig() } } -void ProjectPropertiesDialog::OCIOFilenameUpdated() +void ProjectPropertiesDialog::ocio_filename_updated() { default_input_colorspace_->clear(); try { - OCIO::ConstConfigRcPtr c; + ocio::ConstConfigRcPtr c; if (ocio_filename_->text().isEmpty()) { - c = ColorManager::GetDefaultConfig(); + c = ColorManager::get_default_config(); } else { - c = ColorManager::CreateConfigFromFile(ocio_filename_->text()); + c = ColorManager::create_config_from_file(ocio_filename_->text()); } ocio_filename_->setStyleSheet(QString()); ocio_config_is_valid_ = true; // List input color spaces - QStringList input_cs = ColorManager::ListAvailableColorspaces(c); + QStringList input_cs = ColorManager::list_available_colorspaces(c); foreach (QString cs, input_cs) { default_input_colorspace_->addItem(cs); if (cs == - working_project_->color_manager()->GetDefaultInputColorSpace()) { + working_project_->color_manager()->get_default_input_color_space()) { default_input_colorspace_->setCurrentIndex( default_input_colorspace_->count() - 1); } } - } catch (OCIO::Exception &e) { + } catch (ocio::Exception &e) { ocio_config_is_valid_ = false; ocio_filename_->setStyleSheet( QStringLiteral("QLineEdit {color: red;}")); @@ -285,17 +285,17 @@ void ProjectPropertiesDialog::OCIOFilenameUpdated() } } -void ProjectPropertiesDialog::OpenDiskCacheSettings() +void ProjectPropertiesDialog::open_disk_cache_settings() { - if (disk_cache_radios_[Project::kCacheUseDefaultLocation]->isChecked()) { - DiskManager::instance()->ShowDiskCacheSettingsDialog( - DiskManager::instance()->GetDefaultCacheFolder(), this); - } else if (disk_cache_radios_[Project::kCacheStoreAlongsideProject] + if (disk_cache_radios_[Project::k_cache_use_default_location]->isChecked()) { + DiskManager::instance()->show_disk_cache_settings_dialog( + DiskManager::instance()->get_default_cache_folder(), this); + } else if (disk_cache_radios_[Project::k_cache_store_alongside_project] ->isChecked()) { - DiskManager::instance()->ShowDiskCacheSettingsDialog( + DiskManager::instance()->show_disk_cache_settings_dialog( working_project_->get_cache_alongside_project_path(), this); } else { - DiskManager::instance()->ShowDiskCacheSettingsDialog( + DiskManager::instance()->show_disk_cache_settings_dialog( custom_cache_path_->text(), this); } } diff --git a/app/dialog/projectproperties/projectproperties.h b/app/dialog/projectproperties/projectproperties.h index 8fda2e0d4..6ecb60497 100644 --- a/app/dialog/projectproperties/projectproperties.h +++ b/app/dialog/projectproperties/projectproperties.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTPROPERTIESDIALOG_H -#define PROJECTPROPERTIESDIALOG_H +#ifndef OAK_PROJECTPROPERTIESDIALOG_H +#define OAK_PROJECTPROPERTIESDIALOG_H #include #include @@ -44,7 +44,7 @@ public slots: virtual void accept() override; private: - bool VerifyPathAndWarnIfBad(const QString &path); + bool verify_path_and_warn_if_bad(const QString &path); Project *working_project_; @@ -60,17 +60,17 @@ private: PathWidget *custom_cache_path_; - static const int kDiskCacheRadioCount = 3; - QRadioButton *disk_cache_radios_[kDiskCacheRadioCount]; + static const int k_disk_cache_radio_count = 3; + QRadioButton *disk_cache_radios_[k_disk_cache_radio_count]; private slots: - void BrowseForOCIOConfig(); + void browse_for_ocio_config(); - void OCIOFilenameUpdated(); + void ocio_filename_updated(); - void OpenDiskCacheSettings(); + void open_disk_cache_settings(); }; } -#endif // PROJECTPROPERTIESDIALOG_H +#endif // OAK_PROJECTPROPERTIESDIALOG_H diff --git a/app/dialog/proxy/proxydialog.cpp b/app/dialog/proxy/proxydialog.cpp index 619651725..296770eee 100644 --- a/app/dialog/proxy/proxydialog.cpp +++ b/app/dialog/proxy/proxydialog.cpp @@ -43,7 +43,7 @@ ProxyDialog::ProxyDialog(QWidget *parent, const QVector &footage) setWindowTitle(tr("Proxy Settings")); const ProxyManager::ProxyParams params = - ProxyManager::ProxyParamsFromConfig(); + ProxyManager::proxy_params_from_config(); QVBoxLayout *layout = new QVBoxLayout(this); @@ -56,7 +56,7 @@ ProxyDialog::ProxyDialog(QWidget *parent, const QVector &footage) footage_tree_->setHeaderLabels({ tr("Footage"), tr("Proxy State") }); footage_tree_->setRootIsDecorated(false); footage_layout->addWidget(footage_tree_); - RefreshFootageList(); + refresh_footage_list(); custom_params_checkbox_ = new QCheckBox(tr("Use custom settings for selected footage")); @@ -79,25 +79,25 @@ ProxyDialog::ProxyDialog(QWidget *parent, const QVector &footage) settings_layout->addWidget(new QLabel(tr("Proxy Width:")), row, 0); width_slider_ = new IntegerSlider(); - width_slider_->SetMinimum(160); - width_slider_->SetMaximum(4096); - width_slider_->SetValue(params.width); + width_slider_->set_minimum(160); + width_slider_->set_maximum(4096); + width_slider_->set_value(params.width); settings_layout->addWidget(width_slider_, row, 1); settings_layout->addWidget(new QLabel(tr("Proxy Height:")), row, 2); height_slider_ = new IntegerSlider(); - height_slider_->SetMinimum(120); - height_slider_->SetMaximum(2160); - height_slider_->SetValue(params.height); + height_slider_->set_minimum(120); + height_slider_->set_maximum(2160); + height_slider_->set_value(params.height); settings_layout->addWidget(height_slider_, row, 3); row++; settings_layout->addWidget(new QLabel(tr("Proxy CRF:")), row, 0); crf_slider_ = new IntegerSlider(); - crf_slider_->SetMinimum(0); - crf_slider_->SetMaximum(51); - crf_slider_->SetValue(params.crf); + crf_slider_->set_minimum(0); + crf_slider_->set_maximum(51); + crf_slider_->set_value(params.crf); settings_layout->addWidget(crf_slider_, row, 1); settings_layout->addWidget(new QLabel(tr("Proxy Preset:")), row, 2); @@ -124,13 +124,13 @@ ProxyDialog::ProxyDialog(QWidget *parent, const QVector &footage) row++; settings_layout->addWidget(new QLabel(tr("ffmpeg Executable:")), row, 0); - ffmpeg_path_edit_ = new QLineEdit(OLIVE_CONFIG("FFmpegPath").toString()); + ffmpeg_path_edit_ = new QLineEdit(OAK_CONFIG("FFmpegPath").toString()); ffmpeg_path_edit_->setPlaceholderText(tr("Auto-detect")); settings_layout->addWidget(ffmpeg_path_edit_, row, 1); QPushButton *ffmpeg_browse_btn = new QPushButton(tr("Browse...")); connect(ffmpeg_browse_btn, &QPushButton::clicked, this, - &ProxyDialog::BrowseForFFmpeg); + &ProxyDialog::browse_for_f_fmpeg); settings_layout->addWidget(ffmpeg_browse_btn, row, 2); QHBoxLayout *button_layout = new QHBoxLayout(); @@ -139,12 +139,12 @@ ProxyDialog::ProxyDialog(QWidget *parent, const QVector &footage) if (!footage_.isEmpty()) { QPushButton *generate_btn = new QPushButton(tr("Generate Proxies")); connect(generate_btn, &QPushButton::clicked, this, - &ProxyDialog::GenerateProxies); + &ProxyDialog::generate_proxies); button_layout->addWidget(generate_btn); QPushButton *delete_btn = new QPushButton(tr("Delete Proxies")); connect(delete_btn, &QPushButton::clicked, this, - &ProxyDialog::DeleteProxies); + &ProxyDialog::delete_proxies); button_layout->addWidget(delete_btn); } @@ -157,14 +157,14 @@ ProxyDialog::ProxyDialog(QWidget *parent, const QVector &footage) void ProxyDialog::accept() { - SaveGlobalSettings(); + save_global_settings(); if (!footage_.isEmpty()) { for (Footage *item : footage_) { if (custom_params_checkbox_->isChecked()) { - item->SetCustomProxyParams(CurrentParams()); + item->set_custom_proxy_params(current_params()); } else { - item->ClearCustomProxyParams(); + item->clear_custom_proxy_params(); } } } @@ -172,88 +172,88 @@ void ProxyDialog::accept() QDialog::accept(); } -int ProxyDialog::ProxyWidth() const +int ProxyDialog::proxy_width() const { - return static_cast(width_slider_->GetValue()); + return static_cast(width_slider_->get_value()); } -int ProxyDialog::ProxyHeight() const +int ProxyDialog::proxy_height() const { - return static_cast(height_slider_->GetValue()); + return static_cast(height_slider_->get_value()); } -int ProxyDialog::ProxyCRF() const +int ProxyDialog::proxy_crf() const { - return static_cast(crf_slider_->GetValue()); + return static_cast(crf_slider_->get_value()); } -QString ProxyDialog::ProxyPreset() const +QString ProxyDialog::proxy_preset() const { return preset_combo_->currentText(); } -bool ProxyDialog::ProxyIncludeAudio() const +bool ProxyDialog::proxy_include_audio() const { return include_audio_checkbox_->isChecked(); } -QString ProxyDialog::FFmpegPath() const +QString ProxyDialog::f_fmpeg_path() const { return ffmpeg_path_edit_->text(); } -void ProxyDialog::SetProxyWidth(int width) +void ProxyDialog::set_proxy_width(int width) { - width_slider_->SetValue(width); + width_slider_->set_value(width); } -void ProxyDialog::SetProxyHeight(int height) +void ProxyDialog::set_proxy_height(int height) { - height_slider_->SetValue(height); + height_slider_->set_value(height); } -void ProxyDialog::SetProxyCRF(int crf) +void ProxyDialog::set_proxy_crf(int crf) { - crf_slider_->SetValue(crf); + crf_slider_->set_value(crf); } -void ProxyDialog::SetProxyPreset(const QString &preset) +void ProxyDialog::set_proxy_preset(const QString &preset) { preset_combo_->setCurrentText(preset); } -void ProxyDialog::SetProxyIncludeAudio(bool include_audio) +void ProxyDialog::set_proxy_include_audio(bool include_audio) { include_audio_checkbox_->setChecked(include_audio); } -void ProxyDialog::SetFFmpegPath(const QString &path) +void ProxyDialog::set_f_fmpeg_path(const QString &path) { ffmpeg_path_edit_->setText(path); } -ProxyManager::ProxyParams ProxyDialog::CurrentParams() const +ProxyManager::ProxyParams ProxyDialog::current_params() const { - ProxyManager::ProxyParams params = ProxyManager::ProxyParamsFromConfig(); - params.width = static_cast(width_slider_->GetValue()); - params.height = static_cast(height_slider_->GetValue()); - params.crf = static_cast(crf_slider_->GetValue()); + ProxyManager::ProxyParams params = ProxyManager::proxy_params_from_config(); + params.width = static_cast(width_slider_->get_value()); + params.height = static_cast(height_slider_->get_value()); + params.crf = static_cast(crf_slider_->get_value()); params.preset = preset_combo_->currentText(); params.include_audio = include_audio_checkbox_->isChecked(); return params; } -void ProxyDialog::SaveGlobalSettings() +void ProxyDialog::save_global_settings() { - OLIVE_CONFIG("ProxyWidth") = static_cast(width_slider_->GetValue()); - OLIVE_CONFIG("ProxyHeight") = static_cast(height_slider_->GetValue()); - OLIVE_CONFIG("ProxyCRF") = static_cast(crf_slider_->GetValue()); - OLIVE_CONFIG("ProxyPreset") = preset_combo_->currentText(); - OLIVE_CONFIG("ProxyIncludeAudio") = include_audio_checkbox_->isChecked(); - OLIVE_CONFIG("FFmpegPath") = ffmpeg_path_edit_->text().trimmed(); + OAK_CONFIG("ProxyWidth") = static_cast(width_slider_->get_value()); + OAK_CONFIG("ProxyHeight") = static_cast(height_slider_->get_value()); + OAK_CONFIG("ProxyCRF") = static_cast(crf_slider_->get_value()); + OAK_CONFIG("ProxyPreset") = preset_combo_->currentText(); + OAK_CONFIG("ProxyIncludeAudio") = include_audio_checkbox_->isChecked(); + OAK_CONFIG("FFmpegPath") = ffmpeg_path_edit_->text().trimmed(); } -void ProxyDialog::RefreshFootageList() +void ProxyDialog::refresh_footage_list() { if (!footage_tree_) { return; @@ -263,7 +263,7 @@ void ProxyDialog::RefreshFootageList() for (const Footage *item : footage_) { QTreeWidgetItem *tree_item = new QTreeWidgetItem(footage_tree_); tree_item->setText(0, item->filename()); - QString state = ProxyManager::ProxyStateToString(item->proxy_state()); + QString state = ProxyManager::proxy_state_to_string(item->proxy_state()); if (item->has_custom_proxy_params()) { state = tr("%1 (custom settings)").arg(state); } @@ -271,7 +271,7 @@ void ProxyDialog::RefreshFootageList() } } -void ProxyDialog::GenerateProxies() +void ProxyDialog::generate_proxies() { if (!ProxyManager::instance()) { qWarning() << "ProxyDialog::GenerateProxies: ProxyManager unavailable"; @@ -279,7 +279,7 @@ void ProxyDialog::GenerateProxies() } for (Footage *item : footage_) { - const VideoParams video = item->GetFirstEnabledVideoStream(); + const VideoParams video = item->get_first_enabled_video_stream(); if (!video.is_valid()) { qWarning() << "ProxyDialog::GenerateProxies: skipping item with no valid video stream" @@ -288,21 +288,21 @@ void ProxyDialog::GenerateProxies() } const ProxyManager::ProxyParams params = - custom_params_checkbox_->isChecked() ? CurrentParams() - : item->GetEffectiveProxyParams(); + custom_params_checkbox_->isChecked() ? current_params() + : item->get_effective_proxy_params(); const ProxyManager::Proxy proxy = - ProxyManager::instance()->GetOrStartProxy( + ProxyManager::instance()->get_or_start_proxy( item->project()->cache_path(), item->filename(), video.stream_index(), params); - item->SetProxy(proxy.filename, proxy.state, video.stream_index(), + item->set_proxy(proxy.filename, proxy.state, video.stream_index(), params.version, true); - item->InvalidateAll(Footage::kFilenameInput); + item->invalidate_all(Footage::k_filename_input); } - RefreshFootageList(); + refresh_footage_list(); } -void ProxyDialog::DeleteProxies() +void ProxyDialog::delete_proxies() { for (Footage *item : footage_) { if (item->proxy_path().isEmpty()) { @@ -310,15 +310,15 @@ void ProxyDialog::DeleteProxies() } QFile::remove(item->proxy_path()); - QFile::remove(ProxyManager::GetWorkingProxyFilename(item->proxy_path())); - item->ClearProxy(); - item->InvalidateAll(Footage::kFilenameInput); + QFile::remove(ProxyManager::get_working_proxy_filename(item->proxy_path())); + item->clear_proxy(); + item->invalidate_all(Footage::k_filename_input); } - RefreshFootageList(); + refresh_footage_list(); } -void ProxyDialog::BrowseForFFmpeg() +void ProxyDialog::browse_for_f_fmpeg() { const QString file = QFileDialog::getOpenFileName(this, tr("Select ffmpeg Executable")); diff --git a/app/dialog/proxy/proxydialog.h b/app/dialog/proxy/proxydialog.h index f5ce050f1..dc4d335fc 100644 --- a/app/dialog/proxy/proxydialog.h +++ b/app/dialog/proxy/proxydialog.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef PROXYDIALOG_H -#define PROXYDIALOG_H +#ifndef OAK_PROXYDIALOG_H +#define OAK_PROXYDIALOG_H #include #include @@ -39,36 +39,36 @@ public: virtual void accept() override; - int ProxyWidth() const; + int proxy_width() const; - int ProxyHeight() const; + int proxy_height() const; - int ProxyCRF() const; + int proxy_crf() const; - QString ProxyPreset() const; + QString proxy_preset() const; - bool ProxyIncludeAudio() const; + bool proxy_include_audio() const; - QString FFmpegPath() const; + QString f_fmpeg_path() const; - void SetProxyWidth(int width); + void set_proxy_width(int width); - void SetProxyHeight(int height); + void set_proxy_height(int height); - void SetProxyCRF(int crf); + void set_proxy_crf(int crf); - void SetProxyPreset(const QString &preset); + void set_proxy_preset(const QString &preset); - void SetProxyIncludeAudio(bool include_audio); + void set_proxy_include_audio(bool include_audio); - void SetFFmpegPath(const QString &path); + void set_f_fmpeg_path(const QString &path); private: - ProxyManager::ProxyParams CurrentParams() const; + ProxyManager::ProxyParams current_params() const; - void SaveGlobalSettings(); + void save_global_settings(); - void RefreshFootageList(); + void refresh_footage_list(); QVector footage_; @@ -89,13 +89,13 @@ private: QLineEdit *ffmpeg_path_edit_; private slots: - void GenerateProxies(); + void generate_proxies(); - void DeleteProxies(); + void delete_proxies(); - void BrowseForFFmpeg(); + void browse_for_f_fmpeg(); }; } -#endif // PROXYDIALOG_H +#endif // OAK_PROXYDIALOG_H diff --git a/app/dialog/rendercancel/rendercancel.cpp b/app/dialog/rendercancel/rendercancel.cpp index 71b1c2c5f..53f12d323 100644 --- a/app/dialog/rendercancel/rendercancel.cpp +++ b/app/dialog/rendercancel/rendercancel.cpp @@ -32,7 +32,7 @@ RenderCancelDialog::RenderCancelDialog(QWidget *parent) { } -void RenderCancelDialog::RunIfWorkersAreBusy() +void RenderCancelDialog::run_if_workers_are_busy() { if (busy_workers_ > 0) { waiting_workers_ = busy_workers_; @@ -41,41 +41,41 @@ void RenderCancelDialog::RunIfWorkersAreBusy() } } -void RenderCancelDialog::SetWorkerCount(int count) +void RenderCancelDialog::set_worker_count(int count) { total_workers_ = count; - UpdateProgress(); + update_progress(); } -void RenderCancelDialog::WorkerStarted() +void RenderCancelDialog::worker_started() { busy_workers_++; - UpdateProgress(); + update_progress(); } -void RenderCancelDialog::WorkerDone() +void RenderCancelDialog::worker_done() { busy_workers_--; - UpdateProgress(); + update_progress(); } void RenderCancelDialog::showEvent(QShowEvent *event) { QDialog::showEvent(event); - UpdateProgress(); + update_progress(); } -void RenderCancelDialog::UpdateProgress() +void RenderCancelDialog::update_progress() { if (!total_workers_ || !isVisible()) { return; } - SetProgress( + set_progress( qRound(100.0 * static_cast(waiting_workers_ - busy_workers_) / static_cast(waiting_workers_))); diff --git a/app/dialog/rendercancel/rendercancel.h b/app/dialog/rendercancel/rendercancel.h index 6a522aee8..301e4d7d1 100644 --- a/app/dialog/rendercancel/rendercancel.h +++ b/app/dialog/rendercancel/rendercancel.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERCANCELDIALOG_H -#define RENDERCANCELDIALOG_H +#ifndef OAK_RENDERCANCELDIALOG_H +#define OAK_RENDERCANCELDIALOG_H #include "dialog/progress/progress.h" @@ -32,20 +32,20 @@ class RenderCancelDialog : public ProgressDialog { public: RenderCancelDialog(QWidget *parent = nullptr); - void RunIfWorkersAreBusy(); + void run_if_workers_are_busy(); - void SetWorkerCount(int count); + void set_worker_count(int count); - void WorkerStarted(); + void worker_started(); public slots: - void WorkerDone(); + void worker_done(); protected: virtual void showEvent(QShowEvent *event) override; private: - void UpdateProgress(); + void update_progress(); int busy_workers_; @@ -56,4 +56,4 @@ private: } -#endif // RENDERCANCELDIALOG_H +#endif // OAK_RENDERCANCELDIALOG_H diff --git a/app/dialog/sequence/presetmanager.h b/app/dialog/sequence/presetmanager.h index c19ee10b4..da27df6fd 100644 --- a/app/dialog/sequence/presetmanager.h +++ b/app/dialog/sequence/presetmanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef PRESETMANAGER_H -#define PRESETMANAGER_H +#ifndef OAK_PRESETMANAGER_H +#define OAK_PRESETMANAGER_H #include #include @@ -47,19 +47,19 @@ public: { } - const QString &GetName() const + const QString &get_name() const { return name_; } - void SetName(const QString &s) + void set_name(const QString &s) { name_ = s; } - virtual void Load(QXmlStreamReader *reader) = 0; + virtual void load(QXmlStreamReader *reader) = 0; - virtual void Save(QXmlStreamWriter *writer) const = 0; + virtual void save(QXmlStreamWriter *writer) const = 0; private: QString name_; @@ -74,17 +74,17 @@ public: , parent_(parent) { // Load custom preset data from file - QFile preset_file(GetCustomPresetFilename()); + QFile preset_file(get_custom_preset_filename()); if (preset_file.open(QFile::ReadOnly)) { QXmlStreamReader reader(&preset_file); - while (XMLReadNextStartElement(&reader)) { + while (xml_read_next_start_element(&reader)) { if (reader.name() == QStringLiteral("presets")) { - while (XMLReadNextStartElement(&reader)) { + while (xml_read_next_start_element(&reader)) { if (reader.name() == QStringLiteral("preset")) { PresetPtr p = std::make_unique(); - p->Load(&reader); + p->load(&reader); custom_preset_data_.append(p); } else { @@ -103,7 +103,7 @@ public: ~PresetManager() { // Save custom presets to disk - QFile preset_file(GetCustomPresetFilename()); + QFile preset_file(get_custom_preset_filename()); if (preset_file.open(QFile::WriteOnly)) { QXmlStreamWriter writer(&preset_file); writer.setAutoFormatting(true); @@ -115,7 +115,7 @@ public: foreach (PresetPtr p, custom_preset_data_) { writer.writeStartElement(QStringLiteral("preset")); - p->Save(&writer); + p->save(&writer); writer.writeEndElement(); // preset } @@ -128,7 +128,7 @@ public: } } - QString GetPresetName(QString start) const + QString get_preset_name(QString start) const { bool ok; @@ -163,25 +163,25 @@ public: return start; } - enum SaveStatus { kAppended, kReplaced, kNotSaved }; + enum SaveStatus { k_appended, k_replaced, k_not_saved }; - SaveStatus SavePreset(PresetPtr preset) + SaveStatus save_preset(PresetPtr preset) { QString preset_name; int existing_preset; forever { - preset_name = GetPresetName(preset_name); + preset_name = get_preset_name(preset_name); if (preset_name.isEmpty()) { // Dialog cancelled - leave function entirely - return kNotSaved; + return k_not_saved; } existing_preset = -1; for (int i = 0; i < custom_preset_data_.size(); i++) { - if (custom_preset_data_.at(i)->GetName() == preset_name) { + if (custom_preset_data_.at(i)->get_name() == preset_name) { existing_preset = i; break; } @@ -200,39 +200,39 @@ public: } } - preset->SetName(preset_name); + preset->set_name(preset_name); if (existing_preset >= 0) { custom_preset_data_.replace(existing_preset, preset); - return kReplaced; + return k_replaced; } else { custom_preset_data_.append(preset); - return kAppended; + return k_appended; } } - QString GetCustomPresetFilename() const + QString get_custom_preset_filename() const { - return QDir(FileFunctions::GetConfigurationLocation()) + return QDir(FileFunctions::get_configuration_location()) .filePath(preset_name_); } - PresetPtr GetPreset(int index) + PresetPtr get_preset(int index) { return custom_preset_data_.at(index); } - void DeletePreset(int index) + void delete_preset(int index) { custom_preset_data_.removeAt(index); } - int GetNumberOfPresets() const + int get_number_of_presets() const { return custom_preset_data_.size(); } - const QVector &GetPresetData() const + const QVector &get_preset_data() const { return custom_preset_data_; } @@ -247,4 +247,4 @@ private: } -#endif // PRESETMANAGER_H +#endif // OAK_PRESETMANAGER_H diff --git a/app/dialog/sequence/sequence.cpp b/app/dialog/sequence/sequence.cpp index 8d3711a14..9cd1c9441 100644 --- a/app/dialog/sequence/sequence.cpp +++ b/app/dialog/sequence/sequence.cpp @@ -54,12 +54,12 @@ SequenceDialog::SequenceDialog(Sequence *s, Type t, QWidget *parent) parameter_tab_ = new SequenceDialogParameterTab(sequence_); splitter->addWidget(parameter_tab_); - connect(preset_tab_, &SequenceDialogPresetTab::PresetChanged, - parameter_tab_, &SequenceDialogParameterTab::PresetChanged); - connect(preset_tab_, &SequenceDialogPresetTab::PresetAccepted, this, + connect(preset_tab_, &SequenceDialogPresetTab::preset_changed, + parameter_tab_, &SequenceDialogParameterTab::preset_changed); + connect(preset_tab_, &SequenceDialogPresetTab::preset_accepted, this, &SequenceDialog::accept); - connect(parameter_tab_, &SequenceDialogParameterTab::SaveParametersAsPreset, - preset_tab_, &SequenceDialogPresetTab::SaveParametersAsPreset); + connect(parameter_tab_, &SequenceDialogParameterTab::save_parameters_as_preset, + preset_tab_, &SequenceDialogPresetTab::save_parameters_as_preset); // Set up name section QHBoxLayout *name_layout = new QHBoxLayout(); @@ -78,28 +78,28 @@ SequenceDialog::SequenceDialog(Sequence *s, Type t, QWidget *parent) connect(buttons, &QDialogButtonBox::rejected, this, &SequenceDialog::reject); connect(default_btn, &QPushButton::clicked, this, - &SequenceDialog::SetAsDefaultClicked); + &SequenceDialog::set_as_default_clicked); layout->addWidget(buttons); // Set window title based on type switch (t) { - case kNew: + case k_new: setWindowTitle(tr("New Sequence")); break; - case kExisting: - setWindowTitle(tr("Editing \"%1\"").arg(sequence_->GetLabel())); + case k_existing: + setWindowTitle(tr("Editing \"%1\"").arg(sequence_->get_label())); break; } - name_field_->setText(sequence_->GetLabel()); + name_field_->setText(sequence_->get_label()); } -void SequenceDialog::SetUndoable(bool u) +void SequenceDialog::set_undoable(bool u) { make_undoable_ = u; } -void SequenceDialog::SetNameIsEditable(bool e) +void SequenceDialog::set_name_is_editable(bool e) { name_field_->setEnabled(e); } @@ -107,24 +107,24 @@ void SequenceDialog::SetNameIsEditable(bool e) void SequenceDialog::accept() { if (name_field_->isEnabled() && name_field_->text().isEmpty()) { - QtUtils::MsgBox(this, QMessageBox::Critical, + QtUtils::msg_box(this, QMessageBox::Critical, tr("Error editing Sequence"), tr("Please enter a name for this Sequence.")); return; } - if (!VideoParams::FormatIsFloat( - parameter_tab_->GetSelectedPreviewFormat()) && - !OLIVE_CONFIG("PreviewNonFloatDontAskAgain").toBool()) { + if (!VideoParams::format_is_float( + parameter_tab_->get_selected_preview_format()) && + !OAK_CONFIG("PreviewNonFloatDontAskAgain").toBool()) { QMessageBox b(this); - QCheckBox *dont_show_again_ = new QCheckBox(tr("Don't ask me again")); + QCheckBox *dont_show_again = new QCheckBox(tr("Don't ask me again")); b.setIcon(QMessageBox::Warning); b.setWindowTitle(tr("Low Quality Preview")); b.setText(tr( "The preview resolution has been set to a non-float format. This may cause banding and clipping artifacts in the preview.\n\n" "Do you wish to continue?")); - b.setCheckBox(dont_show_again_); + b.setCheckBox(dont_show_again); b.addButton(QMessageBox::Yes); b.addButton(QMessageBox::No); @@ -133,70 +133,70 @@ void SequenceDialog::accept() return; } - if (dont_show_again_->isChecked()) { - OLIVE_CONFIG("PreviewNonFloatDontAskAgain") = true; + if (dont_show_again->isChecked()) { + OAK_CONFIG("PreviewNonFloatDontAskAgain") = true; } } // Generate video and audio parameter structs from data VideoParams video_params = - VideoParams(parameter_tab_->GetSelectedVideoWidth(), - parameter_tab_->GetSelectedVideoHeight(), - parameter_tab_->GetSelectedVideoFrameRate().flipped(), - parameter_tab_->GetSelectedPreviewFormat(), - VideoParams::kInternalChannelCount, - parameter_tab_->GetSelectedVideoPixelAspect(), - parameter_tab_->GetSelectedVideoInterlacingMode(), - parameter_tab_->GetSelectedPreviewResolution()); + VideoParams(parameter_tab_->get_selected_video_width(), + parameter_tab_->get_selected_video_height(), + parameter_tab_->get_selected_video_frame_rate().flipped(), + parameter_tab_->get_selected_preview_format(), + VideoParams::k_internal_channel_count, + parameter_tab_->get_selected_video_pixel_aspect(), + parameter_tab_->get_selected_video_interlacing_mode(), + parameter_tab_->get_selected_preview_resolution()); AudioParams audio_params = - AudioParams(parameter_tab_->GetSelectedAudioSampleRate(), - parameter_tab_->GetSelectedAudioChannelLayout(), - Sequence::kDefaultSampleFormat); + AudioParams(parameter_tab_->get_selected_audio_sample_rate(), + parameter_tab_->get_selected_audio_channel_layout(), + Sequence::k_default_sample_format); if (make_undoable_) { // Make undoable command to change the parameters SequenceParamCommand *param_command = new SequenceParamCommand( sequence_, video_params, audio_params, name_field_->text(), - parameter_tab_->GetSelectedPreviewAutoCache()); + parameter_tab_->get_selected_preview_auto_cache()); Core::instance()->undo_stack()->push( param_command, - tr("Set Sequence Parameters For \"%1\"").arg(sequence_->GetLabel())); + tr("Set Sequence Parameters For \"%1\"").arg(sequence_->get_label())); } else { // Set sequence values directly with no undo command - sequence_->SetVideoParams(video_params); - sequence_->SetAudioParams(audio_params); - sequence_->SetLabel(name_field_->text()); - sequence_->SetVideoAutoCacheEnabled( - parameter_tab_->GetSelectedPreviewAutoCache()); + sequence_->set_video_params(video_params); + sequence_->set_audio_params(audio_params); + sequence_->set_label(name_field_->text()); + sequence_->set_video_auto_cache_enabled( + parameter_tab_->get_selected_preview_auto_cache()); } QDialog::accept(); } -void SequenceDialog::SetAsDefaultClicked() +void SequenceDialog::set_as_default_clicked() { - if (QtUtils::MsgBox( + if (QtUtils::msg_box( this, QMessageBox::Question, tr("Confirm Set As Default"), tr("Are you sure you want to set the current parameters as defaults?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { // Maybe replace with Preset system - OLIVE_CONFIG("DefaultSequenceWidth") = - parameter_tab_->GetSelectedVideoWidth(); - OLIVE_CONFIG("DefaultSequenceHeight") = - parameter_tab_->GetSelectedVideoHeight(); - OLIVE_CONFIG("DefaultSequencePixelAspect") = - QVariant::fromValue(parameter_tab_->GetSelectedVideoPixelAspect()); - OLIVE_CONFIG("DefaultSequenceFrameRate") = QVariant::fromValue( - parameter_tab_->GetSelectedVideoFrameRate().flipped()); - OLIVE_CONFIG("DefaultSequenceInterlacing") = - parameter_tab_->GetSelectedVideoInterlacingMode(); - OLIVE_CONFIG("DefaultSequenceAudioFrequency") = - parameter_tab_->GetSelectedAudioSampleRate(); - OLIVE_CONFIG("DefaultSequenceAudioLayout") = QVariant::fromValue( - parameter_tab_->GetSelectedAudioChannelLayout()); + OAK_CONFIG("DefaultSequenceWidth") = + parameter_tab_->get_selected_video_width(); + OAK_CONFIG("DefaultSequenceHeight") = + parameter_tab_->get_selected_video_height(); + OAK_CONFIG("DefaultSequencePixelAspect") = + QVariant::fromValue(parameter_tab_->get_selected_video_pixel_aspect()); + OAK_CONFIG("DefaultSequenceFrameRate") = QVariant::fromValue( + parameter_tab_->get_selected_video_frame_rate().flipped()); + OAK_CONFIG("DefaultSequenceInterlacing") = + parameter_tab_->get_selected_video_interlacing_mode(); + OAK_CONFIG("DefaultSequenceAudioFrequency") = + parameter_tab_->get_selected_audio_sample_rate(); + OAK_CONFIG("DefaultSequenceAudioLayout") = QVariant::fromValue( + parameter_tab_->get_selected_audio_channel_layout()); } } @@ -208,40 +208,40 @@ SequenceDialog::SequenceParamCommand::SequenceParamCommand( , new_audio_params_(audio_params) , new_name_(name) , new_autocache_(autocache) - , old_video_params_(s->GetVideoParams()) - , old_audio_params_(s->GetAudioParams()) - , old_name_(s->GetLabel()) - , old_autocache_(s->IsVideoAutoCacheEnabled()) + , old_video_params_(s->get_video_params()) + , old_audio_params_(s->get_audio_params()) + , old_name_(s->get_label()) + , old_autocache_(s->is_video_auto_cache_enabled()) { } -Project *SequenceDialog::SequenceParamCommand::GetRelevantProject() const +Project *SequenceDialog::SequenceParamCommand::get_relevant_project() const { return sequence_->project(); } void SequenceDialog::SequenceParamCommand::redo() { - if (sequence_->GetVideoParams() != new_video_params_) { - sequence_->SetVideoParams(new_video_params_); + if (sequence_->get_video_params() != new_video_params_) { + sequence_->set_video_params(new_video_params_); } - if (sequence_->GetAudioParams() != new_audio_params_) { - sequence_->SetAudioParams(new_audio_params_); + if (sequence_->get_audio_params() != new_audio_params_) { + sequence_->set_audio_params(new_audio_params_); } - sequence_->SetLabel(new_name_); - sequence_->SetVideoAutoCacheEnabled(new_autocache_); + sequence_->set_label(new_name_); + sequence_->set_video_auto_cache_enabled(new_autocache_); } void SequenceDialog::SequenceParamCommand::undo() { - if (sequence_->GetVideoParams() != old_video_params_) { - sequence_->SetVideoParams(old_video_params_); + if (sequence_->get_video_params() != old_video_params_) { + sequence_->set_video_params(old_video_params_); } - if (sequence_->GetAudioParams() != old_audio_params_) { - sequence_->SetAudioParams(old_audio_params_); + if (sequence_->get_audio_params() != old_audio_params_) { + sequence_->set_audio_params(old_audio_params_); } - sequence_->SetLabel(old_name_); - sequence_->SetVideoAutoCacheEnabled(old_autocache_); + sequence_->set_label(old_name_); + sequence_->set_video_auto_cache_enabled(old_autocache_); } } diff --git a/app/dialog/sequence/sequence.h b/app/dialog/sequence/sequence.h index bbf93d1b3..3a344b948 100644 --- a/app/dialog/sequence/sequence.h +++ b/app/dialog/sequence/sequence.h @@ -19,8 +19,8 @@ ***/ -#ifndef SEQUENCEDIALOG_H -#define SEQUENCEDIALOG_H +#ifndef OAK_SEQUENCEDIALOG_H +#define OAK_SEQUENCEDIALOG_H #include #include @@ -54,7 +54,7 @@ public: /** * @brief Used to set the dialog mode of operation (see SequenceDialog()) */ - enum Type { kNew, kExisting }; + enum Type { k_new, k_existing }; /** * @brief SequenceDialog Constructor @@ -68,21 +68,21 @@ public: * @param parent * QWidget parent */ - SequenceDialog(Sequence *s, Type t = kExisting, QWidget *parent = nullptr); + SequenceDialog(Sequence *s, Type t = k_existing, QWidget *parent = nullptr); /** * @brief Set whether the parameter changes should be made into an undo command or not * * Defaults to true. */ - void SetUndoable(bool u); + void set_undoable(bool u); /** * @brief Set whether the name of this Sequence can be edited with this dialog * * Defaults to true. */ - void SetNameIsEditable(bool e); + void set_name_is_editable(bool e); public slots: /** @@ -110,7 +110,7 @@ private: const AudioParams &audio_params, const QString &name, bool autocache); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -131,9 +131,9 @@ private: }; private slots: - void SetAsDefaultClicked(); + void set_as_default_clicked(); }; } -#endif // SEQUENCEDIALOG_H +#endif // OAK_SEQUENCEDIALOG_H diff --git a/app/dialog/sequence/sequencedialogparametertab.cpp b/app/dialog/sequence/sequencedialogparametertab.cpp index 5954b5187..a3541e084 100644 --- a/app/dialog/sequence/sequencedialogparametertab.cpp +++ b/app/dialog/sequence/sequencedialogparametertab.cpp @@ -40,12 +40,12 @@ SequenceDialogParameterTab::SequenceDialogParameterTab(Sequence *sequence, QGridLayout *video_layout = new QGridLayout(video_group); video_layout->addWidget(new QLabel(tr("Width:")), row, 0); width_slider_ = new IntegerSlider(); - width_slider_->SetMinimum(0); + width_slider_->set_minimum(0); video_layout->addWidget(width_slider_, row, 1); row++; video_layout->addWidget(new QLabel(tr("Height:")), row, 0); height_slider_ = new IntegerSlider(); - height_slider_->SetMinimum(0); + height_slider_->set_minimum(0); video_layout->addWidget(height_slider_, row, 1); row++; video_layout->addWidget(new QLabel(tr("Frame Rate:")), row, 0); @@ -101,64 +101,64 @@ SequenceDialogParameterTab::SequenceDialogParameterTab(Sequence *sequence, layout->addWidget(preview_group); // Set values based on input sequence - VideoParams vp = sequence->GetVideoParams(); - AudioParams ap = sequence->GetAudioParams(); - width_slider_->SetValue(vp.width()); - height_slider_->SetValue(vp.height()); - framerate_combo_->SetFrameRate(vp.time_base().flipped()); - pixelaspect_combo_->SetPixelAspectRatio(vp.pixel_aspect_ratio()); - interlacing_combo_->SetInterlaceMode(vp.interlacing()); - preview_resolution_field_->SetDivider(vp.divider()); - preview_format_field_->SetPixelFormat(vp.format()); - preview_autocache_field_->setChecked(sequence->IsVideoAutoCacheEnabled()); - audio_sample_rate_field_->SetSampleRate(ap.sample_rate()); - audio_channels_field_->SetChannelLayout(ap.channel_layout()); + VideoParams vp = sequence->get_video_params(); + AudioParams ap = sequence->get_audio_params(); + width_slider_->set_value(vp.width()); + height_slider_->set_value(vp.height()); + framerate_combo_->set_frame_rate(vp.time_base().flipped()); + pixelaspect_combo_->set_pixel_aspect_ratio(vp.pixel_aspect_ratio()); + interlacing_combo_->set_interlace_mode(vp.interlacing()); + preview_resolution_field_->set_divider(vp.divider()); + preview_format_field_->set_pixel_format(vp.format()); + preview_autocache_field_->setChecked(sequence->is_video_auto_cache_enabled()); + audio_sample_rate_field_->set_sample_rate(ap.sample_rate()); + audio_channels_field_->set_channel_layout(ap.channel_layout()); connect( preview_resolution_field_, static_cast(&QComboBox::currentIndexChanged), - this, &SequenceDialogParameterTab::UpdatePreviewResolutionLabel); + this, &SequenceDialogParameterTab::update_preview_resolution_label); layout->addStretch(); QPushButton *save_preset_btn = new QPushButton(tr("Save Preset")); connect(save_preset_btn, &QPushButton::clicked, this, - &SequenceDialogParameterTab::SavePresetClicked); + &SequenceDialogParameterTab::save_preset_clicked); layout->addWidget(save_preset_btn); - UpdatePreviewResolutionLabel(); + update_preview_resolution_label(); } -void SequenceDialogParameterTab::PresetChanged(const SequencePreset &preset) +void SequenceDialogParameterTab::preset_changed(const SequencePreset &preset) { - width_slider_->SetValue(preset.width()); - height_slider_->SetValue(preset.height()); - framerate_combo_->SetFrameRate(preset.frame_rate()); - pixelaspect_combo_->SetPixelAspectRatio(preset.pixel_aspect()); - interlacing_combo_->SetInterlaceMode(preset.interlacing()); - audio_sample_rate_field_->SetSampleRate(preset.sample_rate()); - audio_channels_field_->SetChannelLayout(preset.channel_layout()); - preview_resolution_field_->SetDivider(preset.preview_divider()); - preview_format_field_->SetPixelFormat(preset.preview_format()); + width_slider_->set_value(preset.width()); + height_slider_->set_value(preset.height()); + framerate_combo_->set_frame_rate(preset.frame_rate()); + pixelaspect_combo_->set_pixel_aspect_ratio(preset.pixel_aspect()); + interlacing_combo_->set_interlace_mode(preset.interlacing()); + audio_sample_rate_field_->set_sample_rate(preset.sample_rate()); + audio_channels_field_->set_channel_layout(preset.channel_layout()); + preview_resolution_field_->set_divider(preset.preview_divider()); + preview_format_field_->set_pixel_format(preset.preview_format()); preview_autocache_field_->setChecked(preset.preview_autocache()); } -void SequenceDialogParameterTab::SavePresetClicked() +void SequenceDialogParameterTab::save_preset_clicked() { - emit SaveParametersAsPreset(SequencePreset( - QString(), GetSelectedVideoWidth(), GetSelectedVideoHeight(), - GetSelectedVideoFrameRate(), GetSelectedVideoPixelAspect(), - GetSelectedVideoInterlacingMode(), GetSelectedAudioSampleRate(), - GetSelectedAudioChannelLayout(), GetSelectedPreviewResolution(), - GetSelectedPreviewFormat(), GetSelectedPreviewAutoCache())); + emit save_parameters_as_preset(SequencePreset( + QString(), get_selected_video_width(), get_selected_video_height(), + get_selected_video_frame_rate(), get_selected_video_pixel_aspect(), + get_selected_video_interlacing_mode(), get_selected_audio_sample_rate(), + get_selected_audio_channel_layout(), get_selected_preview_resolution(), + get_selected_preview_format(), get_selected_preview_auto_cache())); } -void SequenceDialogParameterTab::UpdatePreviewResolutionLabel() +void SequenceDialogParameterTab::update_preview_resolution_label() { - VideoParams test_param(GetSelectedVideoWidth(), GetSelectedVideoHeight(), - PixelFormat::INVALID, - VideoParams::kInternalChannelCount, rational(1), - VideoParams::kInterlaceNone, + VideoParams test_param(get_selected_video_width(), get_selected_video_height(), + PixelFormat::invalid, + VideoParams::k_internal_channel_count, Rational(1), + VideoParams::k_interlace_none, preview_resolution_field_->currentData().toInt()); preview_resolution_label_->setText( diff --git a/app/dialog/sequence/sequencedialogparametertab.h b/app/dialog/sequence/sequencedialogparametertab.h index 8dc124902..6023becd5 100644 --- a/app/dialog/sequence/sequencedialogparametertab.h +++ b/app/dialog/sequence/sequencedialogparametertab.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef SEQUENCEDIALOGPARAMETERTAB_H -#define SEQUENCEDIALOGPARAMETERTAB_H +#ifndef OAK_SEQUENCEDIALOGPARAMETERTAB_H +#define OAK_SEQUENCEDIALOGPARAMETERTAB_H #include #include @@ -37,52 +37,52 @@ class SequenceDialogParameterTab : public QWidget { public: SequenceDialogParameterTab(Sequence *sequence, QWidget *parent = nullptr); - int GetSelectedVideoWidth() const + int get_selected_video_width() const { - return width_slider_->GetValue(); + return width_slider_->get_value(); } - int GetSelectedVideoHeight() const + int get_selected_video_height() const { - return height_slider_->GetValue(); + return height_slider_->get_value(); } - rational GetSelectedVideoFrameRate() const + Rational get_selected_video_frame_rate() const { - return framerate_combo_->GetFrameRate(); + return framerate_combo_->get_frame_rate(); } - rational GetSelectedVideoPixelAspect() const + Rational get_selected_video_pixel_aspect() const { - return pixelaspect_combo_->GetPixelAspectRatio(); + return pixelaspect_combo_->get_pixel_aspect_ratio(); } - VideoParams::Interlacing GetSelectedVideoInterlacingMode() const + VideoParams::Interlacing get_selected_video_interlacing_mode() const { - return interlacing_combo_->GetInterlaceMode(); + return interlacing_combo_->get_interlace_mode(); } - int GetSelectedAudioSampleRate() const + int get_selected_audio_sample_rate() const { - return audio_sample_rate_field_->GetSampleRate(); + return audio_sample_rate_field_->get_sample_rate(); } - [[nodiscard]] uint64_t GetSelectedAudioChannelLayout() const + [[nodiscard]] uint64_t get_selected_audio_channel_layout() const { - return audio_channels_field_->GetChannelLayout(); + return audio_channels_field_->get_channel_layout(); } - int GetSelectedPreviewResolution() const + int get_selected_preview_resolution() const { - return preview_resolution_field_->GetDivider(); + return preview_resolution_field_->get_divider(); } - PixelFormat GetSelectedPreviewFormat() const + PixelFormat get_selected_preview_format() const { - return preview_format_field_->GetPixelFormat(); + return preview_format_field_->get_pixel_format(); } - bool GetSelectedPreviewAutoCache() const + bool get_selected_preview_auto_cache() const { //return preview_autocache_field_->isChecked(); // TEMP: Disable sequence auto-cache, wanna see if clip cache supersedes it. @@ -90,10 +90,10 @@ public: } public slots: - void PresetChanged(const SequencePreset &preset); + void preset_changed(const SequencePreset &preset); signals: - void SaveParametersAsPreset(const SequencePreset &preset); + void save_parameters_as_preset(const SequencePreset &preset); private: IntegerSlider *width_slider_; @@ -119,11 +119,11 @@ private: QCheckBox *preview_autocache_field_; private slots: - void SavePresetClicked(); + void save_preset_clicked(); - void UpdatePreviewResolutionLabel(); + void update_preview_resolution_label(); }; } -#endif // SEQUENCEDIALOGPARAMETERTAB_H +#endif // OAK_SEQUENCEDIALOGPARAMETERTAB_H diff --git a/app/dialog/sequence/sequencedialogpresettab.cpp b/app/dialog/sequence/sequencedialogpresettab.cpp index 5f888a872..d77ed5ff2 100644 --- a/app/dialog/sequence/sequencedialogpresettab.cpp +++ b/app/dialog/sequence/sequencedialogpresettab.cpp @@ -38,9 +38,9 @@ namespace olive { -const int kDataIsPreset = Qt::UserRole; -const int kDataPresetIsCustomRole = Qt::UserRole + 1; -const int kDataPresetDataRole = Qt::UserRole + 2; +const int k_data_is_preset = Qt::UserRole; +const int k_data_preset_is_custom_role = Qt::UserRole + 1; +const int k_data_preset_data_role = Qt::UserRole + 2; SequenceDialogPresetTab::SequenceDialogPresetTab(QWidget *parent) : QWidget(parent) @@ -54,124 +54,124 @@ SequenceDialogPresetTab::SequenceDialogPresetTab(QWidget *parent) preset_tree_->setHeaderLabel(tr("Preset")); preset_tree_->setContextMenuPolicy(Qt::CustomContextMenu); connect(preset_tree_, &QTreeWidget::customContextMenuRequested, this, - &SequenceDialogPresetTab::ShowContextMenu); + &SequenceDialogPresetTab::show_context_menu); outer_layout->addWidget(preset_tree_); connect(preset_tree_, &QTreeWidget::currentItemChanged, this, - &SequenceDialogPresetTab::SelectedItemChanged); + &SequenceDialogPresetTab::selected_item_changed); connect(preset_tree_, &QTreeWidget::itemDoubleClicked, this, - &SequenceDialogPresetTab::ItemDoubleClicked); + &SequenceDialogPresetTab::item_double_clicked); // Add "my presets" folder - my_presets_folder_ = CreateFolder(tr("My Presets")); + my_presets_folder_ = create_folder(tr("My Presets")); preset_tree_->addTopLevelItem(my_presets_folder_); // Add presets preset_tree_->addTopLevelItem( - CreateHDPresetFolder(tr("4K UHD"), 3840, 2160, 2)); + create_hd_preset_folder(tr("4K UHD"), 3840, 2160, 2)); preset_tree_->addTopLevelItem( - CreateHDPresetFolder(tr("1080p"), 1920, 1080, 1)); + create_hd_preset_folder(tr("1080p"), 1920, 1080, 1)); preset_tree_->addTopLevelItem( - CreateHDPresetFolder(tr("720p"), 1280, 720, 1)); + create_hd_preset_folder(tr("720p"), 1280, 720, 1)); preset_tree_->addTopLevelItem( - CreateSDPresetFolder(tr("NTSC"), 720, 480, rational(30000, 1001), - VideoParams::kPixelAspectNTSCStandard, - VideoParams::kPixelAspectNTSCWidescreen, 1)); + create_sd_preset_folder(tr("NTSC"), 720, 480, Rational(30000, 1001), + VideoParams::k_pixel_aspect_ntsc_standard, + VideoParams::k_pixel_aspect_ntsc_widescreen, 1)); preset_tree_->addTopLevelItem( - CreateSDPresetFolder(tr("PAL"), 720, 576, rational(25, 1), - VideoParams::kPixelAspectPALStandard, - VideoParams::kPixelAspectPALWidescreen, 1)); + create_sd_preset_folder(tr("PAL"), 720, 576, Rational(25, 1), + VideoParams::k_pixel_aspect_pal_standard, + VideoParams::k_pixel_aspect_pal_widescreen, 1)); // Load custom presets - for (int i = 0; i < GetNumberOfPresets(); i++) { - AddCustomItem(my_presets_folder_, GetPreset(i), i); + for (int i = 0; i < get_number_of_presets(); i++) { + add_custom_item(my_presets_folder_, get_preset(i), i); } } -void SequenceDialogPresetTab::SaveParametersAsPreset(SequencePreset preset) +void SequenceDialogPresetTab::save_parameters_as_preset(SequencePreset preset) { PresetPtr preset_ptr = std::make_shared(preset); // If replaced, no need to make another item. If not saved, shared ptr will delete itself - if (SavePreset(preset_ptr) == kAppended) { - AddCustomItem(my_presets_folder_, preset_ptr, GetNumberOfPresets() - 1); + if (save_preset(preset_ptr) == k_appended) { + add_custom_item(my_presets_folder_, preset_ptr, get_number_of_presets() - 1); } } -QTreeWidgetItem *SequenceDialogPresetTab::CreateFolder(const QString &name) +QTreeWidgetItem *SequenceDialogPresetTab::create_folder(const QString &name) { QTreeWidgetItem *folder = new QTreeWidgetItem(); folder->setText(0, name); - folder->setIcon(0, icon::Folder); + folder->setIcon(0, icon::folder); return folder; } QTreeWidgetItem * -SequenceDialogPresetTab::CreateHDPresetFolder(const QString &name, int width, +SequenceDialogPresetTab::create_hd_preset_folder(const QString &name, int width, int height, int divider) { const PixelFormat default_format = static_cast( - OLIVE_CONFIG("OfflinePixelFormat").toInt()); + OAK_CONFIG("OfflinePixelFormat").toInt()); const bool default_autocache = false; - QTreeWidgetItem *parent = CreateFolder(name); - const uint64_t layout = kChannelLayoutStereo; - AddStandardItem(parent, + QTreeWidgetItem *parent = create_folder(name); + const uint64_t layout = k_channel_layout_stereo; + add_standard_item(parent, std::make_shared( tr("%1 23.976 FPS").arg(name), width, height, - rational(24000, 1001), VideoParams::kPixelAspectSquare, - VideoParams::kInterlaceNone, 48000, layout, divider, + Rational(24000, 1001), VideoParams::k_pixel_aspect_square, + VideoParams::k_interlace_none, 48000, layout, divider, default_format, default_autocache)); - AddStandardItem(parent, + add_standard_item(parent, std::make_shared( tr("%1 25 FPS").arg(name), width, height, - rational(25, 1), VideoParams::kPixelAspectSquare, - VideoParams::kInterlaceNone, 48000, layout, divider, + Rational(25, 1), VideoParams::k_pixel_aspect_square, + VideoParams::k_interlace_none, 48000, layout, divider, default_format, default_autocache)); - AddStandardItem(parent, + add_standard_item(parent, std::make_shared( tr("%1 29.97 FPS").arg(name), width, height, - rational(30000, 1001), VideoParams::kPixelAspectSquare, - VideoParams::kInterlaceNone, 48000, layout, divider, + Rational(30000, 1001), VideoParams::k_pixel_aspect_square, + VideoParams::k_interlace_none, 48000, layout, divider, default_format, default_autocache)); - AddStandardItem(parent, + add_standard_item(parent, std::make_shared( tr("%1 50 FPS").arg(name), width, height, - rational(50, 1), VideoParams::kPixelAspectSquare, - VideoParams::kInterlaceNone, 48000, layout, divider, + Rational(50, 1), VideoParams::k_pixel_aspect_square, + VideoParams::k_interlace_none, 48000, layout, divider, default_format, default_autocache)); - AddStandardItem(parent, + add_standard_item(parent, std::make_shared( tr("%1 59.94 FPS").arg(name), width, height, - rational(60000, 1001), VideoParams::kPixelAspectSquare, - VideoParams::kInterlaceNone, 48000, layout, divider, + Rational(60000, 1001), VideoParams::k_pixel_aspect_square, + VideoParams::k_interlace_none, 48000, layout, divider, default_format, default_autocache)); return parent; } -QTreeWidgetItem *SequenceDialogPresetTab::CreateSDPresetFolder( - const QString &name, int width, int height, const rational &frame_rate, - const rational &standard_par, const rational &wide_par, int divider) +QTreeWidgetItem *SequenceDialogPresetTab::create_sd_preset_folder( + const QString &name, int width, int height, const Rational &frame_rate, + const Rational &standard_par, const Rational &wide_par, int divider) { const PixelFormat default_format = static_cast( - OLIVE_CONFIG("OfflinePixelFormat").toInt()); + OAK_CONFIG("OfflinePixelFormat").toInt()); const bool default_autocache = false; - QTreeWidgetItem *parent = CreateFolder(name); + QTreeWidgetItem *parent = create_folder(name); preset_tree_->addTopLevelItem(parent); - const uint64_t layout = kChannelLayoutStereo; - AddStandardItem( + const uint64_t layout = k_channel_layout_stereo; + add_standard_item( parent, std::make_shared( tr("%1 Standard").arg(name), width, height, frame_rate, - standard_par, VideoParams::kInterlacedBottomFirst, 48000, + standard_par, VideoParams::k_interlaced_bottom_first, 48000, layout, divider, default_format, default_autocache)); - AddStandardItem( + add_standard_item( parent, std::make_shared( tr("%1 Widescreen").arg(name), width, height, frame_rate, - wide_par, VideoParams::kInterlacedBottomFirst, 48000, + wide_par, VideoParams::k_interlaced_bottom_first, 48000, layout, divider, default_format, default_autocache)); return parent; } -QTreeWidgetItem *SequenceDialogPresetTab::GetSelectedItem() +QTreeWidgetItem *SequenceDialogPresetTab::get_selected_item() { QList selected_items = preset_tree_->selectedItems(); @@ -182,114 +182,114 @@ QTreeWidgetItem *SequenceDialogPresetTab::GetSelectedItem() } } -QTreeWidgetItem *SequenceDialogPresetTab::GetSelectedCustomPreset() +QTreeWidgetItem *SequenceDialogPresetTab::get_selected_custom_preset() { - QTreeWidgetItem *sel = GetSelectedItem(); + QTreeWidgetItem *sel = get_selected_item(); - if (sel && sel->data(0, kDataIsPreset).toBool() && - sel->data(0, kDataPresetIsCustomRole).toBool()) { + if (sel && sel->data(0, k_data_is_preset).toBool() && + sel->data(0, k_data_preset_is_custom_role).toBool()) { return sel; } return nullptr; } -void SequenceDialogPresetTab::AddStandardItem(QTreeWidgetItem *folder, +void SequenceDialogPresetTab::add_standard_item(QTreeWidgetItem *folder, PresetPtr preset, const QString &description) { int index = default_preset_data_.size(); default_preset_data_.append(preset); - AddItemInternal(folder, preset, false, index, description); + add_item_internal(folder, preset, false, index, description); } -void SequenceDialogPresetTab::AddCustomItem(QTreeWidgetItem *folder, +void SequenceDialogPresetTab::add_custom_item(QTreeWidgetItem *folder, PresetPtr preset, int index, const QString &description) { - AddItemInternal(folder, preset, true, index, description); + add_item_internal(folder, preset, true, index, description); } -void SequenceDialogPresetTab::AddItemInternal(QTreeWidgetItem *folder, +void SequenceDialogPresetTab::add_item_internal(QTreeWidgetItem *folder, PresetPtr preset, bool is_custom, int index, const QString &description) { QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setText(0, preset->GetName()); - item->setIcon(0, icon::Video); + item->setText(0, preset->get_name()); + item->setIcon(0, icon::video); item->setToolTip(0, description); - item->setData(0, kDataIsPreset, true); - item->setData(0, kDataPresetIsCustomRole, is_custom); - item->setData(0, kDataPresetDataRole, index); + item->setData(0, k_data_is_preset, true); + item->setData(0, k_data_preset_is_custom_role, is_custom); + item->setData(0, k_data_preset_data_role, index); folder->addChild(item); } -void SequenceDialogPresetTab::SelectedItemChanged(QTreeWidgetItem *current, +void SequenceDialogPresetTab::selected_item_changed(QTreeWidgetItem *current, QTreeWidgetItem *previous) { Q_UNUSED(previous) - if (current->data(0, kDataIsPreset).toBool()) { - int preset_index = current->data(0, kDataPresetDataRole).toInt(); + if (current->data(0, k_data_is_preset).toBool()) { + int preset_index = current->data(0, k_data_preset_data_role).toInt(); PresetPtr preset_data = - (current->data(0, kDataPresetIsCustomRole).toBool()) ? - GetPreset(preset_index) : + (current->data(0, k_data_preset_is_custom_role).toBool()) ? + get_preset(preset_index) : default_preset_data_.at(preset_index); - emit PresetChanged(*static_cast(preset_data.get())); + emit preset_changed(*static_cast(preset_data.get())); } } -void SequenceDialogPresetTab::ItemDoubleClicked(QTreeWidgetItem *item, +void SequenceDialogPresetTab::item_double_clicked(QTreeWidgetItem *item, int column) { Q_UNUSED(column) - if (item->data(0, kDataIsPreset).toBool()) { - emit PresetAccepted(); + if (item->data(0, k_data_is_preset).toBool()) { + emit preset_accepted(); } } -void SequenceDialogPresetTab::ShowContextMenu() +void SequenceDialogPresetTab::show_context_menu() { - QTreeWidgetItem *sel = GetSelectedCustomPreset(); + QTreeWidgetItem *sel = get_selected_custom_preset(); if (sel) { Menu m(this); QAction *delete_action = m.addAction(tr("Delete Preset")); connect(delete_action, &QAction::triggered, this, - &SequenceDialogPresetTab::DeleteSelectedPreset); + &SequenceDialogPresetTab::delete_selected_preset); m.exec(QCursor::pos()); } } -void SequenceDialogPresetTab::DeleteSelectedPreset() +void SequenceDialogPresetTab::delete_selected_preset() { - QTreeWidgetItem *sel = GetSelectedCustomPreset(); + QTreeWidgetItem *sel = get_selected_custom_preset(); if (sel) { - int preset_index = sel->data(0, kDataPresetDataRole).toInt(); + int preset_index = sel->data(0, k_data_preset_data_role).toInt(); // Shift all items whose index was after this preset forward for (int i = 0; i < my_presets_folder_->childCount(); i++) { QTreeWidgetItem *custom_item = my_presets_folder_->child(i); int this_item_index = - custom_item->data(0, kDataPresetDataRole).toInt(); + custom_item->data(0, k_data_preset_data_role).toInt(); if (this_item_index > preset_index) { - custom_item->setData(0, kDataPresetDataRole, + custom_item->setData(0, k_data_preset_data_role, this_item_index - 1); } } // Remove the preset - DeletePreset(preset_index); + delete_preset(preset_index); // Delete the item delete sel; diff --git a/app/dialog/sequence/sequencedialogpresettab.h b/app/dialog/sequence/sequencedialogpresettab.h index 44d99b443..a569c16c5 100644 --- a/app/dialog/sequence/sequencedialogpresettab.h +++ b/app/dialog/sequence/sequencedialogpresettab.h @@ -19,8 +19,8 @@ ***/ -#ifndef SEQUENCEDIALOGPRESETTAB_H -#define SEQUENCEDIALOGPRESETTAB_H +#ifndef OAK_SEQUENCEDIALOGPRESETTAB_H +#define OAK_SEQUENCEDIALOGPRESETTAB_H #include #include @@ -39,33 +39,33 @@ public: SequenceDialogPresetTab(QWidget *parent = nullptr); public slots: - void SaveParametersAsPreset(SequencePreset preset); + void save_parameters_as_preset(SequencePreset preset); signals: - void PresetChanged(const SequencePreset &preset); + void preset_changed(const SequencePreset &preset); - void PresetAccepted(); + void preset_accepted(); private: - QTreeWidgetItem *CreateFolder(const QString &name); + QTreeWidgetItem *create_folder(const QString &name); - QTreeWidgetItem *CreateHDPresetFolder(const QString &name, int width, + QTreeWidgetItem *create_hd_preset_folder(const QString &name, int width, int height, int divider); - QTreeWidgetItem *CreateSDPresetFolder( - const QString &name, int width, int height, const rational &frame_rate, - const rational &standard_par, const rational &wide_par, int divider); + QTreeWidgetItem *create_sd_preset_folder( + const QString &name, int width, int height, const Rational &frame_rate, + const Rational &standard_par, const Rational &wide_par, int divider); - QTreeWidgetItem *GetSelectedItem(); - QTreeWidgetItem *GetSelectedCustomPreset(); + QTreeWidgetItem *get_selected_item(); + QTreeWidgetItem *get_selected_custom_preset(); - void AddStandardItem(QTreeWidgetItem *folder, PresetPtr preset, + void add_standard_item(QTreeWidgetItem *folder, PresetPtr preset, const QString &description = QString()); - void AddCustomItem(QTreeWidgetItem *folder, PresetPtr preset, int index, + void add_custom_item(QTreeWidgetItem *folder, PresetPtr preset, int index, const QString &description = QString()); - void AddItemInternal(QTreeWidgetItem *folder, PresetPtr preset, + void add_item_internal(QTreeWidgetItem *folder, PresetPtr preset, bool is_custom, int index, const QString &description = QString()); @@ -76,16 +76,16 @@ private: QVector default_preset_data_; private slots: - void SelectedItemChanged(QTreeWidgetItem *current, + void selected_item_changed(QTreeWidgetItem *current, QTreeWidgetItem *previous); - void ItemDoubleClicked(QTreeWidgetItem *item, int column); + void item_double_clicked(QTreeWidgetItem *item, int column); - void ShowContextMenu(); + void show_context_menu(); - void DeleteSelectedPreset(); + void delete_selected_preset(); }; } -#endif // SEQUENCEDIALOGPRESETTAB_H +#endif // OAK_SEQUENCEDIALOGPRESETTAB_H diff --git a/app/dialog/sequence/sequencepreset.h b/app/dialog/sequence/sequencepreset.h index 0c105b866..1071fc7a9 100644 --- a/app/dialog/sequence/sequencepreset.h +++ b/app/dialog/sequence/sequencepreset.h @@ -19,8 +19,8 @@ ***/ -#ifndef SEQUENCEPARAM_H -#define SEQUENCEPARAM_H +#ifndef OAK_SEQUENCEPARAM_H +#define OAK_SEQUENCEPARAM_H #include #include @@ -37,7 +37,7 @@ public: SequencePreset() = default; SequencePreset(const QString &name, int width, int height, - const rational &frame_rate, const rational &pixel_aspect, + const Rational &frame_rate, const Rational &pixel_aspect, VideoParams::Interlacing interlacing, int sample_rate, uint64_t channel_layout, int preview_divider, PixelFormat preview_format, bool preview_autocache) @@ -52,23 +52,23 @@ public: , preview_format_(preview_format) , preview_autocache_(preview_autocache) { - SetName(name); + set_name(name); } - virtual void Load(QXmlStreamReader *reader) override + virtual void load(QXmlStreamReader *reader) override { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("name")) { - SetName(reader->readElementText()); + set_name(reader->readElementText()); } else if (reader->name() == QStringLiteral("width")) { width_ = reader->readElementText().toInt(); } else if (reader->name() == QStringLiteral("height")) { height_ = reader->readElementText().toInt(); } else if (reader->name() == QStringLiteral("framerate")) { - frame_rate_ = rational::fromString( + frame_rate_ = Rational::from_string( reader->readElementText().toStdString()); } else if (reader->name() == QStringLiteral("pixelaspect")) { - pixel_aspect_ = rational::fromString( + pixel_aspect_ = Rational::from_string( reader->readElementText().toStdString()); } else if (reader->name() == QStringLiteral("interlacing") || reader->name() == QStringLiteral("interlacing_")) { @@ -93,19 +93,19 @@ public: } } - virtual void Save(QXmlStreamWriter *writer) const override + virtual void save(QXmlStreamWriter *writer) const override { - writer->writeTextElement(QStringLiteral("name"), GetName()); + writer->writeTextElement(QStringLiteral("name"), get_name()); writer->writeTextElement(QStringLiteral("width"), QString::number(width_)); writer->writeTextElement(QStringLiteral("height"), QString::number(height_)); writer->writeTextElement( QStringLiteral("framerate"), - QString::fromStdString(frame_rate_.toString())); + QString::fromStdString(frame_rate_.to_string())); writer->writeTextElement( QStringLiteral("pixelaspect"), - QString::fromStdString(pixel_aspect_.toString())); + QString::fromStdString(pixel_aspect_.to_string())); writer->writeTextElement(QStringLiteral("interlacing"), QString::number(interlacing_)); writer->writeTextElement(QStringLiteral("samplerate"), @@ -130,12 +130,12 @@ public: return height_; } - const rational &frame_rate() const + const Rational &frame_rate() const { return frame_rate_; } - const rational &pixel_aspect() const + const Rational &pixel_aspect() const { return pixel_aspect_; } @@ -173,8 +173,8 @@ public: private: int width_; int height_; - rational frame_rate_; - rational pixel_aspect_; + Rational frame_rate_; + Rational pixel_aspect_; VideoParams::Interlacing interlacing_; int sample_rate_; uint64_t channel_layout_; @@ -185,4 +185,4 @@ private: } -#endif // SEQUENCEPARAM_H +#endif // OAK_SEQUENCEPARAM_H diff --git a/app/dialog/speedduration/speeddurationdialog.cpp b/app/dialog/speedduration/speeddurationdialog.cpp index 7a0732f81..e19fbcd0f 100644 --- a/app/dialog/speedduration/speeddurationdialog.cpp +++ b/app/dialog/speedduration/speeddurationdialog.cpp @@ -36,7 +36,7 @@ namespace olive #define super QDialog SpeedDurationDialog::SpeedDurationDialog(const QVector &clips, - const rational &timebase, + const Rational &timebase, QWidget *parent) : super(parent) , clips_(clips) @@ -57,9 +57,9 @@ SpeedDurationDialog::SpeedDurationDialog(const QVector &clips, speed_layout->addWidget(new QLabel(tr("Speed:")), row, 0); speed_slider_ = new FloatSlider(); - speed_slider_->SetDisplayType(FloatSlider::kPercentage); - connect(speed_slider_, &FloatSlider::ValueChanged, this, - &SpeedDurationDialog::SpeedChanged); + speed_slider_->set_display_type(FloatSlider::k_percentage); + connect(speed_slider_, &FloatSlider::value_changed, this, + &SpeedDurationDialog::speed_changed); speed_layout->addWidget(speed_slider_, row, 1); row++; @@ -67,10 +67,10 @@ SpeedDurationDialog::SpeedDurationDialog(const QVector &clips, speed_layout->addWidget(new QLabel(tr("Duration:")), row, 0); dur_slider_ = new RationalSlider(); - dur_slider_->SetTimebase(timebase); - dur_slider_->SetDisplayType(RationalSlider::kTime); - connect(dur_slider_, &RationalSlider::ValueChanged, this, - &SpeedDurationDialog::DurationChanged); + dur_slider_->set_timebase(timebase); + dur_slider_->set_display_type(RationalSlider::k_time); + connect(dur_slider_, &RationalSlider::value_changed, this, + &SpeedDurationDialog::duration_changed); speed_layout->addWidget(dur_slider_, row, 1); row++; @@ -106,9 +106,9 @@ SpeedDurationDialog::SpeedDurationDialog(const QVector &clips, loop_layout->addWidget(new QLabel(tr("Loop:")), row, 0); loop_combo_ = new QComboBox(); - loop_combo_->addItem(tr("None"), int(LoopMode::kLoopModeOff)); - loop_combo_->addItem(tr("Loop"), int(LoopMode::kLoopModeLoop)); - loop_combo_->addItem(tr("Clamp"), int(LoopMode::kLoopModeClamp)); + loop_combo_->addItem(tr("None"), int(LoopMode::k_loop_mode_off)); + loop_combo_->addItem(tr("Loop"), int(LoopMode::k_loop_mode_loop)); + loop_combo_->addItem(tr("Clamp"), int(LoopMode::k_loop_mode_clamp)); loop_layout->addWidget(loop_combo_, row, 1); } @@ -157,15 +157,15 @@ SpeedDurationDialog::SpeedDurationDialog(const QVector &clips, } if (qIsNaN(start_speed_)) { - speed_slider_->SetTristate(); + speed_slider_->set_tristate(); } else { - speed_slider_->SetValue(start_speed_); + speed_slider_->set_value(start_speed_); } if (start_duration_ == -1) { - dur_slider_->SetTristate(); + dur_slider_->set_tristate(); } else { - dur_slider_->SetValue(start_duration_); + dur_slider_->set_value(start_duration_); } if (start_reverse_ == -1) { @@ -195,16 +195,16 @@ void SpeedDurationDialog::accept() TimelineRippleDeleteGapsAtRegionsCommand::RangeList ripple_ranges; foreach (ClipBlock *c, clips_) { - rational proposed_length = c->length(); + Rational proposed_length = c->length(); - if (dur_slider_->IsTristate()) { - if (link_box_->isChecked() && !speed_slider_->IsTristate()) { - proposed_length = GetLengthAdjustment(c->length(), c->speed(), - speed_slider_->GetValue(), + if (dur_slider_->is_tristate()) { + if (link_box_->isChecked() && !speed_slider_->is_tristate()) { + proposed_length = get_length_adjustment(c->length(), c->speed(), + speed_slider_->get_value(), timebase_); } } else { - proposed_length = dur_slider_->GetValue(); + proposed_length = dur_slider_->get_value(); } if (proposed_length != c->length()) { @@ -220,7 +220,7 @@ void SpeedDurationDialog::accept() if (proposed_length != c->length()) { command->add_child(new BlockTrimCommand( - c->track(), c, proposed_length, Timeline::kTrimOut)); + c->track(), c, proposed_length, Timeline::k_trim_out)); ripple_ranges.append( { c->track(), TimeRange(c->in() + proposed_length, c->out()) }); @@ -234,23 +234,23 @@ void SpeedDurationDialog::accept() } // Set speed values - if (speed_slider_->IsTristate()) { - if (link_box_->isChecked() && !dur_slider_->IsTristate()) { + if (speed_slider_->is_tristate()) { + if (link_box_->isChecked() && !dur_slider_->is_tristate()) { // Automatically determine speed from duration foreach (ClipBlock *c, clips_) { command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(c, ClipBlock::kSpeedInput)), - GetSpeedAdjustment(c->speed(), c->length(), - dur_slider_->GetValue()))); + NodeInput(c, ClipBlock::k_speed_input)), + get_speed_adjustment(c->speed(), c->length(), + dur_slider_->get_value()))); } } } else { // Set speeds to value of slider foreach (ClipBlock *c, clips_) { command->add_child(new NodeParamSetStandardValueCommand( - NodeKeyframeTrackReference(NodeInput(c, ClipBlock::kSpeedInput)), - speed_slider_->GetValue())); + NodeKeyframeTrackReference(NodeInput(c, ClipBlock::k_speed_input)), + speed_slider_->get_value())); } } @@ -259,7 +259,7 @@ void SpeedDurationDialog::accept() foreach (ClipBlock *c, clips_) { command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(c, ClipBlock::kReverseInput)), + NodeInput(c, ClipBlock::k_reverse_input)), reverse_box_->isChecked())); } } @@ -269,7 +269,7 @@ void SpeedDurationDialog::accept() foreach (ClipBlock *c, clips_) { command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(c, ClipBlock::kMaintainAudioPitchInput)), + NodeInput(c, ClipBlock::k_maintain_audio_pitch_input)), maintain_audio_pitch_box_->isChecked())); } } @@ -278,7 +278,7 @@ void SpeedDurationDialog::accept() foreach (ClipBlock *c, clips_) { command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(c, ClipBlock::kLoopModeInput)), + NodeInput(c, ClipBlock::k_loop_mode_input)), loop_combo_->currentData())); } } @@ -286,54 +286,54 @@ void SpeedDurationDialog::accept() QString name = (clips_.size() > 1) ? tr("Set %1 Clip Properties").arg(clips_.size()) : tr("Set Clip \"%1\" Properties") - .arg(clips_.first()->GetLabelOrName()); + .arg(clips_.first()->get_label_or_name()); Core::instance()->undo_stack()->push(command, name); super::accept(); } -rational SpeedDurationDialog::GetLengthAdjustment( - const rational &original_length, double original_speed, double new_speed, - const rational &timebase) +Rational SpeedDurationDialog::get_length_adjustment( + const Rational &original_length, double original_speed, double new_speed, + const Rational &timebase) { return Timecode::snap_time_to_timebase( - rational::fromDouble(original_length.toDouble() / new_speed * + Rational::from_double(original_length.to_double() / new_speed * original_speed), timebase); } -double SpeedDurationDialog::GetSpeedAdjustment(double original_speed, - const rational &original_length, - const rational &new_length) +double SpeedDurationDialog::get_speed_adjustment(double original_speed, + const Rational &original_length, + const Rational &new_length) { - return original_speed / new_length.toDouble() * original_length.toDouble(); + return original_speed / new_length.to_double() * original_length.to_double(); } -void SpeedDurationDialog::SpeedChanged(double s) +void SpeedDurationDialog::speed_changed(double s) { if (!link_box_->isChecked()) { return; } if (start_duration_ == -1) { - dur_slider_->SetTristate(); + dur_slider_->set_tristate(); } else { - dur_slider_->SetValue( - GetLengthAdjustment(start_duration_, start_speed_, s, timebase_)); + dur_slider_->set_value( + get_length_adjustment(start_duration_, start_speed_, s, timebase_)); } } -void SpeedDurationDialog::DurationChanged(const rational &r) +void SpeedDurationDialog::duration_changed(const Rational &r) { if (!link_box_->isChecked()) { return; } if (qIsNaN(start_speed_)) { - speed_slider_->SetTristate(); + speed_slider_->set_tristate(); } else { - speed_slider_->SetValue( - GetSpeedAdjustment(start_speed_, start_duration_, r)); + speed_slider_->set_value( + get_speed_adjustment(start_speed_, start_duration_, r)); } } diff --git a/app/dialog/speedduration/speeddurationdialog.h b/app/dialog/speedduration/speeddurationdialog.h index 445b905ba..22e955757 100644 --- a/app/dialog/speedduration/speeddurationdialog.h +++ b/app/dialog/speedduration/speeddurationdialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef SPEEDDURATIONDIALOG_H -#define SPEEDDURATIONDIALOG_H +#ifndef OAK_SPEEDDURATIONDIALOG_H +#define OAK_SPEEDDURATIONDIALOG_H #include #include @@ -39,7 +39,7 @@ class SpeedDurationDialog : public QDialog { Q_OBJECT public: explicit SpeedDurationDialog(const QVector &clips, - const rational &timebase, + const Rational &timebase, QWidget *parent = nullptr); public slots: @@ -48,13 +48,13 @@ public slots: signals: private: - static rational GetLengthAdjustment(const rational &original_length, + static Rational get_length_adjustment(const Rational &original_length, double original_speed, double new_speed, - const rational &timebase); + const Rational &timebase); - static double GetSpeedAdjustment(double original_speed, - const rational &original_length, - const rational &new_length); + static double get_speed_adjustment(double original_speed, + const Rational &original_length, + const Rational &new_length); QVector clips_; @@ -78,18 +78,18 @@ private: double start_speed_; - rational start_duration_; + Rational start_duration_; int start_loop_; - rational timebase_; + Rational timebase_; private slots: - void SpeedChanged(double s); + void speed_changed(double s); - void DurationChanged(const rational &r); + void duration_changed(const Rational &r); }; } -#endif // SPEEDDURATIONDIALOG_H +#endif // OAK_SPEEDDURATIONDIALOG_H diff --git a/app/dialog/task/task.cpp b/app/dialog/task/task.cpp index 0b8774f6c..3f762645d 100644 --- a/app/dialog/task/task.cpp +++ b/app/dialog/task/task.cpp @@ -30,7 +30,7 @@ namespace olive #define super ProgressDialog TaskDialog::TaskDialog(Task *task, const QString &title, QWidget *parent) - : super(task->GetTitle(), title, parent) + : super(task->get_title(), title, parent) , task_(task) , destroy_on_close_(true) , already_shown_(false) @@ -40,12 +40,12 @@ TaskDialog::TaskDialog(Task *task, const QString &title, QWidget *parent) task_->setParent(this); // Connect the save manager progress signal to the progress bar update on the dialog - connect(task_, &Task::ProgressChanged, this, &TaskDialog::SetProgress, + connect(task_, &Task::progress_changed, this, &TaskDialog::set_progress, Qt::QueuedConnection); // Connect cancel signal (must be a direct connection or it'll be queued after the task has // already finished) - connect(this, &TaskDialog::Cancelled, task_, &Task::Cancel, + connect(this, &TaskDialog::cancelled, task_, &Task::Cancel, Qt::DirectConnection); } @@ -59,12 +59,12 @@ void TaskDialog::showEvent(QShowEvent *e) // Listen for when the task finishes connect(task_watcher, &QFutureWatcher::finished, this, - &TaskDialog::TaskFinished, Qt::QueuedConnection); + &TaskDialog::task_finished, Qt::QueuedConnection); // Run task in another thread with QtConcurrent task_watcher->setFuture( #if QT_VERSION_MAJOR >= 6 - QtConcurrent::run(&Task::Start, task_) + QtConcurrent::run(&Task::start, task_) #else QtConcurrent::run(task_, &Task::Start) #endif @@ -94,7 +94,7 @@ void TaskDialog::closeEvent(QCloseEvent *e) } } -void TaskDialog::TaskFinished() +void TaskDialog::task_finished() { QFutureWatcher *task_watcher = static_cast *>(sender()); @@ -102,10 +102,10 @@ void TaskDialog::TaskFinished() task_finished_ = true; if (task_watcher->result()) { - emit TaskSucceeded(task_); + emit task_succeeded(task_); } else { - ShowErrorMessage(tr("Task Failed"), task_->GetError()); - emit TaskFailed(task_); + show_error_message(tr("Task Failed"), task_->get_error()); + emit task_failed(task_); } task_watcher->deleteLater(); diff --git a/app/dialog/task/task.h b/app/dialog/task/task.h index d01fddced..b04dc3895 100644 --- a/app/dialog/task/task.h +++ b/app/dialog/task/task.h @@ -19,8 +19,8 @@ ***/ -#ifndef TASKDIALOG_H -#define TASKDIALOG_H +#ifndef OAK_TASKDIALOG_H +#define OAK_TASKDIALOG_H #include "dialog/progress/progress.h" #include "task/task.h" @@ -45,7 +45,7 @@ public: * * This is TRUE by default. */ - void SetDestroyOnClose(bool e) + void set_destroy_on_close(bool e) { destroy_on_close_ = e; } @@ -53,7 +53,7 @@ public: /** * @brief Returns this dialog's task */ - Task *GetTask() const + Task *get_task() const { return task_; } @@ -64,9 +64,9 @@ protected: virtual void closeEvent(QCloseEvent *e) override; signals: - void TaskSucceeded(Task *task); + void task_succeeded(Task *task); - void TaskFailed(Task *task); + void task_failed(Task *task); private: Task *task_; @@ -78,9 +78,9 @@ private: bool task_finished_; private slots: - void TaskFinished(); + void task_finished(); }; } -#endif // TASKDIALOG_H +#endif // OAK_TASKDIALOG_H diff --git a/app/dialog/text/text.h b/app/dialog/text/text.h index 77168a973..aabe47e97 100644 --- a/app/dialog/text/text.h +++ b/app/dialog/text/text.h @@ -19,8 +19,8 @@ ***/ -#ifndef RICHTEXTDIALOG_H -#define RICHTEXTDIALOG_H +#ifndef OAK_RICHTEXTDIALOG_H +#define OAK_RICHTEXTDIALOG_H #include #include @@ -48,4 +48,4 @@ private: } -#endif // RICHTEXTDIALOG_H +#endif // OAK_RICHTEXTDIALOG_H diff --git a/app/main.cpp b/app/main.cpp index 396bc8345..8b060c983 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -27,7 +27,7 @@ * Use the navigation above to find documentation on classes or source files. */ -#include "OliveHost.h" +#include "olivehost.h" #include @@ -79,7 +79,7 @@ int decompress_project(const QString &project) .toUtf8() .constData()); - if (!olive::ProjectSerializer::CheckCompressedID(&project_file)) { + if (!olive::ProjectSerializer::check_compressed_id(&project_file)) { printf("%s\n", QCoreApplication::translate( "main", "Failed to decompress, project may be corrupt") @@ -145,7 +145,7 @@ int decompress_project(const QString &project) int main(int argc, char *argv[]) { // Set up debug handler - qInstallMessageHandler(olive::DebugHandler); + qInstallMessageHandler(olive::debug_handler); // Ignore SIGPIPE so that writing to a render-worker process that has // already crashed/closed does not terminate the main application. QProcess @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("oakvideoeditor.org"); QCoreApplication::setApplicationName("Oak Video Editor"); QGuiApplication::setDesktopFileName("org.oakvideoeditor.Oak"); - QCoreApplication::setApplicationVersion(olive::kAppVersionLong); + QCoreApplication::setApplicationVersion(olive::k_app_version_long); // // Parse command line arguments @@ -186,29 +186,29 @@ int main(int argc, char *argv[]) CommandLineParser parser; // Our options - auto help_option = parser.AddOption( + auto help_option = parser.add_option( { QStringLiteral("h"), QStringLiteral("-help") }, QCoreApplication::translate("main", "Show this help text")); - auto version_option = parser.AddOption( + auto version_option = parser.add_option( { QStringLiteral("v"), QStringLiteral("-version") }, QCoreApplication::translate("main", "Show application version")); - auto fullscreen_option = parser.AddOption( + auto fullscreen_option = parser.add_option( { QStringLiteral("f"), QStringLiteral("-fullscreen") }, QCoreApplication::translate("main", "Start in full-screen mode")); - auto export_option = parser.AddOption( + auto export_option = parser.add_option( { QStringLiteral("x"), QStringLiteral("-export") }, QCoreApplication::translate("main", "Export only (No GUI)")); - auto ts_option = parser.AddOption( + auto ts_option = parser.add_option( { QStringLiteral("-ts") }, QCoreApplication::translate("main", "Override language with file"), true, QCoreApplication::translate("main", "qm-file")); auto decompress_option = - parser.AddOption({ QStringLiteral("d"), QStringLiteral("-decompress") }, + parser.add_option({ QStringLiteral("d"), QStringLiteral("-decompress") }, QCoreApplication::translate( "main", "Decompress project file (No GUI)")); @@ -218,11 +218,11 @@ int main(int argc, char *argv[]) QCoreApplication::translate("main", "Launch with debug console")); #endif // _WIN32 - auto project_argument = parser.AddPositionalArgument( + auto project_argument = parser.add_positional_argument( QStringLiteral("project"), QCoreApplication::translate("main", "Project to open on startup")); - auto no_plugin = parser.AddOption( + auto no_plugin = parser.add_option( { QStringLiteral("-no-plugin") }, QCoreApplication::translate("main", "Don't load plugins")); @@ -230,77 +230,77 @@ int main(int argc, char *argv[]) // // Because we don't use QCommandLineParser, we must filter out Qt's arguments ourselves. Here, // we create them so they're recognized, but never use and also hide them in the "help" text. - parser.AddOption({ QStringLiteral("platform") }, QString(), true, QString(), + parser.add_option({ QStringLiteral("platform") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("platformpluginpath") }, QString(), true, + parser.add_option({ QStringLiteral("platformpluginpath") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("platformtheme") }, QString(), true, + parser.add_option({ QStringLiteral("platformtheme") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("plugin") }, QString(), true, QString(), + parser.add_option({ QStringLiteral("plugin") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("qmljsdebugger") }, QString(), true, + parser.add_option({ QStringLiteral("qmljsdebugger") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("qwindowgeometry") }, QString(), true, + parser.add_option({ QStringLiteral("qwindowgeometry") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("qwindowicon") }, QString(), true, + parser.add_option({ QStringLiteral("qwindowicon") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("qwindowtitle") }, QString(), true, + parser.add_option({ QStringLiteral("qwindowtitle") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("reverse") }, QString(), false, QString(), + parser.add_option({ QStringLiteral("reverse") }, QString(), false, QString(), true); - parser.AddOption({ QStringLiteral("session") }, QString(), true, QString(), + parser.add_option({ QStringLiteral("session") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("style") }, QString(), true, QString(), + parser.add_option({ QStringLiteral("style") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("stylesheet") }, QString(), true, + parser.add_option({ QStringLiteral("stylesheet") }, QString(), true, QString(), true); - parser.AddOption({ QStringLiteral("widgetcount") }, QString(), false, + parser.add_option({ QStringLiteral("widgetcount") }, QString(), false, QString(), true); // Hidden crash option for debugging the crash handling - auto crash_option = parser.AddOption({ QStringLiteral("-crash") }, + auto crash_option = parser.add_option({ QStringLiteral("-crash") }, QString(), true, QString(), true); - parser.Process(args); + parser.process(args); - if (help_option->IsSet()) { + if (help_option->is_set()) { // Show help - parser.PrintHelp(argv[0]); + parser.print_help(argv[0]); return 0; } - if (version_option->IsSet()) { + if (version_option->is_set()) { // Print version printf("%s\n", QCoreApplication::applicationVersion().toUtf8().constData()); return 0; } - if (decompress_option->IsSet()) { - return decompress_project(project_argument->GetSetting()); + if (decompress_option->is_set()) { + return decompress_project(project_argument->get_setting()); } - if (export_option->IsSet()) { - startup_params.set_run_mode(olive::Core::CoreParams::kHeadlessExport); + if (export_option->is_set()) { + startup_params.set_run_mode(olive::Core::CoreParams::k_headless_export); } - if (ts_option->IsSet()) { - if (ts_option->GetSetting().isEmpty()) { + if (ts_option->is_set()) { + if (ts_option->get_setting().isEmpty()) { qWarning() << "--ts was set but no translation file was provided"; } else { - startup_params.set_startup_language(ts_option->GetSetting()); + startup_params.set_startup_language(ts_option->get_setting()); } } - const bool load_plugins = !no_plugin->IsSet(); + const bool load_plugins = !no_plugin->is_set(); - if (crash_option->IsSet()) { + if (crash_option->is_set()) { startup_params.set_crash_on_startup(true); } - startup_params.set_fullscreen(fullscreen_option->IsSet()); + startup_params.set_fullscreen(fullscreen_option->is_set()); - startup_params.set_startup_project(project_argument->GetSetting()); + startup_params.set_startup_project(project_argument->get_setting()); // Set OpenGL display profile. Oak's render pipeline still uses OpenGL // internally even when Vulkan is requested as the Qt graphics backend. @@ -327,7 +327,7 @@ int main(int argc, char *argv[]) // Create application instance std::unique_ptr a; - if (startup_params.run_mode() == olive::Core::CoreParams::kRunNormal) { + if (startup_params.run_mode() == olive::Core::CoreParams::k_run_normal) { #ifdef _WIN32 // Since Oak Video Editor is linked with the console subsystem (for better POSIX compatibility), a console // is created by default. If the user didn't request one, we free it here. @@ -341,9 +341,9 @@ int main(int argc, char *argv[]) a.reset(new QCoreApplication(argc, argv)); } - olive::Config::Load(); + olive::Config::load(); const QString graphics_backend = - olive::Config::Current()[QStringLiteral("GraphicsBackend")] + olive::Config::current()[QStringLiteral("GraphicsBackend")] .toString() .toLower(); qputenv("QSG_RHI_BACKEND", graphics_backend == QStringLiteral("vulkan") ? @@ -356,7 +356,7 @@ int main(int argc, char *argv[]) } if (load_plugins) { - olive::plugin::loadPlugins("plugins"); + olive::plugin::load_plugins("plugins"); } #ifdef _WIN32 @@ -412,12 +412,12 @@ int main(int argc, char *argv[]) // Start core olive::Core c(startup_params); - c.Start(); + c.start(); int ret = a->exec(); // Clear core memory - c.Stop(); + c.stop(); return ret; } diff --git a/app/node/audio/pan/pan.cpp b/app/node/audio/pan/pan.cpp index e89d4aa63..7e7b162e3 100644 --- a/app/node/audio/pan/pan.cpp +++ b/app/node/audio/pan/pan.cpp @@ -26,27 +26,27 @@ namespace olive { -const QString PanNode::kSamplesInput = QStringLiteral("samples_in"); -const QString PanNode::kPanningInput = QStringLiteral("panning_in"); +const QString PanNode::k_samples_input = QStringLiteral("samples_in"); +const QString PanNode::k_panning_input = QStringLiteral("panning_in"); #define super Node PanNode::PanNode() { - AddInput(kSamplesInput, NodeValue::kSamples, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_samples_input, NodeValue::k_samples, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kPanningInput, NodeValue::kFloat, 0.0); - SetInputProperty(kPanningInput, QStringLiteral("min"), -1.0); - SetInputProperty(kPanningInput, QStringLiteral("max"), 1.0); - SetInputProperty(kPanningInput, QStringLiteral("view"), - FloatSlider::kPercentage); + add_input(k_panning_input, NodeValue::k_float, 0.0); + set_input_property(k_panning_input, QStringLiteral("min"), -1.0); + set_input_property(k_panning_input, QStringLiteral("max"), 1.0); + set_input_property(k_panning_input, QStringLiteral("view"), + FloatSlider::k_percentage); - SetFlag(kAudioEffect); - SetEffectInput(kSamplesInput); + set_flag(k_audio_effect); + set_effect_input(k_samples_input); } -QString PanNode::Name() const +QString PanNode::name() const { return tr("Pan"); } @@ -56,27 +56,27 @@ QString PanNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.pan"); } -QVector PanNode::Category() const +QVector PanNode::category() const { - return { kCategoryFilter }; + return { k_category_filter }; } -QString PanNode::Description() const +QString PanNode::description() const { return tr("Adjust the stereo panning of an audio source."); } -void PanNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void PanNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // Create a sample job - SampleBuffer samples = value[kSamplesInput].toSamples(); + SampleBuffer samples = value[k_samples_input].to_samples(); if (samples.is_allocated()) { // This node is only compatible with stereo audio if (samples.audio_params().channel_count() == 2) { // If the input is static, we can just do it now which will be faster - if (IsInputStatic(kPanningInput)) { - float pan_volume = value[kPanningInput].toDouble(); + if (is_input_static(k_panning_input)) { + float pan_volume = value[k_panning_input].to_double(); if (!qIsNull(pan_volume)) { if (pan_volume > 0) { samples.transform_volume_for_channel(0, @@ -87,26 +87,26 @@ void PanNode::Value(const NodeValueRow &value, const NodeGlobals &globals, } } - table->Push(NodeValue(NodeValue::kSamples, samples, this)); + table->push(NodeValue(NodeValue::k_samples, samples, this)); } else { // Requires job - SampleJob job(globals.time(), kSamplesInput, value); - job.Insert(kPanningInput, value); - table->Push(NodeValue::kSamples, QVariant::fromValue(job), + SampleJob job(globals.time(), k_samples_input, value); + job.insert(k_panning_input, value); + table->push(NodeValue::k_samples, QVariant::fromValue(job), this); } } else { // Pass right through - table->Push(value[kSamplesInput]); + table->push(value[k_samples_input]); } } } -void PanNode::ProcessSamples(const NodeValueRow &values, +void PanNode::process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const { - float pan_val = values[kPanningInput].toDouble(); + float pan_val = values[k_panning_input].to_double(); for (int i = 0; i < input.audio_params().channel_count(); i++) { output.data(i)[index] = input.data(i)[index]; @@ -119,12 +119,12 @@ void PanNode::ProcessSamples(const NodeValueRow &values, } } -void PanNode::Retranslate() +void PanNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kSamplesInput, tr("Samples")); - SetInputName(kPanningInput, tr("Pan")); + set_input_name(k_samples_input, tr("Samples")); + set_input_name(k_panning_input, tr("Pan")); } } diff --git a/app/node/audio/pan/pan.h b/app/node/audio/pan/pan.h index c6f8627d1..df6568ba1 100644 --- a/app/node/audio/pan/pan.h +++ b/app/node/audio/pan/pan.h @@ -19,8 +19,8 @@ ***/ -#ifndef PANNODE_H -#define PANNODE_H +#ifndef OAK_PANNODE_H +#define OAK_PANNODE_H #include "node/node.h" @@ -34,22 +34,22 @@ public: NODE_DEFAULT_FUNCTIONS(PanNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void ProcessSamples(const NodeValueRow &values, + virtual void process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const override; - virtual void Retranslate() override; + virtual void retranslate() override; - static const QString kSamplesInput; - static const QString kPanningInput; + static const QString k_samples_input; + static const QString k_panning_input; private: NodeInput *samples_input_; @@ -58,4 +58,4 @@ private: } -#endif // PANNODE_H +#endif // OAK_PANNODE_H diff --git a/app/node/audio/volume/volume.cpp b/app/node/audio/volume/volume.cpp index c8103a4f3..ea835910d 100644 --- a/app/node/audio/volume/volume.cpp +++ b/app/node/audio/volume/volume.cpp @@ -26,26 +26,26 @@ namespace olive { -const QString VolumeNode::kSamplesInput = QStringLiteral("samples_in"); -const QString VolumeNode::kVolumeInput = QStringLiteral("volume_in"); +const QString VolumeNode::k_samples_input = QStringLiteral("samples_in"); +const QString VolumeNode::k_volume_input = QStringLiteral("volume_in"); #define super MathNodeBase VolumeNode::VolumeNode() { - AddInput(kSamplesInput, NodeValue::kSamples, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_samples_input, NodeValue::k_samples, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kVolumeInput, NodeValue::kFloat, 1.0); - SetInputProperty(kVolumeInput, QStringLiteral("min"), 0.0); - SetInputProperty(kVolumeInput, QStringLiteral("view"), - FloatSlider::kDecibel); + add_input(k_volume_input, NodeValue::k_float, 1.0); + set_input_property(k_volume_input, QStringLiteral("min"), 0.0); + set_input_property(k_volume_input, QStringLiteral("view"), + FloatSlider::k_decibel); - SetFlag(kAudioEffect); - SetEffectInput(kSamplesInput); + set_flag(k_audio_effect); + set_effect_input(k_samples_input); } -QString VolumeNode::Name() const +QString VolumeNode::name() const { return tr("Volume"); } @@ -55,55 +55,55 @@ QString VolumeNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.volume"); } -QVector VolumeNode::Category() const +QVector VolumeNode::category() const { - return { kCategoryFilter }; + return { k_category_filter }; } -QString VolumeNode::Description() const +QString VolumeNode::description() const { return tr("Adjusts the volume of an audio source."); } -void VolumeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void VolumeNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // Create a sample job - SampleBuffer buffer = value[kSamplesInput].toSamples(); + SampleBuffer buffer = value[k_samples_input].to_samples(); if (buffer.is_allocated()) { // If the input is static, we can just do it now which will be faster - if (IsInputStatic(kVolumeInput)) { - auto volume = value[kVolumeInput].toDouble(); + if (is_input_static(k_volume_input)) { + auto volume = value[k_volume_input].to_double(); if (!qFuzzyCompare(volume, 1.0)) { buffer.transform_volume(volume); } - table->Push(NodeValue::kSamples, QVariant::fromValue(buffer), this); + table->push(NodeValue::k_samples, QVariant::fromValue(buffer), this); } else { // Requires job - SampleJob job(globals.time(), kSamplesInput, value); - job.Insert(kVolumeInput, value); - table->Push(NodeValue::kSamples, QVariant::fromValue(job), this); + SampleJob job(globals.time(), k_samples_input, value); + job.insert(k_volume_input, value); + table->push(NodeValue::k_samples, QVariant::fromValue(job), this); } } } -void VolumeNode::ProcessSamples(const NodeValueRow &values, +void VolumeNode::process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const { - return ProcessSamplesInternal(values, kOpMultiply, kSamplesInput, - kVolumeInput, input, output, index); + return process_samples_internal(values, k_op_multiply, k_samples_input, + k_volume_input, input, output, index); } -void VolumeNode::Retranslate() +void VolumeNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kSamplesInput, tr("Samples")); - SetInputName(kVolumeInput, tr("Volume")); + set_input_name(k_samples_input, tr("Samples")); + set_input_name(k_volume_input, tr("Volume")); } } diff --git a/app/node/audio/volume/volume.h b/app/node/audio/volume/volume.h index 31908c9f0..567e1162f 100644 --- a/app/node/audio/volume/volume.h +++ b/app/node/audio/volume/volume.h @@ -19,8 +19,8 @@ ***/ -#ifndef VOLUMENODE_H -#define VOLUMENODE_H +#ifndef OAK_VOLUMENODE_H +#define OAK_VOLUMENODE_H #include "node/math/math/mathbase.h" @@ -34,24 +34,24 @@ public: NODE_DEFAULT_FUNCTIONS(VolumeNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void ProcessSamples(const NodeValueRow &values, + virtual void process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const override; - virtual void Retranslate() override; + virtual void retranslate() override; - static const QString kSamplesInput; - static const QString kVolumeInput; + static const QString k_samples_input; + static const QString k_volume_input; }; } -#endif // VOLUMENODE_H +#endif // OAK_VOLUMENODE_H diff --git a/app/node/block/block.cpp b/app/node/block/block.cpp index 5fce241f1..fb8d89be9 100644 --- a/app/node/block/block.cpp +++ b/app/node/block/block.cpp @@ -31,39 +31,39 @@ namespace olive #define super Node -const QString Block::kLengthInput = QStringLiteral("length_in"); +const QString Block::k_length_input = QStringLiteral("length_in"); Block::Block() : previous_(nullptr) , next_(nullptr) , track_(nullptr) { - AddInput(kLengthInput, NodeValue::kRational, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | - kInputFlagHidden)); - SetInputProperty(kLengthInput, QStringLiteral("min"), - QVariant::fromValue(rational(0, 1))); - SetInputProperty(kLengthInput, QStringLiteral("view"), - RationalSlider::kTime); - SetInputProperty(kLengthInput, QStringLiteral("viewlock"), true); + add_input(k_length_input, NodeValue::k_rational, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable | + k_input_flag_hidden)); + set_input_property(k_length_input, QStringLiteral("min"), + QVariant::fromValue(Rational(0, 1))); + set_input_property(k_length_input, QStringLiteral("view"), + RationalSlider::k_time); + set_input_property(k_length_input, QStringLiteral("viewlock"), true); - SetInputFlag(kEnabledInput, kInputFlagNotConnectable); - SetInputFlag(kEnabledInput, kInputFlagNotKeyframable); + set_input_flag(k_enabled_input, k_input_flag_not_connectable); + set_input_flag(k_enabled_input, k_input_flag_not_keyframable); - SetFlag(kDontShowInParamView); + set_flag(k_dont_show_in_param_view); } -QVector Block::Category() const +QVector Block::category() const { - return { kCategoryTimeline }; + return { k_category_timeline }; } -rational Block::length() const +Rational Block::length() const { - return GetStandardValue(kLengthInput).value(); + return get_standard_value(k_length_input).value(); } -void Block::set_length_and_media_out(const rational &length) +void Block::set_length_and_media_out(const Rational &length) { if (length == this->length()) { return; @@ -72,7 +72,7 @@ void Block::set_length_and_media_out(const rational &length) set_length_internal(length); } -void Block::set_length_and_media_in(const rational &length) +void Block::set_length_and_media_in(const Rational &length) { if (length == this->length()) { return; @@ -84,50 +84,50 @@ void Block::set_length_and_media_in(const rational &length) bool Block::is_enabled() const { - return GetStandardValue(kEnabledInput).toBool(); + return get_standard_value(k_enabled_input).toBool(); } void Block::set_enabled(bool e) { - SetStandardValue(kEnabledInput, e); + set_standard_value(k_enabled_input, e); - emit EnabledChanged(); + emit enabled_changed(); } void Block::InputValueChangedEvent(const QString &input, int element) { super::InputValueChangedEvent(input, element); - if (input == kLengthInput) { - emit LengthChanged(); - } else if (input == kEnabledInput) { - emit EnabledChanged(); + if (input == k_length_input) { + emit length_changed(); + } else if (input == k_enabled_input) { + emit enabled_changed(); } } -void Block::set_length_internal(const rational &length) +void Block::set_length_internal(const Rational &length) { - SetStandardValue(kLengthInput, QVariant::fromValue(length)); + set_standard_value(k_length_input, QVariant::fromValue(length)); } -void Block::Retranslate() +void Block::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kLengthInput, tr("Length")); - SetInputName(kEnabledInput, tr("Enabled")); + set_input_name(k_length_input, tr("Length")); + set_input_name(k_enabled_input, tr("Enabled")); } -void Block::InvalidateCache(const TimeRange &range, const QString &from, +void Block::invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) { TimeRange r; - if (from == kLengthInput) { + if (from == k_length_input) { // We must intercept the signal here r = TimeRange(qMin(length(), last_length_), RATIONAL_MAX); - if (!NodeInputDragger::IsInputBeingDragged()) { + if (!NodeInputDragger::is_input_being_dragged()) { last_length_ = length(); } @@ -136,7 +136,7 @@ void Block::InvalidateCache(const TimeRange &range, const QString &from, r = range; } - super::InvalidateCache(r, from, element, options); + super::invalidate_cache(r, from, element, options); } void Block::set_previous_next(Block *previous, Block *next) diff --git a/app/node/block/block.h b/app/node/block/block.h index 5d913828a..31bf87145 100644 --- a/app/node/block/block.h +++ b/app/node/block/block.h @@ -19,8 +19,8 @@ ***/ -#ifndef BLOCK_H -#define BLOCK_H +#ifndef OAK_BLOCK_H +#define OAK_BLOCK_H #include "node/node.h" #include "timeline/timelinecommon.h" @@ -38,31 +38,31 @@ class Block : public Node { public: Block(); - virtual QVector Category() const override; + virtual QVector category() const override; - const rational &in() const + const Rational &in() const { return in_point_; } - const rational &out() const + const Rational &out() const { return out_point_; } - void set_in(const rational &in) + void set_in(const Rational &in) { in_point_ = in; } - void set_out(const rational &out) + void set_out(const Rational &out) { out_point_ = out; } - rational length() const; - virtual void set_length_and_media_out(const rational &length); - virtual void set_length_and_media_in(const rational &length); + Rational length() const; + virtual void set_length_and_media_out(const Rational &length); + virtual void set_length_and_media_in(const Rational &length); TimeRange range() const { @@ -97,32 +97,32 @@ public: void set_track(Track *track) { track_ = track; - emit TrackChanged(track_); + emit track_changed(track_); } bool is_enabled() const; void set_enabled(bool e); - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void InvalidateCache( + virtual void invalidate_cache( const TimeRange &range, const QString &from, int element = -1, InvalidateCacheOptions options = InvalidateCacheOptions()) override; - static const QString kLengthInput; + static const QString k_length_input; static void set_previous_next(Block *previous, Block *next); public slots: signals: - void EnabledChanged(); + void enabled_changed(); - void LengthChanged(); + void length_changed(); - void PreviewChanged(); + void preview_changed(); - void TrackChanged(Track *track); + void track_changed(Track *track); protected: virtual void InputValueChangedEvent(const QString &input, @@ -132,15 +132,15 @@ protected: Block *next_; private: - void set_length_internal(const rational &length); + void set_length_internal(const Rational &length); - rational in_point_; - rational out_point_; + Rational in_point_; + Rational out_point_; Track *track_; - rational last_length_; + Rational last_length_; }; } -#endif // BLOCK_H +#endif // OAK_BLOCK_H diff --git a/app/node/block/clip/clip.cpp b/app/node/block/clip/clip.cpp index ca3ae642f..68375286a 100644 --- a/app/node/block/clip/clip.cpp +++ b/app/node/block/clip/clip.cpp @@ -34,59 +34,59 @@ namespace olive #define super Block -const QString ClipBlock::kBufferIn = QStringLiteral("buffer_in"); -const QString ClipBlock::kMediaInInput = QStringLiteral("media_in_in"); -const QString ClipBlock::kSpeedInput = QStringLiteral("speed_in"); -const QString ClipBlock::kReverseInput = QStringLiteral("reverse_in"); -const QString ClipBlock::kMaintainAudioPitchInput = +const QString ClipBlock::k_buffer_in = QStringLiteral("buffer_in"); +const QString ClipBlock::k_media_in_input = QStringLiteral("media_in_in"); +const QString ClipBlock::k_speed_input = QStringLiteral("speed_in"); +const QString ClipBlock::k_reverse_input = QStringLiteral("reverse_in"); +const QString ClipBlock::k_maintain_audio_pitch_input = QStringLiteral("maintain_audio_pitch_in"); -const QString ClipBlock::kAutoCacheInput = QStringLiteral("autocache_in"); -const QString ClipBlock::kLoopModeInput = QStringLiteral("loop_in"); +const QString ClipBlock::k_auto_cache_input = QStringLiteral("autocache_in"); +const QString ClipBlock::k_loop_mode_input = QStringLiteral("loop_in"); ClipBlock::ClipBlock() : in_transition_(nullptr) , out_transition_(nullptr) , connected_viewer_(nullptr) { - AddInput(kMediaInInput, NodeValue::kRational, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); - SetInputProperty(kMediaInInput, QStringLiteral("view"), - RationalSlider::kTime); - SetInputProperty(kMediaInInput, QStringLiteral("viewlock"), true); + add_input(k_media_in_input, NodeValue::k_rational, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); + set_input_property(k_media_in_input, QStringLiteral("view"), + RationalSlider::k_time); + set_input_property(k_media_in_input, QStringLiteral("viewlock"), true); - AddInput(kSpeedInput, NodeValue::kFloat, 1.0, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); - SetInputProperty(kSpeedInput, QStringLiteral("view"), - FloatSlider::kPercentage); - SetInputProperty(kSpeedInput, QStringLiteral("min"), 0.0); + add_input(k_speed_input, NodeValue::k_float, 1.0, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); + set_input_property(k_speed_input, QStringLiteral("view"), + FloatSlider::k_percentage); + set_input_property(k_speed_input, QStringLiteral("min"), 0.0); - AddInput(kReverseInput, NodeValue::kBoolean, false, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_reverse_input, NodeValue::k_boolean, false, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - AddInput(kMaintainAudioPitchInput, NodeValue::kBoolean, false, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_maintain_audio_pitch_input, NodeValue::k_boolean, false, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - AddInput(kAutoCacheInput, NodeValue::kBoolean, false, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_auto_cache_input, NodeValue::k_boolean, false, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - PrependInput(kBufferIn, NodeValue::kNone, - InputFlags(kInputFlagNotKeyframable)); + prepend_input(k_buffer_in, NodeValue::k_none, + InputFlags(k_input_flag_not_keyframable)); //SetValueHintForInput(kBufferIn, ValueHint(NodeValue::kBuffer)); - SetEffectInput(kBufferIn); + set_effect_input(k_buffer_in); - AddInput(kLoopModeInput, NodeValue::kCombo, 0, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_loop_mode_input, NodeValue::k_combo, 0, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); } -QString ClipBlock::Name() const +QString ClipBlock::name() const { - if (connected_viewer_ && !connected_viewer_->GetLabel().isEmpty()) { - return connected_viewer_->GetLabel(); + if (connected_viewer_ && !connected_viewer_->get_label().isEmpty()) { + return connected_viewer_->get_label(); } else if (track()) { - if (track()->type() == Track::kVideo) { + if (track()->type() == Track::k_video) { return tr("Video Clip"); - } else if (track()->type() == Track::kAudio) { + } else if (track()->type() == Track::k_audio) { return tr("Audio Clip"); } } @@ -99,12 +99,12 @@ QString ClipBlock::id() const return QStringLiteral("org.olivevideoeditor.Olive.clip"); } -QString ClipBlock::Description() const +QString ClipBlock::description() const { return tr("A time-based node that represents a media source."); } -void ClipBlock::set_length_and_media_out(const rational &length) +void ClipBlock::set_length_and_media_out(const Rational &length) { if (length == this->length()) { return; @@ -112,39 +112,39 @@ void ClipBlock::set_length_and_media_out(const rational &length) if (reverse()) { // Calculate media_in adjustment - rational proposed_media_in = SequenceToMediaTime( - this->length() - length, kSTMIgnoreReverse | kSTMIgnoreLoop); + Rational proposed_media_in = sequence_to_media_time( + this->length() - length, k_stm_ignore_reverse | k_stm_ignore_loop); set_media_in(proposed_media_in); } super::set_length_and_media_out(length); } -void ClipBlock::set_length_and_media_in(const rational &length) +void ClipBlock::set_length_and_media_in(const Rational &length) { if (length == this->length()) { return; } - rational old_length = this->length(); + Rational old_length = this->length(); super::set_length_and_media_in(length); if (!reverse()) { // Calculate media_in adjustment - set_media_in(SequenceToMediaTime(old_length - length, kSTMIgnoreLoop)); + set_media_in(sequence_to_media_time(old_length - length, k_stm_ignore_loop)); } } -rational ClipBlock::media_in() const +Rational ClipBlock::media_in() const { - return GetStandardValue(kMediaInInput).value(); + return get_standard_value(k_media_in_input).value(); } -Node::ValueHint ClipBlock::GetValueHintForInput(const QString &input, +Node::ValueHint ClipBlock::get_value_hint_for_input(const QString &input, int element) const { - if (input == kBufferIn) { + if (input == k_buffer_in) { // The buffer input takes whatever the connected node provides, so it // is declared as kNone and carries no stored hint. When the connected // node pushes more than one value type (a footage pushes both a @@ -152,46 +152,46 @@ Node::ValueHint ClipBlock::GetValueHintForInput(const QString &input, // the last value in the table, which may feed audio samples into a // video clip and produce a black frame. Prefer the value type that // matches this clip's track. - switch (GetTrackType()) { - case Track::kVideo: - return ValueHint(QVector{ NodeValue::kTexture }); - case Track::kAudio: - return ValueHint(QVector{ NodeValue::kSamples }); + switch (get_track_type()) { + case Track::k_video: + return ValueHint(QVector{ NodeValue::k_texture }); + case Track::k_audio: + return ValueHint(QVector{ NodeValue::k_samples }); default: break; } } - return super::GetValueHintForInput(input, element); + return super::get_value_hint_for_input(input, element); } -void ClipBlock::set_media_in(const rational &media_in) +void ClipBlock::set_media_in(const Rational &media_in) { - SetStandardValue(kMediaInInput, QVariant::fromValue(media_in)); + set_standard_value(k_media_in_input, QVariant::fromValue(media_in)); - RequestInvalidatedFromConnected(); + request_invalidated_from_connected(); } -void ClipBlock::SetAutocache(bool e) +void ClipBlock::set_autocache(bool e) { - SetStandardValue(kAutoCacheInput, e); + set_standard_value(k_auto_cache_input, e); } -void ClipBlock::DiscardCache() +void ClipBlock::discard_cache() { - if (Node *connected = GetConnectedOutput(kBufferIn)) { - Track::Type type = GetTrackType(); - if (type == Track::kVideo) { - connected->video_frame_cache()->Invalidate( + if (Node *connected = get_connected_output(k_buffer_in)) { + Track::Type type = get_track_type(); + if (type == Track::k_video) { + connected->video_frame_cache()->invalidate( TimeRange(RATIONAL_MIN, RATIONAL_MAX)); - } else if (type == Track::kAudio) { - connected->audio_playback_cache()->Invalidate( + } else if (type == Track::k_audio) { + connected->audio_playback_cache()->invalidate( TimeRange(RATIONAL_MIN, RATIONAL_MAX)); } } } -rational ClipBlock::SequenceToMediaTime(const rational &sequence_time, +Rational ClipBlock::sequence_to_media_time(const Rational &sequence_time, uint64_t flags) const { // These constants are not considered "values" per se, so we don't modify them @@ -199,13 +199,13 @@ rational ClipBlock::SequenceToMediaTime(const rational &sequence_time, return sequence_time; } - rational media_time = sequence_time; + Rational media_time = sequence_time; - if (reverse() && !(flags & kSTMIgnoreReverse)) { + if (reverse() && !(flags & k_stm_ignore_reverse)) { media_time = length() - media_time; } - if (!(flags & kSTMIgnoreSpeed)) { + if (!(flags & k_stm_ignore_speed)) { double speed_value = speed(); if (qIsNull(speed_value)) { // Effectively holds the frame at the in point @@ -213,7 +213,7 @@ rational ClipBlock::SequenceToMediaTime(const rational &sequence_time, } else if (!qFuzzyCompare(speed_value, 1.0)) { // Multiply time media_time = - rational::fromDouble(media_time.toDouble() * speed_value); + Rational::from_double(media_time.to_double() * speed_value); } } @@ -232,21 +232,21 @@ rational ClipBlock::SequenceToMediaTime(const rational &sequence_time, media_time -= connected_viewer_->GetLength(); } } else if (loop_mode() == kLoopModeClamp) { - media_time = std::clamp(media_time, rational(0), connected_viewer_->GetLength()-connected_viewer_->GetVideoParams().frame_rate_as_time_base()); + media_time = std::clamp(media_time, Rational(0), connected_viewer_->GetLength()-connected_viewer_->GetVideoParams().frame_rate_as_time_base()); } }*/ return media_time; } -rational ClipBlock::MediaToSequenceTime(const rational &media_time) const +Rational ClipBlock::media_to_sequence_time(const Rational &media_time) const { // These constants are not considered "values" per se, so we don't modify them if (media_time == RATIONAL_MIN || media_time == RATIONAL_MAX) { return media_time; } - rational sequence_time = media_time - media_in(); + Rational sequence_time = media_time - media_in(); double speed_value = speed(); if (qIsNull(speed_value)) { @@ -255,7 +255,7 @@ rational ClipBlock::MediaToSequenceTime(const rational &media_time) const } else if (!qFuzzyCompare(speed_value, 1.0)) { // Divide time sequence_time = - rational::fromDouble(sequence_time.toDouble() / speed_value); + Rational::from_double(sequence_time.to_double() / speed_value); } if (reverse()) { @@ -265,80 +265,80 @@ rational ClipBlock::MediaToSequenceTime(const rational &media_time) const return sequence_time; } -void ClipBlock::RequestRangeFromConnected(const TimeRange &range) +void ClipBlock::request_range_from_connected(const TimeRange &range) { - Track::Type type = GetTrackType(); + Track::Type type = get_track_type(); - if (type == Track::kVideo || type == Track::kAudio) { - if (Node *connected = GetConnectedOutput(kBufferIn)) { + if (type == Track::k_video || type == Track::k_audio) { + if (Node *connected = get_connected_output(k_buffer_in)) { TimeRange max_range = media_range(); - if (type == Track::kVideo) { + if (type == Track::k_video) { // Handle thumbnails - RequestRangeForCache(connected->thumbnail_cache(), max_range, + request_range_for_cache(connected->thumbnail_cache(), max_range, range, true, false); { - TimeRange thumb_range = range.Intersected(max_range); - if (GetAdjustedThumbnailRange(&thumb_range)) { - connected->thumbnail_cache()->Request( + TimeRange thumb_range = range.intersected(max_range); + if (get_adjusted_thumbnail_range(&thumb_range)) { + connected->thumbnail_cache()->request( this->track()->sequence(), thumb_range); } } // Handle video cache - RequestRangeForCache(connected->video_frame_cache(), max_range, - range, true, IsAutocaching()); - } else if (type == Track::kAudio) { + request_range_for_cache(connected->video_frame_cache(), max_range, + range, true, is_autocaching()); + } else if (type == Track::k_audio) { // Handle waveforms - RequestRangeForCache( + request_range_for_cache( connected->waveform_cache(), max_range, range, true, - (OLIVE_CONFIG("TimelineWaveformMode").toInt() == - Timeline::kWaveformsEnabled)); + (OAK_CONFIG("TimelineWaveformMode").toInt() == + Timeline::k_waveforms_enabled)); // Handle audio cache - RequestRangeForCache(connected->audio_playback_cache(), - max_range, range, true, IsAutocaching()); + request_range_for_cache(connected->audio_playback_cache(), + max_range, range, true, is_autocaching()); } } } } -void ClipBlock::RequestInvalidatedFromConnected(bool force_all, +void ClipBlock::request_invalidated_from_connected(bool force_all, const TimeRange &intersect) { - Track::Type type = GetTrackType(); + Track::Type type = get_track_type(); - if (type == Track::kVideo || type == Track::kAudio) { - if (Node *connected = GetConnectedOutput(kBufferIn)) { + if (type == Track::k_video || type == Track::k_audio) { + if (Node *connected = get_connected_output(k_buffer_in)) { TimeRange max_range = media_range(); if (!intersect.length().isNull()) { - max_range = max_range.Intersected(intersect); + max_range = max_range.intersected(intersect); } - if (type == Track::kVideo) { + if (type == Track::k_video) { // Handle thumbnails TimeRange thumb_range = max_range; - if (GetAdjustedThumbnailRange(&thumb_range)) { - RequestInvalidatedForCache(connected->thumbnail_cache(), + if (get_adjusted_thumbnail_range(&thumb_range)) { + request_invalidated_for_cache(connected->thumbnail_cache(), thumb_range); } // Handle video cache - if (IsAutocaching() || force_all) { - RequestInvalidatedForCache(connected->video_frame_cache(), + if (is_autocaching() || force_all) { + request_invalidated_for_cache(connected->video_frame_cache(), max_range); } - } else if (type == Track::kAudio) { + } else if (type == Track::k_audio) { // Handle waveforms - if (OLIVE_CONFIG("TimelineWaveformMode").toInt() == - Timeline::kWaveformsEnabled) { - RequestInvalidatedForCache(connected->waveform_cache(), + if (OAK_CONFIG("TimelineWaveformMode").toInt() == + Timeline::k_waveforms_enabled) { + request_invalidated_for_cache(connected->waveform_cache(), max_range); } // Handle audio cache - if (IsAutocaching() || force_all) { - RequestInvalidatedForCache( + if (is_autocaching() || force_all) { + request_invalidated_for_cache( connected->audio_playback_cache(), max_range); } } @@ -346,56 +346,56 @@ void ClipBlock::RequestInvalidatedFromConnected(bool force_all, } } -void ClipBlock::RequestRangeForCache(PlaybackCache *cache, +void ClipBlock::request_range_for_cache(PlaybackCache *cache, const TimeRange &max_range, const TimeRange &range, bool invalidate, bool request) { - TimeRange r = range.Intersected(max_range); + TimeRange r = range.intersected(max_range); if (invalidate) { - cache->Invalidate(r); + cache->invalidate(r); } if (request) { - cache->Request(this->track()->sequence(), r); + cache->request(this->track()->sequence(), r); } } -void ClipBlock::RequestInvalidatedForCache(PlaybackCache *cache, +void ClipBlock::request_invalidated_for_cache(PlaybackCache *cache, const TimeRange &max_range) { - TimeRangeList invalid = cache->GetInvalidatedRanges(max_range); + TimeRangeList invalid = cache->get_invalidated_ranges(max_range); - for (const PlaybackCache::Passthrough &p : cache->GetPassthroughs()) { + for (const PlaybackCache::Passthrough &p : cache->get_passthroughs()) { invalid.remove(p); } for (const TimeRange &r : invalid) { - RequestRangeForCache(cache, max_range, r, false, true); + request_range_for_cache(cache, max_range, r, false, true); } } -bool ClipBlock::GetAdjustedThumbnailRange(TimeRange *r) const +bool ClipBlock::get_adjusted_thumbnail_range(TimeRange *r) const { switch (static_cast( - OLIVE_CONFIG("TimelineThumbnailMode").toInt())) { - case Timeline::kThumbnailOff: + OAK_CONFIG("TimelineThumbnailMode").toInt())) { + case Timeline::k_thumbnail_off: // Don't cache any range return false; - case Timeline::kThumbnailInOut: { + case Timeline::k_thumbnail_in_out: { // Only cache in point - rational in = this->media_range().in(); - if (r->Contains(in)) { + Rational in = this->media_range().in(); + if (r->contains(in)) { // Cache only the in point - *r = TimeRange(in, in + thumbnail_cache()->GetTimebase()); + *r = TimeRange(in, in + thumbnail_cache()->get_timebase()); return true; } else { // Cache nothing return false; } } - case Timeline::kThumbnailOn: + case Timeline::k_thumbnail_on: // Cache entire range return true; } @@ -404,16 +404,16 @@ bool ClipBlock::GetAdjustedThumbnailRange(TimeRange *r) const return true; } -void ClipBlock::InvalidateCache(const TimeRange &range, const QString &from, +void ClipBlock::invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) { Q_UNUSED(element) // If signal is from texture input, transform all times from media time to sequence time - if (from == kBufferIn) { + if (from == k_buffer_in) { // Render caches where necessary - if (AreCachesEnabled()) { - RequestRangeFromConnected(range); + if (are_caches_enabled()) { + request_range_from_connected(range); } // Adjust range from media time to sequence time @@ -424,48 +424,48 @@ void ClipBlock::InvalidateCache(const TimeRange &range, const QString &from, // Handle 0 speed by invalidating the whole clip adj = TimeRange(RATIONAL_MIN, RATIONAL_MAX); } else { - adj = TimeRange(MediaToSequenceTime(range.in()), - MediaToSequenceTime(range.out())); + adj = TimeRange(media_to_sequence_time(range.in()), + media_to_sequence_time(range.out())); } // Find connected viewer node - auto viewers = FindInputNodesConnectedToInput( - NodeInput(this, kBufferIn), 1); + auto viewers = find_input_nodes_connected_to_input( + NodeInput(this, k_buffer_in), 1); ViewerOutput *new_connected_viewer = viewers.isEmpty() ? nullptr : viewers.first(); if (new_connected_viewer != connected_viewer_) { if (connected_viewer_) { - disconnect(connected_viewer_->GetMarkers(), - &TimelineMarkerList::MarkerAdded, this, - &ClipBlock::PreviewChanged); - disconnect(connected_viewer_->GetMarkers(), - &TimelineMarkerList::MarkerRemoved, this, - &ClipBlock::PreviewChanged); - disconnect(connected_viewer_->GetMarkers(), - &TimelineMarkerList::MarkerModified, this, - &ClipBlock::PreviewChanged); + disconnect(connected_viewer_->get_markers(), + &TimelineMarkerList::marker_added, this, + &ClipBlock::preview_changed); + disconnect(connected_viewer_->get_markers(), + &TimelineMarkerList::marker_removed, this, + &ClipBlock::preview_changed); + disconnect(connected_viewer_->get_markers(), + &TimelineMarkerList::marker_modified, this, + &ClipBlock::preview_changed); } connected_viewer_ = new_connected_viewer; if (connected_viewer_) { - connect(connected_viewer_->GetMarkers(), - &TimelineMarkerList::MarkerAdded, this, - &ClipBlock::PreviewChanged); - connect(connected_viewer_->GetMarkers(), - &TimelineMarkerList::MarkerRemoved, this, - &ClipBlock::PreviewChanged); - connect(connected_viewer_->GetMarkers(), - &TimelineMarkerList::MarkerModified, this, - &ClipBlock::PreviewChanged); + connect(connected_viewer_->get_markers(), + &TimelineMarkerList::marker_added, this, + &ClipBlock::preview_changed); + connect(connected_viewer_->get_markers(), + &TimelineMarkerList::marker_removed, this, + &ClipBlock::preview_changed); + connect(connected_viewer_->get_markers(), + &TimelineMarkerList::marker_modified, this, + &ClipBlock::preview_changed); } } - super::InvalidateCache(adj, from, element, options); + super::invalidate_cache(adj, from, element, options); } else { // Otherwise, pass signal along normally - super::InvalidateCache(range, from, element, options); + super::invalidate_cache(range, from, element, options); } } @@ -487,23 +487,23 @@ void ClipBlock::InputConnectedEvent(const QString &input, int element, { super::InputConnectedEvent(input, element, output); - if (input == kBufferIn) { - connect(output->thumbnail_cache(), &FrameHashCache::Invalidated, this, - &Block::PreviewChanged); - connect(output->waveform_cache(), &AudioPlaybackCache::Invalidated, - this, &Block::PreviewChanged); - connect(output->video_frame_cache(), &FrameHashCache::Invalidated, this, - &Block::PreviewChanged); + if (input == k_buffer_in) { + connect(output->thumbnail_cache(), &FrameHashCache::invalidated, this, + &Block::preview_changed); + connect(output->waveform_cache(), &AudioPlaybackCache::invalidated, + this, &Block::preview_changed); + connect(output->video_frame_cache(), &FrameHashCache::invalidated, this, + &Block::preview_changed); connect(output->audio_playback_cache(), - &AudioPlaybackCache::Invalidated, this, &Block::PreviewChanged); - connect(output->thumbnail_cache(), &FrameHashCache::Validated, this, - &Block::PreviewChanged); - connect(output->waveform_cache(), &AudioPlaybackCache::Validated, this, - &Block::PreviewChanged); - connect(output->video_frame_cache(), &FrameHashCache::Validated, this, - &Block::PreviewChanged); - connect(output->audio_playback_cache(), &AudioPlaybackCache::Validated, - this, &Block::PreviewChanged); + &AudioPlaybackCache::invalidated, this, &Block::preview_changed); + connect(output->thumbnail_cache(), &FrameHashCache::validated, this, + &Block::preview_changed); + connect(output->waveform_cache(), &AudioPlaybackCache::validated, this, + &Block::preview_changed); + connect(output->video_frame_cache(), &FrameHashCache::validated, this, + &Block::preview_changed); + connect(output->audio_playback_cache(), &AudioPlaybackCache::validated, + this, &Block::preview_changed); } } @@ -512,25 +512,25 @@ void ClipBlock::InputDisconnectedEvent(const QString &input, int element, { super::InputDisconnectedEvent(input, element, output); - if (input == kBufferIn) { - disconnect(output->thumbnail_cache(), &FrameHashCache::Invalidated, - this, &Block::PreviewChanged); - disconnect(output->waveform_cache(), &AudioPlaybackCache::Invalidated, - this, &Block::PreviewChanged); - disconnect(output->video_frame_cache(), &FrameHashCache::Invalidated, - this, &Block::PreviewChanged); + if (input == k_buffer_in) { + disconnect(output->thumbnail_cache(), &FrameHashCache::invalidated, + this, &Block::preview_changed); + disconnect(output->waveform_cache(), &AudioPlaybackCache::invalidated, + this, &Block::preview_changed); + disconnect(output->video_frame_cache(), &FrameHashCache::invalidated, + this, &Block::preview_changed); disconnect(output->audio_playback_cache(), - &AudioPlaybackCache::Invalidated, this, - &Block::PreviewChanged); - disconnect(output->thumbnail_cache(), &FrameHashCache::Validated, this, - &Block::PreviewChanged); - disconnect(output->waveform_cache(), &AudioPlaybackCache::Validated, - this, &Block::PreviewChanged); - disconnect(output->video_frame_cache(), &FrameHashCache::Validated, - this, &Block::PreviewChanged); + &AudioPlaybackCache::invalidated, this, + &Block::preview_changed); + disconnect(output->thumbnail_cache(), &FrameHashCache::validated, this, + &Block::preview_changed); + disconnect(output->waveform_cache(), &AudioPlaybackCache::validated, + this, &Block::preview_changed); + disconnect(output->video_frame_cache(), &FrameHashCache::validated, + this, &Block::preview_changed); disconnect(output->audio_playback_cache(), - &AudioPlaybackCache::Validated, this, - &Block::PreviewChanged); + &AudioPlaybackCache::validated, this, + &Block::preview_changed); } } @@ -538,120 +538,120 @@ void ClipBlock::InputValueChangedEvent(const QString &input, int element) { super::InputValueChangedEvent(input, element); - if (input == kAutoCacheInput) { - if (IsAutocaching()) { - RequestInvalidatedFromConnected(); + if (input == k_auto_cache_input) { + if (is_autocaching()) { + request_invalidated_from_connected(); } else { - Track::Type type = GetTrackType(); + Track::Type type = get_track_type(); - if (Node *connected = GetConnectedOutput(kBufferIn)) { - if (type == Track::kVideo) { - emit connected->video_frame_cache()->CancelAll(); - } else if (type == Track::kAudio) { - emit connected->audio_playback_cache()->CancelAll(); + if (Node *connected = get_connected_output(k_buffer_in)) { + if (type == Track::k_video) { + emit connected->video_frame_cache()->cancel_all(); + } else if (type == Track::k_audio) { + emit connected->audio_playback_cache()->cancel_all(); } } } - } else if (input == kLoopModeInput) { - emit PreviewChanged(); + } else if (input == k_loop_mode_input) { + emit preview_changed(); } } -TimeRange ClipBlock::InputTimeAdjustment(const QString &input, int element, +TimeRange ClipBlock::input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const { Q_UNUSED(element) - if (input == kBufferIn) { - return TimeRange(SequenceToMediaTime(input_time.in()), - SequenceToMediaTime(input_time.out())); + if (input == k_buffer_in) { + return TimeRange(sequence_to_media_time(input_time.in()), + sequence_to_media_time(input_time.out())); } - return super::InputTimeAdjustment(input, element, input_time, clamp); + return super::input_time_adjustment(input, element, input_time, clamp); } -TimeRange ClipBlock::OutputTimeAdjustment(const QString &input, int element, +TimeRange ClipBlock::output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const { Q_UNUSED(element) - if (input == kBufferIn) { - return TimeRange(MediaToSequenceTime(input_time.in()), - MediaToSequenceTime(input_time.out())); + if (input == k_buffer_in) { + return TimeRange(media_to_sequence_time(input_time.in()), + media_to_sequence_time(input_time.out())); } - return super::OutputTimeAdjustment(input, element, input_time); + return super::output_time_adjustment(input, element, input_time); } -void ClipBlock::Value(const NodeValueRow &value, const NodeGlobals &globals, +void ClipBlock::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { Q_UNUSED(globals) // We discard most values here except for the buffer we received - NodeValue data = value[kBufferIn]; + NodeValue data = value[k_buffer_in]; - table->Clear(); - if (data.type() != NodeValue::kNone) { - table->Push(data); + table->clear(); + if (data.type() != NodeValue::k_none) { + table->push(data); } } -void ClipBlock::Retranslate() +void ClipBlock::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kBufferIn, tr("Buffer")); - SetInputName(kMediaInInput, tr("Media In")); - SetInputName(kSpeedInput, tr("Speed")); - SetInputName(kReverseInput, tr("Reverse")); - SetInputName(kMaintainAudioPitchInput, tr("Maintain Audio Pitch")); - SetInputName(kLoopModeInput, tr("Loop")); - SetComboBoxStrings(kLoopModeInput, { tr("None"), tr("Loop"), tr("Clamp") }); + set_input_name(k_buffer_in, tr("Buffer")); + set_input_name(k_media_in_input, tr("Media In")); + set_input_name(k_speed_input, tr("Speed")); + set_input_name(k_reverse_input, tr("Reverse")); + set_input_name(k_maintain_audio_pitch_input, tr("Maintain Audio Pitch")); + set_input_name(k_loop_mode_input, tr("Loop")); + set_combo_box_strings(k_loop_mode_input, { tr("None"), tr("Loop"), tr("Clamp") }); } -void ClipBlock::AddCachePassthroughFrom(ClipBlock *other) +void ClipBlock::add_cache_passthrough_from(ClipBlock *other) { if (auto tc = this->video_frame_cache()) { if (auto oc = other->video_frame_cache()) { - tc->SetPassthrough(oc); + tc->set_passthrough(oc); } } if (auto tc = this->audio_playback_cache()) { if (auto oc = other->audio_playback_cache()) { - tc->SetPassthrough(oc); + tc->set_passthrough(oc); } } if (auto tc = this->thumbnails()) { if (auto oc = other->thumbnails()) { - tc->SetPassthrough(oc); + tc->set_passthrough(oc); } } if (auto tc = this->waveform()) { if (auto oc = other->waveform()) { - tc->SetPassthrough(oc); + tc->set_passthrough(oc); } } } void ClipBlock::ConnectedToPreviewEvent() { - RequestInvalidatedFromConnected(); + request_invalidated_from_connected(); } TimeRange ClipBlock::media_range() const { - return InputTimeAdjustment(kBufferIn, -1, TimeRange(0, length()), false); + return input_time_adjustment(k_buffer_in, -1, TimeRange(0, length()), false); } -MultiCamNode *ClipBlock::FindMulticam() +MultiCamNode *ClipBlock::find_multicam() { - auto v = FindInputNodesConnectedToInput( - NodeInput(this, kBufferIn), 1); + auto v = find_input_nodes_connected_to_input( + NodeInput(this, k_buffer_in), 1); if (v.empty()) { return nullptr; } else { diff --git a/app/node/block/clip/clip.h b/app/node/block/clip/clip.h index 3ab5a50ac..4b4c6c8e2 100644 --- a/app/node/block/clip/clip.h +++ b/app/node/block/clip/clip.h @@ -19,8 +19,8 @@ ***/ -#ifndef CLIPBLOCK_H -#define CLIPBLOCK_H +#ifndef OAK_CLIPBLOCK_H +#define OAK_CLIPBLOCK_H #include "audio/audiovisualwaveform.h" #include "codec/decoder.h" @@ -43,80 +43,80 @@ public: NODE_DEFAULT_FUNCTIONS(ClipBlock) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QString Description() const override; + virtual QString description() const override; - virtual void set_length_and_media_out(const rational &length) override; - virtual void set_length_and_media_in(const rational &length) override; + virtual void set_length_and_media_out(const Rational &length) override; + virtual void set_length_and_media_in(const Rational &length) override; - Track::Type GetTrackType() const + Track::Type get_track_type() const { if (track()) { return track()->type(); } else { - return Track::kNone; + return Track::k_none; } } virtual Node::ValueHint - GetValueHintForInput(const QString &input, int element = -1) const override; + get_value_hint_for_input(const QString &input, int element = -1) const override; - rational media_in() const; - void set_media_in(const rational &media_in); + Rational media_in() const; + void set_media_in(const Rational &media_in); - bool IsAutocaching() const + bool is_autocaching() const { - return GetStandardValue(kAutoCacheInput).toBool(); + return get_standard_value(k_auto_cache_input).toBool(); } - void SetAutocache(bool e); + void set_autocache(bool e); - void DiscardCache(); + void discard_cache(); - virtual void InvalidateCache(const TimeRange &range, const QString &from, + virtual void invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) override; - virtual TimeRange InputTimeAdjustment(const QString &input, int element, + virtual TimeRange input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const override; virtual TimeRange - OutputTimeAdjustment(const QString &input, int element, + output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void Retranslate() override; + virtual void retranslate() override; void - RequestInvalidatedFromConnected(bool force_all = false, + request_invalidated_from_connected(bool force_all = false, const TimeRange &intersect = TimeRange()); double speed() const { - return GetStandardValue(kSpeedInput).toDouble(); + return get_standard_value(k_speed_input).toDouble(); } bool reverse() const { - return GetStandardValue(kReverseInput).toBool(); + return get_standard_value(k_reverse_input).toBool(); } void set_reverse(bool e) { - SetStandardValue(kReverseInput, e); + set_standard_value(k_reverse_input, e); } bool maintain_audio_pitch() const { - return GetStandardValue(kMaintainAudioPitchInput).toBool(); + return get_standard_value(k_maintain_audio_pitch_input).toBool(); } void set_maintain_audio_pitch(bool e) { - SetStandardValue(kMaintainAudioPitchInput, e); + set_standard_value(k_maintain_audio_pitch_input, e); } TransitionBlock *in_transition() @@ -146,7 +146,7 @@ public: FrameHashCache *connected_video_cache() const { - if (Node *n = GetConnectedOutput(kBufferIn)) { + if (Node *n = get_connected_output(k_buffer_in)) { return n->video_frame_cache(); } else { return nullptr; @@ -155,7 +155,7 @@ public: AudioPlaybackCache *connected_audio_cache() const { - if (Node *n = GetConnectedOutput(kBufferIn)) { + if (Node *n = get_connected_output(k_buffer_in)) { return n->audio_playback_cache(); } else { return nullptr; @@ -164,7 +164,7 @@ public: FrameHashCache *thumbnails() { - if (Node *n = GetConnectedOutput(kBufferIn)) { + if (Node *n = get_connected_output(k_buffer_in)) { return n->thumbnail_cache(); } else { return nullptr; @@ -173,26 +173,26 @@ public: AudioWaveformCache *waveform() { - if (Node *n = GetConnectedOutput(kBufferIn)) { + if (Node *n = get_connected_output(k_buffer_in)) { return n->waveform_cache(); } else { return nullptr; } } - void AddCachePassthroughFrom(ClipBlock *other); + void add_cache_passthrough_from(ClipBlock *other); ViewerOutput *connected_viewer() const { return connected_viewer_; } - virtual TimeRange GetVideoCacheRange() const override + virtual TimeRange get_video_cache_range() const override { return TimeRange(0, length()); } - virtual TimeRange GetAudioCacheRange() const override + virtual TimeRange get_audio_cache_range() const override { return TimeRange(0, length()); } @@ -206,24 +206,24 @@ public: */ LoopMode loop_mode() const { - return static_cast(GetStandardValue(kLoopModeInput).toInt()); + return static_cast(get_standard_value(k_loop_mode_input).toInt()); } void set_loop_mode(LoopMode l) { - SetStandardValue(kLoopModeInput, int(l)); + set_standard_value(k_loop_mode_input, int(l)); } - MultiCamNode *FindMulticam(); + MultiCamNode *find_multicam(); - static const QString kBufferIn; - static const QString kMediaInInput; - static const QString kSpeedInput; - static const QString kReverseInput; - static const QString kMaintainAudioPitchInput; - static const QString kLoopModeInput; + static const QString k_buffer_in; + static const QString k_media_in_input; + static const QString k_speed_input; + static const QString k_reverse_input; + static const QString k_maintain_audio_pitch_input; + static const QString k_loop_mode_input; - static const QString kAutoCacheInput; + static const QString k_auto_cache_input; protected: virtual void LinkChangeEvent() override; @@ -239,26 +239,26 @@ protected: private: enum SequenceToMediaTimeFlag { - kSTMNone = 0x0, - kSTMIgnoreReverse = 0x1, - kSTMIgnoreSpeed = 0x2, - kSTMIgnoreLoop = 0x4 + k_stm_none = 0x0, + k_stm_ignore_reverse = 0x1, + k_stm_ignore_speed = 0x2, + k_stm_ignore_loop = 0x4 }; - rational SequenceToMediaTime(const rational &sequence_time, - uint64_t flags = kSTMNone) const; + Rational sequence_to_media_time(const Rational &sequence_time, + uint64_t flags = k_stm_none) const; - rational MediaToSequenceTime(const rational &media_time) const; + Rational media_to_sequence_time(const Rational &media_time) const; - void RequestRangeFromConnected(const TimeRange &range); + void request_range_from_connected(const TimeRange &range); - void RequestRangeForCache(PlaybackCache *cache, const TimeRange &max_range, + void request_range_for_cache(PlaybackCache *cache, const TimeRange &max_range, const TimeRange &range, bool invalidate, bool request); - void RequestInvalidatedForCache(PlaybackCache *cache, + void request_invalidated_for_cache(PlaybackCache *cache, const TimeRange &max_range); - bool GetAdjustedThumbnailRange(TimeRange *r) const; + bool get_adjusted_thumbnail_range(TimeRange *r) const; QVector block_links_; @@ -268,7 +268,7 @@ private: ViewerOutput *connected_viewer_; private: - rational last_media_in_; + Rational last_media_in_; }; } diff --git a/app/node/block/gap/gap.cpp b/app/node/block/gap/gap.cpp index 5a9f1880d..f445ec368 100644 --- a/app/node/block/gap/gap.cpp +++ b/app/node/block/gap/gap.cpp @@ -28,7 +28,7 @@ GapBlock::GapBlock() { } -QString GapBlock::Name() const +QString GapBlock::name() const { return tr("Gap"); } @@ -38,7 +38,7 @@ QString GapBlock::id() const return QStringLiteral("org.olivevideoeditor.Olive.gap"); } -QString GapBlock::Description() const +QString GapBlock::description() const { return tr("A time-based node that represents an empty space."); } diff --git a/app/node/block/gap/gap.h b/app/node/block/gap/gap.h index f1b37f3a2..bfe727a5a 100644 --- a/app/node/block/gap/gap.h +++ b/app/node/block/gap/gap.h @@ -19,8 +19,8 @@ ***/ -#ifndef GAPBLOCK_H -#define GAPBLOCK_H +#ifndef OAK_GAPBLOCK_H +#define OAK_GAPBLOCK_H #include "node/block/block.h" @@ -37,9 +37,9 @@ public: NODE_DEFAULT_FUNCTIONS(GapBlock) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QString Description() const override; + virtual QString description() const override; }; } diff --git a/app/node/block/subtitle/subtitle.cpp b/app/node/block/subtitle/subtitle.cpp index 75d5c50a0..a6da17144 100644 --- a/app/node/block/subtitle/subtitle.cpp +++ b/app/node/block/subtitle/subtitle.cpp @@ -26,30 +26,30 @@ namespace olive #define super ClipBlock -const QString SubtitleBlock::kTextIn = QStringLiteral("text_in"); +const QString SubtitleBlock::k_text_in = QStringLiteral("text_in"); SubtitleBlock::SubtitleBlock() { - AddInput(kTextIn, NodeValue::kText, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_text_in, NodeValue::k_text, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - SetInputFlag(kBufferIn, kInputFlagHidden); - SetInputFlag(kLengthInput, kInputFlagHidden); - SetInputFlag(kMediaInInput, kInputFlagHidden); - SetInputFlag(kSpeedInput, kInputFlagHidden); - SetInputFlag(kReverseInput, kInputFlagHidden); - SetInputFlag(kMaintainAudioPitchInput, kInputFlagHidden); + set_input_flag(k_buffer_in, k_input_flag_hidden); + set_input_flag(k_length_input, k_input_flag_hidden); + set_input_flag(k_media_in_input, k_input_flag_hidden); + set_input_flag(k_speed_input, k_input_flag_hidden); + set_input_flag(k_reverse_input, k_input_flag_hidden); + set_input_flag(k_maintain_audio_pitch_input, k_input_flag_hidden); // Undo block flag that hides in param view - SetFlag(kDontShowInParamView, false); + set_flag(k_dont_show_in_param_view, false); } -QString SubtitleBlock::Name() const +QString SubtitleBlock::name() const { - if (GetText().isEmpty()) { + if (get_text().isEmpty()) { return tr("Subtitle"); } else { - return GetText(); + return get_text(); } } @@ -58,17 +58,17 @@ QString SubtitleBlock::id() const return QStringLiteral("org.olivevideoeditor.Olive.subtitle"); } -QString SubtitleBlock::Description() const +QString SubtitleBlock::description() const { return tr( "A time-based node representing a single subtitle element for a certain period of time."); } -void SubtitleBlock::Retranslate() +void SubtitleBlock::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextIn, tr("Text")); + set_input_name(k_text_in, tr("Text")); } } diff --git a/app/node/block/subtitle/subtitle.h b/app/node/block/subtitle/subtitle.h index 824c6f27c..ae3689668 100644 --- a/app/node/block/subtitle/subtitle.h +++ b/app/node/block/subtitle/subtitle.h @@ -19,8 +19,8 @@ ***/ -#ifndef SUBTITLEBLOCK_H -#define SUBTITLEBLOCK_H +#ifndef OAK_SUBTITLEBLOCK_H +#define OAK_SUBTITLEBLOCK_H #include "node/block/clip/clip.h" @@ -34,25 +34,25 @@ public: NODE_DEFAULT_FUNCTIONS(SubtitleBlock) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QString Description() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - static const QString kTextIn; + static const QString k_text_in; - QString GetText() const + QString get_text() const { - return GetStandardValue(kTextIn).toString(); + return get_standard_value(k_text_in).toString(); } - void SetText(const QString &text) + void set_text(const QString &text) { - SetStandardValue(kTextIn, text); + set_standard_value(k_text_in, text); } }; } -#endif // SUBTITLEBLOCK_H +#endif // OAK_SUBTITLEBLOCK_H diff --git a/app/node/block/transition/crossdissolve/crossdissolvetransition.cpp b/app/node/block/transition/crossdissolve/crossdissolvetransition.cpp index cbc0f274f..8d830e8c5 100644 --- a/app/node/block/transition/crossdissolve/crossdissolvetransition.cpp +++ b/app/node/block/transition/crossdissolve/crossdissolvetransition.cpp @@ -28,7 +28,7 @@ CrossDissolveTransition::CrossDissolveTransition() { } -QString CrossDissolveTransition::Name() const +QString CrossDissolveTransition::name() const { return tr("Cross Dissolve"); } @@ -38,23 +38,23 @@ QString CrossDissolveTransition::id() const return QStringLiteral("org.olivevideoeditor.Olive.crossdissolve"); } -QVector CrossDissolveTransition::Category() const +QVector CrossDissolveTransition::category() const { - return { kCategoryTransition }; + return { k_category_transition }; } -QString CrossDissolveTransition::Description() const +QString CrossDissolveTransition::description() const { return tr("Smoothly transition between two clips."); } ShaderCode -CrossDissolveTransition::GetShaderCode(const ShaderRequest &request) const +CrossDissolveTransition::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/crossdissolve.frag"), + FileFunctions::read_file_as_string(":/shaders/crossdissolve.frag"), QString()); } @@ -65,8 +65,8 @@ void CrossDissolveTransition::SampleJobEvent(const SampleBuffer &from_samples, { for (size_t i = 0; i < out_samples.sample_count(); i++) { double this_sample_time = - out_samples.audio_params().samples_to_time(i).toDouble() + time_in; - double progress = GetTotalProgress(this_sample_time); + out_samples.audio_params().samples_to_time(i).to_double() + time_in; + double progress = get_total_progress(this_sample_time); for (int j = 0; j < out_samples.audio_params().channel_count(); j++) { out_samples.data(j)[i] = 0; @@ -74,7 +74,7 @@ void CrossDissolveTransition::SampleJobEvent(const SampleBuffer &from_samples, if (from_samples.is_allocated()) { if (i < from_samples.sample_count()) { out_samples.data(j)[i] += from_samples.data(j)[i] * - TransformCurve(1.0 - progress); + transform_curve(1.0 - progress); } } @@ -85,7 +85,7 @@ void CrossDissolveTransition::SampleJobEvent(const SampleBuffer &from_samples, if (i >= remain) { qint64 in_index = i - remain; out_samples.data(j)[i] += - to_samples.data(j)[in_index] * TransformCurve(progress); + to_samples.data(j)[in_index] * transform_curve(progress); } } } diff --git a/app/node/block/transition/crossdissolve/crossdissolvetransition.h b/app/node/block/transition/crossdissolve/crossdissolvetransition.h index 25b2065dd..c8461b4be 100644 --- a/app/node/block/transition/crossdissolve/crossdissolvetransition.h +++ b/app/node/block/transition/crossdissolve/crossdissolvetransition.h @@ -19,8 +19,8 @@ ***/ -#ifndef CROSSDISSOLVETRANSITION_H -#define CROSSDISSOLVETRANSITION_H +#ifndef OAK_CROSSDISSOLVETRANSITION_H +#define OAK_CROSSDISSOLVETRANSITION_H #include "node/block/transition/transition.h" @@ -34,15 +34,15 @@ public: NODE_DEFAULT_FUNCTIONS(CrossDissolveTransition) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; //virtual void Retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; protected: virtual void SampleJobEvent(const SampleBuffer &from_samples, @@ -53,4 +53,4 @@ protected: } -#endif // CROSSDISSOLVETRANSITION_H +#endif // OAK_CROSSDISSOLVETRANSITION_H diff --git a/app/node/block/transition/diptocolor/diptocolortransition.cpp b/app/node/block/transition/diptocolor/diptocolortransition.cpp index 866137366..1f853a1d3 100644 --- a/app/node/block/transition/diptocolor/diptocolortransition.cpp +++ b/app/node/block/transition/diptocolor/diptocolortransition.cpp @@ -24,17 +24,17 @@ namespace olive { -const QString DipToColorTransition::kColorInput = QStringLiteral("color_in"); +const QString DipToColorTransition::k_color_input = QStringLiteral("color_in"); #define super TransitionBlock DipToColorTransition::DipToColorTransition() { - AddInput(kColorInput, NodeValue::kColor, + add_input(k_color_input, NodeValue::k_color, QVariant::fromValue(Color(0, 0, 0))); } -QString DipToColorTransition::Name() const +QString DipToColorTransition::name() const { return tr("Dip To Color"); } @@ -44,37 +44,37 @@ QString DipToColorTransition::id() const return QStringLiteral("org.olivevideoeditor.Olive.diptocolor"); } -QVector DipToColorTransition::Category() const +QVector DipToColorTransition::category() const { - return { kCategoryTransition }; + return { k_category_transition }; } -QString DipToColorTransition::Description() const +QString DipToColorTransition::description() const { return tr("Transition between clips by dipping to a color."); } ShaderCode -DipToColorTransition::GetShaderCode(const ShaderRequest &request) const +DipToColorTransition::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/diptoblack.frag"), + FileFunctions::read_file_as_string(":/shaders/diptoblack.frag"), QString()); } -void DipToColorTransition::Retranslate() +void DipToColorTransition::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kColorInput, tr("Color")); + set_input_name(k_color_input, tr("Color")); } void DipToColorTransition::ShaderJobEvent(const NodeValueRow &value, ShaderJob *job) const { - job->Insert(kColorInput, value); + job->insert(k_color_input, value); } } diff --git a/app/node/block/transition/diptocolor/diptocolortransition.h b/app/node/block/transition/diptocolor/diptocolortransition.h index 79ae9f949..5704e469e 100644 --- a/app/node/block/transition/diptocolor/diptocolortransition.h +++ b/app/node/block/transition/diptocolor/diptocolortransition.h @@ -19,8 +19,8 @@ ***/ -#ifndef DIPTOCOLORTRANSITION_H -#define DIPTOCOLORTRANSITION_H +#ifndef OAK_DIPTOCOLORTRANSITION_H +#define OAK_DIPTOCOLORTRANSITION_H #include "node/block/transition/transition.h" @@ -34,17 +34,17 @@ public: NODE_DEFAULT_FUNCTIONS(DipToColorTransition) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - virtual void Retranslate() override; + virtual void retranslate() override; - static const QString kColorInput; + static const QString k_color_input; protected: virtual void ShaderJobEvent(const NodeValueRow &value, @@ -53,4 +53,4 @@ protected: } -#endif // DIPTOCOLORTRANSITION_H +#endif // OAK_DIPTOCOLORTRANSITION_H diff --git a/app/node/block/transition/transition.cpp b/app/node/block/transition/transition.cpp index 2aa63a4c0..e4e8fd6c3 100644 --- a/app/node/block/transition/transition.cpp +++ b/app/node/block/transition/transition.cpp @@ -30,48 +30,48 @@ namespace olive #define super Block -const QString TransitionBlock::kOutBlockInput = QStringLiteral("out_block_in"); -const QString TransitionBlock::kInBlockInput = QStringLiteral("in_block_in"); -const QString TransitionBlock::kCurveInput = QStringLiteral("curve_in"); -const QString TransitionBlock::kCenterInput = QStringLiteral("center_in"); +const QString TransitionBlock::k_out_block_input = QStringLiteral("out_block_in"); +const QString TransitionBlock::k_in_block_input = QStringLiteral("in_block_in"); +const QString TransitionBlock::k_curve_input = QStringLiteral("curve_in"); +const QString TransitionBlock::k_center_input = QStringLiteral("center_in"); TransitionBlock::TransitionBlock() : connected_out_block_(nullptr) , connected_in_block_(nullptr) { - AddInput(kOutBlockInput, NodeValue::kNone, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_out_block_input, NodeValue::k_none, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kInBlockInput, NodeValue::kNone, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_in_block_input, NodeValue::k_none, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kCurveInput, NodeValue::kCombo, - InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); + add_input(k_curve_input, NodeValue::k_combo, + InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable)); - AddInput(kCenterInput, NodeValue::kRational, - InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); - SetInputProperty(kCenterInput, QStringLiteral("view"), - RationalSlider::kTime); - SetInputProperty(kCenterInput, QStringLiteral("viewlock"), true); + add_input(k_center_input, NodeValue::k_rational, + InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable)); + set_input_property(k_center_input, QStringLiteral("view"), + RationalSlider::k_time); + set_input_property(k_center_input, QStringLiteral("viewlock"), true); - SetFlag(kDontShowInParamView, false); + set_flag(k_dont_show_in_param_view, false); } -void TransitionBlock::Retranslate() +void TransitionBlock::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kOutBlockInput, tr("From")); - SetInputName(kInBlockInput, tr("To")); - SetInputName(kCurveInput, tr("Curve")); - SetInputName(kCenterInput, tr("Center Offset")); + set_input_name(k_out_block_input, tr("From")); + set_input_name(k_in_block_input, tr("To")); + set_input_name(k_curve_input, tr("Curve")); + set_input_name(k_center_input, tr("Center Offset")); // These must correspond to the CurveType enum - SetComboBoxStrings(kCurveInput, + set_combo_box_strings(k_curve_input, { tr("Linear"), tr("Exponential"), tr("Logarithmic") }); } -rational TransitionBlock::in_offset() const +Rational TransitionBlock::in_offset() const { if (is_dual_transition()) { return length() / 2 + offset_center(); @@ -82,7 +82,7 @@ rational TransitionBlock::in_offset() const } } -rational TransitionBlock::out_offset() const +Rational TransitionBlock::out_offset() const { if (is_dual_transition()) { return length() / 2 - offset_center(); @@ -93,21 +93,21 @@ rational TransitionBlock::out_offset() const } } -rational TransitionBlock::offset_center() const +Rational TransitionBlock::offset_center() const { - return GetStandardValue(kCenterInput).value(); + return get_standard_value(k_center_input).value(); } -void TransitionBlock::set_offset_center(const rational &r) +void TransitionBlock::set_offset_center(const Rational &r) { - SetStandardValue(kCenterInput, QVariant::fromValue(r)); + set_standard_value(k_center_input, QVariant::fromValue(r)); } -void TransitionBlock::set_offsets_and_length(const rational &in_offset, - const rational &out_offset) +void TransitionBlock::set_offsets_and_length(const Rational &in_offset, + const Rational &out_offset) { - rational len = in_offset + out_offset; - rational center = len / 2 - in_offset; + Rational len = in_offset + out_offset; + Rational center = len / 2 - in_offset; set_length_and_media_out(len); set_offset_center(center); @@ -123,101 +123,101 @@ Block *TransitionBlock::connected_in_block() const return connected_in_block_; } -double TransitionBlock::GetTotalProgress(const double &time) const +double TransitionBlock::get_total_progress(const double &time) const { - return GetInternalTransitionTime(time) / length().toDouble(); + return get_internal_transition_time(time) / length().to_double(); } -double TransitionBlock::GetOutProgress(const double &time) const +double TransitionBlock::get_out_progress(const double &time) const { if (out_offset() == 0) { return 0; } return std::clamp( - 1.0 - (GetInternalTransitionTime(time) / out_offset().toDouble()), 0.0, + 1.0 - (get_internal_transition_time(time) / out_offset().to_double()), 0.0, 1.0); } -double TransitionBlock::GetInProgress(const double &time) const +double TransitionBlock::get_in_progress(const double &time) const { if (in_offset() == 0) { return 0; } return std::clamp( - (GetInternalTransitionTime(time) - out_offset().toDouble()) / - in_offset().toDouble(), + (get_internal_transition_time(time) - out_offset().to_double()) / + in_offset().to_double(), 0.0, 1.0); } -double TransitionBlock::GetInternalTransitionTime(const double &time) const +double TransitionBlock::get_internal_transition_time(const double &time) const { return time; } -void TransitionBlock::InsertTransitionTimes(AcceleratedJob *job, +void TransitionBlock::insert_transition_times(AcceleratedJob *job, const double &time) const { // Provides total transition progress from 0.0 (start) - 1.0 (end) - job->Insert(QStringLiteral("ove_tprog_all"), - NodeValue(NodeValue::kFloat, GetTotalProgress(time), this)); + job->insert(QStringLiteral("ove_tprog_all"), + NodeValue(NodeValue::k_float, get_total_progress(time), this)); // Provides progress of out section from 1.0 (start) - 0.0 (end) - job->Insert(QStringLiteral("ove_tprog_out"), - NodeValue(NodeValue::kFloat, GetOutProgress(time), this)); + job->insert(QStringLiteral("ove_tprog_out"), + NodeValue(NodeValue::k_float, get_out_progress(time), this)); // Provides progress of in section from 0.0 (start) - 1.0 (end) - job->Insert(QStringLiteral("ove_tprog_in"), - NodeValue(NodeValue::kFloat, GetInProgress(time), this)); + job->insert(QStringLiteral("ove_tprog_in"), + NodeValue(NodeValue::k_float, get_in_progress(time), this)); } -void TransitionBlock::Value(const NodeValueRow &value, +void TransitionBlock::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - NodeValue out_buffer = value[kOutBlockInput]; - NodeValue in_buffer = value[kInBlockInput]; - NodeValue::Type data_type = (out_buffer.type() != NodeValue::kNone) ? + NodeValue out_buffer = value[k_out_block_input]; + NodeValue in_buffer = value[k_in_block_input]; + NodeValue::Type data_type = (out_buffer.type() != NodeValue::k_none) ? out_buffer.type() : in_buffer.type(); - NodeValue::Type job_type = NodeValue::kNone; + NodeValue::Type job_type = NodeValue::k_none; QVariant push_job; - if (data_type == NodeValue::kTexture) { + if (data_type == NodeValue::k_texture) { // This must be a visual transition ShaderJob job; - if (out_buffer.type() != NodeValue::kNone) { - job.Insert(kOutBlockInput, out_buffer); + if (out_buffer.type() != NodeValue::k_none) { + job.insert(k_out_block_input, out_buffer); } else { - job.Insert(kOutBlockInput, NodeValue(NodeValue::kTexture, nullptr)); + job.insert(k_out_block_input, NodeValue(NodeValue::k_texture, nullptr)); } - if (in_buffer.type() != NodeValue::kNone) { - job.Insert(kInBlockInput, in_buffer); + if (in_buffer.type() != NodeValue::k_none) { + job.insert(k_in_block_input, in_buffer); } else { - job.Insert(kInBlockInput, NodeValue(NodeValue::kTexture, nullptr)); + job.insert(k_in_block_input, NodeValue(NodeValue::k_texture, nullptr)); } - job.Insert(kCurveInput, value); + job.insert(k_curve_input, value); - double time = globals.time().in().toDouble(); - InsertTransitionTimes(&job, time); + double time = globals.time().in().to_double(); + insert_transition_times(&job, time); ShaderJobEvent(value, &job); - job_type = NodeValue::kTexture; - push_job = QVariant::fromValue(Texture::Job(globals.vparams(), job)); - } else if (data_type == NodeValue::kSamples) { + job_type = NodeValue::k_texture; + push_job = QVariant::fromValue(Texture::job(globals.vparams(), job)); + } else if (data_type == NodeValue::k_samples) { // This must be an audio transition - SampleBuffer from_samples = out_buffer.toSamples(); - SampleBuffer to_samples = in_buffer.toSamples(); + SampleBuffer from_samples = out_buffer.to_samples(); + SampleBuffer to_samples = in_buffer.to_samples(); if (from_samples.is_allocated() || to_samples.is_allocated()) { - double time_in = globals.time().in().toDouble(); - double time_out = globals.time().out().toDouble(); + double time_in = globals.time().in().to_double(); + double time_out = globals.time().out().to_double(); const AudioParams ¶ms = (from_samples.is_allocated()) ? from_samples.audio_params() : @@ -232,41 +232,41 @@ void TransitionBlock::Value(const NodeValueRow &value, SampleJobEvent(from_samples, to_samples, out_samples, time_in); } - job_type = NodeValue::kSamples; + job_type = NodeValue::k_samples; push_job = QVariant::fromValue(out_samples); } } if (!push_job.isNull()) { - table->Push(job_type, push_job, this); + table->push(job_type, push_job, this); } } -void TransitionBlock::InvalidateCache(const TimeRange &range, +void TransitionBlock::invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) { TimeRange r = range; - if (from == kOutBlockInput || from == kInBlockInput) { - Block *n = dynamic_cast(GetConnectedOutput(from)); + if (from == k_out_block_input || from == k_in_block_input) { + Block *n = dynamic_cast(get_connected_output(from)); if (n) { - r = Track::TransformRangeFromBlock(n, r); + r = Track::transform_range_from_block(n, r); } } - super::InvalidateCache(r, from, element, options); + super::invalidate_cache(r, from, element, options); } -double TransitionBlock::TransformCurve(double linear) const +double TransitionBlock::transform_curve(double linear) const { - switch (static_cast(GetStandardValue(kCurveInput).toInt())) { - case kLinear: + switch (static_cast(get_standard_value(k_curve_input).toInt())) { + case k_linear: break; - case kExponential: + case k_exponential: linear *= linear; break; - case kLogarithmic: + case k_logarithmic: linear = std::sqrt(linear); break; } @@ -279,12 +279,12 @@ void TransitionBlock::InputConnectedEvent(const QString &input, int element, { Q_UNUSED(element) - if (input == kOutBlockInput) { + if (input == k_out_block_input) { // If node is not a block, this will just be null if ((connected_out_block_ = dynamic_cast(output))) { connected_out_block_->set_out_transition(this); } - } else if (input == kInBlockInput) { + } else if (input == k_in_block_input) { // If node is not a block, this will just be null if ((connected_in_block_ = dynamic_cast(output))) { connected_in_block_->set_in_transition(this); @@ -298,12 +298,12 @@ void TransitionBlock::InputDisconnectedEvent(const QString &input, int element, Q_UNUSED(element) Q_UNUSED(output) - if (input == kOutBlockInput) { + if (input == k_out_block_input) { if (connected_out_block_) { connected_out_block_->set_out_transition(nullptr); connected_out_block_ = nullptr; } - } else if (input == kInBlockInput) { + } else if (input == k_in_block_input) { if (connected_in_block_) { connected_in_block_->set_in_transition(nullptr); connected_in_block_ = nullptr; @@ -311,34 +311,34 @@ void TransitionBlock::InputDisconnectedEvent(const QString &input, int element, } } -TimeRange TransitionBlock::InputTimeAdjustment(const QString &input, +TimeRange TransitionBlock::input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const { - if (input == kInBlockInput || input == kOutBlockInput) { - Block *block = dynamic_cast(GetConnectedOutput(input)); + if (input == k_in_block_input || input == k_out_block_input) { + Block *block = dynamic_cast(get_connected_output(input)); if (block) { // Retransform time as if it came from the track return input_time + in() - block->in(); } } - return super::InputTimeAdjustment(input, element, input_time, clamp); + return super::input_time_adjustment(input, element, input_time, clamp); } TimeRange -TransitionBlock::OutputTimeAdjustment(const QString &input, int element, +TransitionBlock::output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const { - if (input == kInBlockInput || input == kOutBlockInput) { - Block *block = dynamic_cast(GetConnectedOutput(input)); + if (input == k_in_block_input || input == k_out_block_input) { + Block *block = dynamic_cast(get_connected_output(input)); if (block) { return input_time + block->in() - in(); } } - return super::OutputTimeAdjustment(input, element, input_time); + return super::output_time_adjustment(input, element, input_time); } } diff --git a/app/node/block/transition/transition.h b/app/node/block/transition/transition.h index 854993b1a..1c056b9e2 100644 --- a/app/node/block/transition/transition.h +++ b/app/node/block/transition/transition.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRANSITIONBLOCK_H -#define TRANSITIONBLOCK_H +#ifndef OAK_TRANSITIONBLOCK_H +#define OAK_TRANSITIONBLOCK_H #include "node/block/block.h" @@ -34,10 +34,10 @@ class TransitionBlock : public Block { public: TransitionBlock(); - virtual void Retranslate() override; + virtual void retranslate() override; - rational in_offset() const; - rational out_offset() const; + Rational in_offset() const; + Rational out_offset() const; /** * @brief Return the "middle point" of the transition, relative to the transition @@ -47,11 +47,11 @@ public: * 0 means the center of the transition is right in the middle and the in and out offsets will * be equal. */ - rational offset_center() const; - void set_offset_center(const rational &r); + Rational offset_center() const; + void set_offset_center(const Rational &r); - void set_offsets_and_length(const rational &in_offset, - const rational &out_offset); + void set_offsets_and_length(const Rational &in_offset, + const Rational &out_offset); bool is_dual_transition() const { @@ -61,21 +61,21 @@ public: Block *connected_out_block() const; Block *connected_in_block() const; - double GetTotalProgress(const double &time) const; - double GetOutProgress(const double &time) const; - double GetInProgress(const double &time) const; + double get_total_progress(const double &time) const; + double get_out_progress(const double &time) const; + double get_in_progress(const double &time) const; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void InvalidateCache( + virtual void invalidate_cache( const TimeRange &range, const QString &from, int element = -1, InvalidateCacheOptions options = InvalidateCacheOptions()) override; - static const QString kOutBlockInput; - static const QString kInBlockInput; - static const QString kCurveInput; - static const QString kCenterInput; + static const QString k_out_block_input; + static const QString k_in_block_input; + static const QString k_curve_input; + static const QString k_center_input; protected: virtual void ShaderJobEvent(const NodeValueRow &value, ShaderJob *job) const @@ -88,7 +88,7 @@ protected: { } - double TransformCurve(double linear) const; + double transform_curve(double linear) const; virtual void InputConnectedEvent(const QString &input, int element, Node *output) override; @@ -96,20 +96,20 @@ protected: virtual void InputDisconnectedEvent(const QString &input, int element, Node *output) override; - virtual TimeRange InputTimeAdjustment(const QString &input, int element, + virtual TimeRange input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const override; virtual TimeRange - OutputTimeAdjustment(const QString &input, int element, + output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const override; private: - enum CurveType { kLinear, kExponential, kLogarithmic }; + enum CurveType { k_linear, k_exponential, k_logarithmic }; - double GetInternalTransitionTime(const double &time) const; + double get_internal_transition_time(const double &time) const; - void InsertTransitionTimes(AcceleratedJob *job, const double &time) const; + void insert_transition_times(AcceleratedJob *job, const double &time) const; ClipBlock *connected_out_block_; @@ -118,4 +118,4 @@ private: } -#endif // TRANSITIONBLOCK_H +#endif // OAK_TRANSITIONBLOCK_H diff --git a/app/node/color/colormanager/colormanager.cpp b/app/node/color/colormanager/colormanager.cpp index b4f511012..fc162c57c 100644 --- a/app/node/color/colormanager/colormanager.cpp +++ b/app/node/color/colormanager/colormanager.cpp @@ -34,7 +34,7 @@ namespace olive #define super Node -OCIO::ConstConfigRcPtr ColorManager::default_config_ = nullptr; +ocio::ConstConfigRcPtr ColorManager::default_config = nullptr; ColorManager::ColorManager(Project *project) : QObject(project) @@ -42,51 +42,51 @@ ColorManager::ColorManager(Project *project) { } -void ColorManager::Init() +void ColorManager::init() { // Set config to our built-in default - config_ = GetDefaultConfig(); - SetDefaultInputColorSpace(config_->getCanonicalName(OCIO::ROLE_DEFAULT)); - project()->SetColorReferenceSpace(OCIO::ROLE_SCENE_LINEAR); + config_ = get_default_config(); + set_default_input_color_space(config_->getCanonicalName(ocio::ROLE_DEFAULT)); + project()->set_color_reference_space(ocio::ROLE_SCENE_LINEAR); } -OCIO::ConstConfigRcPtr ColorManager::GetConfig() const +ocio::ConstConfigRcPtr ColorManager::get_config() const { return config_; } -OCIO::ConstConfigRcPtr -ColorManager::CreateConfigFromFile(const QString &filename) +ocio::ConstConfigRcPtr +ColorManager::create_config_from_file(const QString &filename) { - return OCIO::Config::CreateFromFile(filename.toUtf8()); + return ocio::Config::CreateFromFile(filename.toUtf8()); } -QString ColorManager::GetConfigFilename() const +QString ColorManager::get_config_filename() const { - return project()->GetColorConfigFilename(); + return project()->get_color_config_filename(); } -OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig() +ocio::ConstConfigRcPtr ColorManager::get_default_config() { // Set up on first use: Project construction calls ColorManager::Init() // unconditionally, so without this any Project created before // SetUpDefaultConfig() crashed dereferencing a null config. - if (!default_config_) { - SetUpDefaultConfig(); + if (!default_config) { + set_up_default_config(); } - return default_config_; + return default_config; } -void ColorManager::SetUpDefaultConfig() +void ColorManager::set_up_default_config() { if (!qEnvironmentVariableIsEmpty("OCIO")) { // Attempt to set config from "OCIO" environment variable try { - default_config_ = OCIO::Config::CreateFromEnv(); + default_config = ocio::Config::CreateFromEnv(); return; - } catch (OCIO::Exception &e) { + } catch (ocio::Exception &e) { qWarning() << "Failed to load config from OCIO environment variable config:" << e.what(); @@ -98,20 +98,20 @@ void ColorManager::SetUpDefaultConfig() QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) .filePath(QStringLiteral("ocioconf")); - FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"), dir, true); + FileFunctions::copy_directory(QStringLiteral(":/ocioconf"), dir, true); qDebug() << "Extracting default OCIO config to" << dir; - default_config_ = - CreateConfigFromFile(QDir(dir).filePath(QStringLiteral("config.ocio"))); + default_config = + create_config_from_file(QDir(dir).filePath(QStringLiteral("config.ocio"))); } -void ColorManager::SetConfigFilename(const QString &filename) +void ColorManager::set_config_filename(const QString &filename) { - project()->SetColorConfigFilename(filename); + project()->set_color_config_filename(filename); } -QStringList ColorManager::ListAvailableDisplays() +QStringList ColorManager::list_available_displays() { QStringList displays; @@ -124,12 +124,12 @@ QStringList ColorManager::ListAvailableDisplays() return displays; } -QString ColorManager::GetDefaultDisplay() +QString ColorManager::get_default_display() { return config_->getDefaultDisplay(); } -QStringList ColorManager::ListAvailableViews(QString display) +QStringList ColorManager::list_available_views(QString display) { QStringList views; @@ -142,12 +142,12 @@ QStringList ColorManager::ListAvailableViews(QString display) return views; } -QString ColorManager::GetDefaultView(const QString &display) +QString ColorManager::get_default_view(const QString &display) { return config_->getDefaultView(display.toUtf8()); } -QStringList ColorManager::ListAvailableLooks() +QStringList ColorManager::list_available_looks() { QStringList looks; @@ -160,37 +160,37 @@ QStringList ColorManager::ListAvailableLooks() return looks; } -QStringList ColorManager::ListAvailableColorspaces() const +QStringList ColorManager::list_available_colorspaces() const { - return ListAvailableColorspaces(config_); + return list_available_colorspaces(config_); } -QString ColorManager::GetDefaultInputColorSpace() const +QString ColorManager::get_default_input_color_space() const { - return project()->GetDefaultInputColorSpace(); + return project()->get_default_input_color_space(); } -void ColorManager::SetDefaultInputColorSpace(const QString &s) +void ColorManager::set_default_input_color_space(const QString &s) { - project()->SetDefaultInputColorSpace(s); + project()->set_default_input_color_space(s); } -QString ColorManager::GetReferenceColorSpace() const +QString ColorManager::get_reference_color_space() const { - return project()->GetColorReferenceSpace(); + return project()->get_color_reference_space(); } -QString ColorManager::GetCompliantColorSpace(const QString &s) +QString ColorManager::get_compliant_color_space(const QString &s) { - if (ListAvailableColorspaces().contains(s)) { + if (list_available_colorspaces().contains(s)) { return s; } else { - return GetDefaultInputColorSpace(); + return get_default_input_color_space(); } } ColorTransform -ColorManager::GetCompliantColorSpace(const ColorTransform &transform, +ColorManager::get_compliant_color_space(const ColorTransform &transform, bool force_display) { if (transform.is_display() || force_display) { @@ -200,17 +200,17 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform, QString look = transform.look(); // Check if display still exists in config - if (!ListAvailableDisplays().contains(display)) { - display = GetDefaultDisplay(); + if (!list_available_displays().contains(display)) { + display = get_default_display(); } // Check if view still exists in display - if (!ListAvailableViews(display).contains(view)) { - view = GetDefaultView(display); + if (!list_available_views(display).contains(view)) { + view = get_default_view(display); } // Check if looks still exists - if (!ListAvailableLooks().contains(look)) { + if (!list_available_looks().contains(look)) { look.clear(); } @@ -219,8 +219,8 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform, } else { QString output = transform.output(); - if (!ListAvailableColorspaces().contains(output)) { - output = GetDefaultInputColorSpace(); + if (!list_available_colorspaces().contains(output)) { + output = get_default_input_color_space(); } return ColorTransform(output); @@ -228,7 +228,7 @@ ColorManager::GetCompliantColorSpace(const ColorTransform &transform, } QStringList -ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config) +ColorManager::list_available_colorspaces(ocio::ConstConfigRcPtr config) { QStringList spaces; @@ -243,7 +243,7 @@ ColorManager::ListAvailableColorspaces(OCIO::ConstConfigRcPtr config) return spaces; } -void ColorManager::GetDefaultLumaCoefs(double *rgb) const +void ColorManager::get_default_luma_coefs(double *rgb) const { config_->getDefaultLumaCoefs(rgb); } @@ -253,17 +253,17 @@ Project *ColorManager::project() const return static_cast(parent()); } -void ColorManager::UpdateConfigFromFilename() +void ColorManager::update_config_from_filename() { try { - QString config_filename = GetConfigFilename(); - QString old_default_cs = GetDefaultInputColorSpace(); + QString config_filename = get_config_filename(); + QString old_default_cs = get_default_input_color_space(); - config_ = OCIO::Config::CreateFromFile(config_filename.toUtf8()); + config_ = ocio::Config::CreateFromFile(config_filename.toUtf8()); // Set new default colorspace appropriately QString new_default = old_default_cs; - QStringList available_cs = ListAvailableColorspaces(); + QStringList available_cs = list_available_colorspaces(); for (int i = 0; i < available_cs.size(); i++) { const QString &c = available_cs.at(i); if (c.compare(old_default_cs, Qt::CaseInsensitive)) { @@ -271,10 +271,10 @@ void ColorManager::UpdateConfigFromFilename() break; } } - SetDefaultInputColorSpace(new_default); + set_default_input_color_space(new_default); - emit ConfigChanged(config_filename); - } catch (OCIO::Exception &) { + emit config_changed(config_filename); + } catch (ocio::Exception &) { } } diff --git a/app/node/color/colormanager/colormanager.h b/app/node/color/colormanager/colormanager.h index a270e61d5..e2c82d24b 100644 --- a/app/node/color/colormanager/colormanager.h +++ b/app/node/color/colormanager/colormanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORSERVICE_H -#define COLORSERVICE_H +#ifndef OAK_COLORSERVICE_H +#define OAK_COLORSERVICE_H #include #include @@ -37,64 +37,64 @@ class ColorManager : public QObject { public: ColorManager(Project *project); - void Init(); + void init(); - OCIO::ConstConfigRcPtr GetConfig() const; + ocio::ConstConfigRcPtr get_config() const; - static OCIO::ConstConfigRcPtr CreateConfigFromFile(const QString &filename); + static ocio::ConstConfigRcPtr create_config_from_file(const QString &filename); - QString GetConfigFilename() const; + QString get_config_filename() const; - static OCIO::ConstConfigRcPtr GetDefaultConfig(); + static ocio::ConstConfigRcPtr get_default_config(); - static void SetUpDefaultConfig(); + static void set_up_default_config(); - void SetConfigFilename(const QString &filename); + void set_config_filename(const QString &filename); - QStringList ListAvailableDisplays(); + QStringList list_available_displays(); - QString GetDefaultDisplay(); + QString get_default_display(); - QStringList ListAvailableViews(QString display); + QStringList list_available_views(QString display); - QString GetDefaultView(const QString &display); + QString get_default_view(const QString &display); - QStringList ListAvailableLooks(); + QStringList list_available_looks(); - QStringList ListAvailableColorspaces() const; + QStringList list_available_colorspaces() const; - QString GetDefaultInputColorSpace() const; + QString get_default_input_color_space() const; - void SetDefaultInputColorSpace(const QString &s); + void set_default_input_color_space(const QString &s); - QString GetReferenceColorSpace() const; + QString get_reference_color_space() const; - QString GetCompliantColorSpace(const QString &s); + QString get_compliant_color_space(const QString &s); - ColorTransform GetCompliantColorSpace(const ColorTransform &transform, + ColorTransform get_compliant_color_space(const ColorTransform &transform, bool force_display = false); - static QStringList ListAvailableColorspaces(OCIO::ConstConfigRcPtr config); + static QStringList list_available_colorspaces(ocio::ConstConfigRcPtr config); - void GetDefaultLumaCoefs(double *rgb) const; + void get_default_luma_coefs(double *rgb) const; Project *project() const; - void UpdateConfigFromFilename(); + void update_config_from_filename(); signals: - void ConfigChanged(const QString &s); + void config_changed(const QString &s); - void ReferenceSpaceChanged(const QString &s); + void reference_space_changed(const QString &s); - void DefaultInputChanged(const QString &s); + void default_input_changed(const QString &s); private: - OCIO::ConstConfigRcPtr config_; + ocio::ConstConfigRcPtr config_; - static OCIO::ConstConfigRcPtr default_config_; + static ocio::ConstConfigRcPtr default_config; }; } -#endif // COLORSERVICE_H +#endif // OAK_COLORSERVICE_H diff --git a/app/node/color/displaytransform/displaytransform.cpp b/app/node/color/displaytransform/displaytransform.cpp index 4b6055bc0..6767379d2 100644 --- a/app/node/color/displaytransform/displaytransform.cpp +++ b/app/node/color/displaytransform/displaytransform.cpp @@ -26,26 +26,26 @@ namespace olive { -const QString DisplayTransformNode::kDisplayInput = +const QString DisplayTransformNode::k_display_input = QStringLiteral("display_in"); -const QString DisplayTransformNode::kViewInput = QStringLiteral("view_in"); -const QString DisplayTransformNode::kDirectionInput = QStringLiteral("dir_in"); +const QString DisplayTransformNode::k_view_input = QStringLiteral("view_in"); +const QString DisplayTransformNode::k_direction_input = QStringLiteral("dir_in"); #define super OCIOBaseNode DisplayTransformNode::DisplayTransformNode() { - AddInput(kDisplayInput, NodeValue::kCombo, 0, - InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); + add_input(k_display_input, NodeValue::k_combo, 0, + InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable)); - AddInput(kViewInput, NodeValue::kCombo, 0, - InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); + add_input(k_view_input, NodeValue::k_combo, 0, + InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable)); - AddInput(kDirectionInput, NodeValue::kCombo, 0, - InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); + add_input(k_direction_input, NodeValue::k_combo, 0, + InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable)); } -QString DisplayTransformNode::Name() const +QString DisplayTransformNode::name() const { return tr("Display Transform"); } @@ -55,58 +55,58 @@ QString DisplayTransformNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.displaytransform"); } -QVector DisplayTransformNode::Category() const +QVector DisplayTransformNode::category() const { - return { kCategoryColor }; + return { k_category_color }; } -QString DisplayTransformNode::Description() const +QString DisplayTransformNode::description() const { return tr("Converts an image to or from a display color space."); } -void DisplayTransformNode::Retranslate() +void DisplayTransformNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kDisplayInput, tr("Display")); - SetInputName(kViewInput, tr("View")); - SetInputName(kDirectionInput, tr("Direction")); - SetComboBoxStrings(kDirectionInput, { tr("Forward"), tr("Inverse") }); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_display_input, tr("Display")); + set_input_name(k_view_input, tr("View")); + set_input_name(k_direction_input, tr("Direction")); + set_combo_box_strings(k_direction_input, { tr("Forward"), tr("Inverse") }); } void DisplayTransformNode::InputValueChangedEvent(const QString &input, int element) { Q_UNUSED(element); - if (input == kDisplayInput || input == kDirectionInput || - input == kViewInput) { - if (input == kDisplayInput) { - UpdateViews(); + if (input == k_display_input || input == k_direction_input || + input == k_view_input) { + if (input == k_display_input) { + update_views(); } - GenerateProcessor(); + generate_processor(); } } -QString DisplayTransformNode::GetDisplay() const +QString DisplayTransformNode::get_display() const { if (manager()) { - int index = GetStandardValue(kDisplayInput).toInt(); - if (index < manager()->ListAvailableDisplays().size()) { - return manager()->ListAvailableDisplays().at(index); + int index = get_standard_value(k_display_input).toInt(); + if (index < manager()->list_available_displays().size()) { + return manager()->list_available_displays().at(index); } } return QString(); } -QString DisplayTransformNode::GetView() const +QString DisplayTransformNode::get_view() const { if (manager()) { - QString display = GetDisplay(); + QString display = get_display(); if (!display.isEmpty()) { - int index = GetStandardValue(kViewInput).toInt(); - QStringList views = manager()->ListAvailableViews(display); + int index = get_standard_value(k_view_input).toInt(); + QStringList views = manager()->list_available_views(display); if (index < views.size()) { return views.at(index); } @@ -115,42 +115,42 @@ QString DisplayTransformNode::GetView() const return QString(); } -ColorProcessor::Direction DisplayTransformNode::GetDirection() const +ColorProcessor::Direction DisplayTransformNode::get_direction() const { return static_cast( - GetStandardValue(kDirectionInput).toInt()); + get_standard_value(k_direction_input).toInt()); ; } -void DisplayTransformNode::UpdateDisplays() +void DisplayTransformNode::update_displays() { if (manager()) { - SetComboBoxStrings(kDisplayInput, manager()->ListAvailableDisplays()); + set_combo_box_strings(k_display_input, manager()->list_available_displays()); } } -void DisplayTransformNode::UpdateViews() +void DisplayTransformNode::update_views() { if (manager()) { - SetComboBoxStrings(kViewInput, - manager()->ListAvailableViews(GetDisplay())); + set_combo_box_strings(k_view_input, + manager()->list_available_views(get_display())); } } -void DisplayTransformNode::ConfigChanged() +void DisplayTransformNode::config_changed() { - UpdateDisplays(); - UpdateViews(); - GenerateProcessor(); + update_displays(); + update_views(); + generate_processor(); } -void DisplayTransformNode::GenerateProcessor() +void DisplayTransformNode::generate_processor() { if (manager()) { - ColorTransform transform(GetDisplay(), GetView(), QString()); - set_processor(ColorProcessor::Create( - manager(), manager()->GetReferenceColorSpace(), transform, - GetDirection())); + ColorTransform transform(get_display(), get_view(), QString()); + set_processor(ColorProcessor::create( + manager(), manager()->get_reference_color_space(), transform, + get_direction())); } } diff --git a/app/node/color/displaytransform/displaytransform.h b/app/node/color/displaytransform/displaytransform.h index 7958fd907..b41cf73ee 100644 --- a/app/node/color/displaytransform/displaytransform.h +++ b/app/node/color/displaytransform/displaytransform.h @@ -19,8 +19,8 @@ ***/ -#ifndef DISPLAYTRANSFORMNODE_H -#define DISPLAYTRANSFORMNODE_H +#ifndef OAK_DISPLAYTRANSFORMNODE_H +#define OAK_DISPLAYTRANSFORMNODE_H #include "node/color/ociobase/ociobase.h" #include "render/colorprocessor.h" @@ -35,34 +35,34 @@ public: NODE_DEFAULT_FUNCTIONS(DisplayTransformNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual void InputValueChangedEvent(const QString &input, int element) override; - QString GetDisplay() const; - QString GetView() const; - ColorProcessor::Direction GetDirection() const; + QString get_display() const; + QString get_view() const; + ColorProcessor::Direction get_direction() const; - static const QString kDisplayInput; - static const QString kViewInput; - static const QString kDirectionInput; + static const QString k_display_input; + static const QString k_view_input; + static const QString k_direction_input; protected slots: - virtual void ConfigChanged() override; + virtual void config_changed() override; private: - void GenerateProcessor(); + void generate_processor(); - void UpdateDisplays(); + void update_displays(); - void UpdateViews(); + void update_views(); }; } // olive -#endif // DISPLAYTRANSFORMNODE_H +#endif // OAK_DISPLAYTRANSFORMNODE_H diff --git a/app/node/color/ociobase/ociobase.cpp b/app/node/color/ociobase/ociobase.cpp index 628ff5648..26f497cab 100644 --- a/app/node/color/ociobase/ociobase.cpp +++ b/app/node/color/ociobase/ociobase.cpp @@ -27,54 +27,54 @@ namespace olive { -const QString OCIOBaseNode::kTextureInput = QStringLiteral("tex_in"); +const QString OCIOBaseNode::k_texture_input = QStringLiteral("tex_in"); OCIOBaseNode::OCIOBaseNode() : manager_(nullptr) , processor_(nullptr) { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - SetEffectInput(kTextureInput); + set_effect_input(k_texture_input); - SetFlag(kVideoEffect); + set_flag(k_video_effect); } void OCIOBaseNode::AddedToGraphEvent(Project *p) { manager_ = p->color_manager(); - connect(manager_, &ColorManager::ConfigChanged, this, - &OCIOBaseNode::ConfigChanged); - ConfigChanged(); + connect(manager_, &ColorManager::config_changed, this, + &OCIOBaseNode::config_changed); + config_changed(); } void OCIOBaseNode::RemovedFromGraphEvent(Project *p) { if (manager_) { - disconnect(manager_, &ColorManager::ConfigChanged, this, - &OCIOBaseNode::ConfigChanged); + disconnect(manager_, &ColorManager::config_changed, this, + &OCIOBaseNode::config_changed); manager_ = nullptr; } } -void OCIOBaseNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void OCIOBaseNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - auto tex_met = value[kTextureInput]; - TexturePtr t = tex_met.toTexture(); + auto tex_met = value[k_texture_input]; + TexturePtr t = tex_met.to_texture(); if (t) { if (processor_) { ColorTransformJob job; - job.SetColorProcessor(processor_); - job.SetInputTexture(tex_met); + job.set_color_processor(processor_); + job.set_input_texture(tex_met); - table->Push(NodeValue::kTexture, t->toJob(job), this); + table->push(NodeValue::k_texture, t->to_job(job), this); } else { // Processor isn't ready yet (e.g. still being generated // asynchronously), pass the input through unchanged. - table->Push(NodeValue::kTexture, QVariant::fromValue(t), this); + table->push(NodeValue::k_texture, QVariant::fromValue(t), this); } } } diff --git a/app/node/color/ociobase/ociobase.h b/app/node/color/ociobase/ociobase.h index b95acdc80..9dfe1254a 100644 --- a/app/node/color/ociobase/ociobase.h +++ b/app/node/color/ociobase/ociobase.h @@ -19,8 +19,8 @@ ***/ -#ifndef OCIOBASENODE_H -#define OCIOBASENODE_H +#ifndef OAK_OCIOBASENODE_H +#define OAK_OCIOBASENODE_H #include "node/node.h" #include "render/job/colortransformjob.h" @@ -36,13 +36,13 @@ public: virtual void AddedToGraphEvent(Project *p) override; virtual void RemovedFromGraphEvent(Project *p) override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTextureInput; + static const QString k_texture_input; protected slots: - virtual void ConfigChanged() = 0; + virtual void config_changed() = 0; protected: ColorManager *manager() const @@ -67,4 +67,4 @@ private: } -#endif // OCIOBASENODE_H +#endif // OAK_OCIOBASENODE_H diff --git a/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.cpp b/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.cpp index da6bbcd81..92a9a5c93 100644 --- a/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.cpp +++ b/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.cpp @@ -31,74 +31,74 @@ namespace olive { -const QString OCIOGradingTransformLinearNode::kContrastInput = +const QString OCIOGradingTransformLinearNode::k_contrast_input = QStringLiteral("ocio_grading_primary_contrast"); -const QString OCIOGradingTransformLinearNode::kOffsetInput = +const QString OCIOGradingTransformLinearNode::k_offset_input = QStringLiteral("ocio_grading_primary_offset"); -const QString OCIOGradingTransformLinearNode::kExposureInput = +const QString OCIOGradingTransformLinearNode::k_exposure_input = QStringLiteral("ocio_grading_primary_exposure"); -const QString OCIOGradingTransformLinearNode::kSaturationInput = +const QString OCIOGradingTransformLinearNode::k_saturation_input = QStringLiteral("ocio_grading_primary_saturation"); -const QString OCIOGradingTransformLinearNode::kPivotInput = +const QString OCIOGradingTransformLinearNode::k_pivot_input = QStringLiteral("ocio_grading_primary_pivot"); -const QString OCIOGradingTransformLinearNode::kClampBlackEnableInput = +const QString OCIOGradingTransformLinearNode::k_clamp_black_enable_input = QStringLiteral("clamp_black_enable_in"); -const QString OCIOGradingTransformLinearNode::kClampBlackInput = +const QString OCIOGradingTransformLinearNode::k_clamp_black_input = QStringLiteral("ocio_grading_primary_clampBlack"); -const QString OCIOGradingTransformLinearNode::kClampWhiteEnableInput = +const QString OCIOGradingTransformLinearNode::k_clamp_white_enable_input = QStringLiteral("clamp_white_enable_in"); -const QString OCIOGradingTransformLinearNode::kClampWhiteInput = +const QString OCIOGradingTransformLinearNode::k_clamp_white_input = QStringLiteral("ocio_grading_primary_clampWhite"); #define super OCIOBaseNode OCIOGradingTransformLinearNode::OCIOGradingTransformLinearNode() { - AddInput(kContrastInput, NodeValue::kVec4, QVector4D{ 1.0, 1.0, 1.0, 1.0 }); - // Minimum based on OCIO::GradingPrimary::validate - SetInputProperty(kContrastInput, QStringLiteral("min"), + add_input(k_contrast_input, NodeValue::k_vec4, QVector4D{ 1.0, 1.0, 1.0, 1.0 }); + // Minimum based on ocio::GradingPrimary::validate + set_input_property(k_contrast_input, QStringLiteral("min"), QVector4D{ 0.01f, 0.01f, 0.01f, 0.01f }); - SetInputProperty(kContrastInput, QStringLiteral("base"), 0.01); - SetVec4InputColors(kContrastInput); + set_input_property(k_contrast_input, QStringLiteral("base"), 0.01); + set_vec4_input_colors(k_contrast_input); - AddInput(kOffsetInput, NodeValue::kVec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 }); - SetInputProperty(kOffsetInput, QStringLiteral("base"), 0.01); - SetVec4InputColors(kOffsetInput); + add_input(k_offset_input, NodeValue::k_vec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 }); + set_input_property(k_offset_input, QStringLiteral("base"), 0.01); + set_vec4_input_colors(k_offset_input); - AddInput(kExposureInput, NodeValue::kVec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 }); - SetInputProperty(kExposureInput, QStringLiteral("base"), 0.01); - SetVec4InputColors(kExposureInput); + add_input(k_exposure_input, NodeValue::k_vec4, QVector4D{ 0.0, 0.0, 0.0, 0.0 }); + set_input_property(k_exposure_input, QStringLiteral("base"), 0.01); + set_vec4_input_colors(k_exposure_input); - AddInput(kSaturationInput, NodeValue::kFloat, 1.0); - SetInputProperty(kSaturationInput, QStringLiteral("view"), - FloatSlider::kPercentage); - SetInputProperty(kSaturationInput, QStringLiteral("min"), 0.0); + add_input(k_saturation_input, NodeValue::k_float, 1.0); + set_input_property(k_saturation_input, QStringLiteral("view"), + FloatSlider::k_percentage); + set_input_property(k_saturation_input, QStringLiteral("min"), 0.0); - AddInput(kPivotInput, NodeValue::kFloat, - 0.18); // Default listed in OCIO::GradingPrimary - SetInputProperty(kPivotInput, QStringLiteral("base"), 0.01); + add_input(k_pivot_input, NodeValue::k_float, + 0.18); // Default listed in ocio::GradingPrimary + set_input_property(k_pivot_input, QStringLiteral("base"), 0.01); - AddInput(kClampBlackEnableInput, NodeValue::kBoolean, false); + add_input(k_clamp_black_enable_input, NodeValue::k_boolean, false); - AddInput(kClampBlackInput, NodeValue::kFloat, 0.0); - SetInputProperty(kClampBlackInput, QStringLiteral("enabled"), - GetStandardValue(kClampBlackEnableInput).toBool()); - SetInputProperty(kClampBlackInput, QStringLiteral("base"), 0.01); + add_input(k_clamp_black_input, NodeValue::k_float, 0.0); + set_input_property(k_clamp_black_input, QStringLiteral("enabled"), + get_standard_value(k_clamp_black_enable_input).toBool()); + set_input_property(k_clamp_black_input, QStringLiteral("base"), 0.01); - AddInput(kClampWhiteEnableInput, NodeValue::kBoolean, false); + add_input(k_clamp_white_enable_input, NodeValue::k_boolean, false); - AddInput(kClampWhiteInput, NodeValue::kFloat, 1.0); - SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"), - GetStandardValue(kClampWhiteEnableInput).toBool()); - SetInputProperty(kClampWhiteInput, QStringLiteral("base"), 0.01); + add_input(k_clamp_white_input, NodeValue::k_float, 1.0); + set_input_property(k_clamp_white_input, QStringLiteral("enabled"), + get_standard_value(k_clamp_white_enable_input).toBool()); + set_input_property(k_clamp_white_input, QStringLiteral("base"), 0.01); // Constrain the white clamp minimum to just above the (static) black clamp - // as per OCIO::GradingPrimary::validate. When the black clamp is keyframed + // as per ocio::GradingPrimary::validate. When the black clamp is keyframed // or connected, Value() enforces the invariant per frame instead. - UpdateClampWhiteMinimum(); + update_clamp_white_minimum(); } -QString OCIOGradingTransformLinearNode::Name() const +QString OCIOGradingTransformLinearNode::name() const { return tr("OCIO Color Grading (Linear)"); } @@ -109,32 +109,32 @@ QString OCIOGradingTransformLinearNode::id() const "org.olivevideoeditor.Olive.ociogradingtransformlinear"); } -QVector OCIOGradingTransformLinearNode::Category() const +QVector OCIOGradingTransformLinearNode::category() const { - return { kCategoryColor }; + return { k_category_color }; } -QString OCIOGradingTransformLinearNode::Description() const +QString OCIOGradingTransformLinearNode::description() const { return tr("Simple linear color grading using OpenColorIO."); } -void OCIOGradingTransformLinearNode::Retranslate() +void OCIOGradingTransformLinearNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kContrastInput, tr("Contrast")); - SetInputName(kOffsetInput, tr("Offset")); - SetInputName(kExposureInput, tr("Exposure")); - SetInputProperty(kExposureInput, QStringLiteral("tooltip"), + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_contrast_input, tr("Contrast")); + set_input_name(k_offset_input, tr("Offset")); + set_input_name(k_exposure_input, tr("Exposure")); + set_input_property(k_exposure_input, QStringLiteral("tooltip"), tr("Exposure increments in stops.")); - SetInputName(kSaturationInput, tr("Saturation")); - SetInputName(kPivotInput, tr("Pivot")); - SetInputName(kClampBlackEnableInput, tr("Enable Black Clamp")); - SetInputName(kClampBlackInput, tr("Black Clamp")); - SetInputName(kClampWhiteEnableInput, tr("Enable White Clamp")); - SetInputName(kClampWhiteInput, tr("White Clamp")); + set_input_name(k_saturation_input, tr("Saturation")); + set_input_name(k_pivot_input, tr("Pivot")); + set_input_name(k_clamp_black_enable_input, tr("Enable Black Clamp")); + set_input_name(k_clamp_black_input, tr("Black Clamp")); + set_input_name(k_clamp_white_enable_input, tr("Enable White Clamp")); + set_input_name(k_clamp_white_input, tr("White Clamp")); } void OCIOGradingTransformLinearNode::InputValueChangedEvent( @@ -142,19 +142,19 @@ void OCIOGradingTransformLinearNode::InputValueChangedEvent( { Q_UNUSED(element); - if (input == kClampWhiteEnableInput) { - SetInputProperty(kClampWhiteInput, QStringLiteral("enabled"), - GetStandardValue(kClampWhiteEnableInput).toBool()); - } else if (input == kClampBlackEnableInput) { - SetInputProperty(kClampBlackInput, QStringLiteral("enabled"), - GetStandardValue(kClampBlackEnableInput).toBool()); - } else if (input == kClampBlackInput) { + if (input == k_clamp_white_enable_input) { + set_input_property(k_clamp_white_input, QStringLiteral("enabled"), + get_standard_value(k_clamp_white_enable_input).toBool()); + } else if (input == k_clamp_black_enable_input) { + set_input_property(k_clamp_black_input, QStringLiteral("enabled"), + get_standard_value(k_clamp_black_enable_input).toBool()); + } else if (input == k_clamp_black_input) { // Ensure the white clamp is always greater than the black clamp as per - // OCIO::GradingPrimary::validate - UpdateClampWhiteMinimum(); + // ocio::GradingPrimary::validate + update_clamp_white_minimum(); } - GenerateProcessor(); + generate_processor(); } void OCIOGradingTransformLinearNode::InputConnectedEvent(const QString &input, @@ -162,8 +162,8 @@ void OCIOGradingTransformLinearNode::InputConnectedEvent(const QString &input, { super::InputConnectedEvent(input, element, output); - if (input == kClampBlackInput) { - UpdateClampWhiteMinimum(); + if (input == k_clamp_black_input) { + update_clamp_white_minimum(); } } @@ -173,139 +173,139 @@ void OCIOGradingTransformLinearNode::InputDisconnectedEvent(const QString &input { super::InputDisconnectedEvent(input, element, output); - if (input == kClampBlackInput) { - UpdateClampWhiteMinimum(); + if (input == k_clamp_black_input) { + update_clamp_white_minimum(); } } -void OCIOGradingTransformLinearNode::UpdateClampWhiteMinimum() +void OCIOGradingTransformLinearNode::update_clamp_white_minimum() { // A static UI minimum cannot follow an animated black clamp; for keyframed // or connected values the white>black invariant is enforced per frame in // Value() instead - if (IsInputKeyframing(kClampBlackInput) || - IsInputConnected(kClampBlackInput)) { + if (is_input_keyframing(k_clamp_black_input) || + is_input_connected(k_clamp_black_input)) { return; } - SetInputProperty(kClampWhiteInput, QStringLiteral("min"), - GetStandardValue(kClampBlackInput).toDouble() + 0.000001); + set_input_property(k_clamp_white_input, QStringLiteral("min"), + get_standard_value(k_clamp_black_input).toDouble() + 0.000001); } -void OCIOGradingTransformLinearNode::GenerateProcessor() +void OCIOGradingTransformLinearNode::generate_processor() { if (manager()) { - OCIO::GradingPrimaryTransformRcPtr gp = - OCIO::GradingPrimaryTransform::Create(OCIO::GRADING_LIN); + ocio::GradingPrimaryTransformRcPtr gp = + ocio::GradingPrimaryTransform::Create(ocio::GRADING_LIN); gp->makeDynamic(); - gp->setDirection(OCIO::TransformDirection::TRANSFORM_DIR_FORWARD); + gp->setDirection(ocio::TransformDirection::TRANSFORM_DIR_FORWARD); try { - set_processor(ColorProcessor::Create( - manager()->GetConfig()->getProcessor(gp))); - } catch (const OCIO::Exception &e) { + set_processor(ColorProcessor::create( + manager()->get_config()->getProcessor(gp))); + } catch (const ocio::Exception &e) { std::cerr << std::endl << e.what() << std::endl; } } } -void OCIOGradingTransformLinearNode::Value(const NodeValueRow &value, +void OCIOGradingTransformLinearNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { if (processor()) { ColorTransformJob job(value); - job.SetColorProcessor(processor()); - job.SetInputTexture(value[kTextureInput]); + job.set_color_processor(processor()); + job.set_input_texture(value[k_texture_input]); - const int MASTER_CHANNEL = 0; - const int RED_CHANNEL = 1; - const int GREEN_CHANNEL = 2; - const int BLUE_CHANNEL = 3; + const int master_channel = 0; + const int red_channel = 1; + const int green_channel = 2; + const int blue_channel = 3; // Oddly, OCIO uses RGBMs when setting the GradingPrimary on the CPU, but uses vec3s on the GPU. // Even more oddly, the conversion from RGBM to vec3 does not appear to have a public API. // Therefore, this code has been duplicated from OCIO here: // https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/3abbe5b20521169580fcfe3692aca81859859953/src/OpenColorIO/ops/gradingprimary/GradingPrimary.cpp#L157 - QVector4D offset = value[kOffsetInput].toVec4(); - offset[RED_CHANNEL] += offset[MASTER_CHANNEL]; - offset[GREEN_CHANNEL] += offset[MASTER_CHANNEL]; - offset[BLUE_CHANNEL] += offset[MASTER_CHANNEL]; - job.Insert(kOffsetInput, - NodeValue(NodeValue::kVec3, - QVector3D(offset[RED_CHANNEL], - offset[GREEN_CHANNEL], - offset[BLUE_CHANNEL]))); + QVector4D offset = value[k_offset_input].to_vec4(); + offset[red_channel] += offset[master_channel]; + offset[green_channel] += offset[master_channel]; + offset[blue_channel] += offset[master_channel]; + job.insert(k_offset_input, + NodeValue(NodeValue::k_vec3, + QVector3D(offset[red_channel], + offset[green_channel], + offset[blue_channel]))); - QVector4D exposure = value[kExposureInput].toVec4(); - exposure[RED_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] + - exposure[RED_CHANNEL]); - exposure[GREEN_CHANNEL] = std::pow( - 2.0f, exposure[MASTER_CHANNEL] + exposure[GREEN_CHANNEL]); - exposure[BLUE_CHANNEL] = std::pow(2.0f, exposure[MASTER_CHANNEL] + - exposure[BLUE_CHANNEL]); - job.Insert(kExposureInput, - NodeValue(NodeValue::kVec3, - QVector3D(exposure[RED_CHANNEL], - exposure[GREEN_CHANNEL], - exposure[BLUE_CHANNEL]))); + QVector4D exposure = value[k_exposure_input].to_vec4(); + exposure[red_channel] = std::pow(2.0f, exposure[master_channel] + + exposure[red_channel]); + exposure[green_channel] = std::pow( + 2.0f, exposure[master_channel] + exposure[green_channel]); + exposure[blue_channel] = std::pow(2.0f, exposure[master_channel] + + exposure[blue_channel]); + job.insert(k_exposure_input, + NodeValue(NodeValue::k_vec3, + QVector3D(exposure[red_channel], + exposure[green_channel], + exposure[blue_channel]))); - QVector4D contrast = value[kContrastInput].toVec4(); - contrast[RED_CHANNEL] *= contrast[MASTER_CHANNEL]; - contrast[GREEN_CHANNEL] *= contrast[MASTER_CHANNEL]; - contrast[BLUE_CHANNEL] *= contrast[MASTER_CHANNEL]; - job.Insert(kContrastInput, - NodeValue(NodeValue::kVec3, - QVector3D(contrast[RED_CHANNEL], - contrast[GREEN_CHANNEL], - contrast[BLUE_CHANNEL]))); + QVector4D contrast = value[k_contrast_input].to_vec4(); + contrast[red_channel] *= contrast[master_channel]; + contrast[green_channel] *= contrast[master_channel]; + contrast[blue_channel] *= contrast[master_channel]; + job.insert(k_contrast_input, + NodeValue(NodeValue::k_vec3, + QVector3D(contrast[red_channel], + contrast[green_channel], + contrast[blue_channel]))); - if (!value[kClampBlackEnableInput].toBool()) { - job.Insert(kClampBlackInput, - NodeValue(NodeValue::kFloat, - OCIO::GradingPrimary::NoClampBlack())); + if (!value[k_clamp_black_enable_input].to_bool()) { + job.insert(k_clamp_black_input, + NodeValue(NodeValue::k_float, + ocio::GradingPrimary::NoClampBlack())); } - if (!value[kClampWhiteEnableInput].toBool()) { - job.Insert(kClampWhiteInput, - NodeValue(NodeValue::kFloat, - OCIO::GradingPrimary::NoClampWhite())); + if (!value[k_clamp_white_enable_input].to_bool()) { + job.insert(k_clamp_white_input, + NodeValue(NodeValue::k_float, + ocio::GradingPrimary::NoClampWhite())); } - if (value[kClampBlackEnableInput].toBool() && - value[kClampWhiteEnableInput].toBool()) { - // OCIO::GradingPrimary::validate requires the white clamp to be + if (value[k_clamp_black_enable_input].to_bool() && + value[k_clamp_white_enable_input].to_bool()) { + // ocio::GradingPrimary::validate requires the white clamp to be // greater than the black clamp. Keyframed or connected values // can violate this at arbitrary times, so enforce the invariant // per frame here. - const double clamp_black = value[kClampBlackInput].toDouble(); - const double clamp_white = value[kClampWhiteInput].toDouble(); + const double clamp_black = value[k_clamp_black_input].to_double(); + const double clamp_white = value[k_clamp_white_input].to_double(); if (clamp_white <= clamp_black) { - job.Insert(kClampWhiteInput, - NodeValue(NodeValue::kFloat, + job.insert(k_clamp_white_input, + NodeValue(NodeValue::k_float, clamp_black + 0.000001)); } } - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } } } -void OCIOGradingTransformLinearNode::ConfigChanged() +void OCIOGradingTransformLinearNode::config_changed() { - GenerateProcessor(); + generate_processor(); } -void OCIOGradingTransformLinearNode::SetVec4InputColors(const QString &input) +void OCIOGradingTransformLinearNode::set_vec4_input_colors(const QString &input) { - SetInputProperty(input, QStringLiteral("color0"), + set_input_property(input, QStringLiteral("color0"), QColor(192, 192, 192).name()); - SetInputProperty(input, QStringLiteral("color1"), QColor(255, 0, 0).name()); - SetInputProperty(input, QStringLiteral("color2"), QColor(0, 255, 0).name()); - SetInputProperty(input, QStringLiteral("color3"), QColor(0, 0, 255).name()); + set_input_property(input, QStringLiteral("color1"), QColor(255, 0, 0).name()); + set_input_property(input, QStringLiteral("color2"), QColor(0, 255, 0).name()); + set_input_property(input, QStringLiteral("color3"), QColor(0, 0, 255).name()); } } diff --git a/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.h b/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.h index 4e201dbe6..afc6d3757 100644 --- a/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.h +++ b/app/node/color/ociogradingtransformlinear/ociogradingtransformlinear.h @@ -19,8 +19,8 @@ ***/ -#ifndef OCIOGRADINGTRANSFORMLINEARNODE_H -#define OCIOGRADINGTRANSFORMLINEARNODE_H +#ifndef OAK_OCIOGRADINGTRANSFORMLINEARNODE_H +#define OAK_OCIOGRADINGTRANSFORMLINEARNODE_H #include "node/color/ociobase/ociobase.h" #include "render/colorprocessor.h" @@ -35,48 +35,48 @@ public: NODE_DEFAULT_FUNCTIONS(OCIOGradingTransformLinearNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual void InputValueChangedEvent(const QString &input, int element) override; virtual void InputConnectedEvent(const QString &input, int element, Node *output) override; virtual void InputDisconnectedEvent(const QString &input, int element, Node *output) override; - void GenerateProcessor(); + void generate_processor(); - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kContrastInput; - static const QString kOffsetInput; - static const QString kExposureInput; - static const QString kSaturationInput; - static const QString kPivotInput; - static const QString kClampBlackEnableInput; - static const QString kClampBlackInput; - static const QString kClampWhiteEnableInput; - static const QString kClampWhiteInput; + static const QString k_contrast_input; + static const QString k_offset_input; + static const QString k_exposure_input; + static const QString k_saturation_input; + static const QString k_pivot_input; + static const QString k_clamp_black_enable_input; + static const QString k_clamp_black_input; + static const QString k_clamp_white_enable_input; + static const QString k_clamp_white_input; protected slots: - virtual void ConfigChanged() override; + virtual void config_changed() override; private: - void SetVec4InputColors(const QString &input); + void set_vec4_input_colors(const QString &input); /** * @brief Constrains the white clamp UI minimum to just above the black - * clamp, as required by OCIO::GradingPrimary::validate + * clamp, as required by ocio::GradingPrimary::validate * * Only applies while the black clamp is a static value; when it is * keyframed or connected the invariant is enforced per frame in Value() * instead. */ - void UpdateClampWhiteMinimum(); + void update_clamp_white_minimum(); }; } // olive diff --git a/app/node/color/ociolut/ociolut.cpp b/app/node/color/ociolut/ociolut.cpp index 48fe3e76b..a2b14d74a 100644 --- a/app/node/color/ociolut/ociolut.cpp +++ b/app/node/color/ociolut/ociolut.cpp @@ -34,23 +34,23 @@ namespace olive { -const QString OCIOLutNode::kFileInput = QStringLiteral("lut_file_in"); -const QString OCIOLutNode::kDirectionInput = QStringLiteral("lut_dir_in"); +const QString OCIOLutNode::k_file_input = QStringLiteral("lut_file_in"); +const QString OCIOLutNode::k_direction_input = QStringLiteral("lut_dir_in"); #define super OCIOBaseNode namespace { -bool IsMainProcess() +bool is_main_process() { return qobject_cast(QCoreApplication::instance()) != nullptr; } -int ReadDirectionInput(const Node *node) +int read_direction_input(const Node *node) { - QVariant v = node->GetStandardValue(OCIOLutNode::kDirectionInput); + QVariant v = node->get_standard_value(OCIOLutNode::k_direction_input); bool ok = false; int direction = v.toInt(&ok); @@ -75,23 +75,23 @@ int ReadDirectionInput(const Node *node) OCIOLutNode::OCIOLutNode() { - AddInput(kFileInput, NodeValue::kFile, QString(), - InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); - SetInputProperty( - kFileInput, QStringLiteral("filter"), + add_input(k_file_input, NodeValue::k_file, QString(), + InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable)); + set_input_property( + k_file_input, QStringLiteral("filter"), tr("LUT Files (*.cube *.3dl);;Cube LUT (*.cube);;3DL LUT (*.3dl);;All Files (*)")); - SetInputProperty(kFileInput, QStringLiteral("placeholder"), + set_input_property(k_file_input, QStringLiteral("placeholder"), tr("Select a .cube or .3dl LUT file")); // Allow the UI to offer the global LUT library for this input - SetInputProperty(kFileInput, QStringLiteral("lut_library"), true); + set_input_property(k_file_input, QStringLiteral("lut_library"), true); - AddInput(kDirectionInput, NodeValue::kCombo, 0, - InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); + add_input(k_direction_input, NodeValue::k_combo, 0, + InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable)); qRegisterMetaType(); } -QString OCIOLutNode::Name() const +QString OCIOLutNode::name() const { return tr("OCIO LUT"); } @@ -101,37 +101,37 @@ QString OCIOLutNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.ociolut"); } -QVector OCIOLutNode::Category() const +QVector OCIOLutNode::category() const { - return { kCategoryColor }; + return { k_category_color }; } -QString OCIOLutNode::Description() const +QString OCIOLutNode::description() const { return tr("Applies a LUT file through OpenColorIO."); } -void OCIOLutNode::Retranslate() +void OCIOLutNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kFileInput, tr("LUT File")); - SetInputName(kDirectionInput, tr("Direction")); - SetComboBoxStrings(kDirectionInput, { tr("Forward"), tr("Inverse") }); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_file_input, tr("LUT File")); + set_input_name(k_direction_input, tr("Direction")); + set_combo_box_strings(k_direction_input, { tr("Forward"), tr("Inverse") }); } void OCIOLutNode::InputValueChangedEvent(const QString &input, int element) { Q_UNUSED(element) - if (input == kFileInput || input == kDirectionInput) { + if (input == k_file_input || input == k_direction_input) { // In the worker process, creating the OCIO processor can be slow and we // are often called from LoadGraph while the main process is blocked // waiting for a response. Defer generation to Value() time so the worker // can ack the graph load immediately. - if (IsMainProcess()) { - GenerateProcessor(); + if (is_main_process()) { + generate_processor(); } else { QMutexLocker locker(&gen_mutex_); processor_dirty_ = true; @@ -139,60 +139,60 @@ void OCIOLutNode::InputValueChangedEvent(const QString &input, int element) } } -void OCIOLutNode::ConfigChanged() +void OCIOLutNode::config_changed() { - if (IsMainProcess()) { - GenerateProcessor(); + if (is_main_process()) { + generate_processor(); } else { QMutexLocker locker(&gen_mutex_); processor_dirty_ = true; } } -void OCIOLutNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void OCIOLutNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // Ensure the processor is up-to-date before the base class emits the color // transform job. This is especially important in the render worker, where // processor creation is deferred until the first render. - EnsureProcessor(); + ensure_processor(); - super::Value(value, globals, table); + super::value(value, globals, table); } -void OCIOLutNode::GenerateProcessor() +void OCIOLutNode::generate_processor() { - EnsureProcessor(); + ensure_processor(); // The processor has changed. In the main GUI process, refresh the viewer by // invalidating the cache and cancelling background cache jobs. // Invalidating first ensures any in-flight renders that complete afterwards // won't write stale frames back. The worker process uses QGuiApplication and // has no RenderManager/PreviewAutoCacher, so skip this step to avoid crashing. - if (IsMainProcess()) { - InvalidateAll(kTextureInput); + if (is_main_process()) { + invalidate_all(k_texture_input); if (RenderManager *rm = RenderManager::instance()) { - if (PreviewAutoCacher *cacher = rm->GetCacher()) { - cacher->CancelVideoTasks(false); + if (PreviewAutoCacher *cacher = rm->get_cacher()) { + cacher->cancel_video_tasks(false); } } } } -void OCIOLutNode::EnsureProcessor() const +void OCIOLutNode::ensure_processor() const { QMutexLocker locker(&gen_mutex_); if (!processor_dirty_ && last_processor_ && - GetStandardValue(kFileInput).toString() == last_path_ && - ReadDirectionInput(this) == last_direction_) { + get_standard_value(k_file_input).toString() == last_path_ && + read_direction_input(this) == last_direction_) { return; } - CreateProcessorFromInputs(); + create_processor_from_inputs(); } -void OCIOLutNode::SetLastError(const QString &error) const +void OCIOLutNode::set_last_error(const QString &error) const { if (last_error_ == error) { return; @@ -202,12 +202,12 @@ void OCIOLutNode::SetLastError(const QString &error) const // Make the error visible to the user instead of failing silently, but only // from the main process (the render worker has no status bar) - if (!error.isEmpty() && IsMainProcess() && Core::instance()) { - Core::instance()->ShowStatusBarMessage(error, 10000); + if (!error.isEmpty() && is_main_process() && Core::instance()) { + Core::instance()->show_status_bar_message(error, 10000); } } -bool OCIOLutNode::CreateProcessorFromInputs() const +bool OCIOLutNode::create_processor_from_inputs() const { if (!manager()) { const_cast(this)->set_processor(nullptr); @@ -218,8 +218,8 @@ bool OCIOLutNode::CreateProcessorFromInputs() const return false; } - const QString path = GetStandardValue(kFileInput).toString(); - const int direction = ReadDirectionInput(this); + const QString path = get_standard_value(k_file_input).toString(); + const int direction = read_direction_input(this); if (path.isEmpty()) { const_cast(this)->set_processor(nullptr); @@ -227,7 +227,7 @@ bool OCIOLutNode::CreateProcessorFromInputs() const last_path_.clear(); last_direction_ = -1; processor_dirty_ = false; - SetLastError(QString()); + set_last_error(QString()); return false; } @@ -245,19 +245,19 @@ bool OCIOLutNode::CreateProcessorFromInputs() const last_path_.clear(); last_direction_ = -1; processor_dirty_ = false; - SetLastError(tr("OCIO LUT: file does not exist: %1").arg(path)); + set_last_error(tr("OCIO LUT: file does not exist: %1").arg(path)); return false; } const QString suffix = info.suffix(); - if (!LUTLibrary::IsSupportedExtension(suffix)) { + if (!LUTLibrary::is_supported_extension(suffix)) { qWarning() << "Unsupported OCIO LUT file extension:" << path; const_cast(this)->set_processor(nullptr); last_processor_.reset(); last_path_.clear(); last_direction_ = -1; processor_dirty_ = false; - SetLastError( + set_last_error( tr("OCIO LUT: unsupported LUT file extension (expected .cube or " ".3dl): %1") .arg(path)); @@ -267,29 +267,29 @@ bool OCIOLutNode::CreateProcessorFromInputs() const ColorProcessorPtr processor; try { const bool forward = static_cast( - direction) == ColorProcessor::kNormal; + direction) == ColorProcessor::k_normal; qDebug() << "OCIOLutNode: creating processor for" << path << "direction=" << direction << "ocio_dir=" << (forward ? "FORWARD" : "INVERSE") - << "process=" << (IsMainProcess() ? "main" : "worker"); + << "process=" << (is_main_process() ? "main" : "worker"); - OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create(); + ocio::FileTransformRcPtr transform = ocio::FileTransform::Create(); transform->setSrc(path.toUtf8().constData()); - transform->setInterpolation(OCIO::INTERP_LINEAR); - transform->setDirection(forward ? OCIO::TRANSFORM_DIR_FORWARD : - OCIO::TRANSFORM_DIR_INVERSE); + transform->setInterpolation(ocio::INTERP_LINEAR); + transform->setDirection(forward ? ocio::TRANSFORM_DIR_FORWARD : + ocio::TRANSFORM_DIR_INVERSE); - processor = ColorProcessor::Create( - manager()->GetConfig()->getProcessor(transform)); + processor = ColorProcessor::create( + manager()->get_config()->getProcessor(transform)); } catch (const std::exception &e) { qWarning() << "OCIO LUT processor error:" << e.what(); processor = nullptr; } if (!processor) { - SetLastError(tr("OCIO LUT: failed to load LUT file: %1").arg(path)); + set_last_error(tr("OCIO LUT: failed to load LUT file: %1").arg(path)); } else { - SetLastError(QString()); + set_last_error(QString()); } last_path_ = path; diff --git a/app/node/color/ociolut/ociolut.h b/app/node/color/ociolut/ociolut.h index 0f36620cb..dc734ac1d 100644 --- a/app/node/color/ociolut/ociolut.h +++ b/app/node/color/ociolut/ociolut.h @@ -18,8 +18,8 @@ ***/ -#ifndef OCIOLUTNODE_H -#define OCIOLUTNODE_H +#ifndef OAK_OCIOLUTNODE_H +#define OAK_OCIOLUTNODE_H #include @@ -36,19 +36,19 @@ public: NODE_DEFAULT_FUNCTIONS(OCIOLutNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual void InputValueChangedEvent(const QString &input, int element) override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kFileInput; - static const QString kDirectionInput; + static const QString k_file_input; + static const QString k_direction_input; /** * @brief Human-readable description of why no LUT processor is active @@ -63,14 +63,14 @@ public: } protected slots: - virtual void ConfigChanged() override; + virtual void config_changed() override; private: - void GenerateProcessor(); - void EnsureProcessor() const; - bool CreateProcessorFromInputs() const; + void generate_processor(); + void ensure_processor() const; + bool create_processor_from_inputs() const; - void SetLastError(const QString &error) const; + void set_last_error(const QString &error) const; mutable QMutex gen_mutex_; mutable bool processor_dirty_ = true; @@ -82,4 +82,4 @@ private: } // namespace olive -#endif // OCIOLUTNODE_H +#endif // OAK_OCIOLUTNODE_H diff --git a/app/node/color/threewaycolor/threewaycolor.cpp b/app/node/color/threewaycolor/threewaycolor.cpp index 676ddae18..e5201a703 100644 --- a/app/node/color/threewaycolor/threewaycolor.cpp +++ b/app/node/color/threewaycolor/threewaycolor.cpp @@ -31,92 +31,92 @@ namespace olive #define super Node -const QString ThreeWayColorNode::kTextureInput = QStringLiteral("tex_in"); -const QString ThreeWayColorNode::kShadowsColorInput = +const QString ThreeWayColorNode::k_texture_input = QStringLiteral("tex_in"); +const QString ThreeWayColorNode::k_shadows_color_input = QStringLiteral("shadows_color_in"); -const QString ThreeWayColorNode::kMidtonesColorInput = +const QString ThreeWayColorNode::k_midtones_color_input = QStringLiteral("midtones_color_in"); -const QString ThreeWayColorNode::kHighlightsColorInput = +const QString ThreeWayColorNode::k_highlights_color_input = QStringLiteral("highlights_color_in"); -const QString ThreeWayColorNode::kShadowsAmountInput = +const QString ThreeWayColorNode::k_shadows_amount_input = QStringLiteral("shadows_amount_in"); -const QString ThreeWayColorNode::kMidtonesAmountInput = +const QString ThreeWayColorNode::k_midtones_amount_input = QStringLiteral("midtones_amount_in"); -const QString ThreeWayColorNode::kHighlightsAmountInput = +const QString ThreeWayColorNode::k_highlights_amount_input = QStringLiteral("highlights_amount_in"); -const QString ThreeWayColorNode::kLumaCoefficientsInput = +const QString ThreeWayColorNode::k_luma_coefficients_input = QStringLiteral("luma_coefficients_in"); ThreeWayColorNode::ThreeWayColorNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); const QVariant neutral = QVariant::fromValue(Color(0.5, 0.5, 0.5, 1.0)); - AddInput(kShadowsColorInput, NodeValue::kColor, neutral); - AddInput(kMidtonesColorInput, NodeValue::kColor, neutral); - AddInput(kHighlightsColorInput, NodeValue::kColor, neutral); + add_input(k_shadows_color_input, NodeValue::k_color, neutral); + add_input(k_midtones_color_input, NodeValue::k_color, neutral); + add_input(k_highlights_color_input, NodeValue::k_color, neutral); - AddInput(kShadowsAmountInput, NodeValue::kFloat, 1.0); - AddInput(kMidtonesAmountInput, NodeValue::kFloat, 1.0); - AddInput(kHighlightsAmountInput, NodeValue::kFloat, 1.0); + add_input(k_shadows_amount_input, NodeValue::k_float, 1.0); + add_input(k_midtones_amount_input, NodeValue::k_float, 1.0); + add_input(k_highlights_amount_input, NodeValue::k_float, 1.0); const QString min = QStringLiteral("min"); const QString view = QStringLiteral("view"); - SetInputProperty(kShadowsAmountInput, min, 0.0); - SetInputProperty(kMidtonesAmountInput, min, 0.0); - SetInputProperty(kHighlightsAmountInput, min, 0.0); - SetInputProperty(kShadowsAmountInput, view, FloatSlider::kPercentage); - SetInputProperty(kMidtonesAmountInput, view, FloatSlider::kPercentage); - SetInputProperty(kHighlightsAmountInput, view, FloatSlider::kPercentage); + set_input_property(k_shadows_amount_input, min, 0.0); + set_input_property(k_midtones_amount_input, min, 0.0); + set_input_property(k_highlights_amount_input, min, 0.0); + set_input_property(k_shadows_amount_input, view, FloatSlider::k_percentage); + set_input_property(k_midtones_amount_input, view, FloatSlider::k_percentage); + set_input_property(k_highlights_amount_input, view, FloatSlider::k_percentage); - SetEffectInput(kTextureInput); - SetFlag(kVideoEffect); + set_effect_input(k_texture_input); + set_flag(k_video_effect); } -void ThreeWayColorNode::Retranslate() +void ThreeWayColorNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kShadowsColorInput, tr("Shadows")); - SetInputName(kMidtonesColorInput, tr("Midtones")); - SetInputName(kHighlightsColorInput, tr("Highlights")); - SetInputName(kShadowsAmountInput, tr("Shadows Amount")); - SetInputName(kMidtonesAmountInput, tr("Midtones Amount")); - SetInputName(kHighlightsAmountInput, tr("Highlights Amount")); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_shadows_color_input, tr("Shadows")); + set_input_name(k_midtones_color_input, tr("Midtones")); + set_input_name(k_highlights_color_input, tr("Highlights")); + set_input_name(k_shadows_amount_input, tr("Shadows Amount")); + set_input_name(k_midtones_amount_input, tr("Midtones Amount")); + set_input_name(k_highlights_amount_input, tr("Highlights Amount")); } -ShaderCode ThreeWayColorNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode ThreeWayColorNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/threewaycolor.frag")); + FileFunctions::read_file_as_string(":/shaders/threewaycolor.frag")); } -void ThreeWayColorNode::Value(const NodeValueRow &value, +void ThreeWayColorNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { Q_UNUSED(globals) - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { ShaderJob job(value); double luma_coeffs[3] = { 0.0, 0.0, 0.0 }; if (project() && project()->color_manager()) { - project()->color_manager()->GetDefaultLumaCoefs(luma_coeffs); + project()->color_manager()->get_default_luma_coefs(luma_coeffs); } else { luma_coeffs[0] = 0.2126; luma_coeffs[1] = 0.7152; luma_coeffs[2] = 0.0722; } - job.Insert(kLumaCoefficientsInput, - NodeValue(NodeValue::kVec3, + job.insert(k_luma_coefficients_input, + NodeValue(NodeValue::k_vec3, QVector3D(luma_coeffs[0], luma_coeffs[1], luma_coeffs[2]))); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } } diff --git a/app/node/color/threewaycolor/threewaycolor.h b/app/node/color/threewaycolor/threewaycolor.h index 33b34ab78..69e0e7ac4 100644 --- a/app/node/color/threewaycolor/threewaycolor.h +++ b/app/node/color/threewaycolor/threewaycolor.h @@ -19,8 +19,8 @@ ***/ -#ifndef THREEWAYCOLORNODE_H -#define THREEWAYCOLORNODE_H +#ifndef OAK_THREEWAYCOLORNODE_H +#define OAK_THREEWAYCOLORNODE_H #include "node/node.h" @@ -34,7 +34,7 @@ public: NODE_DEFAULT_FUNCTIONS(ThreeWayColorNode) - virtual QString Name() const override + virtual QString name() const override { return tr("Three-Way Color"); } @@ -44,34 +44,34 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.threewaycolor"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryColor }; + return { k_category_color }; } - virtual QString Description() const override + virtual QString description() const override { return tr("Adjusts shadows, midtones, and highlights separately."); } - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTextureInput; - static const QString kShadowsColorInput; - static const QString kMidtonesColorInput; - static const QString kHighlightsColorInput; - static const QString kShadowsAmountInput; - static const QString kMidtonesAmountInput; - static const QString kHighlightsAmountInput; - static const QString kLumaCoefficientsInput; + static const QString k_texture_input; + static const QString k_shadows_color_input; + static const QString k_midtones_color_input; + static const QString k_highlights_color_input; + static const QString k_shadows_amount_input; + static const QString k_midtones_amount_input; + static const QString k_highlights_amount_input; + static const QString k_luma_coefficients_input; }; } -#endif // THREEWAYCOLORNODE_H +#endif // OAK_THREEWAYCOLORNODE_H diff --git a/app/node/distort/cornerpin/cornerpindistortnode.cpp b/app/node/distort/cornerpin/cornerpindistortnode.cpp index d4d936e94..d725fced7 100644 --- a/app/node/distort/cornerpin/cornerpindistortnode.cpp +++ b/app/node/distort/cornerpin/cornerpindistortnode.cpp @@ -28,95 +28,95 @@ namespace olive { -const QString CornerPinDistortNode::kTextureInput = QStringLiteral("tex_in"); -const QString CornerPinDistortNode::kTopLeftInput = +const QString CornerPinDistortNode::k_texture_input = QStringLiteral("tex_in"); +const QString CornerPinDistortNode::k_top_left_input = QStringLiteral("top_left_in"); -const QString CornerPinDistortNode::kTopRightInput = +const QString CornerPinDistortNode::k_top_right_input = QStringLiteral("top_right_in"); -const QString CornerPinDistortNode::kBottomRightInput = +const QString CornerPinDistortNode::k_bottom_right_input = QStringLiteral("bottom_right_in"); -const QString CornerPinDistortNode::kBottomLeftInput = +const QString CornerPinDistortNode::k_bottom_left_input = QStringLiteral("bottom_left_in"); -const QString CornerPinDistortNode::kPerspectiveInput = +const QString CornerPinDistortNode::k_perspective_input = QStringLiteral("perspective_in"); #define super Node CornerPinDistortNode::CornerPinDistortNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); - AddInput(kPerspectiveInput, NodeValue::kBoolean, true); - AddInput(kTopLeftInput, NodeValue::kVec2, QVector2D(0.0, 0.0)); - AddInput(kTopRightInput, NodeValue::kVec2, QVector2D(0.0, 0.0)); - AddInput(kBottomRightInput, NodeValue::kVec2, QVector2D(0.0, 0.0)); - AddInput(kBottomLeftInput, NodeValue::kVec2, QVector2D(0.0, 0.0)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); + add_input(k_perspective_input, NodeValue::k_boolean, true); + add_input(k_top_left_input, NodeValue::k_vec2, QVector2D(0.0, 0.0)); + add_input(k_top_right_input, NodeValue::k_vec2, QVector2D(0.0, 0.0)); + add_input(k_bottom_right_input, NodeValue::k_vec2, QVector2D(0.0, 0.0)); + add_input(k_bottom_left_input, NodeValue::k_vec2, QVector2D(0.0, 0.0)); // Initiate gizmos - gizmo_whole_rect_ = AddDraggableGizmo(); - gizmo_resize_handle_[0] = AddDraggableGizmo( - { NodeKeyframeTrackReference(NodeInput(this, kTopLeftInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kTopLeftInput), 1) }); - gizmo_resize_handle_[1] = AddDraggableGizmo( - { NodeKeyframeTrackReference(NodeInput(this, kTopRightInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kTopRightInput), 1) }); - gizmo_resize_handle_[2] = AddDraggableGizmo( - { NodeKeyframeTrackReference(NodeInput(this, kBottomRightInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kBottomRightInput), 1) }); - gizmo_resize_handle_[3] = AddDraggableGizmo( - { NodeKeyframeTrackReference(NodeInput(this, kBottomLeftInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kBottomLeftInput), 1) }); + gizmo_whole_rect_ = add_draggable_gizmo(); + gizmo_resize_handle_[0] = add_draggable_gizmo( + { NodeKeyframeTrackReference(NodeInput(this, k_top_left_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_top_left_input), 1) }); + gizmo_resize_handle_[1] = add_draggable_gizmo( + { NodeKeyframeTrackReference(NodeInput(this, k_top_right_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_top_right_input), 1) }); + gizmo_resize_handle_[2] = add_draggable_gizmo( + { NodeKeyframeTrackReference(NodeInput(this, k_bottom_right_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_bottom_right_input), 1) }); + gizmo_resize_handle_[3] = add_draggable_gizmo( + { NodeKeyframeTrackReference(NodeInput(this, k_bottom_left_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_bottom_left_input), 1) }); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -void CornerPinDistortNode::Retranslate() +void CornerPinDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Texture")); - SetInputName(kPerspectiveInput, tr("Perspective")); - SetInputName(kTopLeftInput, tr("Top Left")); - SetInputName(kTopRightInput, tr("Top Right")); - SetInputName(kBottomRightInput, tr("Bottom Right")); - SetInputName(kBottomLeftInput, tr("Bottom Left")); + set_input_name(k_texture_input, tr("Texture")); + set_input_name(k_perspective_input, tr("Perspective")); + set_input_name(k_top_left_input, tr("Top Left")); + set_input_name(k_top_right_input, tr("Top Right")); + set_input_name(k_bottom_right_input, tr("Bottom Right")); + set_input_name(k_bottom_left_input, tr("Bottom Left")); } -void CornerPinDistortNode::Value(const NodeValueRow &value, +void CornerPinDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If no texture do nothing - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { // In the special case that all sliders are in their default position just // push the texture. - if (!(value[kTopLeftInput].toVec2().isNull() && - value[kTopRightInput].toVec2().isNull() && - value[kBottomRightInput].toVec2().isNull() && - value[kBottomLeftInput].toVec2().isNull())) { + if (!(value[k_top_left_input].to_vec2().isNull() && + value[k_top_right_input].to_vec2().isNull() && + value[k_bottom_right_input].to_vec2().isNull() && + value[k_bottom_left_input].to_vec2().isNull())) { ShaderJob job(value); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, tex->virtual_resolution(), + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, tex->virtual_resolution(), this)); // Convert slider values to their pixel values and then convert to clip space (-1.0 ... 1.0) for overriding the // vertex coordinates. const QVector2D &resolution = tex->virtual_resolution(); QVector2D half_resolution = resolution * 0.5; - QVector2D top_left = QVector2D(ValueToPixel(0, value, resolution)) / + QVector2D top_left = QVector2D(value_to_pixel(0, value, resolution)) / half_resolution - QVector2D(1.0, 1.0); QVector2D top_right = - QVector2D(ValueToPixel(1, value, resolution)) / + QVector2D(value_to_pixel(1, value, resolution)) / half_resolution - QVector2D(1.0, 1.0); QVector2D bottom_right = - QVector2D(ValueToPixel(2, value, resolution)) / + QVector2D(value_to_pixel(2, value, resolution)) / half_resolution - QVector2D(1.0, 1.0); QVector2D bottom_left = - QVector2D(ValueToPixel(3, value, resolution)) / + QVector2D(value_to_pixel(3, value, resolution)) / half_resolution - QVector2D(1.0, 1.0); @@ -130,27 +130,27 @@ void CornerPinDistortNode::Value(const NodeValueRow &value, bottom_left.x(), bottom_left.y(), 0.0f, bottom_right.x(), bottom_right.y(), 0.0f }; - job.SetVertexCoordinates(adjusted_vertices); + job.set_vertex_coordinates(adjusted_vertices); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } else { - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } ShaderCode -CornerPinDistortNode::GetShaderCode(const ShaderRequest &request) const +CornerPinDistortNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString( + return ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/cornerpin.frag")), - FileFunctions::ReadFileAsString( + FileFunctions::read_file_as_string( QStringLiteral(":/shaders/cornerpin.vert"))); } -QPointF CornerPinDistortNode::ValueToPixel(int value, const NodeValueRow &row, +QPointF CornerPinDistortNode::value_to_pixel(int value, const NodeValueRow &row, const QVector2D &resolution) const { Q_ASSERT(value >= 0 && value <= 3); @@ -159,65 +159,65 @@ QPointF CornerPinDistortNode::ValueToPixel(int value, const NodeValueRow &row, switch (value) { case 0: // Top left - v = row[kTopLeftInput].toVec2(); + v = row[k_top_left_input].to_vec2(); return QPointF(v.x(), v.y()); case 1: // Top right - v = row[kTopRightInput].toVec2(); + v = row[k_top_right_input].to_vec2(); return QPointF(resolution.x() + v.x(), v.y()); case 2: // Bottom right - v = row[kBottomRightInput].toVec2(); + v = row[k_bottom_right_input].to_vec2(); return QPointF(resolution.x() + v.x(), resolution.y() + v.y()); case 3: //Bottom left - v = row[kBottomLeftInput].toVec2(); + v = row[k_bottom_left_input].to_vec2(); return QPointF(v.x(), v.y() + resolution.y()); default: // We should never get here return QPointF(); } } -void CornerPinDistortNode::GizmoDragMove(double x, double y, +void CornerPinDistortNode::gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { DraggableGizmo *gizmo = static_cast(sender()); if (gizmo != gizmo_whole_rect_) { - gizmo->GetDraggers()[0].Drag( - gizmo->GetDraggers()[0].GetStartValue().toDouble() + x); - gizmo->GetDraggers()[1].Drag( - gizmo->GetDraggers()[1].GetStartValue().toDouble() + y); + gizmo->get_draggers()[0].drag( + gizmo->get_draggers()[0].get_start_value().toDouble() + x); + gizmo->get_draggers()[1].drag( + gizmo->get_draggers()[1].get_start_value().toDouble() + y); } } -void CornerPinDistortNode::UpdateGizmoPositions(const NodeValueRow &row, +void CornerPinDistortNode::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { - if (TexturePtr tex = row[kTextureInput].toTexture()) { + if (TexturePtr tex = row[k_texture_input].to_texture()) { const QVector2D &resolution = tex->virtual_resolution(); - QPointF top_left = ValueToPixel(0, row, resolution); - QPointF top_right = ValueToPixel(1, row, resolution); - QPointF bottom_right = ValueToPixel(2, row, resolution); - QPointF bottom_left = ValueToPixel(3, row, resolution); + QPointF top_left = value_to_pixel(0, row, resolution); + QPointF top_right = value_to_pixel(1, row, resolution); + QPointF bottom_right = value_to_pixel(2, row, resolution); + QPointF bottom_left = value_to_pixel(3, row, resolution); // Add the correct offset to each slider - SetInputProperty(kTopLeftInput, QStringLiteral("offset"), + set_input_property(k_top_left_input, QStringLiteral("offset"), QVector2D(0.0, 0.0)); - SetInputProperty(kTopRightInput, QStringLiteral("offset"), + set_input_property(k_top_right_input, QStringLiteral("offset"), QVector2D(resolution.x(), 0.0)); - SetInputProperty(kBottomRightInput, QStringLiteral("offset"), + set_input_property(k_bottom_right_input, QStringLiteral("offset"), resolution); - SetInputProperty(kBottomLeftInput, QStringLiteral("offset"), + set_input_property(k_bottom_left_input, QStringLiteral("offset"), QVector2D(0.0, resolution.y())); // Draw bounding box - gizmo_whole_rect_->SetPolygon(QPolygonF( + gizmo_whole_rect_->set_polygon(QPolygonF( { top_left, top_right, bottom_right, bottom_left, top_left })); // Create handles - gizmo_resize_handle_[0]->SetPoint(top_left); - gizmo_resize_handle_[1]->SetPoint(top_right); - gizmo_resize_handle_[2]->SetPoint(bottom_right); - gizmo_resize_handle_[3]->SetPoint(bottom_left); + gizmo_resize_handle_[0]->set_point(top_left); + gizmo_resize_handle_[1]->set_point(top_right); + gizmo_resize_handle_[2]->set_point(bottom_right); + gizmo_resize_handle_[3]->set_point(bottom_left); } } diff --git a/app/node/distort/cornerpin/cornerpindistortnode.h b/app/node/distort/cornerpin/cornerpindistortnode.h index cdb5debff..498582bc4 100644 --- a/app/node/distort/cornerpin/cornerpindistortnode.h +++ b/app/node/distort/cornerpin/cornerpindistortnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef CORNERPINDISTORTNODE_H -#define CORNERPINDISTORTNODE_H +#ifndef OAK_CORNERPINDISTORTNODE_H +#define OAK_CORNERPINDISTORTNODE_H #include @@ -38,7 +38,7 @@ public: NODE_DEFAULT_FUNCTIONS(CornerPinDistortNode) - virtual QString Name() const override + virtual QString name() const override { return tr("Corner Pin"); } @@ -48,52 +48,52 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.cornerpin"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryDistort }; + return { k_category_distort }; } - virtual QString Description() const override + virtual QString description() const override { return tr("Distort the image by dragging the corners."); } - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; /** * @brief Convenience function - converts the 2D slider values from being * an offset to the actual pixel value. */ - QPointF ValueToPixel(int value, const NodeValueRow &row, + QPointF value_to_pixel(int value, const NodeValueRow &row, const QVector2D &resolution) const; - static const QString kTextureInput; - static const QString kPerspectiveInput; - static const QString kTopLeftInput; - static const QString kTopRightInput; - static const QString kBottomRightInput; - static const QString kBottomLeftInput; + static const QString k_texture_input; + static const QString k_perspective_input; + static const QString k_top_left_input; + static const QString k_top_right_input; + static const QString k_bottom_right_input; + static const QString k_bottom_left_input; protected slots: - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) override; private: // Gizmo variables - static const int kGizmoCornerCount = 4; - PointGizmo *gizmo_resize_handle_[kGizmoCornerCount]; + static const int k_gizmo_corner_count = 4; + PointGizmo *gizmo_resize_handle_[k_gizmo_corner_count]; PolygonGizmo *gizmo_whole_rect_; }; } -#endif // CORNERPINDISTORTNODE_H +#endif // OAK_CORNERPINDISTORTNODE_H diff --git a/app/node/distort/crop/cropdistortnode.cpp b/app/node/distort/crop/cropdistortnode.cpp index bf51b82b7..0af40ab0c 100644 --- a/app/node/distort/crop/cropdistortnode.cpp +++ b/app/node/distort/crop/cropdistortnode.cpp @@ -28,133 +28,133 @@ namespace olive { -const QString CropDistortNode::kTextureInput = QStringLiteral("tex_in"); -const QString CropDistortNode::kLeftInput = QStringLiteral("left_in"); -const QString CropDistortNode::kTopInput = QStringLiteral("top_in"); -const QString CropDistortNode::kRightInput = QStringLiteral("right_in"); -const QString CropDistortNode::kBottomInput = QStringLiteral("bottom_in"); -const QString CropDistortNode::kFeatherInput = QStringLiteral("feather_in"); +const QString CropDistortNode::k_texture_input = QStringLiteral("tex_in"); +const QString CropDistortNode::k_left_input = QStringLiteral("left_in"); +const QString CropDistortNode::k_top_input = QStringLiteral("top_in"); +const QString CropDistortNode::k_right_input = QStringLiteral("right_in"); +const QString CropDistortNode::k_bottom_input = QStringLiteral("bottom_in"); +const QString CropDistortNode::k_feather_input = QStringLiteral("feather_in"); #define super Node CropDistortNode::CropDistortNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - CreateCropSideInput(kLeftInput); - CreateCropSideInput(kTopInput); - CreateCropSideInput(kRightInput); - CreateCropSideInput(kBottomInput); + create_crop_side_input(k_left_input); + create_crop_side_input(k_top_input); + create_crop_side_input(k_right_input); + create_crop_side_input(k_bottom_input); - AddInput(kFeatherInput, NodeValue::kFloat, 0.0); - SetInputProperty(kFeatherInput, QStringLiteral("min"), 0.0); + add_input(k_feather_input, NodeValue::k_float, 0.0); + set_input_property(k_feather_input, QStringLiteral("min"), 0.0); // Initiate gizmos - poly_gizmo_ = AddDraggableGizmo( - { kLeftInput, kTopInput, kRightInput, kBottomInput }); + poly_gizmo_ = add_draggable_gizmo( + { k_left_input, k_top_input, k_right_input, k_bottom_input }); - point_gizmo_[kGizmoScaleTopLeft] = - AddDraggableGizmo({ kLeftInput, kTopInput }); - point_gizmo_[kGizmoScaleTopCenter] = - AddDraggableGizmo({ kTopInput }); - point_gizmo_[kGizmoScaleTopRight] = - AddDraggableGizmo({ kRightInput, kTopInput }); - point_gizmo_[kGizmoScaleBottomLeft] = - AddDraggableGizmo({ kLeftInput, kBottomInput }); - point_gizmo_[kGizmoScaleBottomCenter] = - AddDraggableGizmo({ kBottomInput }); - point_gizmo_[kGizmoScaleBottomRight] = - AddDraggableGizmo({ kRightInput, kBottomInput }); - point_gizmo_[kGizmoScaleCenterLeft] = - AddDraggableGizmo({ kLeftInput }); - point_gizmo_[kGizmoScaleCenterRight] = - AddDraggableGizmo({ kRightInput }); + point_gizmo_[k_gizmo_scale_top_left] = + add_draggable_gizmo({ k_left_input, k_top_input }); + point_gizmo_[k_gizmo_scale_top_center] = + add_draggable_gizmo({ k_top_input }); + point_gizmo_[k_gizmo_scale_top_right] = + add_draggable_gizmo({ k_right_input, k_top_input }); + point_gizmo_[k_gizmo_scale_bottom_left] = + add_draggable_gizmo({ k_left_input, k_bottom_input }); + point_gizmo_[k_gizmo_scale_bottom_center] = + add_draggable_gizmo({ k_bottom_input }); + point_gizmo_[k_gizmo_scale_bottom_right] = + add_draggable_gizmo({ k_right_input, k_bottom_input }); + point_gizmo_[k_gizmo_scale_center_left] = + add_draggable_gizmo({ k_left_input }); + point_gizmo_[k_gizmo_scale_center_right] = + add_draggable_gizmo({ k_right_input }); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -void CropDistortNode::Retranslate() +void CropDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Texture")); - SetInputName(kLeftInput, tr("Left")); - SetInputName(kTopInput, tr("Top")); - SetInputName(kRightInput, tr("Right")); - SetInputName(kBottomInput, tr("Bottom")); - SetInputName(kFeatherInput, tr("Feather")); + set_input_name(k_texture_input, tr("Texture")); + set_input_name(k_left_input, tr("Left")); + set_input_name(k_top_input, tr("Top")); + set_input_name(k_right_input, tr("Right")); + set_input_name(k_bottom_input, tr("Bottom")); + set_input_name(k_feather_input, tr("Feather")); } -void CropDistortNode::Value(const NodeValueRow &value, +void CropDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { ShaderJob job; - job.Insert(value); + job.insert(value); - if (TexturePtr texture = job.Get(kTextureInput).toTexture()) { - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, + if (TexturePtr texture = job.get(k_texture_input).to_texture()) { + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, QVector2D(texture->params().width(), texture->params().height()), this)); - if (!qIsNull(job.Get(kLeftInput).toDouble()) || - !qIsNull(job.Get(kRightInput).toDouble()) || - !qIsNull(job.Get(kTopInput).toDouble()) || - !qIsNull(job.Get(kBottomInput).toDouble())) { - table->Push(NodeValue::kTexture, texture->toJob(job), this); + if (!qIsNull(job.get(k_left_input).to_double()) || + !qIsNull(job.get(k_right_input).to_double()) || + !qIsNull(job.get(k_top_input).to_double()) || + !qIsNull(job.get(k_bottom_input).to_double())) { + table->push(NodeValue::k_texture, texture->to_job(job), this); } else { - table->Push(job.Get(kTextureInput)); + table->push(job.get(k_texture_input)); } } } -ShaderCode CropDistortNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode CropDistortNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) return ShaderCode( - FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/crop.frag"))); + FileFunctions::read_file_as_string(QStringLiteral(":/shaders/crop.frag"))); } -void CropDistortNode::UpdateGizmoPositions(const NodeValueRow &row, +void CropDistortNode::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { - if (TexturePtr tex = row[kTextureInput].toTexture()) { + if (TexturePtr tex = row[k_texture_input].to_texture()) { const QVector2D &resolution = tex->virtual_resolution(); temp_resolution_ = resolution; - double left_pt = resolution.x() * row[kLeftInput].toDouble(); - double top_pt = resolution.y() * row[kTopInput].toDouble(); - double right_pt = resolution.x() * (1.0 - row[kRightInput].toDouble()); + double left_pt = resolution.x() * row[k_left_input].to_double(); + double top_pt = resolution.y() * row[k_top_input].to_double(); + double right_pt = resolution.x() * (1.0 - row[k_right_input].to_double()); double bottom_pt = - resolution.y() * (1.0 - row[kBottomInput].toDouble()); + resolution.y() * (1.0 - row[k_bottom_input].to_double()); double center_x_pt = mid(left_pt, right_pt); double center_y_pt = mid(top_pt, bottom_pt); - point_gizmo_[kGizmoScaleTopLeft]->SetPoint(QPointF(left_pt, top_pt)); - point_gizmo_[kGizmoScaleTopCenter]->SetPoint( + point_gizmo_[k_gizmo_scale_top_left]->set_point(QPointF(left_pt, top_pt)); + point_gizmo_[k_gizmo_scale_top_center]->set_point( QPointF(center_x_pt, top_pt)); - point_gizmo_[kGizmoScaleTopRight]->SetPoint(QPointF(right_pt, top_pt)); - point_gizmo_[kGizmoScaleBottomLeft]->SetPoint( + point_gizmo_[k_gizmo_scale_top_right]->set_point(QPointF(right_pt, top_pt)); + point_gizmo_[k_gizmo_scale_bottom_left]->set_point( QPointF(left_pt, bottom_pt)); - point_gizmo_[kGizmoScaleBottomCenter]->SetPoint( + point_gizmo_[k_gizmo_scale_bottom_center]->set_point( QPointF(center_x_pt, bottom_pt)); - point_gizmo_[kGizmoScaleBottomRight]->SetPoint( + point_gizmo_[k_gizmo_scale_bottom_right]->set_point( QPointF(right_pt, bottom_pt)); - point_gizmo_[kGizmoScaleCenterLeft]->SetPoint( + point_gizmo_[k_gizmo_scale_center_left]->set_point( QPointF(left_pt, center_y_pt)); - point_gizmo_[kGizmoScaleCenterRight]->SetPoint( + point_gizmo_[k_gizmo_scale_center_right]->set_point( QPointF(right_pt, center_y_pt)); - poly_gizmo_->SetPolygon( + poly_gizmo_->set_polygon( QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt)); } } -void CropDistortNode::GizmoDragMove(double x_diff, double y_diff, +void CropDistortNode::gizmo_drag_move(double x_diff, double y_diff, const Qt::KeyboardModifiers &modifiers) { DraggableGizmo *gizmo = static_cast(sender()); @@ -163,27 +163,27 @@ void CropDistortNode::GizmoDragMove(double x_diff, double y_diff, x_diff /= res.x(); y_diff /= res.y(); - for (int j = 0; j < gizmo->GetDraggers().size(); j++) { - NodeInputDragger &i = gizmo->GetDraggers()[j]; - double s = i.GetStartValue().toDouble(); - if (i.GetInput().input().input() == kLeftInput) { - i.Drag(s + x_diff); - } else if (i.GetInput().input().input() == kTopInput) { - i.Drag(s + y_diff); - } else if (i.GetInput().input().input() == kRightInput) { - i.Drag(s - x_diff); - } else if (i.GetInput().input().input() == kBottomInput) { - i.Drag(s - y_diff); + for (int j = 0; j < gizmo->get_draggers().size(); j++) { + NodeInputDragger &i = gizmo->get_draggers()[j]; + double s = i.get_start_value().toDouble(); + if (i.get_input().input().input() == k_left_input) { + i.drag(s + x_diff); + } else if (i.get_input().input().input() == k_top_input) { + i.drag(s + y_diff); + } else if (i.get_input().input().input() == k_right_input) { + i.drag(s - x_diff); + } else if (i.get_input().input().input() == k_bottom_input) { + i.drag(s - y_diff); } } } -void CropDistortNode::CreateCropSideInput(const QString &id) +void CropDistortNode::create_crop_side_input(const QString &id) { - AddInput(id, NodeValue::kFloat, 0.0); - SetInputProperty(id, QStringLiteral("min"), 0.0); - SetInputProperty(id, QStringLiteral("max"), 1.0); - SetInputProperty(id, QStringLiteral("view"), FloatSlider::kPercentage); + add_input(id, NodeValue::k_float, 0.0); + set_input_property(id, QStringLiteral("min"), 0.0); + set_input_property(id, QStringLiteral("max"), 1.0); + set_input_property(id, QStringLiteral("view"), FloatSlider::k_percentage); } } diff --git a/app/node/distort/crop/cropdistortnode.h b/app/node/distort/crop/cropdistortnode.h index 427474f03..7276ece46 100644 --- a/app/node/distort/crop/cropdistortnode.h +++ b/app/node/distort/crop/cropdistortnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef CROPDISTORTNODE_H -#define CROPDISTORTNODE_H +#ifndef OAK_CROPDISTORTNODE_H +#define OAK_CROPDISTORTNODE_H #include @@ -39,7 +39,7 @@ public: NODE_DEFAULT_FUNCTIONS(CropDistortNode) - virtual QString Name() const override + virtual QString name() const override { return tr("Crop"); } @@ -49,47 +49,47 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.crop"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryDistort }; + return { k_category_distort }; } - virtual QString Description() const override + virtual QString description() const override { return tr("Crop the edges of an image."); } - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; - static const QString kTextureInput; - static const QString kLeftInput; - static const QString kTopInput; - static const QString kRightInput; - static const QString kBottomInput; - static const QString kFeatherInput; + static const QString k_texture_input; + static const QString k_left_input; + static const QString k_top_input; + static const QString k_right_input; + static const QString k_bottom_input; + static const QString k_feather_input; protected slots: - virtual void GizmoDragMove(double delta_x, double delta_y, + virtual void gizmo_drag_move(double delta_x, double delta_y, const Qt::KeyboardModifiers &modifiers) override; private: - void CreateCropSideInput(const QString &id); + void create_crop_side_input(const QString &id); // Gizmo variables - PointGizmo *point_gizmo_[kGizmoScaleCount]; + PointGizmo *point_gizmo_[k_gizmo_scale_count]; PolygonGizmo *poly_gizmo_; QVector2D temp_resolution_; }; } -#endif // CROPDISTORTNODE_H +#endif // OAK_CROPDISTORTNODE_H diff --git a/app/node/distort/flip/flipdistortnode.cpp b/app/node/distort/flip/flipdistortnode.cpp index 0711fe77b..4544ab124 100644 --- a/app/node/distort/flip/flipdistortnode.cpp +++ b/app/node/distort/flip/flipdistortnode.cpp @@ -24,26 +24,26 @@ namespace olive { -const QString FlipDistortNode::kTextureInput = QStringLiteral("tex_in"); -const QString FlipDistortNode::kHorizontalInput = QStringLiteral("horiz_in"); -const QString FlipDistortNode::kVerticalInput = QStringLiteral("vert_in"); +const QString FlipDistortNode::k_texture_input = QStringLiteral("tex_in"); +const QString FlipDistortNode::k_horizontal_input = QStringLiteral("horiz_in"); +const QString FlipDistortNode::k_vertical_input = QStringLiteral("vert_in"); #define super Node FlipDistortNode::FlipDistortNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kHorizontalInput, NodeValue::kBoolean, false); + add_input(k_horizontal_input, NodeValue::k_boolean, false); - AddInput(kVerticalInput, NodeValue::kBoolean, false); + add_input(k_vertical_input, NodeValue::k_boolean, false); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -QString FlipDistortNode::Name() const +QString FlipDistortNode::name() const { return tr("Flip"); } @@ -53,45 +53,45 @@ QString FlipDistortNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.flip"); } -QVector FlipDistortNode::Category() const +QVector FlipDistortNode::category() const { - return { kCategoryDistort }; + return { k_category_distort }; } -QString FlipDistortNode::Description() const +QString FlipDistortNode::description() const { return tr("Flips an image horizontally or vertically"); } -void FlipDistortNode::Retranslate() +void FlipDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kHorizontalInput, tr("Horizontal")); - SetInputName(kVerticalInput, tr("Vertical")); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_horizontal_input, tr("Horizontal")); + set_input_name(k_vertical_input, tr("Vertical")); } -ShaderCode FlipDistortNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode FlipDistortNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/flip.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/flip.frag")); } -void FlipDistortNode::Value(const NodeValueRow &value, +void FlipDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If there's no texture, no need to run an operation - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { // Only run shader if at least one of flip or flop are selected - if (value[kHorizontalInput].toBool() || - value[kVerticalInput].toBool()) { - table->Push(NodeValue::kTexture, tex->toJob(ShaderJob(value)), + if (value[k_horizontal_input].to_bool() || + value[k_vertical_input].to_bool()) { + table->push(NodeValue::k_texture, tex->to_job(ShaderJob(value)), this); } else { // If we're not flipping or flopping just push the texture - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } diff --git a/app/node/distort/flip/flipdistortnode.h b/app/node/distort/flip/flipdistortnode.h index 91b3917be..978440805 100644 --- a/app/node/distort/flip/flipdistortnode.h +++ b/app/node/distort/flip/flipdistortnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef FLIPDISTORTNODE_H -#define FLIPDISTORTNODE_H +#ifndef OAK_FLIPDISTORTNODE_H +#define OAK_FLIPDISTORTNODE_H #include "node/node.h" @@ -34,23 +34,23 @@ public: NODE_DEFAULT_FUNCTIONS(FlipDistortNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTextureInput; - static const QString kHorizontalInput; - static const QString kVerticalInput; + static const QString k_texture_input; + static const QString k_horizontal_input; + static const QString k_vertical_input; }; } -#endif // FLIPDISTORTNODE_H +#endif // OAK_FLIPDISTORTNODE_H diff --git a/app/node/distort/mask/mask.cpp b/app/node/distort/mask/mask.cpp index 21bb8ebee..544fdec6f 100644 --- a/app/node/distort/mask/mask.cpp +++ b/app/node/distort/mask/mask.cpp @@ -28,105 +28,105 @@ namespace olive #define super PolygonGenerator -const QString MaskDistortNode::kFeatherInput = QStringLiteral("feather_in"); -const QString MaskDistortNode::kInvertInput = QStringLiteral("invert_in"); +const QString MaskDistortNode::k_feather_input = QStringLiteral("feather_in"); +const QString MaskDistortNode::k_invert_input = QStringLiteral("invert_in"); MaskDistortNode::MaskDistortNode() { // Mask should always be (1.0, 1.0, 1.0) for multiply to work correctly - SetInputFlag(kColorInput, kInputFlagHidden); + set_input_flag(k_color_input, k_input_flag_hidden); - AddInput(kInvertInput, NodeValue::kBoolean, false); + add_input(k_invert_input, NodeValue::k_boolean, false); - AddInput(kFeatherInput, NodeValue::kFloat, 0.0); - SetInputProperty(kFeatherInput, QStringLiteral("min"), 0.0); + add_input(k_feather_input, NodeValue::k_float, 0.0); + set_input_property(k_feather_input, QStringLiteral("min"), 0.0); } -ShaderCode MaskDistortNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode MaskDistortNode::get_shader_code(const ShaderRequest &request) const { if (request.id == QStringLiteral("mrg")) { - return ShaderCode(FileFunctions::ReadFileAsString( + return ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/multiply.frag"))); } else if (request.id == QStringLiteral("feather")) { - return ShaderCode(FileFunctions::ReadFileAsString( + return ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/blur.frag"))); } else if (request.id == QStringLiteral("invert")) { - return ShaderCode(FileFunctions::ReadFileAsString( + return ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/invertrgba.frag"))); } else { - return super::GetShaderCode(request); + return super::get_shader_code(request); } } -void MaskDistortNode::Retranslate() +void MaskDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kBaseInput, tr("Texture")); - SetInputName(kInvertInput, tr("Invert")); - SetInputName(kFeatherInput, tr("Feather")); + set_input_name(k_base_input, tr("Texture")); + set_input_name(k_invert_input, tr("Invert")); + set_input_name(k_feather_input, tr("Feather")); } -void MaskDistortNode::Value(const NodeValueRow &value, +void MaskDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - TexturePtr texture = value[kBaseInput].toTexture(); + TexturePtr texture = value[k_base_input].to_texture(); VideoParams job_params = texture ? texture->params() : globals.vparams(); - NodeValue job(NodeValue::kTexture, - Texture::Job(job_params, GetGenerateJob(value, job_params)), + NodeValue job(NodeValue::k_texture, + Texture::job(job_params, get_generate_job(value, job_params)), this); - if (value[kInvertInput].toBool()) { + if (value[k_invert_input].to_bool()) { ShaderJob invert; - invert.SetShaderID(QStringLiteral("invert")); - invert.Insert(QStringLiteral("tex_in"), job); - job.set_value(Texture::Job(job_params, invert)); + invert.set_shader_id(QStringLiteral("invert")); + invert.insert(QStringLiteral("tex_in"), job); + job.set_value(Texture::job(job_params, invert)); } if (texture) { // Push as merge node ShaderJob merge; - merge.SetShaderID(QStringLiteral("mrg")); - merge.Insert(QStringLiteral("tex_a"), value[kBaseInput]); + merge.set_shader_id(QStringLiteral("mrg")); + merge.insert(QStringLiteral("tex_a"), value[k_base_input]); - if (value[kFeatherInput].toDouble() > 0.0) { + if (value[k_feather_input].to_double() > 0.0) { // Nest a blur shader in there too ShaderJob feather; - feather.SetShaderID(QStringLiteral("feather")); - feather.Insert(BlurFilterNode::kTextureInput, job); - feather.Insert(BlurFilterNode::kMethodInput, - NodeValue(NodeValue::kInt, - int(BlurFilterNode::kGaussian), this)); - feather.Insert(BlurFilterNode::kHorizInput, - NodeValue(NodeValue::kBoolean, true, this)); - feather.Insert(BlurFilterNode::kVertInput, - NodeValue(NodeValue::kBoolean, true, this)); - feather.Insert(BlurFilterNode::kRepeatEdgePixelsInput, - NodeValue(NodeValue::kBoolean, true, this)); - feather.Insert(BlurFilterNode::kRadiusInput, - NodeValue(NodeValue::kFloat, - value[kFeatherInput].toDouble(), this)); - feather.SetIterations(2, BlurFilterNode::kTextureInput); - feather.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, + feather.set_shader_id(QStringLiteral("feather")); + feather.insert(BlurFilterNode::k_texture_input, job); + feather.insert(BlurFilterNode::k_method_input, + NodeValue(NodeValue::k_int, + int(BlurFilterNode::k_gaussian), this)); + feather.insert(BlurFilterNode::k_horiz_input, + NodeValue(NodeValue::k_boolean, true, this)); + feather.insert(BlurFilterNode::k_vert_input, + NodeValue(NodeValue::k_boolean, true, this)); + feather.insert(BlurFilterNode::k_repeat_edge_pixels_input, + NodeValue(NodeValue::k_boolean, true, this)); + feather.insert(BlurFilterNode::k_radius_input, + NodeValue(NodeValue::k_float, + value[k_feather_input].to_double(), this)); + feather.set_iterations(2, BlurFilterNode::k_texture_input); + feather.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, texture ? texture->virtual_resolution() : globals.square_resolution(), this)); - merge.Insert(QStringLiteral("tex_b"), - NodeValue(NodeValue::kTexture, - Texture::Job(job_params, feather), this)); + merge.insert(QStringLiteral("tex_b"), + NodeValue(NodeValue::k_texture, + Texture::job(job_params, feather), this)); } else { - merge.Insert(QStringLiteral("tex_b"), job); + merge.insert(QStringLiteral("tex_b"), job); } - table->Push(NodeValue::kTexture, Texture::Job(job_params, merge), this); + table->push(NodeValue::k_texture, Texture::job(job_params, merge), this); } else { - table->Push(job); + table->push(job); } } diff --git a/app/node/distort/mask/mask.h b/app/node/distort/mask/mask.h index d9a4e8ef1..822433f90 100644 --- a/app/node/distort/mask/mask.h +++ b/app/node/distort/mask/mask.h @@ -19,8 +19,8 @@ ***/ -#ifndef MASKDISTORTNODE_H -#define MASKDISTORTNODE_H +#ifndef OAK_MASKDISTORTNODE_H +#define OAK_MASKDISTORTNODE_H #include "node/generator/polygon/polygon.h" @@ -34,7 +34,7 @@ public: NODE_DEFAULT_FUNCTIONS(MaskDistortNode) - virtual QString Name() const override + virtual QString name() const override { return tr("Mask"); } @@ -44,28 +44,28 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.mask"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryDistort }; + return { k_category_distort }; } - virtual QString Description() const override + virtual QString description() const override { return tr("Apply a polygonal mask."); } virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kInvertInput; - static const QString kFeatherInput; + static const QString k_invert_input; + static const QString k_feather_input; }; } -#endif // MASKDISTORTNODE_H +#endif // OAK_MASKDISTORTNODE_H diff --git a/app/node/distort/ripple/rippledistortnode.cpp b/app/node/distort/ripple/rippledistortnode.cpp index e7e3065dc..6dd61c56d 100644 --- a/app/node/distort/ripple/rippledistortnode.cpp +++ b/app/node/distort/ripple/rippledistortnode.cpp @@ -24,43 +24,43 @@ namespace olive { -const QString RippleDistortNode::kTextureInput = QStringLiteral("tex_in"); -const QString RippleDistortNode::kEvolutionInput = +const QString RippleDistortNode::k_texture_input = QStringLiteral("tex_in"); +const QString RippleDistortNode::k_evolution_input = QStringLiteral("evolution_in"); -const QString RippleDistortNode::kIntensityInput = +const QString RippleDistortNode::k_intensity_input = QStringLiteral("intensity_in"); -const QString RippleDistortNode::kFrequencyInput = +const QString RippleDistortNode::k_frequency_input = QStringLiteral("frequency_in"); -const QString RippleDistortNode::kPositionInput = QStringLiteral("position_in"); -const QString RippleDistortNode::kStretchInput = QStringLiteral("stretch_in"); +const QString RippleDistortNode::k_position_input = QStringLiteral("position_in"); +const QString RippleDistortNode::k_stretch_input = QStringLiteral("stretch_in"); #define super Node RippleDistortNode::RippleDistortNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kEvolutionInput, NodeValue::kFloat, 0); - AddInput(kIntensityInput, NodeValue::kFloat, 100); + add_input(k_evolution_input, NodeValue::k_float, 0); + add_input(k_intensity_input, NodeValue::k_float, 100); - AddInput(kFrequencyInput, NodeValue::kFloat, 1); - SetInputProperty(kFrequencyInput, QStringLiteral("base"), 0.01); + add_input(k_frequency_input, NodeValue::k_float, 1); + set_input_property(k_frequency_input, QStringLiteral("base"), 0.01); - AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0)); - AddInput(kStretchInput, NodeValue::kBoolean, false); + add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0)); + add_input(k_stretch_input, NodeValue::k_boolean, false); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); - gizmo_ = AddDraggableGizmo({ - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1), + gizmo_ = add_draggable_gizmo({ + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1), }); - gizmo_->SetShape(PointGizmo::kAnchorPoint); + gizmo_->set_shape(PointGizmo::k_anchor_point); } -QString RippleDistortNode::Name() const +QString RippleDistortNode::name() const { return tr("Ripple"); } @@ -70,72 +70,72 @@ QString RippleDistortNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.ripple"); } -QVector RippleDistortNode::Category() const +QVector RippleDistortNode::category() const { - return { kCategoryDistort }; + return { k_category_distort }; } -QString RippleDistortNode::Description() const +QString RippleDistortNode::description() const { return tr("Distorts an image with a ripple effect."); } -void RippleDistortNode::Retranslate() +void RippleDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kFrequencyInput, tr("Frequency")); - SetInputName(kIntensityInput, tr("Intensity")); - SetInputName(kEvolutionInput, tr("Evolution")); - SetInputName(kPositionInput, tr("Position")); - SetInputName(kStretchInput, tr("Stretch")); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_frequency_input, tr("Frequency")); + set_input_name(k_intensity_input, tr("Intensity")); + set_input_name(k_evolution_input, tr("Evolution")); + set_input_name(k_position_input, tr("Position")); + set_input_name(k_stretch_input, tr("Stretch")); } -ShaderCode RippleDistortNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode RippleDistortNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/ripple.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/ripple.frag")); } -void RippleDistortNode::Value(const NodeValueRow &value, +void RippleDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If there's no texture, no need to run an operation - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { // Only run shader if at least one of flip or flop are selected - if (!qIsNull(value[kIntensityInput].toDouble())) { + if (!qIsNull(value[k_intensity_input].to_double())) { ShaderJob job(value); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, tex->virtual_resolution(), + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, tex->virtual_resolution(), this)); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } else { // If we're not flipping or flopping just push the texture - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } -void RippleDistortNode::UpdateGizmoPositions(const NodeValueRow &row, +void RippleDistortNode::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { - if (TexturePtr tex = row[kTextureInput].toTexture()) { + if (TexturePtr tex = row[k_texture_input].to_texture()) { QPointF half_res(tex->virtual_resolution().x() / 2, tex->virtual_resolution().y() / 2); - gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF()); + gizmo_->set_point(half_res + row[k_position_input].to_vec2().toPointF()); } } -void RippleDistortNode::GizmoDragMove(double x, double y, +void RippleDistortNode::gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { - NodeInputDragger &x_drag = gizmo_->GetDraggers()[0]; - NodeInputDragger &y_drag = gizmo_->GetDraggers()[1]; + NodeInputDragger &x_drag = gizmo_->get_draggers()[0]; + NodeInputDragger &y_drag = gizmo_->get_draggers()[1]; - x_drag.Drag(x_drag.GetStartValue().toDouble() + x); - y_drag.Drag(y_drag.GetStartValue().toDouble() + y); + x_drag.drag(x_drag.get_start_value().toDouble() + x); + y_drag.drag(y_drag.get_start_value().toDouble() + y); } } diff --git a/app/node/distort/ripple/rippledistortnode.h b/app/node/distort/ripple/rippledistortnode.h index d6bc6e13c..1a3bc9d4a 100644 --- a/app/node/distort/ripple/rippledistortnode.h +++ b/app/node/distort/ripple/rippledistortnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef RIPPLEDISTORTNODE_H -#define RIPPLEDISTORTNODE_H +#ifndef OAK_RIPPLEDISTORTNODE_H +#define OAK_RIPPLEDISTORTNODE_H #include "node/gizmo/point.h" #include "node/node.h" @@ -35,30 +35,30 @@ public: NODE_DEFAULT_FUNCTIONS(RippleDistortNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; - static const QString kTextureInput; - static const QString kEvolutionInput; - static const QString kIntensityInput; - static const QString kFrequencyInput; - static const QString kPositionInput; - static const QString kStretchInput; + static const QString k_texture_input; + static const QString k_evolution_input; + static const QString k_intensity_input; + static const QString k_frequency_input; + static const QString k_position_input; + static const QString k_stretch_input; protected slots: - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) override; private: @@ -67,4 +67,4 @@ private: } -#endif // RIPPLEDISTORTNODE_H +#endif // OAK_RIPPLEDISTORTNODE_H diff --git a/app/node/distort/swirl/swirldistortnode.cpp b/app/node/distort/swirl/swirldistortnode.cpp index 6fb0d3d94..73a784c5e 100644 --- a/app/node/distort/swirl/swirldistortnode.cpp +++ b/app/node/distort/swirl/swirldistortnode.cpp @@ -24,37 +24,37 @@ namespace olive { -const QString SwirlDistortNode::kTextureInput = QStringLiteral("tex_in"); -const QString SwirlDistortNode::kRadiusInput = QStringLiteral("radius_in"); -const QString SwirlDistortNode::kAngleInput = QStringLiteral("angle_in"); -const QString SwirlDistortNode::kPositionInput = QStringLiteral("pos_in"); +const QString SwirlDistortNode::k_texture_input = QStringLiteral("tex_in"); +const QString SwirlDistortNode::k_radius_input = QStringLiteral("radius_in"); +const QString SwirlDistortNode::k_angle_input = QStringLiteral("angle_in"); +const QString SwirlDistortNode::k_position_input = QStringLiteral("pos_in"); #define super Node SwirlDistortNode::SwirlDistortNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kRadiusInput, NodeValue::kFloat, 200); - SetInputProperty(kRadiusInput, QStringLiteral("min"), 0); + add_input(k_radius_input, NodeValue::k_float, 200); + set_input_property(k_radius_input, QStringLiteral("min"), 0); - AddInput(kAngleInput, NodeValue::kFloat, 10); - SetInputProperty(kAngleInput, QStringLiteral("base"), 0.1); + add_input(k_angle_input, NodeValue::k_float, 10); + set_input_property(k_angle_input, QStringLiteral("base"), 0.1); - AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0)); + add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0)); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); - gizmo_ = AddDraggableGizmo({ - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1), + gizmo_ = add_draggable_gizmo({ + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1), }); - gizmo_->SetShape(PointGizmo::kAnchorPoint); + gizmo_->set_shape(PointGizmo::k_anchor_point); } -QString SwirlDistortNode::Name() const +QString SwirlDistortNode::name() const { return tr("Swirl"); } @@ -64,70 +64,70 @@ QString SwirlDistortNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.swirl"); } -QVector SwirlDistortNode::Category() const +QVector SwirlDistortNode::category() const { - return { kCategoryDistort }; + return { k_category_distort }; } -QString SwirlDistortNode::Description() const +QString SwirlDistortNode::description() const { return tr("Distorts an image by swirling it around a center point."); } -void SwirlDistortNode::Retranslate() +void SwirlDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kRadiusInput, tr("Radius")); - SetInputName(kAngleInput, tr("Angle")); - SetInputName(kPositionInput, tr("Position")); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_radius_input, tr("Radius")); + set_input_name(k_angle_input, tr("Angle")); + set_input_name(k_position_input, tr("Position")); } -ShaderCode SwirlDistortNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode SwirlDistortNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/swirl.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/swirl.frag")); } -void SwirlDistortNode::Value(const NodeValueRow &value, +void SwirlDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If there's no texture, no need to run an operation - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { // Only run shader if at least one of flip or flop are selected - if (!qIsNull(value[kAngleInput].toDouble()) && - !qIsNull(value[kRadiusInput].toDouble())) { + if (!qIsNull(value[k_angle_input].to_double()) && + !qIsNull(value[k_radius_input].to_double())) { ShaderJob job(value); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, tex->virtual_resolution(), + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, tex->virtual_resolution(), this)); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } else { // If we're not flipping or flopping just push the texture - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } -void SwirlDistortNode::UpdateGizmoPositions(const NodeValueRow &row, +void SwirlDistortNode::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { QPointF half_res(globals.square_resolution().x() / 2, globals.square_resolution().y() / 2); - gizmo_->SetPoint(half_res + row[kPositionInput].toVec2().toPointF()); + gizmo_->set_point(half_res + row[k_position_input].to_vec2().toPointF()); } -void SwirlDistortNode::GizmoDragMove(double x, double y, +void SwirlDistortNode::gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { - NodeInputDragger &x_drag = gizmo_->GetDraggers()[0]; - NodeInputDragger &y_drag = gizmo_->GetDraggers()[1]; + NodeInputDragger &x_drag = gizmo_->get_draggers()[0]; + NodeInputDragger &y_drag = gizmo_->get_draggers()[1]; - x_drag.Drag(x_drag.GetStartValue().toDouble() + x); - y_drag.Drag(y_drag.GetStartValue().toDouble() + y); + x_drag.drag(x_drag.get_start_value().toDouble() + x); + y_drag.drag(y_drag.get_start_value().toDouble() + y); } } diff --git a/app/node/distort/swirl/swirldistortnode.h b/app/node/distort/swirl/swirldistortnode.h index 1bba960e9..29b3e2102 100644 --- a/app/node/distort/swirl/swirldistortnode.h +++ b/app/node/distort/swirl/swirldistortnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef SWIRLDISTORTNODE_H -#define SWIRLDISTORTNODE_H +#ifndef OAK_SWIRLDISTORTNODE_H +#define OAK_SWIRLDISTORTNODE_H #include "node/gizmo/point.h" #include "node/node.h" @@ -35,28 +35,28 @@ public: NODE_DEFAULT_FUNCTIONS(SwirlDistortNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; - static const QString kTextureInput; - static const QString kRadiusInput; - static const QString kAngleInput; - static const QString kPositionInput; + static const QString k_texture_input; + static const QString k_radius_input; + static const QString k_angle_input; + static const QString k_position_input; protected slots: - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) override; private: @@ -65,4 +65,4 @@ private: } -#endif // SWIRLDISTORTNODE_H +#endif // OAK_SWIRLDISTORTNODE_H diff --git a/app/node/distort/tile/tiledistortnode.cpp b/app/node/distort/tile/tiledistortnode.cpp index f535a2c02..014530dd2 100644 --- a/app/node/distort/tile/tiledistortnode.cpp +++ b/app/node/distort/tile/tiledistortnode.cpp @@ -26,43 +26,43 @@ namespace olive { -const QString TileDistortNode::kTextureInput = QStringLiteral("tex_in"); -const QString TileDistortNode::kScaleInput = QStringLiteral("scale_in"); -const QString TileDistortNode::kPositionInput = QStringLiteral("position_in"); -const QString TileDistortNode::kAnchorInput = QStringLiteral("anchor_in"); -const QString TileDistortNode::kMirrorXInput = QStringLiteral("mirrorx_in"); -const QString TileDistortNode::kMirrorYInput = QStringLiteral("mirrory_in"); +const QString TileDistortNode::k_texture_input = QStringLiteral("tex_in"); +const QString TileDistortNode::k_scale_input = QStringLiteral("scale_in"); +const QString TileDistortNode::k_position_input = QStringLiteral("position_in"); +const QString TileDistortNode::k_anchor_input = QStringLiteral("anchor_in"); +const QString TileDistortNode::k_mirror_x_input = QStringLiteral("mirrorx_in"); +const QString TileDistortNode::k_mirror_y_input = QStringLiteral("mirrory_in"); #define super Node TileDistortNode::TileDistortNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kScaleInput, NodeValue::kFloat, 0.5); - SetInputProperty(kScaleInput, QStringLiteral("min"), 0); - SetInputProperty(kScaleInput, QStringLiteral("view"), - FloatSlider::kPercentage); + add_input(k_scale_input, NodeValue::k_float, 0.5); + set_input_property(k_scale_input, QStringLiteral("min"), 0); + set_input_property(k_scale_input, QStringLiteral("view"), + FloatSlider::k_percentage); - AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0)); + add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0)); - AddInput(kAnchorInput, NodeValue::kCombo, kMiddleCenter); + add_input(k_anchor_input, NodeValue::k_combo, k_middle_center); - AddInput(kMirrorXInput, NodeValue::kBoolean, false); - AddInput(kMirrorYInput, NodeValue::kBoolean, false); + add_input(k_mirror_x_input, NodeValue::k_boolean, false); + add_input(k_mirror_y_input, NodeValue::k_boolean, false); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); - gizmo_ = AddDraggableGizmo({ - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1), + gizmo_ = add_draggable_gizmo({ + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1), }); - gizmo_->SetShape(PointGizmo::kAnchorPoint); + gizmo_->set_shape(PointGizmo::k_anchor_point); } -QString TileDistortNode::Name() const +QString TileDistortNode::name() const { return tr("Tile"); } @@ -72,28 +72,28 @@ QString TileDistortNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.tile"); } -QVector TileDistortNode::Category() const +QVector TileDistortNode::category() const { - return { kCategoryDistort }; + return { k_category_distort }; } -QString TileDistortNode::Description() const +QString TileDistortNode::description() const { return tr("Infinitely tile an image horizontally and vertically."); } -void TileDistortNode::Retranslate() +void TileDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kScaleInput, tr("Scale")); - SetInputName(kPositionInput, tr("Position")); - SetInputName(kMirrorXInput, tr("Mirror Horizontally")); - SetInputName(kMirrorYInput, tr("Mirror Vertically")); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_scale_input, tr("Scale")); + set_input_name(k_position_input, tr("Position")); + set_input_name(k_mirror_x_input, tr("Mirror Horizontally")); + set_input_name(k_mirror_y_input, tr("Mirror Vertically")); - SetInputName(kAnchorInput, tr("Anchor")); - SetComboBoxStrings(kAnchorInput, { + set_input_name(k_anchor_input, tr("Anchor")); + set_combo_box_strings(k_anchor_input, { tr("Top-Left"), tr("Top-Center"), tr("Top-Right"), @@ -106,72 +106,72 @@ void TileDistortNode::Retranslate() }); } -ShaderCode TileDistortNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode TileDistortNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/tile.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/tile.frag")); } -void TileDistortNode::Value(const NodeValueRow &value, +void TileDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If there's no texture, no need to run an operation - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { // Only run shader if at least one of flip or flop are selected - if (!qFuzzyCompare(value[kScaleInput].toDouble(), 1.0)) { + if (!qFuzzyCompare(value[k_scale_input].to_double(), 1.0)) { ShaderJob job(value); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, tex->virtual_resolution(), + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, tex->virtual_resolution(), this)); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } else { // If we're not flipping or flopping just push the texture - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } -void TileDistortNode::UpdateGizmoPositions(const NodeValueRow &row, +void TileDistortNode::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { - if (TexturePtr tex = row[kTextureInput].toTexture()) { + if (TexturePtr tex = row[k_texture_input].to_texture()) { QPointF res = tex->virtual_resolution().toPointF(); - QPointF pos = row[kPositionInput].toVec2().toPointF(); + QPointF pos = row[k_position_input].to_vec2().toPointF(); qreal x = pos.x(); qreal y = pos.y(); - Anchor a = static_cast(row[kAnchorInput].toInt()); - if (a == kTopLeft || a == kTopCenter || a == kTopRight) { + Anchor a = static_cast(row[k_anchor_input].to_int()); + if (a == k_top_left || a == k_top_center || a == k_top_right) { // Do nothing - } else if (a == kMiddleLeft || a == kMiddleCenter || - a == kMiddleRight) { + } else if (a == k_middle_left || a == k_middle_center || + a == k_middle_right) { y += res.y() / 2; - } else if (a == kBottomLeft || a == kBottomCenter || - a == kBottomRight) { + } else if (a == k_bottom_left || a == k_bottom_center || + a == k_bottom_right) { y += res.y(); } - if (a == kTopLeft || a == kMiddleLeft || a == kBottomLeft) { + if (a == k_top_left || a == k_middle_left || a == k_bottom_left) { // Do nothing - } else if (a == kTopCenter || a == kMiddleCenter || - a == kBottomCenter) { + } else if (a == k_top_center || a == k_middle_center || + a == k_bottom_center) { x += res.x() / 2; - } else if (a == kTopRight || a == kMiddleRight || a == kBottomRight) { + } else if (a == k_top_right || a == k_middle_right || a == k_bottom_right) { x += res.x(); } - gizmo_->SetPoint(QPointF(x, y)); + gizmo_->set_point(QPointF(x, y)); } } -void TileDistortNode::GizmoDragMove(double x, double y, +void TileDistortNode::gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { - NodeInputDragger &x_drag = gizmo_->GetDraggers()[0]; - NodeInputDragger &y_drag = gizmo_->GetDraggers()[1]; + NodeInputDragger &x_drag = gizmo_->get_draggers()[0]; + NodeInputDragger &y_drag = gizmo_->get_draggers()[1]; - x_drag.Drag(x_drag.GetStartValue().toDouble() + x); - y_drag.Drag(y_drag.GetStartValue().toDouble() + y); + x_drag.drag(x_drag.get_start_value().toDouble() + x); + y_drag.drag(y_drag.get_start_value().toDouble() + y); } } diff --git a/app/node/distort/tile/tiledistortnode.h b/app/node/distort/tile/tiledistortnode.h index 67f81684c..cde13200e 100644 --- a/app/node/distort/tile/tiledistortnode.h +++ b/app/node/distort/tile/tiledistortnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef TILEDISTORTNODE_H -#define TILEDISTORTNODE_H +#ifndef OAK_TILEDISTORTNODE_H +#define OAK_TILEDISTORTNODE_H #include "node/gizmo/point.h" #include "node/node.h" @@ -35,43 +35,43 @@ public: NODE_DEFAULT_FUNCTIONS(TileDistortNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; - static const QString kTextureInput; - static const QString kScaleInput; - static const QString kPositionInput; - static const QString kAnchorInput; - static const QString kMirrorXInput; - static const QString kMirrorYInput; + static const QString k_texture_input; + static const QString k_scale_input; + static const QString k_position_input; + static const QString k_anchor_input; + static const QString k_mirror_x_input; + static const QString k_mirror_y_input; protected slots: - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) override; private: enum Anchor { - kTopLeft, - kTopCenter, - kTopRight, - kMiddleLeft, - kMiddleCenter, - kMiddleRight, - kBottomLeft, - kBottomCenter, - kBottomRight + k_top_left, + k_top_center, + k_top_right, + k_middle_left, + k_middle_center, + k_middle_right, + k_bottom_left, + k_bottom_center, + k_bottom_right }; PointGizmo *gizmo_; @@ -79,4 +79,4 @@ private: } -#endif // TILEDISTORTNODE_H +#endif // OAK_TILEDISTORTNODE_H diff --git a/app/node/distort/transform/transformdistortnode.cpp b/app/node/distort/transform/transformdistortnode.cpp index 59d427240..4574a19a1 100644 --- a/app/node/distort/transform/transformdistortnode.cpp +++ b/app/node/distort/transform/transformdistortnode.cpp @@ -26,124 +26,124 @@ namespace olive { -const QString TransformDistortNode::kParentInput = QStringLiteral("parent_in"); -const QString TransformDistortNode::kTextureInput = QStringLiteral("tex_in"); -const QString TransformDistortNode::kAutoscaleInput = +const QString TransformDistortNode::k_parent_input = QStringLiteral("parent_in"); +const QString TransformDistortNode::k_texture_input = QStringLiteral("tex_in"); +const QString TransformDistortNode::k_autoscale_input = QStringLiteral("autoscale_in"); -const QString TransformDistortNode::kInterpolationInput = +const QString TransformDistortNode::k_interpolation_input = QStringLiteral("interpolation_in"); #define super MatrixGenerator TransformDistortNode::TransformDistortNode() { - AddInput(kParentInput, NodeValue::kMatrix); + add_input(k_parent_input, NodeValue::k_matrix); - AddInput(kAutoscaleInput, NodeValue::kCombo, 0); + add_input(k_autoscale_input, NodeValue::k_combo, 0); - AddInput(kInterpolationInput, NodeValue::kCombo, 2); + add_input(k_interpolation_input, NodeValue::k_combo, 2); - PrependInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + prepend_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); // Initiate gizmos - rotation_gizmo_ = AddDraggableGizmo(); - rotation_gizmo_->AddInput(NodeInput(this, kRotationInput)); - rotation_gizmo_->SetDragValueBehavior(ScreenGizmo::kAbsolute); + rotation_gizmo_ = add_draggable_gizmo(); + rotation_gizmo_->add_input(NodeInput(this, k_rotation_input)); + rotation_gizmo_->set_drag_value_behavior(ScreenGizmo::k_absolute); - poly_gizmo_ = AddDraggableGizmo(); - poly_gizmo_->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0)); - poly_gizmo_->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1)); + poly_gizmo_ = add_draggable_gizmo(); + poly_gizmo_->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0)); + poly_gizmo_->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1)); - anchor_gizmo_ = AddDraggableGizmo(); - anchor_gizmo_->SetShape(PointGizmo::kAnchorPoint); - anchor_gizmo_->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kAnchorInput), 0)); - anchor_gizmo_->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kAnchorInput), 1)); - anchor_gizmo_->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0)); - anchor_gizmo_->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1)); + anchor_gizmo_ = add_draggable_gizmo(); + anchor_gizmo_->set_shape(PointGizmo::k_anchor_point); + anchor_gizmo_->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_anchor_input), 0)); + anchor_gizmo_->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_anchor_input), 1)); + anchor_gizmo_->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0)); + anchor_gizmo_->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1)); - for (int i = 0; i < kGizmoScaleCount; i++) { - point_gizmo_[i] = AddDraggableGizmo(); - point_gizmo_[i]->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kScaleInput), 0)); - point_gizmo_[i]->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kScaleInput), 1)); - point_gizmo_[i]->SetDragValueBehavior(PointGizmo::kAbsolute); + for (int i = 0; i < k_gizmo_scale_count; i++) { + point_gizmo_[i] = add_draggable_gizmo(); + point_gizmo_[i]->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_scale_input), 0)); + point_gizmo_[i]->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_scale_input), 1)); + point_gizmo_[i]->set_drag_value_behavior(PointGizmo::k_absolute); } - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -void TransformDistortNode::Retranslate() +void TransformDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kParentInput, tr("Parent")); - SetInputName(kAutoscaleInput, tr("Auto-Scale")); - SetInputName(kTextureInput, tr("Texture")); - SetInputName(kInterpolationInput, tr("Interpolation")); + set_input_name(k_parent_input, tr("Parent")); + set_input_name(k_autoscale_input, tr("Auto-Scale")); + set_input_name(k_texture_input, tr("Texture")); + set_input_name(k_interpolation_input, tr("Interpolation")); - SetComboBoxStrings(kAutoscaleInput, + set_combo_box_strings(k_autoscale_input, { tr("None"), tr("Fit"), tr("Fill"), tr("Stretch") }); - SetComboBoxStrings(kInterpolationInput, + set_combo_box_strings(k_interpolation_input, { tr("Nearest Neighbor"), tr("Bilinear"), tr("Mipmapped Bilinear") }); } -void TransformDistortNode::Value(const NodeValueRow &value, +void TransformDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // Generate matrix - QMatrix4x4 generated_matrix = GenerateMatrix( - value, false, false, false, value[kParentInput].toMatrix()); + QMatrix4x4 generated_matrix = generate_matrix( + value, false, false, false, value[k_parent_input].to_matrix()); // Pop texture - NodeValue texture_meta = value[kTextureInput]; + NodeValue texture_meta = value[k_texture_input]; TexturePtr job_to_push = nullptr; // If we have a texture, generate a matrix and make it happen - if (TexturePtr texture = texture_meta.toTexture()) { + if (TexturePtr texture = texture_meta.to_texture()) { // Adjust our matrix by the resolutions involved - QMatrix4x4 real_matrix = GenerateAutoScaledMatrix( + QMatrix4x4 real_matrix = generate_auto_scaled_matrix( generated_matrix, value, globals, texture->params()); if (!real_matrix.isIdentity()) { // The matrix will transform things ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), texture_meta); - job.Insert(QStringLiteral("ove_mvpmat"), - NodeValue(NodeValue::kMatrix, real_matrix, this)); - job.SetInterpolation(QStringLiteral("ove_maintex"), + job.insert(QStringLiteral("ove_maintex"), texture_meta); + job.insert(QStringLiteral("ove_mvpmat"), + NodeValue(NodeValue::k_matrix, real_matrix, this)); + job.set_interpolation(QStringLiteral("ove_maintex"), static_cast( - value[kInterpolationInput].toInt())); + value[k_interpolation_input].to_int())); // Use global resolution rather than texture resolution because this may result in a size change - job_to_push = Texture::Job(globals.vparams(), job); + job_to_push = Texture::job(globals.vparams(), job); } } - table->Push(NodeValue::kMatrix, QVariant::fromValue(generated_matrix), + table->push(NodeValue::k_matrix, QVariant::fromValue(generated_matrix), this); if (!job_to_push) { // Re-push whatever value we received - table->Push(texture_meta); + table->push(texture_meta); } else { - table->Push(NodeValue::kTexture, job_to_push, this); + table->push(NodeValue::k_texture, job_to_push, this); } } ShaderCode -TransformDistortNode::GetShaderCode(const ShaderRequest &request) const +TransformDistortNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request); @@ -151,70 +151,70 @@ TransformDistortNode::GetShaderCode(const ShaderRequest &request) const return ShaderCode(); } -void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x, - double y, const rational &time) +void TransformDistortNode::gizmo_drag_start(const NodeValueRow &row, double x, + double y, const Rational &time) { DraggableGizmo *gizmo = static_cast(sender()); if (gizmo == anchor_gizmo_) { gizmo_inverted_transform_ = - GenerateMatrix(row, true, true, false, row[kParentInput].toMatrix()) + generate_matrix(row, true, true, false, row[k_parent_input].to_matrix()) .toTransform() .inverted(); - } else if (IsAScaleGizmo(gizmo)) { + } else if (is_a_scale_gizmo(gizmo)) { // Dragging scale handle - TexturePtr tex = row[kTextureInput].toTexture(); + TexturePtr tex = row[k_texture_input].to_texture(); if (!tex) { return; } - gizmo_scale_uniform_ = row[kUniformScaleInput].toBool(); - gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() + - gizmo->GetGlobals().nonsquare_resolution() / 2) + gizmo_scale_uniform_ = row[k_uniform_scale_input].to_bool(); + gizmo_anchor_pt_ = (row[k_anchor_input].to_vec2() + + gizmo->get_globals().nonsquare_resolution() / 2) .toPointF(); - if (gizmo == point_gizmo_[kGizmoScaleTopLeft] || - gizmo == point_gizmo_[kGizmoScaleTopRight] || - gizmo == point_gizmo_[kGizmoScaleBottomLeft] || - gizmo == point_gizmo_[kGizmoScaleBottomRight]) { - gizmo_scale_axes_ = kGizmoScaleBoth; - } else if (gizmo == point_gizmo_[kGizmoScaleCenterLeft] || - gizmo == point_gizmo_[kGizmoScaleCenterRight]) { - gizmo_scale_axes_ = kGizmoScaleXOnly; + if (gizmo == point_gizmo_[k_gizmo_scale_top_left] || + gizmo == point_gizmo_[k_gizmo_scale_top_right] || + gizmo == point_gizmo_[k_gizmo_scale_bottom_left] || + gizmo == point_gizmo_[k_gizmo_scale_bottom_right]) { + gizmo_scale_axes_ = k_gizmo_scale_both; + } else if (gizmo == point_gizmo_[k_gizmo_scale_center_left] || + gizmo == point_gizmo_[k_gizmo_scale_center_right]) { + gizmo_scale_axes_ = k_gizmo_scale_x_only; } else { - gizmo_scale_axes_ = kGizmoScaleYOnly; + gizmo_scale_axes_ = k_gizmo_scale_y_only; } // Store texture size VideoParams texture_params = tex->params(); QVector2D texture_sz(texture_params.square_pixel_width(), texture_params.height()); - gizmo_scale_anchor_ = row[kAnchorInput].toVec2() + texture_sz / 2; + gizmo_scale_anchor_ = row[k_anchor_input].to_vec2() + texture_sz / 2; - if (gizmo == point_gizmo_[kGizmoScaleTopRight] || - gizmo == point_gizmo_[kGizmoScaleBottomRight] || - gizmo == point_gizmo_[kGizmoScaleCenterRight]) { + if (gizmo == point_gizmo_[k_gizmo_scale_top_right] || + gizmo == point_gizmo_[k_gizmo_scale_bottom_right] || + gizmo == point_gizmo_[k_gizmo_scale_center_right]) { // Right handles, flip X axis gizmo_scale_anchor_.setX(texture_sz.x() - gizmo_scale_anchor_.x()); } - if (gizmo == point_gizmo_[kGizmoScaleBottomLeft] || - gizmo == point_gizmo_[kGizmoScaleBottomRight] || - gizmo == point_gizmo_[kGizmoScaleBottomCenter]) { + if (gizmo == point_gizmo_[k_gizmo_scale_bottom_left] || + gizmo == point_gizmo_[k_gizmo_scale_bottom_right] || + gizmo == point_gizmo_[k_gizmo_scale_bottom_center]) { // Bottom handles, flip Y axis gizmo_scale_anchor_.setY(texture_sz.y() - gizmo_scale_anchor_.y()); } // Store current matrix gizmo_inverted_transform_ = - GenerateMatrix(row, true, true, true, row[kParentInput].toMatrix()) + generate_matrix(row, true, true, true, row[k_parent_input].to_matrix()) .toTransform() .inverted(); } else if (gizmo == rotation_gizmo_) { - gizmo_anchor_pt_ = (row[kAnchorInput].toVec2() + - gizmo->GetGlobals().nonsquare_resolution() / 2) + gizmo_anchor_pt_ = (row[k_anchor_input].to_vec2() + + gizmo->get_globals().nonsquare_resolution() / 2) .toPointF(); gizmo_start_angle_ = std::atan2(y - gizmo_anchor_pt_.y(), x - gizmo_anchor_pt_.x()); @@ -222,36 +222,36 @@ void TransformDistortNode::GizmoDragStart(const NodeValueRow &row, double x, gizmo_last_alt_angle_ = std::atan2(x - gizmo_anchor_pt_.x(), y - gizmo_anchor_pt_.y()); gizmo_rotate_wrap_ = 0; - gizmo_rotate_last_dir_ = kDirectionNone; + gizmo_rotate_last_dir_ = k_direction_none; } } -void TransformDistortNode::GizmoDragMove(double x, double y, +void TransformDistortNode::gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { DraggableGizmo *gizmo = static_cast(sender()); if (gizmo == poly_gizmo_) { - NodeInputDragger &x_drag = gizmo->GetDraggers()[0]; - NodeInputDragger &y_drag = gizmo->GetDraggers()[1]; + NodeInputDragger &x_drag = gizmo->get_draggers()[0]; + NodeInputDragger &y_drag = gizmo->get_draggers()[1]; - x_drag.Drag(x_drag.GetStartValue().toDouble() + x); - y_drag.Drag(y_drag.GetStartValue().toDouble() + y); + x_drag.drag(x_drag.get_start_value().toDouble() + x); + y_drag.drag(y_drag.get_start_value().toDouble() + y); } else if (gizmo == anchor_gizmo_) { - NodeInputDragger &x_anchor_drag = gizmo->GetDraggers()[0]; - NodeInputDragger &y_anchor_drag = gizmo->GetDraggers()[1]; - NodeInputDragger &x_pos_drag = gizmo->GetDraggers()[2]; - NodeInputDragger &y_pos_drag = gizmo->GetDraggers()[3]; + NodeInputDragger &x_anchor_drag = gizmo->get_draggers()[0]; + NodeInputDragger &y_anchor_drag = gizmo->get_draggers()[1]; + NodeInputDragger &x_pos_drag = gizmo->get_draggers()[2]; + NodeInputDragger &y_pos_drag = gizmo->get_draggers()[3]; QPointF inverted_movement(gizmo_inverted_transform_.map(QPointF(x, y))); - x_anchor_drag.Drag(x_anchor_drag.GetStartValue().toDouble() + + x_anchor_drag.drag(x_anchor_drag.get_start_value().toDouble() + inverted_movement.x()); - y_anchor_drag.Drag(y_anchor_drag.GetStartValue().toDouble() + + y_anchor_drag.drag(y_anchor_drag.get_start_value().toDouble() + inverted_movement.y()); - x_pos_drag.Drag(x_pos_drag.GetStartValue().toDouble() + x); - y_pos_drag.Drag(y_pos_drag.GetStartValue().toDouble() + y); + x_pos_drag.drag(x_pos_drag.get_start_value().toDouble() + x); + y_pos_drag.drag(y_pos_drag.get_start_value().toDouble() + y); } else if (gizmo == rotation_gizmo_) { double raw_angle = @@ -263,11 +263,11 @@ void TransformDistortNode::GizmoDragMove(double x, double y, // Detect rotation wrap around RotationDirection this_dir = - GetDirectionFromAngles(gizmo_last_angle_, raw_angle); + get_direction_from_angles(gizmo_last_angle_, raw_angle); RotationDirection alt_dir = - GetDirectionFromAngles(gizmo_last_alt_angle_, alt_angle); + get_direction_from_angles(gizmo_last_alt_angle_, alt_angle); - if (gizmo_rotate_last_dir_ != kDirectionNone && + if (gizmo_rotate_last_dir_ != k_direction_none && this_dir != gizmo_rotate_last_dir_) { if (alt_dir == gizmo_rotate_last_alt_dir_) { if ((raw_angle - gizmo_last_angle_) < 0) { @@ -292,10 +292,10 @@ void TransformDistortNode::GizmoDragMove(double x, double y, double rotation_difference = (current_angle - gizmo_start_angle_) * 57.2958; - NodeInputDragger &d = gizmo->GetDraggers()[0]; - d.Drag(d.GetStartValue().toDouble() + rotation_difference); + NodeInputDragger &d = gizmo->get_draggers()[0]; + d.drag(d.get_start_value().toDouble() + rotation_difference); - } else if (IsAScaleGizmo(gizmo)) { + } else if (is_a_scale_gizmo(gizmo)) { QPointF mouse_relative = gizmo_inverted_transform_.map(QPointF(x, y) - gizmo_anchor_pt_); @@ -304,38 +304,38 @@ void TransformDistortNode::GizmoDragMove(double x, double y, double y_scaled_movement = qAbs(mouse_relative.y() / gizmo_scale_anchor_.y()); - NodeInputDragger &x_drag = gizmo->GetDraggers()[0]; - NodeInputDragger &y_drag = gizmo->GetDraggers()[1]; + NodeInputDragger &x_drag = gizmo->get_draggers()[0]; + NodeInputDragger &y_drag = gizmo->get_draggers()[1]; switch (gizmo_scale_axes_) { - case kGizmoScaleXOnly: - x_drag.Drag(x_scaled_movement); + case k_gizmo_scale_x_only: + x_drag.drag(x_scaled_movement); break; - case kGizmoScaleYOnly: + case k_gizmo_scale_y_only: if (gizmo_scale_uniform_) { - x_drag.Drag(y_scaled_movement); + x_drag.drag(y_scaled_movement); } else { - y_drag.Drag(y_scaled_movement); + y_drag.drag(y_scaled_movement); } break; - case kGizmoScaleBoth: + case k_gizmo_scale_both: if (gizmo_scale_uniform_) { double distance = std::hypot(mouse_relative.x(), mouse_relative.y()); double texture_diag = std::hypot(gizmo_scale_anchor_.x(), gizmo_scale_anchor_.y()); - x_drag.Drag(qAbs(distance / texture_diag)); + x_drag.drag(qAbs(distance / texture_diag)); } else { - x_drag.Drag(x_scaled_movement); - y_drag.Drag(y_scaled_movement); + x_drag.drag(x_scaled_movement); + y_drag.drag(y_scaled_movement); } break; } } } -QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions( +QMatrix4x4 TransformDistortNode::adjust_matrix_by_resolutions( const QMatrix4x4 &mat, const QVector2D &sequence_res, const QVector2D &texture_res, const QVector2D &offset, AutoScaleType autoscale_type) @@ -356,8 +356,8 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions( adjusted_matrix.scale(texture_res.x() * 0.5, texture_res.y() * 0.5, 1.0); // If auto-scale is enabled, fit the texture to the sequence (without cropping) - if (autoscale_type != kAutoScaleNone) { - if (autoscale_type == kAutoScaleStretch) { + if (autoscale_type != k_auto_scale_none) { + if (autoscale_type == k_auto_scale_stretch) { adjusted_matrix.scale(sequence_res.x() / texture_res.x(), sequence_res.y() / texture_res.y(), 1.0); } else { @@ -368,7 +368,7 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions( double scale_by_y = sequence_res.y() / texture_res.y(); double autoscale_val; - if ((autoscale_type == kAutoScaleFit) == + if ((autoscale_type == k_auto_scale_fit) == (sequence_real_ar > footage_real_ar)) { // Scale by height. Either the sequence is wider than the footage or we're using fill and // cutting off the sides @@ -386,10 +386,10 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions( return adjusted_matrix; } -void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, +void TransformDistortNode::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { - TexturePtr tex = row[kTextureInput].toTexture(); + TexturePtr tex = row[k_texture_input].to_texture(); if (!tex) { return; } @@ -406,13 +406,13 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, // Retrieve autoscale value AutoScaleType autoscale = - static_cast(row[kAutoscaleInput].toInt()); + static_cast(row[k_autoscale_input].to_int()); // Fold values into a matrix for the rectangle QMatrix4x4 rectangle_matrix; rectangle_matrix.scale(sequence_half_res.x(), sequence_half_res.y()); - rectangle_matrix *= AdjustMatrixByResolutions( - GenerateMatrix(row, false, false, false, row[kParentInput].toMatrix()), + rectangle_matrix *= adjust_matrix_by_resolutions( + generate_matrix(row, false, false, false, row[k_parent_input].to_matrix()), sequence_res, tex_sz, tex_offset, autoscale); // Create rect and transform it @@ -422,63 +422,63 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, QTransform rectangle_transform = rectangle_matrix.toTransform(); QPolygonF r = rectangle_transform.map(points); r.translate(sequence_half_res_pt); - poly_gizmo_->SetPolygon(r); + poly_gizmo_->set_polygon(r); // Draw anchor point QMatrix4x4 anchor_matrix; anchor_matrix.scale(sequence_half_res.x(), sequence_half_res.y()); - anchor_matrix *= AdjustMatrixByResolutions( - GenerateMatrix(row, true, false, false, row[kParentInput].toMatrix()), + anchor_matrix *= adjust_matrix_by_resolutions( + generate_matrix(row, true, false, false, row[k_parent_input].to_matrix()), sequence_res, tex_sz, tex_offset, autoscale); - anchor_gizmo_->SetPoint(anchor_matrix.toTransform().map(QPointF(0, 0)) + + anchor_gizmo_->set_point(anchor_matrix.toTransform().map(QPointF(0, 0)) + sequence_half_res_pt); // Draw scale handles - point_gizmo_[kGizmoScaleTopLeft]->SetPoint( - CreateScalePoint(-1, -1, sequence_half_res_pt, rectangle_matrix)); - point_gizmo_[kGizmoScaleTopCenter]->SetPoint( - CreateScalePoint(0, -1, sequence_half_res_pt, rectangle_matrix)); - point_gizmo_[kGizmoScaleTopRight]->SetPoint( - CreateScalePoint(1, -1, sequence_half_res_pt, rectangle_matrix)); - point_gizmo_[kGizmoScaleBottomLeft]->SetPoint( - CreateScalePoint(-1, 1, sequence_half_res_pt, rectangle_matrix)); - point_gizmo_[kGizmoScaleBottomCenter]->SetPoint( - CreateScalePoint(0, 1, sequence_half_res_pt, rectangle_matrix)); - point_gizmo_[kGizmoScaleBottomRight]->SetPoint( - CreateScalePoint(1, 1, sequence_half_res_pt, rectangle_matrix)); - point_gizmo_[kGizmoScaleCenterLeft]->SetPoint( - CreateScalePoint(-1, 0, sequence_half_res_pt, rectangle_matrix)); - point_gizmo_[kGizmoScaleCenterRight]->SetPoint( - CreateScalePoint(1, 0, sequence_half_res_pt, rectangle_matrix)); + point_gizmo_[k_gizmo_scale_top_left]->set_point( + create_scale_point(-1, -1, sequence_half_res_pt, rectangle_matrix)); + point_gizmo_[k_gizmo_scale_top_center]->set_point( + create_scale_point(0, -1, sequence_half_res_pt, rectangle_matrix)); + point_gizmo_[k_gizmo_scale_top_right]->set_point( + create_scale_point(1, -1, sequence_half_res_pt, rectangle_matrix)); + point_gizmo_[k_gizmo_scale_bottom_left]->set_point( + create_scale_point(-1, 1, sequence_half_res_pt, rectangle_matrix)); + point_gizmo_[k_gizmo_scale_bottom_center]->set_point( + create_scale_point(0, 1, sequence_half_res_pt, rectangle_matrix)); + point_gizmo_[k_gizmo_scale_bottom_right]->set_point( + create_scale_point(1, 1, sequence_half_res_pt, rectangle_matrix)); + point_gizmo_[k_gizmo_scale_center_left]->set_point( + create_scale_point(-1, 0, sequence_half_res_pt, rectangle_matrix)); + point_gizmo_[k_gizmo_scale_center_right]->set_point( + create_scale_point(1, 0, sequence_half_res_pt, rectangle_matrix)); // Use offsets to make the appearance of values that start in the top left, even though we // really anchor around the center - SetInputProperty(kPositionInput, QStringLiteral("offset"), + set_input_property(k_position_input, QStringLiteral("offset"), sequence_half_res + tex_offset); - SetInputProperty(kAnchorInput, QStringLiteral("offset"), tex_sz * 0.5); + set_input_property(k_anchor_input, QStringLiteral("offset"), tex_sz * 0.5); } QTransform -TransformDistortNode::GizmoTransformation(const NodeValueRow &row, +TransformDistortNode::gizmo_transformation(const NodeValueRow &row, const NodeGlobals &globals) const { - if (TexturePtr texture = row[kTextureInput].toTexture()) { + if (TexturePtr texture = row[k_texture_input].to_texture()) { //auto m = GenerateMatrix(row, false, false, false, row[kParentInput].toMatrix()); - auto m = GenerateMatrix(row, false, false, false, QMatrix4x4()); - return GenerateAutoScaledMatrix(m, row, globals, texture->params()) + auto m = generate_matrix(row, false, false, false, QMatrix4x4()); + return generate_auto_scaled_matrix(m, row, globals, texture->params()) .toTransform(); } - return super::GizmoTransformation(row, globals); + return super::gizmo_transformation(row, globals); } -QPointF TransformDistortNode::CreateScalePoint(double x, double y, +QPointF TransformDistortNode::create_scale_point(double x, double y, const QPointF &half_res, const QMatrix4x4 &mat) { return mat.map(QPointF(x, y)) + half_res; } -QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix( +QMatrix4x4 TransformDistortNode::generate_auto_scaled_matrix( const QMatrix4x4 &generated_matrix, const NodeValueRow &value, const NodeGlobals &globals, const VideoParams &texture_params) const { @@ -486,16 +486,16 @@ QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix( QVector2D texture_res(texture_params.square_pixel_width(), texture_params.height()); AutoScaleType autoscale = - static_cast(value[kAutoscaleInput].toInt()); + static_cast(value[k_autoscale_input].to_int()); - return AdjustMatrixByResolutions(generated_matrix, sequence_res, + return adjust_matrix_by_resolutions(generated_matrix, sequence_res, texture_res, texture_params.offset(), autoscale); } -bool TransformDistortNode::IsAScaleGizmo(NodeGizmo *g) const +bool TransformDistortNode::is_a_scale_gizmo(NodeGizmo *g) const { - for (int i = 0; i < kGizmoScaleCount; i++) { + for (int i = 0; i < k_gizmo_scale_count; i++) { if (point_gizmo_[i] == g) { return true; } @@ -505,9 +505,9 @@ bool TransformDistortNode::IsAScaleGizmo(NodeGizmo *g) const } TransformDistortNode::RotationDirection -TransformDistortNode::GetDirectionFromAngles(double last, double current) +TransformDistortNode::get_direction_from_angles(double last, double current) { - return (current > last) ? kDirectionPositive : kDirectionNegative; + return (current > last) ? k_direction_positive : k_direction_negative; } } diff --git a/app/node/distort/transform/transformdistortnode.h b/app/node/distort/transform/transformdistortnode.h index adf98b5d8..6b8fec63e 100644 --- a/app/node/distort/transform/transformdistortnode.h +++ b/app/node/distort/transform/transformdistortnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRANSFORMDISTORTNODE_H -#define TRANSFORMDISTORTNODE_H +#ifndef OAK_TRANSFORMDISTORTNODE_H +#define OAK_TRANSFORMDISTORTNODE_H #include "node/generator/matrix/matrix.h" #include "node/gizmo/point.h" @@ -37,15 +37,15 @@ public: NODE_DEFAULT_FUNCTIONS(TransformDistortNode) - virtual QString Name() const override + virtual QString name() const override { return tr("Transform"); } - virtual QString ShortName() const override + virtual QString short_name() const override { // Override MatrixGenerator's short name "Ortho" - return Name(); + return name(); } virtual QString id() const override @@ -53,65 +53,65 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.transform"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryDistort }; + return { k_category_distort }; } - virtual QString Description() const override + virtual QString description() const override { return tr( "Transform an image in 2D space. Equivalent to multiplying by an orthographic matrix."); } - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; enum AutoScaleType { - kAutoScaleNone, - kAutoScaleFit, - kAutoScaleFill, - kAutoScaleStretch + k_auto_scale_none, + k_auto_scale_fit, + k_auto_scale_fill, + k_auto_scale_stretch }; - static QMatrix4x4 AdjustMatrixByResolutions( + static QMatrix4x4 adjust_matrix_by_resolutions( const QMatrix4x4 &mat, const QVector2D &sequence_res, const QVector2D &texture_res, const QVector2D &offset, - AutoScaleType autoscale_type = kAutoScaleNone); + AutoScaleType autoscale_type = k_auto_scale_none); - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; virtual QTransform - GizmoTransformation(const NodeValueRow &row, + gizmo_transformation(const NodeValueRow &row, const NodeGlobals &globals) const override; - static const QString kParentInput; - static const QString kTextureInput; - static const QString kAutoscaleInput; - static const QString kInterpolationInput; + static const QString k_parent_input; + static const QString k_texture_input; + static const QString k_autoscale_input; + static const QString k_interpolation_input; protected slots: - virtual void GizmoDragStart(const olive::NodeValueRow &row, double x, - double y, const olive::rational &time) override; + virtual void gizmo_drag_start(const olive::NodeValueRow &row, double x, + double y, const olive::Rational &time) override; - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) override; private: - static QPointF CreateScalePoint(double x, double y, const QPointF &half_res, + static QPointF create_scale_point(double x, double y, const QPointF &half_res, const QMatrix4x4 &mat); QMatrix4x4 - GenerateAutoScaledMatrix(const QMatrix4x4 &generated_matrix, + generate_auto_scaled_matrix(const QMatrix4x4 &generated_matrix, const NodeValueRow &db, const NodeGlobals &globals, const VideoParams &texture_params) const; - bool IsAScaleGizmo(NodeGizmo *g) const; + bool is_a_scale_gizmo(NodeGizmo *g) const; // Gizmo variables double gizmo_start_angle_; @@ -123,23 +123,23 @@ private: int gizmo_rotate_wrap_; enum RotationDirection { - kDirectionNone, - kDirectionPositive, // Clockwise - kDirectionNegative // Counter-clockwise + k_direction_none, + k_direction_positive, // Clockwise + k_direction_negative // Counter-clockwise }; - static RotationDirection GetDirectionFromAngles(double last, + static RotationDirection get_direction_from_angles(double last, double current); RotationDirection gizmo_rotate_last_dir_; RotationDirection gizmo_rotate_last_alt_dir_; - enum GizmoScaleType { kGizmoScaleXOnly, kGizmoScaleYOnly, kGizmoScaleBoth }; + enum GizmoScaleType { k_gizmo_scale_x_only, k_gizmo_scale_y_only, k_gizmo_scale_both }; GizmoScaleType gizmo_scale_axes_; QVector2D gizmo_scale_anchor_; // Gizmo on screen object storage - PointGizmo *point_gizmo_[kGizmoScaleCount]; + PointGizmo *point_gizmo_[k_gizmo_scale_count]; PointGizmo *anchor_gizmo_; PolygonGizmo *poly_gizmo_; ScreenGizmo *rotation_gizmo_; @@ -147,4 +147,4 @@ private: } -#endif // TRANSFORMDISTORTNODE_H +#endif // OAK_TRANSFORMDISTORTNODE_H diff --git a/app/node/distort/wave/wavedistortnode.cpp b/app/node/distort/wave/wavedistortnode.cpp index 1ba41e722..b28254cfa 100644 --- a/app/node/distort/wave/wavedistortnode.cpp +++ b/app/node/distort/wave/wavedistortnode.cpp @@ -24,30 +24,30 @@ namespace olive { -const QString WaveDistortNode::kTextureInput = QStringLiteral("tex_in"); -const QString WaveDistortNode::kFrequencyInput = QStringLiteral("frequency_in"); -const QString WaveDistortNode::kIntensityInput = QStringLiteral("intensity_in"); -const QString WaveDistortNode::kEvolutionInput = QStringLiteral("evolution_in"); -const QString WaveDistortNode::kVerticalInput = QStringLiteral("vertical_in"); +const QString WaveDistortNode::k_texture_input = QStringLiteral("tex_in"); +const QString WaveDistortNode::k_frequency_input = QStringLiteral("frequency_in"); +const QString WaveDistortNode::k_intensity_input = QStringLiteral("intensity_in"); +const QString WaveDistortNode::k_evolution_input = QStringLiteral("evolution_in"); +const QString WaveDistortNode::k_vertical_input = QStringLiteral("vertical_in"); #define super Node WaveDistortNode::WaveDistortNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kFrequencyInput, NodeValue::kFloat, 10); - AddInput(kIntensityInput, NodeValue::kFloat, 10); - AddInput(kEvolutionInput, NodeValue::kFloat, 0); + add_input(k_frequency_input, NodeValue::k_float, 10); + add_input(k_intensity_input, NodeValue::k_float, 10); + add_input(k_evolution_input, NodeValue::k_float, 0); - AddInput(kVerticalInput, NodeValue::kCombo, false); + add_input(k_vertical_input, NodeValue::k_combo, false); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -QString WaveDistortNode::Name() const +QString WaveDistortNode::name() const { return tr("Wave"); } @@ -57,48 +57,48 @@ QString WaveDistortNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.wave"); } -QVector WaveDistortNode::Category() const +QVector WaveDistortNode::category() const { - return { kCategoryDistort }; + return { k_category_distort }; } -QString WaveDistortNode::Description() const +QString WaveDistortNode::description() const { return tr("Distorts an image along a sine wave."); } -void WaveDistortNode::Retranslate() +void WaveDistortNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kFrequencyInput, tr("Frequency")); - SetInputName(kIntensityInput, tr("Intensity")); - SetInputName(kEvolutionInput, tr("Evolution")); - SetInputName(kVerticalInput, tr("Direction")); - SetComboBoxStrings(kVerticalInput, { tr("Horizontal"), tr("Vertical") }); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_frequency_input, tr("Frequency")); + set_input_name(k_intensity_input, tr("Intensity")); + set_input_name(k_evolution_input, tr("Evolution")); + set_input_name(k_vertical_input, tr("Direction")); + set_combo_box_strings(k_vertical_input, { tr("Horizontal"), tr("Vertical") }); } -ShaderCode WaveDistortNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode WaveDistortNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/wave.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/wave.frag")); } -void WaveDistortNode::Value(const NodeValueRow &value, +void WaveDistortNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If there's no texture, no need to run an operation - if (TexturePtr texture = value[kTextureInput].toTexture()) { + if (TexturePtr texture = value[k_texture_input].to_texture()) { // Only run shader if at least one of flip or flop are selected - if (!qIsNull(value[kIntensityInput].toDouble())) { - table->Push(NodeValue::kTexture, - Texture::Job(texture->params(), ShaderJob(value)), + if (!qIsNull(value[k_intensity_input].to_double())) { + table->push(NodeValue::k_texture, + Texture::job(texture->params(), ShaderJob(value)), this); } else { // If we're not flipping or flopping just push the texture - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } diff --git a/app/node/distort/wave/wavedistortnode.h b/app/node/distort/wave/wavedistortnode.h index f1b920be8..538c9627e 100644 --- a/app/node/distort/wave/wavedistortnode.h +++ b/app/node/distort/wave/wavedistortnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef WAVEDISTORTNODE_H -#define WAVEDISTORTNODE_H +#ifndef OAK_WAVEDISTORTNODE_H +#define OAK_WAVEDISTORTNODE_H #include "node/node.h" @@ -34,25 +34,25 @@ public: NODE_DEFAULT_FUNCTIONS(WaveDistortNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTextureInput; - static const QString kFrequencyInput; - static const QString kIntensityInput; - static const QString kEvolutionInput; - static const QString kVerticalInput; + static const QString k_texture_input; + static const QString k_frequency_input; + static const QString k_intensity_input; + static const QString k_evolution_input; + static const QString k_vertical_input; }; } -#endif // WAVEDISTORTNODE_H +#endif // OAK_WAVEDISTORTNODE_H diff --git a/app/node/effect/opacity/opacityeffect.cpp b/app/node/effect/opacity/opacityeffect.cpp index d722c7d3c..0f16cce14 100644 --- a/app/node/effect/opacity/opacityeffect.cpp +++ b/app/node/effect/opacity/opacityeffect.cpp @@ -26,65 +26,65 @@ namespace olive #define super Node -const QString OpacityEffect::kTextureInput = QStringLiteral("tex_in"); -const QString OpacityEffect::kValueInput = QStringLiteral("opacity_in"); +const QString OpacityEffect::k_texture_input = QStringLiteral("tex_in"); +const QString OpacityEffect::k_value_input = QStringLiteral("opacity_in"); OpacityEffect::OpacityEffect() { MathNode *math = new MathNode(); math->setParent(this); - math->SetOperation(MathNode::kOpMultiply); + math->set_operation(MathNode::k_op_multiply); - SetNodePositionInContext(math, QPointF(0, 0)); + set_node_position_in_context(math, QPointF(0, 0)); - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kValueInput, NodeValue::kFloat, 1.0); - SetInputProperty(kValueInput, QStringLiteral("view"), - FloatSlider::kPercentage); - SetInputProperty(kValueInput, QStringLiteral("min"), 0.0); - SetInputProperty(kValueInput, QStringLiteral("max"), 1.0); + add_input(k_value_input, NodeValue::k_float, 1.0); + set_input_property(k_value_input, QStringLiteral("view"), + FloatSlider::k_percentage); + set_input_property(k_value_input, QStringLiteral("min"), 0.0); + set_input_property(k_value_input, QStringLiteral("max"), 1.0); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -void OpacityEffect::Retranslate() +void OpacityEffect::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Texture")); - SetInputName(kValueInput, tr("Opacity")); + set_input_name(k_texture_input, tr("Texture")); + set_input_name(k_value_input, tr("Opacity")); } -ShaderCode OpacityEffect::GetShaderCode(const ShaderRequest &request) const +ShaderCode OpacityEffect::get_shader_code(const ShaderRequest &request) const { if (request.id == QStringLiteral("rgbmult")) { return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/opacity_rgb.frag")); + FileFunctions::read_file_as_string(":/shaders/opacity_rgb.frag")); } else { return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/opacity.frag")); + FileFunctions::read_file_as_string(":/shaders/opacity.frag")); } } -void OpacityEffect::Value(const NodeValueRow &value, const NodeGlobals &globals, +void OpacityEffect::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If there's no texture, no need to run an operation - if (TexturePtr tex = value[kTextureInput].toTexture()) { - if (TexturePtr opacity_tex = value[kValueInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { + if (TexturePtr opacity_tex = value[k_value_input].to_texture()) { ShaderJob job(value); - job.SetShaderID(QStringLiteral("rgbmult")); - table->Push(NodeValue::kTexture, tex->toJob(job), this); - } else if (!qFuzzyCompare(value[kValueInput].toDouble(), 1.0)) { - table->Push(NodeValue::kTexture, tex->toJob(ShaderJob(value)), + job.set_shader_id(QStringLiteral("rgbmult")); + table->push(NodeValue::k_texture, tex->to_job(job), this); + } else if (!qFuzzyCompare(value[k_value_input].to_double(), 1.0)) { + table->push(NodeValue::k_texture, tex->to_job(ShaderJob(value)), this); } else { // 1.0 float is a no-op, so just push the texture - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } diff --git a/app/node/effect/opacity/opacityeffect.h b/app/node/effect/opacity/opacityeffect.h index 8224565bb..c995e037b 100644 --- a/app/node/effect/opacity/opacityeffect.h +++ b/app/node/effect/opacity/opacityeffect.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef OPACITYEFFECT_H -#define OPACITYEFFECT_H +#ifndef OAK_OPACITYEFFECT_H +#define OAK_OPACITYEFFECT_H #include "node/group/group.h" @@ -30,7 +30,7 @@ public: NODE_DEFAULT_FUNCTIONS(OpacityEffect) - virtual QString Name() const override + virtual QString name() const override { return tr("Opacity"); } @@ -40,28 +40,28 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.opacity"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryFilter }; + return { k_category_filter }; } - virtual QString Description() const override + virtual QString description() const override { return tr( "Alter a video's opacity.\n\nThis is equivalent to multiplying a video by a number between 0.0 and 1.0."); } - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTextureInput; - static const QString kValueInput; + static const QString k_texture_input; + static const QString k_value_input; }; } -#endif // OPACITYEFFECT_H +#endif // OAK_OPACITYEFFECT_H diff --git a/app/node/factory.cpp b/app/node/factory.cpp index c91a9303d..28e672162 100644 --- a/app/node/factory.cpp +++ b/app/node/factory.cpp @@ -35,7 +35,7 @@ #include "color/ociogradingtransformlinear/ociogradingtransformlinear.h" #include "color/ociolut/ociolut.h" #include "color/threewaycolor/threewaycolor.h" -#include "common/Current.h" +#include "common/current.h" #include "distort/cornerpin/cornerpindistortnode.h" #include "distort/crop/cropdistortnode.h" #include "distort/flip/flipdistortnode.h" @@ -69,8 +69,8 @@ #include "math/trigonometry/trigonometry.h" #include "output/track/track.h" #include "output/viewer/viewer.h" -#include "pluginSupport/OliveHost.h" -#include "plugins/Plugin.h" +#include "pluginSupport/olivehost.h" +#include "plugins/plugin.h" #include "project/folder/folder.h" #include "project/footage/footage.h" #include "project/sequence/sequence.h" @@ -81,58 +81,58 @@ namespace olive { -QList NodeFactory::library_; +QList NodeFactory::library; -void NodeFactory::Initialize() +void NodeFactory::initialize() { - Destroy(); + destroy(); // Add internal types - for (int i = 0; i < kInternalNodeCount; i++) { - Node *created_node = CreateFromFactoryIndex(static_cast(i)); + for (int i = 0; i < k_internal_node_count; i++) { + Node *created_node = create_from_factory_index(static_cast(i)); - library_.append(created_node); + library.append(created_node); } - RegisterPluginNodes(); + register_plugin_nodes(); } -void NodeFactory::Destroy() +void NodeFactory::destroy() { - qDeleteAll(library_); - library_.clear(); + qDeleteAll(library); + library.clear(); } -Menu *NodeFactory::CreateMenu(QWidget *parent, bool create_none_item, +Menu *NodeFactory::create_menu(QWidget *parent, bool create_none_item, Node::CategoryID restrict_to, uint64_t restrict_flags) { Menu *menu = new Menu(parent); menu->setToolTipsVisible(true); - for (int i = 0; i < library_.size(); i++) { - Node *n = library_.at(i); + for (int i = 0; i < library.size(); i++) { + Node *n = library.at(i); - if (restrict_to != Node::kCategoryUnknown && - !n->Category().contains(restrict_to)) { + if (restrict_to != Node::k_category_unknown && + !n->category().contains(restrict_to)) { // Skip this node continue; } - if (restrict_flags && !(n->GetFlags() & restrict_flags)) { + if (restrict_flags && !(n->get_flags() & restrict_flags)) { continue; } - if (n->GetFlags() & Node::kDontShowInCreateMenu) { + if (n->get_flags() & Node::k_dont_show_in_create_menu) { continue; } // Make sure nodes are up-to-date with the current translation - n->Retranslate(); + n->retranslate(); - QString category_name = Node::GetCategoryName( - n->Category().isEmpty() ? Node::kCategoryUnknown : - n->Category().first()); + QString category_name = Node::get_category_name( + n->category().isEmpty() ? Node::k_category_unknown : + n->category().first()); // Find or create top-level category menu Menu *top_menu = nullptr; @@ -145,13 +145,13 @@ Menu *NodeFactory::CreateMenu(QWidget *parent, bool create_none_item, } if (!top_menu) { top_menu = new Menu(category_name, menu); - menu->InsertAlphabetically(top_menu); + menu->insert_alphabetically(top_menu); } // Determine final destination (support secondary grouping) Menu *destination = top_menu; - QString sub = n->SubCategory(); - if (!sub.isEmpty() && n->Category().contains(Node::kCategoryOpenFX)) { + QString sub = n->sub_category(); + if (!sub.isEmpty() && n->category().contains(Node::k_category_open_fx)) { QList sub_actions = top_menu->actions(); foreach (QAction *action, sub_actions) { if (action->menu() && action->menu()->title() == sub) { @@ -161,14 +161,14 @@ Menu *NodeFactory::CreateMenu(QWidget *parent, bool create_none_item, } if (destination == top_menu) { destination = new Menu(sub, top_menu); - top_menu->InsertAlphabetically(destination); + top_menu->insert_alphabetically(destination); } } // Add entry to menu - QAction *a = destination->InsertAlphabetically(n->Name()); + QAction *a = destination->insert_alphabetically(n->name()); a->setData(i); - a->setToolTip(n->Description()); + a->setToolTip(n->description()); } if (create_none_item) { @@ -196,7 +196,7 @@ Node *NodeFactory::CreateFromMenuAction(QAction *action) return nullptr; } - return library_.at(index)->copy(); + return library.at(index)->copy(); } QString NodeFactory::GetIDFromMenuAction(QAction *action) @@ -207,15 +207,15 @@ QString NodeFactory::GetIDFromMenuAction(QAction *action) return QString(); } - return library_.at(action->data().toInt())->id(); + return library.at(action->data().toInt())->id(); } -QString NodeFactory::GetNameFromID(const QString &id) +QString NodeFactory::get_name_from_id(const QString &id) { if (!id.isEmpty()) { - foreach (Node *n, library_) { + foreach (Node *n, library) { if (n->id() == id) { - return n->Name(); + return n->name(); } } } @@ -223,12 +223,12 @@ QString NodeFactory::GetNameFromID(const QString &id) return QString(); } -Node *NodeFactory::CreateFromID(const QString &id) +Node *NodeFactory::create_from_id(const QString &id) { QString resolved_id = id; // Node IDs renamed after older project files were written - static const QHash kLegacyIDs = { + static const QHash k_legacy_i_ds = { { QStringLiteral("org.oliveeditor.Olive.flip"), QStringLiteral("org.olivevideoeditor.Olive.flip") }, { QStringLiteral("org.oliveeditor.Olive.ripple"), @@ -240,9 +240,9 @@ Node *NodeFactory::CreateFromID(const QString &id) { QStringLiteral("org.oliveeditor.Olive.wave"), QStringLiteral("org.olivevideoeditor.Olive.wave") }, }; - resolved_id = kLegacyIDs.value(id, id); + resolved_id = k_legacy_i_ds.value(id, id); - foreach (Node *n, library_) { + foreach (Node *n, library) { if (n->id() == resolved_id) { return n->copy(); } @@ -251,10 +251,10 @@ Node *NodeFactory::CreateFromID(const QString &id) return nullptr; } -void NodeFactory::RegisterPluginNodes() +void NodeFactory::register_plugin_nodes() { QSet existing_ids; - for (Node *node : library_) { + for (Node *node : library) { existing_ids.insert(node->id()); } @@ -287,118 +287,118 @@ void NodeFactory::RegisterPluginNodes() } plugin::PluginNode *plugin_node = new plugin::PluginNode(instance); - library_.append(plugin_node); + library.append(plugin_node); existing_ids.insert(plugin_id); } } -Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id) +Node *NodeFactory::create_from_factory_index(const NodeFactory::InternalID &id) { switch (id) { - case kClipBlock: + case k_clip_block: return new ClipBlock(); - case kGapBlock: + case k_gap_block: return new GapBlock(); - case kPolygonGenerator: + case k_polygon_generator: return new PolygonGenerator(); - case kMatrixGenerator: + case k_matrix_generator: return new MatrixGenerator(); - case kTransformDistort: + case k_transform_distort: return new TransformDistortNode(); - case kTrackOutput: + case k_track_output: return new Track(); - case kViewerOutput: + case k_viewer_output: return new ViewerOutput(); - case kAudioVolume: + case k_audio_volume: return new VolumeNode(); - case kAudioPanning: + case k_audio_panning: return new PanNode(); - case kMath: + case k_math: return new MathNode(); - case kTrigonometry: + case k_trigonometry: return new TrigonometryNode(); - case kTime: + case k_time: return new TimeInput(); - case kBlurFilter: + case k_blur_filter: return new BlurFilterNode(); - case kSolidGenerator: + case k_solid_generator: return new SolidGenerator(); - case kMerge: + case k_merge: return new MergeNode(); - case kStrokeFilter: + case k_stroke_filter: return new StrokeFilterNode(); - case kTextGeneratorV1: + case k_text_generator_v1: return new TextGeneratorV1(); - case kTextGeneratorV2: + case k_text_generator_v2: return new TextGeneratorV2(); - case kTextGeneratorV3: + case k_text_generator_v3: return new TextGeneratorV3(); - case kCrossDissolveTransition: + case k_cross_dissolve_transition: return new CrossDissolveTransition(); - case kDipToColorTransition: + case k_dip_to_color_transition: return new DipToColorTransition(); - case kMosaicFilter: + case k_mosaic_filter: return new MosaicFilterNode(); - case kCropDistort: + case k_crop_distort: return new CropDistortNode(); - case kProjectFootage: + case k_project_footage: return new Footage(); - case kProjectFolder: + case k_project_folder: return new Folder(); - case kProjectSequence: + case k_project_sequence: return new Sequence(); - case kValueNode: + case k_value_node: return new ValueNode(); - case kTimeRemapNode: + case k_time_remap_node: return new TimeRemapNode(); - case kSubtitleBlock: + case k_subtitle_block: return new SubtitleBlock(); - case kShapeGenerator: + case k_shape_generator: return new ShapeNode(); - case kColorDifferenceKeyKeying: + case k_color_difference_key_keying: return new ColorDifferenceKeyNode(); - case kDespillKeying: + case k_despill_keying: return new DespillNode(); - case kGroupNode: + case k_group_node: return new NodeGroup(); - case kOpacityEffect: + case k_opacity_effect: return new OpacityEffect(); - case kFlipDistort: + case k_flip_distort: return new FlipDistortNode(); - case kNoiseGenerator: + case k_noise_generator: return new NoiseGeneratorNode(); - case kTimeOffsetNode: + case k_time_offset_node: return new TimeOffsetNode(); - case kCornerPinDistort: + case k_corner_pin_distort: return new CornerPinDistortNode(); - case kDisplayTransform: + case k_display_transform: return new DisplayTransformNode(); - case kOCIOGradingTransformLinear: + case k_ocio_grading_transform_linear: return new OCIOGradingTransformLinearNode(); - case kOCIOLut: + case k_ocio_lut: return new OCIOLutNode(); - case kThreeWayColor: + case k_three_way_color: return new ThreeWayColorNode(); - case kChromaKey: + case k_chroma_key: return new ChromaKeyNode(); - case kMaskDistort: + case k_mask_distort: return new MaskDistortNode(); - case kDropShadowFilter: + case k_drop_shadow_filter: return new DropShadowFilter(); - case kTimeFormat: + case k_time_format: return new TimeFormatNode(); - case kWaveDistort: + case k_wave_distort: return new WaveDistortNode(); - case kTileDistort: + case k_tile_distort: return new TileDistortNode(); - case kSwirlDistort: + case k_swirl_distort: return new SwirlDistortNode(); - case kRippleDistort: + case k_ripple_distort: return new RippleDistortNode(); - case kMulticamNode: + case k_multicam_node: return new MultiCamNode(); - case kInternalNodeCount: + case k_internal_node_count: break; } diff --git a/app/node/factory.h b/app/node/factory.h index 5651c02a9..50fb72bce 100644 --- a/app/node/factory.h +++ b/app/node/factory.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEFACTORY_H -#define NODEFACTORY_H +#ifndef OAK_NODEFACTORY_H +#define OAK_NODEFACTORY_H #include @@ -33,88 +33,88 @@ namespace olive class NodeFactory { public: enum InternalID { - kViewerOutput, - kClipBlock, - kGapBlock, - kPolygonGenerator, - kMatrixGenerator, - kTransformDistort, - kTrackOutput, - kAudioVolume, - kAudioPanning, - kMath, - kTime, - kTrigonometry, - kBlurFilter, - kSolidGenerator, - kMerge, - kStrokeFilter, - kTextGeneratorV1, - kTextGeneratorV2, - kTextGeneratorV3, - kCrossDissolveTransition, - kDipToColorTransition, - kMosaicFilter, - kCropDistort, - kProjectFootage, - kProjectFolder, - kProjectSequence, - kValueNode, - kTimeRemapNode, - kSubtitleBlock, - kShapeGenerator, - kColorDifferenceKeyKeying, - kDespillKeying, - kGroupNode, - kOpacityEffect, - kFlipDistort, - kNoiseGenerator, - kTimeOffsetNode, - kCornerPinDistort, - kDisplayTransform, - kOCIOGradingTransformLinear, - kOCIOLut, - kThreeWayColor, - kChromaKey, - kMaskDistort, - kDropShadowFilter, - kTimeFormat, - kWaveDistort, - kRippleDistort, - kTileDistort, - kSwirlDistort, - kMulticamNode, + k_viewer_output, + k_clip_block, + k_gap_block, + k_polygon_generator, + k_matrix_generator, + k_transform_distort, + k_track_output, + k_audio_volume, + k_audio_panning, + k_math, + k_time, + k_trigonometry, + k_blur_filter, + k_solid_generator, + k_merge, + k_stroke_filter, + k_text_generator_v1, + k_text_generator_v2, + k_text_generator_v3, + k_cross_dissolve_transition, + k_dip_to_color_transition, + k_mosaic_filter, + k_crop_distort, + k_project_footage, + k_project_folder, + k_project_sequence, + k_value_node, + k_time_remap_node, + k_subtitle_block, + k_shape_generator, + k_color_difference_key_keying, + k_despill_keying, + k_group_node, + k_opacity_effect, + k_flip_distort, + k_noise_generator, + k_time_offset_node, + k_corner_pin_distort, + k_display_transform, + k_ocio_grading_transform_linear, + k_ocio_lut, + k_three_way_color, + k_chroma_key, + k_mask_distort, + k_drop_shadow_filter, + k_time_format, + k_wave_distort, + k_ripple_distort, + k_tile_distort, + k_swirl_distort, + k_multicam_node, // Count value - kInternalNodeCount + k_internal_node_count }; NodeFactory() = default; - static void Initialize(); + static void initialize(); - static void Destroy(); + static void destroy(); static Menu * - CreateMenu(QWidget *parent, bool create_none_item = false, - Node::CategoryID restrict_to = Node::kCategoryUnknown, + create_menu(QWidget *parent, bool create_none_item = false, + Node::CategoryID restrict_to = Node::k_category_unknown, uint64_t restrict_flags = 0); static Node *CreateFromMenuAction(QAction *action); static QString GetIDFromMenuAction(QAction *action); - static QString GetNameFromID(const QString &id); + static QString get_name_from_id(const QString &id); - static Node *CreateFromID(const QString &id); - static void RegisterPluginNodes(); + static Node *create_from_id(const QString &id); + static void register_plugin_nodes(); - static Node *CreateFromFactoryIndex(const InternalID &id); + static Node *create_from_factory_index(const InternalID &id); private: - static QList library_; + static QList library; }; } -#endif // NODEFACTORY_H +#endif // OAK_NODEFACTORY_H diff --git a/app/node/filter/blur/blur.cpp b/app/node/filter/blur/blur.cpp index 094544844..12c6dc875 100644 --- a/app/node/filter/blur/blur.cpp +++ b/app/node/filter/blur/blur.cpp @@ -24,67 +24,67 @@ namespace olive { -const QString BlurFilterNode::kTextureInput = QStringLiteral("tex_in"); -const QString BlurFilterNode::kMethodInput = QStringLiteral("method_in"); -const QString BlurFilterNode::kRadiusInput = QStringLiteral("radius_in"); -const QString BlurFilterNode::kHorizInput = QStringLiteral("horiz_in"); -const QString BlurFilterNode::kVertInput = QStringLiteral("vert_in"); -const QString BlurFilterNode::kRepeatEdgePixelsInput = +const QString BlurFilterNode::k_texture_input = QStringLiteral("tex_in"); +const QString BlurFilterNode::k_method_input = QStringLiteral("method_in"); +const QString BlurFilterNode::k_radius_input = QStringLiteral("radius_in"); +const QString BlurFilterNode::k_horiz_input = QStringLiteral("horiz_in"); +const QString BlurFilterNode::k_vert_input = QStringLiteral("vert_in"); +const QString BlurFilterNode::k_repeat_edge_pixels_input = QStringLiteral("repeat_edge_pixels_in"); -const QString BlurFilterNode::kDirectionalDegreesInput = +const QString BlurFilterNode::k_directional_degrees_input = QStringLiteral("directional_degrees_in"); -const QString BlurFilterNode::kRadialCenterInput = +const QString BlurFilterNode::k_radial_center_input = QStringLiteral("radial_center_in"); #define super Node BlurFilterNode::BlurFilterNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - Method default_method = kGaussian; + Method default_method = k_gaussian; - AddInput(kMethodInput, NodeValue::kCombo, default_method, - InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); + add_input(k_method_input, NodeValue::k_combo, default_method, + InputFlags(k_input_flag_not_keyframable | k_input_flag_not_connectable)); - AddInput(kRadiusInput, NodeValue::kFloat, 10.0); - SetInputProperty(kRadiusInput, QStringLiteral("min"), 0.0); + add_input(k_radius_input, NodeValue::k_float, 10.0); + set_input_property(k_radius_input, QStringLiteral("min"), 0.0); { // Box and gaussian only - AddInput(kHorizInput, NodeValue::kBoolean, true); - AddInput(kVertInput, NodeValue::kBoolean, true); + add_input(k_horiz_input, NodeValue::k_boolean, true); + add_input(k_vert_input, NodeValue::k_boolean, true); } { // Directional only - AddInput(kDirectionalDegreesInput, NodeValue::kFloat, 0.0); + add_input(k_directional_degrees_input, NodeValue::k_float, 0.0); } { // Radial only - AddInput(kRadialCenterInput, NodeValue::kVec2, QVector2D(0, 0)); + add_input(k_radial_center_input, NodeValue::k_vec2, QVector2D(0, 0)); } - UpdateInputs(default_method); + update_inputs(default_method); - AddInput(kRepeatEdgePixelsInput, NodeValue::kBoolean, true); + add_input(k_repeat_edge_pixels_input, NodeValue::k_boolean, true); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); - radial_center_gizmo_ = AddDraggableGizmo(); - radial_center_gizmo_->SetShape(PointGizmo::kAnchorPoint); - radial_center_gizmo_->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kRadialCenterInput), 0)); - radial_center_gizmo_->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kRadialCenterInput), 1)); + radial_center_gizmo_ = add_draggable_gizmo(); + radial_center_gizmo_->set_shape(PointGizmo::k_anchor_point); + radial_center_gizmo_->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_radial_center_input), 0)); + radial_center_gizmo_->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_radial_center_input), 1)); } -QString BlurFilterNode::Name() const +QString BlurFilterNode::name() const { return tr("Blur"); } @@ -94,58 +94,58 @@ QString BlurFilterNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.blur"); } -QVector BlurFilterNode::Category() const +QVector BlurFilterNode::category() const { - return { kCategoryFilter }; + return { k_category_filter }; } -QString BlurFilterNode::Description() const +QString BlurFilterNode::description() const { return tr("Blurs an image."); } -void BlurFilterNode::Retranslate() +void BlurFilterNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kMethodInput, tr("Method")); - SetComboBoxStrings(kMethodInput, { tr("Box"), tr("Gaussian"), + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_method_input, tr("Method")); + set_combo_box_strings(k_method_input, { tr("Box"), tr("Gaussian"), tr("Directional"), tr("Radial") }); - SetInputName(kRadiusInput, tr("Radius")); - SetInputName(kHorizInput, tr("Horizontal")); - SetInputName(kVertInput, tr("Vertical")); - SetInputName(kRepeatEdgePixelsInput, tr("Repeat Edge Pixels")); + set_input_name(k_radius_input, tr("Radius")); + set_input_name(k_horiz_input, tr("Horizontal")); + set_input_name(k_vert_input, tr("Vertical")); + set_input_name(k_repeat_edge_pixels_input, tr("Repeat Edge Pixels")); - SetInputName(kDirectionalDegreesInput, tr("Direction")); - SetInputName(kRadialCenterInput, tr("Center")); + set_input_name(k_directional_degrees_input, tr("Direction")); + set_input_name(k_radial_center_input, tr("Center")); } -ShaderCode BlurFilterNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode BlurFilterNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/blur.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/blur.frag")); } -void BlurFilterNode::Value(const NodeValueRow &value, +void BlurFilterNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If there's no texture, no need to run an operation - if (TexturePtr tex = value[kTextureInput].toTexture()) { - Method method = static_cast(value[kMethodInput].toInt()); + if (TexturePtr tex = value[k_texture_input].to_texture()) { + Method method = static_cast(value[k_method_input].to_int()); bool can_push_job = true; int iterations = 1; // Check if radius is > 0 - if (value[kRadiusInput].toDouble() > 0.0) { + if (value[k_radius_input].to_double() > 0.0) { // Method-specific considerations switch (method) { - case kBox: - case kGaussian: { - bool horiz = value[kHorizInput].toBool(); - bool vert = value[kVertInput].toBool(); + case k_box: + case k_gaussian: { + bool horiz = value[k_horiz_input].to_bool(); + bool vert = value[k_vert_input].to_bool(); if (!horiz && !vert) { // Disable job if horiz and vert are unchecked @@ -156,8 +156,8 @@ void BlurFilterNode::Value(const NodeValueRow &value, } break; } - case kDirectional: - case kRadial: + case k_directional: + case k_radial: break; } } else { @@ -166,71 +166,71 @@ void BlurFilterNode::Value(const NodeValueRow &value, if (can_push_job) { ShaderJob job(value); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, tex->virtual_resolution(), + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, tex->virtual_resolution(), this)); - job.SetIterations(iterations, kTextureInput); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + job.set_iterations(iterations, k_texture_input); + table->push(NodeValue::k_texture, tex->to_job(job), this); } else { // If we're not performing the blur job, just push the texture - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } -void BlurFilterNode::UpdateGizmoPositions(const NodeValueRow &row, +void BlurFilterNode::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { - if (TexturePtr tex = row[kTextureInput].toTexture()) { - if (row[kMethodInput].toInt() == kRadial) { + if (TexturePtr tex = row[k_texture_input].to_texture()) { + if (row[k_method_input].to_int() == k_radial) { const QVector2D &sequence_res = tex->virtual_resolution(); QVector2D sequence_half_res = sequence_res * 0.5; - radial_center_gizmo_->SetVisible(true); - radial_center_gizmo_->SetPoint( + radial_center_gizmo_->set_visible(true); + radial_center_gizmo_->set_point( sequence_half_res.toPointF() + - row[kRadialCenterInput].toVec2().toPointF()); + row[k_radial_center_input].to_vec2().toPointF()); - SetInputProperty(kRadialCenterInput, QStringLiteral("offset"), + set_input_property(k_radial_center_input, QStringLiteral("offset"), sequence_half_res); } else { - radial_center_gizmo_->SetVisible(false); + radial_center_gizmo_->set_visible(false); } } } -void BlurFilterNode::GizmoDragMove(double x, double y, +void BlurFilterNode::gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { DraggableGizmo *gizmo = static_cast(sender()); if (gizmo == radial_center_gizmo_) { - NodeInputDragger &x_drag = gizmo->GetDraggers()[0]; - NodeInputDragger &y_drag = gizmo->GetDraggers()[1]; + NodeInputDragger &x_drag = gizmo->get_draggers()[0]; + NodeInputDragger &y_drag = gizmo->get_draggers()[1]; - x_drag.Drag(x_drag.GetStartValue().toDouble() + x); - y_drag.Drag(y_drag.GetStartValue().toDouble() + y); + x_drag.drag(x_drag.get_start_value().toDouble() + x); + y_drag.drag(y_drag.get_start_value().toDouble() + y); } } void BlurFilterNode::InputValueChangedEvent(const QString &input, int element) { - if (input == kMethodInput) { - UpdateInputs(GetMethod()); + if (input == k_method_input) { + update_inputs(get_method()); } super::InputValueChangedEvent(input, element); } -void BlurFilterNode::UpdateInputs(Method method) +void BlurFilterNode::update_inputs(Method method) { - SetInputFlag(kHorizInput, kInputFlagHidden, - !(method == kBox || method == kGaussian)); - SetInputFlag(kVertInput, kInputFlagHidden, - !(method == kBox || method == kGaussian)); - SetInputFlag(kDirectionalDegreesInput, kInputFlagHidden, - !(method == kDirectional)); - SetInputFlag(kRadialCenterInput, kInputFlagHidden, !(method == kRadial)); + set_input_flag(k_horiz_input, k_input_flag_hidden, + !(method == k_box || method == k_gaussian)); + set_input_flag(k_vert_input, k_input_flag_hidden, + !(method == k_box || method == k_gaussian)); + set_input_flag(k_directional_degrees_input, k_input_flag_hidden, + !(method == k_directional)); + set_input_flag(k_radial_center_input, k_input_flag_hidden, !(method == k_radial)); } } diff --git a/app/node/filter/blur/blur.h b/app/node/filter/blur/blur.h index 35be91e5f..d4f5b9b8c 100644 --- a/app/node/filter/blur/blur.h +++ b/app/node/filter/blur/blur.h @@ -19,8 +19,8 @@ ***/ -#ifndef BLURFILTERNODE_H -#define BLURFILTERNODE_H +#ifndef OAK_BLURFILTERNODE_H +#define OAK_BLURFILTERNODE_H #include "node/gizmo/point.h" #include "node/node.h" @@ -33,43 +33,43 @@ class BlurFilterNode : public Node { public: BlurFilterNode(); - enum Method { kBox, kGaussian, kDirectional, kRadial }; + enum Method { k_box, k_gaussian, k_directional, k_radial }; NODE_DEFAULT_FUNCTIONS(BlurFilterNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - Method GetMethod() const + Method get_method() const { - return static_cast(GetStandardValue(kMethodInput).toInt()); + return static_cast(get_standard_value(k_method_input).toInt()); } - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; - static const QString kTextureInput; - static const QString kMethodInput; - static const QString kRadiusInput; - static const QString kHorizInput; - static const QString kVertInput; - static const QString kRepeatEdgePixelsInput; + static const QString k_texture_input; + static const QString k_method_input; + static const QString k_radius_input; + static const QString k_horiz_input; + static const QString k_vert_input; + static const QString k_repeat_edge_pixels_input; - static const QString kDirectionalDegreesInput; + static const QString k_directional_degrees_input; - static const QString kRadialCenterInput; + static const QString k_radial_center_input; protected slots: - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) override; protected: @@ -77,11 +77,11 @@ protected: int element) override; private: - void UpdateInputs(Method method); + void update_inputs(Method method); PointGizmo *radial_center_gizmo_; }; } -#endif // BLURFILTERNODE_H +#endif // OAK_BLURFILTERNODE_H diff --git a/app/node/filter/dropshadow/dropshadowfilter.cpp b/app/node/filter/dropshadow/dropshadowfilter.cpp index 266ec71d4..6f66fe29e 100644 --- a/app/node/filter/dropshadow/dropshadowfilter.cpp +++ b/app/node/filter/dropshadow/dropshadowfilter.cpp @@ -28,79 +28,79 @@ namespace olive #define super Node -const QString DropShadowFilter::kTextureInput = QStringLiteral("tex_in"); -const QString DropShadowFilter::kColorInput = QStringLiteral("color_in"); -const QString DropShadowFilter::kDistanceInput = QStringLiteral("distance_in"); -const QString DropShadowFilter::kAngleInput = QStringLiteral("angle_in"); -const QString DropShadowFilter::kSoftnessInput = QStringLiteral("radius_in"); -const QString DropShadowFilter::kOpacityInput = QStringLiteral("opacity_in"); -const QString DropShadowFilter::kFastInput = QStringLiteral("fast_in"); +const QString DropShadowFilter::k_texture_input = QStringLiteral("tex_in"); +const QString DropShadowFilter::k_color_input = QStringLiteral("color_in"); +const QString DropShadowFilter::k_distance_input = QStringLiteral("distance_in"); +const QString DropShadowFilter::k_angle_input = QStringLiteral("angle_in"); +const QString DropShadowFilter::k_softness_input = QStringLiteral("radius_in"); +const QString DropShadowFilter::k_opacity_input = QStringLiteral("opacity_in"); +const QString DropShadowFilter::k_fast_input = QStringLiteral("fast_in"); DropShadowFilter::DropShadowFilter() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kColorInput, NodeValue::kColor, + add_input(k_color_input, NodeValue::k_color, QVariant::fromValue(Color(0.0, 0.0, 0.0))); - AddInput(kDistanceInput, NodeValue::kFloat, 10.0); + add_input(k_distance_input, NodeValue::k_float, 10.0); - AddInput(kAngleInput, NodeValue::kFloat, 135.0); + add_input(k_angle_input, NodeValue::k_float, 135.0); - AddInput(kSoftnessInput, NodeValue::kFloat, 10.0); - SetInputProperty(kSoftnessInput, QStringLiteral("min"), 0.0); + add_input(k_softness_input, NodeValue::k_float, 10.0); + set_input_property(k_softness_input, QStringLiteral("min"), 0.0); - AddInput(kOpacityInput, NodeValue::kFloat, 1.0); - SetInputProperty(kOpacityInput, QStringLiteral("min"), 0.0); - SetInputProperty(kOpacityInput, QStringLiteral("view"), - FloatSlider::kPercentage); + add_input(k_opacity_input, NodeValue::k_float, 1.0); + set_input_property(k_opacity_input, QStringLiteral("min"), 0.0); + set_input_property(k_opacity_input, QStringLiteral("view"), + FloatSlider::k_percentage); - AddInput(kFastInput, NodeValue::kBoolean, false); + add_input(k_fast_input, NodeValue::k_boolean, false); - SetEffectInput(kTextureInput); - SetFlag(kVideoEffect); + set_effect_input(k_texture_input); + set_flag(k_video_effect); } -void DropShadowFilter::Retranslate() +void DropShadowFilter::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Texture")); - SetInputName(kColorInput, tr("Color")); - SetInputName(kDistanceInput, tr("Distance")); - SetInputName(kAngleInput, tr("Angle")); - SetInputName(kSoftnessInput, tr("Softness")); - SetInputName(kOpacityInput, tr("Opacity")); - SetInputName(kFastInput, tr("Faster (Lower Quality)")); + set_input_name(k_texture_input, tr("Texture")); + set_input_name(k_color_input, tr("Color")); + set_input_name(k_distance_input, tr("Distance")); + set_input_name(k_angle_input, tr("Angle")); + set_input_name(k_softness_input, tr("Softness")); + set_input_name(k_opacity_input, tr("Opacity")); + set_input_name(k_fast_input, tr("Faster (Lower Quality)")); } -ShaderCode DropShadowFilter::GetShaderCode(const ShaderRequest &request) const +ShaderCode DropShadowFilter::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/dropshadow.frag")); + FileFunctions::read_file_as_string(":/shaders/dropshadow.frag")); } -void DropShadowFilter::Value(const NodeValueRow &value, +void DropShadowFilter::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { ShaderJob job(value); QString iterative = QStringLiteral("previous_iteration_in"); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, tex->virtual_resolution(), + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, tex->virtual_resolution(), this)); - job.Insert(iterative, value[kTextureInput]); + job.insert(iterative, value[k_texture_input]); - if (!qIsNull(value[kSoftnessInput].toDouble())) { - job.SetIterations(3, iterative); + if (!qIsNull(value[k_softness_input].to_double())) { + job.set_iterations(3, iterative); } - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } } diff --git a/app/node/filter/dropshadow/dropshadowfilter.h b/app/node/filter/dropshadow/dropshadowfilter.h index cbedf006f..92b794823 100644 --- a/app/node/filter/dropshadow/dropshadowfilter.h +++ b/app/node/filter/dropshadow/dropshadowfilter.h @@ -19,8 +19,8 @@ ***/ -#ifndef DROPSHADOWFILTER_H -#define DROPSHADOWFILTER_H +#ifndef OAK_DROPSHADOWFILTER_H +#define OAK_DROPSHADOWFILTER_H #include "node/node.h" @@ -34,7 +34,7 @@ public: NODE_DEFAULT_FUNCTIONS(DropShadowFilter) - virtual QString Name() const override + virtual QString name() const override { return tr("Drop Shadow"); } @@ -42,31 +42,31 @@ public: { return QStringLiteral("org.olivevideoeditor.Olive.dropshadow"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryFilter }; + return { k_category_filter }; } - virtual QString Description() const override + virtual QString description() const override { return tr("Adds a drop shadow to an image."); } - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTextureInput; - static const QString kColorInput; - static const QString kDistanceInput; - static const QString kAngleInput; - static const QString kSoftnessInput; - static const QString kOpacityInput; - static const QString kFastInput; + static const QString k_texture_input; + static const QString k_color_input; + static const QString k_distance_input; + static const QString k_angle_input; + static const QString k_softness_input; + static const QString k_opacity_input; + static const QString k_fast_input; }; } -#endif // DROPSHADOWFILTER_H +#endif // OAK_DROPSHADOWFILTER_H diff --git a/app/node/filter/mosaic/mosaicfilternode.cpp b/app/node/filter/mosaic/mosaicfilternode.cpp index 64f325f4b..1d471180a 100644 --- a/app/node/filter/mosaic/mosaicfilternode.cpp +++ b/app/node/filter/mosaic/mosaicfilternode.cpp @@ -24,60 +24,60 @@ namespace olive { -const QString MosaicFilterNode::kTextureInput = QStringLiteral("tex_in"); -const QString MosaicFilterNode::kHorizInput = QStringLiteral("horiz_in"); -const QString MosaicFilterNode::kVertInput = QStringLiteral("vert_in"); +const QString MosaicFilterNode::k_texture_input = QStringLiteral("tex_in"); +const QString MosaicFilterNode::k_horiz_input = QStringLiteral("horiz_in"); +const QString MosaicFilterNode::k_vert_input = QStringLiteral("vert_in"); #define super Node MosaicFilterNode::MosaicFilterNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kHorizInput, NodeValue::kFloat, 32.0); - SetInputProperty(kHorizInput, QStringLiteral("min"), 1.0); + add_input(k_horiz_input, NodeValue::k_float, 32.0); + set_input_property(k_horiz_input, QStringLiteral("min"), 1.0); - AddInput(kVertInput, NodeValue::kFloat, 18.0); - SetInputProperty(kVertInput, QStringLiteral("min"), 1.0); + add_input(k_vert_input, NodeValue::k_float, 18.0); + set_input_property(k_vert_input, QStringLiteral("min"), 1.0); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -void MosaicFilterNode::Retranslate() +void MosaicFilterNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Texture")); - SetInputName(kHorizInput, tr("Horizontal")); - SetInputName(kVertInput, tr("Vertical")); + set_input_name(k_texture_input, tr("Texture")); + set_input_name(k_horiz_input, tr("Horizontal")); + set_input_name(k_vert_input, tr("Vertical")); } -void MosaicFilterNode::Value(const NodeValueRow &value, +void MosaicFilterNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (TexturePtr texture = value[kTextureInput].toTexture()) { - if (texture && (value[kHorizInput].toInt() != texture->width() || - value[kVertInput].toInt() != texture->height())) { + if (TexturePtr texture = value[k_texture_input].to_texture()) { + if (texture && (value[k_horiz_input].to_int() != texture->width() || + value[k_vert_input].to_int() != texture->height())) { ShaderJob job(value); // Mipmapping makes this look weird, so we just use bilinear for finding the color of each block - job.SetInterpolation(kTextureInput, Texture::kLinear); + job.set_interpolation(k_texture_input, Texture::k_linear); - table->Push(NodeValue::kTexture, texture->toJob(job), this); + table->push(NodeValue::k_texture, texture->to_job(job), this); } else { - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } -ShaderCode MosaicFilterNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode MosaicFilterNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/mosaic.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/mosaic.frag")); } } diff --git a/app/node/filter/mosaic/mosaicfilternode.h b/app/node/filter/mosaic/mosaicfilternode.h index 730017dc0..be1e1d0d0 100644 --- a/app/node/filter/mosaic/mosaicfilternode.h +++ b/app/node/filter/mosaic/mosaicfilternode.h @@ -19,8 +19,8 @@ ***/ -#ifndef MOSAICFILTERNODE_H -#define MOSAICFILTERNODE_H +#ifndef OAK_MOSAICFILTERNODE_H +#define OAK_MOSAICFILTERNODE_H #include "node/node.h" @@ -34,7 +34,7 @@ public: NODE_DEFAULT_FUNCTIONS(MosaicFilterNode) - virtual QString Name() const override + virtual QString name() const override { return tr("Mosaic"); } @@ -44,28 +44,28 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.mosaicfilter"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryFilter }; + return { k_category_filter }; } - virtual QString Description() const override + virtual QString description() const override { return tr("Apply a pixelated mosaic filter to video."); } - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - static const QString kTextureInput; - static const QString kHorizInput; - static const QString kVertInput; + static const QString k_texture_input; + static const QString k_horiz_input; + static const QString k_vert_input; }; } -#endif // MOSAICFILTERNODE_H +#endif // OAK_MOSAICFILTERNODE_H diff --git a/app/node/filter/stroke/stroke.cpp b/app/node/filter/stroke/stroke.cpp index bab59319a..2212dcc9d 100644 --- a/app/node/filter/stroke/stroke.cpp +++ b/app/node/filter/stroke/stroke.cpp @@ -26,38 +26,38 @@ namespace olive { -const QString StrokeFilterNode::kTextureInput = QStringLiteral("tex_in"); -const QString StrokeFilterNode::kColorInput = QStringLiteral("color_in"); -const QString StrokeFilterNode::kRadiusInput = QStringLiteral("radius_in"); -const QString StrokeFilterNode::kOpacityInput = QStringLiteral("opacity_in"); -const QString StrokeFilterNode::kInnerInput = QStringLiteral("inner_in"); +const QString StrokeFilterNode::k_texture_input = QStringLiteral("tex_in"); +const QString StrokeFilterNode::k_color_input = QStringLiteral("color_in"); +const QString StrokeFilterNode::k_radius_input = QStringLiteral("radius_in"); +const QString StrokeFilterNode::k_opacity_input = QStringLiteral("opacity_in"); +const QString StrokeFilterNode::k_inner_input = QStringLiteral("inner_in"); #define super Node StrokeFilterNode::StrokeFilterNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kColorInput, NodeValue::kColor, + add_input(k_color_input, NodeValue::k_color, QVariant::fromValue(Color(1.0f, 1.0f, 1.0f, 1.0f))); - AddInput(kRadiusInput, NodeValue::kFloat, 10.0); - SetInputProperty(kRadiusInput, QStringLiteral("min"), 0.0); + add_input(k_radius_input, NodeValue::k_float, 10.0); + set_input_property(k_radius_input, QStringLiteral("min"), 0.0); - AddInput(kOpacityInput, NodeValue::kFloat, 1.0f); - SetInputProperty(kOpacityInput, QStringLiteral("view"), - FloatSlider::kPercentage); - SetInputProperty(kOpacityInput, QStringLiteral("min"), 0.0f); - SetInputProperty(kOpacityInput, QStringLiteral("max"), 1.0f); + add_input(k_opacity_input, NodeValue::k_float, 1.0f); + set_input_property(k_opacity_input, QStringLiteral("view"), + FloatSlider::k_percentage); + set_input_property(k_opacity_input, QStringLiteral("min"), 0.0f); + set_input_property(k_opacity_input, QStringLiteral("max"), 1.0f); - AddInput(kInnerInput, NodeValue::kBoolean, false); + add_input(k_inner_input, NodeValue::k_boolean, false); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -QString StrokeFilterNode::Name() const +QString StrokeFilterNode::name() const { return tr("Stroke"); } @@ -67,50 +67,50 @@ QString StrokeFilterNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.stroke"); } -QVector StrokeFilterNode::Category() const +QVector StrokeFilterNode::category() const { - return { kCategoryFilter }; + return { k_category_filter }; } -QString StrokeFilterNode::Description() const +QString StrokeFilterNode::description() const { return tr("Creates a stroke outline around an image."); } -void StrokeFilterNode::Retranslate() +void StrokeFilterNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kColorInput, tr("Color")); - SetInputName(kRadiusInput, tr("Radius")); - SetInputName(kOpacityInput, tr("Opacity")); - SetInputName(kInnerInput, tr("Inner")); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_color_input, tr("Color")); + set_input_name(k_radius_input, tr("Radius")); + set_input_name(k_opacity_input, tr("Opacity")); + set_input_name(k_inner_input, tr("Inner")); } -void StrokeFilterNode::Value(const NodeValueRow &value, +void StrokeFilterNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (TexturePtr tex = value[kTextureInput].toTexture()) { - if (value[kRadiusInput].toDouble() > 0.0 && - value[kOpacityInput].toDouble() > 0.0) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { + if (value[k_radius_input].to_double() > 0.0 && + value[k_opacity_input].to_double() > 0.0) { ShaderJob job(value); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, tex->virtual_resolution(), + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, tex->virtual_resolution(), this)); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } else { - table->Push(value[kTextureInput]); + table->push(value[k_texture_input]); } } } -ShaderCode StrokeFilterNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode StrokeFilterNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/stroke.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/stroke.frag")); } } diff --git a/app/node/filter/stroke/stroke.h b/app/node/filter/stroke/stroke.h index c2d0d829f..ae7790e4e 100644 --- a/app/node/filter/stroke/stroke.h +++ b/app/node/filter/stroke/stroke.h @@ -19,8 +19,8 @@ ***/ -#ifndef STROKEFILTERNODE_H -#define STROKEFILTERNODE_H +#ifndef OAK_STROKEFILTERNODE_H +#define OAK_STROKEFILTERNODE_H #include "node/node.h" @@ -34,25 +34,25 @@ public: NODE_DEFAULT_FUNCTIONS(StrokeFilterNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - static const QString kTextureInput; - static const QString kColorInput; - static const QString kRadiusInput; - static const QString kOpacityInput; - static const QString kInnerInput; + static const QString k_texture_input; + static const QString k_color_input; + static const QString k_radius_input; + static const QString k_opacity_input; + static const QString k_inner_input; }; } -#endif // STROKEFILTERNODE_H +#endif // OAK_STROKEFILTERNODE_H diff --git a/app/node/generator/matrix/matrix.cpp b/app/node/generator/matrix/matrix.cpp index 8037fedac..f4b263e22 100644 --- a/app/node/generator/matrix/matrix.cpp +++ b/app/node/generator/matrix/matrix.cpp @@ -29,39 +29,39 @@ namespace olive { -const QString MatrixGenerator::kPositionInput = QStringLiteral("pos_in"); -const QString MatrixGenerator::kRotationInput = QStringLiteral("rot_in"); -const QString MatrixGenerator::kScaleInput = QStringLiteral("scale_in"); -const QString MatrixGenerator::kUniformScaleInput = +const QString MatrixGenerator::k_position_input = QStringLiteral("pos_in"); +const QString MatrixGenerator::k_rotation_input = QStringLiteral("rot_in"); +const QString MatrixGenerator::k_scale_input = QStringLiteral("scale_in"); +const QString MatrixGenerator::k_uniform_scale_input = QStringLiteral("uniform_scale_in"); -const QString MatrixGenerator::kAnchorInput = QStringLiteral("anchor_in"); +const QString MatrixGenerator::k_anchor_input = QStringLiteral("anchor_in"); #define super Node MatrixGenerator::MatrixGenerator() { - AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0.0, 0.0)); + add_input(k_position_input, NodeValue::k_vec2, QVector2D(0.0, 0.0)); - AddInput(kRotationInput, NodeValue::kFloat, 0.0); + add_input(k_rotation_input, NodeValue::k_float, 0.0); - AddInput(kScaleInput, NodeValue::kVec2, QVector2D(1.0f, 1.0f)); - SetInputProperty(kScaleInput, QStringLiteral("min"), QVector2D(0, 0)); - SetInputProperty(kScaleInput, QStringLiteral("view"), - FloatSlider::kPercentage); - SetInputProperty(kScaleInput, QStringLiteral("disable1"), true); + add_input(k_scale_input, NodeValue::k_vec2, QVector2D(1.0f, 1.0f)); + set_input_property(k_scale_input, QStringLiteral("min"), QVector2D(0, 0)); + set_input_property(k_scale_input, QStringLiteral("view"), + FloatSlider::k_percentage); + set_input_property(k_scale_input, QStringLiteral("disable1"), true); - AddInput(kUniformScaleInput, NodeValue::kBoolean, true, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_uniform_scale_input, NodeValue::k_boolean, true, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - AddInput(kAnchorInput, NodeValue::kVec2, QVector2D(0.0, 0.0)); + add_input(k_anchor_input, NodeValue::k_vec2, QVector2D(0.0, 0.0)); } -QString MatrixGenerator::Name() const +QString MatrixGenerator::name() const { return tr("Orthographic Matrix"); } -QString MatrixGenerator::ShortName() const +QString MatrixGenerator::short_name() const { return tr("Ortho"); } @@ -71,38 +71,38 @@ QString MatrixGenerator::id() const return QStringLiteral("org.olivevideoeditor.Olive.ortho"); } -QVector MatrixGenerator::Category() const +QVector MatrixGenerator::category() const { - return { kCategoryGenerator, kCategoryMath }; + return { k_category_generator, k_category_math }; } -QString MatrixGenerator::Description() const +QString MatrixGenerator::description() const { return tr( "Generate an orthographic matrix using position, rotation, and scale."); } -void MatrixGenerator::Retranslate() +void MatrixGenerator::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kPositionInput, tr("Position")); - SetInputName(kRotationInput, tr("Rotation")); - SetInputName(kScaleInput, tr("Scale")); - SetInputName(kUniformScaleInput, tr("Uniform Scale")); - SetInputName(kAnchorInput, tr("Anchor Point")); + set_input_name(k_position_input, tr("Position")); + set_input_name(k_rotation_input, tr("Rotation")); + set_input_name(k_scale_input, tr("Scale")); + set_input_name(k_uniform_scale_input, tr("Uniform Scale")); + set_input_name(k_anchor_input, tr("Anchor Point")); } -void MatrixGenerator::Value(const NodeValueRow &value, +void MatrixGenerator::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // Push matrix output - QMatrix4x4 mat = GenerateMatrix(value, false, false, false, QMatrix4x4()); - table->Push(NodeValue::kMatrix, mat, this); + QMatrix4x4 mat = generate_matrix(value, false, false, false, QMatrix4x4()); + table->push(NodeValue::k_matrix, mat, this); } -QMatrix4x4 MatrixGenerator::GenerateMatrix(const NodeValueRow &value, +QMatrix4x4 MatrixGenerator::generate_matrix(const NodeValueRow &value, bool ignore_anchor, bool ignore_position, bool ignore_scale, @@ -113,23 +113,23 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(const NodeValueRow &value, QVector2D scale; if (!ignore_anchor) { - anchor = value[kAnchorInput].toVec2(); + anchor = value[k_anchor_input].to_vec2(); } if (!ignore_scale) { - scale = value[kScaleInput].toVec2(); + scale = value[k_scale_input].to_vec2(); } if (!ignore_position) { - position = value[kPositionInput].toVec2(); + position = value[k_position_input].to_vec2(); } - return GenerateMatrix(position, value[kRotationInput].toDouble(), scale, - value[kUniformScaleInput].toBool(), anchor, mat); + return generate_matrix(position, value[k_rotation_input].to_double(), scale, + value[k_uniform_scale_input].to_bool(), anchor, mat); } QMatrix4x4 -MatrixGenerator::GenerateMatrix(const QVector2D &pos, const float &rot, +MatrixGenerator::generate_matrix(const QVector2D &pos, const float &rot, const QVector2D &scale, bool uniform_scale, const QVector2D &anchor, QMatrix4x4 mat) { @@ -158,9 +158,9 @@ void MatrixGenerator::InputValueChangedEvent(const QString &input, int element) { Q_UNUSED(element) - if (input == kUniformScaleInput) { - SetInputProperty(kScaleInput, QStringLiteral("disable1"), - GetStandardValue(kUniformScaleInput).toBool()); + if (input == k_uniform_scale_input) { + set_input_property(k_scale_input, QStringLiteral("disable1"), + get_standard_value(k_uniform_scale_input).toBool()); } } diff --git a/app/node/generator/matrix/matrix.h b/app/node/generator/matrix/matrix.h index fc29a6464..5ab0dc872 100644 --- a/app/node/generator/matrix/matrix.h +++ b/app/node/generator/matrix/matrix.h @@ -19,8 +19,8 @@ ***/ -#ifndef MATRIXGENERATOR_H -#define MATRIXGENERATOR_H +#ifndef OAK_MATRIXGENERATOR_H +#define OAK_MATRIXGENERATOR_H #include @@ -37,28 +37,28 @@ public: NODE_DEFAULT_FUNCTIONS(MatrixGenerator) - virtual QString Name() const override; - virtual QString ShortName() const override; + virtual QString name() const override; + virtual QString short_name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kPositionInput; - static const QString kRotationInput; - static const QString kScaleInput; - static const QString kUniformScaleInput; - static const QString kAnchorInput; + static const QString k_position_input; + static const QString k_rotation_input; + static const QString k_scale_input; + static const QString k_uniform_scale_input; + static const QString k_anchor_input; protected: - QMatrix4x4 GenerateMatrix(const NodeValueRow &value, bool ignore_anchor, + QMatrix4x4 generate_matrix(const NodeValueRow &value, bool ignore_anchor, bool ignore_position, bool ignore_scale, const QMatrix4x4 &mat) const; - static QMatrix4x4 GenerateMatrix(const QVector2D &pos, const float &rot, + static QMatrix4x4 generate_matrix(const QVector2D &pos, const float &rot, const QVector2D &scale, bool uniform_scale, const QVector2D &anchor, QMatrix4x4 mat); diff --git a/app/node/generator/noise/noise.cpp b/app/node/generator/noise/noise.cpp index aeb6294c5..30c8a3601 100644 --- a/app/node/generator/noise/noise.cpp +++ b/app/node/generator/noise/noise.cpp @@ -26,30 +26,30 @@ namespace olive { -const QString NoiseGeneratorNode::kBaseIn = QStringLiteral("base_in"); -const QString NoiseGeneratorNode::kColorInput = QStringLiteral("color_in"); -const QString NoiseGeneratorNode::kStrengthInput = +const QString NoiseGeneratorNode::k_base_in = QStringLiteral("base_in"); +const QString NoiseGeneratorNode::k_color_input = QStringLiteral("color_in"); +const QString NoiseGeneratorNode::k_strength_input = QStringLiteral("strength_in"); #define super Node NoiseGeneratorNode::NoiseGeneratorNode() { - AddInput(kBaseIn, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_base_in, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kStrengthInput, NodeValue::kFloat, 0.2); - SetInputProperty(kStrengthInput, QStringLiteral("view"), - FloatSlider::kPercentage); - SetInputProperty(kStrengthInput, QStringLiteral("min"), 0); + add_input(k_strength_input, NodeValue::k_float, 0.2); + set_input_property(k_strength_input, QStringLiteral("view"), + FloatSlider::k_percentage); + set_input_property(k_strength_input, QStringLiteral("min"), 0); - AddInput(kColorInput, NodeValue::kBoolean, false); + add_input(k_color_input, NodeValue::k_boolean, false); - SetEffectInput(kBaseIn); - SetFlag(kVideoEffect); + set_effect_input(k_base_in); + set_flag(k_video_effect); } -QString NoiseGeneratorNode::Name() const +QString NoiseGeneratorNode::name() const { return tr("Noise"); } @@ -59,45 +59,45 @@ QString NoiseGeneratorNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.noise"); } -QVector NoiseGeneratorNode::Category() const +QVector NoiseGeneratorNode::category() const { - return { kCategoryGenerator }; + return { k_category_generator }; } -QString NoiseGeneratorNode::Description() const +QString NoiseGeneratorNode::description() const { return tr("Generates noise patterns"); } -void NoiseGeneratorNode::Retranslate() +void NoiseGeneratorNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kBaseIn, tr("Base")); - SetInputName(kStrengthInput, tr("Strength")); - SetInputName(kColorInput, tr("Color")); + set_input_name(k_base_in, tr("Base")); + set_input_name(k_strength_input, tr("Strength")); + set_input_name(k_color_input, tr("Color")); } -ShaderCode NoiseGeneratorNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode NoiseGeneratorNode::get_shader_code(const ShaderRequest &request) const { - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/noise.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/noise.frag")); } -void NoiseGeneratorNode::Value(const NodeValueRow &value, +void NoiseGeneratorNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { ShaderJob job(value); - job.Insert(value); - job.Insert(QStringLiteral("time_in"), - NodeValue(NodeValue::kFloat, globals.time().in().toDouble(), + job.insert(value); + job.insert(QStringLiteral("time_in"), + NodeValue(NodeValue::k_float, globals.time().in().to_double(), this)); - TexturePtr base = value[kBaseIn].toTexture(); + TexturePtr base = value[k_base_in].to_texture(); - table->Push(NodeValue::kTexture, - Texture::Job(base ? base->params() : globals.vparams(), job), + table->push(NodeValue::k_texture, + Texture::job(base ? base->params() : globals.vparams(), job), this); } } diff --git a/app/node/generator/noise/noise.h b/app/node/generator/noise/noise.h index 157d02a12..c9d6b7e00 100644 --- a/app/node/generator/noise/noise.h +++ b/app/node/generator/noise/noise.h @@ -19,8 +19,8 @@ ***/ -#ifndef NOISEGENERATORNODE_H -#define NOISEGENERATORNODE_H +#ifndef OAK_NOISEGENERATORNODE_H +#define OAK_NOISEGENERATORNODE_H #include "node/node.h" @@ -34,23 +34,23 @@ public: NODE_DEFAULT_FUNCTIONS(NoiseGeneratorNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kBaseIn; - static const QString kColorInput; - static const QString kStrengthInput; + static const QString k_base_in; + static const QString k_color_input; + static const QString k_strength_input; }; } // namespace olive -#endif // NOISEGENERATORNODE_H +#endif // OAK_NOISEGENERATORNODE_H diff --git a/app/node/generator/polygon/polygon.cpp b/app/node/generator/polygon/polygon.cpp index f9e9d119a..b5ff3ac58 100644 --- a/app/node/generator/polygon/polygon.cpp +++ b/app/node/generator/polygon/polygon.cpp @@ -27,43 +27,43 @@ namespace olive { -const QString PolygonGenerator::kPointsInput = QStringLiteral("points_in"); -const QString PolygonGenerator::kColorInput = QStringLiteral("color_in"); +const QString PolygonGenerator::k_points_input = QStringLiteral("points_in"); +const QString PolygonGenerator::k_color_input = QStringLiteral("color_in"); #define super GeneratorWithMerge PolygonGenerator::PolygonGenerator() { - AddInput(kPointsInput, NodeValue::kBezier, QVector2D(0, 0), - InputFlags(kInputFlagArray)); + add_input(k_points_input, NodeValue::k_bezier, QVector2D(0, 0), + InputFlags(k_input_flag_array)); - AddInput(kColorInput, NodeValue::kColor, + add_input(k_color_input, NodeValue::k_color, QVariant::fromValue(Color(1.0, 1.0, 1.0))); - const int kMiddleX = 135; - const int kMiddleY = 45; - const int kBottomX = 90; - const int kBottomY = 120; - const int kTopY = 135; + const int k_middle_x = 135; + const int k_middle_y = 45; + const int k_bottom_x = 90; + const int k_bottom_y = 120; + const int k_top_y = 135; // The Default Pentagon(tm) - InputArrayResize(kPointsInput, 5); - SetSplitStandardValueOnTrack(kPointsInput, 0, 0, 0); - SetSplitStandardValueOnTrack(kPointsInput, 1, -kTopY, 0); - SetSplitStandardValueOnTrack(kPointsInput, 0, kMiddleX, 1); - SetSplitStandardValueOnTrack(kPointsInput, 1, -kMiddleY, 1); - SetSplitStandardValueOnTrack(kPointsInput, 0, kBottomX, 2); - SetSplitStandardValueOnTrack(kPointsInput, 1, kBottomY, 2); - SetSplitStandardValueOnTrack(kPointsInput, 0, -kBottomX, 3); - SetSplitStandardValueOnTrack(kPointsInput, 1, kBottomY, 3); - SetSplitStandardValueOnTrack(kPointsInput, 0, -kMiddleX, 4); - SetSplitStandardValueOnTrack(kPointsInput, 1, -kMiddleY, 4); + input_array_resize(k_points_input, 5); + set_split_standard_value_on_track(k_points_input, 0, 0, 0); + set_split_standard_value_on_track(k_points_input, 1, -k_top_y, 0); + set_split_standard_value_on_track(k_points_input, 0, k_middle_x, 1); + set_split_standard_value_on_track(k_points_input, 1, -k_middle_y, 1); + set_split_standard_value_on_track(k_points_input, 0, k_bottom_x, 2); + set_split_standard_value_on_track(k_points_input, 1, k_bottom_y, 2); + set_split_standard_value_on_track(k_points_input, 0, -k_bottom_x, 3); + set_split_standard_value_on_track(k_points_input, 1, k_bottom_y, 3); + set_split_standard_value_on_track(k_points_input, 0, -k_middle_x, 4); + set_split_standard_value_on_track(k_points_input, 1, -k_middle_y, 4); // Initiate gizmos poly_gizmo_ = new PathGizmo(this); } -QString PolygonGenerator::Name() const +QString PolygonGenerator::name() const { return tr("Polygon"); } @@ -73,52 +73,52 @@ QString PolygonGenerator::id() const return QStringLiteral("org.olivevideoeditor.Olive.polygon"); } -QVector PolygonGenerator::Category() const +QVector PolygonGenerator::category() const { - return { kCategoryGenerator }; + return { k_category_generator }; } -QString PolygonGenerator::Description() const +QString PolygonGenerator::description() const { return tr("Generate a 2D polygon of any amount of points."); } -void PolygonGenerator::Retranslate() +void PolygonGenerator::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kPointsInput, tr("Points")); - SetInputName(kColorInput, tr("Color")); + set_input_name(k_points_input, tr("Points")); + set_input_name(k_color_input, tr("Color")); } -ShaderJob PolygonGenerator::GetGenerateJob(const NodeValueRow &value, +ShaderJob PolygonGenerator::get_generate_job(const NodeValueRow &value, const VideoParams ¶ms) const { VideoParams p = params; - p.set_format(PixelFormat::U8); - auto job = Texture::Job(p, GenerateJob(value)); + p.set_format(PixelFormat::u8); + auto job = Texture::job(p, GenerateJob(value)); // Conversion to RGB ShaderJob rgb; - rgb.SetShaderID(QStringLiteral("rgb")); - rgb.Insert(QStringLiteral("texture_in"), - NodeValue(NodeValue::kTexture, job, this)); - rgb.Insert(QStringLiteral("color_in"), value[kColorInput]); + rgb.set_shader_id(QStringLiteral("rgb")); + rgb.insert(QStringLiteral("texture_in"), + NodeValue(NodeValue::k_texture, job, this)); + rgb.insert(QStringLiteral("color_in"), value[k_color_input]); return rgb; } -void PolygonGenerator::Value(const NodeValueRow &value, +void PolygonGenerator::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - PushMergableJob(value, - Texture::Job(globals.vparams(), - GetGenerateJob(value, globals.vparams())), + push_mergable_job(value, + Texture::job(globals.vparams(), + get_generate_job(value, globals.vparams())), table); } -void PolygonGenerator::GenerateFrame(FramePtr frame, +void PolygonGenerator::generate_frame(FramePtr frame, const GenerateJob &job) const { // This could probably be more optimized, but for now we use Qt to draw to a QImage. @@ -129,12 +129,12 @@ void PolygonGenerator::GenerateFrame(FramePtr frame, frame->linesize_bytes(), QImage::Format_RGBA8888_Premultiplied); img.fill(Qt::transparent); - auto points = job.Get(kPointsInput).toArray(); + auto points = job.get(k_points_input).to_array(); - QPainterPath path = GeneratePath(points, InputArraySize(kPointsInput)); + QPainterPath path = generate_path(points, input_array_size(k_points_input)); QPainter p(&img); - double par = frame->video_params().pixel_aspect_ratio().toDouble(); + double par = frame->video_params().pixel_aspect_ratio().to_double(); p.scale(1.0 / frame->video_params().divider() / par, 1.0 / frame->video_params().divider()); p.translate(frame->video_params().width() / 2 * par, @@ -145,18 +145,18 @@ void PolygonGenerator::GenerateFrame(FramePtr frame, p.drawPath(path); } -template NodeGizmo *PolygonGenerator::CreateAppropriateGizmo() +template NodeGizmo *PolygonGenerator::create_appropriate_gizmo() { return new T(this); } -template <> NodeGizmo *PolygonGenerator::CreateAppropriateGizmo() +template <> NodeGizmo *PolygonGenerator::create_appropriate_gizmo() { - return AddDraggableGizmo(); + return add_draggable_gizmo(); } template -void PolygonGenerator::ValidateGizmoVectorSize(QVector &vec, int new_sz) +void PolygonGenerator::validate_gizmo_vector_size(QVector &vec, int new_sz) { int old_sz = vec.size(); @@ -171,17 +171,17 @@ void PolygonGenerator::ValidateGizmoVectorSize(QVector &vec, int new_sz) if (old_sz < new_sz) { for (int i = old_sz; i < new_sz; i++) { - vec[i] = static_cast(CreateAppropriateGizmo()); + vec[i] = static_cast(create_appropriate_gizmo()); } } } } -void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row, +void PolygonGenerator::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { QVector2D res; - if (TexturePtr tex = row[kBaseInput].toTexture()) { + if (TexturePtr tex = row[k_base_input].to_texture()) { res = tex->virtual_resolution(); } else { res = globals.square_resolution(); @@ -189,72 +189,72 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row, Imath::V2d half_res(res.x() / 2, res.y() / 2); - auto points = row[kPointsInput].toArray(); + auto points = row[k_points_input].to_array(); int current_pos_sz = gizmo_position_handles_.size(); - ValidateGizmoVectorSize(gizmo_position_handles_, points.size()); - ValidateGizmoVectorSize(gizmo_bezier_handles_, points.size() * 2); - ValidateGizmoVectorSize(gizmo_bezier_lines_, points.size() * 2); + validate_gizmo_vector_size(gizmo_position_handles_, points.size()); + validate_gizmo_vector_size(gizmo_bezier_handles_, points.size() * 2); + validate_gizmo_vector_size(gizmo_bezier_lines_, points.size() * 2); for (int i = current_pos_sz; i < gizmo_position_handles_.size(); i++) { - gizmo_position_handles_.at(i)->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 0)); - gizmo_position_handles_.at(i)->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 1)); + gizmo_position_handles_.at(i)->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 0)); + gizmo_position_handles_.at(i)->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 1)); PointGizmo *bez_gizmo1 = gizmo_bezier_handles_.at(i * 2 + 0); - bez_gizmo1->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 2)); - bez_gizmo1->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 3)); - bez_gizmo1->SetShape(PointGizmo::kCircle); - bez_gizmo1->SetSmaller(true); + bez_gizmo1->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 2)); + bez_gizmo1->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 3)); + bez_gizmo1->set_shape(PointGizmo::k_circle); + bez_gizmo1->set_smaller(true); PointGizmo *bez_gizmo2 = gizmo_bezier_handles_.at(i * 2 + 1); - bez_gizmo2->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 4)); - bez_gizmo2->AddInput( - NodeKeyframeTrackReference(NodeInput(this, kPointsInput, i), 5)); - bez_gizmo2->SetShape(PointGizmo::kCircle); - bez_gizmo2->SetSmaller(true); + bez_gizmo2->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 4)); + bez_gizmo2->add_input( + NodeKeyframeTrackReference(NodeInput(this, k_points_input, i), 5)); + bez_gizmo2->set_shape(PointGizmo::k_circle); + bez_gizmo2->set_smaller(true); } - int pts_sz = InputArraySize(kPointsInput); + int pts_sz = input_array_size(k_points_input); if (!points.empty()) { for (int i = 0; i < pts_sz; i++) { - const Bezier &pt = points.at(i).toBezier(); + const Bezier &pt = points.at(i).to_bezier(); Imath::V2d main = pt.to_vec() + half_res; Imath::V2d cp1 = main + pt.control_point_1_to_vec(); Imath::V2d cp2 = main + pt.control_point_2_to_vec(); - gizmo_position_handles_[i]->SetPoint(QPointF(main.x, main.y)); + gizmo_position_handles_[i]->set_point(QPointF(main.x, main.y)); - gizmo_bezier_handles_[i * 2]->SetPoint(QPointF(cp1.x, cp1.y)); - gizmo_bezier_lines_[i * 2]->SetLine( + gizmo_bezier_handles_[i * 2]->set_point(QPointF(cp1.x, cp1.y)); + gizmo_bezier_lines_[i * 2]->set_line( QLineF(QPointF(main.x, main.y), QPointF(cp1.x, cp1.y))); - gizmo_bezier_handles_[i * 2 + 1]->SetPoint(QPointF(cp2.x, cp2.y)); - gizmo_bezier_lines_[i * 2 + 1]->SetLine( + gizmo_bezier_handles_[i * 2 + 1]->set_point(QPointF(cp2.x, cp2.y)); + gizmo_bezier_lines_[i * 2 + 1]->set_line( QLineF(QPointF(main.x, main.y), QPointF(cp2.x, cp2.y))); } } - poly_gizmo_->SetPath(GeneratePath(points, pts_sz) + poly_gizmo_->set_path(generate_path(points, pts_sz) .translated(QPointF(half_res.x, half_res.y))); } -ShaderCode PolygonGenerator::GetShaderCode(const ShaderRequest &request) const +ShaderCode PolygonGenerator::get_shader_code(const ShaderRequest &request) const { if (request.id == QStringLiteral("rgb")) { return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/rgb.frag")); + FileFunctions::read_file_as_string(":/shaders/rgb.frag")); } else { - return super::GetShaderCode(request); + return super::get_shader_code(request); } } -void PolygonGenerator::GizmoDragMove(double x, double y, +void PolygonGenerator::gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { DraggableGizmo *gizmo = static_cast(sender()); @@ -262,14 +262,14 @@ void PolygonGenerator::GizmoDragMove(double x, double y, if (gizmo == poly_gizmo_) { // FIXME: Drag all points } else { - NodeInputDragger &x_drag = gizmo->GetDraggers()[0]; - NodeInputDragger &y_drag = gizmo->GetDraggers()[1]; - x_drag.Drag(x_drag.GetStartValue().toDouble() + x); - y_drag.Drag(y_drag.GetStartValue().toDouble() + y); + NodeInputDragger &x_drag = gizmo->get_draggers()[0]; + NodeInputDragger &y_drag = gizmo->get_draggers()[1]; + x_drag.drag(x_drag.get_start_value().toDouble() + x); + y_drag.drag(y_drag.get_start_value().toDouble() + y); } } -void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before, +void PolygonGenerator::add_point_to_path(QPainterPath *path, const Bezier &before, const Bezier &after) { Imath::V2d a = before.to_vec() + before.control_point_2_to_vec(); @@ -279,22 +279,22 @@ void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before, path->cubicTo(QPointF(a.x, a.y), QPointF(b.x, b.y), QPointF(c.x, c.y)); } -QPainterPath PolygonGenerator::GeneratePath(const NodeValueArray &points, +QPainterPath PolygonGenerator::generate_path(const NodeValueArray &points, int size) { QPainterPath path; if (!points.empty()) { - const Bezier &first_pt = points.at(0).toBezier(); + const Bezier &first_pt = points.at(0).to_bezier(); Imath::V2d v = first_pt.to_vec(); path.moveTo(QPointF(v.x, v.y)); for (int i = 1; i < size; i++) { - AddPointToPath(&path, points.at(i - 1).toBezier(), - points.at(i).toBezier()); + add_point_to_path(&path, points.at(i - 1).to_bezier(), + points.at(i).to_bezier()); } - AddPointToPath(&path, points.at(size - 1).toBezier(), first_pt); + add_point_to_path(&path, points.at(size - 1).to_bezier(), first_pt); } return path; diff --git a/app/node/generator/polygon/polygon.h b/app/node/generator/polygon/polygon.h index 6c68d3fb7..0f6544186 100644 --- a/app/node/generator/polygon/polygon.h +++ b/app/node/generator/polygon/polygon.h @@ -19,8 +19,8 @@ ***/ -#ifndef POLYGONGENERATOR_H -#define POLYGONGENERATOR_H +#ifndef OAK_POLYGONGENERATOR_H +#define OAK_POLYGONGENERATOR_H #include @@ -41,46 +41,46 @@ public: NODE_DEFAULT_FUNCTIONS(PolygonGenerator) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void GenerateFrame(FramePtr frame, + virtual void generate_frame(FramePtr frame, const GenerateJob &job) const override; - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - static const QString kPointsInput; - static const QString kColorInput; + static const QString k_points_input; + static const QString k_color_input; protected: - ShaderJob GetGenerateJob(const NodeValueRow &value, + ShaderJob get_generate_job(const NodeValueRow &value, const VideoParams ¶ms) const; protected slots: - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) override; private: - static void AddPointToPath(QPainterPath *path, const Bezier &before, + static void add_point_to_path(QPainterPath *path, const Bezier &before, const Bezier &after); - static QPainterPath GeneratePath(const NodeValueArray &points, int size); + static QPainterPath generate_path(const NodeValueArray &points, int size); template - void ValidateGizmoVectorSize(QVector &vec, int new_sz); + void validate_gizmo_vector_size(QVector &vec, int new_sz); - template NodeGizmo *CreateAppropriateGizmo(); + template NodeGizmo *create_appropriate_gizmo(); PathGizmo *poly_gizmo_; QVector gizmo_position_handles_; @@ -90,4 +90,4 @@ private: } -#endif // POLYGONGENERATOR_H +#endif // OAK_POLYGONGENERATOR_H diff --git a/app/node/generator/shape/generatorwithmerge.cpp b/app/node/generator/shape/generatorwithmerge.cpp index 9367ef872..ad26dbc45 100644 --- a/app/node/generator/shape/generatorwithmerge.cpp +++ b/app/node/generator/shape/generatorwithmerge.cpp @@ -28,50 +28,50 @@ namespace olive #define super Node -const QString GeneratorWithMerge::kBaseInput = QStringLiteral("base_in"); +const QString GeneratorWithMerge::k_base_input = QStringLiteral("base_in"); GeneratorWithMerge::GeneratorWithMerge() { - AddInput(kBaseInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); - SetEffectInput(kBaseInput); - SetFlag(kVideoEffect); + add_input(k_base_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); + set_effect_input(k_base_input); + set_flag(k_video_effect); } -void GeneratorWithMerge::Retranslate() +void GeneratorWithMerge::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kBaseInput, tr("Base")); + set_input_name(k_base_input, tr("Base")); } -ShaderCode GeneratorWithMerge::GetShaderCode(const ShaderRequest &request) const +ShaderCode GeneratorWithMerge::get_shader_code(const ShaderRequest &request) const { if (request.id == QStringLiteral("mrg")) { return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/alphaover.frag")); + FileFunctions::read_file_as_string(":/shaders/alphaover.frag")); } return ShaderCode(); } -void GeneratorWithMerge::PushMergableJob(const NodeValueRow &value, +void GeneratorWithMerge::push_mergable_job(const NodeValueRow &value, TexturePtr job, NodeValueTable *table) const { - if (TexturePtr base = value[kBaseInput].toTexture()) { + if (TexturePtr base = value[k_base_input].to_texture()) { // Push as merge node ShaderJob merge; - merge.SetShaderID(QStringLiteral("mrg")); - merge.Insert(MergeNode::kBaseIn, value[kBaseInput]); - merge.Insert(MergeNode::kBlendIn, - NodeValue(NodeValue::kTexture, job, this)); + merge.set_shader_id(QStringLiteral("mrg")); + merge.insert(MergeNode::k_base_in, value[k_base_input]); + merge.insert(MergeNode::k_blend_in, + NodeValue(NodeValue::k_texture, job, this)); - table->Push(NodeValue::kTexture, base->toJob(merge), this); + table->push(NodeValue::k_texture, base->to_job(merge), this); } else { // Just push generate job - table->Push(NodeValue::kTexture, job, this); + table->push(NodeValue::k_texture, job, this); } } diff --git a/app/node/generator/shape/generatorwithmerge.h b/app/node/generator/shape/generatorwithmerge.h index 56fce90da..3400d3967 100644 --- a/app/node/generator/shape/generatorwithmerge.h +++ b/app/node/generator/shape/generatorwithmerge.h @@ -19,8 +19,8 @@ ***/ -#ifndef GENERATORWITHMERGE_H -#define GENERATORWITHMERGE_H +#ifndef OAK_GENERATORWITHMERGE_H +#define OAK_GENERATORWITHMERGE_H #include "node/node.h" @@ -32,18 +32,18 @@ class GeneratorWithMerge : public Node { public: GeneratorWithMerge(); - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - static const QString kBaseInput; + static const QString k_base_input; protected: - void PushMergableJob(const NodeValueRow &value, TexturePtr job, + void push_mergable_job(const NodeValueRow &value, TexturePtr job, NodeValueTable *table) const; }; } -#endif // GENERATORWITHMERGE_H +#endif // OAK_GENERATORWITHMERGE_H diff --git a/app/node/generator/shape/shapenode.cpp b/app/node/generator/shape/shapenode.cpp index f76c72815..1c9c93796 100644 --- a/app/node/generator/shape/shapenode.cpp +++ b/app/node/generator/shape/shapenode.cpp @@ -26,18 +26,18 @@ namespace olive #define super ShapeNodeBase -QString ShapeNode::kTypeInput = QStringLiteral("type_in"); -QString ShapeNode::kRadiusInput = QStringLiteral("radius_in"); +QString ShapeNode::k_type_input = QStringLiteral("type_in"); +QString ShapeNode::k_radius_input = QStringLiteral("radius_in"); ShapeNode::ShapeNode() { - PrependInput(kTypeInput, NodeValue::kCombo); + prepend_input(k_type_input, NodeValue::k_combo); - AddInput(kRadiusInput, NodeValue::kFloat, 20.0); - SetInputProperty(kRadiusInput, QStringLiteral("min"), 0.0); + add_input(k_radius_input, NodeValue::k_float, 20.0); + set_input_property(k_radius_input, QStringLiteral("min"), 0.0); } -QString ShapeNode::Name() const +QString ShapeNode::name() const { return tr("Shape"); } @@ -47,63 +47,63 @@ QString ShapeNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.shape"); } -QVector ShapeNode::Category() const +QVector ShapeNode::category() const { - return { kCategoryGenerator }; + return { k_category_generator }; } -QString ShapeNode::Description() const +QString ShapeNode::description() const { return tr("Generate a 2D primitive shape."); } -void ShapeNode::Retranslate() +void ShapeNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTypeInput, tr("Type")); - SetInputName(kRadiusInput, tr("Radius")); + set_input_name(k_type_input, tr("Type")); + set_input_name(k_radius_input, tr("Radius")); // Coordinate with Type enum - SetComboBoxStrings(kTypeInput, { tr("Rectangle"), tr("Ellipse"), + set_combo_box_strings(k_type_input, { tr("Rectangle"), tr("Ellipse"), tr("Rounded Rectangle") }); } -ShaderCode ShapeNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode ShapeNode::get_shader_code(const ShaderRequest &request) const { if (request.id == QStringLiteral("shape")) { - return ShaderCode(FileFunctions::ReadFileAsString( + return ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/shape.frag"))); } else { - return super::GetShaderCode(request); + return super::get_shader_code(request); } } -void ShapeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void ShapeNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - TexturePtr base = value[kBaseInput].toTexture(); + TexturePtr base = value[k_base_input].to_texture(); ShaderJob job(value); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, base ? base->virtual_resolution() : globals.square_resolution(), this)); - job.SetShaderID(QStringLiteral("shape")); + job.set_shader_id(QStringLiteral("shape")); - PushMergableJob( - value, Texture::Job(base ? base->params() : globals.vparams(), job), + push_mergable_job( + value, Texture::job(base ? base->params() : globals.vparams(), job), table); } void ShapeNode::InputValueChangedEvent(const QString &input, int element) { - if (input == kTypeInput) { - SetInputFlag(kRadiusInput, kInputFlagHidden, - (GetStandardValue(kTypeInput).toInt() != - kRoundedRectangle)); + if (input == k_type_input) { + set_input_flag(k_radius_input, k_input_flag_hidden, + (get_standard_value(k_type_input).toInt() != + k_rounded_rectangle)); } super::InputValueChangedEvent(input, element); } diff --git a/app/node/generator/shape/shapenode.h b/app/node/generator/shape/shapenode.h index 1f079d8ca..d8c1c0f98 100644 --- a/app/node/generator/shape/shapenode.h +++ b/app/node/generator/shape/shapenode.h @@ -19,8 +19,8 @@ ***/ -#ifndef SHAPENODE_H -#define SHAPENODE_H +#ifndef OAK_SHAPENODE_H +#define OAK_SHAPENODE_H #include "shapenodebase.h" @@ -32,24 +32,24 @@ class ShapeNode : public ShapeNodeBase { public: ShapeNode(); - enum Type { kRectangle, kEllipse, kRoundedRectangle }; + enum Type { k_rectangle, k_ellipse, k_rounded_rectangle }; NODE_DEFAULT_FUNCTIONS(ShapeNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static QString kTypeInput; - static QString kRadiusInput; + static QString k_type_input; + static QString k_radius_input; protected: virtual void InputValueChangedEvent(const QString &input, @@ -58,4 +58,4 @@ protected: } -#endif // SHAPENODE_H +#endif // OAK_SHAPENODE_H diff --git a/app/node/generator/shape/shapenodebase.cpp b/app/node/generator/shape/shapenodebase.cpp index 945c9ff88..6f59b341d 100644 --- a/app/node/generator/shape/shapenodebase.cpp +++ b/app/node/generator/shape/shapenodebase.cpp @@ -33,60 +33,60 @@ namespace olive #define super GeneratorWithMerge -const QString ShapeNodeBase::kPositionInput = QStringLiteral("pos_in"); -const QString ShapeNodeBase::kSizeInput = QStringLiteral("size_in"); -const QString ShapeNodeBase::kColorInput = QStringLiteral("color_in"); +const QString ShapeNodeBase::k_position_input = QStringLiteral("pos_in"); +const QString ShapeNodeBase::k_size_input = QStringLiteral("size_in"); +const QString ShapeNodeBase::k_color_input = QStringLiteral("color_in"); ShapeNodeBase::ShapeNodeBase(bool create_color_input) { - AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0)); - AddInput(kSizeInput, NodeValue::kVec2, QVector2D(100, 100)); - SetInputProperty(kSizeInput, QStringLiteral("min"), QVector2D(0, 0)); + add_input(k_position_input, NodeValue::k_vec2, QVector2D(0, 0)); + add_input(k_size_input, NodeValue::k_vec2, QVector2D(100, 100)); + set_input_property(k_size_input, QStringLiteral("min"), QVector2D(0, 0)); if (create_color_input) { - AddInput(kColorInput, NodeValue::kColor, + add_input(k_color_input, NodeValue::k_color, QVariant::fromValue(Color(1.0, 0.0, 0.0, 1.0))); } // Initiate gizmos QVector pos_n_sz = { - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1), - NodeKeyframeTrackReference(NodeInput(this, kSizeInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kSizeInput), 1) + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1), + NodeKeyframeTrackReference(NodeInput(this, k_size_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_size_input), 1) }; - poly_gizmo_ = AddDraggableGizmo({ - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0), - NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1), + poly_gizmo_ = add_draggable_gizmo({ + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 0), + NodeKeyframeTrackReference(NodeInput(this, k_position_input), 1), }); - for (int i = 0; i < kGizmoScaleCount; i++) { + for (int i = 0; i < k_gizmo_scale_count; i++) { point_gizmo_[i] = - AddDraggableGizmo(pos_n_sz, PointGizmo::kAbsolute); + add_draggable_gizmo(pos_n_sz, PointGizmo::k_absolute); } } -void ShapeNodeBase::Retranslate() +void ShapeNodeBase::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kPositionInput, tr("Position")); - SetInputName(kSizeInput, tr("Size")); + set_input_name(k_position_input, tr("Position")); + set_input_name(k_size_input, tr("Size")); - if (HasInputWithID(kColorInput)) { - SetInputName(kColorInput, tr("Color")); + if (has_input_with_id(k_color_input)) { + set_input_name(k_color_input, tr("Color")); } } -void ShapeNodeBase::UpdateGizmoPositions(const NodeValueRow &row, +void ShapeNodeBase::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { // Use offsets to make the appearance of values that start in the top left, even though we // really anchor around the center QVector2D center_pt = globals.square_resolution() * 0.5; - SetInputProperty(kPositionInput, QStringLiteral("offset"), center_pt); + set_input_property(k_position_input, QStringLiteral("offset"), center_pt); - QVector2D pos = row[kPositionInput].toVec2(); - QVector2D sz = row[kSizeInput].toVec2(); + QVector2D pos = row[k_position_input].to_vec2(); + QVector2D sz = row[k_size_input].to_vec2(); QVector2D half_sz = sz * 0.5; double left_pt = pos.x() + center_pt.x() - half_sz.x(); @@ -96,32 +96,32 @@ void ShapeNodeBase::UpdateGizmoPositions(const NodeValueRow &row, double center_x_pt = mid(left_pt, right_pt); double center_y_pt = mid(top_pt, bottom_pt); - point_gizmo_[kGizmoScaleTopLeft]->SetPoint(QPointF(left_pt, top_pt)); - point_gizmo_[kGizmoScaleTopCenter]->SetPoint(QPointF(center_x_pt, top_pt)); - point_gizmo_[kGizmoScaleTopRight]->SetPoint(QPointF(right_pt, top_pt)); - point_gizmo_[kGizmoScaleBottomLeft]->SetPoint(QPointF(left_pt, bottom_pt)); - point_gizmo_[kGizmoScaleBottomCenter]->SetPoint( + point_gizmo_[k_gizmo_scale_top_left]->set_point(QPointF(left_pt, top_pt)); + point_gizmo_[k_gizmo_scale_top_center]->set_point(QPointF(center_x_pt, top_pt)); + point_gizmo_[k_gizmo_scale_top_right]->set_point(QPointF(right_pt, top_pt)); + point_gizmo_[k_gizmo_scale_bottom_left]->set_point(QPointF(left_pt, bottom_pt)); + point_gizmo_[k_gizmo_scale_bottom_center]->set_point( QPointF(center_x_pt, bottom_pt)); - point_gizmo_[kGizmoScaleBottomRight]->SetPoint( + point_gizmo_[k_gizmo_scale_bottom_right]->set_point( QPointF(right_pt, bottom_pt)); - point_gizmo_[kGizmoScaleCenterLeft]->SetPoint( + point_gizmo_[k_gizmo_scale_center_left]->set_point( QPointF(left_pt, center_y_pt)); - point_gizmo_[kGizmoScaleCenterRight]->SetPoint( + point_gizmo_[k_gizmo_scale_center_right]->set_point( QPointF(right_pt, center_y_pt)); - poly_gizmo_->SetPolygon( + poly_gizmo_->set_polygon( QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt)); } -void ShapeNodeBase::SetRect(QRectF rect, const VideoParams &sequence_res, +void ShapeNodeBase::set_rect(QRectF rect, const VideoParams &sequence_res, MultiUndoCommand *command) { // Normalize around center of sequence rect.translate(-sequence_res.width() * 0.5, -sequence_res.height() * 0.5); rect.translate(rect.width() * 0.5, rect.height() * 0.5); - NodeInput pos(this, ShapeNodeBase::kPositionInput); - NodeInput sz(this, ShapeNodeBase::kSizeInput); + NodeInput pos(this, ShapeNodeBase::k_position_input); + NodeInput sz(this, ShapeNodeBase::k_size_input); command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference(sz, 0), rect.width())); @@ -133,40 +133,40 @@ void ShapeNodeBase::SetRect(QRectF rect, const VideoParams &sequence_res, NodeKeyframeTrackReference(pos, 1), rect.y())); } -void ShapeNodeBase::GizmoDragMove(double x, double y, +void ShapeNodeBase::gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { DraggableGizmo *gizmo = static_cast(sender()); - NodeInputDragger &x_drag = gizmo->GetDraggers()[0]; - NodeInputDragger &y_drag = gizmo->GetDraggers()[1]; + NodeInputDragger &x_drag = gizmo->get_draggers()[0]; + NodeInputDragger &y_drag = gizmo->get_draggers()[1]; if (gizmo == poly_gizmo_) { - x_drag.Drag(x_drag.GetStartValue().toDouble() + x); - y_drag.Drag(y_drag.GetStartValue().toDouble() + y); + x_drag.drag(x_drag.get_start_value().toDouble() + x); + y_drag.drag(y_drag.get_start_value().toDouble() + y); } else { bool from_center = modifiers & Qt::AltModifier; bool keep_ratio = modifiers & Qt::ShiftModifier; - NodeInputDragger &w_drag = gizmo->GetDraggers()[2]; - NodeInputDragger &h_drag = gizmo->GetDraggers()[3]; + NodeInputDragger &w_drag = gizmo->get_draggers()[2]; + NodeInputDragger &h_drag = gizmo->get_draggers()[3]; - QVector2D gizmo_sz_start(w_drag.GetStartValue().toDouble(), - h_drag.GetStartValue().toDouble()); - QVector2D gizmo_pos_start(x_drag.GetStartValue().toDouble(), - y_drag.GetStartValue().toDouble()); - QVector2D gizmo_half_res = gizmo->GetGlobals().square_resolution() / 2; + QVector2D gizmo_sz_start(w_drag.get_start_value().toDouble(), + h_drag.get_start_value().toDouble()); + QVector2D gizmo_pos_start(x_drag.get_start_value().toDouble(), + y_drag.get_start_value().toDouble()); + QVector2D gizmo_half_res = gizmo->get_globals().square_resolution() / 2; QVector2D adjusted_pt(x, y); QVector2D new_size; QVector2D new_pos; QVector2D anchor; - static const int kXYCount = 2; - bool negative[kXYCount] = { false }; + static const int k_xy_count = 2; + bool negative[k_xy_count] = { false }; double original_ratio; if (keep_ratio) { - original_ratio = w_drag.GetStartValue().toDouble() / - h_drag.GetStartValue().toDouble(); + original_ratio = w_drag.get_start_value().toDouble() / + h_drag.get_start_value().toDouble(); } // Calculate new size @@ -174,11 +174,11 @@ void ShapeNodeBase::GizmoDragMove(double x, double y, // Calculate new size by using distance from center and doubling it new_size = (adjusted_pt - gizmo_half_res - gizmo_pos_start) * 2; - if (IsGizmoTop(gizmo)) { + if (is_gizmo_top(gizmo)) { new_size.setY(-new_size.y()); } - if (IsGizmoLeft(gizmo)) { + if (is_gizmo_left(gizmo)) { new_size.setX(-new_size.x()); } } else { @@ -186,7 +186,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y, // from the gizmo being dragged adjusted_pt -= gizmo_half_res; - anchor = GenerateGizmoAnchor(gizmo_pos_start, gizmo_sz_start, gizmo, + anchor = generate_gizmo_anchor(gizmo_pos_start, gizmo_sz_start, gizmo, &adjusted_pt) + gizmo_half_res; @@ -196,7 +196,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y, new_size = adjusted_pt - anchor; // Abs size so neither coord is negative - for (int i = 0; i < kXYCount; i++) { + for (int i = 0; i < k_xy_count; i++) { if (new_size[i] < 0) { negative[i] = true; new_size[i] = -new_size[i]; @@ -205,7 +205,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y, } // Restrict sizes by constraints - if (IsGizmoVerticalCenter(gizmo)) { + if (is_gizmo_vertical_center(gizmo)) { if (keep_ratio) { // Calculate width from new height new_size.setX(new_size.y() * original_ratio); @@ -215,7 +215,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y, } } - if (IsGizmoHorizontalCenter(gizmo)) { + if (is_gizmo_horizontal_center(gizmo)) { if (keep_ratio) { // Calculate height from new width new_size.setY(new_size.x() / original_ratio); @@ -225,7 +225,7 @@ void ShapeNodeBase::GizmoDragMove(double x, double y, } } - if (IsGizmoCorner(gizmo)) { + if (is_gizmo_corner(gizmo)) { if (keep_ratio) { float hypot = std::hypot(new_size.x(), new_size.y()); @@ -245,34 +245,34 @@ void ShapeNodeBase::GizmoDragMove(double x, double y, QVector2D using_size = new_size; // Un-abs size - for (int i = 0; i < kXYCount; i++) { + for (int i = 0; i < k_xy_count; i++) { if (negative[i]) { using_size[i] = -using_size[i]; } } // I'm pretty sure there's an algorithmic way of doing this, but I'm tired and this works - if (IsGizmoHorizontalCenter(gizmo)) { + if (is_gizmo_horizontal_center(gizmo)) { using_size.setY(0); } - if (IsGizmoVerticalCenter(gizmo)) { + if (is_gizmo_vertical_center(gizmo)) { using_size.setX(0); } new_pos = - GenerateGizmoAnchor(gizmo_pos_start, gizmo_sz_start, gizmo) + + generate_gizmo_anchor(gizmo_pos_start, gizmo_sz_start, gizmo) + using_size / 2; } - x_drag.Drag(new_pos.x()); - y_drag.Drag(new_pos.y()); - w_drag.Drag(new_size.x()); - h_drag.Drag(new_size.y()); + x_drag.drag(new_pos.x()); + y_drag.drag(new_pos.y()); + w_drag.drag(new_size.x()); + h_drag.drag(new_size.y()); } } -QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos, +QVector2D ShapeNodeBase::generate_gizmo_anchor(const QVector2D &pos, const QVector2D &size, NodeGizmo *gizmo, QVector2D *pt) const @@ -280,28 +280,28 @@ QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos, QVector2D anchor = pos; QVector2D half_sz = size / 2; - if (IsGizmoLeft(gizmo)) { + if (is_gizmo_left(gizmo)) { anchor.setX(anchor.x() + half_sz.x()); if (pt && pt->x() > anchor.x()) { pt->setX(anchor.x()); } } - if (IsGizmoRight(gizmo)) { + if (is_gizmo_right(gizmo)) { anchor.setX(anchor.x() - half_sz.x()); if (pt && pt->x() < anchor.x()) { pt->setX(anchor.x()); } } - if (IsGizmoTop(gizmo)) { + if (is_gizmo_top(gizmo)) { anchor.setY(anchor.y() + half_sz.y()); if (pt && pt->y() > anchor.y()) { pt->setY(anchor.y()); } } - if (IsGizmoBottom(gizmo)) { + if (is_gizmo_bottom(gizmo)) { anchor.setY(anchor.y() - half_sz.y()); if (pt && pt->y() < anchor.y()) { pt->setY(anchor.y()); @@ -311,52 +311,52 @@ QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos, return anchor; } -bool ShapeNodeBase::IsGizmoTop(NodeGizmo *g) const +bool ShapeNodeBase::is_gizmo_top(NodeGizmo *g) const { - return g == point_gizmo_[kGizmoScaleTopCenter] || - g == point_gizmo_[kGizmoScaleTopLeft] || - g == point_gizmo_[kGizmoScaleTopRight]; + return g == point_gizmo_[k_gizmo_scale_top_center] || + g == point_gizmo_[k_gizmo_scale_top_left] || + g == point_gizmo_[k_gizmo_scale_top_right]; } -bool ShapeNodeBase::IsGizmoBottom(NodeGizmo *g) const +bool ShapeNodeBase::is_gizmo_bottom(NodeGizmo *g) const { - return g == point_gizmo_[kGizmoScaleBottomCenter] || - g == point_gizmo_[kGizmoScaleBottomLeft] || - g == point_gizmo_[kGizmoScaleBottomRight]; + return g == point_gizmo_[k_gizmo_scale_bottom_center] || + g == point_gizmo_[k_gizmo_scale_bottom_left] || + g == point_gizmo_[k_gizmo_scale_bottom_right]; } -bool ShapeNodeBase::IsGizmoLeft(NodeGizmo *g) const +bool ShapeNodeBase::is_gizmo_left(NodeGizmo *g) const { - return g == point_gizmo_[kGizmoScaleTopLeft] || - g == point_gizmo_[kGizmoScaleCenterLeft] || - g == point_gizmo_[kGizmoScaleBottomLeft]; + return g == point_gizmo_[k_gizmo_scale_top_left] || + g == point_gizmo_[k_gizmo_scale_center_left] || + g == point_gizmo_[k_gizmo_scale_bottom_left]; } -bool ShapeNodeBase::IsGizmoRight(NodeGizmo *g) const +bool ShapeNodeBase::is_gizmo_right(NodeGizmo *g) const { - return g == point_gizmo_[kGizmoScaleTopRight] || - g == point_gizmo_[kGizmoScaleCenterRight] || - g == point_gizmo_[kGizmoScaleBottomRight]; + return g == point_gizmo_[k_gizmo_scale_top_right] || + g == point_gizmo_[k_gizmo_scale_center_right] || + g == point_gizmo_[k_gizmo_scale_bottom_right]; } -bool ShapeNodeBase::IsGizmoHorizontalCenter(NodeGizmo *g) const +bool ShapeNodeBase::is_gizmo_horizontal_center(NodeGizmo *g) const { - return g == point_gizmo_[kGizmoScaleCenterLeft] || - g == point_gizmo_[kGizmoScaleCenterRight]; + return g == point_gizmo_[k_gizmo_scale_center_left] || + g == point_gizmo_[k_gizmo_scale_center_right]; } -bool ShapeNodeBase::IsGizmoVerticalCenter(NodeGizmo *g) const +bool ShapeNodeBase::is_gizmo_vertical_center(NodeGizmo *g) const { - return g == point_gizmo_[kGizmoScaleTopCenter] || - g == point_gizmo_[kGizmoScaleBottomCenter]; + return g == point_gizmo_[k_gizmo_scale_top_center] || + g == point_gizmo_[k_gizmo_scale_bottom_center]; } -bool ShapeNodeBase::IsGizmoCorner(NodeGizmo *g) const +bool ShapeNodeBase::is_gizmo_corner(NodeGizmo *g) const { - return g == point_gizmo_[kGizmoScaleTopLeft] || - g == point_gizmo_[kGizmoScaleTopRight] || - g == point_gizmo_[kGizmoScaleBottomRight] || - g == point_gizmo_[kGizmoScaleBottomLeft]; + return g == point_gizmo_[k_gizmo_scale_top_left] || + g == point_gizmo_[k_gizmo_scale_top_right] || + g == point_gizmo_[k_gizmo_scale_bottom_right] || + g == point_gizmo_[k_gizmo_scale_bottom_left]; } } diff --git a/app/node/generator/shape/shapenodebase.h b/app/node/generator/shape/shapenodebase.h index becdb29a1..0cef129bf 100644 --- a/app/node/generator/shape/shapenodebase.h +++ b/app/node/generator/shape/shapenodebase.h @@ -19,8 +19,8 @@ ***/ -#ifndef SHAPENODEBASE_H -#define SHAPENODEBASE_H +#ifndef OAK_SHAPENODEBASE_H +#define OAK_SHAPENODEBASE_H #include "generatorwithmerge.h" #include "node/gizmo/point.h" @@ -36,17 +36,17 @@ class ShapeNodeBase : public GeneratorWithMerge { public: ShapeNodeBase(bool create_color_input = true); - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; - void SetRect(QRectF rect, const VideoParams &sequence_res, + void set_rect(QRectF rect, const VideoParams &sequence_res, MultiUndoCommand *command); - static const QString kPositionInput; - static const QString kSizeInput; - static const QString kColorInput; + static const QString k_position_input; + static const QString k_size_input; + static const QString k_color_input; protected: PolygonGizmo *poly_gizmo() const @@ -55,28 +55,28 @@ protected: } protected slots: - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) override; private: - QVector2D GenerateGizmoAnchor(const QVector2D &pos, const QVector2D &size, + QVector2D generate_gizmo_anchor(const QVector2D &pos, const QVector2D &size, NodeGizmo *gizmo, QVector2D *pt = nullptr) const; - bool IsGizmoTop(NodeGizmo *g) const; - bool IsGizmoBottom(NodeGizmo *g) const; - bool IsGizmoLeft(NodeGizmo *g) const; - bool IsGizmoRight(NodeGizmo *g) const; - bool IsGizmoHorizontalCenter(NodeGizmo *g) const; - bool IsGizmoVerticalCenter(NodeGizmo *g) const; - bool IsGizmoCorner(NodeGizmo *g) const; + bool is_gizmo_top(NodeGizmo *g) const; + bool is_gizmo_bottom(NodeGizmo *g) const; + bool is_gizmo_left(NodeGizmo *g) const; + bool is_gizmo_right(NodeGizmo *g) const; + bool is_gizmo_horizontal_center(NodeGizmo *g) const; + bool is_gizmo_vertical_center(NodeGizmo *g) const; + bool is_gizmo_corner(NodeGizmo *g) const; // Gizmo variables - static const int kGizmoWholeRect = kGizmoScaleCount; - PointGizmo *point_gizmo_[kGizmoScaleCount]; + static const int k_gizmo_whole_rect = k_gizmo_scale_count; + PointGizmo *point_gizmo_[k_gizmo_scale_count]; PolygonGizmo *poly_gizmo_; }; } -#endif // SHAPENODEBASE_H +#endif // OAK_SHAPENODEBASE_H diff --git a/app/node/generator/solid/solid.cpp b/app/node/generator/solid/solid.cpp index 11e7e3137..065b2f5be 100644 --- a/app/node/generator/solid/solid.cpp +++ b/app/node/generator/solid/solid.cpp @@ -24,18 +24,18 @@ namespace olive { -const QString SolidGenerator::kColorInput = QStringLiteral("color_in"); +const QString SolidGenerator::k_color_input = QStringLiteral("color_in"); #define super Node SolidGenerator::SolidGenerator() { // Default to a color that isn't black - AddInput(kColorInput, NodeValue::kColor, + add_input(k_color_input, NodeValue::k_color, QVariant::fromValue(Color(1.0f, 0.0f, 0.0f, 1.0f))); } -QString SolidGenerator::Name() const +QString SolidGenerator::name() const { return tr("Solid"); } @@ -45,36 +45,36 @@ QString SolidGenerator::id() const return QStringLiteral("org.olivevideoeditor.Olive.solidgenerator"); } -QVector SolidGenerator::Category() const +QVector SolidGenerator::category() const { - return { kCategoryGenerator }; + return { k_category_generator }; } -QString SolidGenerator::Description() const +QString SolidGenerator::description() const { return tr("Generate a solid color."); } -void SolidGenerator::Retranslate() +void SolidGenerator::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kColorInput, tr("Color")); + set_input_name(k_color_input, tr("Color")); } -void SolidGenerator::Value(const NodeValueRow &value, +void SolidGenerator::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - table->Push(NodeValue::kTexture, - Texture::Job(globals.vparams(), ShaderJob(value)), this); + table->push(NodeValue::k_texture, + Texture::job(globals.vparams(), ShaderJob(value)), this); } -ShaderCode SolidGenerator::GetShaderCode(const ShaderRequest &request) const +ShaderCode SolidGenerator::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) - return ShaderCode(FileFunctions::ReadFileAsString(":/shaders/solid.frag")); + return ShaderCode(FileFunctions::read_file_as_string(":/shaders/solid.frag")); } } diff --git a/app/node/generator/solid/solid.h b/app/node/generator/solid/solid.h index b8fb0e27c..010b9bc16 100644 --- a/app/node/generator/solid/solid.h +++ b/app/node/generator/solid/solid.h @@ -19,8 +19,8 @@ ***/ -#ifndef SOLIDGENERATOR_H -#define SOLIDGENERATOR_H +#ifndef OAK_SOLIDGENERATOR_H +#define OAK_SOLIDGENERATOR_H #include "node/node.h" @@ -34,21 +34,21 @@ public: NODE_DEFAULT_FUNCTIONS(SolidGenerator) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - static const QString kColorInput; + static const QString k_color_input; }; } -#endif // SOLIDGENERATOR_H +#endif // OAK_SOLIDGENERATOR_H diff --git a/app/node/generator/text/textv1.cpp b/app/node/generator/text/textv1.cpp index 0ac1211b5..68954bb3c 100644 --- a/app/node/generator/text/textv1.cpp +++ b/app/node/generator/text/textv1.cpp @@ -28,39 +28,39 @@ namespace olive { enum TextVerticalAlign { - kVerticalAlignTop, - kVerticalAlignCenter, - kVerticalAlignBottom, + k_vertical_align_top, + k_vertical_align_center, + k_vertical_align_bottom, }; -const QString TextGeneratorV1::kTextInput = QStringLiteral("text_in"); -const QString TextGeneratorV1::kHtmlInput = QStringLiteral("html_in"); -const QString TextGeneratorV1::kColorInput = QStringLiteral("color_in"); -const QString TextGeneratorV1::kVAlignInput = QStringLiteral("valign_in"); -const QString TextGeneratorV1::kFontInput = QStringLiteral("font_in"); -const QString TextGeneratorV1::kFontSizeInput = QStringLiteral("font_size_in"); +const QString TextGeneratorV1::k_text_input = QStringLiteral("text_in"); +const QString TextGeneratorV1::k_html_input = QStringLiteral("html_in"); +const QString TextGeneratorV1::k_color_input = QStringLiteral("color_in"); +const QString TextGeneratorV1::k_v_align_input = QStringLiteral("valign_in"); +const QString TextGeneratorV1::k_font_input = QStringLiteral("font_in"); +const QString TextGeneratorV1::k_font_size_input = QStringLiteral("font_size_in"); #define super Node TextGeneratorV1::TextGeneratorV1() { - AddInput(kTextInput, NodeValue::kText, tr("Sample Text")); + add_input(k_text_input, NodeValue::k_text, tr("Sample Text")); - AddInput(kHtmlInput, NodeValue::kBoolean, false); + add_input(k_html_input, NodeValue::k_boolean, false); - AddInput(kColorInput, NodeValue::kColor, + add_input(k_color_input, NodeValue::k_color, QVariant::fromValue(Color(1.0f, 1.0f, 1.0))); - AddInput(kVAlignInput, NodeValue::kCombo, 1); + add_input(k_v_align_input, NodeValue::k_combo, 1); - AddInput(kFontInput, NodeValue::kFont); + add_input(k_font_input, NodeValue::k_font); - AddInput(kFontSizeInput, NodeValue::kFloat, 72.0f); + add_input(k_font_size_input, NodeValue::k_float, 72.0f); - SetFlag(kDontShowInCreateMenu); + set_flag(k_dont_show_in_create_menu); } -QString TextGeneratorV1::Name() const +QString TextGeneratorV1::name() const { return tr("Text (Legacy)"); } @@ -70,40 +70,40 @@ QString TextGeneratorV1::id() const return QStringLiteral("org.olivevideoeditor.Olive.textgenerator"); } -QVector TextGeneratorV1::Category() const +QVector TextGeneratorV1::category() const { - return { kCategoryGenerator }; + return { k_category_generator }; } -QString TextGeneratorV1::Description() const +QString TextGeneratorV1::description() const { return tr("Generate rich text."); } -void TextGeneratorV1::Retranslate() +void TextGeneratorV1::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextInput, tr("Text")); - SetInputName(kHtmlInput, tr("Enable HTML")); - SetInputName(kFontInput, tr("Font")); - SetInputName(kFontSizeInput, tr("Font Size")); - SetInputName(kColorInput, tr("Color")); - SetInputName(kVAlignInput, tr("Vertical Align")); - SetComboBoxStrings(kVAlignInput, { tr("Top"), tr("Center"), tr("Bottom") }); + set_input_name(k_text_input, tr("Text")); + set_input_name(k_html_input, tr("Enable HTML")); + set_input_name(k_font_input, tr("Font")); + set_input_name(k_font_size_input, tr("Font Size")); + set_input_name(k_color_input, tr("Color")); + set_input_name(k_v_align_input, tr("Vertical Align")); + set_combo_box_strings(k_v_align_input, { tr("Top"), tr("Center"), tr("Bottom") }); } -void TextGeneratorV1::Value(const NodeValueRow &value, +void TextGeneratorV1::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (!value[kTextInput].toString().isEmpty()) { - table->Push(NodeValue::kTexture, - Texture::Job(globals.vparams(), GenerateJob(value)), this); + if (!value[k_text_input].to_string().isEmpty()) { + table->push(NodeValue::k_texture, + Texture::job(globals.vparams(), GenerateJob(value)), this); } } -void TextGeneratorV1::GenerateFrame(FramePtr frame, +void TextGeneratorV1::generate_frame(FramePtr frame, const GenerateJob &job) const { // This could probably be more optimized, but for now we use Qt to draw to a QImage. @@ -117,15 +117,15 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame, // Set default font QFont default_font; - default_font.setFamily(job.Get(kFontInput).toString()); - default_font.setPointSizeF(job.Get(kFontSizeInput).toDouble()); + default_font.setFamily(job.get(k_font_input).to_string()); + default_font.setPointSizeF(job.get(k_font_size_input).to_double()); text_doc.setDefaultFont(default_font); // Center by default text_doc.setDefaultTextOption(QTextOption(Qt::AlignCenter)); - QString html = job.Get(kTextInput).toString(); - if (job.Get(kHtmlInput).toBool()) { + QString html = job.get(k_text_input).to_string(); + if (job.get(k_html_input).to_bool()) { html.replace('\n', QStringLiteral("
")); text_doc.setHtml(html); } else { @@ -145,19 +145,19 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame, p.translate(tenth_of_width, 0); TextVerticalAlign valign = - static_cast(job.Get(kVAlignInput).toInt()); + static_cast(job.get(k_v_align_input).to_int()); int doc_height = text_doc.size().height(); switch (valign) { - case kVerticalAlignTop: + case k_vertical_align_top: // Push 10% inwards for title safe area p.translate(0, frame->video_params().height() / 10); break; - case kVerticalAlignCenter: + case k_vertical_align_center: // Center align p.translate(0, frame->video_params().height() / 2 - doc_height / 2); break; - case kVerticalAlignBottom: + case k_vertical_align_bottom: // Push 10% inwards for title safe area p.translate(0, frame->video_params().height() - doc_height - frame->video_params().height() / 10); @@ -169,7 +169,7 @@ void TextGeneratorV1::GenerateFrame(FramePtr frame, text_doc.documentLayout()->draw(&p, ctx); // Transplant alpha channel to frame - Color rgb = job.Get(kColorInput).toColor(); + Color rgb = job.get(k_color_input).to_color(); for (int x = 0; x < frame->width(); x++) { for (int y = 0; y < frame->height(); y++) { uchar src_alpha = img.bits()[img.bytesPerLine() * y + x]; diff --git a/app/node/generator/text/textv1.h b/app/node/generator/text/textv1.h index 793d89ae7..ec8c0b980 100644 --- a/app/node/generator/text/textv1.h +++ b/app/node/generator/text/textv1.h @@ -19,8 +19,8 @@ ***/ -#ifndef TEXTGENERATORV1_H -#define TEXTGENERATORV1_H +#ifndef OAK_TEXTGENERATORV1_H +#define OAK_TEXTGENERATORV1_H #include "node/node.h" @@ -34,27 +34,27 @@ public: NODE_DEFAULT_FUNCTIONS(TextGeneratorV1) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void GenerateFrame(FramePtr frame, + virtual void generate_frame(FramePtr frame, const GenerateJob &job) const override; - static const QString kTextInput; - static const QString kHtmlInput; - static const QString kColorInput; - static const QString kVAlignInput; - static const QString kFontInput; - static const QString kFontSizeInput; + static const QString k_text_input; + static const QString k_html_input; + static const QString k_color_input; + static const QString k_v_align_input; + static const QString k_font_input; + static const QString k_font_size_input; }; } -#endif // TEXTGENERATORV1_H +#endif // OAK_TEXTGENERATORV1_H diff --git a/app/node/generator/text/textv2.cpp b/app/node/generator/text/textv2.cpp index a82967b24..20d308eea 100644 --- a/app/node/generator/text/textv2.cpp +++ b/app/node/generator/text/textv2.cpp @@ -32,36 +32,36 @@ namespace olive #define super ShapeNodeBase enum TextVerticalAlign { - kVerticalAlignTop, - kVerticalAlignCenter, - kVerticalAlignBottom, + k_vertical_align_top, + k_vertical_align_center, + k_vertical_align_bottom, }; -const QString TextGeneratorV2::kTextInput = QStringLiteral("text_in"); -const QString TextGeneratorV2::kHtmlInput = QStringLiteral("html_in"); -const QString TextGeneratorV2::kVAlignInput = QStringLiteral("valign_in"); -const QString TextGeneratorV2::kFontInput = QStringLiteral("font_in"); -const QString TextGeneratorV2::kFontSizeInput = QStringLiteral("font_size_in"); +const QString TextGeneratorV2::k_text_input = QStringLiteral("text_in"); +const QString TextGeneratorV2::k_html_input = QStringLiteral("html_in"); +const QString TextGeneratorV2::k_v_align_input = QStringLiteral("valign_in"); +const QString TextGeneratorV2::k_font_input = QStringLiteral("font_in"); +const QString TextGeneratorV2::k_font_size_input = QStringLiteral("font_size_in"); TextGeneratorV2::TextGeneratorV2() { - AddInput(kTextInput, NodeValue::kText, tr("Sample Text")); + add_input(k_text_input, NodeValue::k_text, tr("Sample Text")); - AddInput(kHtmlInput, NodeValue::kBoolean, false); + add_input(k_html_input, NodeValue::k_boolean, false); - AddInput(kVAlignInput, NodeValue::kCombo, kVerticalAlignTop); + add_input(k_v_align_input, NodeValue::k_combo, k_vertical_align_top); - AddInput(kFontInput, NodeValue::kFont); + add_input(k_font_input, NodeValue::k_font); - AddInput(kFontSizeInput, NodeValue::kFloat, 72.0f); + add_input(k_font_size_input, NodeValue::k_float, 72.0f); - SetStandardValue(kColorInput, QVariant::fromValue(Color(1.0f, 1.0f, 1.0))); - SetStandardValue(kSizeInput, QVector2D(400, 300)); + set_standard_value(k_color_input, QVariant::fromValue(Color(1.0f, 1.0f, 1.0))); + set_standard_value(k_size_input, QVector2D(400, 300)); - SetFlag(kDontShowInCreateMenu); + set_flag(k_dont_show_in_create_menu); } -QString TextGeneratorV2::Name() const +QString TextGeneratorV2::name() const { return tr("Text (Legacy)"); } @@ -71,41 +71,41 @@ QString TextGeneratorV2::id() const return QStringLiteral("org.olivevideoeditor.Olive.text2"); } -QVector TextGeneratorV2::Category() const +QVector TextGeneratorV2::category() const { - return { kCategoryGenerator }; + return { k_category_generator }; } -QString TextGeneratorV2::Description() const +QString TextGeneratorV2::description() const { return tr("Generate rich text."); } -void TextGeneratorV2::Retranslate() +void TextGeneratorV2::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextInput, tr("Text")); - SetInputName(kHtmlInput, tr("Enable HTML")); - SetInputName(kFontInput, tr("Font")); - SetInputName(kFontSizeInput, tr("Font Size")); - SetInputName(kVAlignInput, tr("Vertical Align")); - SetComboBoxStrings(kVAlignInput, { tr("Top"), tr("Center"), tr("Bottom") }); + set_input_name(k_text_input, tr("Text")); + set_input_name(k_html_input, tr("Enable HTML")); + set_input_name(k_font_input, tr("Font")); + set_input_name(k_font_size_input, tr("Font Size")); + set_input_name(k_v_align_input, tr("Vertical Align")); + set_combo_box_strings(k_v_align_input, { tr("Top"), tr("Center"), tr("Bottom") }); } -void TextGeneratorV2::Value(const NodeValueRow &value, +void TextGeneratorV2::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (!value[kTextInput].toString().isEmpty()) { + if (!value[k_text_input].to_string().isEmpty()) { GenerateJob job(value); auto text_params = globals.vparams(); - text_params.set_format(PixelFormat::F32); - table->Push(NodeValue::kTexture, Texture::Job(text_params, job), this); + text_params.set_format(PixelFormat::f32); + table->push(NodeValue::k_texture, Texture::job(text_params, job), this); } } -void TextGeneratorV2::GenerateFrame(FramePtr frame, +void TextGeneratorV2::generate_frame(FramePtr frame, const GenerateJob &job) const { // This could probably be more optimized, but for now we use Qt to draw to a QImage. @@ -125,19 +125,19 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame, // Set default font QFont default_font; - default_font.setFamily(job.Get(kFontInput).toString()); - default_font.setPointSizeF(job.Get(kFontSizeInput).toDouble()); + default_font.setFamily(job.get(k_font_input).to_string()); + default_font.setPointSizeF(job.get(k_font_size_input).to_double()); text_doc.setDefaultFont(default_font); - QString html = job.Get(kTextInput).toString(); - if (job.Get(kHtmlInput).toBool()) { + QString html = job.get(k_text_input).to_string(); + if (job.get(k_html_input).to_bool()) { html.replace('\n', QStringLiteral("
")); text_doc.setHtml(html); } else { text_doc.setPlainText(html); } - QVector2D size = job.Get(kSizeInput).toVec2(); + QVector2D size = job.get(k_size_input).to_vec2(); text_doc.setTextWidth(size.x()); // Draw rich text onto image @@ -145,25 +145,25 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame, p.scale(1.0 / frame->video_params().divider(), 1.0 / frame->video_params().divider()); - QVector2D pos = job.Get(kPositionInput).toVec2(); + QVector2D pos = job.get(k_position_input).to_vec2(); p.translate(pos.x() - size.x() / 2, pos.y() - size.y() / 2); p.translate(frame->video_params().width() / 2, frame->video_params().height() / 2); p.setClipRect(0, 0, size.x(), size.y()); TextVerticalAlign valign = - static_cast(job.Get(kVAlignInput).toInt()); + static_cast(job.get(k_v_align_input).to_int()); int doc_height = text_doc.size().height(); switch (valign) { - case kVerticalAlignTop: + case k_vertical_align_top: // Do nothing break; - case kVerticalAlignCenter: + case k_vertical_align_center: // Center align p.translate(0, size.y() / 2 - doc_height / 2); break; - case kVerticalAlignBottom: + case k_vertical_align_bottom: p.translate(0, size.y() - doc_height); break; } @@ -174,7 +174,7 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame, text_doc.documentLayout()->draw(&p, ctx); // Transplant alpha channel to frame - Color rgba = job.Get(kColorInput).toColor(); + Color rgba = job.get(k_color_input).to_color(); #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) __m128 sse_color = _mm_loadu_ps(rgba.data()); #endif @@ -183,11 +183,11 @@ void TextGeneratorV2::GenerateFrame(FramePtr frame, for (int y = 0; y < frame->height(); y++) { uchar *src_y = img.bits() + img.bytesPerLine() * y; float *dst_y = frame_dst + y * frame->linesize_pixels() * - VideoParams::kRGBAChannelCount; + VideoParams::k_rgba_channel_count; for (int x = 0; x < frame->width(); x++) { float alpha = float(src_y[x]) / 255.0f; - float *dst = dst_y + x * VideoParams::kRGBAChannelCount; + float *dst = dst_y + x * VideoParams::k_rgba_channel_count; #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) __m128 sse_alpha = _mm_load1_ps(&alpha); diff --git a/app/node/generator/text/textv2.h b/app/node/generator/text/textv2.h index df6ed4fe9..e9aa16e5c 100644 --- a/app/node/generator/text/textv2.h +++ b/app/node/generator/text/textv2.h @@ -19,8 +19,8 @@ ***/ -#ifndef TEXTGENERATORV2_H -#define TEXTGENERATORV2_H +#ifndef OAK_TEXTGENERATORV2_H +#define OAK_TEXTGENERATORV2_H #include "node/generator/shape/shapenodebase.h" @@ -34,26 +34,26 @@ public: NODE_DEFAULT_FUNCTIONS(TextGeneratorV2) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void GenerateFrame(FramePtr frame, + virtual void generate_frame(FramePtr frame, const GenerateJob &job) const override; - static const QString kTextInput; - static const QString kHtmlInput; - static const QString kVAlignInput; - static const QString kFontInput; - static const QString kFontSizeInput; + static const QString k_text_input; + static const QString k_html_input; + static const QString k_v_align_input; + static const QString k_font_input; + static const QString k_font_size_input; }; } -#endif // TEXTGENERATORV2_H +#endif // OAK_TEXTGENERATORV2_H diff --git a/app/node/generator/text/textv3.cpp b/app/node/generator/text/textv3.cpp index 57b2eced0..25fb6f2aa 100644 --- a/app/node/generator/text/textv3.cpp +++ b/app/node/generator/text/textv3.cpp @@ -36,46 +36,46 @@ namespace olive #define super ShapeNodeBase enum TextVerticalAlign { - kVerticalAlignTop, - kVerticalAlignCenter, - kVerticalAlignBottom, + k_vertical_align_top, + k_vertical_align_center, + k_vertical_align_bottom, }; -const QString TextGeneratorV3::kTextInput = QStringLiteral("text_in"); -const QString TextGeneratorV3::kVerticalAlignmentInput = +const QString TextGeneratorV3::k_text_input = QStringLiteral("text_in"); +const QString TextGeneratorV3::k_vertical_alignment_input = QStringLiteral("valign_in"); -const QString TextGeneratorV3::kUseArgsInput = QStringLiteral("use_args_in"); -const QString TextGeneratorV3::kArgsInput = QStringLiteral("args_in"); +const QString TextGeneratorV3::k_use_args_input = QStringLiteral("use_args_in"); +const QString TextGeneratorV3::k_args_input = QStringLiteral("args_in"); TextGeneratorV3::TextGeneratorV3() : ShapeNodeBase(false) , dont_emit_valign_(false) { - AddInput(kTextInput, NodeValue::kText, + add_input(k_text_input, NodeValue::k_text, QStringLiteral("

%1

") .arg(tr("Sample Text"))); - SetInputProperty(kTextInput, QStringLiteral("vieweronly"), true); + set_input_property(k_text_input, QStringLiteral("vieweronly"), true); - SetStandardValue(kSizeInput, QVector2D(400, 300)); + set_standard_value(k_size_input, QVector2D(400, 300)); - AddInput(kVerticalAlignmentInput, NodeValue::kCombo, - InputFlags(kInputFlagHidden | kInputFlagStatic)); + add_input(k_vertical_alignment_input, NodeValue::k_combo, + InputFlags(k_input_flag_hidden | k_input_flag_static)); - AddInput(kUseArgsInput, NodeValue::kBoolean, true, - InputFlags(kInputFlagHidden | kInputFlagStatic)); + add_input(k_use_args_input, NodeValue::k_boolean, true, + InputFlags(k_input_flag_hidden | k_input_flag_static)); - AddInput(kArgsInput, NodeValue::kText, InputFlags(kInputFlagArray)); - SetInputProperty(kArgsInput, QStringLiteral("arraystart"), 1); + add_input(k_args_input, NodeValue::k_text, InputFlags(k_input_flag_array)); + set_input_property(k_args_input, QStringLiteral("arraystart"), 1); text_gizmo_ = new TextGizmo(this); - text_gizmo_->SetInput(NodeInput(this, kTextInput)); - connect(text_gizmo_, &TextGizmo::Activated, this, - &TextGeneratorV3::GizmoActivated); - connect(text_gizmo_, &TextGizmo::Deactivated, this, - &TextGeneratorV3::GizmoDeactivated); + text_gizmo_->set_input(NodeInput(this, k_text_input)); + connect(text_gizmo_, &TextGizmo::activated, this, + &TextGeneratorV3::gizmo_activated); + connect(text_gizmo_, &TextGizmo::deactivated, this, + &TextGeneratorV3::gizmo_deactivated); } -QString TextGeneratorV3::Name() const +QString TextGeneratorV3::name() const { return tr("Text"); } @@ -85,64 +85,64 @@ QString TextGeneratorV3::id() const return QStringLiteral("org.olivevideoeditor.Olive.text3"); } -QVector TextGeneratorV3::Category() const +QVector TextGeneratorV3::category() const { - return { kCategoryGenerator }; + return { k_category_generator }; } -QString TextGeneratorV3::Description() const +QString TextGeneratorV3::description() const { return tr("Generate rich text."); } -void TextGeneratorV3::Retranslate() +void TextGeneratorV3::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextInput, tr("Text")); - SetInputName(kVerticalAlignmentInput, tr("Vertical Alignment")); - SetComboBoxStrings(kVerticalAlignmentInput, + set_input_name(k_text_input, tr("Text")); + set_input_name(k_vertical_alignment_input, tr("Vertical Alignment")); + set_combo_box_strings(k_vertical_alignment_input, { tr("Top"), tr("Middle"), tr("Bottom") }); - SetInputName(kArgsInput, tr("Arguments")); + set_input_name(k_args_input, tr("Arguments")); } -void TextGeneratorV3::Value(const NodeValueRow &value, +void TextGeneratorV3::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - QString text = value[kTextInput].toString(); + QString text = value[k_text_input].to_string(); - if (value[kUseArgsInput].toBool()) { - auto args = value[kArgsInput].toArray(); + if (value[k_use_args_input].to_bool()) { + auto args = value[k_args_input].to_array(); if (!args.empty()) { QStringList list; list.reserve(args.size()); for (size_t i = 0; i < args.size(); i++) { - list.append(args[i].toString()); + list.append(args[i].to_string()); } - text = FormatString(text, list); + text = format_string(text, list); } } if (!text.isEmpty()) { - TexturePtr base = value[kTextInput].toTexture(); + TexturePtr base = value[k_text_input].to_texture(); VideoParams text_params = base ? base->params() : globals.vparams(); - text_params.set_format(PixelFormat::U8); + text_params.set_format(PixelFormat::u8); text_params.set_colorspace( - project()->color_manager()->GetDefaultInputColorSpace()); + project()->color_manager()->get_default_input_color_space()); GenerateJob job(value); - job.Insert(kTextInput, NodeValue(NodeValue::kText, text)); + job.insert(k_text_input, NodeValue(NodeValue::k_text, text)); - PushMergableJob(value, Texture::Job(text_params, job), table); - } else if (value[kBaseInput].toTexture()) { - table->Push(value[kBaseInput]); + push_mergable_job(value, Texture::job(text_params, job), table); + } else if (value[k_base_input].to_texture()) { + table->push(value[k_base_input]); } } -void TextGeneratorV3::GenerateFrame(FramePtr frame, +void TextGeneratorV3::generate_frame(FramePtr frame, const GenerateJob &job) const { QImage img(reinterpret_cast(frame->data()), frame->width(), @@ -158,10 +158,10 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame, QTextDocument text_doc; text_doc.documentLayout()->setPaintDevice(&img); - QString html = job.Get(kTextInput).toString(); - Html::HtmlToDoc(&text_doc, html); + QString html = job.get(k_text_input).to_string(); + Html::html_to_doc(&text_doc, html); - QVector2D size = job.Get(kSizeInput).toVec2(); + QVector2D size = job.get(k_size_input).to_vec2(); text_doc.setTextWidth(size.x()); // Draw rich text onto image @@ -169,21 +169,21 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame, p.scale(1.0 / frame->video_params().divider(), 1.0 / frame->video_params().divider()); - QVector2D pos = job.Get(kPositionInput).toVec2(); + QVector2D pos = job.get(k_position_input).to_vec2(); p.translate(pos.x() - size.x() / 2, pos.y() - size.y() / 2); p.translate(frame->video_params().width() / 2, frame->video_params().height() / 2); p.setClipRect(0, 0, size.x(), size.y()); switch (static_cast( - job.Get(kVerticalAlignmentInput).toInt())) { - case kVAlignTop: + job.get(k_vertical_alignment_input).to_int())) { + case k_v_align_top: // Do nothing break; - case kVAlignMiddle: + case k_v_align_middle: p.translate(0, size.y() / 2 - text_doc.size().height() / 2); break; - case kVAlignBottom: + case k_v_align_bottom: p.translate(0, size.y() - text_doc.size().height()); break; } @@ -195,45 +195,45 @@ void TextGeneratorV3::GenerateFrame(FramePtr frame, text_doc.documentLayout()->draw(&p, ctx); } -void TextGeneratorV3::UpdateGizmoPositions(const NodeValueRow &row, +void TextGeneratorV3::update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { - super::UpdateGizmoPositions(row, globals); + super::update_gizmo_positions(row, globals); - QRectF rect = poly_gizmo()->GetPolygon().boundingRect(); - text_gizmo_->SetRect(rect); - text_gizmo_->SetHtml(row[kTextInput].toString()); + QRectF rect = poly_gizmo()->get_polygon().boundingRect(); + text_gizmo_->set_rect(rect); + text_gizmo_->set_html(row[k_text_input].to_string()); } -Qt::Alignment TextGeneratorV3::GetQtAlignmentFromOurs(VerticalAlignment v) +Qt::Alignment TextGeneratorV3::get_qt_alignment_from_ours(VerticalAlignment v) { switch (v) { - case kVAlignTop: + case k_v_align_top: return Qt::AlignTop; - case kVAlignMiddle: + case k_v_align_middle: return Qt::AlignVCenter; - case kVAlignBottom: + case k_v_align_bottom: return Qt::AlignBottom; } return Qt::Alignment(); } TextGeneratorV3::VerticalAlignment -TextGeneratorV3::GetOurAlignmentFromQts(Qt::Alignment v) +TextGeneratorV3::get_our_alignment_from_qts(Qt::Alignment v) { switch (v) { case Qt::AlignTop: - return kVAlignTop; + return k_v_align_top; case Qt::AlignVCenter: - return kVAlignMiddle; + return k_v_align_middle; case Qt::AlignBottom: - return kVAlignBottom; + return k_v_align_bottom; } - return kVAlignTop; + return k_v_align_top; } -QString TextGeneratorV3::FormatString(const QString &input, +QString TextGeneratorV3::format_string(const QString &input, const QStringList &args) { QString output; @@ -274,36 +274,36 @@ QString TextGeneratorV3::FormatString(const QString &input, void TextGeneratorV3::InputValueChangedEvent(const QString &input, int element) { - if (input == kVerticalAlignmentInput && !dont_emit_valign_) { - text_gizmo_->SetVerticalAlignment( - GetQtAlignmentFromOurs(GetVerticalAlignment())); + if (input == k_vertical_alignment_input && !dont_emit_valign_) { + text_gizmo_->set_vertical_alignment( + get_qt_alignment_from_ours(get_vertical_alignment())); } super::InputValueChangedEvent(input, element); } -void TextGeneratorV3::GizmoActivated() +void TextGeneratorV3::gizmo_activated() { - SetStandardValue(kUseArgsInput, false); - connect(text_gizmo_, &TextGizmo::VerticalAlignmentChanged, this, - &TextGeneratorV3::SetVerticalAlignmentUndoable); + set_standard_value(k_use_args_input, false); + connect(text_gizmo_, &TextGizmo::vertical_alignment_changed, this, + &TextGeneratorV3::set_vertical_alignment_undoable); dont_emit_valign_ = true; } -void TextGeneratorV3::GizmoDeactivated() +void TextGeneratorV3::gizmo_deactivated() { - SetStandardValue(kUseArgsInput, true); - disconnect(text_gizmo_, &TextGizmo::VerticalAlignmentChanged, this, - &TextGeneratorV3::SetVerticalAlignmentUndoable); + set_standard_value(k_use_args_input, true); + disconnect(text_gizmo_, &TextGizmo::vertical_alignment_changed, this, + &TextGeneratorV3::set_vertical_alignment_undoable); dont_emit_valign_ = true; } -void TextGeneratorV3::SetVerticalAlignmentUndoable(Qt::Alignment a) +void TextGeneratorV3::set_vertical_alignment_undoable(Qt::Alignment a) { Core::instance()->undo_stack()->push( new NodeParamSetStandardValueCommand(NodeInput(this, - kVerticalAlignmentInput), - GetOurAlignmentFromQts(a)), + k_vertical_alignment_input), + get_our_alignment_from_qts(a)), tr("Set Text Vertical Alignment")); } diff --git a/app/node/generator/text/textv3.h b/app/node/generator/text/textv3.h index 47a641c95..b5b8051c6 100644 --- a/app/node/generator/text/textv3.h +++ b/app/node/generator/text/textv3.h @@ -19,8 +19,8 @@ ***/ -#ifndef TEXTGENERATORV3_H -#define TEXTGENERATORV3_H +#ifndef OAK_TEXTGENERATORV3_H +#define OAK_TEXTGENERATORV3_H #include "node/generator/shape/shapenodebase.h" #include "node/gizmo/text.h" @@ -35,39 +35,39 @@ public: NODE_DEFAULT_FUNCTIONS(TextGeneratorV3) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void GenerateFrame(FramePtr frame, + virtual void generate_frame(FramePtr frame, const GenerateJob &job) const override; - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) override; - enum VerticalAlignment { kVAlignTop, kVAlignMiddle, kVAlignBottom }; + enum VerticalAlignment { k_v_align_top, k_v_align_middle, k_v_align_bottom }; - VerticalAlignment GetVerticalAlignment() const + VerticalAlignment get_vertical_alignment() const { return static_cast( - GetStandardValue(kVerticalAlignmentInput).toInt()); + get_standard_value(k_vertical_alignment_input).toInt()); } - static Qt::Alignment GetQtAlignmentFromOurs(VerticalAlignment v); - static VerticalAlignment GetOurAlignmentFromQts(Qt::Alignment v); + static Qt::Alignment get_qt_alignment_from_ours(VerticalAlignment v); + static VerticalAlignment get_our_alignment_from_qts(Qt::Alignment v); - static const QString kTextInput; - static const QString kVerticalAlignmentInput; - static const QString kUseArgsInput; - static const QString kArgsInput; + static const QString k_text_input; + static const QString k_vertical_alignment_input; + static const QString k_use_args_input; + static const QString k_args_input; - static QString FormatString(const QString &input, const QStringList &args); + static QString format_string(const QString &input, const QStringList &args); protected: virtual void InputValueChangedEvent(const QString &input, @@ -79,11 +79,11 @@ private: bool dont_emit_valign_; private slots: - void GizmoActivated(); - void GizmoDeactivated(); - void SetVerticalAlignmentUndoable(Qt::Alignment a); + void gizmo_activated(); + void gizmo_deactivated(); + void set_vertical_alignment_undoable(Qt::Alignment a); }; } -#endif // TEXTGENERATORV3_H +#endif // OAK_TEXTGENERATORV3_H diff --git a/app/node/gizmo/draggable.cpp b/app/node/gizmo/draggable.cpp index db2aa1ab4..bfd6ca9d8 100644 --- a/app/node/gizmo/draggable.cpp +++ b/app/node/gizmo/draggable.cpp @@ -26,30 +26,30 @@ namespace olive DraggableGizmo::DraggableGizmo(QObject *parent) : NodeGizmo{ parent } - , drag_value_behavior_(kAbsolute) + , drag_value_behavior_(k_absolute) { } -void DraggableGizmo::DragStart(const NodeValueRow &row, double abs_x, - double abs_y, const rational &time) +void DraggableGizmo::drag_start(const NodeValueRow &row, double abs_x, + double abs_y, const Rational &time) { for (int i = 0; i < draggers_.size(); i++) { - draggers_[i].Start(inputs_[i], time); + draggers_[i].start(inputs_[i], time); } - emit HandleStart(row, abs_x, abs_y, time); + emit handle_start(row, abs_x, abs_y, time); } -void DraggableGizmo::DragMove(double x, double y, +void DraggableGizmo::drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { - emit HandleMovement(x, y, modifiers); + emit handle_movement(x, y, modifiers); } -void DraggableGizmo::DragEnd(MultiUndoCommand *command) +void DraggableGizmo::drag_end(MultiUndoCommand *command) { for (int i = 0; i < draggers_.size(); i++) { - draggers_[i].End(command); + draggers_[i].end(command); } } diff --git a/app/node/gizmo/draggable.h b/app/node/gizmo/draggable.h index fdde2c94e..b26493aa0 100644 --- a/app/node/gizmo/draggable.h +++ b/app/node/gizmo/draggable.h @@ -19,8 +19,8 @@ ***/ -#ifndef DRAGGABLEGIZMO_H -#define DRAGGABLEGIZMO_H +#ifndef OAK_DRAGGABLEGIZMO_H +#define OAK_DRAGGABLEGIZMO_H #include "gizmo.h" #include "node/inputdragger.h" @@ -35,49 +35,49 @@ public: /// Changes what the X/Y coordinates emitted from HandleMovement specify enum DragValueBehavior { /// X/Y will be the exact mouse coordinates (in sequence pixels) - kAbsolute, + k_absolute, /// X/Y will be the movement since the last time HandleMovement was called - kDeltaFromPrevious, + k_delta_from_previous, /// X/Y will be the movement from the start of the drag - kDeltaFromStart + k_delta_from_start }; explicit DraggableGizmo(QObject *parent = nullptr); - void DragStart(const NodeValueRow &row, double abs_x, double abs_y, - const olive::core::rational &time); + void drag_start(const NodeValueRow &row, double abs_x, double abs_y, + const olive::core::Rational &time); - void DragMove(double x, double y, const Qt::KeyboardModifiers &modifiers); + void drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers); - void DragEnd(olive::MultiUndoCommand *command); + void drag_end(olive::MultiUndoCommand *command); - void AddInput(const NodeKeyframeTrackReference &input) + void add_input(const NodeKeyframeTrackReference &input) { inputs_.append(input); draggers_.append(NodeInputDragger()); } - QVector &GetDraggers() + QVector &get_draggers() { return draggers_; } - DragValueBehavior GetDragValueBehavior() const + DragValueBehavior get_drag_value_behavior() const { return drag_value_behavior_; } - void SetDragValueBehavior(DragValueBehavior d) + void set_drag_value_behavior(DragValueBehavior d) { drag_value_behavior_ = d; } signals: - void HandleStart(const olive::NodeValueRow &row, double x, double y, - const olive::core::rational &time); + void handle_start(const olive::NodeValueRow &row, double x, double y, + const olive::core::Rational &time); - void HandleMovement(double x, double y, + void handle_movement(double x, double y, const Qt::KeyboardModifiers &modifiers); private: @@ -90,4 +90,4 @@ private: } -#endif // DRAGGABLEGIZMO_H +#endif // OAK_DRAGGABLEGIZMO_H diff --git a/app/node/gizmo/gizmo.h b/app/node/gizmo/gizmo.h index db3a0d7da..74120627a 100644 --- a/app/node/gizmo/gizmo.h +++ b/app/node/gizmo/gizmo.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEGIZMO_H -#define NODEGIZMO_H +#ifndef OAK_NODEGIZMO_H +#define OAK_NODEGIZMO_H #include #include @@ -36,24 +36,24 @@ public: explicit NodeGizmo(QObject *parent = nullptr); virtual ~NodeGizmo() override; - virtual void Draw(QPainter *p) const + virtual void draw(QPainter *p) const { } - const NodeGlobals &GetGlobals() const + const NodeGlobals &get_globals() const { return globals_; } - void SetGlobals(const NodeGlobals &globals) + void set_globals(const NodeGlobals &globals) { globals_ = globals; } - bool IsVisible() const + bool is_visible() const { return visible_; } - void SetVisible(bool e) + void set_visible(bool e) { visible_ = e; } @@ -68,4 +68,4 @@ private: } -#endif // NODEGIZMO_H +#endif // OAK_NODEGIZMO_H diff --git a/app/node/gizmo/line.cpp b/app/node/gizmo/line.cpp index 7cf127127..49d497545 100644 --- a/app/node/gizmo/line.cpp +++ b/app/node/gizmo/line.cpp @@ -29,7 +29,7 @@ LineGizmo::LineGizmo(QObject *parent) { } -void LineGizmo::Draw(QPainter *p) const +void LineGizmo::draw(QPainter *p) const { // Draw transposed black QLineF transposed = p->transform().map(line_); diff --git a/app/node/gizmo/line.h b/app/node/gizmo/line.h index f60573199..0ef7e8831 100644 --- a/app/node/gizmo/line.h +++ b/app/node/gizmo/line.h @@ -19,8 +19,8 @@ ***/ -#ifndef LINEGIZMO_H -#define LINEGIZMO_H +#ifndef OAK_LINEGIZMO_H +#define OAK_LINEGIZMO_H #include @@ -34,16 +34,16 @@ class LineGizmo : public NodeGizmo { public: LineGizmo(QObject *parent = nullptr); - const QLineF &GetLine() const + const QLineF &get_line() const { return line_; } - void SetLine(const QLineF &line) + void set_line(const QLineF &line) { line_ = line; } - virtual void Draw(QPainter *p) const override; + virtual void draw(QPainter *p) const override; private: QLineF line_; @@ -51,4 +51,4 @@ private: } -#endif // LINEGIZMO_H +#endif // OAK_LINEGIZMO_H diff --git a/app/node/gizmo/path.cpp b/app/node/gizmo/path.cpp index 4e7eb6e09..f78a69f74 100644 --- a/app/node/gizmo/path.cpp +++ b/app/node/gizmo/path.cpp @@ -29,7 +29,7 @@ PathGizmo::PathGizmo(QObject *parent) { } -void PathGizmo::Draw(QPainter *p) const +void PathGizmo::draw(QPainter *p) const { // Draw transposed black QPainterPath transposed = p->transform().map(path_); diff --git a/app/node/gizmo/path.h b/app/node/gizmo/path.h index d0d1081ab..f395b5c96 100644 --- a/app/node/gizmo/path.h +++ b/app/node/gizmo/path.h @@ -19,8 +19,8 @@ ***/ -#ifndef PATHGIZMO_H -#define PATHGIZMO_H +#ifndef OAK_PATHGIZMO_H +#define OAK_PATHGIZMO_H #include @@ -34,16 +34,16 @@ class PathGizmo : public DraggableGizmo { public: explicit PathGizmo(QObject *parent = nullptr); - const QPainterPath &GetPath() const + const QPainterPath &get_path() const { return path_; } - void SetPath(const QPainterPath &path) + void set_path(const QPainterPath &path) { path_ = path; } - virtual void Draw(QPainter *p) const override; + virtual void draw(QPainter *p) const override; private: QPainterPath path_; @@ -51,4 +51,4 @@ private: } -#endif // PATHGIZMO_H +#endif // OAK_PATHGIZMO_H diff --git a/app/node/gizmo/point.cpp b/app/node/gizmo/point.cpp index 957ccd866..6f71bf1d0 100644 --- a/app/node/gizmo/point.cpp +++ b/app/node/gizmo/point.cpp @@ -39,27 +39,27 @@ PointGizmo::PointGizmo(const Shape &shape, QObject *parent) } PointGizmo::PointGizmo(QObject *parent) - : PointGizmo(kSquare, parent) + : PointGizmo(k_square, parent) { } -void PointGizmo::Draw(QPainter *p) const +void PointGizmo::draw(QPainter *p) const { - QRectF rect = GetDrawingRect(p->transform(), GetStandardRadius()); + QRectF rect = get_drawing_rect(p->transform(), get_standard_radius()); - if (shape_ != kAnchorPoint) { + if (shape_ != k_anchor_point) { p->setPen(QPen(Qt::black, 0)); p->setBrush(Qt::white); } switch (shape_) { - case kSquare: + case k_square: p->drawRect(rect); break; - case kCircle: + case k_circle: p->drawEllipse(rect); break; - case kAnchorPoint: + case k_anchor_point: p->setPen(QPen(Qt::white, 0)); p->setBrush(Qt::NoBrush); @@ -72,17 +72,17 @@ void PointGizmo::Draw(QPainter *p) const } } -QRectF PointGizmo::GetClickingRect(const QTransform &t) const +QRectF PointGizmo::get_clicking_rect(const QTransform &t) const { - return GetDrawingRect(t, GetStandardRadius()); + return get_drawing_rect(t, get_standard_radius()); } -double PointGizmo::GetStandardRadius() +double PointGizmo::get_standard_radius() { return QFontMetrics(qApp->font()).height() * 0.25; } -QRectF PointGizmo::GetDrawingRect(const QTransform &transform, +QRectF PointGizmo::get_drawing_rect(const QTransform &transform, double radius) const { QRectF r(0, 0, radius, radius); @@ -92,7 +92,7 @@ QRectF PointGizmo::GetDrawingRect(const QTransform &transform, double width = r.width(); double height = r.height(); - if (shape_ == kAnchorPoint) { + if (shape_ == k_anchor_point) { width *= 2; height *= 2; } diff --git a/app/node/gizmo/point.h b/app/node/gizmo/point.h index 22d7d7b64..09c13dfd4 100644 --- a/app/node/gizmo/point.h +++ b/app/node/gizmo/point.h @@ -19,8 +19,8 @@ ***/ -#ifndef POINTGIZMO_H -#define POINTGIZMO_H +#ifndef OAK_POINTGIZMO_H +#define OAK_POINTGIZMO_H #include @@ -32,48 +32,48 @@ namespace olive class PointGizmo : public DraggableGizmo { Q_OBJECT public: - enum Shape { kSquare, kCircle, kAnchorPoint }; + enum Shape { k_square, k_circle, k_anchor_point }; explicit PointGizmo(const Shape &shape, bool smaller, QObject *parent = nullptr); explicit PointGizmo(const Shape &shape, QObject *parent = nullptr); explicit PointGizmo(QObject *parent = nullptr); - const Shape &GetShape() const + const Shape &get_shape() const { return shape_; } - void SetShape(const Shape &s) + void set_shape(const Shape &s) { shape_ = s; } - const QPointF &GetPoint() const + const QPointF &get_point() const { return point_; } - void SetPoint(const QPointF &pt) + void set_point(const QPointF &pt) { point_ = pt; } - bool GetSmaller() const + bool get_smaller() const { return smaller_; } - void SetSmaller(bool e) + void set_smaller(bool e) { smaller_ = e; } - virtual void Draw(QPainter *p) const override; + virtual void draw(QPainter *p) const override; - QRectF GetClickingRect(const QTransform &t) const; + QRectF get_clicking_rect(const QTransform &t) const; private: - static double GetStandardRadius(); + static double get_standard_radius(); - QRectF GetDrawingRect(const QTransform &transform, double radius) const; + QRectF get_drawing_rect(const QTransform &transform, double radius) const; Shape shape_; @@ -84,4 +84,4 @@ private: } -#endif // POINTGIZMO_H +#endif // OAK_POINTGIZMO_H diff --git a/app/node/gizmo/polygon.cpp b/app/node/gizmo/polygon.cpp index 68d73d4cf..a01b0bea7 100644 --- a/app/node/gizmo/polygon.cpp +++ b/app/node/gizmo/polygon.cpp @@ -29,7 +29,7 @@ PolygonGizmo::PolygonGizmo(QObject *parent) { } -void PolygonGizmo::Draw(QPainter *p) const +void PolygonGizmo::draw(QPainter *p) const { // Draw transposed black QPolygonF transposed = p->transform().map(polygon_); diff --git a/app/node/gizmo/polygon.h b/app/node/gizmo/polygon.h index fa4178d15..b4afb2790 100644 --- a/app/node/gizmo/polygon.h +++ b/app/node/gizmo/polygon.h @@ -19,8 +19,8 @@ ***/ -#ifndef POLYGONGIZMO_H -#define POLYGONGIZMO_H +#ifndef OAK_POLYGONGIZMO_H +#define OAK_POLYGONGIZMO_H #include @@ -34,16 +34,16 @@ class PolygonGizmo : public DraggableGizmo { public: explicit PolygonGizmo(QObject *parent = nullptr); - const QPolygonF &GetPolygon() const + const QPolygonF &get_polygon() const { return polygon_; } - void SetPolygon(const QPolygonF &polygon) + void set_polygon(const QPolygonF &polygon) { polygon_ = polygon; } - virtual void Draw(QPainter *p) const override; + virtual void draw(QPainter *p) const override; private: QPolygonF polygon_; @@ -51,4 +51,4 @@ private: } -#endif // POLYGONGIZMO_H +#endif // OAK_POLYGONGIZMO_H diff --git a/app/node/gizmo/screen.h b/app/node/gizmo/screen.h index 1b0bfa224..fbf2486d4 100644 --- a/app/node/gizmo/screen.h +++ b/app/node/gizmo/screen.h @@ -19,8 +19,8 @@ ***/ -#ifndef SCREENGIZMO_H -#define SCREENGIZMO_H +#ifndef OAK_SCREENGIZMO_H +#define OAK_SCREENGIZMO_H #include "draggable.h" @@ -35,4 +35,4 @@ public: } -#endif // SCREENGIZMO_H +#endif // OAK_SCREENGIZMO_H diff --git a/app/node/gizmo/text.cpp b/app/node/gizmo/text.cpp index 97ad2240c..0d8f96cad 100644 --- a/app/node/gizmo/text.cpp +++ b/app/node/gizmo/text.cpp @@ -33,26 +33,26 @@ TextGizmo::TextGizmo(QObject *parent) { } -void TextGizmo::SetRect(const QRectF &r) +void TextGizmo::set_rect(const QRectF &r) { rect_ = r; - emit RectChanged(rect_); + emit rect_changed(rect_); } -void TextGizmo::UpdateInputHtml(const QString &s, const rational &time) +void TextGizmo::update_input_html(const QString &s, const Rational &time) { - if (input_.IsValid()) { + if (input_.is_valid()) { MultiUndoCommand *command = new MultiUndoCommand(); - Node::SetValueAtTime(input_.input(), time, s, input_.track(), command, + Node::set_value_at_time(input_.input(), time, s, input_.track(), command, true); Core::instance()->undo_stack()->push(command, tr("Edit Text")); } } -void TextGizmo::SetVerticalAlignment(Qt::Alignment va) +void TextGizmo::set_vertical_alignment(Qt::Alignment va) { valign_ = va; - emit VerticalAlignmentChanged(valign_); + emit vertical_alignment_changed(valign_); } } diff --git a/app/node/gizmo/text.h b/app/node/gizmo/text.h index ea5e49b3a..bc174cab1 100644 --- a/app/node/gizmo/text.h +++ b/app/node/gizmo/text.h @@ -19,8 +19,8 @@ ***/ -#ifndef TEXTGIZMO_H -#define TEXTGIZMO_H +#ifndef OAK_TEXTGIZMO_H +#define OAK_TEXTGIZMO_H #include "gizmo.h" #include "node/param.h" @@ -33,39 +33,39 @@ class TextGizmo : public NodeGizmo { public: explicit TextGizmo(QObject *parent = nullptr); - const QRectF &GetRect() const + const QRectF &get_rect() const { return rect_; } - void SetRect(const QRectF &r); + void set_rect(const QRectF &r); - const QString &GetHtml() const + const QString &get_html() const { return text_; } - void SetHtml(const QString &t) + void set_html(const QString &t) { text_ = t; } - void SetInput(const NodeKeyframeTrackReference &input) + void set_input(const NodeKeyframeTrackReference &input) { input_ = input; } - void UpdateInputHtml(const QString &s, const rational &time); + void update_input_html(const QString &s, const Rational &time); - Qt::Alignment GetVerticalAlignment() const + Qt::Alignment get_vertical_alignment() const { return valign_; } - void SetVerticalAlignment(Qt::Alignment va); + void set_vertical_alignment(Qt::Alignment va); signals: - void Activated(); - void Deactivated(); - void VerticalAlignmentChanged(Qt::Alignment va); - void RectChanged(const QRectF &r); + void activated(); + void deactivated(); + void vertical_alignment_changed(Qt::Alignment va); + void rect_changed(const QRectF &r); private: QRectF rect_; @@ -79,4 +79,4 @@ private: } -#endif // TEXTGIZMO_H +#endif // OAK_TEXTGIZMO_H diff --git a/app/node/globals.h b/app/node/globals.h index 14e8884bb..808d5370d 100644 --- a/app/node/globals.h +++ b/app/node/globals.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEGLOBALS_H -#define NODEGLOBALS_H +#ifndef OAK_NODEGLOBALS_H +#define OAK_NODEGLOBALS_H #include @@ -46,7 +46,7 @@ public: } NodeGlobals(const VideoParams &vparam, const AudioParams &aparam, - const rational &time, LoopMode loop_mode) + const Rational &time, LoopMode loop_mode) : NodeGlobals(vparam, aparam, TimeRange(time, time + vparam.frame_rate_as_time_base()), loop_mode) @@ -87,4 +87,4 @@ private: } -#endif // NODEGLOBALS_H +#endif // OAK_NODEGLOBALS_H diff --git a/app/node/group/group.cpp b/app/node/group/group.cpp index 9a44eb393..9d28c0169 100644 --- a/app/node/group/group.cpp +++ b/app/node/group/group.cpp @@ -31,10 +31,10 @@ namespace olive NodeGroup::NodeGroup() : output_passthrough_(nullptr) { - SetFlag(kDontShowInCreateMenu); + set_flag(k_dont_show_in_create_menu); } -QString NodeGroup::Name() const +QString NodeGroup::name() const { return tr("Group"); } @@ -44,37 +44,37 @@ QString NodeGroup::id() const return QStringLiteral("org.olivevideoeditor.Olive.group"); } -QVector NodeGroup::Category() const +QVector NodeGroup::category() const { - return { kCategoryUnknown }; + return { k_category_unknown }; } -QString NodeGroup::Description() const +QString NodeGroup::description() const { return tr("A group of nodes that is represented as a single node."); } -void NodeGroup::Retranslate() +void NodeGroup::retranslate() { - super::Retranslate(); + super::retranslate(); - for (auto it = GetContextPositions().cbegin(); - it != GetContextPositions().cend(); it++) { - it.key()->Retranslate(); + for (auto it = get_context_positions().cbegin(); + it != get_context_positions().cend(); it++) { + it.key()->retranslate(); } } -bool NodeGroup::LoadCustom(QXmlStreamReader *reader, SerializedData *data) +bool NodeGroup::load_custom(QXmlStreamReader *reader, SerializedData *data) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthroughs")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthrough")) { SerializedData::GroupLink link; link.group = this; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { link.input_node = reader->readElementText().toULongLong(); @@ -92,22 +92,22 @@ bool NodeGroup::LoadCustom(QXmlStreamReader *reader, SerializedData *data) link.custom_flags = InputFlags( reader->readElementText().toULongLong()); } else if (reader->name() == QStringLiteral("type")) { - link.data_type = NodeValue::GetDataTypeFromName( + link.data_type = NodeValue::get_data_type_from_name( reader->readElementText()); } else if (reader->name() == QStringLiteral("default")) { - link.default_val = NodeValue::StringToValue( + link.default_val = NodeValue::string_to_value( link.data_type, reader->readElementText(), false); } else if (reader->name() == QStringLiteral("properties")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("property")) { QString key; QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("key")) { key = reader->readElementText(); @@ -148,12 +148,12 @@ bool NodeGroup::LoadCustom(QXmlStreamReader *reader, SerializedData *data) return true; } -void NodeGroup::SaveCustom(QXmlStreamWriter *writer) const +void NodeGroup::save_custom(QXmlStreamWriter *writer) const { writer->writeStartElement(QStringLiteral("inputpassthroughs")); foreach (const NodeGroup::InputPassthrough &ip, - this->GetInputPassthroughs()) { + this->get_input_passthroughs()) { writer->writeStartElement(QStringLiteral("inputpassthrough")); // Reference to inner input @@ -170,23 +170,23 @@ void NodeGroup::SaveCustom(QXmlStreamWriter *writer) const // Passthrough-specific details const QString &input = ip.first; writer->writeTextElement(QStringLiteral("name"), - this->Node::GetInputName(input)); + this->Node::get_input_name(input)); writer->writeTextElement( QStringLiteral("flags"), QString::number( - (GetInputFlags(input) & ~ip.second.GetFlags()).value())); + (get_input_flags(input) & ~ip.second.get_flags()).value())); - NodeValue::Type data_type = GetInputDataType(input); + NodeValue::Type data_type = get_input_data_type(input); writer->writeTextElement(QStringLiteral("type"), - NodeValue::GetDataTypeName(data_type)); + NodeValue::get_data_type_name(data_type)); writer->writeTextElement( QStringLiteral("default"), - NodeValue::ValueToString(data_type, GetDefaultValue(input), false)); + NodeValue::value_to_string(data_type, get_default_value(input), false)); writer->writeStartElement(QStringLiteral("properties")); - auto p = GetInputProperties(input); + auto p = get_input_properties(input); for (auto it = p.cbegin(); it != p.cend(); it++) { writer->writeStartElement(QStringLiteral("property")); writer->writeTextElement(QStringLiteral("key"), it.key()); @@ -203,7 +203,7 @@ void NodeGroup::SaveCustom(QXmlStreamWriter *writer) const writer->writeTextElement(QStringLiteral("outputpassthrough"), QString::number(reinterpret_cast( - this->GetOutputPassthrough()))); + this->get_output_passthrough()))); } void NodeGroup::PostLoadEvent(SerializedData *data) @@ -214,22 +214,22 @@ void NodeGroup::PostLoadEvent(SerializedData *data) if (Node *input_node = data->node_ptrs.value(l.input_node)) { NodeInput resolved(input_node, l.input_id, l.input_element); - l.group->AddInputPassthrough(resolved, l.passthrough_id); + l.group->add_input_passthrough(resolved, l.passthrough_id); - l.group->SetInputFlag(l.passthrough_id, + l.group->set_input_flag(l.passthrough_id, InputFlag(l.custom_flags.value())); if (!l.custom_name.isEmpty()) { - l.group->SetInputName(l.passthrough_id, l.custom_name); + l.group->set_input_name(l.passthrough_id, l.custom_name); } - l.group->SetInputDataType(l.passthrough_id, l.data_type); + l.group->set_input_data_type(l.passthrough_id, l.data_type); - l.group->SetDefaultValue(l.passthrough_id, l.default_val); + l.group->set_default_value(l.passthrough_id, l.default_val); for (auto it = l.custom_properties.cbegin(); it != l.custom_properties.cend(); it++) { - l.group->SetInputProperty(l.passthrough_id, it.key(), + l.group->set_input_property(l.passthrough_id, it.key(), it.value()); } } @@ -238,15 +238,15 @@ void NodeGroup::PostLoadEvent(SerializedData *data) for (auto it = data->group_output_links.cbegin(); it != data->group_output_links.cend(); it++) { if (Node *output_node = data->node_ptrs.value(it.value())) { - it.key()->SetOutputPassthrough(output_node); + it.key()->set_output_passthrough(output_node); } } } -QString NodeGroup::AddInputPassthrough(const NodeInput &input, +QString NodeGroup::add_input_passthrough(const NodeInput &input, const QString &force_id) { - Q_ASSERT(ContextContainsNode(input.node())); + Q_ASSERT(context_contains_node(input.node())); for (auto it = input_passthroughs_.cbegin(); it != input_passthroughs_.cend(); it++) { @@ -261,7 +261,7 @@ QString NodeGroup::AddInputPassthrough(const NodeInput &input, if (force_id.isEmpty()) { id = input.input(); int i = 2; - while (HasInputWithID(id)) { + while (has_input_with_id(id)) { id = QStringLiteral("%1_%2").arg(input.input(), QString::number(i)); i++; } @@ -280,39 +280,39 @@ QString NodeGroup::AddInputPassthrough(const NodeInput &input, Q_ASSERT(!already_exists); } - AddInput(id, input.GetDataType(), input.GetDefaultValue(), - input.GetFlags()); + add_input(id, input.get_data_type(), input.get_default_value(), + input.get_flags()); input_passthroughs_.append({ id, input }); - emit InputPassthroughAdded(this, input); + emit input_passthrough_added(this, input); return id; } -void NodeGroup::RemoveInputPassthrough(const NodeInput &input) +void NodeGroup::remove_input_passthrough(const NodeInput &input) { for (auto it = input_passthroughs_.begin(); it != input_passthroughs_.end(); it++) { if (it->second == input) { - RemoveInput(it->first); - emit InputPassthroughRemoved(this, it->second); + remove_input(it->first); + emit input_passthrough_removed(this, it->second); input_passthroughs_.erase(it); break; } } } -void NodeGroup::SetOutputPassthrough(Node *node) +void NodeGroup::set_output_passthrough(Node *node) { - Q_ASSERT(!node || ContextContainsNode(node)); + Q_ASSERT(!node || context_contains_node(node)); output_passthrough_ = node; - emit OutputPassthroughChanged(this, output_passthrough_); + emit output_passthrough_changed(this, output_passthrough_); } -bool NodeGroup::ContainsInputPassthrough(const NodeInput &input) const +bool NodeGroup::contains_input_passthrough(const NodeInput &input) const { for (auto it = input_passthroughs_.cbegin(); it != input_passthroughs_.cend(); it++) { @@ -324,35 +324,35 @@ bool NodeGroup::ContainsInputPassthrough(const NodeInput &input) const return false; } -QString NodeGroup::GetInputName(const QString &id) const +QString NodeGroup::get_input_name(const QString &id) const { // If an override name was set, use that - QString override = super::GetInputName(id); + QString override = super::get_input_name(id); if (!override.isEmpty()) { return override; } // Call GetInputName of passed through node, which may be another group - NodeInput pass = GetInputFromID(id); - if (!pass.IsValid()) { + NodeInput pass = get_input_from_id(id); + if (!pass.is_valid()) { return QString(); } - return pass.node()->GetInputName(pass.input()); + return pass.node()->get_input_name(pass.input()); } -NodeInput NodeGroup::ResolveInput(NodeInput input) +NodeInput NodeGroup::resolve_input(NodeInput input) { - while (GetInner(&input)) { + while (get_inner(&input)) { } return input; } -bool NodeGroup::GetInner(NodeInput *input) +bool NodeGroup::get_inner(NodeInput *input) { if (NodeGroup *g = dynamic_cast(input->node())) { - const NodeInput &passthrough = g->GetInputFromID(input->input()); - if (!passthrough.IsValid()) { + const NodeInput &passthrough = g->get_input_from_id(input->input()); + if (!passthrough.is_valid()) { return false; } @@ -366,8 +366,8 @@ bool NodeGroup::GetInner(NodeInput *input) void NodeGroupAddInputPassthrough::redo() { - if (!group_->ContainsInputPassthrough(input_)) { - group_->AddInputPassthrough(input_, force_id_); + if (!group_->contains_input_passthrough(input_)) { + group_->add_input_passthrough(input_, force_id_); actually_added_ = true; } else { actually_added_ = false; @@ -377,19 +377,19 @@ void NodeGroupAddInputPassthrough::redo() void NodeGroupAddInputPassthrough::undo() { if (actually_added_) { - group_->RemoveInputPassthrough(input_); + group_->remove_input_passthrough(input_); } } void NodeGroupSetOutputPassthrough::redo() { - old_output_ = group_->GetOutputPassthrough(); - group_->SetOutputPassthrough(new_output_); + old_output_ = group_->get_output_passthrough(); + group_->set_output_passthrough(new_output_); } void NodeGroupSetOutputPassthrough::undo() { - group_->SetOutputPassthrough(old_output_); + group_->set_output_passthrough(old_output_); } } diff --git a/app/node/group/group.h b/app/node/group/group.h index ff25faf09..15ca7b144 100644 --- a/app/node/group/group.h +++ b/app/node/group/group.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEGROUP_H -#define NODEGROUP_H +#ifndef OAK_NODEGROUP_H +#define OAK_NODEGROUP_H #include "node/node.h" @@ -34,45 +34,45 @@ public: NODE_DEFAULT_FUNCTIONS(NodeGroup) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual bool LoadCustom(QXmlStreamReader *reader, + virtual bool load_custom(QXmlStreamReader *reader, SerializedData *data) override; - virtual void SaveCustom(QXmlStreamWriter *writer) const override; + virtual void save_custom(QXmlStreamWriter *writer) const override; virtual void PostLoadEvent(SerializedData *data) override; - QString AddInputPassthrough(const NodeInput &input, + QString add_input_passthrough(const NodeInput &input, const QString &force_id = QString()); - void RemoveInputPassthrough(const NodeInput &input); + void remove_input_passthrough(const NodeInput &input); - Node *GetOutputPassthrough() const + Node *get_output_passthrough() const { return output_passthrough_; } - void SetOutputPassthrough(Node *node); + void set_output_passthrough(Node *node); using InputPassthrough = QPair; using InputPassthroughs = QVector; - const InputPassthroughs &GetInputPassthroughs() const + const InputPassthroughs &get_input_passthroughs() const { return input_passthroughs_; } - bool ContainsInputPassthrough(const NodeInput &input) const; + bool contains_input_passthrough(const NodeInput &input) const; - virtual QString GetInputName(const QString &id) const override; + virtual QString get_input_name(const QString &id) const override; - static NodeInput ResolveInput(NodeInput input); - static bool GetInner(NodeInput *input); + static NodeInput resolve_input(NodeInput input); + static bool get_inner(NodeInput *input); - QString GetIDOfPassthrough(const NodeInput &input) const + QString get_id_of_passthrough(const NodeInput &input) const { for (auto it = input_passthroughs_.cbegin(); it != input_passthroughs_.cend(); it++) { @@ -83,7 +83,7 @@ public: return QString(); } - NodeInput GetInputFromID(const QString &id) const + NodeInput get_input_from_id(const QString &id) const { for (auto it = input_passthroughs_.cbegin(); it != input_passthroughs_.cend(); it++) { @@ -95,13 +95,13 @@ public: } signals: - void InputPassthroughAdded(olive::NodeGroup *group, + void input_passthrough_added(olive::NodeGroup *group, const olive::NodeInput &input); - void InputPassthroughRemoved(olive::NodeGroup *group, + void input_passthrough_removed(olive::NodeGroup *group, const olive::NodeInput &input); - void OutputPassthroughChanged(olive::NodeGroup *group, olive::Node *output); + void output_passthrough_changed(olive::NodeGroup *group, olive::Node *output); private: InputPassthroughs input_passthroughs_; @@ -119,7 +119,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return group_->project(); } @@ -147,7 +147,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return group_->project(); } @@ -166,4 +166,4 @@ private: } -#endif // NODEGROUP_H +#endif // OAK_NODEGROUP_H diff --git a/app/node/input/multicam/multicamnode.cpp b/app/node/input/multicam/multicamnode.cpp index a192a01d5..91b3ffff8 100644 --- a/app/node/input/multicam/multicamnode.cpp +++ b/app/node/input/multicam/multicamnode.cpp @@ -25,29 +25,29 @@ namespace olive #define super Node -const QString MultiCamNode::kCurrentInput = QStringLiteral("current_in"); -const QString MultiCamNode::kSourcesInput = QStringLiteral("sources_in"); -const QString MultiCamNode::kSequenceInput = QStringLiteral("sequence_in"); -const QString MultiCamNode::kSequenceTypeInput = +const QString MultiCamNode::k_current_input = QStringLiteral("current_in"); +const QString MultiCamNode::k_sources_input = QStringLiteral("sources_in"); +const QString MultiCamNode::k_sequence_input = QStringLiteral("sequence_in"); +const QString MultiCamNode::k_sequence_type_input = QStringLiteral("sequence_type_in"); MultiCamNode::MultiCamNode() { - AddInput(kCurrentInput, NodeValue::kCombo, InputFlags(kInputFlagStatic)); + add_input(k_current_input, NodeValue::k_combo, InputFlags(k_input_flag_static)); - AddInput(kSourcesInput, NodeValue::kNone, - InputFlags(kInputFlagNotKeyframable | kInputFlagArray)); - SetInputProperty(kSourcesInput, QStringLiteral("arraystart"), 1); + add_input(k_sources_input, NodeValue::k_none, + InputFlags(k_input_flag_not_keyframable | k_input_flag_array)); + set_input_property(k_sources_input, QStringLiteral("arraystart"), 1); - AddInput(kSequenceInput, NodeValue::kNone, - InputFlags(kInputFlagNotKeyframable)); - AddInput(kSequenceTypeInput, NodeValue::kCombo, - InputFlags(kInputFlagStatic | kInputFlagHidden)); + add_input(k_sequence_input, NodeValue::k_none, + InputFlags(k_input_flag_not_keyframable)); + add_input(k_sequence_type_input, NodeValue::k_combo, + InputFlags(k_input_flag_static | k_input_flag_hidden)); sequence_ = nullptr; } -QString MultiCamNode::Name() const +QString MultiCamNode::name() const { return tr("Multi-Cam"); } @@ -57,44 +57,44 @@ QString MultiCamNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.multicam"); } -QVector MultiCamNode::Category() const +QVector MultiCamNode::category() const { - return { kCategoryTimeline }; + return { k_category_timeline }; } -QString MultiCamNode::Description() const +QString MultiCamNode::description() const { return tr("Allows easy switching between multiple sources."); } Node::ActiveElements -MultiCamNode::GetActiveElementsAtTime(const QString &input, +MultiCamNode::get_active_elements_at_time(const QString &input, const TimeRange &r) const { - if (input == kSourcesInput) { - int src = GetCurrentSource(); - if (src >= 0 && src < GetSourceCount()) { + if (input == k_sources_input) { + int src = get_current_source(); + if (src >= 0 && src < get_source_count()) { Node::ActiveElements a; a.add(src); return a; } else { - return ActiveElements::kNoElements; + return ActiveElements::k_no_elements; } } else { - return super::GetActiveElementsAtTime(input, r); + return super::get_active_elements_at_time(input, r); } } -void MultiCamNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void MultiCamNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - NodeValueArray arr = value[kSourcesInput].toArray(); + NodeValueArray arr = value[k_sources_input].to_array(); if (!arr.empty()) { - table->Push(arr.begin()->second); + table->push(arr.begin()->second); } } -void MultiCamNode::IndexToRowCols(int index, int total_rows, int total_cols, +void MultiCamNode::index_to_row_cols(int index, int total_rows, int total_cols, int *row, int *col) { Q_UNUSED(total_rows) @@ -103,39 +103,39 @@ void MultiCamNode::IndexToRowCols(int index, int total_rows, int total_cols, *row = index / total_cols; } -Node *MultiCamNode::GetConnectedRenderOutput(const QString &input, +Node *MultiCamNode::get_connected_render_output(const QString &input, int element) const { - if (sequence_ && input == kSourcesInput && element >= 0 && - element < GetSourceCount()) { - return GetTrackList()->GetTrackAt(element); + if (sequence_ && input == k_sources_input && element >= 0 && + element < get_source_count()) { + return get_track_list()->get_track_at(element); } else { - return Node::GetConnectedRenderOutput(input, element); + return Node::get_connected_render_output(input, element); } } -bool MultiCamNode::IsInputConnectedForRender(const QString &input, +bool MultiCamNode::is_input_connected_for_render(const QString &input, int element) const { - if (sequence_ && input == kSourcesInput && element >= 0 && - element < GetSourceCount()) { + if (sequence_ && input == k_sources_input && element >= 0 && + element < get_source_count()) { return true; } else { - return Node::IsInputConnectedForRender(input, element); + return Node::is_input_connected_for_render(input, element); } } -QVector MultiCamNode::IgnoreInputsForRendering() const +QVector MultiCamNode::ignore_inputs_for_rendering() const { - return { kSequenceInput }; + return { k_sequence_input }; } void MultiCamNode::InputConnectedEvent(const QString &input, int element, Node *output) { - if (input == kSequenceInput) { + if (input == k_sequence_input) { if (Sequence *s = dynamic_cast(output)) { - SetInputFlag(kSequenceTypeInput, kInputFlagHidden, false); + set_input_flag(k_sequence_type_input, k_input_flag_hidden, false); sequence_ = s; } } @@ -144,51 +144,51 @@ void MultiCamNode::InputConnectedEvent(const QString &input, int element, void MultiCamNode::InputDisconnectedEvent(const QString &input, int element, Node *output) { - if (input == kSequenceInput) { - SetInputFlag(kSequenceTypeInput, kInputFlagHidden, true); + if (input == k_sequence_input) { + set_input_flag(k_sequence_type_input, k_input_flag_hidden, true); sequence_ = nullptr; } } -TrackList *MultiCamNode::GetTrackList() const +TrackList *MultiCamNode::get_track_list() const { return sequence_->track_list( - static_cast(GetStandardValue(kSequenceTypeInput).toInt())); + static_cast(get_standard_value(k_sequence_type_input).toInt())); } -void MultiCamNode::Retranslate() +void MultiCamNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kCurrentInput, tr("Current")); - SetInputName(kSourcesInput, tr("Sources")); - SetInputName(kSequenceInput, tr("Sequence")); - SetInputName(kSequenceTypeInput, tr("Sequence Type")); - SetComboBoxStrings(kSequenceTypeInput, { tr("Video"), tr("Audio") }); + set_input_name(k_current_input, tr("Current")); + set_input_name(k_sources_input, tr("Sources")); + set_input_name(k_sequence_input, tr("Sequence")); + set_input_name(k_sequence_type_input, tr("Sequence Type")); + set_combo_box_strings(k_sequence_type_input, { tr("Video"), tr("Audio") }); QStringList names; - int name_count = GetSourceCount(); + int name_count = get_source_count(); names.reserve(name_count); for (int i = 0; i < name_count; i++) { QString src_name; - if (Node *n = GetConnectedRenderOutput(kSourcesInput, i)) { - src_name = n->Name(); + if (Node *n = get_connected_render_output(k_sources_input, i)) { + src_name = n->name(); } names.append(tr("%1: %2").arg(QString::number(i + 1), src_name)); } - SetComboBoxStrings(kCurrentInput, names); + set_combo_box_strings(k_current_input, names); } -int MultiCamNode::GetSourceCount() const +int MultiCamNode::get_source_count() const { if (sequence_) { - return GetTrackList()->GetTrackCount(); + return get_track_list()->get_track_count(); } else { - return InputArraySize(kSourcesInput); + return input_array_size(k_sources_input); } } -void MultiCamNode::GetRowsAndColumns(int sources, int *rows_in, int *cols_in) +void MultiCamNode::get_rows_and_columns(int sources, int *rows_in, int *cols_in) { int &rows = *rows_in; int &cols = *cols_in; diff --git a/app/node/input/multicam/multicamnode.h b/app/node/input/multicam/multicamnode.h index ff9dcb555..9441f1d87 100644 --- a/app/node/input/multicam/multicamnode.h +++ b/app/node/input/multicam/multicamnode.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef MULTICAMNODE_H -#define MULTICAMNODE_H +#ifndef OAK_MULTICAMNODE_H +#define OAK_MULTICAMNODE_H #include "node/node.h" #include "node/output/track/tracklist.h" @@ -34,57 +34,57 @@ public: NODE_DEFAULT_FUNCTIONS(MultiCamNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; virtual ActiveElements - GetActiveElementsAtTime(const QString &input, + get_active_elements_at_time(const QString &input, const TimeRange &r) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void Retranslate() override; + virtual void retranslate() override; - static const QString kCurrentInput; - static const QString kSourcesInput; - static const QString kSequenceInput; - static const QString kSequenceTypeInput; + static const QString k_current_input; + static const QString k_sources_input; + static const QString k_sequence_input; + static const QString k_sequence_type_input; - int GetCurrentSource() const + int get_current_source() const { - return GetStandardValue(kCurrentInput).toInt(); + return get_standard_value(k_current_input).toInt(); } - int GetSourceCount() const; + int get_source_count() const; - static void GetRowsAndColumns(int sources, int *rows, int *cols); - void GetRowsAndColumns(int *rows, int *cols) const + static void get_rows_and_columns(int sources, int *rows, int *cols); + void get_rows_and_columns(int *rows, int *cols) const { - return GetRowsAndColumns(GetSourceCount(), rows, cols); + return get_rows_and_columns(get_source_count(), rows, cols); } - void SetSequenceType(Track::Type t) + void set_sequence_type(Track::Type t) { - SetStandardValue(kSequenceTypeInput, t); + set_standard_value(k_sequence_type_input, t); } - static void IndexToRowCols(int index, int total_rows, int total_cols, + static void index_to_row_cols(int index, int total_rows, int total_cols, int *row, int *col); - static int RowsColsToIndex(int row, int col, int total_rows, int total_cols) + static int rows_cols_to_index(int row, int col, int total_rows, int total_cols) { return col + row * total_cols; } - virtual Node *GetConnectedRenderOutput(const QString &input, + virtual Node *get_connected_render_output(const QString &input, int element = -1) const override; - virtual bool IsInputConnectedForRender(const QString &input, + virtual bool is_input_connected_for_render(const QString &input, int element = -1) const override; - virtual QVector IgnoreInputsForRendering() const override; + virtual QVector ignore_inputs_for_rendering() const override; protected: virtual void InputConnectedEvent(const QString &input, int element, @@ -93,11 +93,11 @@ protected: Node *output) override; private: - TrackList *GetTrackList() const; + TrackList *get_track_list() const; Sequence *sequence_; }; } -#endif // MULTICAMNODE_H +#endif // OAK_MULTICAMNODE_H diff --git a/app/node/input/time/timeinput.cpp b/app/node/input/time/timeinput.cpp index 8acec004b..b2c7d68a9 100644 --- a/app/node/input/time/timeinput.cpp +++ b/app/node/input/time/timeinput.cpp @@ -30,7 +30,7 @@ TimeInput::TimeInput() { } -QString TimeInput::Name() const +QString TimeInput::name() const { return tr("Time"); } @@ -40,20 +40,20 @@ QString TimeInput::id() const return QStringLiteral("org.olivevideoeditor.Olive.time"); } -QVector TimeInput::Category() const +QVector TimeInput::category() const { - return { kCategoryTime }; + return { k_category_time }; } -QString TimeInput::Description() const +QString TimeInput::description() const { return tr("Generates the time (in seconds) at this frame."); } -void TimeInput::Value(const NodeValueRow &value, const NodeGlobals &globals, +void TimeInput::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - table->Push(NodeValue::kFloat, globals.time().in().toDouble(), this, false, + table->push(NodeValue::k_float, globals.time().in().to_double(), this, false, QStringLiteral("time")); } diff --git a/app/node/input/time/timeinput.h b/app/node/input/time/timeinput.h index 9ba19483c..2066e9a84 100644 --- a/app/node/input/time/timeinput.h +++ b/app/node/input/time/timeinput.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMEINPUT_H -#define TIMEINPUT_H +#ifndef OAK_TIMEINPUT_H +#define OAK_TIMEINPUT_H #include "node/node.h" @@ -34,15 +34,15 @@ public: NODE_DEFAULT_FUNCTIONS(TimeInput) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; }; } -#endif // TIMEINPUT_H +#endif // OAK_TIMEINPUT_H diff --git a/app/node/input/value/valuenode.cpp b/app/node/input/value/valuenode.cpp index 70fce2410..0d21355f4 100644 --- a/app/node/input/value/valuenode.cpp +++ b/app/node/input/value/valuenode.cpp @@ -24,56 +24,56 @@ namespace olive { -const QString ValueNode::kTypeInput = QStringLiteral("type_in"); -const QString ValueNode::kValueInput = QStringLiteral("value_in"); -const QVector ValueNode::kSupportedTypes = { - NodeValue::kFloat, NodeValue::kInt, NodeValue::kRational, - NodeValue::kVec2, NodeValue::kVec3, NodeValue::kVec4, - NodeValue::kColor, NodeValue::kText, NodeValue::kMatrix, - NodeValue::kFont, NodeValue::kBoolean, +const QString ValueNode::k_type_input = QStringLiteral("type_in"); +const QString ValueNode::k_value_input = QStringLiteral("value_in"); +const QVector ValueNode::k_supported_types = { + NodeValue::k_float, NodeValue::k_int, NodeValue::k_rational, + NodeValue::k_vec2, NodeValue::k_vec3, NodeValue::k_vec4, + NodeValue::k_color, NodeValue::k_text, NodeValue::k_matrix, + NodeValue::k_font, NodeValue::k_boolean, }; #define super Node ValueNode::ValueNode() { - AddInput(kTypeInput, NodeValue::kCombo, 0, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_type_input, NodeValue::k_combo, 0, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - AddInput(kValueInput, kSupportedTypes.first(), QVariant(), - InputFlags(kInputFlagNotConnectable)); + add_input(k_value_input, k_supported_types.first(), QVariant(), + InputFlags(k_input_flag_not_connectable)); } -void ValueNode::Retranslate() +void ValueNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTypeInput, QStringLiteral("Type")); - SetInputName(kValueInput, QStringLiteral("Value")); + set_input_name(k_type_input, QStringLiteral("Type")); + set_input_name(k_value_input, QStringLiteral("Value")); QStringList type_names; - type_names.reserve(kSupportedTypes.size()); - foreach (NodeValue::Type type, kSupportedTypes) { - type_names.append(NodeValue::GetPrettyDataTypeName(type)); + type_names.reserve(k_supported_types.size()); + foreach (NodeValue::Type type, k_supported_types) { + type_names.append(NodeValue::get_pretty_data_type_name(type)); } - SetComboBoxStrings(kTypeInput, type_names); + set_combo_box_strings(k_type_input, type_names); } -void ValueNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void ValueNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { Q_UNUSED(globals) // Ensure value is pushed onto the table - table->Push(value[kValueInput]); + table->push(value[k_value_input]); } void ValueNode::InputValueChangedEvent(const QString &input, int element) { - if (input == kTypeInput) { - SetInputDataType( - kValueInput, - kSupportedTypes.at(GetStandardValue(kTypeInput).toInt())); + if (input == k_type_input) { + set_input_data_type( + k_value_input, + k_supported_types.at(get_standard_value(k_type_input).toInt())); } super::InputValueChangedEvent(input, element); diff --git a/app/node/input/value/valuenode.h b/app/node/input/value/valuenode.h index d4571bc9c..340cebe7c 100644 --- a/app/node/input/value/valuenode.h +++ b/app/node/input/value/valuenode.h @@ -19,8 +19,8 @@ ***/ -#ifndef VALUENODE_H -#define VALUENODE_H +#ifndef OAK_VALUENODE_H +#define OAK_VALUENODE_H #include "node/node.h" @@ -34,7 +34,7 @@ public: NODE_DEFAULT_FUNCTIONS(ValueNode) - virtual QString Name() const override + virtual QString name() const override { return tr("Value"); } @@ -44,23 +44,23 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.value"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryGenerator }; + return { k_category_generator }; } - virtual QString Description() const override + virtual QString description() const override { return tr( "Create a single value that can be connected to various other inputs."); } - static const QString kTypeInput; - static const QString kValueInput; + static const QString k_type_input; + static const QString k_value_input; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; protected: @@ -68,9 +68,9 @@ protected: int element) override; private: - static const QVector kSupportedTypes; + static const QVector k_supported_types; }; } -#endif // VALUENODE_H +#endif // OAK_VALUENODE_H diff --git a/app/node/inputdragger.cpp b/app/node/inputdragger.cpp index 2a2c2d693..7208dc6e2 100644 --- a/app/node/inputdragger.cpp +++ b/app/node/inputdragger.cpp @@ -34,16 +34,16 @@ NodeInputDragger::NodeInputDragger() { } -bool NodeInputDragger::IsStarted() const +bool NodeInputDragger::is_started() const { - return input_.IsValid(); + return input_.is_valid(); } -void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, - const rational &time, +void NodeInputDragger::start(const NodeKeyframeTrackReference &input, + const Rational &time, bool create_key_on_all_tracks) { - Q_ASSERT(!IsStarted()); + Q_ASSERT(!is_started()); // Set up new drag input_ = input; @@ -52,32 +52,32 @@ void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, Node *node = input_.input().node(); // Cache current value - start_value_ = node->GetSplitValueAtTimeOnTrack(input_, time); + start_value_ = node->get_split_value_at_time_on_track(input_, time); end_value_ = start_value_; // Determine whether we are creating a keyframe or not - if (input_.input().IsKeyframing()) { - dragging_key_ = node->GetKeyframeAtTimeOnTrack(input_, time); + if (input_.input().is_keyframing()) { + dragging_key_ = node->get_keyframe_at_time_on_track(input_, time); if (!dragging_key_) { dragging_key_ = new NodeKeyframe( time, start_value_, - node->GetBestKeyframeTypeForTimeOnTrack(input_, time), + node->get_best_keyframe_type_for_time_on_track(input_, time), input_.track(), input_.input().element(), input_.input().input(), node); created_keys_.append(dragging_key_); if (create_key_on_all_tracks) { int nb_tracks = NodeValue::get_number_of_keyframe_tracks( - input.input().node()->GetInputDataType( + input.input().node()->get_input_data_type( input.input().input())); for (int i = 0; i < nb_tracks; i++) { if (i != input.track()) { NodeKeyframeTrackReference this_ref(input.input(), i); created_keys_.append(new NodeKeyframe( time, - node->GetSplitValueAtTimeOnTrack(this_ref, time), - node->GetBestKeyframeTypeForTimeOnTrack(this_ref, + node->get_split_value_at_time_on_track(this_ref, time), + node->get_best_keyframe_type_for_time_on_track(this_ref, time), i, input.input().element(), input.input().input(), node)); @@ -90,26 +90,26 @@ void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, input_being_dragged++; } -void NodeInputDragger::Drag(QVariant value) +void NodeInputDragger::drag(QVariant value) { - Q_ASSERT(IsStarted()); + Q_ASSERT(is_started()); Node *node = input_.input().node(); const QString &input = input_.input().input(); - if (node->HasInputProperty(input, QStringLiteral("min"))) { + if (node->has_input_property(input, QStringLiteral("min"))) { // Assumes the value is a double of some kind double min = - node->GetInputProperty(input, QStringLiteral("min")).toDouble(); + node->get_input_property(input, QStringLiteral("min")).toDouble(); double v = value.toDouble(); if (v < min) { value = min; } } - if (node->HasInputProperty(input, QStringLiteral("max"))) { + if (node->has_input_property(input, QStringLiteral("max"))) { double max = - node->GetInputProperty(input, QStringLiteral("max")).toDouble(); + node->get_input_property(input, QStringLiteral("max")).toDouble(); double v = value.toDouble(); if (v > max) { value = max; @@ -120,24 +120,24 @@ void NodeInputDragger::Drag(QVariant value) //input_->blockSignals(true); - if (input_.input().IsKeyframing()) { + if (input_.input().is_keyframing()) { dragging_key_->set_value(value); } else { - node->SetSplitStandardValueOnTrack(input_, value); + node->set_split_standard_value_on_track(input_, value); } //input_->blockSignals(false); } -void NodeInputDragger::End(MultiUndoCommand *command) +void NodeInputDragger::end(MultiUndoCommand *command) { - if (!IsStarted()) { + if (!is_started()) { return; } input_being_dragged--; - if (input_.input().node()->IsInputKeyframing(input_.input())) { + if (input_.input().node()->is_input_keyframing(input_.input())) { for (int i = 0; i < created_keys_.size(); i++) { // We created a keyframe in this process command->add_child(new NodeParamInsertKeyframeCommand( @@ -155,7 +155,7 @@ void NodeInputDragger::End(MultiUndoCommand *command) input_, end_value_, start_value_)); } - input_.Reset(); + input_.reset(); created_keys_.clear(); } diff --git a/app/node/inputdragger.h b/app/node/inputdragger.h index 48fac004f..2a367dcfa 100644 --- a/app/node/inputdragger.h +++ b/app/node/inputdragger.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEINPUTDRAGGER_H -#define NODEINPUTDRAGGER_H +#ifndef OAK_NODEINPUTDRAGGER_H +#define OAK_NODEINPUTDRAGGER_H #include "node/keyframe.h" #include "node/param.h" @@ -33,31 +33,31 @@ class NodeInputDragger { public: NodeInputDragger(); - bool IsStarted() const; + bool is_started() const; - void Start(const NodeKeyframeTrackReference &input, const rational &time, + void start(const NodeKeyframeTrackReference &input, const Rational &time, bool create_key_on_all_tracks = true); - void Drag(QVariant value); + void drag(QVariant value); - void End(MultiUndoCommand *command); + void end(MultiUndoCommand *command); - static bool IsInputBeingDragged() + static bool is_input_being_dragged() { return input_being_dragged; } - const QVariant &GetStartValue() const + const QVariant &get_start_value() const { return start_value_; } - const NodeKeyframeTrackReference &GetInput() const + const NodeKeyframeTrackReference &get_input() const { return input_; } - const rational &GetTime() const + const Rational &get_time() const { return time_; } @@ -65,7 +65,7 @@ public: private: NodeKeyframeTrackReference input_; - rational time_; + Rational time_; QVariant start_value_; @@ -79,4 +79,4 @@ private: } -#endif // NODEINPUTDRAGGER_H +#endif // OAK_NODEINPUTDRAGGER_H diff --git a/app/node/inputimmediate.cpp b/app/node/inputimmediate.cpp index 51500cf0b..f516e7526 100644 --- a/app/node/inputimmediate.cpp +++ b/app/node/inputimmediate.cpp @@ -50,7 +50,7 @@ void NodeInputImmediate::set_split_standard_value(const SplitValue &value) } QVector -NodeInputImmediate::get_keyframe_at_time(const rational &time) const +NodeInputImmediate::get_keyframe_at_time(const Rational &time) const { QVector keys; @@ -66,7 +66,7 @@ NodeInputImmediate::get_keyframe_at_time(const rational &time) const } NodeKeyframe * -NodeInputImmediate::get_keyframe_at_time_on_track(const rational &time, +NodeInputImmediate::get_keyframe_at_time_on_track(const Rational &time, int track) const { if (!is_using_standard_value(track)) { @@ -81,7 +81,7 @@ NodeInputImmediate::get_keyframe_at_time_on_track(const rational &time, } NodeKeyframe * -NodeInputImmediate::get_closest_keyframe_to_time_on_track(const rational &time, +NodeInputImmediate::get_closest_keyframe_to_time_on_track(const Rational &time, int track) const { if (is_using_standard_value(track)) { @@ -104,8 +104,8 @@ NodeInputImmediate::get_closest_keyframe_to_time_on_track(const rational &time, if (prev_key->time() <= time && next_key->time() >= time) { // Return whichever is closer - rational prev_diff = time - prev_key->time(); - rational next_diff = next_key->time() - time; + Rational prev_diff = time - prev_key->time(); + Rational next_diff = next_key->time() - time; if (next_diff < prev_diff) { return next_key; @@ -119,7 +119,7 @@ NodeInputImmediate::get_closest_keyframe_to_time_on_track(const rational &time, } NodeKeyframe * -NodeInputImmediate::get_closest_keyframe_before_time(const rational &time) const +NodeInputImmediate::get_closest_keyframe_before_time(const Rational &time) const { NodeKeyframe *key = nullptr; @@ -137,7 +137,7 @@ NodeInputImmediate::get_closest_keyframe_before_time(const rational &time) const } NodeKeyframe * -NodeInputImmediate::get_closest_keyframe_after_time(const rational &time) const +NodeInputImmediate::get_closest_keyframe_after_time(const Rational &time) const { NodeKeyframe *key = nullptr; @@ -157,7 +157,7 @@ NodeInputImmediate::get_closest_keyframe_after_time(const rational &time) const } NodeKeyframe::Type -NodeInputImmediate::get_best_keyframe_type_for_time(const rational &time, +NodeInputImmediate::get_best_keyframe_type_for_time(const Rational &time, int track) const { NodeKeyframe *closest_key = @@ -167,10 +167,10 @@ NodeInputImmediate::get_best_keyframe_type_for_time(const rational &time, return closest_key->type(); } - return NodeKeyframe::kDefaultType; + return NodeKeyframe::k_default_type; } -bool NodeInputImmediate::has_keyframe_at_time(const rational &time) const +bool NodeInputImmediate::has_keyframe_at_time(const Rational &time) const { if (!is_keyframing()) { return false; diff --git a/app/node/inputimmediate.h b/app/node/inputimmediate.h index 5327416fe..62c8a8ece 100644 --- a/app/node/inputimmediate.h +++ b/app/node/inputimmediate.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEINPUTIMMEDIATE_H -#define NODEINPUTIMMEDIATE_H +#ifndef OAK_NODEINPUTIMMEDIATE_H +#define OAK_NODEINPUTIMMEDIATE_H #include "common/xmlutils.h" #include "node/keyframe.h" @@ -67,7 +67,7 @@ public: * * List may be empty if this input is not keyframing or has no keyframes at this time. */ - QVector get_keyframe_at_time(const rational &time) const; + QVector get_keyframe_at_time(const Rational &time) const; /** * @brief Retrieve the keyframe object at a given time for a given track @@ -76,7 +76,7 @@ public: * * The keyframe object at this time or nullptr if there isn't one or if is_keyframing() is false. */ - NodeKeyframe *get_keyframe_at_time_on_track(const rational &time, + NodeKeyframe *get_keyframe_at_time_on_track(const Rational &time, int track) const; /** @@ -84,7 +84,7 @@ public: * * If is_keyframing() is false or keyframes_ is empty, this will return nullptr. */ - NodeKeyframe *get_closest_keyframe_to_time_on_track(const rational &time, + NodeKeyframe *get_closest_keyframe_to_time_on_track(const Rational &time, int track) const; /** @@ -92,19 +92,19 @@ public: * * If no keyframe is before this time, returns nullptr. */ - NodeKeyframe *get_closest_keyframe_before_time(const rational &time) const; + NodeKeyframe *get_closest_keyframe_before_time(const Rational &time) const; /** * @brief Get closest keyframe that's before the time on any track * * If no keyframe is before this time, returns nullptr. */ - NodeKeyframe *get_closest_keyframe_after_time(const rational &time) const; + NodeKeyframe *get_closest_keyframe_after_time(const Rational &time) const; /** * @brief A heuristic to determine what type a keyframe should be if it's inserted at a certain time (between keyframes) */ - NodeKeyframe::Type get_best_keyframe_type_for_time(const rational &time, + NodeKeyframe::Type get_best_keyframe_type_for_time(const Rational &time, int track) const; /** @@ -147,7 +147,7 @@ public: * If is_keyframing() is false, this will always return false. This checks all tracks and will return true if *any* * track has a keyframe. */ - bool has_keyframe_at_time(const rational &time) const; + bool has_keyframe_at_time(const Rational &time) const; bool is_using_standard_value(int track) const { @@ -182,4 +182,4 @@ private: } -#endif // NODEINPUTIMMEDIATE_H +#endif // OAK_NODEINPUTIMMEDIATE_H diff --git a/app/node/keyframe.cpp b/app/node/keyframe.cpp index 9eae2ca90..0bf394089 100644 --- a/app/node/keyframe.cpp +++ b/app/node/keyframe.cpp @@ -26,9 +26,9 @@ namespace olive { -const NodeKeyframe::Type NodeKeyframe::kDefaultType = kLinear; +const NodeKeyframe::Type NodeKeyframe::k_default_type = k_linear; -NodeKeyframe::NodeKeyframe(const rational &time, const QVariant &value, +NodeKeyframe::NodeKeyframe(const Rational &time, const QVariant &value, Type type, int track, int element, const QString &input, QObject *parent) : time_(time) @@ -46,7 +46,7 @@ NodeKeyframe::NodeKeyframe(const rational &time, const QVariant &value, } NodeKeyframe::NodeKeyframe() - : type_(NodeKeyframe::kLinear) + : type_(NodeKeyframe::k_linear) , bezier_control_in_(QPointF(0.0, 0.0)) , bezier_control_out_(QPointF(0.0, 0.0)) , track_(-1) @@ -80,15 +80,15 @@ Node *NodeKeyframe::parent() const return static_cast(QObject::parent()); } -const rational &NodeKeyframe::time() const +const Rational &NodeKeyframe::time() const { return time_; } -void NodeKeyframe::set_time(const rational &time) +void NodeKeyframe::set_time(const Rational &time) { time_ = time; - emit TimeChanged(time_); + emit time_changed(time_); } const QVariant &NodeKeyframe::value() const @@ -99,7 +99,7 @@ const QVariant &NodeKeyframe::value() const void NodeKeyframe::set_value(const QVariant &value) { value_ = value; - emit ValueChanged(value_); + emit value_changed(value_); } const NodeKeyframe::Type &NodeKeyframe::type() const @@ -112,14 +112,14 @@ void NodeKeyframe::set_type(const NodeKeyframe::Type &type) if (type_ != type) { set_type_no_bezier_adj(type); - if (type_ == kBezier) { + if (type_ == k_bezier) { // Set some sane defaults if this keyframe existed in the track and was just changed if (bezier_control_in_.isNull()) { if (previous_) { // Set the in point to be half way between set_bezier_control_in( - QPointF((previous_->time().toDouble() - - this->time().toDouble()) * + QPointF((previous_->time().to_double() - + this->time().to_double()) * 0.5, 0.0)); } else { @@ -130,7 +130,7 @@ void NodeKeyframe::set_type(const NodeKeyframe::Type &type) if (bezier_control_out_.isNull()) { if (next_) { set_bezier_control_out(QPointF( - (next_->time().toDouble() - this->time().toDouble()) * + (next_->time().to_double() - this->time().to_double()) * 0.5, 0.0)); } else { @@ -144,7 +144,7 @@ void NodeKeyframe::set_type(const NodeKeyframe::Type &type) void NodeKeyframe::set_type_no_bezier_adj(const Type &type) { type_ = type; - emit TypeChanged(type_); + emit type_changed(type_); } const QPointF &NodeKeyframe::bezier_control_in() const @@ -155,7 +155,7 @@ const QPointF &NodeKeyframe::bezier_control_in() const void NodeKeyframe::set_bezier_control_in(const QPointF &control) { bezier_control_in_ = control; - emit BezierControlInChanged(bezier_control_in_); + emit bezier_control_in_changed(bezier_control_in_); } const QPointF &NodeKeyframe::bezier_control_out() const @@ -166,17 +166,17 @@ const QPointF &NodeKeyframe::bezier_control_out() const void NodeKeyframe::set_bezier_control_out(const QPointF &control) { bezier_control_out_ = control; - emit BezierControlOutChanged(bezier_control_out_); + emit bezier_control_out_changed(bezier_control_out_); } QPointF NodeKeyframe::valid_bezier_control_in() const { - double t = time().toDouble(); + double t = time().to_double(); qreal adjusted_x = t + bezier_control_in_.x(); if (previous_) { // Limit to the point of that keyframe - adjusted_x = qMax(adjusted_x, previous_->time().toDouble()); + adjusted_x = qMax(adjusted_x, previous_->time().to_double()); } return QPointF(adjusted_x - t, bezier_control_in_.y()); @@ -184,12 +184,12 @@ QPointF NodeKeyframe::valid_bezier_control_in() const QPointF NodeKeyframe::valid_bezier_control_out() const { - double t = time().toDouble(); + double t = time().to_double(); qreal adjusted_x = t + bezier_control_out_.x(); if (next_) { // Limit to the point of that keyframe - adjusted_x = qMin(adjusted_x, next_->time().toDouble()); + adjusted_x = qMin(adjusted_x, next_->time().to_double()); } return QPointF(adjusted_x - t, bezier_control_out_.y()); @@ -197,7 +197,7 @@ QPointF NodeKeyframe::valid_bezier_control_out() const const QPointF &NodeKeyframe::bezier_control(NodeKeyframe::BezierType type) const { - if (type == kInHandle) { + if (type == k_in_handle) { return bezier_control_in(); } else { return bezier_control_out(); @@ -207,7 +207,7 @@ const QPointF &NodeKeyframe::bezier_control(NodeKeyframe::BezierType type) const void NodeKeyframe::set_bezier_control(NodeKeyframe::BezierType type, const QPointF &control) { - if (type == kInHandle) { + if (type == k_in_handle) { set_bezier_control_in(control); } else { set_bezier_control_out(control); @@ -217,17 +217,17 @@ void NodeKeyframe::set_bezier_control(NodeKeyframe::BezierType type, NodeKeyframe::BezierType NodeKeyframe::get_opposing_bezier_type(NodeKeyframe::BezierType type) { - if (type == kInHandle) { - return kOutHandle; + if (type == k_in_handle) { + return k_out_handle; } else { - return kInHandle; + return k_in_handle; } } -bool NodeKeyframe::has_sibling_at_time(const rational &t) const +bool NodeKeyframe::has_sibling_at_time(const Rational &t) const { NodeKeyframe *k = - parent()->GetKeyframeAtTimeOnTrack(input(), t, track(), element()); + parent()->get_keyframe_at_time_on_track(input(), t, track(), element()); return k && k != this; } @@ -243,7 +243,7 @@ bool NodeKeyframe::load(QXmlStreamReader *reader, NodeValue::Type data_type) key_input = attr.value().toString(); } else if (attr.name() == QStringLiteral("time")) { this->set_time( - rational::fromString(attr.value().toString().toStdString())); + Rational::from_string(attr.value().toString().toStdString())); } else if (attr.name() == QStringLiteral("type")) { this->set_type_no_bezier_adj( static_cast(attr.value().toInt())); @@ -259,7 +259,7 @@ bool NodeKeyframe::load(QXmlStreamReader *reader, NodeValue::Type data_type) } this->set_value( - NodeValue::StringToValue(data_type, reader->readElementText(), true)); + NodeValue::string_to_value(data_type, reader->readElementText(), true)); if (!key_input.isEmpty()) { this->set_input(key_input); @@ -276,7 +276,7 @@ void NodeKeyframe::save(QXmlStreamWriter *writer, { writer->writeAttribute(QStringLiteral("input"), this->input()); writer->writeAttribute(QStringLiteral("time"), - QString::fromStdString(this->time().toString())); + QString::fromStdString(this->time().to_string())); writer->writeAttribute(QStringLiteral("type"), QString::number(this->type())); writer->writeAttribute(QStringLiteral("inhandlex"), @@ -289,7 +289,7 @@ void NodeKeyframe::save(QXmlStreamWriter *writer, QString::number(this->bezier_control_out().y())); writer->writeCharacters( - NodeValue::ValueToString(data_type, this->value(), true)); + NodeValue::value_to_string(data_type, this->value(), true)); } } diff --git a/app/node/keyframe.h b/app/node/keyframe.h index 1e5bb6bd4..b0bead7a1 100644 --- a/app/node/keyframe.h +++ b/app/node/keyframe.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEKEYFRAME_H -#define NODEKEYFRAME_H +#ifndef OAK_NODEKEYFRAME_H +#define OAK_NODEKEYFRAME_H #include #include @@ -42,19 +42,19 @@ public: /** * @brief Methods of interpolation to use with this keyframe */ - enum Type { kInvalid = -1, kLinear, kHold, kBezier }; + enum Type { k_invalid = -1, k_linear, k_hold, k_bezier }; /** * @brief The two types of bezier handles that are available on bezier keyframes */ - enum BezierType { kInHandle, kOutHandle }; + enum BezierType { k_in_handle, k_out_handle }; - static const Type kDefaultType; + static const Type k_default_type; /** * @brief NodeKeyframe Constructor */ - NodeKeyframe(const rational &time, const QVariant &value, Type type, + NodeKeyframe(const Rational &time, const QVariant &value, Type type, int track, int element, const QString &input, QObject *parent = nullptr); NodeKeyframe(); @@ -84,8 +84,8 @@ public: /** * @brief The time this keyframe is set at */ - const rational &time() const; - void set_time(const rational &time); + const Rational &time() const; + void set_time(const Rational &time); /** * @brief The value of this keyframe (i.e. the value to use at this keyframe's time) @@ -177,7 +177,7 @@ public: next_ = keyframe; } - bool has_sibling_at_time(const rational &t) const; + bool has_sibling_at_time(const Rational &t) const; bool load(QXmlStreamReader *reader, NodeValue::Type data_type); void save(QXmlStreamWriter *writer, NodeValue::Type data_type) const; @@ -186,30 +186,30 @@ signals: /** * @brief Signal emitted when this keyframe's time is changed */ - void TimeChanged(const rational &time); + void time_changed(const Rational &time); /** * @brief Signal emitted when this keyframe's value is changed */ - void ValueChanged(const QVariant &value); + void value_changed(const QVariant &value); /** * @brief Signal emitted when this keyframe's value is changed */ - void TypeChanged(const Type &type); + void type_changed(const Type &type); /** * @brief Signal emitted when this keyframe's bezier in control point is changed */ - void BezierControlInChanged(const QPointF &d); + void bezier_control_in_changed(const QPointF &d); /** * @brief Signal emitted when this keyframe's bezier out control point is changed */ - void BezierControlOutChanged(const QPointF &d); + void bezier_control_out_changed(const QPointF &d); private: - rational time_; + Rational time_; QVariant value_; @@ -236,4 +236,4 @@ using NodeKeyframeTrack = QVector; Q_DECLARE_METATYPE(olive::NodeKeyframe::Type) -#endif // NODEKEYFRAME_H +#endif // OAK_NODEKEYFRAME_H diff --git a/app/node/keying/chromakey/chromakey.cpp b/app/node/keying/chromakey/chromakey.cpp index dcf0cdc24..822818c8f 100644 --- a/app/node/keying/chromakey/chromakey.cpp +++ b/app/node/keying/chromakey/chromakey.cpp @@ -24,55 +24,55 @@ namespace olive #define super OCIOBaseNode -const QString ChromaKeyNode::kColorInput = QStringLiteral("color_key"); -const QString ChromaKeyNode::kMaskOnlyInput = QStringLiteral("mask_only_in"); -const QString ChromaKeyNode::kInvertInput = QStringLiteral("invert_in"); -const QString ChromaKeyNode::kUpperToleranceInput = +const QString ChromaKeyNode::k_color_input = QStringLiteral("color_key"); +const QString ChromaKeyNode::k_mask_only_input = QStringLiteral("mask_only_in"); +const QString ChromaKeyNode::k_invert_input = QStringLiteral("invert_in"); +const QString ChromaKeyNode::k_upper_tolerance_input = QStringLiteral("upper_tolerance_in"); -const QString ChromaKeyNode::kLowerToleranceInput = +const QString ChromaKeyNode::k_lower_tolerance_input = QStringLiteral("lower_tolerance_in"); -const QString ChromaKeyNode::kGarbageMatteInput = QStringLiteral("garbage_in"); -const QString ChromaKeyNode::kCoreMatteInput = QStringLiteral("core_in"); -const QString ChromaKeyNode::kShadowsInput = QStringLiteral("shadows_in"); -const QString ChromaKeyNode::kHighlightsInput = QStringLiteral("highlights_in"); +const QString ChromaKeyNode::k_garbage_matte_input = QStringLiteral("garbage_in"); +const QString ChromaKeyNode::k_core_matte_input = QStringLiteral("core_in"); +const QString ChromaKeyNode::k_shadows_input = QStringLiteral("shadows_in"); +const QString ChromaKeyNode::k_highlights_input = QStringLiteral("highlights_in"); ChromaKeyNode::ChromaKeyNode() { - AddInput(kColorInput, NodeValue::kColor, + add_input(k_color_input, NodeValue::k_color, QVariant::fromValue(Color(0.0f, 1.0f, 0.0f, 1.0f))); - AddInput(kLowerToleranceInput, NodeValue::kFloat, 5.0); - SetInputProperty(kLowerToleranceInput, QStringLiteral("min"), 0.0); - SetInputProperty(kLowerToleranceInput, QStringLiteral("base"), 0.1); + add_input(k_lower_tolerance_input, NodeValue::k_float, 5.0); + set_input_property(k_lower_tolerance_input, QStringLiteral("min"), 0.0); + set_input_property(k_lower_tolerance_input, QStringLiteral("base"), 0.1); - AddInput(kUpperToleranceInput, NodeValue::kFloat, 25.0); - SetInputProperty(kUpperToleranceInput, QStringLiteral("base"), 0.1); + add_input(k_upper_tolerance_input, NodeValue::k_float, 25.0); + set_input_property(k_upper_tolerance_input, QStringLiteral("base"), 0.1); // FIXME: Temporarily disabled. This will break if "lower tolerance" is keyframed or connected to // something and there's currently no solution to remedy that. If there is in the future, // we can look into re-enabling this. //SetInputProperty(kUpperToleranceInput, QStringLiteral("min"), GetStandardValue(kLowerToleranceInput).toDouble()); - AddInput(kGarbageMatteInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_garbage_matte_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kCoreMatteInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_core_matte_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kHighlightsInput, NodeValue::kFloat, 100.0f); - SetInputProperty(kHighlightsInput, QStringLiteral("min"), 0.0); - SetInputProperty(kHighlightsInput, QStringLiteral("base"), 0.1); + add_input(k_highlights_input, NodeValue::k_float, 100.0f); + set_input_property(k_highlights_input, QStringLiteral("min"), 0.0); + set_input_property(k_highlights_input, QStringLiteral("base"), 0.1); - AddInput(kShadowsInput, NodeValue::kFloat, 100.0f); - SetInputProperty(kShadowsInput, QStringLiteral("min"), 0.0); - SetInputProperty(kShadowsInput, QStringLiteral("base"), 0.1); + add_input(k_shadows_input, NodeValue::k_float, 100.0f); + set_input_property(k_shadows_input, QStringLiteral("min"), 0.0); + set_input_property(k_shadows_input, QStringLiteral("base"), 0.1); - AddInput(kInvertInput, NodeValue::kBoolean, false); + add_input(k_invert_input, NodeValue::k_boolean, false); - AddInput(kMaskOnlyInput, NodeValue::kBoolean, false); + add_input(k_mask_only_input, NodeValue::k_boolean, false); } -QString ChromaKeyNode::Name() const +QString ChromaKeyNode::name() const { return tr("Chroma Key"); } @@ -82,98 +82,98 @@ QString ChromaKeyNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.chromakey"); } -QVector ChromaKeyNode::Category() const +QVector ChromaKeyNode::category() const { - return { kCategoryKeying }; + return { k_category_keying }; } -QString ChromaKeyNode::Description() const +QString ChromaKeyNode::description() const { return tr( "A simple color key based on the distance from the chroma of a selected color."); } -void ChromaKeyNode::Retranslate() +void ChromaKeyNode::retranslate() { - super::Retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kGarbageMatteInput, tr("Garbage Matte")); - SetInputName(kCoreMatteInput, tr("Core Matte")); - SetInputName(kColorInput, tr("Key Color")); - SetInputName(kShadowsInput, tr("Shadows")); - SetInputName(kHighlightsInput, tr("Highlights")); - SetInputName(kUpperToleranceInput, tr("Upper Tolerance")); - SetInputName(kLowerToleranceInput, tr("Lower Tolerance")); - SetInputName(kInvertInput, tr("Invert Mask")); - SetInputName(kMaskOnlyInput, tr("Show Mask Only")); + super::retranslate(); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_garbage_matte_input, tr("Garbage Matte")); + set_input_name(k_core_matte_input, tr("Core Matte")); + set_input_name(k_color_input, tr("Key Color")); + set_input_name(k_shadows_input, tr("Shadows")); + set_input_name(k_highlights_input, tr("Highlights")); + set_input_name(k_upper_tolerance_input, tr("Upper Tolerance")); + set_input_name(k_lower_tolerance_input, tr("Lower Tolerance")); + set_input_name(k_invert_input, tr("Invert Mask")); + set_input_name(k_mask_only_input, tr("Show Mask Only")); } void ChromaKeyNode::InputValueChangedEvent(const QString &input, int element) { Q_UNUSED(element); - if (input == kLowerToleranceInput) { + if (input == k_lower_tolerance_input) { // FIXME: Temporarily disabled. This will break if "lower tolerance" is keyframed or connected to // something and there's currently no solution to remedy that. If there is in the future, // we can look into re-enabling this. //SetInputProperty(kUpperToleranceInput, QStringLiteral("min"), GetStandardValue(kLowerToleranceInput).toDouble()); } - GenerateProcessor(); + generate_processor(); } -ShaderCode ChromaKeyNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode ChromaKeyNode::get_shader_code(const ShaderRequest &request) const { - return ShaderCode(FileFunctions::ReadFileAsString( + return ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/chromakey.frag")) .arg(request.stub)); } -void ChromaKeyNode::GenerateProcessor() +void ChromaKeyNode::generate_processor() { if (manager()) { try { ColorTransform transform("cie_xyz_d65_interchange"); - set_processor(ColorProcessor::Create( - manager(), manager()->GetReferenceColorSpace(), transform)); - } catch (const OCIO::Exception &e) { + set_processor(ColorProcessor::create( + manager(), manager()->get_reference_color_space(), transform)); + } catch (const ocio::Exception &e) { std::cerr << std::endl << e.what() << std::endl; } } } -void ChromaKeyNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void ChromaKeyNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { if (processor()) { ColorTransformJob job(value); - job.SetColorProcessor(processor()); - job.SetInputTexture(value[kTextureInput]); - job.SetNeedsCustomShader(this); - job.SetFunctionName(QStringLiteral("SceneLinearToCIEXYZ_d65")); + job.set_color_processor(processor()); + job.set_input_texture(value[k_texture_input]); + job.set_needs_custom_shader(this); + job.set_function_name(QStringLiteral("SceneLinearToCIEXYZ_d65")); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } } } -void ChromaKeyNode::ConfigChanged() +void ChromaKeyNode::config_changed() { - GenerateProcessor(); + generate_processor(); } -QString ChromaKeyNode::GetInputIDForLegacyID(const QString &id) const +QString ChromaKeyNode::get_input_id_for_legacy_id(const QString &id) const { // Older project files used the misspelled "tolerence" input IDs if (id == QStringLiteral("upper_tolerence_in")) { - return kUpperToleranceInput; + return k_upper_tolerance_input; } if (id == QStringLiteral("lower_tolerence_in")) { - return kLowerToleranceInput; + return k_lower_tolerance_input; } - return super::GetInputIDForLegacyID(id); + return super::get_input_id_for_legacy_id(id); } } // namespace olive diff --git a/app/node/keying/chromakey/chromakey.h b/app/node/keying/chromakey/chromakey.h index bdfa6e8c8..11c3daa05 100644 --- a/app/node/keying/chromakey/chromakey.h +++ b/app/node/keying/chromakey/chromakey.h @@ -14,8 +14,8 @@ along with this program. If not, see . ***/ -#ifndef CHROMAKEYNODE_H -#define CHROMAKEYNODE_H +#ifndef OAK_CHROMAKEYNODE_H +#define OAK_CHROMAKEYNODE_H #include "node/color/ociobase/ociobase.h" @@ -29,41 +29,41 @@ public: NODE_DEFAULT_FUNCTIONS(ChromaKeyNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual void InputValueChangedEvent(const QString &input, int element) override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void ConfigChanged() override; + virtual void config_changed() override; // Maps the misspelled tolerance input IDs from old project files onto the // corrected ones - virtual QString GetInputIDForLegacyID(const QString &id) const override; + virtual QString get_input_id_for_legacy_id(const QString &id) const override; - static const QString kColorInput; - static const QString kInvertInput; - static const QString kMaskOnlyInput; - static const QString kUpperToleranceInput; - static const QString kLowerToleranceInput; - static const QString kGarbageMatteInput; - static const QString kCoreMatteInput; - static const QString kShadowsInput; - static const QString kHighlightsInput; + static const QString k_color_input; + static const QString k_invert_input; + static const QString k_mask_only_input; + static const QString k_upper_tolerance_input; + static const QString k_lower_tolerance_input; + static const QString k_garbage_matte_input; + static const QString k_core_matte_input; + static const QString k_shadows_input; + static const QString k_highlights_input; private: - void GenerateProcessor(); + void generate_processor(); }; } // namespace olive -#endif // CHROMAKEYNODE_H +#endif // OAK_CHROMAKEYNODE_H diff --git a/app/node/keying/colordifferencekey/colordifferencekey.cpp b/app/node/keying/colordifferencekey/colordifferencekey.cpp index 1b755882b..285ea545f 100644 --- a/app/node/keying/colordifferencekey/colordifferencekey.cpp +++ b/app/node/keying/colordifferencekey/colordifferencekey.cpp @@ -19,49 +19,49 @@ namespace olive { -const QString ColorDifferenceKeyNode::kTextureInput = QStringLiteral("tex_in"); -const QString ColorDifferenceKeyNode::kGarbageMatteInput = +const QString ColorDifferenceKeyNode::k_texture_input = QStringLiteral("tex_in"); +const QString ColorDifferenceKeyNode::k_garbage_matte_input = QStringLiteral("garbage_in"); -const QString ColorDifferenceKeyNode::kCoreMatteInput = +const QString ColorDifferenceKeyNode::k_core_matte_input = QStringLiteral("core_in"); -const QString ColorDifferenceKeyNode::kColorInput = QStringLiteral("color_in"); -const QString ColorDifferenceKeyNode::kShadowsInput = +const QString ColorDifferenceKeyNode::k_color_input = QStringLiteral("color_in"); +const QString ColorDifferenceKeyNode::k_shadows_input = QStringLiteral("shadows_in"); -const QString ColorDifferenceKeyNode::kHighlightsInput = +const QString ColorDifferenceKeyNode::k_highlights_input = QStringLiteral("highlights_in"); -const QString ColorDifferenceKeyNode::kMaskOnlyInput = +const QString ColorDifferenceKeyNode::k_mask_only_input = QStringLiteral("mask_only_in"); #define super Node ColorDifferenceKeyNode::ColorDifferenceKeyNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kGarbageMatteInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_garbage_matte_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kCoreMatteInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_core_matte_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kColorInput, NodeValue::kCombo, 0); + add_input(k_color_input, NodeValue::k_combo, 0); - AddInput(kHighlightsInput, NodeValue::kFloat, 1.0f); - SetInputProperty(kHighlightsInput, QStringLiteral("min"), 0.0); - SetInputProperty(kHighlightsInput, QStringLiteral("base"), 0.01); + add_input(k_highlights_input, NodeValue::k_float, 1.0f); + set_input_property(k_highlights_input, QStringLiteral("min"), 0.0); + set_input_property(k_highlights_input, QStringLiteral("base"), 0.01); - AddInput(kShadowsInput, NodeValue::kFloat, 1.0f); - SetInputProperty(kShadowsInput, QStringLiteral("min"), 0.0); - SetInputProperty(kShadowsInput, QStringLiteral("base"), 0.01); + add_input(k_shadows_input, NodeValue::k_float, 1.0f); + set_input_property(k_shadows_input, QStringLiteral("min"), 0.0); + set_input_property(k_shadows_input, QStringLiteral("base"), 0.01); - AddInput(kMaskOnlyInput, NodeValue::kBoolean, false); + add_input(k_mask_only_input, NodeValue::k_boolean, false); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -QString ColorDifferenceKeyNode::Name() const +QString ColorDifferenceKeyNode::name() const { return tr("Color Difference Key"); } @@ -71,48 +71,48 @@ QString ColorDifferenceKeyNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.colordifferencekey"); } -QVector ColorDifferenceKeyNode::Category() const +QVector ColorDifferenceKeyNode::category() const { - return { kCategoryKeying }; + return { k_category_keying }; } -QString ColorDifferenceKeyNode::Description() const +QString ColorDifferenceKeyNode::description() const { return tr( "A simple color key based on the distance of one color from other colors."); } -void ColorDifferenceKeyNode::Retranslate() +void ColorDifferenceKeyNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); - SetInputName(kGarbageMatteInput, tr("Garbage Matte")); - SetInputName(kCoreMatteInput, tr("Core Matte")); - SetInputName(kColorInput, tr("Key Color")); - SetComboBoxStrings(kColorInput, { tr("Green"), tr("Blue") }); - SetInputName(kShadowsInput, tr("Shadows")); - SetInputName(kHighlightsInput, tr("Highlights")); - SetInputName(kMaskOnlyInput, tr("Show Mask Only")); + set_input_name(k_texture_input, tr("Input")); + set_input_name(k_garbage_matte_input, tr("Garbage Matte")); + set_input_name(k_core_matte_input, tr("Core Matte")); + set_input_name(k_color_input, tr("Key Color")); + set_combo_box_strings(k_color_input, { tr("Green"), tr("Blue") }); + set_input_name(k_shadows_input, tr("Shadows")); + set_input_name(k_highlights_input, tr("Highlights")); + set_input_name(k_mask_only_input, tr("Show Mask Only")); } ShaderCode -ColorDifferenceKeyNode::GetShaderCode(const ShaderRequest &request) const +ColorDifferenceKeyNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/colordifferencekey.frag")); + FileFunctions::read_file_as_string(":/shaders/colordifferencekey.frag")); } -void ColorDifferenceKeyNode::Value(const NodeValueRow &value, +void ColorDifferenceKeyNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // If there's no texture, no need to run an operation - if (TexturePtr tex = value[kTextureInput].toTexture()) { + if (TexturePtr tex = value[k_texture_input].to_texture()) { ShaderJob job; - job.Insert(value); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + job.insert(value); + table->push(NodeValue::k_texture, tex->to_job(job), this); } } diff --git a/app/node/keying/colordifferencekey/colordifferencekey.h b/app/node/keying/colordifferencekey/colordifferencekey.h index 9ee4c7acd..a19d732b7 100644 --- a/app/node/keying/colordifferencekey/colordifferencekey.h +++ b/app/node/keying/colordifferencekey/colordifferencekey.h @@ -14,8 +14,8 @@ along with this program. If not, see . ***/ -#ifndef COLORDIFFERENCEKEYNODE_H -#define COLORDIFFERENCEKEYNODE_H +#ifndef OAK_COLORDIFFERENCEKEYNODE_H +#define OAK_COLORDIFFERENCEKEYNODE_H #include "node/node.h" @@ -28,27 +28,27 @@ public: NODE_DEFAULT_FUNCTIONS(ColorDifferenceKeyNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTextureInput; - static const QString kGarbageMatteInput; - static const QString kCoreMatteInput; - static const QString kColorInput; - static const QString kShadowsInput; - static const QString kHighlightsInput; - static const QString kMaskOnlyInput; + static const QString k_texture_input; + static const QString k_garbage_matte_input; + static const QString k_core_matte_input; + static const QString k_color_input; + static const QString k_shadows_input; + static const QString k_highlights_input; + static const QString k_mask_only_input; }; } // namespace olive -#endif // COLORDIFFERENCEKEYNODE_H +#endif // OAK_COLORDIFFERENCEKEYNODE_H diff --git a/app/node/keying/despill/despill.cpp b/app/node/keying/despill/despill.cpp index 090ed0452..1df019967 100644 --- a/app/node/keying/despill/despill.cpp +++ b/app/node/keying/despill/despill.cpp @@ -21,30 +21,30 @@ namespace olive { -const QString DespillNode::kTextureInput = QStringLiteral("tex_in"); -const QString DespillNode::kColorInput = QStringLiteral("color_in"); -const QString DespillNode::kMethodInput = QStringLiteral("method_in"); -const QString DespillNode::kPreserveLuminanceInput = +const QString DespillNode::k_texture_input = QStringLiteral("tex_in"); +const QString DespillNode::k_color_input = QStringLiteral("color_in"); +const QString DespillNode::k_method_input = QStringLiteral("method_in"); +const QString DespillNode::k_preserve_luminance_input = QStringLiteral("preserve_luminance_input"); #define super Node DespillNode::DespillNode() { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kColorInput, NodeValue::kCombo, 0); + add_input(k_color_input, NodeValue::k_combo, 0); - AddInput(kMethodInput, NodeValue::kCombo, 0); + add_input(k_method_input, NodeValue::k_combo, 0); - AddInput(kPreserveLuminanceInput, NodeValue::kBoolean, false); + add_input(k_preserve_luminance_input, NodeValue::k_boolean, false); - SetFlag(kVideoEffect); - SetEffectInput(kTextureInput); + set_flag(k_video_effect); + set_effect_input(k_texture_input); } -QString DespillNode::Name() const +QString DespillNode::name() const { return tr("Despill"); } @@ -54,62 +54,62 @@ QString DespillNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.despill"); } -QVector DespillNode::Category() const +QVector DespillNode::category() const { - return { kCategoryKeying }; + return { k_category_keying }; } -QString DespillNode::Description() const +QString DespillNode::description() const { return tr("Selection of simple despill operations"); } -void DespillNode::Retranslate() +void DespillNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTextureInput, tr("Input")); + set_input_name(k_texture_input, tr("Input")); - SetInputName(kColorInput, tr("Key Color")); - SetComboBoxStrings(kColorInput, { tr("Green"), tr("Blue") }); + set_input_name(k_color_input, tr("Key Color")); + set_combo_box_strings(k_color_input, { tr("Green"), tr("Blue") }); - SetInputName(kMethodInput, tr("Method")); - SetComboBoxStrings(kMethodInput, { tr("Average"), tr("Double Red Average"), + set_input_name(k_method_input, tr("Method")); + set_combo_box_strings(k_method_input, { tr("Average"), tr("Double Red Average"), tr("Double Average"), tr("Limit") }); - SetInputName(kPreserveLuminanceInput, tr("Preserve Luminance")); + set_input_name(k_preserve_luminance_input, tr("Preserve Luminance")); } -ShaderCode DespillNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode DespillNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/despill.frag")); + FileFunctions::read_file_as_string(":/shaders/despill.frag")); } -void DespillNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void DespillNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { ShaderJob job; - job.Insert(value); + job.insert(value); // Set luma coefficients double luma_coeffs[3] = { 0.0f, 0.0f, 0.0f }; if (project() && project()->color_manager()) { - project()->color_manager()->GetDefaultLumaCoefs(luma_coeffs); + project()->color_manager()->get_default_luma_coefs(luma_coeffs); } else { luma_coeffs[0] = 0.2126; luma_coeffs[1] = 0.7152; luma_coeffs[2] = 0.0722; } - job.Insert( + job.insert( QStringLiteral("luma_coeffs"), - NodeValue(NodeValue::kVec3, + NodeValue(NodeValue::k_vec3, QVector3D(luma_coeffs[0], luma_coeffs[1], luma_coeffs[2]))); // If there's no texture, no need to run an operation - if (TexturePtr tex = job.Get(kTextureInput).toTexture()) { - table->Push(NodeValue::kTexture, tex->toJob(job), this); + if (TexturePtr tex = job.get(k_texture_input).to_texture()) { + table->push(NodeValue::k_texture, tex->to_job(job), this); } } diff --git a/app/node/keying/despill/despill.h b/app/node/keying/despill/despill.h index 40ed3b20e..cba5a161d 100644 --- a/app/node/keying/despill/despill.h +++ b/app/node/keying/despill/despill.h @@ -14,8 +14,8 @@ along with this program. If not, see . ***/ -#ifndef DESPILLNODE_H -#define DESPILLNODE_H +#ifndef OAK_DESPILLNODE_H +#define OAK_DESPILLNODE_H #include "node/node.h" #include "node/color/colormanager/colormanager.h" @@ -29,24 +29,24 @@ public: NODE_DEFAULT_FUNCTIONS(DespillNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTextureInput; - static const QString kColorInput; - static const QString kMethodInput; - static const QString kPreserveLuminanceInput; + static const QString k_texture_input; + static const QString k_color_input; + static const QString k_method_input; + static const QString k_preserve_luminance_input; }; } // namespace olive -#endif // DESPILLNODE_H +#endif // OAK_DESPILLNODE_H diff --git a/app/node/math/math/math.cpp b/app/node/math/math/math.cpp index 2113f40db..76ebe1812 100644 --- a/app/node/math/math/math.cpp +++ b/app/node/math/math/math.cpp @@ -24,32 +24,32 @@ namespace olive { -const QString MathNode::kMethodIn = QStringLiteral("method_in"); -const QString MathNode::kParamAIn = QStringLiteral("param_a_in"); -const QString MathNode::kParamBIn = QStringLiteral("param_b_in"); -const QString MathNode::kParamCIn = QStringLiteral("param_c_in"); +const QString MathNode::k_method_in = QStringLiteral("method_in"); +const QString MathNode::k_param_a_in = QStringLiteral("param_a_in"); +const QString MathNode::k_param_b_in = QStringLiteral("param_b_in"); +const QString MathNode::k_param_c_in = QStringLiteral("param_c_in"); #define super MathNodeBase MathNode::MathNode() { - AddInput(kMethodIn, NodeValue::kCombo, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_method_in, NodeValue::k_combo, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - AddInput(kParamAIn, NodeValue::kFloat, 0.0); - SetInputProperty(kParamAIn, QStringLiteral("decimalplaces"), 8); - SetInputProperty(kParamAIn, QStringLiteral("autotrim"), true); + add_input(k_param_a_in, NodeValue::k_float, 0.0); + set_input_property(k_param_a_in, QStringLiteral("decimalplaces"), 8); + set_input_property(k_param_a_in, QStringLiteral("autotrim"), true); - AddInput(kParamBIn, NodeValue::kFloat, 0.0); - SetInputProperty(kParamBIn, QStringLiteral("decimalplaces"), 8); - SetInputProperty(kParamBIn, QStringLiteral("autotrim"), true); + add_input(k_param_b_in, NodeValue::k_float, 0.0); + set_input_property(k_param_b_in, QStringLiteral("decimalplaces"), 8); + set_input_property(k_param_b_in, QStringLiteral("autotrim"), true); } -QString MathNode::Name() const +QString MathNode::name() const { // Default to naming after the operation if (parent()) { - QString op_name = GetOperationName(GetOperation()); + QString op_name = get_operation_name(get_operation()); if (!op_name.isEmpty()) { return op_name; } @@ -63,63 +63,63 @@ QString MathNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.math"); } -QVector MathNode::Category() const +QVector MathNode::category() const { - return { kCategoryMath }; + return { k_category_math }; } -QString MathNode::Description() const +QString MathNode::description() const { return tr("Perform a mathematical operation between two values."); } -void MathNode::Retranslate() +void MathNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kMethodIn, tr("Method")); - SetInputName(kParamAIn, tr("Value")); - SetInputName(kParamBIn, tr("Value")); + set_input_name(k_method_in, tr("Method")); + set_input_name(k_param_a_in, tr("Value")); + set_input_name(k_param_b_in, tr("Value")); - QStringList operations = { GetOperationName(kOpAdd), - GetOperationName(kOpSubtract), - GetOperationName(kOpMultiply), - GetOperationName(kOpDivide), - GetOperationName(kOpPower) }; + QStringList operations = { get_operation_name(k_op_add), + get_operation_name(k_op_subtract), + get_operation_name(k_op_multiply), + get_operation_name(k_op_divide), + get_operation_name(k_op_power) }; - SetComboBoxStrings(kMethodIn, operations); + set_combo_box_strings(k_method_in, operations); } -ShaderCode MathNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode MathNode::get_shader_code(const ShaderRequest &request) const { - return GetShaderCodeInternal(request.id, kParamAIn, kParamBIn); + return get_shader_code_internal(request.id, k_param_a_in, k_param_b_in); } -void MathNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void MathNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // Auto-detect what values to operate with // FIXME: Very inefficient NodeValueTable at, bt; - at.Push(value[kParamAIn]); - bt.Push(value[kParamBIn]); + at.push(value[k_param_a_in]); + bt.push(value[k_param_b_in]); PairingCalculator calc(at, bt); // Do nothing if no pairing was found - if (!calc.FoundMostLikelyPairing()) { + if (!calc.found_most_likely_pairing()) { return; } - return ValueInternal(GetOperation(), calc.GetMostLikelyPairing(), kParamAIn, - calc.GetMostLikelyValueA(), kParamBIn, - calc.GetMostLikelyValueB(), globals, table); + return value_internal(get_operation(), calc.get_most_likely_pairing(), k_param_a_in, + calc.get_most_likely_value_a(), k_param_b_in, + calc.get_most_likely_value_b(), globals, table); } -void MathNode::ProcessSamples(const NodeValueRow &values, +void MathNode::process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const { - return ProcessSamplesInternal(values, GetOperation(), kParamAIn, kParamBIn, + return process_samples_internal(values, get_operation(), k_param_a_in, k_param_b_in, input, output, index); } diff --git a/app/node/math/math/math.h b/app/node/math/math/math.h index 759e9d540..338e87c6d 100644 --- a/app/node/math/math/math.h +++ b/app/node/math/math/math.h @@ -19,8 +19,8 @@ ***/ -#ifndef MATHNODE_H -#define MATHNODE_H +#ifndef OAK_MATHNODE_H +#define OAK_MATHNODE_H #include "mathbase.h" @@ -34,39 +34,39 @@ public: NODE_DEFAULT_FUNCTIONS(MathNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; + get_shader_code(const ShaderRequest &request) const override; - Operation GetOperation() const + Operation get_operation() const { - return static_cast(GetStandardValue(kMethodIn).toInt()); + return static_cast(get_standard_value(k_method_in).toInt()); } - void SetOperation(Operation o) + void set_operation(Operation o) { - SetStandardValue(kMethodIn, o); + set_standard_value(k_method_in, o); } - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual void ProcessSamples(const NodeValueRow &values, + virtual void process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const override; - static const QString kMethodIn; - static const QString kParamAIn; - static const QString kParamBIn; - static const QString kParamCIn; + static const QString k_method_in; + static const QString k_param_a_in; + static const QString k_param_b_in; + static const QString k_param_c_in; }; } -#endif // MATHNODE_H +#endif // OAK_MATHNODE_H diff --git a/app/node/math/math/mathbase.cpp b/app/node/math/math/mathbase.cpp index 9bf6ed1cc..92979d521 100644 --- a/app/node/math/math/mathbase.cpp +++ b/app/node/math/math/mathbase.cpp @@ -30,7 +30,7 @@ namespace olive { -ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id, +ShaderCode MathNodeBase::get_shader_code_internal(const QString &shader_id, const QString ¶m_a_in, const QString ¶m_b_in) const { @@ -45,11 +45,11 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id, QString operation, frag, vert; - if (pairing == kPairTextureMatrix && op == kOpMultiply) { + if (pairing == k_pair_texture_matrix && op == k_op_multiply) { // Override the operation for this operation since we multiply texture COORDS by the matrix rather than - const QString &tex_in = (type_a == NodeValue::kTexture) ? param_a_in : + const QString &tex_in = (type_a == NodeValue::k_texture) ? param_a_in : param_b_in; - const QString &mat_in = (type_a == NodeValue::kTexture) ? param_b_in : + const QString &mat_in = (type_a == NodeValue::k_texture) ? param_b_in : param_a_in; // No-op frag shader (can we return QString() instead?) @@ -70,20 +70,20 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id, } else { switch (op) { - case kOpAdd: + case k_op_add: operation = QStringLiteral("%1 + %2"); break; - case kOpSubtract: + case k_op_subtract: operation = QStringLiteral("%1 - %2"); break; - case kOpMultiply: + case k_op_multiply: operation = QStringLiteral("%1 * %2"); break; - case kOpDivide: + case k_op_divide: operation = QStringLiteral("%1 / %2"); break; - case kOpPower: - if (pairing == kPairTextureNumber) { + case k_op_power: + if (pairing == k_pair_texture_number) { // The "number" in this operation has to be declared a vec4 if (NodeValue::type_is_numeric(type_a)) { operation = QStringLiteral("pow(%2, vec4(%1))"); @@ -96,8 +96,8 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id, break; } - operation = operation.arg(GetShaderVariableCall(param_a_in, type_a), - GetShaderVariableCall(param_b_in, type_b)); + operation = operation.arg(get_shader_variable_call(param_a_in, type_a), + get_shader_variable_call(param_b_in, type_b)); } frag = @@ -113,31 +113,31 @@ ShaderCode MathNodeBase::GetShaderCodeInternal(const QString &shader_id, " c.a = clamp(c.a, 0.0, 1.0);\n" // Ensure alpha is between 0.0 and 1.0 " frag_color = c;\n" "}\n") - .arg(GetShaderUniformType(type_a), GetShaderUniformType(type_b), + .arg(get_shader_uniform_type(type_a), get_shader_uniform_type(type_b), param_a_in, param_b_in, operation); return ShaderCode(frag, vert); } -QString MathNodeBase::GetShaderUniformType(const olive::NodeValue::Type &type) +QString MathNodeBase::get_shader_uniform_type(const olive::NodeValue::Type &type) { switch (type) { - case NodeValue::kTexture: + case NodeValue::k_texture: return QStringLiteral("sampler2D"); - case NodeValue::kColor: + case NodeValue::k_color: return QStringLiteral("vec4"); - case NodeValue::kMatrix: + case NodeValue::k_matrix: return QStringLiteral("mat4"); default: return QStringLiteral("float"); } } -QString MathNodeBase::GetShaderVariableCall(const QString &input_id, +QString MathNodeBase::get_shader_variable_call(const QString &input_id, const NodeValue::Type &type, const QString &coord_op) { - if (type == NodeValue::kTexture) { + if (type == NodeValue::k_texture) { return QStringLiteral("texture(%1, ove_texcoord%2)") .arg(input_id, coord_op); } @@ -145,67 +145,67 @@ QString MathNodeBase::GetShaderVariableCall(const QString &input_id, return input_id; } -QVector4D MathNodeBase::RetrieveVector(const NodeValue &val) +QVector4D MathNodeBase::retrieve_vector(const NodeValue &val) { // QVariant doesn't know that QVector*D can convert themselves so we do it here switch (val.type()) { - case NodeValue::kVec2: - return QVector4D(val.toVec2()); - case NodeValue::kVec3: - return QVector4D(val.toVec3()); - case NodeValue::kVec4: + case NodeValue::k_vec2: + return QVector4D(val.to_vec2()); + case NodeValue::k_vec3: + return QVector4D(val.to_vec3()); + case NodeValue::k_vec4: default: - return val.toVec4(); + return val.to_vec4(); } } -void MathNodeBase::PushVector(NodeValueTable *output, +void MathNodeBase::push_vector(NodeValueTable *output, olive::NodeValue::Type type, const QVector4D &vec) const { switch (type) { - case NodeValue::kVec2: - output->Push(type, QVector2D(vec), this); + case NodeValue::k_vec2: + output->push(type, QVector2D(vec), this); break; - case NodeValue::kVec3: - output->Push(type, QVector3D(vec), this); + case NodeValue::k_vec3: + output->push(type, QVector3D(vec), this); break; - case NodeValue::kVec4: - output->Push(type, vec, this); + case NodeValue::k_vec4: + output->push(type, vec, this); break; default: break; } } -QString MathNodeBase::GetOperationName(Operation o) +QString MathNodeBase::get_operation_name(Operation o) { switch (o) { - case kOpAdd: + case k_op_add: return tr("Add"); - case kOpSubtract: + case k_op_subtract: return tr("Subtract"); - case kOpMultiply: + case k_op_multiply: return tr("Multiply"); - case kOpDivide: + case k_op_divide: return tr("Divide"); - case kOpPower: + case k_op_power: return tr("Power"); } return QString(); } -void MathNodeBase::PerformAllOnFloatBuffer(Operation operation, float *a, +void MathNodeBase::perform_all_on_float_buffer(Operation operation, float *a, float b, int start, int end) { for (int j = start; j < end; j++) { - a[j] = PerformAll(operation, a[j], b); + a[j] = perform_all(operation, a[j], b); } } #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) -void MathNodeBase::PerformAllOnFloatBufferSSE(Operation operation, float *a, +void MathNodeBase::perform_all_on_float_buffer_sse(Operation operation, float *a, float b, int start, int end) { int end_divisible_4 = (end / 4) * 4; @@ -214,32 +214,32 @@ void MathNodeBase::PerformAllOnFloatBufferSSE(Operation operation, float *a, __m128 mult = _mm_load1_ps(&b); switch (operation) { - case kOpAdd: + case k_op_add: // Loop all values for (int j = 0; j < end_divisible_4; j += 4) { _mm_storeu_ps(a + start + j, _mm_add_ps(_mm_loadu_ps(a + start + j), mult)); } break; - case kOpSubtract: + case k_op_subtract: for (int j = 0; j < end_divisible_4; j += 4) { _mm_storeu_ps(a + start + j, _mm_sub_ps(_mm_loadu_ps(a + start + j), mult)); } break; - case kOpMultiply: + case k_op_multiply: for (int j = 0; j < end_divisible_4; j += 4) { _mm_storeu_ps(a + start + j, _mm_mul_ps(_mm_loadu_ps(a + start + j), mult)); } break; - case kOpDivide: + case k_op_divide: for (int j = 0; j < end_divisible_4; j += 4) { _mm_storeu_ps(a + start + j, _mm_div_ps(_mm_loadu_ps(a + start + j), mult)); } break; - case kOpPower: + case k_op_power: // Fallback for operations we can't support here end_divisible_4 = 0; break; @@ -247,133 +247,133 @@ void MathNodeBase::PerformAllOnFloatBufferSSE(Operation operation, float *a, // Handle last 1-3 bytes if necessary, or all bytes if we couldn't // support this op on SSE - PerformAllOnFloatBuffer(operation, a, b, end_divisible_4, end); + perform_all_on_float_buffer(operation, a, b, end_divisible_4, end); } #endif -void MathNodeBase::ValueInternal( +void MathNodeBase::value_internal( Operation operation, Pairing pairing, const QString ¶m_a_in, const NodeValue &val_a, const QString ¶m_b_in, const NodeValue &val_b, const NodeGlobals &globals, NodeValueTable *output) const { switch (pairing) { - case kPairNumberNumber: { - if (val_a.type() == NodeValue::kRational && - val_b.type() == NodeValue::kRational && operation != kOpPower) { + case k_pair_number_number: { + if (val_a.type() == NodeValue::k_rational && + val_b.type() == NodeValue::k_rational && operation != k_op_power) { // Preserve rationals - output->Push( - NodeValue::kRational, - QVariant::fromValue(PerformAddSubMultDiv( - operation, val_a.toRational(), val_b.toRational())), + output->push( + NodeValue::k_rational, + QVariant::fromValue(perform_add_sub_mult_div( + operation, val_a.to_rational(), val_b.to_rational())), this); } else { - output->Push(NodeValue::kFloat, - PerformAll(operation, - RetrieveNumber(val_a), - RetrieveNumber(val_b)), + output->push(NodeValue::k_float, + perform_all(operation, + retrieve_number(val_a), + retrieve_number(val_b)), this); } break; } - case kPairVecVec: { + case k_pair_vec_vec: { // We convert all vectors to QVector4D just for simplicity and exploit the fact that kVec4 is higher than kVec2 in // the enum to find the largest data type - QVector4D vec_a = RetrieveVector(val_a); - QVector4D vec_b = RetrieveVector(val_b); + QVector4D vec_a = retrieve_vector(val_a); + QVector4D vec_b = retrieve_vector(val_b); - if (operation == kOpDivide) { + if (operation == k_op_divide) { // Lower-dimensional vectors are padded with zeros; dividing the // padding components would be 0/0 (assert in Qt debug builds, NaN // otherwise). Force those components to 0/1 so the result is a // well-defined zero, which is discarded by PushVector anyway. const NodeValue::Type max_type = qMax(val_a.type(), val_b.type()); - if (max_type == NodeValue::kVec2) { + if (max_type == NodeValue::k_vec2) { vec_a.setZ(0.0f); vec_a.setW(0.0f); vec_b.setZ(1.0f); vec_b.setW(1.0f); - } else if (max_type == NodeValue::kVec3) { + } else if (max_type == NodeValue::k_vec3) { vec_a.setW(0.0f); vec_b.setW(1.0f); } } - PushVector(output, qMax(val_a.type(), val_b.type()), - PerformAddSubMultDiv(operation, vec_a, + push_vector(output, qMax(val_a.type(), val_b.type()), + perform_add_sub_mult_div(operation, vec_a, vec_b)); break; } - case kPairMatrixVec: { - QMatrix4x4 matrix = (val_a.type() == NodeValue::kMatrix) ? - val_a.toMatrix() : - val_b.toMatrix(); - QVector4D vec = (val_a.type() == NodeValue::kMatrix) ? - RetrieveVector(val_b) : - RetrieveVector(val_a); + case k_pair_matrix_vec: { + QMatrix4x4 matrix = (val_a.type() == NodeValue::k_matrix) ? + val_a.to_matrix() : + val_b.to_matrix(); + QVector4D vec = (val_a.type() == NodeValue::k_matrix) ? + retrieve_vector(val_b) : + retrieve_vector(val_a); // Only valid operation is multiply - PushVector(output, qMax(val_a.type(), val_b.type()), - PerformMult(operation, vec, matrix)); + push_vector(output, qMax(val_a.type(), val_b.type()), + perform_mult(operation, vec, matrix)); break; } - case kPairVecNumber: { + case k_pair_vec_number: { QVector4D vec = (NodeValue::type_is_vector(val_a.type()) ? - RetrieveVector(val_a) : - RetrieveVector(val_b)); - float number = RetrieveNumber(NodeValue::type_is_vector(val_a.type()) ? + retrieve_vector(val_a) : + retrieve_vector(val_b)); + float number = retrieve_number(NodeValue::type_is_vector(val_a.type()) ? val_b : val_a); // Only multiply and divide are valid operations - PushVector(output, + push_vector(output, NodeValue::type_is_vector(val_a.type()) ? val_a.type() : val_b.type(), - PerformMultDiv(operation, vec, number)); + perform_mult_div(operation, vec, number)); break; } - case kPairMatrixMatrix: { - QMatrix4x4 mat_a = val_a.toMatrix(); - QMatrix4x4 mat_b = val_b.toMatrix(); - output->Push(NodeValue::kMatrix, - PerformAddSubMult(operation, mat_a, + case k_pair_matrix_matrix: { + QMatrix4x4 mat_a = val_a.to_matrix(); + QMatrix4x4 mat_b = val_b.to_matrix(); + output->push(NodeValue::k_matrix, + perform_add_sub_mult(operation, mat_a, mat_b), this); break; } - case kPairColorColor: { - Color col_a = val_a.toColor(); - Color col_b = val_b.toColor(); + case k_pair_color_color: { + Color col_a = val_a.to_color(); + Color col_b = val_b.to_color(); // Only add and subtract are valid operations - output->Push(NodeValue::kColor, + output->push(NodeValue::k_color, QVariant::fromValue( - PerformAddSub(operation, col_a, col_b)), + perform_add_sub(operation, col_a, col_b)), this); break; } - case kPairNumberColor: { - Color col = (val_a.type() == NodeValue::kColor) ? val_a.toColor() : - val_b.toColor(); - float num = (val_a.type() == NodeValue::kColor) ? val_b.toDouble() : - val_a.toDouble(); + case k_pair_number_color: { + Color col = (val_a.type() == NodeValue::k_color) ? val_a.to_color() : + val_b.to_color(); + float num = (val_a.type() == NodeValue::k_color) ? val_b.to_double() : + val_a.to_double(); // Only multiply and divide are valid operations - output->Push( - NodeValue::kColor, - QVariant::fromValue(PerformMult(operation, col, num)), + output->push( + NodeValue::k_color, + QVariant::fromValue(perform_mult(operation, col, num)), this); break; } - case kPairSampleSample: { - SampleBuffer samples_a = val_a.toSamples(); - SampleBuffer samples_b = val_b.toSamples(); + case k_pair_sample_sample: { + SampleBuffer samples_a = val_a.to_samples(); + SampleBuffer samples_b = val_b.to_samples(); size_t max_samples = qMax(samples_a.sample_count(), samples_b.sample_count()); @@ -386,7 +386,7 @@ void MathNodeBase::ValueInternal( for (int i = 0; i < mixed_samples.audio_params().channel_count(); i++) { // Mix samples that are in both buffers for (size_t j = 0; j < min_samples; j++) { - mixed_samples.data(i)[j] = PerformAll( + mixed_samples.data(i)[j] = perform_all( operation, samples_a.data(i)[j], samples_b.data(i)[j]); } } @@ -407,94 +407,94 @@ void MathNodeBase::ValueInternal( } } - output->Push(NodeValue::kSamples, QVariant::fromValue(mixed_samples), + output->push(NodeValue::k_samples, QVariant::fromValue(mixed_samples), this); break; } - case kPairTextureColor: - case kPairTextureNumber: - case kPairTextureTexture: - case kPairTextureMatrix: { + case k_pair_texture_color: + case k_pair_texture_number: + case k_pair_texture_texture: + case k_pair_texture_matrix: { ShaderJob job; - job.SetShaderID(QStringLiteral("%1.%2.%3.%4") + job.set_shader_id(QStringLiteral("%1.%2.%3.%4") .arg(QString::number(operation), QString::number(pairing), QString::number(val_a.type()), QString::number(val_b.type()))); - job.Insert(param_a_in, val_a); - job.Insert(param_b_in, val_b); + job.insert(param_a_in, val_a); + job.insert(param_b_in, val_b); bool operation_is_noop = false; const NodeValue &number_val = - val_a.type() == NodeValue::kTexture ? val_b : val_a; + val_a.type() == NodeValue::k_texture ? val_b : val_a; const NodeValue &texture_val = - val_a.type() == NodeValue::kTexture ? val_a : val_b; - TexturePtr texture = texture_val.toTexture(); + val_a.type() == NodeValue::k_texture ? val_a : val_b; + TexturePtr texture = texture_val.to_texture(); if (!texture) { operation_is_noop = true; - } else if (pairing == kPairTextureNumber) { - if (NumberIsNoOp(operation, RetrieveNumber(number_val))) { + } else if (pairing == k_pair_texture_number) { + if (number_is_no_op(operation, retrieve_number(number_val))) { operation_is_noop = true; } - } else if (pairing == kPairTextureMatrix) { + } else if (pairing == k_pair_texture_matrix) { // Only allow matrix multiplication const QVector2D &sequence_res = globals.nonsquare_resolution(); QVector2D texture_res(texture->params().width() * - texture->pixel_aspect_ratio().toDouble(), + texture->pixel_aspect_ratio().to_double(), texture->params().height()); QMatrix4x4 adjusted_matrix = - TransformDistortNode::AdjustMatrixByResolutions( - number_val.toMatrix(), sequence_res, + TransformDistortNode::adjust_matrix_by_resolutions( + number_val.to_matrix(), sequence_res, texture->params().offset(), texture_res); - if (operation != kOpMultiply || adjusted_matrix.isIdentity()) { + if (operation != k_op_multiply || adjusted_matrix.isIdentity()) { operation_is_noop = true; } else { // Replace with adjusted matrix - job.Insert(val_a.type() == NodeValue::kTexture ? param_b_in : + job.insert(val_a.type() == NodeValue::k_texture ? param_b_in : param_a_in, - NodeValue(NodeValue::kMatrix, adjusted_matrix, + NodeValue(NodeValue::k_matrix, adjusted_matrix, this)); } } if (operation_is_noop) { // Just push texture as-is - output->Push(texture_val); + output->push(texture_val); } else { // Push shader job - output->Push(NodeValue::kTexture, - Texture::Job(globals.vparams(), job), this); + output->push(NodeValue::k_texture, + Texture::job(globals.vparams(), job), this); } break; } - case kPairSampleNumber: { + case k_pair_sample_number: { // Queue a sample job const NodeValue &number_val = - val_a.type() == NodeValue::kSamples ? val_b : val_a; + val_a.type() == NodeValue::k_samples ? val_b : val_a; const QString &number_param = - val_a.type() == NodeValue::kSamples ? param_b_in : param_a_in; + val_a.type() == NodeValue::k_samples ? param_b_in : param_a_in; - float number = RetrieveNumber(number_val); + float number = retrieve_number(number_val); - SampleBuffer buffer = val_a.type() == NodeValue::kSamples ? - val_a.toSamples() : - val_b.toSamples(); + SampleBuffer buffer = val_a.type() == NodeValue::k_samples ? + val_a.to_samples() : + val_b.to_samples(); if (buffer.is_allocated()) { - if (IsInputStatic(number_param)) { - if (!NumberIsNoOp(operation, number)) { + if (is_input_static(number_param)) { + if (!number_is_no_op(operation, number)) { for (int i = 0; i < buffer.audio_params().channel_count(); i++) { #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) // Use SSE instructions for optimization - PerformAllOnFloatBufferSSE(operation, buffer.data(i), + perform_all_on_float_buffer_sse(operation, buffer.data(i), number, 0, buffer.sample_count()); #else @@ -505,28 +505,28 @@ void MathNodeBase::ValueInternal( } } - output->Push(NodeValue::kSamples, QVariant::fromValue(buffer), + output->push(NodeValue::k_samples, QVariant::fromValue(buffer), this); } else { SampleJob job(globals.time(), - val_a.type() == NodeValue::kSamples ? val_a : + val_a.type() == NodeValue::k_samples ? val_a : val_b); - job.Insert(number_param, - NodeValue(NodeValue::kFloat, number, this)); - output->Push(NodeValue::kSamples, QVariant::fromValue(job), + job.insert(number_param, + NodeValue(NodeValue::k_float, number, this)); + output->push(NodeValue::k_samples, QVariant::fromValue(job), this); } } break; } - case kPairNone: - case kPairCount: + case k_pair_none: + case k_pair_count: break; } } -void MathNodeBase::ProcessSamplesInternal(const NodeValueRow &values, +void MathNodeBase::process_samples_internal(const NodeValueRow &values, MathNodeBase::Operation operation, const QString ¶m_a_in, const QString ¶m_b_in, @@ -537,44 +537,44 @@ void MathNodeBase::ProcessSamplesInternal(const NodeValueRow &values, // This function is only used for sample+number pairing NodeValue number_val = values[param_a_in]; - if (number_val.type() == NodeValue::kNone) { + if (number_val.type() == NodeValue::k_none) { number_val = values[param_b_in]; - if (number_val.type() == NodeValue::kNone) { + if (number_val.type() == NodeValue::k_none) { return; } } - float number_flt = RetrieveNumber(number_val); + float number_flt = retrieve_number(number_val); for (int i = 0; i < output.audio_params().channel_count(); i++) { - output.data(i)[index] = PerformAll( + output.data(i)[index] = perform_all( operation, input.data(i)[index], number_flt); } } -float MathNodeBase::RetrieveNumber(const NodeValue &val) +float MathNodeBase::retrieve_number(const NodeValue &val) { - if (val.type() == NodeValue::kRational) { - return val.toRational().toDouble(); + if (val.type() == NodeValue::k_rational) { + return val.to_rational().to_double(); } else { - return val.toDouble(); + return val.to_double(); } } -bool MathNodeBase::NumberIsNoOp(const MathNodeBase::Operation &op, +bool MathNodeBase::number_is_no_op(const MathNodeBase::Operation &op, const float &number) { switch (op) { - case kOpAdd: - case kOpSubtract: + case k_op_add: + case k_op_subtract: if (qIsNull(number)) { return true; } break; - case kOpMultiply: - case kOpDivide: - case kOpPower: + case k_op_multiply: + case k_op_divide: + case k_op_power: if (qFuzzyCompare(number, 1.0f)) { return true; } @@ -587,15 +587,15 @@ bool MathNodeBase::NumberIsNoOp(const MathNodeBase::Operation &op, MathNodeBase::PairingCalculator::PairingCalculator( const NodeValueTable &table_a, const NodeValueTable &table_b) { - QVector pair_likelihood_a = GetPairLikelihood(table_a); - QVector pair_likelihood_b = GetPairLikelihood(table_b); + QVector pair_likelihood_a = get_pair_likelihood(table_a); + QVector pair_likelihood_b = get_pair_likelihood(table_b); - int weight_a = qMax(0, table_b.Count() - table_a.Count()); - int weight_b = qMax(0, table_a.Count() - table_b.Count()); + int weight_a = qMax(0, table_b.count() - table_a.count()); + int weight_b = qMax(0, table_a.count() - table_b.count()); - QVector likelihoods(kPairCount); + QVector likelihoods(k_pair_count); - for (int i = 0; i < kPairCount; i++) { + for (int i = 0; i < k_pair_count; i++) { if (pair_likelihood_a.at(i) == -1 || pair_likelihood_b.at(i) == -1) { likelihoods.replace(i, -1); } else { @@ -604,18 +604,18 @@ MathNodeBase::PairingCalculator::PairingCalculator( } } - most_likely_pairing_ = kPairNone; + most_likely_pairing_ = k_pair_none; for (int i = 0; i < likelihoods.size(); i++) { if (likelihoods.at(i) > -1) { - if (most_likely_pairing_ == kPairNone || + if (most_likely_pairing_ == k_pair_none || likelihoods.at(i) > likelihoods.at(most_likely_pairing_)) { most_likely_pairing_ = static_cast(i); } } } - if (most_likely_pairing_ != kPairNone) { + if (most_likely_pairing_ != k_pair_none) { most_likely_value_a_ = table_a.at(pair_likelihood_a.at(most_likely_pairing_)); most_likely_value_b_ = @@ -624,82 +624,82 @@ MathNodeBase::PairingCalculator::PairingCalculator( } QVector -MathNodeBase::PairingCalculator::GetPairLikelihood(const NodeValueTable &table) +MathNodeBase::PairingCalculator::get_pair_likelihood(const NodeValueTable &table) { - QVector likelihood(kPairCount, -1); + QVector likelihood(k_pair_count, -1); - for (int i = 0; i < table.Count(); i++) { + for (int i = 0; i < table.count(); i++) { NodeValue::Type type = table.at(i).type(); int weight = i; if (NodeValue::type_is_vector(type)) { - likelihood.replace(kPairVecVec, weight); - likelihood.replace(kPairVecNumber, weight); - likelihood.replace(kPairMatrixVec, weight); - } else if (type == NodeValue::kMatrix) { - likelihood.replace(kPairMatrixMatrix, weight); - likelihood.replace(kPairMatrixVec, weight); - likelihood.replace(kPairTextureMatrix, weight); - } else if (type == NodeValue::kColor) { - likelihood.replace(kPairColorColor, weight); - likelihood.replace(kPairNumberColor, weight); - likelihood.replace(kPairTextureColor, weight); + likelihood.replace(k_pair_vec_vec, weight); + likelihood.replace(k_pair_vec_number, weight); + likelihood.replace(k_pair_matrix_vec, weight); + } else if (type == NodeValue::k_matrix) { + likelihood.replace(k_pair_matrix_matrix, weight); + likelihood.replace(k_pair_matrix_vec, weight); + likelihood.replace(k_pair_texture_matrix, weight); + } else if (type == NodeValue::k_color) { + likelihood.replace(k_pair_color_color, weight); + likelihood.replace(k_pair_number_color, weight); + likelihood.replace(k_pair_texture_color, weight); } else if (NodeValue::type_is_numeric(type)) { - likelihood.replace(kPairNumberNumber, weight); - likelihood.replace(kPairVecNumber, weight); - likelihood.replace(kPairNumberColor, weight); - likelihood.replace(kPairTextureNumber, weight); - likelihood.replace(kPairSampleNumber, weight); - } else if (type == NodeValue::kSamples) { - likelihood.replace(kPairSampleSample, weight); - likelihood.replace(kPairSampleNumber, weight); - } else if (type == NodeValue::kTexture) { - likelihood.replace(kPairTextureTexture, weight); - likelihood.replace(kPairTextureNumber, weight); - likelihood.replace(kPairTextureColor, weight); - likelihood.replace(kPairTextureMatrix, weight); + likelihood.replace(k_pair_number_number, weight); + likelihood.replace(k_pair_vec_number, weight); + likelihood.replace(k_pair_number_color, weight); + likelihood.replace(k_pair_texture_number, weight); + likelihood.replace(k_pair_sample_number, weight); + } else if (type == NodeValue::k_samples) { + likelihood.replace(k_pair_sample_sample, weight); + likelihood.replace(k_pair_sample_number, weight); + } else if (type == NodeValue::k_texture) { + likelihood.replace(k_pair_texture_texture, weight); + likelihood.replace(k_pair_texture_number, weight); + likelihood.replace(k_pair_texture_color, weight); + likelihood.replace(k_pair_texture_matrix, weight); } } return likelihood; } -bool MathNodeBase::PairingCalculator::FoundMostLikelyPairing() const +bool MathNodeBase::PairingCalculator::found_most_likely_pairing() const { - return (most_likely_pairing_ > kPairNone && - most_likely_pairing_ < kPairCount); + return (most_likely_pairing_ > k_pair_none && + most_likely_pairing_ < k_pair_count); } MathNodeBase::Pairing -MathNodeBase::PairingCalculator::GetMostLikelyPairing() const +MathNodeBase::PairingCalculator::get_most_likely_pairing() const { return most_likely_pairing_; } -const NodeValue &MathNodeBase::PairingCalculator::GetMostLikelyValueA() const +const NodeValue &MathNodeBase::PairingCalculator::get_most_likely_value_a() const { return most_likely_value_a_; } -const NodeValue &MathNodeBase::PairingCalculator::GetMostLikelyValueB() const +const NodeValue &MathNodeBase::PairingCalculator::get_most_likely_value_b() const { return most_likely_value_b_; } template -T MathNodeBase::PerformAll(Operation operation, T a, U b) +T MathNodeBase::perform_all(Operation operation, T a, U b) { switch (operation) { - case kOpAdd: + case k_op_add: return a + b; - case kOpSubtract: + case k_op_subtract: return a - b; - case kOpMultiply: + case k_op_multiply: return a * b; - case kOpDivide: + case k_op_divide: return a / b; - case kOpPower: + case k_op_power: return std::pow(a, b); } @@ -707,16 +707,16 @@ T MathNodeBase::PerformAll(Operation operation, T a, U b) } template -T MathNodeBase::PerformMultDiv(Operation operation, T a, U b) +T MathNodeBase::perform_mult_div(Operation operation, T a, U b) { switch (operation) { - case kOpMultiply: + case k_op_multiply: return a * b; - case kOpDivide: + case k_op_divide: return a / b; - case kOpAdd: - case kOpSubtract: - case kOpPower: + case k_op_add: + case k_op_subtract: + case k_op_power: break; } @@ -724,16 +724,16 @@ T MathNodeBase::PerformMultDiv(Operation operation, T a, U b) } template -T MathNodeBase::PerformAddSub(Operation operation, T a, U b) +T MathNodeBase::perform_add_sub(Operation operation, T a, U b) { switch (operation) { - case kOpAdd: + case k_op_add: return a + b; - case kOpSubtract: + case k_op_subtract: return a - b; - case kOpMultiply: - case kOpDivide: - case kOpPower: + case k_op_multiply: + case k_op_divide: + case k_op_power: break; } @@ -741,15 +741,15 @@ T MathNodeBase::PerformAddSub(Operation operation, T a, U b) } template -T MathNodeBase::PerformMult(Operation operation, T a, U b) +T MathNodeBase::perform_mult(Operation operation, T a, U b) { switch (operation) { - case kOpMultiply: + case k_op_multiply: return a * b; - case kOpAdd: - case kOpSubtract: - case kOpDivide: - case kOpPower: + case k_op_add: + case k_op_subtract: + case k_op_divide: + case k_op_power: break; } @@ -757,17 +757,17 @@ T MathNodeBase::PerformMult(Operation operation, T a, U b) } template -T MathNodeBase::PerformAddSubMult(Operation operation, T a, U b) +T MathNodeBase::perform_add_sub_mult(Operation operation, T a, U b) { switch (operation) { - case kOpAdd: + case k_op_add: return a + b; - case kOpSubtract: + case k_op_subtract: return a - b; - case kOpMultiply: + case k_op_multiply: return a * b; - case kOpDivide: - case kOpPower: + case k_op_divide: + case k_op_power: break; } @@ -775,18 +775,18 @@ T MathNodeBase::PerformAddSubMult(Operation operation, T a, U b) } template -T MathNodeBase::PerformAddSubMultDiv(Operation operation, T a, U b) +T MathNodeBase::perform_add_sub_mult_div(Operation operation, T a, U b) { switch (operation) { - case kOpAdd: + case k_op_add: return a + b; - case kOpSubtract: + case k_op_subtract: return a - b; - case kOpMultiply: + case k_op_multiply: return a * b; - case kOpDivide: + case k_op_divide: return a / b; - case kOpPower: + case k_op_power: break; } diff --git a/app/node/math/math/mathbase.h b/app/node/math/math/mathbase.h index 212aef0c5..308954b78 100644 --- a/app/node/math/math/mathbase.h +++ b/app/node/math/math/mathbase.h @@ -19,8 +19,8 @@ ***/ -#ifndef MATHNODEBASE_H -#define MATHNODEBASE_H +#ifndef OAK_MATHNODEBASE_H +#define OAK_MATHNODEBASE_H #include "node/node.h" @@ -31,30 +31,30 @@ class MathNodeBase : public Node { public: MathNodeBase() = default; - enum Operation { kOpAdd, kOpSubtract, kOpMultiply, kOpDivide, kOpPower }; + enum Operation { k_op_add, k_op_subtract, k_op_multiply, k_op_divide, k_op_power }; - static QString GetOperationName(Operation o); + static QString get_operation_name(Operation o); protected: enum Pairing { - kPairNone = -1, + k_pair_none = -1, - kPairNumberNumber, - kPairVecVec, - kPairMatrixMatrix, - kPairColorColor, - kPairTextureTexture, + k_pair_number_number, + k_pair_vec_vec, + k_pair_matrix_matrix, + k_pair_color_color, + k_pair_texture_texture, - kPairVecNumber, - kPairMatrixVec, - kPairNumberColor, - kPairTextureNumber, - kPairTextureColor, - kPairTextureMatrix, - kPairSampleSample, - kPairSampleNumber, + k_pair_vec_number, + k_pair_matrix_vec, + k_pair_number_color, + k_pair_texture_number, + k_pair_texture_color, + k_pair_texture_matrix, + k_pair_sample_sample, + k_pair_sample_number, - kPairCount + k_pair_count }; class PairingCalculator { @@ -62,14 +62,14 @@ protected: PairingCalculator(const NodeValueTable &table_a, const NodeValueTable &table_b); - bool FoundMostLikelyPairing() const; - Pairing GetMostLikelyPairing() const; + bool found_most_likely_pairing() const; + Pairing get_most_likely_pairing() const; - const NodeValue &GetMostLikelyValueA() const; - const NodeValue &GetMostLikelyValueB() const; + const NodeValue &get_most_likely_value_a() const; + const NodeValue &get_most_likely_value_b() const; private: - static QVector GetPairLikelihood(const NodeValueTable &table); + static QVector get_pair_likelihood(const NodeValueTable &table); Pairing most_likely_pairing_; @@ -79,57 +79,57 @@ protected: }; template - static T PerformAll(Operation operation, T a, U b); + static T perform_all(Operation operation, T a, U b); template - static T PerformMultDiv(Operation operation, T a, U b); + static T perform_mult_div(Operation operation, T a, U b); template - static T PerformAddSub(Operation operation, T a, U b); + static T perform_add_sub(Operation operation, T a, U b); template - static T PerformMult(Operation operation, T a, U b); + static T perform_mult(Operation operation, T a, U b); template - static T PerformAddSubMult(Operation operation, T a, U b); + static T perform_add_sub_mult(Operation operation, T a, U b); template - static T PerformAddSubMultDiv(Operation operation, T a, U b); + static T perform_add_sub_mult_div(Operation operation, T a, U b); - static void PerformAllOnFloatBuffer(Operation operation, float *a, float b, + static void perform_all_on_float_buffer(Operation operation, float *a, float b, int start, int end); #if defined(Q_PROCESSOR_X86) || defined(Q_PROCESSOR_ARM) - static void PerformAllOnFloatBufferSSE(Operation operation, float *a, + static void perform_all_on_float_buffer_sse(Operation operation, float *a, float b, int start, int end); #endif - static QString GetShaderUniformType(const NodeValue::Type &type); + static QString get_shader_uniform_type(const NodeValue::Type &type); - static QString GetShaderVariableCall(const QString &input_id, + static QString get_shader_variable_call(const QString &input_id, const NodeValue::Type &type, const QString &coord_op = QString()); - static QVector4D RetrieveVector(const NodeValue &val); + static QVector4D retrieve_vector(const NodeValue &val); - static float RetrieveNumber(const NodeValue &val); + static float retrieve_number(const NodeValue &val); - static bool NumberIsNoOp(const Operation &op, const float &number); + static bool number_is_no_op(const Operation &op, const float &number); - ShaderCode GetShaderCodeInternal(const QString &shader_id, + ShaderCode get_shader_code_internal(const QString &shader_id, const QString ¶m_a_in, const QString ¶m_b_in) const; - void PushVector(NodeValueTable *output, NodeValue::Type type, + void push_vector(NodeValueTable *output, NodeValue::Type type, const QVector4D &vec) const; - void ValueInternal(Operation operation, Pairing pairing, + void value_internal(Operation operation, Pairing pairing, const QString ¶m_a_in, const NodeValue &val_a, const QString ¶m_b_in, const NodeValue &val_b, const NodeGlobals &globals, NodeValueTable *output) const; - void ProcessSamplesInternal(const NodeValueRow &values, Operation operation, + void process_samples_internal(const NodeValueRow &values, Operation operation, const QString ¶m_a_in, const QString ¶m_b_in, const SampleBuffer &input, SampleBuffer &output, @@ -138,4 +138,4 @@ protected: } -#endif // MATHNODEBASE_H +#endif // OAK_MATHNODEBASE_H diff --git a/app/node/math/merge/merge.cpp b/app/node/math/merge/merge.cpp index 2d49b8057..8efdabce9 100644 --- a/app/node/math/merge/merge.cpp +++ b/app/node/math/merge/merge.cpp @@ -26,23 +26,23 @@ namespace olive { -const QString MergeNode::kBaseIn = QStringLiteral("base_in"); -const QString MergeNode::kBlendIn = QStringLiteral("blend_in"); +const QString MergeNode::k_base_in = QStringLiteral("base_in"); +const QString MergeNode::k_blend_in = QStringLiteral("blend_in"); #define super Node MergeNode::MergeNode() { - AddInput(kBaseIn, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_base_in, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - AddInput(kBlendIn, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_blend_in, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); - SetFlag(kDontShowInParamView); + set_flag(k_dont_show_in_param_view); } -QString MergeNode::Name() const +QString MergeNode::name() const { return tr("Merge"); } @@ -52,49 +52,49 @@ QString MergeNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.merge"); } -QVector MergeNode::Category() const +QVector MergeNode::category() const { - return { kCategoryMath }; + return { k_category_math }; } -QString MergeNode::Description() const +QString MergeNode::description() const { return tr("Merge two textures together."); } -void MergeNode::Retranslate() +void MergeNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kBaseIn, tr("Base")); + set_input_name(k_base_in, tr("Base")); - SetInputName(kBlendIn, tr("Blend")); + set_input_name(k_blend_in, tr("Blend")); } -ShaderCode MergeNode::GetShaderCode(const ShaderRequest &request) const +ShaderCode MergeNode::get_shader_code(const ShaderRequest &request) const { Q_UNUSED(request) return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/alphaover.frag")); + FileFunctions::read_file_as_string(":/shaders/alphaover.frag")); } -void MergeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void MergeNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - TexturePtr base_tex = value[kBaseIn].toTexture(); - TexturePtr blend_tex = value[kBlendIn].toTexture(); + TexturePtr base_tex = value[k_base_in].to_texture(); + TexturePtr blend_tex = value[k_blend_in].to_texture(); if (base_tex || blend_tex) { if (!base_tex || (blend_tex && blend_tex->channel_count() < - VideoParams::kRGBAChannelCount)) { + VideoParams::k_rgba_channel_count)) { // We only have a blend texture or the blend texture is RGB only, no need to alpha over - table->Push(value[kBlendIn]); + table->push(value[k_blend_in]); } else if (!blend_tex) { // We only have a base texture, no need to alpha over - table->Push(value[kBaseIn]); + table->push(value[k_base_in]); } else { - table->Push(NodeValue::kTexture, base_tex->toJob(ShaderJob(value)), + table->push(NodeValue::k_texture, base_tex->to_job(ShaderJob(value)), this); } } diff --git a/app/node/math/merge/merge.h b/app/node/math/merge/merge.h index 09f68a7cc..50de0df65 100644 --- a/app/node/math/merge/merge.h +++ b/app/node/math/merge/merge.h @@ -19,8 +19,8 @@ ***/ -#ifndef MERGENODE_H -#define MERGENODE_H +#ifndef OAK_MERGENODE_H +#define OAK_MERGENODE_H #include "node/node.h" @@ -34,20 +34,20 @@ public: NODE_DEFAULT_FUNCTIONS(MergeNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; virtual ShaderCode - GetShaderCode(const ShaderRequest &request) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + get_shader_code(const ShaderRequest &request) const override; + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kBaseIn; - static const QString kBlendIn; + static const QString k_base_in; + static const QString k_blend_in; private: NodeInput *base_in_; @@ -57,4 +57,4 @@ private: } -#endif // MERGENODE_H +#endif // OAK_MERGENODE_H diff --git a/app/node/math/trigonometry/trigonometry.cpp b/app/node/math/trigonometry/trigonometry.cpp index 2e7d8854e..59a940556 100644 --- a/app/node/math/trigonometry/trigonometry.cpp +++ b/app/node/math/trigonometry/trigonometry.cpp @@ -24,20 +24,20 @@ namespace olive { -const QString TrigonometryNode::kMethodIn = QStringLiteral("method_in"); -const QString TrigonometryNode::kXIn = QStringLiteral("x_in"); +const QString TrigonometryNode::k_method_in = QStringLiteral("method_in"); +const QString TrigonometryNode::k_x_in = QStringLiteral("x_in"); #define super Node TrigonometryNode::TrigonometryNode() { - AddInput(kMethodIn, NodeValue::kCombo, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_method_in, NodeValue::k_combo, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - AddInput(kXIn, NodeValue::kFloat, 0.0); + add_input(k_x_in, NodeValue::k_float, 0.0); } -QString TrigonometryNode::Name() const +QString TrigonometryNode::name() const { return tr("Trigonometry"); } @@ -47,19 +47,19 @@ QString TrigonometryNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.trigonometry"); } -QVector TrigonometryNode::Category() const +QVector TrigonometryNode::category() const { - return { kCategoryMath }; + return { k_category_math }; } -QString TrigonometryNode::Description() const +QString TrigonometryNode::description() const { return tr("Perform a trigonometry operation on a value."); } -void TrigonometryNode::Retranslate() +void TrigonometryNode::retranslate() { - super::Retranslate(); + super::retranslate(); QStringList strings = { tr("Sine"), tr("Cosine"), @@ -71,50 +71,50 @@ void TrigonometryNode::Retranslate() tr("Hyperbolic Cosine"), tr("Hyperbolic Tangent") }; - SetComboBoxStrings(kMethodIn, strings); + set_combo_box_strings(k_method_in, strings); - SetInputName(kMethodIn, tr("Method")); + set_input_name(k_method_in, tr("Method")); - SetInputName(kXIn, tr("Value")); + set_input_name(k_x_in, tr("Value")); } -void TrigonometryNode::Value(const NodeValueRow &value, +void TrigonometryNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - double x = value[kXIn].toDouble(); + double x = value[k_x_in].to_double(); - switch (static_cast(GetStandardValue(kMethodIn).toInt())) { - case kOpSine: + switch (static_cast(get_standard_value(k_method_in).toInt())) { + case k_op_sine: x = std::sin(x); break; - case kOpCosine: + case k_op_cosine: x = std::cos(x); break; - case kOpTangent: + case k_op_tangent: x = std::tan(x); break; - case kOpArcSine: + case k_op_arc_sine: x = std::asin(x); break; - case kOpArcCosine: + case k_op_arc_cosine: x = std::acos(x); break; - case kOpArcTangent: + case k_op_arc_tangent: x = std::atan(x); break; - case kOpHypSine: + case k_op_hyp_sine: x = std::sinh(x); break; - case kOpHypCosine: + case k_op_hyp_cosine: x = std::cosh(x); break; - case kOpHypTangent: + case k_op_hyp_tangent: x = std::tanh(x); break; } - table->Push(NodeValue::kFloat, x, this); + table->push(NodeValue::k_float, x, this); } } diff --git a/app/node/math/trigonometry/trigonometry.h b/app/node/math/trigonometry/trigonometry.h index 6993f43fb..f1495c407 100644 --- a/app/node/math/trigonometry/trigonometry.h +++ b/app/node/math/trigonometry/trigonometry.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRIGNODE_H -#define TRIGNODE_H +#ifndef OAK_TRIGNODE_H +#define OAK_TRIGNODE_H #include "node/node.h" @@ -34,33 +34,33 @@ public: NODE_DEFAULT_FUNCTIONS(TrigonometryNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kMethodIn; - static const QString kXIn; + static const QString k_method_in; + static const QString k_x_in; private: enum Operation { - kOpSine, - kOpCosine, - kOpTangent, - kOpArcSine, - kOpArcCosine, - kOpArcTangent, - kOpHypSine, - kOpHypCosine, - kOpHypTangent + k_op_sine, + k_op_cosine, + k_op_tangent, + k_op_arc_sine, + k_op_arc_cosine, + k_op_arc_tangent, + k_op_hyp_sine, + k_op_hyp_cosine, + k_op_hyp_tangent }; }; } -#endif // TRIGNODE_H +#endif // OAK_TRIGNODE_H diff --git a/app/node/node.cpp b/app/node/node.cpp index 8056acfda..bc9f29102 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -42,28 +42,28 @@ namespace olive #define super QObject -const QString Node::kEnabledInput = QStringLiteral("enabled_in"); +const QString Node::k_enabled_input = QStringLiteral("enabled_in"); Node::Node() : override_color_(-1) , folder_(nullptr) - , flags_(kNone) + , flags_(k_none) , caches_enabled_(true) { - AddInput(kEnabledInput, NodeValue::kBoolean, true); + add_input(k_enabled_input, NodeValue::k_boolean, true); video_cache_ = new FrameHashCache(this); thumbnail_cache_ = new ThumbnailCache(this); audio_cache_ = new AudioPlaybackCache(this); waveform_cache_ = new AudioWaveformCache(this); - waveform_cache_->SetSavingEnabled(false); + waveform_cache_->set_saving_enabled(false); } Node::~Node() { // Disconnect all edges - DisconnectAll(); + disconnect_all(); // Remove self from anything while we're still a node rather than a base QObject setParent(nullptr); @@ -87,28 +87,28 @@ Project *Node::parent() const Project *Node::project() const { - return Project::GetProjectFromObject(this); + return Project::get_project_from_object(this); } -QString Node::ShortName() const +QString Node::short_name() const { - return Name(); + return name(); } -QString Node::Description() const +QString Node::description() const { // Return an empty string by default return QString(); } -void Node::Retranslate() +void Node::retranslate() { - SetInputName(kEnabledInput, tr("Enabled")); + set_input_name(k_enabled_input, tr("Enabled")); } QVariant Node::data(const DataType &d) const { - if (d == ICON) { + if (d == icon) { // Just a meaningless default icon to be used where necessary return icon::New; } @@ -116,34 +116,34 @@ QVariant Node::data(const DataType &d) const return QVariant(); } -bool Node::SetNodePositionInContext(Node *node, const QPointF &pos) +bool Node::set_node_position_in_context(Node *node, const QPointF &pos) { Position p = context_positions_.value(node); p.position = pos; - return SetNodePositionInContext(node, p); + return set_node_position_in_context(node, p); } -bool Node::SetNodePositionInContext(Node *node, const Position &pos) +bool Node::set_node_position_in_context(Node *node, const Position &pos) { - bool added = !ContextContainsNode(node); + bool added = !context_contains_node(node); context_positions_.insert(node, pos); if (added) { - emit NodeAddedToContext(node); + emit node_added_to_context(node); } - emit NodePositionInContextChanged(node, pos.position); + emit node_position_in_context_changed(node, pos.position); return added; } -bool Node::RemoveNodeFromContext(Node *node) +bool Node::remove_node_from_context(Node *node) { - if (ContextContainsNode(node)) { + if (context_contains_node(node)) { context_positions_.remove(node); - emit NodeRemovedFromContext(node); + emit node_removed_from_context(node); return true; } else { return false; @@ -157,12 +157,12 @@ Color Node::color() const if (override_color_ >= 0) { c = override_color_; } else { - c = OLIVE_CONFIG_STR( - QStringLiteral("CatColor%1").arg(this->Category().first())) + c = OAK_CONFIG_STR( + QStringLiteral("CatColor%1").arg(this->category().first())) .toInt(); } - return ColorCoding::GetColor(c); + return ColorCoding::get_color(c); } QLinearGradient Node::gradient_color(qreal top, qreal bottom) const @@ -172,7 +172,7 @@ QLinearGradient Node::gradient_color(qreal top, qreal bottom) const grad.setStart(0, top); grad.setFinalStop(0, bottom); - QColor c = QtUtils::toQColor(color()); + QColor c = QtUtils::to_q_color(color()); grad.setColorAt(0.0, c.lighter()); grad.setColorAt(1.0, c); @@ -182,14 +182,14 @@ QLinearGradient Node::gradient_color(qreal top, qreal bottom) const QBrush Node::brush(qreal top, qreal bottom) const { - if (OLIVE_CONFIG("UseGradients").toBool()) { + if (OAK_CONFIG("UseGradients").toBool()) { return gradient_color(top, bottom); } else { - return QtUtils::toQColor(color()); + return QtUtils::to_q_color(color()); } } -void Node::ConnectEdge(Node *output, const NodeInput &input) +void Node::connect_edge(Node *output, const NodeInput &input) { // Ensure graph is the same Q_ASSERT(input.node()->parent() == output->parent()); @@ -208,17 +208,17 @@ void Node::ConnectEdge(Node *output, const NodeInput &input) output->OutputConnectedEvent(input); // Emit signals - emit input.node()->InputConnected(output, input); - emit output->OutputConnected(output, input); + emit input.node()->input_connected(output, input); + emit output->output_connected(output, input); // Invalidate all if this node isn't ignoring this input - if (!(input.node()->GetInputFlags(input.input()) & - kInputFlagIgnoreInvalidations)) { - input.node()->InvalidateAll(input.input(), input.element()); + if (!(input.node()->get_input_flags(input.input()) & + k_input_flag_ignore_invalidations)) { + input.node()->invalidate_all(input.input(), input.element()); } } -void Node::DisconnectEdge(Node *output, const NodeInput &input) +void Node::disconnect_edge(Node *output, const NodeInput &input) { // Ensure graph is the same Q_ASSERT(input.node()->parent() == output->parent()); @@ -239,87 +239,87 @@ void Node::DisconnectEdge(Node *output, const NodeInput &input) output); output->OutputDisconnectedEvent(input); - emit input.node()->InputDisconnected(output, input); - emit output->OutputDisconnected(output, input); + emit input.node()->input_disconnected(output, input); + emit output->output_disconnected(output, input); - if (!(input.node()->GetInputFlags(input.input()) & - kInputFlagIgnoreInvalidations)) { - input.node()->InvalidateAll(input.input(), input.element()); + if (!(input.node()->get_input_flags(input.input()) & + k_input_flag_ignore_invalidations)) { + input.node()->invalidate_all(input.input(), input.element()); } } -void Node::CopyCacheUuidsFrom(Node *n) +void Node::copy_cache_uuids_from(Node *n) { - video_cache_->SetUuid(n->video_cache_->GetUuid()); - audio_cache_->SetUuid(n->audio_cache_->GetUuid()); - thumbnail_cache_->SetUuid(n->thumbnail_cache_->GetUuid()); - waveform_cache_->SetUuid(n->waveform_cache_->GetUuid()); + video_cache_->set_uuid(n->video_cache_->get_uuid()); + audio_cache_->set_uuid(n->audio_cache_->get_uuid()); + thumbnail_cache_->set_uuid(n->thumbnail_cache_->get_uuid()); + waveform_cache_->set_uuid(n->waveform_cache_->get_uuid()); } -QString Node::GetInputName(const QString &id) const +QString Node::get_input_name(const QString &id) const { - const Input *i = GetInternalInputData(id); + const Input *i = get_internal_input_data(id); if (i) { return i->human_name; } else { - ReportInvalidInput("get name of", id, -1); + report_invalid_input("get name of", id, -1); return QString(); } } -bool Node::IsInputHidden(const QString &input) const +bool Node::is_input_hidden(const QString &input) const { - return (GetInputFlags(input) & kInputFlagHidden); + return (get_input_flags(input) & k_input_flag_hidden); } -bool Node::IsInputConnectable(const QString &input) const +bool Node::is_input_connectable(const QString &input) const { - return !(GetInputFlags(input) & kInputFlagNotConnectable); + return !(get_input_flags(input) & k_input_flag_not_connectable); } -bool Node::IsInputKeyframable(const QString &input) const +bool Node::is_input_keyframable(const QString &input) const { - return !(GetInputFlags(input) & kInputFlagNotKeyframable); + return !(get_input_flags(input) & k_input_flag_not_keyframable); } -bool Node::IsInputKeyframing(const QString &input, int element) const +bool Node::is_input_keyframing(const QString &input, int element) const { - NodeInputImmediate *imm = GetImmediate(input, element); + NodeInputImmediate *imm = get_immediate(input, element); if (imm) { return imm->is_keyframing(); } else { - ReportInvalidInput("get keyframing state of", input, element); + report_invalid_input("get keyframing state of", input, element); return false; } } -void Node::SetInputIsKeyframing(const QString &input, bool e, int element) +void Node::set_input_is_keyframing(const QString &input, bool e, int element) { - if (!IsInputKeyframable(input)) { + if (!is_input_keyframable(input)) { qDebug() << "Ignored set keyframing of" << input << "because this input is not keyframable"; return; } - NodeInputImmediate *imm = GetImmediate(input, element); + NodeInputImmediate *imm = get_immediate(input, element); if (imm) { imm->set_is_keyframing(e); - emit KeyframeEnableChanged(NodeInput(this, input, element), e); + emit keyframe_enable_changed(NodeInput(this, input, element), e); } else { - ReportInvalidInput("set keyframing state of", input, element); + report_invalid_input("set keyframing state of", input, element); } } -bool Node::IsInputConnected(const QString &input, int element) const +bool Node::is_input_connected(const QString &input, int element) const { - return GetConnectedOutput(input, element); + return get_connected_output(input, element); } -Node *Node::GetConnectedOutput(const QString &input, int element) const +Node *Node::get_connected_output(const QString &input, int element) const { for (auto it = input_connections_.cbegin(); it != input_connections_.cend(); it++) { @@ -331,121 +331,121 @@ Node *Node::GetConnectedOutput(const QString &input, int element) const return nullptr; } -bool Node::IsUsingStandardValue(const QString &input, int track, +bool Node::is_using_standard_value(const QString &input, int track, int element) const { - NodeInputImmediate *imm = GetImmediate(input, element); + NodeInputImmediate *imm = get_immediate(input, element); if (imm) { return imm->is_using_standard_value(track); } else { - ReportInvalidInput("determine whether using standard value in", input, + report_invalid_input("determine whether using standard value in", input, element); return true; } } -NodeValue::Type Node::GetInputDataType(const QString &id) const +NodeValue::Type Node::get_input_data_type(const QString &id) const { - const Input *i = GetInternalInputData(id); + const Input *i = get_internal_input_data(id); if (i) { return i->type; } else { - ReportInvalidInput("get data type of", id, -1); - return NodeValue::kNone; + report_invalid_input("get data type of", id, -1); + return NodeValue::k_none; } } -void Node::SetInputDataType(const QString &id, const NodeValue::Type &type) +void Node::set_input_data_type(const QString &id, const NodeValue::Type &type) { - Input *input_meta = GetInternalInputData(id); + Input *input_meta = get_internal_input_data(id); if (input_meta) { input_meta->type = type; - int array_sz = InputArraySize(id); + int array_sz = input_array_size(id); for (int i = -1; i < array_sz; i++) { - GetImmediate(id, i)->set_data_type(type); + get_immediate(id, i)->set_data_type(type); } - emit InputDataTypeChanged(id, type); + emit input_data_type_changed(id, type); } else { - ReportInvalidInput("set data type of", id, -1); + report_invalid_input("set data type of", id, -1); } } -bool Node::HasInputProperty(const QString &id, const QString &name) const +bool Node::has_input_property(const QString &id, const QString &name) const { - const Input *i = GetInternalInputData(id); + const Input *i = get_internal_input_data(id); if (i) { return i->properties.contains(name); } else { - ReportInvalidInput("get property of", id, -1); + report_invalid_input("get property of", id, -1); return false; } } -QHash Node::GetInputProperties(const QString &id) const +QHash Node::get_input_properties(const QString &id) const { - const Input *i = GetInternalInputData(id); + const Input *i = get_internal_input_data(id); if (i) { return i->properties; } else { - ReportInvalidInput("get property table of", id, -1); + report_invalid_input("get property table of", id, -1); return QHash(); } } -QVariant Node::GetInputProperty(const QString &id, const QString &name) const +QVariant Node::get_input_property(const QString &id, const QString &name) const { - const Input *i = GetInternalInputData(id); + const Input *i = get_internal_input_data(id); if (i) { return i->properties.value(name); } else { - ReportInvalidInput("get property of", id, -1); + report_invalid_input("get property of", id, -1); return QVariant(); } } -void Node::SetInputProperty(const QString &id, const QString &name, +void Node::set_input_property(const QString &id, const QString &name, const QVariant &value) { - Input *i = GetInternalInputData(id); + Input *i = get_internal_input_data(id); if (i) { i->properties.insert(name, value); - emit InputPropertyChanged(id, name, value); + emit input_property_changed(id, name, value); } else { - ReportInvalidInput("set property of", id, -1); + report_invalid_input("set property of", id, -1); } } -SplitValue Node::GetSplitValueAtTime(const QString &input, const rational &time, +SplitValue Node::get_split_value_at_time(const QString &input, const Rational &time, int element) const { SplitValue vals; - int nb_tracks = GetNumberOfKeyframeTracks(input); + int nb_tracks = get_number_of_keyframe_tracks(input); for (int i = 0; i < nb_tracks; i++) { - vals.append(GetSplitValueAtTimeOnTrack(input, time, i, element)); + vals.append(get_split_value_at_time_on_track(input, time, i, element)); } return vals; } -QVariant Node::GetSplitValueAtTimeOnTrack(const QString &input, - const rational &time, int track, +QVariant Node::get_split_value_at_time_on_track(const QString &input, + const Rational &time, int track, int element) const { - if (!IsUsingStandardValue(input, track, element)) { + if (!is_using_standard_value(input, track, element)) { const NodeKeyframeTrack &key_track = - GetKeyframeTracks(input, element).at(track); + get_keyframe_tracks(input, element).at(track); if (key_track.first()->time() >= time) { // This time precedes any keyframe, so we just return the first value @@ -457,7 +457,7 @@ QVariant Node::GetSplitValueAtTimeOnTrack(const QString &input, return key_track.last()->value(); } - NodeValue::Type type = GetInputDataType(input); + NodeValue::Type type = get_input_data_type(input); // If we're here, the time must be somewhere in between the keyframes NodeKeyframe *before = nullptr, *after = nullptr; @@ -483,7 +483,7 @@ QVariant Node::GetSplitValueAtTimeOnTrack(const QString &input, if (before) { if (before->time() == time || ((!NodeValue::type_can_be_interpolated(type) || - before->type() == NodeKeyframe::kHold) && + before->type() == NodeKeyframe::k_hold) && after->time() > time)) { // Time == keyframe time, so value is precise return before->value(); @@ -496,81 +496,81 @@ QVariant Node::GetSplitValueAtTimeOnTrack(const QString &input, // We must interpolate between these keyframes double before_val, after_val, interpolated; - if (type == NodeValue::kRational) { - // Keys for rational inputs usually hold rationals, but may - // hold plain doubles, in which case we convert to rational + if (type == NodeValue::k_rational) { + // Keys for Rational inputs usually hold rationals, but may + // hold plain doubles, in which case we convert to Rational // first to preserve the value - before_val = (before->value().canConvert() ? - before->value().value() : - rational::fromDouble( + before_val = (before->value().canConvert() ? + before->value().value() : + Rational::from_double( before->value().toDouble())) - .toDouble(); - after_val = (after->value().canConvert() ? - after->value().value() : - rational::fromDouble( + .to_double(); + after_val = (after->value().canConvert() ? + after->value().value() : + Rational::from_double( after->value().toDouble())) - .toDouble(); + .to_double(); } else { before_val = before->value().toDouble(); after_val = after->value().toDouble(); } - if (before->type() == NodeKeyframe::kBezier && - after->type() == NodeKeyframe::kBezier) { + if (before->type() == NodeKeyframe::k_bezier && + after->type() == NodeKeyframe::k_bezier) { // Perform a cubic bezier with two control points - interpolated = Bezier::CubicXtoY( - time.toDouble(), - Imath::V2d(before->time().toDouble(), before_val), - Imath::V2d(before->time().toDouble() + + interpolated = Bezier::cubic_xto_y( + time.to_double(), + Imath::V2d(before->time().to_double(), before_val), + Imath::V2d(before->time().to_double() + before->valid_bezier_control_out().x(), before_val + before->valid_bezier_control_out().y()), - Imath::V2d(after->time().toDouble() + + Imath::V2d(after->time().to_double() + after->valid_bezier_control_in().x(), after_val + after->valid_bezier_control_in().y()), - Imath::V2d(after->time().toDouble(), after_val)); + Imath::V2d(after->time().to_double(), after_val)); - } else if (before->type() == NodeKeyframe::kBezier || - after->type() == NodeKeyframe::kBezier) { + } else if (before->type() == NodeKeyframe::k_bezier || + after->type() == NodeKeyframe::k_bezier) { // Perform a quadratic bezier with only one control point Imath::V2d control_point; - if (before->type() == NodeKeyframe::kBezier) { + if (before->type() == NodeKeyframe::k_bezier) { control_point.x = (before->valid_bezier_control_out().x() + - before->time().toDouble()); + before->time().to_double()); control_point.y = (before->valid_bezier_control_out().y() + before_val); } else { control_point.x = (after->valid_bezier_control_in().x() + - after->time().toDouble()); + after->time().to_double()); control_point.y = (after->valid_bezier_control_in().y() + after_val); } // Interpolate value using quadratic beziers - interpolated = Bezier::QuadraticXtoY( - time.toDouble(), - Imath::V2d(before->time().toDouble(), before_val), + interpolated = Bezier::quadratic_xto_y( + time.to_double(), + Imath::V2d(before->time().to_double(), before_val), control_point, - Imath::V2d(after->time().toDouble(), after_val)); + Imath::V2d(after->time().to_double(), after_val)); } else { // To have arrived here, the keyframes must both be linear qreal period_progress = - (time.toDouble() - before->time().toDouble()) / - (after->time().toDouble() - before->time().toDouble()); + (time.to_double() - before->time().to_double()) / + (after->time().to_double() - before->time().to_double()); interpolated = lerp(before_val, after_val, period_progress); } - if (type == NodeValue::kRational) { + if (type == NodeValue::k_rational) { return QVariant::fromValue( - rational::fromDouble(interpolated)); + Rational::from_double(interpolated)); } else { return interpolated; } @@ -580,33 +580,33 @@ QVariant Node::GetSplitValueAtTimeOnTrack(const QString &input, } } - return GetSplitStandardValueOnTrack(input, track, element); + return get_split_standard_value_on_track(input, track, element); } -QVariant Node::GetDefaultValue(const QString &input) const +QVariant Node::get_default_value(const QString &input) const { - NodeValue::Type type = GetInputDataType(input); + NodeValue::Type type = get_input_data_type(input); return NodeValue::combine_track_values_into_normal_value( - type, GetSplitDefaultValue(input)); + type, get_split_default_value(input)); } -SplitValue Node::GetSplitDefaultValue(const QString &input) const +SplitValue Node::get_split_default_value(const QString &input) const { - const Input *i = GetInternalInputData(input); + const Input *i = get_internal_input_data(input); if (i) { return i->default_value; } else { - ReportInvalidInput("retrieve default value of", input, -1); + report_invalid_input("retrieve default value of", input, -1); return SplitValue(); } } -QVariant Node::GetSplitDefaultValueOnTrack(const QString &input, +QVariant Node::get_split_default_value_on_track(const QString &input, int track) const { - SplitValue val = GetSplitDefaultValue(input); + SplitValue val = get_split_default_value(input); if (track < val.size()) { return val.at(track); } else { @@ -614,259 +614,259 @@ QVariant Node::GetSplitDefaultValueOnTrack(const QString &input, } } -void Node::SetDefaultValue(const QString &input, const QVariant &val) +void Node::set_default_value(const QString &input, const QVariant &val) { - NodeValue::Type type = GetInputDataType(input); + NodeValue::Type type = get_input_data_type(input); - SetSplitDefaultValue( + set_split_default_value( input, NodeValue::split_normal_value_into_track_values(type, val)); } -void Node::SetSplitDefaultValue(const QString &input, const SplitValue &val) +void Node::set_split_default_value(const QString &input, const SplitValue &val) { - Input *i = GetInternalInputData(input); + Input *i = get_internal_input_data(input); if (i) { i->default_value = val; } else { - ReportInvalidInput("set default value of", input, -1); + report_invalid_input("set default value of", input, -1); } } -void Node::SetSplitDefaultValueOnTrack(const QString &input, +void Node::set_split_default_value_on_track(const QString &input, const QVariant &val, int track) { - Input *i = GetInternalInputData(input); + Input *i = get_internal_input_data(input); if (i) { if (track < i->default_value.size()) { i->default_value[track] = val; } } else { - ReportInvalidInput("set default value on track of", input, -1); + report_invalid_input("set default value on track of", input, -1); } } -const QVector &Node::GetKeyframeTracks(const QString &input, +const QVector &Node::get_keyframe_tracks(const QString &input, int element) const { - return GetImmediate(input, element)->keyframe_tracks(); + return get_immediate(input, element)->keyframe_tracks(); } -QVector Node::GetKeyframesAtTime(const QString &input, - const rational &time, +QVector Node::get_keyframes_at_time(const QString &input, + const Rational &time, int element) const { - NodeInputImmediate *imm = GetImmediate(input, element); + NodeInputImmediate *imm = get_immediate(input, element); if (imm) { return imm->get_keyframe_at_time(time); } else { - ReportInvalidInput("get keyframes at time from", input, element); + report_invalid_input("get keyframes at time from", input, element); return QVector(); } } -NodeKeyframe *Node::GetKeyframeAtTimeOnTrack(const QString &input, - const rational &time, int track, +NodeKeyframe *Node::get_keyframe_at_time_on_track(const QString &input, + const Rational &time, int track, int element) const { - NodeInputImmediate *imm = GetImmediate(input, element); + NodeInputImmediate *imm = get_immediate(input, element); if (imm) { return imm->get_keyframe_at_time_on_track(time, track); } else { - ReportInvalidInput("get keyframe at time on track from", input, + report_invalid_input("get keyframe at time on track from", input, element); return nullptr; } } -NodeKeyframe::Type Node::GetBestKeyframeTypeForTimeOnTrack(const QString &input, - const rational &time, +NodeKeyframe::Type Node::get_best_keyframe_type_for_time_on_track(const QString &input, + const Rational &time, int track, int element) const { - NodeInputImmediate *imm = GetImmediate(input, element); + NodeInputImmediate *imm = get_immediate(input, element); if (imm) { return imm->get_best_keyframe_type_for_time(time, track); } else { - ReportInvalidInput("get closest keyframe before a time from", input, + report_invalid_input("get closest keyframe before a time from", input, element); - return NodeKeyframe::kDefaultType; + return NodeKeyframe::k_default_type; } } -int Node::GetNumberOfKeyframeTracks(const QString &id) const +int Node::get_number_of_keyframe_tracks(const QString &id) const { - return NodeValue::get_number_of_keyframe_tracks(GetInputDataType(id)); + return NodeValue::get_number_of_keyframe_tracks(get_input_data_type(id)); } -NodeKeyframe *Node::GetEarliestKeyframe(const QString &id, int element) const +NodeKeyframe *Node::get_earliest_keyframe(const QString &id, int element) const { - NodeInputImmediate *imm = GetImmediate(id, element); + NodeInputImmediate *imm = get_immediate(id, element); if (imm) { return imm->get_earliest_keyframe(); } else { - ReportInvalidInput("get earliest keyframe from", id, element); + report_invalid_input("get earliest keyframe from", id, element); return nullptr; } } -NodeKeyframe *Node::GetLatestKeyframe(const QString &id, int element) const +NodeKeyframe *Node::get_latest_keyframe(const QString &id, int element) const { - NodeInputImmediate *imm = GetImmediate(id, element); + NodeInputImmediate *imm = get_immediate(id, element); if (imm) { return imm->get_latest_keyframe(); } else { - ReportInvalidInput("get latest keyframe from", id, element); + report_invalid_input("get latest keyframe from", id, element); return nullptr; } } -NodeKeyframe *Node::GetClosestKeyframeBeforeTime(const QString &id, - const rational &time, +NodeKeyframe *Node::get_closest_keyframe_before_time(const QString &id, + const Rational &time, int element) const { - NodeInputImmediate *imm = GetImmediate(id, element); + NodeInputImmediate *imm = get_immediate(id, element); if (imm) { return imm->get_closest_keyframe_before_time(time); } else { - ReportInvalidInput("get closest keyframe before a time from", id, + report_invalid_input("get closest keyframe before a time from", id, element); return nullptr; } } -NodeKeyframe *Node::GetClosestKeyframeAfterTime(const QString &id, - const rational &time, +NodeKeyframe *Node::get_closest_keyframe_after_time(const QString &id, + const Rational &time, int element) const { - NodeInputImmediate *imm = GetImmediate(id, element); + NodeInputImmediate *imm = get_immediate(id, element); if (imm) { return imm->get_closest_keyframe_after_time(time); } else { - ReportInvalidInput("get closest keyframe after a time from", id, + report_invalid_input("get closest keyframe after a time from", id, element); return nullptr; } } -bool Node::HasKeyframeAtTime(const QString &id, const rational &time, +bool Node::has_keyframe_at_time(const QString &id, const Rational &time, int element) const { - NodeInputImmediate *imm = GetImmediate(id, element); + NodeInputImmediate *imm = get_immediate(id, element); if (imm) { return imm->has_keyframe_at_time(time); } else { - ReportInvalidInput("determine if it has a keyframe at a time from", id, + report_invalid_input("determine if it has a keyframe at a time from", id, element); return false; } } -QStringList Node::GetComboBoxStrings(const QString &id) const +QStringList Node::get_combo_box_strings(const QString &id) const { - return GetInputProperty(id, QStringLiteral("combo_str")).toStringList(); + return get_input_property(id, QStringLiteral("combo_str")).toStringList(); } -QVariant Node::GetStandardValue(const QString &id, int element) const +QVariant Node::get_standard_value(const QString &id, int element) const { - NodeValue::Type type = GetInputDataType(id); + NodeValue::Type type = get_input_data_type(id); return NodeValue::combine_track_values_into_normal_value( - type, GetSplitStandardValue(id, element)); + type, get_split_standard_value(id, element)); } -SplitValue Node::GetSplitStandardValue(const QString &id, int element) const +SplitValue Node::get_split_standard_value(const QString &id, int element) const { - NodeInputImmediate *imm = GetImmediate(id, element); + NodeInputImmediate *imm = get_immediate(id, element); if (imm) { return imm->get_split_standard_value(); } else { - ReportInvalidInput("get standard value of", id, element); + report_invalid_input("get standard value of", id, element); return SplitValue(); } } -QVariant Node::GetSplitStandardValueOnTrack(const QString &input, int track, +QVariant Node::get_split_standard_value_on_track(const QString &input, int track, int element) const { - NodeInputImmediate *imm = GetImmediate(input, element); + NodeInputImmediate *imm = get_immediate(input, element); if (imm) { return imm->get_split_standard_value_on_track(track); } else { - ReportInvalidInput("get standard value of", input, element); + report_invalid_input("get standard value of", input, element); return QVariant(); } } -void Node::SetStandardValue(const QString &id, const QVariant &value, +void Node::set_standard_value(const QString &id, const QVariant &value, int element) { - NodeValue::Type type = GetInputDataType(id); + NodeValue::Type type = get_input_data_type(id); - SetSplitStandardValue( + set_split_standard_value( id, NodeValue::split_normal_value_into_track_values(type, value), element); } -void Node::SetSplitStandardValue(const QString &id, const SplitValue &value, +void Node::set_split_standard_value(const QString &id, const SplitValue &value, int element) { - NodeInputImmediate *imm = GetImmediate(id, element); + NodeInputImmediate *imm = get_immediate(id, element); if (imm) { imm->set_split_standard_value(value); for (int i = 0; i < value.size(); i++) { - if (IsUsingStandardValue(id, i, element)) { + if (is_using_standard_value(id, i, element)) { // If this standard value is being used, we need to send a value changed signal - ParameterValueChanged(id, element, + parameter_value_changed(id, element, TimeRange(RATIONAL_MIN, RATIONAL_MAX)); break; } } } else { - ReportInvalidInput("set standard value of", id, element); + report_invalid_input("set standard value of", id, element); } } -void Node::SetSplitStandardValueOnTrack(const QString &id, int track, +void Node::set_split_standard_value_on_track(const QString &id, int track, const QVariant &value, int element) { - NodeInputImmediate *imm = GetImmediate(id, element); + NodeInputImmediate *imm = get_immediate(id, element); if (imm) { imm->set_standard_value_on_track(value, track); - if (IsUsingStandardValue(id, track, element)) { + if (is_using_standard_value(id, track, element)) { // If this standard value is being used, we need to send a value changed signal - ParameterValueChanged(id, element, + parameter_value_changed(id, element, TimeRange(RATIONAL_MIN, RATIONAL_MAX)); } } else { - ReportInvalidInput("set standard value of", id, element); + report_invalid_input("set standard value of", id, element); } } -bool Node::InputIsArray(const QString &id) const +bool Node::input_is_array(const QString &id) const { - return GetInputFlags(id) & kInputFlagArray; + return get_input_flags(id) & k_input_flag_array; } -void Node::InputArrayInsert(const QString &id, int index) +void Node::input_array_insert(const QString &id, int index) { // Add new input - ArrayResizeInternal(id, InputArraySize(id) + 1); + array_resize_internal(id, input_array_size(id) + 1); // Move connections down InputConnections copied_edges = input_connections(); @@ -876,23 +876,23 @@ void Node::InputArrayInsert(const QString &id, int index) NodeInput new_edge = it->first; new_edge.set_element(new_edge.element() + 1); - DisconnectEdge(it->second, it->first); - ConnectEdge(it->second, new_edge); + disconnect_edge(it->second, it->first); + connect_edge(it->second, new_edge); } } // Shift values and keyframes up one element - for (int i = InputArraySize(id) - 1; i > index; i--) { - CopyValuesOfElement(this, this, id, i - 1, i); + for (int i = input_array_size(id) - 1; i > index; i--) { + copy_values_of_element(this, this, id, i - 1, i); } // Reset value of element we just "inserted" - ClearElement(id, index); + clear_element(id, index); } -void Node::InputArrayResize(const QString &id, int size) +void Node::input_array_resize(const QString &id, int size) { - if (InputArraySize(id) == size) { + if (input_array_size(id) == size) { return; } @@ -901,68 +901,68 @@ void Node::InputArrayResize(const QString &id, int size) delete c; } -void Node::InputArrayRemove(const QString &id, int index) +void Node::input_array_remove(const QString &id, int index) { // Remove input - ArrayResizeInternal(id, InputArraySize(id) - 1); + array_resize_internal(id, input_array_size(id) - 1); // Move connections up InputConnections copied_edges = input_connections(); for (auto it = copied_edges.cbegin(); it != copied_edges.cend(); it++) { if (it->first.input() == id && it->first.element() >= index) { // Disconnect this and reconnect it one element up if it's not the element being removed - DisconnectEdge(it->second, it->first); + disconnect_edge(it->second, it->first); if (it->first.element() > index) { NodeInput new_edge = it->first; new_edge.set_element(new_edge.element() - 1); - ConnectEdge(it->second, new_edge); + connect_edge(it->second, new_edge); } } } // Shift values and keyframes down one element - int arr_sz = InputArraySize(id); + int arr_sz = input_array_size(id); for (int i = index; i < arr_sz; i++) { // Copying ArraySize()+1 is actually legal because immediates are never deleted - CopyValuesOfElement(this, this, id, i + 1, i); + copy_values_of_element(this, this, id, i + 1, i); } // Reset value of last element - ClearElement(id, arr_sz); + clear_element(id, arr_sz); } -int Node::InputArraySize(const QString &id) const +int Node::input_array_size(const QString &id) const { - const Input *i = GetInternalInputData(id); + const Input *i = get_internal_input_data(id); if (i) { return i->array_size; } else { - ReportInvalidInput("retrieve array size of", id, -1); + report_invalid_input("retrieve array size of", id, -1); return 0; } } -void Node::SetValueHintForInput(const QString &input, const ValueHint &hint, +void Node::set_value_hint_for_input(const QString &input, const ValueHint &hint, int element) { value_hints_.insert({ input, element }, hint); - emit InputValueHintChanged(NodeInput(this, input, element)); + emit input_value_hint_changed(NodeInput(this, input, element)); - InvalidateAll(input, element); + invalidate_all(input, element); } -const NodeKeyframeTrack &Node::GetTrackFromKeyframe(NodeKeyframe *key) const +const NodeKeyframeTrack &Node::get_track_from_keyframe(NodeKeyframe *key) const { - return GetImmediate(key->input(), key->element()) + return get_immediate(key->input(), key->element()) ->keyframe_tracks() .at(key->track()); } -NodeInputImmediate *Node::GetImmediate(const QString &input, int element) const +NodeInputImmediate *Node::get_immediate(const QString &input, int element) const { if (element == -1) { return standard_immediates_.value(input, nullptr); @@ -978,21 +978,21 @@ NodeInputImmediate *Node::GetImmediate(const QString &input, int element) const return nullptr; } -InputFlags Node::GetInputFlags(const QString &input) const +InputFlags Node::get_input_flags(const QString &input) const { - const Input *i = GetInternalInputData(input); + const Input *i = get_internal_input_data(input); if (i) { return i->flags; } else { - ReportInvalidInput("retrieve flags of", input, -1); - return InputFlags(kInputFlagNormal); + report_invalid_input("retrieve flags of", input, -1); + return InputFlags(k_input_flag_normal); } } -void Node::SetInputFlag(const QString &input, InputFlag f, bool on) +void Node::set_input_flag(const QString &input, InputFlag f, bool on) { - Input *i = GetInternalInputData(input); + Input *i = get_internal_input_data(input); if (i) { if (on) { @@ -1000,13 +1000,13 @@ void Node::SetInputFlag(const QString &input, InputFlag f, bool on) } else { i->flags &= ~f; } - emit InputFlagsChanged(input, i->flags); + emit input_flags_changed(input, i->flags); } else { - ReportInvalidInput("set flags of", input, -1); + report_invalid_input("set flags of", input, -1); } } -void Node::Value(const NodeValueRow &value, const NodeGlobals &globals, +void Node::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { // Do nothing @@ -1015,31 +1015,31 @@ void Node::Value(const NodeValueRow &value, const NodeGlobals &globals, Q_UNUSED(table) } -void Node::InvalidateCache(const TimeRange &range, const QString &from, +void Node::invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) { Q_UNUSED(from) Q_UNUSED(element) - if (AreCachesEnabled()) { + if (are_caches_enabled()) { if (range.in() != range.out()) { - TimeRange vr = range.Intersected(GetVideoCacheRange()); + TimeRange vr = range.intersected(get_video_cache_range()); if (vr.length() != 0) { - video_frame_cache()->Invalidate(vr); - thumbnail_cache()->Invalidate(vr); + video_frame_cache()->invalidate(vr); + thumbnail_cache()->invalidate(vr); } - TimeRange ar = range.Intersected(GetAudioCacheRange()); + TimeRange ar = range.intersected(get_audio_cache_range()); if (ar.length() != 0) { - audio_playback_cache()->Invalidate(ar); - waveform_cache()->Invalidate(ar); + audio_playback_cache()->invalidate(ar); + waveform_cache()->invalidate(ar); } } } - SendInvalidateCache(range, options); + send_invalidate_cache(range, options); } -TimeRange Node::InputTimeAdjustment(const QString &, int, +TimeRange Node::input_time_adjustment(const QString &, int, const TimeRange &input_time, bool clamp) const { @@ -1047,14 +1047,14 @@ TimeRange Node::InputTimeAdjustment(const QString &, int, return input_time; } -TimeRange Node::OutputTimeAdjustment(const QString &, int, +TimeRange Node::output_time_adjustment(const QString &, int, const TimeRange &input_time) const { // Default behavior is no time adjustment at all return input_time; } -QVector Node::CopyDependencyGraph(const QVector &nodes, +QVector Node::copy_dependency_graph(const QVector &nodes, MultiUndoCommand *command) { int nb_nodes = nodes.size(); @@ -1066,7 +1066,7 @@ QVector Node::CopyDependencyGraph(const QVector &nodes, Node *c = nodes.at(i)->copy(); // Copy the values, but NOT the connections, since we'll be connecting to our own clones later - Node::CopyInputs(nodes.at(i), c, false); + Node::copy_inputs(nodes.at(i), c, false); // Add to graph Project *graph = nodes.at(i)->parent(); @@ -1080,12 +1080,12 @@ QVector Node::CopyDependencyGraph(const QVector &nodes, copies[i] = c; } - CopyDependencyGraph(nodes, copies, command); + copy_dependency_graph(nodes, copies, command); return copies; } -void Node::CopyDependencyGraph(const QVector &src, +void Node::copy_dependency_graph(const QVector &src, const QVector &dst, MultiUndoCommand *command) { @@ -1109,13 +1109,13 @@ void Node::CopyDependencyGraph(const QVector &src, new NodeEdgeAddCommand(copied_output, copied_input)); command->add_child(new NodeSetValueHintCommand( copied_input, - src_node->GetValueHintForInput( + src_node->get_value_hint_for_input( copied_input.input(), copied_input.element()))); } else { - ConnectEdge(copied_output, copied_input); - copied_input.node()->SetValueHintForInput( + connect_edge(copied_output, copied_input); + copied_input.node()->set_value_hint_for_input( copied_input.input(), - src_node->GetValueHintForInput(copied_input.input(), + src_node->get_value_hint_for_input(copied_input.input(), copied_input.element()), copied_input.element()); } @@ -1124,7 +1124,7 @@ void Node::CopyDependencyGraph(const QVector &src, } } -Node *Node::CopyNodeAndDependencyGraphMinusItemsInternal( +Node *Node::copy_node_and_dependency_graph_minus_items_internal( QMap &created, Node *node, MultiUndoCommand *command) { // Make a new node of the same type @@ -1137,17 +1137,17 @@ Node *Node::CopyNodeAndDependencyGraphMinusItemsInternal( command->add_child(new NodeAddCommand(node->parent(), copy)); // Copy context children - const PositionMap &map = node->GetContextPositions(); + const PositionMap &map = node->get_context_positions(); for (auto it = map.cbegin(); it != map.cend(); it++) { // Add either the copy (if it exists) or the original node to the context Node *child; - if (it.key()->IsItem()) { + if (it.key()->is_item()) { child = it.key(); } else { child = created.value(it.key()); if (!child) { - child = CopyNodeAndDependencyGraphMinusItemsInternal( + child = copy_node_and_dependency_graph_minus_items_internal( created, it.key(), command); } } @@ -1159,8 +1159,8 @@ Node *Node::CopyNodeAndDependencyGraphMinusItemsInternal( if (NodeGroup *src_group = dynamic_cast(node)) { NodeGroup *dst_group = static_cast(copy); - for (auto it = src_group->GetInputPassthroughs().cbegin(); - it != src_group->GetInputPassthroughs().cend(); it++) { + for (auto it = src_group->get_input_passthroughs().cbegin(); + it != src_group->get_input_passthroughs().cend(); it++) { // This node should have been created by the context loop above NodeInput input = it->second; input.set_node(created.value(input.node())); @@ -1169,11 +1169,11 @@ Node *Node::CopyNodeAndDependencyGraphMinusItemsInternal( } command->add_child(new NodeGroupSetOutputPassthrough( - dst_group, created.value(src_group->GetOutputPassthrough()))); + dst_group, created.value(src_group->get_output_passthrough()))); } // Copy values to the clone - CopyInputs(node, copy, false, command); + copy_inputs(node, copy, false, command); // Go through input connections and copy if non-item and connect if item for (auto it = node->input_connections_.cbegin(); @@ -1182,14 +1182,14 @@ Node *Node::CopyNodeAndDependencyGraphMinusItemsInternal( Node *connected = it->second; Node *connected_copy; - if (connected->IsItem()) { + if (connected->is_item()) { // This is an item and we avoid copying those and just connect to them directly connected_copy = connected; } else { // Non-item, we want to clone this too connected_copy = created.value(connected, nullptr); if (!connected_copy) { - connected_copy = CopyNodeAndDependencyGraphMinusItemsInternal( + connected_copy = copy_node_and_dependency_graph_minus_items_internal( created, connected, command); } } @@ -1200,34 +1200,34 @@ Node *Node::CopyNodeAndDependencyGraphMinusItemsInternal( new NodeEdgeAddCommand(connected_copy, copied_input)); command->add_child(new NodeSetValueHintCommand( copied_input, - node->GetValueHintForInput(input.input(), input.element()))); + node->get_value_hint_for_input(input.input(), input.element()))); } return copy; } -Node *Node::CopyNodeAndDependencyGraphMinusItems(Node *node, +Node *Node::copy_node_and_dependency_graph_minus_items(Node *node, MultiUndoCommand *command) { QMap created; - return CopyNodeAndDependencyGraphMinusItemsInternal(created, node, command); + return copy_node_and_dependency_graph_minus_items_internal(created, node, command); } -Node *Node::CopyNodeInGraph(Node *node, MultiUndoCommand *command) +Node *Node::copy_node_in_graph(Node *node, MultiUndoCommand *command) { Node *copy; - if (OLIVE_CONFIG("SplitClipsCopyNodes").toBool()) { - copy = Node::CopyNodeAndDependencyGraphMinusItems(node, command); + if (OAK_CONFIG("SplitClipsCopyNodes").toBool()) { + copy = Node::copy_node_and_dependency_graph_minus_items(node, command); } else { copy = node->copy(); command->add_child(new NodeAddCommand(node->parent(), copy)); - CopyInputs(node, copy, true, command); + copy_inputs(node, copy, true, command); - const PositionMap &map = node->GetContextPositions(); + const PositionMap &map = node->get_context_positions(); for (auto it = map.cbegin(); it != map.cend(); it++) { // Add to the context command->add_child( @@ -1238,29 +1238,29 @@ Node *Node::CopyNodeInGraph(Node *node, MultiUndoCommand *command) return copy; } -void Node::SendInvalidateCache(const TimeRange &range, +void Node::send_invalidate_cache(const TimeRange &range, const InvalidateCacheOptions &options) { for (const OutputConnection &conn : output_connections_) { // Send clear cache signal to the Node const NodeInput &in = conn.second; - in.node()->InvalidateCache(range, in.input(), in.element(), options); + in.node()->invalidate_cache(range, in.input(), in.element(), options); } } -void Node::InvalidateAll(const QString &input, int element) +void Node::invalidate_all(const QString &input, int element) { - InvalidateCache(TimeRange(RATIONAL_MIN, RATIONAL_MAX), input, element); + invalidate_cache(TimeRange(RATIONAL_MIN, RATIONAL_MAX), input, element); } -bool Node::Link(Node *a, Node *b) +bool Node::link(Node *a, Node *b) { if (a == b || !a || !b) { return false; } - if (AreLinked(a, b)) { + if (are_linked(a, b)) { return false; } @@ -1270,15 +1270,15 @@ bool Node::Link(Node *a, Node *b) a->LinkChangeEvent(); b->LinkChangeEvent(); - emit a->LinksChanged(); - emit b->LinksChanged(); + emit a->links_changed(); + emit b->links_changed(); return true; } -bool Node::Unlink(Node *a, Node *b) +bool Node::unlink(Node *a, Node *b) { - if (!AreLinked(a, b)) { + if (!are_linked(a, b)) { return false; } @@ -1288,18 +1288,18 @@ bool Node::Unlink(Node *a, Node *b) a->LinkChangeEvent(); b->LinkChangeEvent(); - emit a->LinksChanged(); - emit b->LinksChanged(); + emit a->links_changed(); + emit b->links_changed(); return true; } -bool Node::AreLinked(Node *a, Node *b) +bool Node::are_linked(Node *a, Node *b) { return a->links_.contains(b); } -bool Node::Load(QXmlStreamReader *reader, SerializedData *data) +bool Node::load(QXmlStreamReader *reader, SerializedData *data) { uint version = 0; @@ -1315,15 +1315,15 @@ bool Node::Load(QXmlStreamReader *reader, SerializedData *data) Q_UNUSED(version) - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { - LoadInput(reader, data); + load_input(reader, data); } else if (reader->name() == QStringLiteral("label")) { - this->SetLabel(reader->readElementText()); + this->set_label(reader->readElementText()); } else if (reader->name() == QStringLiteral("color")) { - this->SetOverrideColor(reader->readElementText().toInt()); + this->set_override_color(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("links")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("link")) { data->block_links.append( { this, reader->readElementText().toULongLong() }); @@ -1332,12 +1332,12 @@ bool Node::Load(QXmlStreamReader *reader, SerializedData *data) } } } else if (reader->name() == QStringLiteral("custom")) { - if (!LoadCustom(reader, data)) { + if (!load_custom(reader, data)) { return false; } } else if (reader->name() == QStringLiteral("connections")) { // Load connections - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("connection")) { QString param_id; int ele = -1; @@ -1353,11 +1353,11 @@ bool Node::Load(QXmlStreamReader *reader, SerializedData *data) // Translate IDs renamed after older project files were // written - param_id = GetInputIDForLegacyID(param_id); + param_id = get_input_id_for_legacy_id(param_id); QString output_node_id; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("output")) { output_node_id = reader->readElementText(); } else { @@ -1373,7 +1373,7 @@ bool Node::Load(QXmlStreamReader *reader, SerializedData *data) } } } else if (reader->name() == QStringLiteral("hints")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("hint")) { QString input; int element = -1; @@ -1391,13 +1391,13 @@ bool Node::Load(QXmlStreamReader *reader, SerializedData *data) if (!vh.load(reader)) { return false; } - this->SetValueHintForInput(input, vh, element); + this->set_value_hint_for_input(input, vh, element); } else { reader->skipCurrentElement(); } } } else if (reader->name() == QStringLiteral("context")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { quintptr node_ptr = 0; @@ -1422,18 +1422,18 @@ bool Node::Load(QXmlStreamReader *reader, SerializedData *data) } } } else if (reader->name() == QStringLiteral("caches")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("audio")) { - this->audio_playback_cache()->SetUuid( + this->audio_playback_cache()->set_uuid( QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("video")) { - this->video_frame_cache()->SetUuid( + this->video_frame_cache()->set_uuid( QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("thumb")) { - this->thumbnail_cache()->SetUuid( + this->thumbnail_cache()->set_uuid( QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("waveform")) { - this->waveform_cache()->SetUuid( + this->waveform_cache()->set_uuid( QUuid::fromString(reader->readElementText())); } else { reader->skipCurrentElement(); @@ -1449,26 +1449,26 @@ bool Node::Load(QXmlStreamReader *reader, SerializedData *data) return true; } -void Node::Save(QXmlStreamWriter *writer) const +void Node::save(QXmlStreamWriter *writer) const { writer->writeAttribute(QStringLiteral("version"), QString::number(1)); writer->writeAttribute(QStringLiteral("id"), this->id()); writer->writeAttribute(QStringLiteral("ptr"), QString::number(reinterpret_cast(this))); - if (!this->GetLabel().isEmpty()) { - writer->writeTextElement(QStringLiteral("label"), this->GetLabel()); + if (!this->get_label().isEmpty()) { + writer->writeTextElement(QStringLiteral("label"), this->get_label()); } - if (this->GetOverrideColor() != -1) { + if (this->get_override_color() != -1) { writer->writeTextElement(QStringLiteral("color"), - QString::number(this->GetOverrideColor())); + QString::number(this->get_override_color())); } foreach (const QString &input, this->inputs()) { writer->writeStartElement(QStringLiteral("input")); - SaveInput(writer, input); + save_input(writer, input); writer->writeEndElement(); // input } @@ -1502,10 +1502,10 @@ void Node::Save(QXmlStreamWriter *writer) const writer->writeEndElement(); // connections } - if (!this->GetValueHints().empty()) { + if (!this->get_value_hints().empty()) { writer->writeStartElement(QStringLiteral("hints")); - for (auto it = this->GetValueHints().cbegin(); - it != this->GetValueHints().cend(); it++) { + for (auto it = this->get_value_hints().cbegin(); + it != this->get_value_hints().cend(); it++) { writer->writeStartElement(QStringLiteral("hint")); writer->writeAttribute(QStringLiteral("input"), it.key().input); @@ -1519,7 +1519,7 @@ void Node::Save(QXmlStreamWriter *writer) const writer->writeEndElement(); // hints } - const Node::PositionMap &map = this->GetContextPositions(); + const Node::PositionMap &map = this->get_context_positions(); if (!map.isEmpty()) { writer->writeStartElement(QStringLiteral("context")); @@ -1540,24 +1540,24 @@ void Node::Save(QXmlStreamWriter *writer) const writer->writeTextElement( QStringLiteral("audio"), - this->audio_playback_cache()->GetUuid().toString()); + this->audio_playback_cache()->get_uuid().toString()); writer->writeTextElement(QStringLiteral("video"), - this->video_frame_cache()->GetUuid().toString()); + this->video_frame_cache()->get_uuid().toString()); writer->writeTextElement(QStringLiteral("thumb"), - this->thumbnail_cache()->GetUuid().toString()); + this->thumbnail_cache()->get_uuid().toString()); writer->writeTextElement(QStringLiteral("waveform"), - this->waveform_cache()->GetUuid().toString()); + this->waveform_cache()->get_uuid().toString()); writer->writeEndElement(); // caches writer->writeStartElement(QStringLiteral("custom")); - SaveCustom(writer); + save_custom(writer); writer->writeEndElement(); // custom } -bool Node::LoadCustom(QXmlStreamReader *reader, SerializedData *data) +bool Node::load_custom(QXmlStreamReader *reader, SerializedData *data) { reader->skipCurrentElement(); return true; @@ -1572,17 +1572,17 @@ void Node::PostLoadEvent(SerializedData *data) for (auto jt = positions.cbegin(); jt != positions.cend(); jt++) { Node *n = data->node_ptrs.value(jt.key()); if (n) { - this->SetNodePositionInContext(n, jt.value()); + this->set_node_position_in_context(n, jt.value()); } } } -QString Node::GetInputIDForLegacyID(const QString &id) const +QString Node::get_input_id_for_legacy_id(const QString &id) const { return id; } -bool Node::LoadInput(QXmlStreamReader *reader, SerializedData *data) +bool Node::load_input(QXmlStreamReader *reader, SerializedData *data) { if (dynamic_cast(this)) { // Ignore input of group @@ -1608,18 +1608,18 @@ bool Node::LoadInput(QXmlStreamReader *reader, SerializedData *data) } // Translate IDs renamed after older project files were written - param_id = GetInputIDForLegacyID(param_id); + param_id = get_input_id_for_legacy_id(param_id); - if (!this->HasInputWithID(param_id)) { + if (!this->has_input_with_id(param_id)) { qWarning() << "Failed to load parameter that didn't exist:" << param_id; reader->skipCurrentElement(); return false; } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { // Load primary immediate - if (!LoadImmediate(reader, param_id, -1, data)) { + if (!load_immediate(reader, param_id, -1, data)) { return false; } } else if (reader->name() == QStringLiteral("subelements")) { @@ -1627,15 +1627,15 @@ bool Node::LoadInput(QXmlStreamReader *reader, SerializedData *data) XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("count")) { - this->InputArrayResize(param_id, attr.value().toInt()); + this->input_array_resize(param_id, attr.value().toInt()); } } int element_counter = 0; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("element")) { - if (!LoadImmediate(reader, param_id, element_counter, + if (!load_immediate(reader, param_id, element_counter, data)) { return false; } @@ -1653,17 +1653,17 @@ bool Node::LoadInput(QXmlStreamReader *reader, SerializedData *data) return true; } -void Node::SaveInput(QXmlStreamWriter *writer, const QString &id) const +void Node::save_input(QXmlStreamWriter *writer, const QString &id) const { writer->writeAttribute(QStringLiteral("id"), id); writer->writeStartElement(QStringLiteral("primary")); - SaveImmediate(writer, id, -1); + save_immediate(writer, id, -1); writer->writeEndElement(); // primary - int arr_sz = this->InputArraySize(id); + int arr_sz = this->input_array_size(id); if (arr_sz > 0) { writer->writeStartElement(QStringLiteral("subelements")); @@ -1674,7 +1674,7 @@ void Node::SaveInput(QXmlStreamWriter *writer, const QString &id) const for (int i = 0; i < arr_sz; i++) { writer->writeStartElement(QStringLiteral("element")); - SaveImmediate(writer, id, i); + save_immediate(writer, id, i); writer->writeEndElement(); // element } @@ -1683,46 +1683,46 @@ void Node::SaveInput(QXmlStreamWriter *writer, const QString &id) const } } -bool Node::LoadImmediate(QXmlStreamReader *reader, const QString &input, +bool Node::load_immediate(QXmlStreamReader *reader, const QString &input, int element, SerializedData *data) { - NodeValue::Type data_type = this->GetInputDataType(input); + NodeValue::Type data_type = this->get_input_data_type(input); // HACK: SubtitleParams contain the actual subtitle data, so loading/replacing it will overwrite // the valid subtitles. We hack around it by simply skipping loading subtitles, we'll see // if this ends up being an issue in the future. - if (data_type == NodeValue::kSubtitleParams) { + if (data_type == NodeValue::k_subtitle_params) { reader->skipCurrentElement(); return true; } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { // Load standard value int val_index = 0; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { QVariant value_on_track; - if (data_type == NodeValue::kVideoParams) { + if (data_type == NodeValue::k_video_params) { VideoParams vp; - vp.Load(reader); + vp.load(reader); value_on_track = QVariant::fromValue(vp); - } else if (data_type == NodeValue::kAudioParams) { + } else if (data_type == NodeValue::k_audio_params) { AudioParams ap = - TypeSerializer::LoadAudioParams(reader); + TypeSerializer::load_audio_params(reader); value_on_track = QVariant::fromValue(ap); } else { QString value_text = reader->readElementText(); if (!value_text.isEmpty()) { - value_on_track = NodeValue::StringToValue( + value_on_track = NodeValue::string_to_value( data_type, value_text, true); } } - this->SetSplitStandardValueOnTrack(input, val_index, + this->set_split_standard_value_on_track(input, val_index, value_on_track, element); val_index++; @@ -1732,15 +1732,15 @@ bool Node::LoadImmediate(QXmlStreamReader *reader, const QString &input, } } else if (reader->name() == QStringLiteral("keyframing")) { bool k = reader->readElementText().toInt(); - if (this->IsInputKeyframable(input)) { - this->SetInputIsKeyframing(input, k, element); + if (this->is_input_keyframable(input)) { + this->set_input_is_keyframing(input, k, element); } } else if (reader->name() == QStringLiteral("keyframes")) { int track = 0; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("key")) { NodeKeyframe *key = new NodeKeyframe(); key->set_input(input); @@ -1763,16 +1763,16 @@ bool Node::LoadImmediate(QXmlStreamReader *reader, const QString &input, } } } else if (reader->name() == QStringLiteral("csinput")) { - this->SetInputProperty(input, QStringLiteral("col_input"), + this->set_input_property(input, QStringLiteral("col_input"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csdisplay")) { - this->SetInputProperty(input, QStringLiteral("col_display"), + this->set_input_property(input, QStringLiteral("col_display"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csview")) { - this->SetInputProperty(input, QStringLiteral("col_view"), + this->set_input_property(input, QStringLiteral("col_view"), reader->readElementText()); } else if (reader->name() == QStringLiteral("cslook")) { - this->SetInputProperty(input, QStringLiteral("col_look"), + this->set_input_property(input, QStringLiteral("col_look"), reader->readElementText()); } else { reader->skipCurrentElement(); @@ -1782,31 +1782,31 @@ bool Node::LoadImmediate(QXmlStreamReader *reader, const QString &input, return true; } -void Node::SaveImmediate(QXmlStreamWriter *writer, const QString &input, +void Node::save_immediate(QXmlStreamWriter *writer, const QString &input, int element) const { - bool is_keyframing = this->IsInputKeyframing(input, element); + bool is_keyframing = this->is_input_keyframing(input, element); - if (this->IsInputKeyframable(input)) { + if (this->is_input_keyframable(input)) { writer->writeTextElement(QStringLiteral("keyframing"), QString::number(is_keyframing)); } - NodeValue::Type data_type = this->GetInputDataType(input); + NodeValue::Type data_type = this->get_input_data_type(input); // Write standard value writer->writeStartElement(QStringLiteral("standard")); - foreach (const QVariant &v, this->GetSplitStandardValue(input, element)) { + foreach (const QVariant &v, this->get_split_standard_value(input, element)) { writer->writeStartElement(QStringLiteral("track")); - if (data_type == NodeValue::kVideoParams) { - v.value().Save(writer); - } else if (data_type == NodeValue::kAudioParams) { - TypeSerializer::SaveAudioParams(writer, v.value()); + if (data_type == NodeValue::k_video_params) { + v.value().save(writer); + } else if (data_type == NodeValue::k_audio_params) { + TypeSerializer::save_audio_params(writer, v.value()); } else { writer->writeCharacters( - NodeValue::ValueToString(data_type, v, true)); + NodeValue::value_to_string(data_type, v, true)); } writer->writeEndElement(); // track @@ -1819,7 +1819,7 @@ void Node::SaveImmediate(QXmlStreamWriter *writer, const QString &input, writer->writeStartElement(QStringLiteral("keyframes")); for (const NodeKeyframeTrack &track : - this->GetKeyframeTracks(input, element)) { + this->get_keyframe_tracks(input, element)) { writer->writeStartElement(QStringLiteral("track")); for (NodeKeyframe *key : track) { @@ -1836,28 +1836,28 @@ void Node::SaveImmediate(QXmlStreamWriter *writer, const QString &input, writer->writeEndElement(); // keyframes } - if (data_type == NodeValue::kColor) { + if (data_type == NodeValue::k_color) { // Save color management information writer->writeTextElement( QStringLiteral("csinput"), - this->GetInputProperty(input, QStringLiteral("col_input")) + this->get_input_property(input, QStringLiteral("col_input")) .toString()); writer->writeTextElement( QStringLiteral("csdisplay"), - this->GetInputProperty(input, QStringLiteral("col_display")) + this->get_input_property(input, QStringLiteral("col_display")) .toString()); writer->writeTextElement( QStringLiteral("csview"), - this->GetInputProperty(input, QStringLiteral("col_view")) + this->get_input_property(input, QStringLiteral("col_view")) .toString()); writer->writeTextElement( QStringLiteral("cslook"), - this->GetInputProperty(input, QStringLiteral("col_look")) + this->get_input_property(input, QStringLiteral("col_look")) .toString()); } } -void Node::InsertInput(const QString &id, NodeValue::Type type, +void Node::insert_input(const QString &id, NodeValue::Type type, const QVariant &default_value, InputFlags flags, int index) { @@ -1867,7 +1867,7 @@ void Node::InsertInput(const QString &id, NodeValue::Type type, return; } - if (HasParamWithID(id)) { + if (has_param_with_id(id)) { qWarning() << "Failed to add input to node" << this->id() << "- param with ID" << id << "already exists"; return; @@ -1885,28 +1885,28 @@ void Node::InsertInput(const QString &id, NodeValue::Type type, input_data_.insert(index, i); if (!standard_immediates_.value(id, nullptr)) { - standard_immediates_.insert(id, CreateImmediate(id)); + standard_immediates_.insert(id, create_immediate(id)); } - emit InputAdded(id); + emit input_added(id); } -void Node::RemoveInput(const QString &id) +void Node::remove_input(const QString &id) { int index = input_ids_.indexOf(id); if (index == -1) { - ReportInvalidInput("remove", id, -1); + report_invalid_input("remove", id, -1); return; } input_ids_.removeAt(index); input_data_.removeAt(index); - emit InputRemoved(id); + emit input_removed(id); } -void Node::ReportInvalidInput(const char *attempted_action, const QString &id, +void Node::report_invalid_input(const char *attempted_action, const QString &id, int element) const { qWarning() @@ -1914,24 +1914,24 @@ void Node::ReportInvalidInput(const char *attempted_action, const QString &id, << element << "in node" << this->id() << "- input doesn't exist"; } -NodeInputImmediate *Node::CreateImmediate(const QString &input) +NodeInputImmediate *Node::create_immediate(const QString &input) { - const Input *i = GetInternalInputData(input); + const Input *i = get_internal_input_data(input); if (i) { return new NodeInputImmediate(i->type, i->default_value); } else { - ReportInvalidInput("create immediate", input, -1); + report_invalid_input("create immediate", input, -1); return nullptr; } } -void Node::ArrayResizeInternal(const QString &id, int size) +void Node::array_resize_internal(const QString &id, int size) { - Input *imm = GetInternalInputData(id); + Input *imm = get_internal_input_data(id); if (!imm) { - ReportInvalidInput("set array size", id, -1); + report_invalid_input("set array size", id, -1); return; } @@ -1941,7 +1941,7 @@ void Node::ArrayResizeInternal(const QString &id, int size) // Size is larger, create any immediates that don't exist QVector &subinputs = array_immediates_[id]; for (int i = subinputs.size(); i < size; i++) { - subinputs.append(CreateImmediate(id)); + subinputs.append(create_immediate(id)); } // Note that we do not delete any immediates when decreasing size since the user might still @@ -1951,31 +1951,31 @@ void Node::ArrayResizeInternal(const QString &id, int size) int old_sz = imm->array_size; imm->array_size = size; - emit InputArraySizeChanged(id, old_sz, size); - ParameterValueChanged(id, -1, TimeRange(RATIONAL_MIN, RATIONAL_MAX)); + emit input_array_size_changed(id, old_sz, size); + parameter_value_changed(id, -1, TimeRange(RATIONAL_MIN, RATIONAL_MAX)); } } -QString Node::GetConnectCommandString(Node *output, const NodeInput &input) +QString Node::get_connect_command_string(Node *output, const NodeInput &input) { return tr("Connected %1 to %2 - %3") - .arg(output->GetLabelAndName(), input.node()->GetLabelAndName(), - input.GetInputName()); + .arg(output->get_label_and_name(), input.node()->get_label_and_name(), + input.get_input_name()); } -QString Node::GetDisconnectCommandString(Node *output, const NodeInput &input) +QString Node::get_disconnect_command_string(Node *output, const NodeInput &input) { return tr("Disconnected %1 from %2 - %3") - .arg(output->GetLabelAndName(), input.node()->GetLabelAndName(), - input.GetInputName()); + .arg(output->get_label_and_name(), input.node()->get_label_and_name(), + input.get_input_name()); } -int Node::GetInternalInputArraySize(const QString &input) +int Node::get_internal_input_array_size(const QString &input) { return array_immediates_.value(input).size(); } -void FindWaysNodeArrivesHereRecursively(const Node *output, const Node *input, +void find_ways_node_arrives_here_recursively(const Node *output, const Node *input, QVector &v) { for (auto it = input->input_connections().cbegin(); @@ -1983,65 +1983,65 @@ void FindWaysNodeArrivesHereRecursively(const Node *output, const Node *input, if (it->second == output) { v.append(it->first); } else { - FindWaysNodeArrivesHereRecursively(output, it->second, v); + find_ways_node_arrives_here_recursively(output, it->second, v); } } } -QVector Node::FindWaysNodeArrivesHere(const Node *output) const +QVector Node::find_ways_node_arrives_here(const Node *output) const { QVector v; - FindWaysNodeArrivesHereRecursively(output, this, v); + find_ways_node_arrives_here_recursively(output, this, v); return v; } -void Node::SetInputName(const QString &id, const QString &name) +void Node::set_input_name(const QString &id, const QString &name) { - Input *i = GetInternalInputData(id); + Input *i = get_internal_input_data(id); if (i) { i->human_name = name; - emit InputNameChanged(id, name); + emit input_name_changed(id, name); } else { - ReportInvalidInput("set name of", id, -1); + report_invalid_input("set name of", id, -1); } } -const QString &Node::GetLabel() const +const QString &Node::get_label() const { return label_; } -void Node::SetLabel(const QString &s) +void Node::set_label(const QString &s) { if (label_ != s) { label_ = s; - emit LabelChanged(label_); + emit label_changed(label_); } } -QString Node::GetLabelAndName() const +QString Node::get_label_and_name() const { - if (GetLabel().isEmpty()) { - return Name(); + if (get_label().isEmpty()) { + return name(); } else { - return tr("%1 (%2)").arg(GetLabel(), Name()); + return tr("%1 (%2)").arg(get_label(), name()); } } -QString Node::GetLabelOrName() const +QString Node::get_label_or_name() const { - if (GetLabel().isEmpty()) { - return Name(); + if (get_label().isEmpty()) { + return name(); } - return GetLabel(); + return get_label(); } -void Node::CopyInputs(const Node *source, Node *destination, +void Node::copy_inputs(const Node *source, Node *destination, bool include_connections, MultiUndoCommand *command) { Q_ASSERT(source->id() == destination->id()); @@ -2050,41 +2050,41 @@ void Node::CopyInputs(const Node *source, Node *destination, // NOTE: This assert is to ensure that inputs in the source also exist in the destination, which // they should. If they don't and you hit this assert, check if you're handling group // passthroughs correctly. - Q_ASSERT(destination->HasInputWithID(input)); + Q_ASSERT(destination->has_input_with_id(input)); - CopyInput(source, destination, input, include_connections, true, + copy_input(source, destination, input, include_connections, true, command); } if (command) { command->add_child( - new NodeRenameCommand(destination, source->GetLabel())); + new NodeRenameCommand(destination, source->get_label())); } else { - destination->SetLabel(source->GetLabel()); + destination->set_label(source->get_label()); } if (command) { command->add_child(new NodeOverrideColorCommand( - destination, source->GetOverrideColor())); + destination, source->get_override_color())); } else { - destination->SetOverrideColor(source->GetOverrideColor()); + destination->set_override_color(source->get_override_color()); } } -void Node::CopyInput(const Node *src, Node *dst, const QString &input, +void Node::copy_input(const Node *src, Node *dst, const QString &input, bool include_connections, bool traverse_arrays, MultiUndoCommand *command) { Q_ASSERT(src->id() == dst->id()); - CopyValuesOfElement(src, dst, input, -1, command); + copy_values_of_element(src, dst, input, -1, command); // Copy array size - if (src->InputIsArray(input) && traverse_arrays) { - int src_array_sz = src->InputArraySize(input); + if (src->input_is_array(input) && traverse_arrays) { + int src_array_sz = src->input_array_size(input); for (int i = 0; i < src_array_sz; i++) { - CopyValuesOfElement(src, dst, input, i, command); + copy_values_of_element(src, dst, input, i, command); } } @@ -2104,17 +2104,17 @@ void Node::CopyInput(const Node *src, Node *dst, const QString &input, command->add_child( new NodeEdgeAddCommand(conn_output, conn_input)); } else { - ConnectEdge(conn_output, conn_input); + connect_edge(conn_output, conn_input); } } } } -void Node::CopyValuesOfElement(const Node *src, Node *dst, const QString &input, +void Node::copy_values_of_element(const Node *src, Node *dst, const QString &input, int src_element, int dst_element, MultiUndoCommand *command) { - if (dst_element >= dst->GetInternalInputArraySize(input)) { + if (dst_element >= dst->get_internal_input_array_size(input)) { qDebug() << "Ignored destination element that was out of array bounds"; return; } @@ -2122,16 +2122,16 @@ void Node::CopyValuesOfElement(const Node *src, Node *dst, const QString &input, NodeInput dst_input(dst, input, dst_element); // Copy standard value - SplitValue standard = src->GetSplitStandardValue(input, src_element); + SplitValue standard = src->get_split_standard_value(input, src_element); if (command) { command->add_child( new NodeParamSetSplitStandardValueCommand(dst_input, standard)); } else { - dst->SetSplitStandardValue(input, standard, dst_element); + dst->set_split_standard_value(input, standard, dst_element); } // Copy keyframes - if (NodeInputImmediate *immediate = dst->GetImmediate(input, dst_element)) { + if (NodeInputImmediate *immediate = dst->get_immediate(input, dst_element)) { if (command) { command->add_child( new NodeImmediateRemoveAllKeyframesCommand(immediate)); @@ -2141,7 +2141,7 @@ void Node::CopyValuesOfElement(const Node *src, Node *dst, const QString &input, } for (const NodeKeyframeTrack &track : - src->GetImmediate(input, src_element)->keyframe_tracks()) { + src->get_immediate(input, src_element)->keyframe_tracks()) { for (NodeKeyframe *key : track) { NodeKeyframe *copy = key->copy(dst_element, command ? nullptr : dst); @@ -2153,49 +2153,49 @@ void Node::CopyValuesOfElement(const Node *src, Node *dst, const QString &input, } // Copy keyframing state - if (src->IsInputKeyframable(input)) { - bool is_keying = src->IsInputKeyframing(input, src_element); + if (src->is_input_keyframable(input)) { + bool is_keying = src->is_input_keyframing(input, src_element); if (command) { command->add_child( new NodeParamSetKeyframingCommand(dst_input, is_keying)); } else { - dst->SetInputIsKeyframing(input, is_keying, dst_element); + dst->set_input_is_keyframing(input, is_keying, dst_element); } } // If this is the root of an array, copy the array size if (src_element == -1 && dst_element == -1) { - int array_sz = src->InputArraySize(input); + int array_sz = src->input_array_size(input); if (command) { command->add_child( new NodeArrayResizeCommand(dst, input, array_sz)); } else { - dst->ArrayResizeInternal(input, array_sz); + dst->array_resize_internal(input, array_sz); } } // Copy value hint - Node::ValueHint vh = src->GetValueHintForInput(input, src_element); + Node::ValueHint vh = src->get_value_hint_for_input(input, src_element); if (command) { command->add_child(new NodeSetValueHintCommand(dst_input, vh)); } else { - dst->SetValueHintForInput(input, vh, dst_element); + dst->set_value_hint_for_input(input, vh, dst_element); } } -void GetDependenciesRecursively(QVector &list, const Node *node, +void get_dependencies_recursively(QVector &list, const Node *node, bool traverse, bool exclusive_only) { for (auto it = node->input_connections().cbegin(); it != node->input_connections().cend(); it++) { Node *connected_node = it->second; - if (!exclusive_only || !connected_node->IsItem()) { + if (!exclusive_only || !connected_node->is_item()) { if (!list.contains(connected_node)) { list.append(connected_node); if (traverse) { - GetDependenciesRecursively(list, connected_node, traverse, + get_dependencies_recursively(list, connected_node, traverse, exclusive_only); } } @@ -2211,48 +2211,48 @@ void GetDependenciesRecursively(QVector &list, const Node *node, * TRUE to recursively traverse each node for a complete dependency graph. FALSE to return only the immediate * dependencies. */ -QVector Node::GetDependenciesInternal(bool traverse, +QVector Node::get_dependencies_internal(bool traverse, bool exclusive_only) const { QVector list; - GetDependenciesRecursively(list, this, traverse, exclusive_only); + get_dependencies_recursively(list, this, traverse, exclusive_only); return list; } -QVector Node::GetDependencies() const +QVector Node::get_dependencies() const { - return GetDependenciesInternal(true, false); + return get_dependencies_internal(true, false); } -QVector Node::GetExclusiveDependencies() const +QVector Node::get_exclusive_dependencies() const { - return GetDependenciesInternal(true, true); + return get_dependencies_internal(true, true); } -QVector Node::GetImmediateDependencies() const +QVector Node::get_immediate_dependencies() const { - return GetDependenciesInternal(false, false); + return get_dependencies_internal(false, false); } -ShaderCode Node::GetShaderCode(const ShaderRequest &request) const +ShaderCode Node::get_shader_code(const ShaderRequest &request) const { return ShaderCode(QString(), QString()); } -void Node::ProcessSamples(const NodeValueRow &, const SampleBuffer &, +void Node::process_samples(const NodeValueRow &, const SampleBuffer &, SampleBuffer &, int) const { } -void Node::GenerateFrame(FramePtr frame, const GenerateJob &job) const +void Node::generate_frame(FramePtr frame, const GenerateJob &job) const { Q_UNUSED(frame) Q_UNUSED(job) } -bool Node::InputsFrom(Node *n, bool recursively) const +bool Node::inputs_from(Node *n, bool recursively) const { for (auto it = input_connections_.cbegin(); it != input_connections_.cend(); it++) { @@ -2260,7 +2260,7 @@ bool Node::InputsFrom(Node *n, bool recursively) const if (connected == n) { return true; - } else if (recursively && connected->InputsFrom(n, recursively)) { + } else if (recursively && connected->inputs_from(n, recursively)) { return true; } } @@ -2268,7 +2268,7 @@ bool Node::InputsFrom(Node *n, bool recursively) const return false; } -bool Node::InputsFrom(const QString &id, bool recursively) const +bool Node::inputs_from(const QString &id, bool recursively) const { for (auto it = input_connections_.cbegin(); it != input_connections_.cend(); it++) { @@ -2276,7 +2276,7 @@ bool Node::InputsFrom(const QString &id, bool recursively) const if (connected->id() == id) { return true; - } else if (recursively && connected->InputsFrom(id, recursively)) { + } else if (recursively && connected->inputs_from(id, recursively)) { return true; } } @@ -2284,79 +2284,79 @@ bool Node::InputsFrom(const QString &id, bool recursively) const return false; } -void Node::DisconnectAll() +void Node::disconnect_all() { // Disconnect inputs (copy map since internal map will change as we disconnect) InputConnections copy = input_connections_; for (auto it = copy.cbegin(); it != copy.cend(); it++) { - DisconnectEdge(it->second, it->first); + disconnect_edge(it->second, it->first); } while (!output_connections_.empty()) { OutputConnection conn = output_connections_.back(); - DisconnectEdge(conn.first, conn.second); + disconnect_edge(conn.first, conn.second); } } -QString Node::GetCategoryName(const CategoryID &c) +QString Node::get_category_name(const CategoryID &c) { switch (c) { - case kCategoryOutput: + case k_category_output: return tr("Output"); - case kCategoryDistort: + case k_category_distort: return tr("Distort"); - case kCategoryMath: + case k_category_math: return tr("Math"); - case kCategoryKeying: + case k_category_keying: return tr("Keying"); - case kCategoryColor: + case k_category_color: return tr("Color"); - case kCategoryFilter: + case k_category_filter: return tr("Filter"); - case kCategoryTimeline: + case k_category_timeline: return tr("Timeline"); - case kCategoryGenerator: + case k_category_generator: return tr("Generator"); - case kCategoryTransition: + case k_category_transition: return tr("Transition"); - case kCategoryProject: + case k_category_project: return tr("Project"); - case kCategoryOpenFX: + case k_category_open_fx: return tr("OpenFX"); - case kCategoryTime: + case k_category_time: return tr("Time"); - case kCategoryUnknown: - case kCategoryCount: + case k_category_unknown: + case k_category_count: break; } return tr("Uncategorized"); } -TimeRange Node::TransformTimeTo(TimeRange time, Node *target, +TimeRange Node::transform_time_to(TimeRange time, Node *target, TransformTimeDirection dir, int path_index) { Node *from = this; Node *to = target; - if (dir == kTransformTowardsInput) { + if (dir == k_transform_towards_input) { std::swap(from, to); } - std::list path = FindPath(from, to, path_index); + std::list path = find_path(from, to, path_index); if (!path.empty()) { - if (dir == kTransformTowardsInput) { + if (dir == k_transform_towards_input) { for (auto it = path.crbegin(); it != path.crend(); it++) { const NodeInput &i = (*it); - time = i.node()->InputTimeAdjustment(i.input(), i.element(), + time = i.node()->input_time_adjustment(i.input(), i.element(), time, false); } } else { // Traverse in output direction for (auto it = path.cbegin(); it != path.cend(); it++) { const NodeInput &i = (*it); - time = i.node()->OutputTimeAdjustment(i.input(), i.element(), + time = i.node()->output_time_adjustment(i.input(), i.element(), time); } } @@ -2365,45 +2365,45 @@ TimeRange Node::TransformTimeTo(TimeRange time, Node *target, return time; } -void Node::ParameterValueChanged(const QString &input, int element, +void Node::parameter_value_changed(const QString &input, int element, const TimeRange &range) { InputValueChangedEvent(input, element); - emit ValueChanged(NodeInput(this, input, element), range); + emit value_changed(NodeInput(this, input, element), range); - if (GetInputFlags(input) & kInputFlagIgnoreInvalidations) { + if (get_input_flags(input) & k_input_flag_ignore_invalidations) { return; } - InvalidateCache(range, input, element); + invalidate_cache(range, input, element); } -TimeRange Node::GetRangeAffectedByKeyframe(NodeKeyframe *key) const +TimeRange Node::get_range_affected_by_keyframe(NodeKeyframe *key) const { - const NodeKeyframeTrack &key_track = GetTrackFromKeyframe(key); + const NodeKeyframeTrack &key_track = get_track_from_keyframe(key); int keyframe_index = key_track.indexOf(key); - TimeRange range = GetRangeAroundIndex(key->input(), keyframe_index, + TimeRange range = get_range_around_index(key->input(), keyframe_index, key->track(), key->element()); // If a previous key exists and it's a hold, we don't need to invalidate those frames if (key_track.size() > 1 && keyframe_index > 0 && - key_track.at(keyframe_index - 1)->type() == NodeKeyframe::kHold) { + key_track.at(keyframe_index - 1)->type() == NodeKeyframe::k_hold) { range.set_in(key->time()); } return range; } -TimeRange Node::GetRangeAroundIndex(const QString &input, int index, int track, +TimeRange Node::get_range_around_index(const QString &input, int index, int track, int element) const { - rational range_begin = RATIONAL_MIN; - rational range_end = RATIONAL_MAX; + Rational range_begin = RATIONAL_MIN; + Rational range_end = RATIONAL_MAX; const NodeKeyframeTrack &key_track = - GetImmediate(input, element)->keyframe_tracks().at(track); + get_immediate(input, element)->keyframe_tracks().at(track); if (key_track.size() > 1) { if (index > 0) { @@ -2419,15 +2419,15 @@ TimeRange Node::GetRangeAroundIndex(const QString &input, int index, int track, return TimeRange(range_begin, range_end); } -void Node::ClearElement(const QString &input, int index) +void Node::clear_element(const QString &input, int index) { - GetImmediate(input, index)->delete_all_keyframes(); + get_immediate(input, index)->delete_all_keyframes(); - if (IsInputKeyframable(input)) { - SetInputIsKeyframing(input, false, index); + if (is_input_keyframable(input)) { + set_input_is_keyframing(input, false, index); } - SetSplitStandardValue(input, GetSplitDefaultValue(input), index); + set_split_standard_value(input, get_split_default_value(input), index); } void Node::InputValueChangedEvent(const QString &input, int element) @@ -2469,39 +2469,39 @@ void Node::childEvent(QChildEvent *event) NodeInput i(this, key->input(), key->element()); if (event->type() == QEvent::ChildAdded) { - GetImmediate(key->input(), key->element())->insert_keyframe(key); + get_immediate(key->input(), key->element())->insert_keyframe(key); - connect(key, &NodeKeyframe::TimeChanged, this, - &Node::InvalidateFromKeyframeTimeChange); - connect(key, &NodeKeyframe::ValueChanged, this, - &Node::InvalidateFromKeyframeValueChange); - connect(key, &NodeKeyframe::TypeChanged, this, - &Node::InvalidateFromKeyframeTypeChanged); - connect(key, &NodeKeyframe::BezierControlInChanged, this, - &Node::InvalidateFromKeyframeBezierInChange); - connect(key, &NodeKeyframe::BezierControlOutChanged, this, - &Node::InvalidateFromKeyframeBezierOutChange); + connect(key, &NodeKeyframe::time_changed, this, + &Node::invalidate_from_keyframe_time_change); + connect(key, &NodeKeyframe::value_changed, this, + &Node::invalidate_from_keyframe_value_change); + connect(key, &NodeKeyframe::type_changed, this, + &Node::invalidate_from_keyframe_type_changed); + connect(key, &NodeKeyframe::bezier_control_in_changed, this, + &Node::invalidate_from_keyframe_bezier_in_change); + connect(key, &NodeKeyframe::bezier_control_out_changed, this, + &Node::invalidate_from_keyframe_bezier_out_change); - emit KeyframeAdded(key); - ParameterValueChanged(i, GetRangeAffectedByKeyframe(key)); + emit keyframe_added(key); + parameter_value_changed(i, get_range_affected_by_keyframe(key)); } else if (event->type() == QEvent::ChildRemoved) { - TimeRange time_affected = GetRangeAffectedByKeyframe(key); + TimeRange time_affected = get_range_affected_by_keyframe(key); - disconnect(key, &NodeKeyframe::TimeChanged, this, - &Node::InvalidateFromKeyframeTimeChange); - disconnect(key, &NodeKeyframe::ValueChanged, this, - &Node::InvalidateFromKeyframeValueChange); - disconnect(key, &NodeKeyframe::TypeChanged, this, - &Node::InvalidateFromKeyframeTypeChanged); - disconnect(key, &NodeKeyframe::BezierControlInChanged, this, - &Node::InvalidateFromKeyframeBezierInChange); - disconnect(key, &NodeKeyframe::BezierControlOutChanged, this, - &Node::InvalidateFromKeyframeBezierOutChange); + disconnect(key, &NodeKeyframe::time_changed, this, + &Node::invalidate_from_keyframe_time_change); + disconnect(key, &NodeKeyframe::value_changed, this, + &Node::invalidate_from_keyframe_value_change); + disconnect(key, &NodeKeyframe::type_changed, this, + &Node::invalidate_from_keyframe_type_changed); + disconnect(key, &NodeKeyframe::bezier_control_in_changed, this, + &Node::invalidate_from_keyframe_bezier_in_change); + disconnect(key, &NodeKeyframe::bezier_control_out_changed, this, + &Node::invalidate_from_keyframe_bezier_out_change); - emit KeyframeRemoved(key); + emit keyframe_removed(key); - GetImmediate(key->input(), key->element())->remove_keyframe(key); - ParameterValueChanged(i, time_affected); + get_immediate(key->input(), key->element())->remove_keyframe(key); + parameter_value_changed(i, time_affected); } } else if (NodeGizmo *gizmo = dynamic_cast(event->child())) { if (event->type() == QEvent::ChildAdded) { @@ -2512,43 +2512,43 @@ void Node::childEvent(QChildEvent *event) } } -void Node::InvalidateFromKeyframeBezierInChange() +void Node::invalidate_from_keyframe_bezier_in_change() { NodeKeyframe *key = static_cast(sender()); - const NodeKeyframeTrack &track = GetTrackFromKeyframe(key); + const NodeKeyframeTrack &track = get_track_from_keyframe(key); int keyframe_index = track.indexOf(key); - rational start = RATIONAL_MIN; - rational end = key->time(); + Rational start = RATIONAL_MIN; + Rational end = key->time(); if (keyframe_index > 0) { start = track.at(keyframe_index - 1)->time(); } - ParameterValueChanged(key->key_track_ref().input(), TimeRange(start, end)); + parameter_value_changed(key->key_track_ref().input(), TimeRange(start, end)); } -void Node::InvalidateFromKeyframeBezierOutChange() +void Node::invalidate_from_keyframe_bezier_out_change() { NodeKeyframe *key = static_cast(sender()); - const NodeKeyframeTrack &track = GetTrackFromKeyframe(key); + const NodeKeyframeTrack &track = get_track_from_keyframe(key); int keyframe_index = track.indexOf(key); - rational start = key->time(); - rational end = RATIONAL_MAX; + Rational start = key->time(); + Rational end = RATIONAL_MAX; if (keyframe_index < track.size() - 1) { end = track.at(keyframe_index + 1)->time(); } - ParameterValueChanged(key->key_track_ref().input(), TimeRange(start, end)); + parameter_value_changed(key->key_track_ref().input(), TimeRange(start, end)); } -void Node::InvalidateFromKeyframeTimeChange() +void Node::invalidate_from_keyframe_time_change() { NodeKeyframe *key = static_cast(sender()); - NodeInputImmediate *immediate = GetImmediate(key->input(), key->element()); - TimeRange original_range = GetRangeAffectedByKeyframe(key); + NodeInputImmediate *immediate = get_immediate(key->input(), key->element()); + TimeRange original_range = get_range_affected_by_keyframe(key); TimeRangeList invalidate_range; invalidate_range.insert(original_range); @@ -2562,31 +2562,31 @@ void Node::InvalidateFromKeyframeTimeChange() immediate->insert_keyframe(key); // Invalidate new area that the keyframe has been moved to - invalidate_range.insert(GetRangeAffectedByKeyframe(key)); + invalidate_range.insert(get_range_affected_by_keyframe(key)); } // Invalidate entire area surrounding the keyframe (either where it currently is, or where it used to be before it // was resorted in the if block above) foreach (const TimeRange &r, invalidate_range) { - ParameterValueChanged(key->key_track_ref().input(), r); + parameter_value_changed(key->key_track_ref().input(), r); } - emit KeyframeTimeChanged(key); + emit keyframe_time_changed(key); } -void Node::InvalidateFromKeyframeValueChange() +void Node::invalidate_from_keyframe_value_change() { NodeKeyframe *key = static_cast(sender()); - ParameterValueChanged(key->key_track_ref().input(), - GetRangeAffectedByKeyframe(key)); + parameter_value_changed(key->key_track_ref().input(), + get_range_affected_by_keyframe(key)); - emit KeyframeValueChanged(key); + emit keyframe_value_changed(key); } -void Node::InvalidateFromKeyframeTypeChanged() +void Node::invalidate_from_keyframe_type_changed() { NodeKeyframe *key = static_cast(sender()); - const NodeKeyframeTrack &track = GetTrackFromKeyframe(key); + const NodeKeyframeTrack &track = get_track_from_keyframe(key); if (track.size() == 1) { // If there are no other frames, the interpolation won't do anything @@ -2594,23 +2594,23 @@ void Node::InvalidateFromKeyframeTypeChanged() } // Invalidate entire range - ParameterValueChanged(key->key_track_ref().input(), - GetRangeAroundIndex(key->input(), track.indexOf(key), + parameter_value_changed(key->key_track_ref().input(), + get_range_around_index(key->input(), track.indexOf(key), key->track(), key->element())); - emit KeyframeTypeChanged(key); + emit keyframe_type_changed(key); } -void Node::SetValueAtTime(const NodeInput &input, const rational &time, +void Node::set_value_at_time(const NodeInput &input, const Rational &time, const QVariant &value, int track, MultiUndoCommand *command, bool insert_on_all_tracks_if_no_key) { - if (input.IsKeyframing()) { - rational node_time = time; + if (input.is_keyframing()) { + Rational node_time = time; NodeKeyframe *existing_key = - input.GetKeyframeAtTimeOnTrack(node_time, track); + input.get_keyframe_at_time_on_track(node_time, track); if (existing_key) { command->add_child( @@ -2618,7 +2618,7 @@ void Node::SetValueAtTime(const NodeInput &input, const rational &time, } else { // No existing key, create a new one int nb_tracks = NodeValue::get_number_of_keyframe_tracks( - input.node()->GetInputDataType(input.input())); + input.node()->get_input_data_type(input.input())); for (int i = 0; i < nb_tracks; i++) { QVariant track_value; @@ -2627,13 +2627,13 @@ void Node::SetValueAtTime(const NodeInput &input, const rational &time, } else if (!insert_on_all_tracks_if_no_key) { continue; } else { - track_value = input.node()->GetSplitValueAtTimeOnTrack( + track_value = input.node()->get_split_value_at_time_on_track( input.input(), node_time, i, input.element()); } NodeKeyframe *new_key = new NodeKeyframe( node_time, track_value, - input.node()->GetBestKeyframeTypeForTimeOnTrack( + input.node()->get_best_keyframe_type_for_time_on_track( NodeKeyframeTrackReference(input, i), node_time), i, input.element(), input.input()); @@ -2647,7 +2647,7 @@ void Node::SetValueAtTime(const NodeInput &input, const rational &time, } } -bool FindPathInternal(std::list &vec, Node *from, Node *to, +bool find_path_internal(std::list &vec, Node *from, Node *to, int &path_index) { for (auto it = from->output_connections().cbegin(); @@ -2667,7 +2667,7 @@ bool FindPathInternal(std::list &vec, Node *from, Node *to, } } - if (FindPathInternal(vec, next.node(), to, path_index)) { + if (find_path_internal(vec, next.node(), to, path_index)) { return true; } @@ -2677,11 +2677,11 @@ bool FindPathInternal(std::list &vec, Node *from, Node *to, return false; } -std::list Node::FindPath(Node *from, Node *to, int path_index) +std::list Node::find_path(Node *from, Node *to, int path_index) { std::list v; - FindPathInternal(v, from, to, path_index); + find_path_internal(v, from, to, path_index); return v; } @@ -2696,10 +2696,10 @@ bool Node::ValueHint::load(QXmlStreamReader *reader) Q_UNUSED(version) - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("types")) { QVector types; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("type")) { types.append(static_cast( reader->readElementText().toInt())); @@ -2743,7 +2743,7 @@ bool Node::Position::load(QXmlStreamReader *reader) bool got_pos_x = false; bool got_pos_y = false; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("x")) { this->position.setX(reader->readElementText().toDouble()); got_pos_x = true; diff --git a/app/node/node.h b/app/node/node.h index 697a2b0bb..1bb8a682c 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODE_H -#define NODE_H +#ifndef OAK_NODE_H +#define OAK_NODE_H #include "ofxhImageEffectAPI.h" @@ -57,7 +57,7 @@ namespace olive #define NODE_DEFAULT_DESTRUCTOR(x) \ virtual ~x() override \ { \ - DisconnectAll(); \ + disconnect_all(); \ } #define NODE_COPY_FUNCTION(x) \ @@ -88,31 +88,31 @@ class Node : public QObject { Q_OBJECT public: enum CategoryID { - kCategoryUnknown = -1, + k_category_unknown = -1, - kCategoryOutput, - kCategoryGenerator, - kCategoryMath, - kCategoryKeying, - kCategoryFilter, - kCategoryColor, - kCategoryTime, - kCategoryTimeline, - kCategoryTransition, - kCategoryDistort, - kCategoryProject, - kCategoryOpenFX, + k_category_output, + k_category_generator, + k_category_math, + k_category_keying, + k_category_filter, + k_category_color, + k_category_time, + k_category_timeline, + k_category_transition, + k_category_distort, + k_category_project, + k_category_open_fx, - kCategoryCount + k_category_count }; enum Flag { - kNone = 0, - kDontShowInParamView = 0x1, - kVideoEffect = 0x2, - kAudioEffect = 0x4, - kDontShowInCreateMenu = 0x8, - kIsItem = 0x10 + k_none = 0, + k_dont_show_in_param_view = 0x1, + k_video_effect = 0x2, + k_audio_effect = 0x4, + k_dont_show_in_create_menu = 0x8, + k_is_item = 0x10 }; struct ContextPair { @@ -139,7 +139,7 @@ public: Project *project() const; - const uint64_t &GetFlags() const + const uint64_t &get_flags() const { return flags_; } @@ -150,14 +150,14 @@ public: * This is the node's name shown to the user. This must be overridden by subclasses, and preferably run through the * translator. */ - virtual QString Name() const = 0; + virtual QString name() const = 0; /** * @brief Returns a shortened name of this node if applicable * * Defaults to returning Name() but can be overridden. */ - virtual QString ShortName() const; + virtual QString short_name() const; /** * @brief Return the unique identifier of the node @@ -176,13 +176,13 @@ public: * interpreted as an empty string category. This value should be run through a translator as its largely user * oriented. */ - virtual QVector Category() const = 0; + virtual QVector category() const = 0; /** * @brief Return a sub-category string for secondary grouping * within the primary category (e.g. "Filter" under "OpenFX"). */ - virtual QString SubCategory() const + virtual QString sub_category() const { return QString(); } @@ -193,30 +193,30 @@ public: * A short (1-2 sentence) description of what this node should do to help the user understand its purpose. This should * be run through a translator. */ - virtual QString Description() const; + virtual QString description() const; Folder *folder() const { return folder_; } - bool IsItem() const + bool is_item() const { - return flags_ & kIsItem; + return flags_ & k_is_item; } /** * @brief Function called to retranslate parameter names (should be overridden in derivatives) */ - virtual void Retranslate(); + virtual void retranslate(); enum DataType { - ICON, - DURATION, - CREATED_TIME, - MODIFIED_TIME, - FREQUENCY_RATE, - TOOLTIP + icon, + duration, + created_time, + modified_time, + frequency_rate, + tooltip }; virtual QVariant data(const DataType &d) const; @@ -226,16 +226,16 @@ public: return input_ids_; } - virtual QVector IgnoreInputsForRendering() const + virtual QVector ignore_inputs_for_rendering() const { return QVector(); } class ActiveElements { public: - enum Mode { kAllElements, kSpecified, kNoElements }; + enum Mode { k_all_elements, k_specified, k_no_elements }; - ActiveElements(Mode m = kAllElements) + ActiveElements(Mode m = k_all_elements) { mode_ = m; } @@ -252,7 +252,7 @@ public: void add(int e) { elements_.push_back(e); - mode_ = kSpecified; + mode_ = k_specified; } private: @@ -260,20 +260,20 @@ public: std::list elements_; }; - virtual ActiveElements GetActiveElementsAtTime(const QString &input, + virtual ActiveElements get_active_elements_at_time(const QString &input, const TimeRange &r) const { - return ActiveElements::kAllElements; + return ActiveElements::k_all_elements; } - bool HasInputWithID(const QString &id) const + bool has_input_with_id(const QString &id) const { return input_ids_.contains(id); } - bool HasParamWithID(const QString &id) const + bool has_param_with_id(const QString &id) const { - return HasInputWithID(id); + return has_input_with_id(id); } FrameHashCache *video_frame_cache() const @@ -296,11 +296,11 @@ public: return waveform_cache_; } - virtual TimeRange GetVideoCacheRange() const + virtual TimeRange get_video_cache_range() const { return TimeRange(); } - virtual TimeRange GetAudioCacheRange() const + virtual TimeRange get_audio_cache_range() const { return TimeRange(); } @@ -344,41 +344,41 @@ public: }; using PositionMap = QHash; - const PositionMap &GetContextPositions() const + const PositionMap &get_context_positions() const { return context_positions_; } - bool IsNodeExpandedInContext(Node *node) const + bool is_node_expanded_in_context(Node *node) const { return context_positions_.value(node).expanded; } - bool ContextContainsNode(Node *node) const + bool context_contains_node(Node *node) const { return context_positions_.contains(node); } - Position GetNodePositionDataInContext(Node *node) + Position get_node_position_data_in_context(Node *node) { return context_positions_.value(node); } - QPointF GetNodePositionInContext(Node *node) + QPointF get_node_position_in_context(Node *node) { - return GetNodePositionDataInContext(node).position; + return get_node_position_data_in_context(node).position; } - bool SetNodePositionInContext(Node *node, const QPointF &pos); + bool set_node_position_in_context(Node *node, const QPointF &pos); - bool SetNodePositionInContext(Node *node, const Position &pos); + bool set_node_position_in_context(Node *node, const Position &pos); - void SetNodeExpandedInContext(Node *node, bool e) + void set_node_expanded_in_context(Node *node, bool e) { context_positions_[node].expanded = e; } - bool RemoveNodeFromContext(Node *node); + bool remove_node_from_context(Node *node); /** * @brief Retrieve the color of this node @@ -395,7 +395,7 @@ public: */ QBrush brush(qreal top, qreal bottom) const; - int GetOverrideColor() const + int get_override_color() const { return override_color_; } @@ -403,331 +403,331 @@ public: /** * @brief Sets the override color. Set to -1 for no override color. */ - void SetOverrideColor(int index) + void set_override_color(int index) { if (override_color_ != index) { override_color_ = index; - emit ColorChanged(); + emit color_changed(); } } - static void ConnectEdge(Node *output, const NodeInput &input); + static void connect_edge(Node *output, const NodeInput &input); - static void DisconnectEdge(Node *output, const NodeInput &input); + static void disconnect_edge(Node *output, const NodeInput &input); - void CopyCacheUuidsFrom(Node *n); + void copy_cache_uuids_from(Node *n); - bool AreCachesEnabled() const + bool are_caches_enabled() const { return caches_enabled_; } - void SetCachesEnabled(bool e) + void set_caches_enabled(bool e) { caches_enabled_ = e; } - virtual QString GetInputName(const QString &id) const; + virtual QString get_input_name(const QString &id) const; - void SetInputName(const QString &id, const QString &name); + void set_input_name(const QString &id, const QString &name); - bool IsInputHidden(const QString &input) const; - bool IsInputConnectable(const QString &input) const; - bool IsInputKeyframable(const QString &input) const; + bool is_input_hidden(const QString &input) const; + bool is_input_connectable(const QString &input) const; + bool is_input_keyframable(const QString &input) const; - bool IsInputKeyframing(const QString &input, int element = -1) const; - bool IsInputKeyframing(const NodeInput &input) const + bool is_input_keyframing(const QString &input, int element = -1) const; + bool is_input_keyframing(const NodeInput &input) const { - return IsInputKeyframing(input.input(), input.element()); + return is_input_keyframing(input.input(), input.element()); } - void SetInputIsKeyframing(const QString &input, bool e, int element = -1); - void SetInputIsKeyframing(const NodeInput &input, bool e) + void set_input_is_keyframing(const QString &input, bool e, int element = -1); + void set_input_is_keyframing(const NodeInput &input, bool e) { - SetInputIsKeyframing(input.input(), e, input.element()); + set_input_is_keyframing(input.input(), e, input.element()); } - bool IsInputConnected(const QString &input, int element = -1) const; - bool IsInputConnected(const NodeInput &input) const + bool is_input_connected(const QString &input, int element = -1) const; + bool is_input_connected(const NodeInput &input) const { - return IsInputConnected(input.input(), input.element()); + return is_input_connected(input.input(), input.element()); } - virtual bool IsInputConnectedForRender(const QString &input, + virtual bool is_input_connected_for_render(const QString &input, int element = -1) const { - return IsInputConnected(input, element); + return is_input_connected(input, element); } - bool IsInputConnectedForRender(const NodeInput &input) const + bool is_input_connected_for_render(const NodeInput &input) const { - return IsInputConnectedForRender(input.input(), input.element()); + return is_input_connected_for_render(input.input(), input.element()); } - bool IsInputStatic(const QString &input, int element = -1) const + bool is_input_static(const QString &input, int element = -1) const { - return !IsInputConnected(input, element) && - !IsInputKeyframing(input, element); + return !is_input_connected(input, element) && + !is_input_keyframing(input, element); } - bool IsInputStatic(const NodeInput &input) const + bool is_input_static(const NodeInput &input) const { - return IsInputStatic(input.input(), input.element()); + return is_input_static(input.input(), input.element()); } - Node *GetConnectedOutput(const QString &input, int element = -1) const; + Node *get_connected_output(const QString &input, int element = -1) const; - Node *GetConnectedOutput(const NodeInput &input) const + Node *get_connected_output(const NodeInput &input) const { - return GetConnectedOutput(input.input(), input.element()); + return get_connected_output(input.input(), input.element()); } - virtual Node *GetConnectedRenderOutput(const QString &input, + virtual Node *get_connected_render_output(const QString &input, int element = -1) const { - return GetConnectedOutput(input, element); + return get_connected_output(input, element); } - Node *GetConnectedRenderOutput(const NodeInput &input) const + Node *get_connected_render_output(const NodeInput &input) const { - return GetConnectedRenderOutput(input.input(), input.element()); + return get_connected_render_output(input.input(), input.element()); } - bool IsUsingStandardValue(const QString &input, int track, + bool is_using_standard_value(const QString &input, int track, int element = -1) const; - NodeValue::Type GetInputDataType(const QString &id) const; - void SetInputDataType(const QString &id, const NodeValue::Type &type); + NodeValue::Type get_input_data_type(const QString &id) const; + void set_input_data_type(const QString &id, const NodeValue::Type &type); - bool HasInputProperty(const QString &id, const QString &name) const; - QHash GetInputProperties(const QString &id) const; - QVariant GetInputProperty(const QString &id, const QString &name) const; - void SetInputProperty(const QString &id, const QString &name, + bool has_input_property(const QString &id, const QString &name) const; + QHash get_input_properties(const QString &id) const; + QVariant get_input_property(const QString &id, const QString &name) const; + void set_input_property(const QString &id, const QString &name, const QVariant &value); - QVariant GetValueAtTime(const QString &input, const rational &time, + QVariant get_value_at_time(const QString &input, const Rational &time, int element = -1) const { - NodeValue::Type type = GetInputDataType(input); + NodeValue::Type type = get_input_data_type(input); return NodeValue::combine_track_values_into_normal_value( - type, GetSplitValueAtTime(input, time, element)); + type, get_split_value_at_time(input, time, element)); } - QVariant GetValueAtTime(const NodeInput &input, const rational &time) + QVariant get_value_at_time(const NodeInput &input, const Rational &time) { - return GetValueAtTime(input.input(), time, input.element()); + return get_value_at_time(input.input(), time, input.element()); } - SplitValue GetSplitValueAtTime(const QString &input, const rational &time, + SplitValue get_split_value_at_time(const QString &input, const Rational &time, int element = -1) const; - SplitValue GetSplitValueAtTime(const NodeInput &input, const rational &time) + SplitValue get_split_value_at_time(const NodeInput &input, const Rational &time) { - return GetSplitValueAtTime(input.input(), time, input.element()); + return get_split_value_at_time(input.input(), time, input.element()); } - QVariant GetSplitValueAtTimeOnTrack(const QString &input, - const rational &time, int track, + QVariant get_split_value_at_time_on_track(const QString &input, + const Rational &time, int track, int element = -1) const; - QVariant GetSplitValueAtTimeOnTrack(const NodeInput &input, - const rational &time, int track) const + QVariant get_split_value_at_time_on_track(const NodeInput &input, + const Rational &time, int track) const { - return GetSplitValueAtTimeOnTrack(input.input(), time, track, + return get_split_value_at_time_on_track(input.input(), time, track, input.element()); } - QVariant GetSplitValueAtTimeOnTrack(const NodeKeyframeTrackReference &input, - const rational &time) const + QVariant get_split_value_at_time_on_track(const NodeKeyframeTrackReference &input, + const Rational &time) const { - return GetSplitValueAtTimeOnTrack(input.input(), time, input.track()); + return get_split_value_at_time_on_track(input.input(), time, input.track()); } - QVariant GetDefaultValue(const QString &input) const; - SplitValue GetSplitDefaultValue(const QString &input) const; - QVariant GetSplitDefaultValueOnTrack(const QString &input, int track) const; + QVariant get_default_value(const QString &input) const; + SplitValue get_split_default_value(const QString &input) const; + QVariant get_split_default_value_on_track(const QString &input, int track) const; - void SetDefaultValue(const QString &input, const QVariant &val); - void SetSplitDefaultValue(const QString &input, const SplitValue &val); - void SetSplitDefaultValueOnTrack(const QString &input, const QVariant &val, + void set_default_value(const QString &input, const QVariant &val); + void set_split_default_value(const QString &input, const SplitValue &val); + void set_split_default_value_on_track(const QString &input, const QVariant &val, int track); - const QVector &GetKeyframeTracks(const QString &input, + const QVector &get_keyframe_tracks(const QString &input, int element) const; const QVector & - GetKeyframeTracks(const NodeInput &input) const + get_keyframe_tracks(const NodeInput &input) const { - return GetKeyframeTracks(input.input(), input.element()); + return get_keyframe_tracks(input.input(), input.element()); } - QVector GetKeyframesAtTime(const QString &input, - const rational &time, + QVector get_keyframes_at_time(const QString &input, + const Rational &time, int element = -1) const; - QVector GetKeyframesAtTime(const NodeInput &input, - const rational &time) const + QVector get_keyframes_at_time(const NodeInput &input, + const Rational &time) const { - return GetKeyframesAtTime(input.input(), time, input.element()); + return get_keyframes_at_time(input.input(), time, input.element()); } - NodeKeyframe *GetKeyframeAtTimeOnTrack(const QString &input, - const rational &time, int track, + NodeKeyframe *get_keyframe_at_time_on_track(const QString &input, + const Rational &time, int track, int element = -1) const; - NodeKeyframe *GetKeyframeAtTimeOnTrack(const NodeInput &input, - const rational &time, + NodeKeyframe *get_keyframe_at_time_on_track(const NodeInput &input, + const Rational &time, int track) const { - return GetKeyframeAtTimeOnTrack(input.input(), time, track, + return get_keyframe_at_time_on_track(input.input(), time, track, input.element()); } NodeKeyframe * - GetKeyframeAtTimeOnTrack(const NodeKeyframeTrackReference &input, - const rational &time) const + get_keyframe_at_time_on_track(const NodeKeyframeTrackReference &input, + const Rational &time) const { - return GetKeyframeAtTimeOnTrack(input.input(), time, input.track()); + return get_keyframe_at_time_on_track(input.input(), time, input.track()); } NodeKeyframe::Type - GetBestKeyframeTypeForTimeOnTrack(const QString &input, - const rational &time, int track, + get_best_keyframe_type_for_time_on_track(const QString &input, + const Rational &time, int track, int element = -1) const; - NodeKeyframe::Type GetBestKeyframeTypeForTimeOnTrack(const NodeInput &input, - const rational &time, + NodeKeyframe::Type get_best_keyframe_type_for_time_on_track(const NodeInput &input, + const Rational &time, int track) const { - return GetBestKeyframeTypeForTimeOnTrack(input.input(), time, track, + return get_best_keyframe_type_for_time_on_track(input.input(), time, track, input.element()); } NodeKeyframe::Type - GetBestKeyframeTypeForTimeOnTrack(const NodeKeyframeTrackReference &input, - const rational &time) const + get_best_keyframe_type_for_time_on_track(const NodeKeyframeTrackReference &input, + const Rational &time) const { - return GetBestKeyframeTypeForTimeOnTrack(input.input(), time, + return get_best_keyframe_type_for_time_on_track(input.input(), time, input.track()); } - int GetNumberOfKeyframeTracks(const QString &id) const; - int GetNumberOfKeyframeTracks(const NodeInput &id) const + int get_number_of_keyframe_tracks(const QString &id) const; + int get_number_of_keyframe_tracks(const NodeInput &id) const { - return GetNumberOfKeyframeTracks(id.input()); + return get_number_of_keyframe_tracks(id.input()); } - NodeKeyframe *GetEarliestKeyframe(const QString &id, + NodeKeyframe *get_earliest_keyframe(const QString &id, int element = -1) const; - NodeKeyframe *GetEarliestKeyframe(const NodeInput &id) const + NodeKeyframe *get_earliest_keyframe(const NodeInput &id) const { - return GetEarliestKeyframe(id.input(), id.element()); + return get_earliest_keyframe(id.input(), id.element()); } - NodeKeyframe *GetLatestKeyframe(const QString &id, int element = -1) const; - NodeKeyframe *GetLatestKeyframe(const NodeInput &id) const + NodeKeyframe *get_latest_keyframe(const QString &id, int element = -1) const; + NodeKeyframe *get_latest_keyframe(const NodeInput &id) const { - return GetLatestKeyframe(id.input(), id.element()); + return get_latest_keyframe(id.input(), id.element()); } - NodeKeyframe *GetClosestKeyframeBeforeTime(const QString &id, - const rational &time, + NodeKeyframe *get_closest_keyframe_before_time(const QString &id, + const Rational &time, int element = -1) const; - NodeKeyframe *GetClosestKeyframeBeforeTime(const NodeInput &id, - const rational &time) const + NodeKeyframe *get_closest_keyframe_before_time(const NodeInput &id, + const Rational &time) const { - return GetClosestKeyframeBeforeTime(id.input(), time, id.element()); + return get_closest_keyframe_before_time(id.input(), time, id.element()); } - NodeKeyframe *GetClosestKeyframeAfterTime(const QString &id, - const rational &time, + NodeKeyframe *get_closest_keyframe_after_time(const QString &id, + const Rational &time, int element = -1) const; - NodeKeyframe *GetClosestKeyframeAfterTime(const NodeInput &id, - const rational &time) const + NodeKeyframe *get_closest_keyframe_after_time(const NodeInput &id, + const Rational &time) const { - return GetClosestKeyframeAfterTime(id.input(), time, id.element()); + return get_closest_keyframe_after_time(id.input(), time, id.element()); } - bool HasKeyframeAtTime(const QString &id, const rational &time, + bool has_keyframe_at_time(const QString &id, const Rational &time, int element = -1) const; - bool HasKeyframeAtTime(const NodeInput &id, const rational &time) const + bool has_keyframe_at_time(const NodeInput &id, const Rational &time) const { - return HasKeyframeAtTime(id.input(), time, id.element()); + return has_keyframe_at_time(id.input(), time, id.element()); } - QStringList GetComboBoxStrings(const QString &id) const; + QStringList get_combo_box_strings(const QString &id) const; - QVariant GetStandardValue(const QString &id, int element = -1) const; - QVariant GetStandardValue(const NodeInput &id) const + QVariant get_standard_value(const QString &id, int element = -1) const; + QVariant get_standard_value(const NodeInput &id) const { - return GetStandardValue(id.input(), id.element()); + return get_standard_value(id.input(), id.element()); } - SplitValue GetSplitStandardValue(const QString &id, int element = -1) const; - SplitValue GetSplitStandardValue(const NodeInput &id) const + SplitValue get_split_standard_value(const QString &id, int element = -1) const; + SplitValue get_split_standard_value(const NodeInput &id) const { - return GetSplitStandardValue(id.input(), id.element()); + return get_split_standard_value(id.input(), id.element()); } - QVariant GetSplitStandardValueOnTrack(const QString &input, int track, + QVariant get_split_standard_value_on_track(const QString &input, int track, int element = -1) const; QVariant - GetSplitStandardValueOnTrack(const NodeKeyframeTrackReference &id) const + get_split_standard_value_on_track(const NodeKeyframeTrackReference &id) const { - return GetSplitStandardValueOnTrack(id.input().input(), id.track(), + return get_split_standard_value_on_track(id.input().input(), id.track(), id.input().element()); } - void SetStandardValue(const QString &id, const QVariant &value, + void set_standard_value(const QString &id, const QVariant &value, int element = -1); - void SetStandardValue(const NodeInput &id, const QVariant &value) + void set_standard_value(const NodeInput &id, const QVariant &value) { - SetStandardValue(id.input(), value, id.element()); + set_standard_value(id.input(), value, id.element()); } - void SetSplitStandardValue(const QString &id, const SplitValue &value, + void set_split_standard_value(const QString &id, const SplitValue &value, int element = -1); - void SetSplitStandardValue(const NodeInput &id, const SplitValue &value) + void set_split_standard_value(const NodeInput &id, const SplitValue &value) { - SetSplitStandardValue(id.input(), value, id.element()); + set_split_standard_value(id.input(), value, id.element()); } - void SetSplitStandardValueOnTrack(const QString &id, int track, + void set_split_standard_value_on_track(const QString &id, int track, const QVariant &value, int element = -1); - void SetSplitStandardValueOnTrack(const NodeKeyframeTrackReference &id, + void set_split_standard_value_on_track(const NodeKeyframeTrackReference &id, const QVariant &value) { - SetSplitStandardValueOnTrack(id.input().input(), id.track(), value, + set_split_standard_value_on_track(id.input().input(), id.track(), value, id.input().element()); } - bool InputIsArray(const QString &id) const; + bool input_is_array(const QString &id) const; - void InputArrayInsert(const QString &id, int index); - void InputArrayResize(const QString &id, int size); - void InputArrayRemove(const QString &id, int index); + void input_array_insert(const QString &id, int index); + void input_array_resize(const QString &id, int size); + void input_array_remove(const QString &id, int index); - void InputArrayAppend(const QString &id) + void input_array_append(const QString &id) { - InputArrayResize(id, InputArraySize(id) + 1); + input_array_resize(id, input_array_size(id) + 1); } - void InputArrayPrepend(const QString &id) + void input_array_prepend(const QString &id) { - InputArrayInsert(id, 0); + input_array_insert(id, 0); } - void InputArrayRemoveLast(const QString &id) + void input_array_remove_last(const QString &id) { - InputArrayResize(id, InputArraySize(id) - 1); + input_array_resize(id, input_array_size(id) - 1); } - int InputArraySize(const QString &id) const; + int input_array_size(const QString &id) const; - NodeInputImmediate *GetImmediate(const QString &input, int element) const; + NodeInputImmediate *get_immediate(const QString &input, int element) const; - NodeInput GetEffectInput() + NodeInput get_effect_input() { return effect_input_.isEmpty() ? NodeInput() : NodeInput(this, effect_input_); } - const QString &GetEffectInputID() const + const QString &get_effect_input_id() const { return effect_input_; } @@ -797,21 +797,21 @@ public: QString tag_; }; - const QMap &GetValueHints() const + const QMap &get_value_hints() const { return value_hints_; } - virtual ValueHint GetValueHintForInput(const QString &input, + virtual ValueHint get_value_hint_for_input(const QString &input, int element = -1) const { return value_hints_.value({ input, element }); } - void SetValueHintForInput(const QString &input, const ValueHint &hint, + void set_value_hint_for_input(const QString &input, const ValueHint &hint, int element = -1); - const NodeKeyframeTrack &GetTrackFromKeyframe(NodeKeyframe *key) const; + const NodeKeyframeTrack &get_track_from_keyframe(NodeKeyframe *key) const; using InputConnections = std::map; @@ -843,7 +843,7 @@ public: /** * @brief Return a list of all Nodes that this Node's inputs are connected to (does not include this Node) */ - QVector GetDependencies() const; + QVector get_dependencies() const; /** * @brief Returns a list of Nodes that this Node is dependent on, provided no other Nodes are dependent on them @@ -851,12 +851,12 @@ public: * * Similar to GetDependencies(), but excludes any Nodes that are used outside the dependency graph of this Node. */ - QVector GetExclusiveDependencies() const; + QVector get_exclusive_dependencies() const; /** * @brief Retrieve immediate dependencies (only nodes that are directly connected to the inputs of this one) */ - QVector GetImmediateDependencies() const; + QVector get_immediate_dependencies() const; struct ShaderRequest { ShaderRequest(const QString &shader_id) @@ -877,12 +877,12 @@ public: /** * @brief Generate hardware accelerated code for this Node */ - virtual ShaderCode GetShaderCode(const ShaderRequest &request) const; + virtual ShaderCode get_shader_code(const ShaderRequest &request) const; /** * @brief If Value() pushes a ShaderJob, this is the function that will process them. */ - virtual void ProcessSamples(const NodeValueRow &values, + virtual void process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const; @@ -893,17 +893,17 @@ public: * * The destination buffer. It will already be allocated and ready for writing to. */ - virtual void GenerateFrame(FramePtr frame, const GenerateJob &job) const; + virtual void generate_frame(FramePtr frame, const GenerateJob &job) const; /** * @brief Returns whether this node ever receives an input from a particular node instance */ - bool InputsFrom(Node *n, bool recursively) const; + bool inputs_from(Node *n, bool recursively) const; /** * @brief Returns whether this node ever receives an input from a node with a particular ID */ - bool InputsFrom(const QString &id, bool recursively) const; + bool inputs_from(const QString &id, bool recursively) const; /** * @brief Find inputs that `output` outputs to in order to arrive at this node @@ -911,39 +911,39 @@ public: * Traverse this node's inputs recursively looking for `output`, and return a list of * edges that `output` uses to get to `this` node. */ - QVector FindWaysNodeArrivesHere(const Node *output) const; + QVector find_ways_node_arrives_here(const Node *output) const; /** * @brief Severs all input and output connections */ - void DisconnectAll(); + void disconnect_all(); /** * @brief Get the human-readable name for any category */ - static QString GetCategoryName(const CategoryID &c); + static QString get_category_name(const CategoryID &c); enum TransformTimeDirection { - kTransformTowardsInput, - kTransformTowardsOutput + k_transform_towards_input, + k_transform_towards_output }; /** * @brief Transforms time from this node through the connections it takes to get to the specified node */ - TimeRange TransformTimeTo(TimeRange time, Node *target, + TimeRange transform_time_to(TimeRange time, Node *target, TransformTimeDirection dir, int path_index); /** * @brief Find nodes of a certain type that this Node takes inputs from */ - template QVector FindInputNodes(int maximum = 0) const; + template QVector find_input_nodes(int maximum = 0) const; /** * @brief Find nodes of a certain type that this Node takes inputs from */ template - static QVector FindInputNodesConnectedToInput(const NodeInput &input, + static QVector find_input_nodes_connected_to_input(const NodeInput &input, int maximum = 0); using InvalidateCacheOptions = QHash; @@ -958,15 +958,15 @@ public: * call this function with transformed time and relay the signal that way. */ virtual void - InvalidateCache(const TimeRange &range, const QString &from, + invalidate_cache(const TimeRange &range, const QString &from, int element = -1, InvalidateCacheOptions options = InvalidateCacheOptions()); - void InvalidateCache( + void invalidate_cache( const TimeRange &range, const NodeInput &from, const InvalidateCacheOptions &options = InvalidateCacheOptions()) { - InvalidateCache(range, from.input(), from.element(), options); + invalidate_cache(range, from.input(), from.element(), options); } /** @@ -975,14 +975,14 @@ public: * If this node modifies the `time` (i.e. a clip converting sequence time to media time), this function should be * overridden to do so. Also make sure to override OutputTimeAdjustment() to provide the inverse function. */ - virtual TimeRange InputTimeAdjustment(const QString &input, int element, + virtual TimeRange input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const; /** * @brief The inverse of InputTimeAdjustment() */ - virtual TimeRange OutputTimeAdjustment(const QString &input, int element, + virtual TimeRange output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const; /** @@ -990,38 +990,38 @@ public: * * Nodes must be of the same types (i.e. have the same ID) */ - static void CopyInputs(const Node *source, Node *destination, + static void copy_inputs(const Node *source, Node *destination, bool include_connections = true, MultiUndoCommand *command = nullptr); - static void CopyInput(const Node *src, Node *dst, const QString &input, + static void copy_input(const Node *src, Node *dst, const QString &input, bool include_connections, bool traverse_arrays, MultiUndoCommand *command); - static void CopyValuesOfElement(const Node *src, Node *dst, + static void copy_values_of_element(const Node *src, Node *dst, const QString &input, int src_element, int dst_element, MultiUndoCommand *command = nullptr); - static void CopyValuesOfElement(const Node *src, Node *dst, + static void copy_values_of_element(const Node *src, Node *dst, const QString &input, int element, MultiUndoCommand *command = nullptr) { - return CopyValuesOfElement(src, dst, input, element, element, command); + return copy_values_of_element(src, dst, input, element, element, command); } /** * @brief Clones a set of nodes and connects the new ones the way the old ones were */ - static QVector CopyDependencyGraph(const QVector &nodes, + static QVector copy_dependency_graph(const QVector &nodes, MultiUndoCommand *command); - static void CopyDependencyGraph(const QVector &src, + static void copy_dependency_graph(const QVector &src, const QVector &dst, MultiUndoCommand *command); static Node * - CopyNodeAndDependencyGraphMinusItems(Node *node, MultiUndoCommand *command); + copy_node_and_dependency_graph_minus_items(Node *node, MultiUndoCommand *command); - static Node *CopyNodeInGraph(Node *node, MultiUndoCommand *command); + static Node *copy_node_in_graph(Node *node, MultiUndoCommand *command); /** * @brief The main processing function @@ -1036,39 +1036,39 @@ public: * corresponding output if it's connected to one. If your node doesn't directly deal with time, the default behavior * of the NodeParam objects will handle everything related to it automatically. */ - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const; - bool HasGizmos() const + bool has_gizmos() const { return !gizmos_.isEmpty(); } - const QVector &GetGizmos() const + const QVector &get_gizmos() const { return gizmos_; } - virtual QTransform GizmoTransformation(const NodeValueRow &row, + virtual QTransform gizmo_transformation(const NodeValueRow &row, const NodeGlobals &globals) const { return QTransform(); } - virtual void UpdateGizmoPositions(const NodeValueRow &row, + virtual void update_gizmo_positions(const NodeValueRow &row, const NodeGlobals &globals) { } - const QString &GetLabel() const; - void SetLabel(const QString &s); + const QString &get_label() const; + void set_label(const QString &s); - QString GetLabelAndName() const; - QString GetLabelOrName() const; + QString get_label_and_name() const; + QString get_label_or_name() const; - void InvalidateAll(const QString &input, int element = -1); + void invalidate_all(const QString &input, int element = -1); - bool HasLinks() const + bool has_links() const { return !links_.isEmpty(); } @@ -1078,21 +1078,21 @@ public: return links_; } - static bool Link(Node *a, Node *b); - static bool Unlink(Node *a, Node *b); - static bool AreLinked(Node *a, Node *b); + static bool link(Node *a, Node *b); + static bool unlink(Node *a, Node *b); + static bool are_linked(Node *a, Node *b); - bool Load(QXmlStreamReader *reader, SerializedData *data); - void Save(QXmlStreamWriter *writer) const; + bool load(QXmlStreamReader *reader, SerializedData *data); + void save(QXmlStreamWriter *writer) const; - virtual bool LoadCustom(QXmlStreamReader *reader, SerializedData *data); - virtual void SaveCustom(QXmlStreamWriter *writer) const + virtual bool load_custom(QXmlStreamReader *reader, SerializedData *data); + virtual void save_custom(QXmlStreamWriter *writer) const { } virtual void PostLoadEvent(SerializedData *data); - bool LoadInput(QXmlStreamReader *reader, SerializedData *data); - void SaveInput(QXmlStreamWriter *writer, const QString &id) const; + bool load_input(QXmlStreamReader *reader, SerializedData *data); + void save_input(QXmlStreamWriter *writer, const QString &id) const; /** * @brief Maps an input ID read from an old project file to its current ID @@ -1100,20 +1100,20 @@ public: * Nodes whose input IDs have been renamed override this so old projects * keep loading. The default implementation returns the ID unchanged. */ - virtual QString GetInputIDForLegacyID(const QString &id) const; + virtual QString get_input_id_for_legacy_id(const QString &id) const; - bool LoadImmediate(QXmlStreamReader *reader, const QString &input, + bool load_immediate(QXmlStreamReader *reader, const QString &input, int element, SerializedData *data); - void SaveImmediate(QXmlStreamWriter *writer, const QString &input, + void save_immediate(QXmlStreamWriter *writer, const QString &input, int element) const; - void SetFolder(Folder *folder) + void set_folder(Folder *folder) { folder_ = folder; } - InputFlags GetInputFlags(const QString &input) const; - void SetInputFlag(const QString &input, InputFlag f, bool on = true); + InputFlags get_input_flags(const QString &input) const; + void set_input_flag(const QString &input, InputFlag f, bool on = true); virtual void LoadFinishedEvent() { @@ -1122,7 +1122,7 @@ public: { } - static void SetValueAtTime(const NodeInput &input, const rational &time, + static void set_value_at_time(const NodeInput &input, const Rational &time, const QVariant &value, int track, MultiUndoCommand *command, bool insert_on_all_tracks_if_no_key); @@ -1130,9 +1130,9 @@ public: /** * @brief Find path starting at `from` that outputs to arrive at `to` */ - static std::list FindPath(Node *from, Node *to, int path_index); + static std::list find_path(Node *from, Node *to, int path_index); - void ArrayResizeInternal(const QString &id, int size); + void array_resize_internal(const QString &id, int size); virtual void AddedToGraphEvent(Project *p) { @@ -1141,12 +1141,12 @@ public: { } - static QString GetConnectCommandString(Node *output, + static QString get_connect_command_string(Node *output, const NodeInput &input); - static QString GetDisconnectCommandString(Node *output, + static QString get_disconnect_command_string(Node *output, const NodeInput &input); - static const QString kEnabledInput; + static const QString k_enabled_input; OFX::Host::ImageEffect::Instance *getPluginInstance() const { @@ -1166,56 +1166,56 @@ protected: plugin_instance_ = instance; } - void InsertInput(const QString &id, NodeValue::Type type, + void insert_input(const QString &id, NodeValue::Type type, const QVariant &default_value, InputFlags flags, int index); - void PrependInput(const QString &id, NodeValue::Type type, + void prepend_input(const QString &id, NodeValue::Type type, const QVariant &default_value, - InputFlags flags = InputFlags(kInputFlagNormal)) + InputFlags flags = InputFlags(k_input_flag_normal)) { - InsertInput(id, type, default_value, flags, 0); + insert_input(id, type, default_value, flags, 0); } - void PrependInput(const QString &id, NodeValue::Type type, - InputFlags flags = InputFlags(kInputFlagNormal)) + void prepend_input(const QString &id, NodeValue::Type type, + InputFlags flags = InputFlags(k_input_flag_normal)) { - PrependInput(id, type, QVariant(), flags); + prepend_input(id, type, QVariant(), flags); } - void AddInput(const QString &id, NodeValue::Type type, + void add_input(const QString &id, NodeValue::Type type, const QVariant &default_value, - InputFlags flags = InputFlags(kInputFlagNormal)) + InputFlags flags = InputFlags(k_input_flag_normal)) { - InsertInput(id, type, default_value, flags, input_ids_.size()); + insert_input(id, type, default_value, flags, input_ids_.size()); } - void AddInput(const QString &id, NodeValue::Type type, - InputFlags flags = InputFlags(kInputFlagNormal)) + void add_input(const QString &id, NodeValue::Type type, + InputFlags flags = InputFlags(k_input_flag_normal)) { - AddInput(id, type, QVariant(), flags); + add_input(id, type, QVariant(), flags); } - void RemoveInput(const QString &id); + void remove_input(const QString &id); - void SetComboBoxStrings(const QString &id, const QStringList &strings) + void set_combo_box_strings(const QString &id, const QStringList &strings) { - SetInputProperty(id, QStringLiteral("combo_str"), strings); + set_input_property(id, QStringLiteral("combo_str"), strings); } - void SendInvalidateCache(const TimeRange &range, + void send_invalidate_cache(const TimeRange &range, const InvalidateCacheOptions &options); enum GizmoScaleHandles { - kGizmoScaleTopLeft, - kGizmoScaleTopCenter, - kGizmoScaleTopRight, - kGizmoScaleBottomLeft, - kGizmoScaleBottomCenter, - kGizmoScaleBottomRight, - kGizmoScaleCenterLeft, - kGizmoScaleCenterRight, - kGizmoScaleCount, + k_gizmo_scale_top_left, + k_gizmo_scale_top_center, + k_gizmo_scale_top_right, + k_gizmo_scale_bottom_left, + k_gizmo_scale_bottom_center, + k_gizmo_scale_bottom_right, + k_gizmo_scale_center_left, + k_gizmo_scale_center_right, + k_gizmo_scale_count, }; virtual void LinkChangeEvent() @@ -1236,12 +1236,12 @@ protected: virtual void childEvent(QChildEvent *event) override; - void SetEffectInput(const QString &input) + void set_effect_input(const QString &input) { effect_input_ = input; } - void SetFlag(Flag f, bool on = true) + void set_flag(Flag f, bool on = true) { if (on) { flags_ |= f; @@ -1251,42 +1251,42 @@ protected: } template - T *AddDraggableGizmo(const QVector &inputs = + T *add_draggable_gizmo(const QVector &inputs = QVector(), DraggableGizmo::DragValueBehavior behavior = - DraggableGizmo::kDeltaFromStart) + DraggableGizmo::k_delta_from_start) { T *gizmo = new T(this); - gizmo->SetDragValueBehavior(behavior); + gizmo->set_drag_value_behavior(behavior); foreach (const NodeKeyframeTrackReference &input, inputs) { - gizmo->AddInput(input); + gizmo->add_input(input); } - connect(gizmo, &DraggableGizmo::HandleStart, this, - &Node::GizmoDragStart); - connect(gizmo, &DraggableGizmo::HandleMovement, this, - &Node::GizmoDragMove); + connect(gizmo, &DraggableGizmo::handle_start, this, + &Node::gizmo_drag_start); + connect(gizmo, &DraggableGizmo::handle_movement, this, + &Node::gizmo_drag_move); return gizmo; } template - T *AddDraggableGizmo(const QStringList &inputs, + T *add_draggable_gizmo(const QStringList &inputs, DraggableGizmo::DragValueBehavior behavior = - DraggableGizmo::kDeltaFromStart) + DraggableGizmo::k_delta_from_start) { QVector refs(inputs.size()); for (int i = 0; i < refs.size(); i++) { refs[i] = NodeInput(this, inputs[i]); } - return AddDraggableGizmo(refs, behavior); + return add_draggable_gizmo(refs, behavior); } protected slots: - virtual void GizmoDragStart(const olive::NodeValueRow &row, double x, - double y, const olive::core::rational &time) + virtual void gizmo_drag_start(const olive::NodeValueRow &row, double x, + double y, const olive::core::Rational &time) { } - virtual void GizmoDragMove(double x, double y, + virtual void gizmo_drag_move(double x, double y, const Qt::KeyboardModifiers &modifiers) { } @@ -1295,63 +1295,63 @@ signals: /** * @brief Signal emitted when SetLabel() is called */ - void LabelChanged(const QString &s); + void label_changed(const QString &s); - void ColorChanged(); + void color_changed(); - void ValueChanged(const NodeInput &input, const TimeRange &range); + void value_changed(const NodeInput &input, const TimeRange &range); - void InputConnected(Node *output, const NodeInput &input); + void input_connected(Node *output, const NodeInput &input); - void InputDisconnected(Node *output, const NodeInput &input); + void input_disconnected(Node *output, const NodeInput &input); - void OutputConnected(Node *output, const NodeInput &input); + void output_connected(Node *output, const NodeInput &input); - void OutputDisconnected(Node *output, const NodeInput &input); + void output_disconnected(Node *output, const NodeInput &input); - void InputValueHintChanged(const NodeInput &input); + void input_value_hint_changed(const NodeInput &input); - void InputPropertyChanged(const QString &input, const QString &key, + void input_property_changed(const QString &input, const QString &key, const QVariant &value); - void LinksChanged(); + void links_changed(); - void InputArraySizeChanged(const QString &input, int old_size, + void input_array_size_changed(const QString &input, int old_size, int new_size); - void KeyframeAdded(NodeKeyframe *key); + void keyframe_added(NodeKeyframe *key); - void KeyframeRemoved(NodeKeyframe *key); + void keyframe_removed(NodeKeyframe *key); - void KeyframeTimeChanged(NodeKeyframe *key); + void keyframe_time_changed(NodeKeyframe *key); - void MessageCountChanged(); + void message_count_changed(); - void KeyframeTypeChanged(NodeKeyframe *key); + void keyframe_type_changed(NodeKeyframe *key); - void KeyframeValueChanged(NodeKeyframe *key); + void keyframe_value_changed(NodeKeyframe *key); - void KeyframeEnableChanged(const NodeInput &input, bool enabled); + void keyframe_enable_changed(const NodeInput &input, bool enabled); - void InputAdded(const QString &id); + void input_added(const QString &id); - void InputRemoved(const QString &id); + void input_removed(const QString &id); - void InputNameChanged(const QString &id, const QString &name); + void input_name_changed(const QString &id, const QString &name); - void InputDataTypeChanged(const QString &id, NodeValue::Type type); + void input_data_type_changed(const QString &id, NodeValue::Type type); - void AddedToGraph(Project *graph); + void added_to_graph(Project *graph); - void RemovedFromGraph(Project *graph); + void removed_from_graph(Project *graph); - void NodeAddedToContext(Node *node); + void node_added_to_context(Node *node); - void NodePositionInContextChanged(Node *node, const QPointF &pos); + void node_position_in_context_changed(Node *node, const QPointF &pos); - void NodeRemovedFromContext(Node *node); + void node_removed_from_context(Node *node); - void InputFlagsChanged(const QString &input, const InputFlags &flags); + void input_flags_changed(const QString &input, const InputFlags &flags); private: struct Input { @@ -1363,16 +1363,16 @@ private: int array_size; }; - NodeInputImmediate *CreateImmediate(const QString &input); + NodeInputImmediate *create_immediate(const QString &input); - int GetInternalInputIndex(const QString &input) const + int get_internal_input_index(const QString &input) const { return input_ids_.indexOf(input); } - Input *GetInternalInputData(const QString &input) + Input *get_internal_input_data(const QString &input) { - int i = GetInternalInputIndex(input); + int i = get_internal_input_index(input); if (i == -1) { return nullptr; @@ -1381,9 +1381,9 @@ private: } } - const Input *GetInternalInputData(const QString &input) const + const Input *get_internal_input_data(const QString &input) const { - int i = GetInternalInputIndex(input); + int i = get_internal_input_index(input); if (i == -1) { return nullptr; @@ -1392,52 +1392,52 @@ private: } } - void ReportInvalidInput(const char *attempted_action, const QString &id, + void report_invalid_input(const char *attempted_action, const QString &id, int element) const; - static Node *CopyNodeAndDependencyGraphMinusItemsInternal( + static Node *copy_node_and_dependency_graph_minus_items_internal( QMap &created, Node *node, MultiUndoCommand *command); /** * @brief Immediates aren't deleted, so the actual array size may be larger than ArraySize() */ - int GetInternalInputArraySize(const QString &input); + int get_internal_input_array_size(const QString &input); /** * @brief Find nodes of a certain type that this Node takes inputs from */ template - static void FindInputNodesConnectedToInputInternal(const NodeInput &input, + static void find_input_nodes_connected_to_input_internal(const NodeInput &input, QVector &list, int maximum); template - static void FindInputNodeInternal(const Node *n, QVector &list, + static void find_input_node_internal(const Node *n, QVector &list, int maximum); - QVector GetDependenciesInternal(bool traverse, + QVector get_dependencies_internal(bool traverse, bool exclusive_only) const; - void ParameterValueChanged(const QString &input, int element, + void parameter_value_changed(const QString &input, int element, const olive::core::TimeRange &range); - void ParameterValueChanged(const NodeInput &input, + void parameter_value_changed(const NodeInput &input, const olive::core::TimeRange &range) { - ParameterValueChanged(input.input(), input.element(), range); + parameter_value_changed(input.input(), input.element(), range); } /** * @brief Intelligently determine how what time range is affected by a keyframe */ - TimeRange GetRangeAffectedByKeyframe(NodeKeyframe *key) const; + TimeRange get_range_affected_by_keyframe(NodeKeyframe *key) const; /** * @brief Gets a time range between the previous and next keyframes of index */ - TimeRange GetRangeAroundIndex(const QString &input, int index, int track, + TimeRange get_range_around_index(const QString &input, int index, int track, int element) const; - void ClearElement(const QString &input, int index); + void clear_element(const QString &input, int index); /** * @brief Custom user label for node @@ -1489,35 +1489,35 @@ private slots: /** * @brief Slot when a keyframe's time changes to keep the keyframes correctly sorted by time */ - void InvalidateFromKeyframeTimeChange(); + void invalidate_from_keyframe_time_change(); /** * @brief Slot when a keyframe's value changes to signal that the cache needs updating */ - void InvalidateFromKeyframeValueChange(); + void invalidate_from_keyframe_value_change(); /** * @brief Slot when a keyframe's type changes to signal that the cache needs updating */ - void InvalidateFromKeyframeTypeChanged(); + void invalidate_from_keyframe_type_changed(); /** * @brief Slot when a keyframe's bezier in value changes to signal that the cache needs updating */ - void InvalidateFromKeyframeBezierInChange(); + void invalidate_from_keyframe_bezier_in_change(); /** * @brief Slot when a keyframe's bezier out value changes to signal that the cache needs updating */ - void InvalidateFromKeyframeBezierOutChange(); + void invalidate_from_keyframe_bezier_out_change(); }; template -void Node::FindInputNodesConnectedToInputInternal(const NodeInput &input, +void Node::find_input_nodes_connected_to_input_internal(const NodeInput &input, QVector &list, int maximum) { - Node *edge = input.GetConnectedOutput(); + Node *edge = input.get_connected_output(); if (!edge) { return; } @@ -1531,34 +1531,34 @@ void Node::FindInputNodesConnectedToInputInternal(const NodeInput &input, } } - FindInputNodeInternal(edge, list, maximum); + find_input_node_internal(edge, list, maximum); } template -QVector Node::FindInputNodesConnectedToInput(const NodeInput &input, +QVector Node::find_input_nodes_connected_to_input(const NodeInput &input, int maximum) { QVector list; - FindInputNodesConnectedToInputInternal(input, list, maximum); + find_input_nodes_connected_to_input_internal(input, list, maximum); return list; } template -void Node::FindInputNodeInternal(const Node *n, QVector &list, int maximum) +void Node::find_input_node_internal(const Node *n, QVector &list, int maximum) { for (auto it = n->input_connections_.cbegin(); it != n->input_connections_.cend(); it++) { - FindInputNodesConnectedToInputInternal(it->first, list, maximum); + find_input_nodes_connected_to_input_internal(it->first, list, maximum); } } -template QVector Node::FindInputNodes(int maximum) const +template QVector Node::find_input_nodes(int maximum) const { QVector list; - FindInputNodeInternal(this, list, maximum); + find_input_node_internal(this, list, maximum); return list; } @@ -1567,4 +1567,4 @@ template QVector Node::FindInputNodes(int maximum) const Q_DECLARE_METATYPE(olive::Node::ValueHint) -#endif // NODE_H +#endif // OAK_NODE_H diff --git a/app/node/nodeundo.cpp b/app/node/nodeundo.cpp index 0eef74d56..2f482c6ca 100644 --- a/app/node/nodeundo.cpp +++ b/app/node/nodeundo.cpp @@ -26,38 +26,38 @@ namespace olive void NodeSetPositionCommand::redo() { - added_ = !context_->ContextContainsNode(node_); + added_ = !context_->context_contains_node(node_); if (!added_) { - old_pos_ = context_->GetNodePositionDataInContext(node_); + old_pos_ = context_->get_node_position_data_in_context(node_); } - context_->SetNodePositionInContext(node_, pos_); + context_->set_node_position_in_context(node_, pos_); } void NodeSetPositionCommand::undo() { if (added_) { - context_->RemoveNodeFromContext(node_); + context_->remove_node_from_context(node_); } else { - context_->SetNodePositionInContext(node_, old_pos_); + context_->set_node_position_in_context(node_, old_pos_); } } void NodeRemovePositionFromContextCommand::redo() { - contained_ = context_->ContextContainsNode(node_); + contained_ = context_->context_contains_node(node_); if (contained_) { - old_pos_ = context_->GetNodePositionDataInContext(node_); - context_->RemoveNodeFromContext(node_); + old_pos_ = context_->get_node_position_data_in_context(node_); + context_->remove_node_from_context(node_); } } void NodeRemovePositionFromContextCommand::undo() { if (contained_) { - context_->SetNodePositionInContext(node_, old_pos_); + context_->set_node_position_in_context(node_, old_pos_); } } @@ -66,10 +66,10 @@ void NodeRemovePositionFromAllContextsCommand::redo() Project *graph = node_->parent(); foreach (Node *context, graph->nodes()) { - if (context->ContextContainsNode(node_)) { + if (context->context_contains_node(node_)) { contexts_.insert( - { context, context->GetNodePositionInContext(node_) }); - context->RemoveNodeFromContext(node_); + { context, context->get_node_position_in_context(node_) }); + context->remove_node_from_context(node_); } } } @@ -77,7 +77,7 @@ void NodeRemovePositionFromAllContextsCommand::redo() void NodeRemovePositionFromAllContextsCommand::undo() { for (auto it = contexts_.crbegin(); it != contexts_.crend(); it++) { - it->first->SetNodePositionInContext(node_, it->second); + it->first->set_node_position_in_context(node_, it->second); } contexts_.clear(); @@ -87,7 +87,7 @@ void NodeSetPositionAndDependenciesRecursivelyCommand::prepare() { move_recursively( node_, - pos_.position - context_->GetNodePositionDataInContext(node_).position); + pos_.position - context_->get_node_position_data_in_context(node_).position); } void NodeSetPositionAndDependenciesRecursivelyCommand::redo() @@ -107,14 +107,14 @@ void NodeSetPositionAndDependenciesRecursivelyCommand::undo() void NodeSetPositionAndDependenciesRecursivelyCommand::move_recursively( Node *node, const QPointF &diff) { - Node::Position pos = context_->GetNodePositionDataInContext(node); + Node::Position pos = context_->get_node_position_data_in_context(node); pos += diff; commands_.append(new NodeSetPositionCommand(node, context_, pos)); for (auto it = node->input_connections().cbegin(); it != node->input_connections().cend(); it++) { Node *output = it->second; - if (context_->ContextContainsNode(output)) { + if (context_->context_contains_node(output)) { move_recursively(output, diff); } } @@ -134,28 +134,28 @@ NodeEdgeAddCommand::~NodeEdgeAddCommand() void NodeEdgeAddCommand::redo() { - if (input_.IsConnected()) { + if (input_.is_connected()) { if (!remove_command_) { remove_command_ = - new NodeEdgeRemoveCommand(input_.GetConnectedOutput(), input_); + new NodeEdgeRemoveCommand(input_.get_connected_output(), input_); } remove_command_->redo_now(); } - Node::ConnectEdge(output_, input_); + Node::connect_edge(output_, input_); } void NodeEdgeAddCommand::undo() { - Node::DisconnectEdge(output_, input_); + Node::disconnect_edge(output_, input_); if (remove_command_) { remove_command_->undo_now(); } } -Project *NodeEdgeAddCommand::GetRelevantProject() const +Project *NodeEdgeAddCommand::get_relevant_project() const { return output_->project(); } @@ -169,15 +169,15 @@ NodeEdgeRemoveCommand::NodeEdgeRemoveCommand(Node *output, void NodeEdgeRemoveCommand::redo() { - Node::DisconnectEdge(output_, input_); + Node::disconnect_edge(output_, input_); } void NodeEdgeRemoveCommand::undo() { - Node::ConnectEdge(output_, input_); + Node::connect_edge(output_, input_); } -Project *NodeEdgeRemoveCommand::GetRelevantProject() const +Project *NodeEdgeRemoveCommand::get_relevant_project() const { return output_->project(); } @@ -190,7 +190,7 @@ NodeAddCommand::NodeAddCommand(Project *graph, Node *node) node_->setParent(&memory_manager_); } -void NodeAddCommand::PushToThread(QThread *thread) +void NodeAddCommand::push_to_thread(QThread *thread) { memory_manager_.moveToThread(thread); } @@ -205,7 +205,7 @@ void NodeAddCommand::undo() node_->setParent(&memory_manager_); } -Project *NodeAddCommand::GetRelevantProject() const +Project *NodeAddCommand::get_relevant_project() const { return graph_; } @@ -215,7 +215,7 @@ void NodeRemoveAndDisconnectCommand::prepare() command_ = new MultiUndoCommand(); // If this is a block, remove all links - if (node_->HasLinks()) { + if (node_->has_links()) { command_->add_child(new NodeUnlinkAllCommand(node_)); } @@ -232,28 +232,28 @@ void NodeRemoveAndDisconnectCommand::prepare() command_->add_child(new NodeRemovePositionFromAllContextsCommand(node_)); } -void NodeRenameCommand::AddNode(Node *node, const QString &new_name) +void NodeRenameCommand::add_node(Node *node, const QString &new_name) { nodes_.append(node); new_labels_.append(new_name); - old_labels_.append(node->GetLabel()); + old_labels_.append(node->get_label()); } void NodeRenameCommand::redo() { for (int i = 0; i < nodes_.size(); i++) { - nodes_.at(i)->SetLabel(new_labels_.at(i)); + nodes_.at(i)->set_label(new_labels_.at(i)); } } void NodeRenameCommand::undo() { for (int i = 0; i < nodes_.size(); i++) { - nodes_.at(i)->SetLabel(old_labels_.at(i)); + nodes_.at(i)->set_label(old_labels_.at(i)); } } -Project *NodeRenameCommand::GetRelevantProject() const +Project *NodeRenameCommand::get_relevant_project() const { return nodes_.isEmpty() ? nullptr : nodes_.first()->project(); } @@ -264,29 +264,29 @@ NodeOverrideColorCommand::NodeOverrideColorCommand(Node *node, int index) { } -Project *NodeOverrideColorCommand::GetRelevantProject() const +Project *NodeOverrideColorCommand::get_relevant_project() const { return node_->project(); } void NodeOverrideColorCommand::redo() { - old_index_ = node_->GetOverrideColor(); - node_->SetOverrideColor(new_index_); + old_index_ = node_->get_override_color(); + node_->set_override_color(new_index_); } void NodeOverrideColorCommand::undo() { - node_->SetOverrideColor(old_index_); + node_->set_override_color(old_index_); } NodeViewDeleteCommand::NodeViewDeleteCommand() { } -void NodeViewDeleteCommand::AddNode(Node *node, Node *context) +void NodeViewDeleteCommand::add_node(Node *node, Node *context) { - if (ContainsNode(node, context)) { + if (contains_node(node, context)) { return; } @@ -295,20 +295,20 @@ void NodeViewDeleteCommand::AddNode(Node *node, Node *context) for (auto it = node->input_connections().cbegin(); it != node->input_connections().cend(); it++) { - if (context->ContextContainsNode(it->second)) { - AddEdge(it->second, it->first); + if (context->context_contains_node(it->second)) { + add_edge(it->second, it->first); } } for (auto it = node->output_connections().cbegin(); it != node->output_connections().cend(); it++) { - if (context->ContextContainsNode(it->second.node())) { - AddEdge(it->first, it->second); + if (context->context_contains_node(it->second.node())) { + add_edge(it->first, it->second); } } } -void NodeViewDeleteCommand::AddEdge(Node *output, const NodeInput &input) +void NodeViewDeleteCommand::add_edge(Node *output, const NodeInput &input) { foreach (const Node::OutputConnection &edge, edges_) { if (edge.first == output && edge.second == input) { @@ -319,7 +319,7 @@ void NodeViewDeleteCommand::AddEdge(Node *output, const NodeInput &input) edges_.append({ output, input }); } -bool NodeViewDeleteCommand::ContainsNode(Node *node, Node *context) +bool NodeViewDeleteCommand::contains_node(Node *node, Node *context) { foreach (const Node::ContextPair &pair, nodes_) { if (pair.node == node && pair.context == context) { @@ -330,7 +330,7 @@ bool NodeViewDeleteCommand::ContainsNode(Node *node, Node *context) return false; } -Project *NodeViewDeleteCommand::GetRelevantProject() const +Project *NodeViewDeleteCommand::get_relevant_project() const { if (!nodes_.isEmpty()) { return nodes_.first().node->project(); @@ -346,7 +346,7 @@ Project *NodeViewDeleteCommand::GetRelevantProject() const void NodeViewDeleteCommand::redo() { foreach (const Node::OutputConnection &edge, edges_) { - Node::DisconnectEdge(edge.first, edge.second); + Node::disconnect_edge(edge.first, edge.second); } foreach (const Node::ContextPair &pair, nodes_) { @@ -354,12 +354,12 @@ void NodeViewDeleteCommand::redo() rn.node = pair.node; rn.context = pair.context; - rn.pos = rn.context->GetNodePositionInContext(rn.node); + rn.pos = rn.context->get_node_position_in_context(rn.node); - rn.context->RemoveNodeFromContext(rn.node); + rn.context->remove_node_from_context(rn.node); // If node is no longer in any contexts and is not connected to anything, remove it - if (rn.node->parent()->GetNumberOfContextsNodeIsIn(rn.node, true) == + if (rn.node->parent()->get_number_of_contexts_node_is_in(rn.node, true) == 0 && rn.node->input_connections().empty() && rn.node->output_connections().empty()) { @@ -381,12 +381,12 @@ void NodeViewDeleteCommand::undo() rn->node->setParent(rn->removed_from_graph); } - rn->context->SetNodePositionInContext(rn->node, rn->pos); + rn->context->set_node_position_in_context(rn->node, rn->pos); } removed_nodes_.clear(); for (auto edge = edges_.crbegin(); edge != edges_.crend(); edge++) { - Node::ConnectEdge(edge->first, edge->second); + Node::connect_edge(edge->first, edge->second); } } @@ -397,20 +397,20 @@ NodeParamSetKeyframingCommand::NodeParamSetKeyframingCommand( { } -Project *NodeParamSetKeyframingCommand::GetRelevantProject() const +Project *NodeParamSetKeyframingCommand::get_relevant_project() const { return input_.node()->project(); } void NodeParamSetKeyframingCommand::redo() { - old_setting_ = input_.IsKeyframing(); - input_.node()->SetInputIsKeyframing(input_, new_setting_); + old_setting_ = input_.is_keyframing(); + input_.node()->set_input_is_keyframing(input_, new_setting_); } void NodeParamSetKeyframingCommand::undo() { - input_.node()->SetInputIsKeyframing(input_, old_setting_); + input_.node()->set_input_is_keyframing(input_, old_setting_); } NodeParamSetKeyframeValueCommand::NodeParamSetKeyframeValueCommand( @@ -429,7 +429,7 @@ NodeParamSetKeyframeValueCommand::NodeParamSetKeyframeValueCommand( { } -Project *NodeParamSetKeyframeValueCommand::GetRelevantProject() const +Project *NodeParamSetKeyframeValueCommand::get_relevant_project() const { return key_->parent()->project(); } @@ -453,7 +453,7 @@ NodeParamInsertKeyframeCommand::NodeParamInsertKeyframeCommand( undo(); } -Project *NodeParamInsertKeyframeCommand::GetRelevantProject() const +Project *NodeParamInsertKeyframeCommand::get_relevant_project() const { return input_->project(); } @@ -475,7 +475,7 @@ NodeParamRemoveKeyframeCommand::NodeParamRemoveKeyframeCommand( { } -Project *NodeParamRemoveKeyframeCommand::GetRelevantProject() const +Project *NodeParamRemoveKeyframeCommand::get_relevant_project() const { return input_->project(); } @@ -492,7 +492,7 @@ void NodeParamRemoveKeyframeCommand::undo() } NodeParamSetKeyframeTimeCommand::NodeParamSetKeyframeTimeCommand( - NodeKeyframe *key, const rational &time) + NodeKeyframe *key, const Rational &time) : key_(key) , old_time_(key->time()) , new_time_(time) @@ -500,14 +500,14 @@ NodeParamSetKeyframeTimeCommand::NodeParamSetKeyframeTimeCommand( } NodeParamSetKeyframeTimeCommand::NodeParamSetKeyframeTimeCommand( - NodeKeyframe *key, const rational &new_time, const rational &old_time) + NodeKeyframe *key, const Rational &new_time, const Rational &old_time) : key_(key) , old_time_(old_time) , new_time_(new_time) { } -Project *NodeParamSetKeyframeTimeCommand::GetRelevantProject() const +Project *NodeParamSetKeyframeTimeCommand::get_relevant_project() const { return key_->parent()->project(); } @@ -525,7 +525,7 @@ void NodeParamSetKeyframeTimeCommand::undo() NodeParamSetStandardValueCommand::NodeParamSetStandardValueCommand( const NodeKeyframeTrackReference &input, const QVariant &value) : ref_(input) - , old_value_(ref_.input().node()->GetStandardValue(ref_.input())) + , old_value_(ref_.input().node()->get_standard_value(ref_.input())) , new_value_(value) { } @@ -539,19 +539,19 @@ NodeParamSetStandardValueCommand::NodeParamSetStandardValueCommand( { } -Project *NodeParamSetStandardValueCommand::GetRelevantProject() const +Project *NodeParamSetStandardValueCommand::get_relevant_project() const { return ref_.input().node()->project(); } void NodeParamSetStandardValueCommand::redo() { - ref_.input().node()->SetSplitStandardValueOnTrack(ref_, new_value_); + ref_.input().node()->set_split_standard_value_on_track(ref_, new_value_); } void NodeParamSetStandardValueCommand::undo() { - ref_.input().node()->SetSplitStandardValueOnTrack(ref_, old_value_); + ref_.input().node()->set_split_standard_value_on_track(ref_, old_value_); } NodeParamArrayAppendCommand::NodeParamArrayAppendCommand(Node *node, @@ -561,46 +561,46 @@ NodeParamArrayAppendCommand::NodeParamArrayAppendCommand(Node *node, { } -Project *NodeParamArrayAppendCommand::GetRelevantProject() const +Project *NodeParamArrayAppendCommand::get_relevant_project() const { return node_->project(); } void NodeParamArrayAppendCommand::redo() { - node_->InputArrayAppend(input_); + node_->input_array_append(input_); } void NodeParamArrayAppendCommand::undo() { - node_->InputArrayRemoveLast(input_); + node_->input_array_remove_last(input_); } void NodeSetValueHintCommand::redo() { old_hint_ = - input_.node()->GetValueHintForInput(input_.input(), input_.element()); - input_.node()->SetValueHintForInput(input_.input(), new_hint_, + input_.node()->get_value_hint_for_input(input_.input(), input_.element()); + input_.node()->set_value_hint_for_input(input_.input(), new_hint_, input_.element()); } void NodeSetValueHintCommand::undo() { - input_.node()->SetValueHintForInput(input_.input(), old_hint_, + input_.node()->set_value_hint_for_input(input_.input(), old_hint_, input_.element()); } -Project *NodeArrayInsertCommand::GetRelevantProject() const +Project *NodeArrayInsertCommand::get_relevant_project() const { return node_->project(); } -Project *NodeArrayRemoveCommand::GetRelevantProject() const +Project *NodeArrayRemoveCommand::get_relevant_project() const { return node_->project(); } -Project *NodeArrayResizeCommand::GetRelevantProject() const +Project *NodeArrayResizeCommand::get_relevant_project() const { return node_->project(); } diff --git a/app/node/nodeundo.h b/app/node/nodeundo.h index c8d408e7c..78eef567a 100644 --- a/app/node/nodeundo.h +++ b/app/node/nodeundo.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEUNDO_H -#define NODEUNDO_H +#ifndef OAK_NODEUNDO_H +#define OAK_NODEUNDO_H #include "node/node.h" #include "node/project.h" @@ -38,7 +38,7 @@ public: pos_ = pos; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return node_->project(); } @@ -66,7 +66,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return node_->project(); } @@ -95,7 +95,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return node_->project(); } @@ -122,7 +122,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return node_->project(); } @@ -147,17 +147,17 @@ public: { } - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override { - node_->InputArrayInsert(input_, index_); + node_->input_array_insert(input_, index_); } virtual void undo() override { - node_->InputArrayRemove(input_, index_); + node_->input_array_remove(input_, index_); } private: @@ -175,12 +175,12 @@ public: { } - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override { - old_size_ = node_->InputArraySize(input_); + old_size_ = node_->input_array_size(input_); if (old_size_ > size_) { // Decreasing in size, disconnect any extraneous edges @@ -191,24 +191,24 @@ protected: removed_connections_[input] = output; - Node::DisconnectEdge(output, input); + Node::disconnect_edge(output, input); } catch (std::out_of_range &) { } } } - node_->ArrayResizeInternal(input_, size_); + node_->array_resize_internal(input_, size_); } virtual void undo() override { for (auto it = removed_connections_.cbegin(); it != removed_connections_.cend(); it++) { - Node::ConnectEdge(it->second, it->first); + Node::connect_edge(it->second, it->first); } removed_connections_.clear(); - node_->ArrayResizeInternal(input_, old_size_); + node_->array_resize_internal(input_, old_size_); } private: @@ -229,26 +229,26 @@ public: { } - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override { // Save immediate data - if (node_->IsInputKeyframable(input_)) { - is_keyframing_ = node_->IsInputKeyframing(input_, index_); + if (node_->is_input_keyframable(input_)) { + is_keyframing_ = node_->is_input_keyframing(input_, index_); } - standard_value_ = node_->GetSplitStandardValue(input_, index_); - keyframes_ = node_->GetKeyframeTracks(input_, index_); - node_->GetImmediate(input_, index_) + standard_value_ = node_->get_split_standard_value(input_, index_); + keyframes_ = node_->get_keyframe_tracks(input_, index_); + node_->get_immediate(input_, index_) ->delete_all_keyframes(&memory_manager_); - node_->InputArrayRemove(input_, index_); + node_->input_array_remove(input_, index_); } virtual void undo() override { - node_->InputArrayInsert(input_, index_); + node_->input_array_insert(input_, index_); // Restore keyframes foreach (const NodeKeyframeTrack &track, keyframes_) { @@ -256,10 +256,10 @@ protected: key->setParent(node_); } } - node_->SetSplitStandardValue(input_, standard_value_, index_); + node_->set_split_standard_value(input_, standard_value_, index_); - if (node_->IsInputKeyframable(input_)) { - node_->SetInputIsKeyframing(input_, is_keyframing_, index_); + if (node_->is_input_keyframable(input_)) { + node_->set_input_is_keyframing(input_, is_keyframing_, index_); } } @@ -283,7 +283,7 @@ class NodeEdgeRemoveCommand : public UndoCommand { public: NodeEdgeRemoveCommand(Node *output, const NodeInput &input); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -305,7 +305,7 @@ public: virtual ~NodeEdgeAddCommand() override; - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -322,9 +322,9 @@ class NodeAddCommand : public UndoCommand { public: NodeAddCommand(Project *graph, Node *node); - void PushToThread(QThread *thread); + void push_to_thread(QThread *thread); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -351,7 +351,7 @@ public: delete command_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return graph_; } @@ -397,12 +397,12 @@ public: delete command_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { if (command_) { return static_cast( command_->child(0)) - ->GetRelevantProject(); + ->get_relevant_project(); } else { return node_->project(); } @@ -416,7 +416,7 @@ protected: command_->add_child(new NodeRemoveAndDisconnectCommand(node_)); // Remove exclusive dependencies - QVector deps = node_->GetExclusiveDependencies(); + QVector deps = node_->get_exclusive_dependencies(); foreach (Node *d, deps) { command_->add_child(new NodeRemoveAndDisconnectCommand(d)); } @@ -446,7 +446,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return a_->project(); } @@ -455,9 +455,9 @@ protected: virtual void redo() override { if (link_) { - done_ = Node::Link(a_, b_); + done_ = Node::link(a_, b_); } else { - done_ = Node::Unlink(a_, b_); + done_ = Node::unlink(a_, b_); } } @@ -465,9 +465,9 @@ protected: { if (done_) { if (link_) { - Node::Unlink(a_, b_); + Node::unlink(a_, b_); } else { - Node::Link(a_, b_); + Node::link(a_, b_); } } } @@ -486,7 +486,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return node_->project(); } @@ -497,14 +497,14 @@ protected: unlinked_ = node_->links(); foreach (Node *link, unlinked_) { - Node::Unlink(node_, link); + Node::unlink(node_, link); } } virtual void undo() override { foreach (Node *link, unlinked_) { - Node::Link(node_, link); + Node::link(node_, link); } unlinked_.clear(); @@ -530,7 +530,7 @@ public: } } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nodes_.first()->project(); } @@ -544,12 +544,12 @@ public: NodeRenameCommand() = default; NodeRenameCommand(Node *node, const QString &new_name) { - AddNode(node, new_name); + add_node(node, new_name); } - void AddNode(Node *node, const QString &new_name); + void add_node(Node *node, const QString &new_name); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -567,7 +567,7 @@ class NodeOverrideColorCommand : public UndoCommand { public: NodeOverrideColorCommand(Node *node, int index); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -586,13 +586,13 @@ class NodeViewDeleteCommand : public UndoCommand { public: NodeViewDeleteCommand(); - void AddNode(Node *node, Node *context); + void add_node(Node *node, Node *context); - void AddEdge(Node *output, const NodeInput &input); + void add_edge(Node *output, const NodeInput &input); - bool ContainsNode(Node *node, Node *context); + bool contains_node(Node *node, Node *context); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -620,7 +620,7 @@ class NodeParamSetKeyframingCommand : public UndoCommand { public: NodeParamSetKeyframingCommand(const NodeInput &input, bool setting); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -636,7 +636,7 @@ class NodeParamInsertKeyframeCommand : public UndoCommand { public: NodeParamInsertKeyframeCommand(Node *node, NodeKeyframe *keyframe); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -654,7 +654,7 @@ class NodeParamRemoveKeyframeCommand : public UndoCommand { public: NodeParamRemoveKeyframeCommand(NodeKeyframe *keyframe); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -670,11 +670,11 @@ private: class NodeParamSetKeyframeTimeCommand : public UndoCommand { public: - NodeParamSetKeyframeTimeCommand(NodeKeyframe *key, const rational &time); - NodeParamSetKeyframeTimeCommand(NodeKeyframe *key, const rational &new_time, - const rational &old_time); + NodeParamSetKeyframeTimeCommand(NodeKeyframe *key, const Rational &time); + NodeParamSetKeyframeTimeCommand(NodeKeyframe *key, const Rational &new_time, + const Rational &old_time); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -683,8 +683,8 @@ protected: private: NodeKeyframe *key_; - rational old_time_; - rational new_time_; + Rational old_time_; + Rational new_time_; }; class NodeParamSetKeyframeValueCommand : public UndoCommand { @@ -694,7 +694,7 @@ public: const QVariant &new_value, const QVariant &old_value); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -715,7 +715,7 @@ public: const QVariant &new_value, const QVariant &old_value); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -742,11 +742,11 @@ public: NodeParamSetSplitStandardValueCommand(const NodeInput &input, const SplitValue &value) : NodeParamSetSplitStandardValueCommand( - input, value, input.node()->GetSplitStandardValue(input.input())) + input, value, input.node()->get_split_standard_value(input.input())) { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return ref_.node()->project(); } @@ -754,13 +754,13 @@ public: protected: virtual void redo() override { - ref_.node()->SetSplitStandardValue(ref_.input(), new_value_, + ref_.node()->set_split_standard_value(ref_.input(), new_value_, ref_.element()); } virtual void undo() override { - ref_.node()->SetSplitStandardValue(ref_.input(), old_value_, + ref_.node()->set_split_standard_value(ref_.input(), old_value_, ref_.element()); } @@ -775,7 +775,7 @@ class NodeParamArrayAppendCommand : public UndoCommand { public: NodeParamArrayAppendCommand(Node *node, const QString &input); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -802,7 +802,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return input_.node()->project(); } @@ -827,7 +827,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nullptr; } @@ -851,4 +851,4 @@ private: } -#endif // NODEUNDO_H +#endif // OAK_NODEUNDO_H diff --git a/app/node/output/track/track.cpp b/app/node/output/track/track.cpp index 0f494f72d..8335de079 100644 --- a/app/node/output/track/track.cpp +++ b/app/node/output/track/track.cpp @@ -35,16 +35,16 @@ namespace olive #define super Node -const double Track::kTrackHeightDefault = 3.0; -const double Track::kTrackHeightMinimum = 1.5; -const double Track::kTrackHeightInterval = 0.5; +const double Track::k_track_height_default = 3.0; +const double Track::k_track_height_minimum = 1.5; +const double Track::k_track_height_interval = 0.5; -const QString Track::kBlockInput = QStringLiteral("block_in"); -const QString Track::kMutedInput = QStringLiteral("muted_in"); -const QString Track::kArrayMapInput = QStringLiteral("arraymap_in"); +const QString Track::k_block_input = QStringLiteral("block_in"); +const QString Track::k_muted_input = QStringLiteral("muted_in"); +const QString Track::k_array_map_input = QStringLiteral("arraymap_in"); Track::Track() - : track_type_(Track::kNone) + : track_type_(Track::k_none) , index_(-1) , locked_(false) , sequence_(nullptr) @@ -52,19 +52,19 @@ Track::Track() , arraymap_invalid_(false) , ignore_arraymap_set_(false) { - AddInput(kBlockInput, NodeValue::kNone, - InputFlags(kInputFlagArray | kInputFlagNotKeyframable | - kInputFlagHidden | kInputFlagIgnoreInvalidations)); + add_input(k_block_input, NodeValue::k_none, + InputFlags(k_input_flag_array | k_input_flag_not_keyframable | + k_input_flag_hidden | k_input_flag_ignore_invalidations)); - AddInput(kMutedInput, NodeValue::kBoolean, false, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable)); + add_input(k_muted_input, NodeValue::k_boolean, false, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable)); - AddInput(kArrayMapInput, NodeValue::kBinary, - InputFlags(kInputFlagStatic | kInputFlagHidden | - kInputFlagIgnoreInvalidations)); + add_input(k_array_map_input, NodeValue::k_binary, + InputFlags(k_input_flag_static | k_input_flag_hidden | + k_input_flag_ignore_invalidations)); // Set default height - track_height_ = kTrackHeightDefault; + track_height_ = k_track_height_default; } void Track::set_type(const Type &track_type) @@ -77,13 +77,13 @@ const Track::Type &Track::type() const return track_type_; } -QString Track::Name() const +QString Track::name() const { - if (track_type_ == Track::kVideo) { + if (track_type_ == Track::k_video) { return tr("Video Track %1").arg(index_); - } else if (track_type_ == Track::kAudio) { + } else if (track_type_ == Track::k_audio) { return tr("Audio Track %1").arg(index_); - } else if (track_type_ == Track::kSubtitle) { + } else if (track_type_ == Track::k_subtitle) { return tr("Subtitle Track %1").arg(index_); } @@ -95,28 +95,28 @@ QString Track::id() const return QStringLiteral("org.olivevideoeditor.Olive.track"); } -QVector Track::Category() const +QVector Track::category() const { - return { kCategoryTimeline }; + return { k_category_timeline }; } -QString Track::Description() const +QString Track::description() const { return tr( "Node for representing and processing a single array of Blocks sorted by time. Also represents the end of " "a Sequence."); } -Node::ActiveElements Track::GetActiveElementsAtTime(const QString &input, +Node::ActiveElements Track::get_active_elements_at_time(const QString &input, const TimeRange &r) const { - if (input == kBlockInput) { - if (IsMuted() || blocks_.empty() || r.in() >= track_length() || + if (input == k_block_input) { + if (is_muted() || blocks_.empty() || r.in() >= track_length() || r.out() <= 0) { - return ActiveElements::kNoElements; + return ActiveElements::k_no_elements; } else { - int start = GetBlockIndexAtTime(r.in()); - int end = GetBlockIndexAtTime(r.out()); + int start = get_block_index_at_time(r.in()); + int end = get_block_index_at_time(r.out()); if (start == -1) { start = 0; @@ -134,42 +134,42 @@ Node::ActiveElements Track::GetActiveElementsAtTime(const QString &input, Block *b = blocks_.at(i); if (b->is_enabled() && (dynamic_cast(b) || dynamic_cast(b))) { - a.add(GetArrayIndexFromCacheIndex(i)); + a.add(get_array_index_from_cache_index(i)); } } if (a.elements().empty()) { - return ActiveElements::kNoElements; + return ActiveElements::k_no_elements; } else { return a; } } } else { - return super::GetActiveElementsAtTime(input, r); + return super::get_active_elements_at_time(input, r); } } -void Track::Value(const NodeValueRow &value, const NodeGlobals &globals, +void Track::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (this->type() == Track::kVideo) { + if (this->type() == Track::k_video) { // Just pass straight through - NodeValueArray a = value[kBlockInput].toArray(); + NodeValueArray a = value[k_block_input].to_array(); if (!a.empty()) { - table->Push(a.begin()->second); + table->push(a.begin()->second); } - } else if (this->type() == Track::kAudio) { + } else if (this->type() == Track::k_audio) { // Audio - ProcessAudioTrack(value, globals, table); + process_audio_track(value, globals, table); } } -TimeRange Track::InputTimeAdjustment(const QString &input, int element, +TimeRange Track::input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const { - if (input == kBlockInput && element >= 0) { - int cache_index = GetCacheIndexFromArrayIndex(element); + if (input == k_block_input && element >= 0) { + int cache_index = get_cache_index_from_array_index(element); if (cache_index > -1) { TimeRange r = input_time; @@ -180,45 +180,45 @@ TimeRange Track::InputTimeAdjustment(const QString &input, int element, std::min(r.out(), b->out())); } - return TransformRangeForBlock(b, r); + return transform_range_for_block(b, r); } } - return Node::InputTimeAdjustment(input, element, input_time, clamp); + return Node::input_time_adjustment(input, element, input_time, clamp); } -TimeRange Track::OutputTimeAdjustment(const QString &input, int element, +TimeRange Track::output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const { - if (input == kBlockInput && element >= 0) { - int cache_index = GetCacheIndexFromArrayIndex(element); + if (input == k_block_input && element >= 0) { + int cache_index = get_cache_index_from_array_index(element); if (cache_index > -1) { - return TransformRangeFromBlock(blocks_.at(cache_index), input_time); + return transform_range_from_block(blocks_.at(cache_index), input_time); } } - return Node::OutputTimeAdjustment(input, element, input_time); + return Node::output_time_adjustment(input, element, input_time); } -const double &Track::GetTrackHeight() const +const double &Track::get_track_height() const { return track_height_; } -void Track::SetTrackHeight(const double &height) +void Track::set_track_height(const double &height) { track_height_ = height; - emit TrackHeightChanged(track_height_); + emit track_height_changed(track_height_); } -bool Track::LoadCustom(QXmlStreamReader *reader, SerializedData *data) +bool Track::load_custom(QXmlStreamReader *reader, SerializedData *data) { ignore_arraymap_set_ = true; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("height")) { - this->SetTrackHeight(reader->readElementText().toDouble()); + this->set_track_height(reader->readElementText().toDouble()); } else { reader->skipCurrentElement(); } @@ -227,51 +227,51 @@ bool Track::LoadCustom(QXmlStreamReader *reader, SerializedData *data) return true; } -void Track::SaveCustom(QXmlStreamWriter *writer) const +void Track::save_custom(QXmlStreamWriter *writer) const { writer->writeTextElement(QStringLiteral("height"), - QString::number(this->GetTrackHeight())); + QString::number(this->get_track_height())); } void Track::PostLoadEvent(SerializedData *data) { ignore_arraymap_set_ = false; - RefreshBlockCacheFromArrayMap(); + refresh_block_cache_from_array_map(); } void Track::InputValueChangedEvent(const QString &input, int element) { Q_UNUSED(element) - if (input == kMutedInput) { - emit MutedChanged(IsMuted()); - } else if (input == kArrayMapInput) { + if (input == k_muted_input) { + emit muted_changed(is_muted()); + } else if (input == k_array_map_input) { if (ignore_arraymap_ > 0) { ignore_arraymap_--; } else { - RefreshBlockCacheFromArrayMap(); + refresh_block_cache_from_array_map(); } } } -void Track::Retranslate() +void Track::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kBlockInput, tr("Blocks")); - SetInputName(kMutedInput, tr("Muted")); + set_input_name(k_block_input, tr("Blocks")); + set_input_name(k_muted_input, tr("Muted")); } -void Track::SetIndex(const int &index) +void Track::set_index(const int &index) { int old = index_; index_ = index; - emit IndexChanged(old, index_); + emit index_changed(old, index_); } -Block *Track::BlockContainingTime(const rational &time) const +Block *Track::block_containing_time(const Rational &time) const { foreach (Block *block, blocks_) { if (block->in() < time && block->out() > time) { @@ -284,7 +284,7 @@ Block *Track::BlockContainingTime(const rational &time) const return nullptr; } -Block *Track::NearestBlockBefore(const rational &time) const +Block *Track::nearest_block_before(const Rational &time) const { foreach (Block *block, blocks_) { // Blocks are sorted by time, so the first Block who's out point is at/after this time is the correct Block @@ -300,7 +300,7 @@ Block *Track::NearestBlockBefore(const rational &time) const return nullptr; } -Block *Track::NearestBlockBeforeOrAt(const rational &time) const +Block *Track::nearest_block_before_or_at(const Rational &time) const { foreach (Block *block, blocks_) { // Blocks are sorted by time, so the first Block who's out point is at/after this time is the correct Block @@ -312,7 +312,7 @@ Block *Track::NearestBlockBeforeOrAt(const rational &time) const return nullptr; } -Block *Track::NearestBlockAfterOrAt(const rational &time) const +Block *Track::nearest_block_after_or_at(const Rational &time) const { foreach (Block *block, blocks_) { // Blocks are sorted by time, so the first Block after this time is the correct Block @@ -324,7 +324,7 @@ Block *Track::NearestBlockAfterOrAt(const rational &time) const return nullptr; } -Block *Track::NearestBlockAfter(const rational &time) const +Block *Track::nearest_block_after(const Rational &time) const { foreach (Block *block, blocks_) { // Blocks are sorted by time, so the first Block after this time is the correct Block @@ -336,9 +336,9 @@ Block *Track::NearestBlockAfter(const rational &time) const return nullptr; } -bool Track::IsRangeFree(const TimeRange &range) const +bool Track::is_range_free(const TimeRange &range) const { - Block *b = NearestBlockBeforeOrAt(range.in()); + Block *b = nearest_block_before_or_at(range.in()); if (!b) { // No block here, assume track is empty here return true; @@ -363,18 +363,18 @@ bool Track::IsRangeFree(const TimeRange &range) const return true; } -void Track::InvalidateCache(const TimeRange &range, const QString &from, +void Track::invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) { TimeRange limited; const Block *b; - if (from == kBlockInput && element >= 0 && - (b = dynamic_cast(GetConnectedOutput(from, element))) && + if (from == k_block_input && element >= 0 && + (b = dynamic_cast(get_connected_output(from, element))) && !options.value(QStringLiteral("lengthevent")).toBool()) { // Limit the range signal to the corresponding block - TimeRange transformed = TransformRangeFromBlock(b, range); + TimeRange transformed = transform_range_from_block(b, range); if (transformed.out() <= b->in() || transformed.in() >= b->out()) { return; @@ -390,44 +390,44 @@ void Track::InvalidateCache(const TimeRange &range, const QString &from, // to keep it options.remove(QStringLiteral("lengthevent")); - Node::InvalidateCache(limited, from, element, options); + Node::invalidate_cache(limited, from, element, options); } -void Track::InsertBlockBefore(Block *block, Block *after) +void Track::insert_block_before(Block *block, Block *after) { if (!after) { - AppendBlock(block); + append_block(block); } else { - InsertBlockAtIndex(block, blocks_.indexOf(after)); + insert_block_at_index(block, blocks_.indexOf(after)); } } -void Track::InsertBlockAfter(Block *block, Block *before) +void Track::insert_block_after(Block *block, Block *before) { if (!before) { - PrependBlock(block); + prepend_block(block); } else { int before_index = blocks_.indexOf(before); Q_ASSERT(before_index >= 0); - InsertBlockAtIndex(block, before_index + 1); + insert_block_at_index(block, before_index + 1); } } -void Track::PrependBlock(Block *block) +void Track::prepend_block(Block *block) { - InsertBlockAtIndex(block, 0); + insert_block_at_index(block, 0); } -void Track::InsertBlockAtIndex(Block *block, int index) +void Track::insert_block_at_index(Block *block, int index) { // Set track Q_ASSERT(block->track() == nullptr); block->set_track(this); // Update array - int array_index = ConnectBlock(block); + int array_index = connect_block(block); blocks_.insert(index, block); block_array_indexes_.insert(index, array_index); @@ -439,28 +439,28 @@ void Track::InsertBlockAtIndex(Block *block, int index) Block::set_previous_next(block, next); // Update in/out - UpdateInOutFrom(index); + update_in_out_from(index); - connect(block, &Block::LengthChanged, this, &Track::BlockLengthChanged); + connect(block, &Block::length_changed, this, &Track::block_length_changed); - Node::InvalidateCache(TimeRange(block->in(), track_length()), kBlockInput); + Node::invalidate_cache(TimeRange(block->in(), track_length()), k_block_input); - emit BlockAdded(block); + emit block_added(block); - UpdateArrayMap(); + update_array_map(); } -void Track::AppendBlock(Block *block) +void Track::append_block(Block *block) { - InsertBlockAtIndex(block, blocks_.size()); + insert_block_at_index(block, blocks_.size()); } -void Track::RippleRemoveBlock(Block *block) +void Track::ripple_remove_block(Block *block) { - rational remove_in = block->in(); - rational remove_out = block->out(); + Rational remove_in = block->in(); + Rational remove_out = block->out(); - emit BlockRemoved(block); + emit block_removed(block); // Set track Q_ASSERT(block->track() == this); @@ -475,9 +475,9 @@ void Track::RippleRemoveBlock(Block *block) blocks_.removeAt(index); block_array_indexes_.removeAt(index); - Node::DisconnectEdge(block, NodeInput(this, kBlockInput, array_index)); + Node::disconnect_edge(block, NodeInput(this, k_block_input, array_index)); empty_inputs_.push_back(array_index); - disconnect(block, &Block::LengthChanged, this, &Track::BlockLengthChanged); + disconnect(block, &Block::length_changed, this, &Track::block_length_changed); // Handle previous/next Block *previous = (index > 0) ? blocks_.at(index - 1) : nullptr; @@ -489,17 +489,17 @@ void Track::RippleRemoveBlock(Block *block) block->set_out(block->length()); // Update in/outs - UpdateInOutFrom(index); + update_in_out_from(index); - Node::InvalidateCache( - TimeRange(remove_in, qMax(track_length(), remove_out)), kBlockInput); + Node::invalidate_cache( + TimeRange(remove_in, qMax(track_length(), remove_out)), k_block_input); - UpdateArrayMap(); + update_array_map(); } -void Track::ReplaceBlock(Block *old, Block *replace) +void Track::replace_block(Block *old, Block *replace) { - emit BlockRemoved(old); + emit block_removed(old); // Set track Q_ASSERT(old->track() == this); @@ -510,13 +510,13 @@ void Track::ReplaceBlock(Block *old, Block *replace) // Update array int cache_index = blocks_.indexOf(old); - int index_of_old_block = GetArrayIndexFromCacheIndex(cache_index); + int index_of_old_block = get_array_index_from_cache_index(cache_index); - DisconnectEdge(old, NodeInput(this, kBlockInput, index_of_old_block)); - ConnectEdge(replace, NodeInput(this, kBlockInput, index_of_old_block)); + disconnect_edge(old, NodeInput(this, k_block_input, index_of_old_block)); + connect_edge(replace, NodeInput(this, k_block_input, index_of_old_block)); blocks_.replace(cache_index, replace); - disconnect(old, &Block::LengthChanged, this, &Track::BlockLengthChanged); - connect(replace, &Block::LengthChanged, this, &Track::BlockLengthChanged); + disconnect(old, &Block::length_changed, this, &Track::block_length_changed); + connect(replace, &Block::length_changed, this, &Track::block_length_changed); // Handle previous/next replace->set_previous(old->previous()); @@ -534,22 +534,22 @@ void Track::ReplaceBlock(Block *old, Block *replace) replace->set_in(replace->previous() ? replace->previous()->out() : 0); replace->set_out(replace->in() + replace->length()); - Node::InvalidateCache(TimeRange(replace->in(), replace->out()), - kBlockInput); + Node::invalidate_cache(TimeRange(replace->in(), replace->out()), + k_block_input); } else { // Update in/outs - UpdateInOutFrom(cache_index); + update_in_out_from(cache_index); - Node::InvalidateCache(TimeRange(replace->in(), track_length()), - kBlockInput); + Node::invalidate_cache(TimeRange(replace->in(), track_length()), + k_block_input); } - emit BlockAdded(replace); + emit block_added(replace); - UpdateArrayMap(); + update_array_map(); } -rational Track::track_length() const +Rational Track::track_length() const { if (blocks_.isEmpty()) { return 0; @@ -558,37 +558,37 @@ rational Track::track_length() const } } -bool Track::IsMuted() const +bool Track::is_muted() const { - return GetStandardValue(kMutedInput).toBool(); + return get_standard_value(k_muted_input).toBool(); } -bool Track::IsLocked() const +bool Track::is_locked() const { return locked_; } -void Track::SetMuted(bool e) +void Track::set_muted(bool e) { - SetStandardValue(kMutedInput, e); + set_standard_value(k_muted_input, e); } -void Track::SetLocked(bool e) +void Track::set_locked(bool e) { locked_ = e; } void Track::InputConnectedEvent(const QString &input, int element, Node *node) { - if (arraymap_invalid_ && input == kBlockInput && element >= 0) { - RefreshBlockCacheFromArrayMap(); + if (arraymap_invalid_ && input == k_block_input && element >= 0) { + refresh_block_cache_from_array_map(); } } -void Track::UpdateInOutFrom(int index) +void Track::update_in_out_from(int index) { // Find block just before this one to find the last out point - rational last_out = (index == 0) ? 0 : blocks_.at(index - 1)->out(); + Rational last_out = (index == 0) ? 0 : blocks_.at(index - 1)->out(); // Iterate through all blocks updating their in/outs for (int i = index; i < blocks_.size(); i++) { @@ -601,28 +601,28 @@ void Track::UpdateInOutFrom(int index) b->set_out(last_out); } - emit BlocksRefreshed(); + emit blocks_refreshed(); // Update track length - emit TrackLengthChanged(); + emit track_length_changed(); } -int Track::GetArrayIndexFromBlock(Block *block) const +int Track::get_array_index_from_block(Block *block) const { return block_array_indexes_.at(blocks_.indexOf(block)); } -int Track::GetArrayIndexFromCacheIndex(int index) const +int Track::get_array_index_from_cache_index(int index) const { return block_array_indexes_.at(index); } -int Track::GetCacheIndexFromArrayIndex(int index) const +int Track::get_cache_index_from_array_index(int index) const { return block_array_indexes_.indexOf(index); } -int Track::GetBlockIndexAtTime(const rational &time) const +int Track::get_block_index_at_time(const Rational &time) const { if (time < 0 || time >= track_length()) { return -1; @@ -647,7 +647,7 @@ int Track::GetBlockIndexAtTime(const rational &time) const return -1; } -void Track::ProcessAudioTrack(const NodeValueRow &value, +void Track::process_audio_track(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { @@ -658,10 +658,10 @@ void Track::ProcessAudioTrack(const NodeValueRow &value, block_range_buffer.silence(); // Loop through active blocks retrieving their audio - NodeValueArray arr = value[kBlockInput].toArray(); + NodeValueArray arr = value[k_block_input].to_array(); for (auto it = arr.cbegin(); it != arr.cend(); it++) { - Block *b = blocks_.at(GetCacheIndexFromArrayIndex(it->first)); + Block *b = blocks_.at(get_cache_index_from_array_index(it->first)); TimeRange range_for_block(qMax(b->in(), range.in()), qMin(b->out(), range.out())); @@ -673,7 +673,7 @@ void Track::ProcessAudioTrack(const NodeValueRow &value, globals.aparams().time_to_samples(range_for_block.length()); // Destination buffer - SampleBuffer samples_from_this_block = it->second.toSamples(); + SampleBuffer samples_from_this_block = it->second.to_samples(); if (samples_from_this_block.is_allocated()) { // If this is a clip, we might have extra speed/reverse information @@ -688,7 +688,7 @@ void Track::ProcessAudioTrack(const NodeValueRow &value, if (clip_cast->maintain_audio_pitch()) { AudioProcessor processor; - if (processor.Open( + if (processor.open( samples_from_this_block.audio_params(), samples_from_this_block.audio_params(), speed_value)) { @@ -700,7 +700,7 @@ void Track::ProcessAudioTrack(const NodeValueRow &value, // well on export (assuming audio is all generated at once on export), but // users may hear clicks and pops in the audio during preview due to this // approach. - int r = processor.Convert( + int r = processor.convert( samples_from_this_block.to_raw_ptrs().data(), samples_from_this_block.sample_count(), nullptr); @@ -709,9 +709,9 @@ void Track::ProcessAudioTrack(const NodeValueRow &value, qCritical() << "Failed to change tempo of audio:" << r; } else { - processor.Flush(); + processor.flush(); - processor.Convert(nullptr, 0, &out); + processor.convert(nullptr, 0, &out); if (!out.empty()) { int nb_samples = @@ -762,37 +762,37 @@ void Track::ProcessAudioTrack(const NodeValueRow &value, } } - table->Push(NodeValue::kSamples, QVariant::fromValue(block_range_buffer), + table->push(NodeValue::k_samples, QVariant::fromValue(block_range_buffer), this); } -int Track::ConnectBlock(Block *b) +int Track::connect_block(Block *b) { if (!empty_inputs_.empty()) { int index = empty_inputs_.front(); empty_inputs_.pop_front(); - Node::ConnectEdge(b, NodeInput(this, kBlockInput, index)); + Node::connect_edge(b, NodeInput(this, k_block_input, index)); return index; } else { - int old_sz = InputArraySize(kBlockInput); - InputArrayAppend(kBlockInput); - Node::ConnectEdge(b, NodeInput(this, kBlockInput, old_sz)); + int old_sz = input_array_size(k_block_input); + input_array_append(k_block_input); + Node::connect_edge(b, NodeInput(this, k_block_input, old_sz)); return old_sz; } } -void Track::UpdateArrayMap() +void Track::update_array_map() { ignore_arraymap_++; - SetStandardValue( - kArrayMapInput, + set_standard_value( + k_array_map_input, QByteArray(reinterpret_cast(block_array_indexes_.data()), block_array_indexes_.size() * sizeof(uint32_t))); } -void Track::RefreshBlockCacheFromArrayMap() +void Track::refresh_block_cache_from_array_map() { if (ignore_arraymap_set_) { return; @@ -806,10 +806,10 @@ void Track::RefreshBlockCacheFromArrayMap() b->set_next(nullptr); b->set_in(0); b->set_out(b->length()); - disconnect(b, &Block::LengthChanged, this, &Track::BlockLengthChanged); + disconnect(b, &Block::length_changed, this, &Track::block_length_changed); } - QByteArray bytes = GetStandardValue(kArrayMapInput).toByteArray(); + QByteArray bytes = get_standard_value(k_array_map_input).toByteArray(); block_array_indexes_.resize(bytes.size() / sizeof(uint32_t)); memcpy(block_array_indexes_.data(), bytes.data(), bytes.size()); blocks_.clear(); @@ -820,13 +820,13 @@ void Track::RefreshBlockCacheFromArrayMap() for (int i = 0; i < block_array_indexes_.size(); i++) { Block *b = static_cast( - GetConnectedOutput(kBlockInput, block_array_indexes_.at(i))); + get_connected_output(k_block_input, block_array_indexes_.at(i))); Block::set_previous_next(prev, b); if (b) { b->set_track(this); - connect(b, &Block::LengthChanged, this, &Track::BlockLengthChanged); + connect(b, &Block::length_changed, this, &Track::block_length_changed); blocks_.append(b); prev = b; @@ -841,15 +841,15 @@ void Track::RefreshBlockCacheFromArrayMap() prev->set_next(nullptr); } - UpdateInOutFrom(0); + update_in_out_from(0); } -void Track::BlockLengthChanged() +void Track::block_length_changed() { // Assumes sender is a Block Block *b = static_cast(sender()); - UpdateInOutFrom(blocks_.indexOf(b)); + update_in_out_from(blocks_.indexOf(b)); } uint qHash(const Track::Reference &r, uint seed) diff --git a/app/node/output/track/track.h b/app/node/output/track/track.h index 0b5ccbe2b..7a6e9fd71 100644 --- a/app/node/output/track/track.h +++ b/app/node/output/track/track.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRACK_H -#define TRACK_H +#ifndef OAK_TRACK_H +#define OAK_TRACK_H #include "node/block/block.h" @@ -35,7 +35,7 @@ class Sequence; class Track : public Node { Q_OBJECT public: - enum Type { kNone = -1, kVideo, kAudio, kSubtitle, kCount }; + enum Type { k_none = -1, k_video, k_audio, k_subtitle, k_count }; Track(); @@ -44,27 +44,27 @@ public: const Track::Type &type() const; void set_type(const Track::Type &track_type); - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; virtual ActiveElements - GetActiveElementsAtTime(const QString &input, + get_active_elements_at_time(const QString &input, const TimeRange &r) const override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - virtual TimeRange InputTimeAdjustment(const QString &input, int element, + virtual TimeRange input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const override; virtual TimeRange - OutputTimeAdjustment(const QString &input, int element, + output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const override; - static rational TransformTimeForBlock(const Block *block, - const rational &time) + static Rational transform_time_for_block(const Block *block, + const Rational &time) { if (time == RATIONAL_MAX || time == RATIONAL_MIN) { return time; @@ -73,15 +73,15 @@ public: return time - block->in(); } - static TimeRange TransformRangeForBlock(const Block *block, + static TimeRange transform_range_for_block(const Block *block, const TimeRange &range) { - return TimeRange(TransformTimeForBlock(block, range.in()), - TransformTimeForBlock(block, range.out())); + return TimeRange(transform_time_for_block(block, range.in()), + transform_time_for_block(block, range.out())); } - static rational TransformTimeFromBlock(const Block *block, - const rational &time) + static Rational transform_time_from_block(const Block *block, + const Rational &time) { if (time == RATIONAL_MAX || time == RATIONAL_MIN) { return time; @@ -90,57 +90,57 @@ public: return time + block->in(); } - static TimeRange TransformRangeFromBlock(const Block *block, + static TimeRange transform_range_from_block(const Block *block, const TimeRange &range) { - return TimeRange(TransformTimeFromBlock(block, range.in()), - TransformTimeFromBlock(block, range.out())); + return TimeRange(transform_time_from_block(block, range.in()), + transform_time_from_block(block, range.out())); } - const double &GetTrackHeight() const; - void SetTrackHeight(const double &height); + const double &get_track_height() const; + void set_track_height(const double &height); - int GetTrackHeightInPixels() const + int get_track_height_in_pixels() const { - return InternalHeightToPixelHeight(GetTrackHeight()); + return internal_height_to_pixel_height(get_track_height()); } - void SetTrackHeightInPixels(int h) + void set_track_height_in_pixels(int h) { - SetTrackHeight(PixelHeightToInternalHeight(h)); + set_track_height(pixel_height_to_internal_height(h)); } - virtual bool LoadCustom(QXmlStreamReader *reader, + virtual bool load_custom(QXmlStreamReader *reader, SerializedData *data) override; - virtual void SaveCustom(QXmlStreamWriter *writer) const override; + virtual void save_custom(QXmlStreamWriter *writer) const override; virtual void PostLoadEvent(SerializedData *data) override; - static int InternalHeightToPixelHeight(double h) + static int internal_height_to_pixel_height(double h) { return qRound(h * QFontMetrics(QFont()).height()); } - static double PixelHeightToInternalHeight(int h) + static double pixel_height_to_internal_height(int h) { return double(h) / double(QFontMetrics(QFont()).height()); } - static int GetDefaultTrackHeightInPixels() + static int get_default_track_height_in_pixels() { - return InternalHeightToPixelHeight(kTrackHeightDefault); + return internal_height_to_pixel_height(k_track_height_default); } - static int GetMinimumTrackHeightInPixels() + static int get_minimum_track_height_in_pixels() { - return InternalHeightToPixelHeight(kTrackHeightMinimum); + return internal_height_to_pixel_height(k_track_height_minimum); } - virtual void Retranslate() override; + virtual void retranslate() override; class Reference { public: Reference() - : type_(kNone) + : type_(k_none) , index_(-1) { } @@ -180,9 +180,9 @@ public: return index_ < rhs.index_; } - QString ToString() const + QString to_string() const { - QString type_string = TypeToString(type_); + QString type_string = type_to_string(type_); if (type_string.isEmpty()) { return QString(); } else { @@ -192,17 +192,17 @@ public: } /// For IDs that shouldn't change between localizations - static QString TypeToString(Type type) + static QString type_to_string(Type type) { switch (type) { - case kVideo: + case k_video: return QStringLiteral("v"); - case kAudio: + case k_audio: return QStringLiteral("a"); - case kSubtitle: + case k_subtitle: return QStringLiteral("s"); - case kCount: - case kNone: + case k_count: + case k_none: break; } @@ -210,49 +210,49 @@ public: } /// For human-facing strings - static QString TypeToTranslatedString(Type type) + static QString type_to_translated_string(Type type) { switch (type) { - case kVideo: + case k_video: return tr("V"); - case kAudio: + case k_audio: return tr("A"); - case kSubtitle: + case k_subtitle: return tr("S"); - case kCount: - case kNone: + case k_count: + case k_none: break; } return QString(); } - static Type TypeFromString(const QString &s) + static Type type_from_string(const QString &s) { if (s.size() >= 3) { if (s.at(1) == ':') { if (s.at(0) == 'v') { // Video stream - return Track::kVideo; + return Track::k_video; } else if (s.at(0) == 'a') { // Audio stream - return Track::kAudio; + return Track::k_audio; } else if (s.at(0) == 's') { // Subtitle stream - return Track::kSubtitle; + return Track::k_subtitle; } } } - return Track::kNone; + return Track::k_none; } - static Reference FromString(const QString &s) + static Reference from_string(const QString &s) { Reference ref; - Type parse_type = TypeFromString(s); + Type parse_type = type_from_string(s); - if (parse_type != Track::kNone) { + if (parse_type != Track::k_none) { bool ok; int parse_index = s.mid(2).toInt(&ok); @@ -265,9 +265,9 @@ public: return ref; } - bool IsValid() const + bool is_valid() const { - return type_ > kNone && type_ < kCount && index_ >= 0; + return type_ > k_none && type_ < k_count && index_ >= 0; } private: @@ -276,17 +276,17 @@ public: int index_; }; - Reference ToReference() const + Reference to_reference() const { - return Reference(type(), Index()); + return Reference(type(), index()); } - const int &Index() const + const int &index() const { return index_; } - void SetIndex(const int &index); + void set_index(const int &index); /** * @brief Returns the block that starts BEFORE (not AT) and ends AFTER (not AT) a time @@ -294,7 +294,7 @@ public: * Catches the first block that matches `block.in < time && block.out > time` or nullptr if any * block starts/ends precisely at that time or the time exceeds the track length. */ - Block *BlockContainingTime(const rational &time) const; + Block *block_containing_time(const Rational &time) const; /** * @brief Returns the block that starts BEFORE a given time and ends either AFTER or AT that time @@ -302,7 +302,7 @@ public: * @return Catches the first block that matches `block.out >= time` or nullptr if this time * exceeds the track length. */ - Block *NearestBlockBefore(const rational &time) const; + Block *nearest_block_before(const Rational &time) const; /** * @brief Returns the block that starts BEFORE or AT a given time. @@ -310,7 +310,7 @@ public: * @return Catches the first block that matches `block.out > time` or nullptr if this time * exceeds the track length. */ - Block *NearestBlockBeforeOrAt(const rational &time) const; + Block *nearest_block_before_or_at(const Rational &time) const; /** * @brief Returns the block that starts either AT a given time or the soonest block AFTER @@ -318,7 +318,7 @@ public: * @return Catches the first block that matches `block.in >= time` or nullptr if this time * exceeds the track length. */ - Block *NearestBlockAfterOrAt(const rational &time) const; + Block *nearest_block_after_or_at(const Rational &time) const; /** * @brief Returns the block that starts AFTER the given time (but never AT the given time) @@ -326,32 +326,32 @@ public: * @return Catches the first block that matches `block.in > time` or nullptr if this time * exceeds the track length. */ - Block *NearestBlockAfter(const rational &time) const; + Block *nearest_block_after(const Rational &time) const; /* * @brief Returns whether a time range is empty or only has a gap */ - bool IsRangeFree(const TimeRange &range) const; + bool is_range_free(const TimeRange &range) const; - const QVector &Blocks() const + const QVector &blocks() const { return blocks_; } - virtual void InvalidateCache(const TimeRange &range, const QString &from, + virtual void invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) override; - Block *VisibleBlockAtTime(const rational &t) const + Block *visible_block_at_time(const Rational &t) const { - int index = GetBlockIndexAtTime(t); + int index = get_block_index_at_time(t); return (index == -1) ? nullptr : blocks_.at(index); } /** * @brief Adds Block `block` at the very beginning of the Sequence before all other clips */ - void PrependBlock(Block *block); + void prepend_block(Block *block); /** * @brief Inserts Block `block` at a specific index (0 is the start of the timeline) @@ -359,44 +359,44 @@ public: * If the index == 0, this function does the same as PrependBlock(). If the index >= the current number of blocks, * this function is the same as AppendBlock(). */ - void InsertBlockAtIndex(Block *block, int index); + void insert_block_at_index(Block *block, int index); /** * @brief Inserts Block after another Block * * Equivalent to calling InsertBlockBetweenBlocks(block, before, before->next()) */ - void InsertBlockAfter(Block *block, Block *before); + void insert_block_after(Block *block, Block *before); /** * @brief Inserts Block before another Block */ - void InsertBlockBefore(Block *block, Block *after); + void insert_block_before(Block *block, Block *after); /** * @brief Adds Block `block` at the very end of the Sequence after all other clips */ - void AppendBlock(Block *block); + void append_block(Block *block); /** * @brief Removes a Block pushing all subsequent Blocks earlier to take up the space */ - void RippleRemoveBlock(Block *block); + void ripple_remove_block(Block *block); /** * @brief Replaces Block `old` with Block `replace` * * Both blocks must have equal lengths. */ - void ReplaceBlock(Block *old, Block *replace); + void replace_block(Block *old, Block *replace); - rational track_length() const; + Rational track_length() const; - bool IsMuted() const; + bool is_muted() const; - bool IsLocked() const; + bool is_locked() const; - int GetArrayIndexFromBlock(Block *block) const; + int get_array_index_from_block(Block *block) const; Sequence *sequence() const { @@ -408,54 +408,54 @@ public: sequence_ = sequence; } - static const double kTrackHeightDefault; - static const double kTrackHeightMinimum; - static const double kTrackHeightInterval; + static const double k_track_height_default; + static const double k_track_height_minimum; + static const double k_track_height_interval; - static const QString kBlockInput; - static const QString kMutedInput; - static const QString kArrayMapInput; + static const QString k_block_input; + static const QString k_muted_input; + static const QString k_array_map_input; public slots: - void SetMuted(bool e); + void set_muted(bool e); - void SetLocked(bool e); + void set_locked(bool e); signals: /** * @brief Signal emitted when a Block is added to this Track */ - void BlockAdded(Block *block); + void block_added(Block *block); /** * @brief Signal emitted when a Block is removed from this Track */ - void BlockRemoved(Block *block); + void block_removed(Block *block); /** * @brief Signal emitted when the length of the track has changed */ - void TrackLengthChanged(); + void track_length_changed(); /** * @brief Signal emitted when the height of the track has changed */ - void TrackHeightChanged(qreal virtual_height); + void track_height_changed(qreal virtual_height); /** * @brief Signal emitted when the muted setting changes */ - void MutedChanged(bool e); + void muted_changed(bool e); /** * @brief Signal emitted when the index has changed */ - void IndexChanged(int old, int now); + void index_changed(int old, int now); /** * @brief Emitted when a block changes length and all the subsequent blocks had to update */ - void BlocksRefreshed(); + void blocks_refreshed(); protected: virtual void InputConnectedEvent(const QString &input, int element, @@ -464,21 +464,21 @@ protected: int element) override; private: - void UpdateInOutFrom(int index); + void update_in_out_from(int index); - int GetArrayIndexFromCacheIndex(int index) const; + int get_array_index_from_cache_index(int index) const; - int GetCacheIndexFromArrayIndex(int index) const; + int get_cache_index_from_array_index(int index) const; - int GetBlockIndexAtTime(const rational &time) const; + int get_block_index_at_time(const Rational &time) const; - void ProcessAudioTrack(const NodeValueRow &value, + void process_audio_track(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const; - int ConnectBlock(Block *b); + int connect_block(Block *b); - void UpdateArrayMap(); + void update_array_map(); TimeRangeList block_length_pending_invalidations_; @@ -502,9 +502,9 @@ private: bool ignore_arraymap_set_; private slots: - void BlockLengthChanged(); + void block_length_changed(); - void RefreshBlockCacheFromArrayMap(); + void refresh_block_cache_from_array_map(); }; uint qHash(const Track::Reference &r, uint seed = 0); @@ -515,4 +515,4 @@ QDataStream &operator>>(QDataStream &in, Track::Reference &ref); } -#endif // TRACK_H +#endif // OAK_TRACK_H diff --git a/app/node/output/track/tracklist.cpp b/app/node/output/track/tracklist.cpp index dac924796..5dd236b61 100644 --- a/app/node/output/track/tracklist.cpp +++ b/app/node/output/track/tracklist.cpp @@ -39,7 +39,7 @@ TrackList::TrackList(Sequence *parent, const Track::Type &type, { } -Track *TrackList::GetTrackAt(int index) const +Track *TrackList::get_track_at(int index) const { if (index >= 0 && index < track_cache_.size()) { return track_cache_.at(index); @@ -48,10 +48,10 @@ Track *TrackList::GetTrackAt(int index) const } } -void TrackList::TrackConnected(Node *node, int element) +void TrackList::track_connected(Node *node, int element) { if (element == -1) { - parent()->InvalidateAll(track_input(), element); + parent()->invalidate_all(track_input(), element); return; } @@ -63,9 +63,9 @@ void TrackList::TrackConnected(Node *node, int element) // Determine where in the cache this block will be int cache_index = -1; - for (int i = element + 1; i < ArraySize(); i++) { + for (int i = element + 1; i < array_size(); i++) { // Find next track because this will be the index we insert at - cache_index = GetCacheIndexFromArrayIndex(i); + cache_index = get_cache_index_from_array_index(i); if (cache_index >= 0) { break; @@ -81,33 +81,33 @@ void TrackList::TrackConnected(Node *node, int element) track_array_indexes_.insert(cache_index, element); // Update track indexes in the list (including this track) - UpdateTrackIndexesFrom(cache_index); + update_track_indexes_from(cache_index); - connect(track, &Track::TrackLengthChanged, this, - &TrackList::UpdateTotalLength); + connect(track, &Track::track_length_changed, this, + &TrackList::update_total_length); track_height_connections_.insert( - track, connect(track, &Track::TrackHeightChanged, this, [this]() { + track, connect(track, &Track::track_height_changed, this, [this]() { Track *t = static_cast(sender()); - emit TrackHeightChanged(t, t->GetTrackHeightInPixels()); + emit track_height_changed(t, t->get_track_height_in_pixels()); })); track->set_type(type_); track->set_sequence(parent()); - emit TrackListChanged(); + emit track_list_changed(); // This function must be called after the track is added to track_cache_, since it uses track_cache_ to determine // the track's index - emit TrackAdded(track); + emit track_added(track); - UpdateTotalLength(); + update_total_length(); } -void TrackList::TrackDisconnected(Node *node, int element) +void TrackList::track_disconnected(Node *node, int element) { if (element == -1) { // User has replaced the entire array, we will invalidate everything - parent()->InvalidateAll(track_input(), element); + parent()->invalidate_all(track_input(), element); return; } @@ -118,38 +118,38 @@ void TrackList::TrackDisconnected(Node *node, int element) } // Traverse through Tracks uncaching and disconnecting them - emit TrackRemoved(track); + emit track_removed(track); - int cache_index = GetCacheIndexFromArrayIndex(element); + int cache_index = get_cache_index_from_array_index(element); // Remove track here track_cache_.removeAt(cache_index); track_array_indexes_.removeAt(cache_index); // Update indices for all subsequent tracks - UpdateTrackIndexesFrom(cache_index); + update_track_indexes_from(cache_index); - track->SetIndex(-1); - track->set_type(Track::kNone); + track->set_index(-1); + track->set_type(Track::k_none); track->set_sequence(nullptr); - disconnect(track, &Track::TrackLengthChanged, this, - &TrackList::UpdateTotalLength); + disconnect(track, &Track::track_length_changed, this, + &TrackList::update_total_length); disconnect(track_height_connections_.take(track)); - emit TrackListChanged(); + emit track_list_changed(); - UpdateTotalLength(); + update_total_length(); } -void TrackList::UpdateTrackIndexesFrom(int index) +void TrackList::update_track_indexes_from(int index) { for (int i = index; i < track_cache_.size(); i++) { - track_cache_.at(i)->SetIndex(i); + track_cache_.at(i)->set_index(i); } } -Project *TrackList::GetParentGraph() const +Project *TrackList::get_parent_graph() const { return parent()->parent(); } @@ -169,22 +169,22 @@ Sequence *TrackList::parent() const return static_cast(QObject::parent()); } -int TrackList::ArraySize() const +int TrackList::array_size() const { - return parent()->InputArraySize(track_input()); + return parent()->input_array_size(track_input()); } -void TrackList::ArrayAppend() +void TrackList::array_append() { - parent()->InputArrayAppend(track_input()); + parent()->input_array_append(track_input()); } -void TrackList::ArrayRemoveLast() +void TrackList::array_remove_last() { - parent()->InputArrayRemoveLast(track_input()); + parent()->input_array_remove_last(track_input()); } -void TrackList::UpdateTotalLength() +void TrackList::update_total_length() { total_length_ = 0; @@ -194,7 +194,7 @@ void TrackList::UpdateTotalLength() } } - emit LengthChanged(total_length_); + emit length_changed(total_length_); } } diff --git a/app/node/output/track/tracklist.h b/app/node/output/track/tracklist.h index b5271b30c..a4fd90f2e 100644 --- a/app/node/output/track/tracklist.h +++ b/app/node/output/track/tracklist.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRACKLIST_H -#define TRACKLIST_H +#ifndef OAK_TRACKLIST_H +#define OAK_TRACKLIST_H #include #include @@ -44,41 +44,41 @@ public: return type_; } - const QVector &GetTracks() const + const QVector &get_tracks() const { return track_cache_; } - Track *GetTrackAt(int index) const; + Track *get_track_at(int index) const; - const rational &GetTotalLength() const + const Rational &get_total_length() const { return total_length_; } - int GetTrackCount() const + int get_track_count() const { return track_cache_.size(); } - Project *GetParentGraph() const; + Project *get_parent_graph() const; const QString &track_input() const; NodeInput track_input(int element) const; Sequence *parent() const; - int ArraySize() const; + int array_size() const; - void ArrayAppend(); - void ArrayRemoveLast(); + void array_append(); + void array_remove_last(); - int GetArrayIndexFromCacheIndex(int index) const + int get_array_index_from_cache_index(int index) const { return track_array_indexes_.at(index); } - int GetCacheIndexFromArrayIndex(int index) const + int get_cache_index_from_array_index(int index) const { return track_array_indexes_.indexOf(index); } @@ -87,26 +87,26 @@ public slots: /** * @brief Slot for when the track connection is added */ - void TrackConnected(Node *node, int element); + void track_connected(Node *node, int element); /** * @brief Slot for when the track connection is removed */ - void TrackDisconnected(Node *node, int element); + void track_disconnected(Node *node, int element); signals: - void TrackListChanged(); + void track_list_changed(); - void LengthChanged(const rational &length); + void length_changed(const Rational &length); - void TrackAdded(Track *track); + void track_added(Track *track); - void TrackRemoved(Track *track); + void track_removed(Track *track); - void TrackHeightChanged(Track *track, int height); + void track_height_changed(Track *track, int height); private: - void UpdateTrackIndexesFrom(int index); + void update_track_indexes_from(int index); /** * @brief A cache of connected Tracks @@ -121,7 +121,7 @@ private: QString track_input_; - rational total_length_; + Rational total_length_; enum Track::Type type_; @@ -129,9 +129,9 @@ private slots: /** * @brief Slot for when any of the track's length changes so we can update the length of the tracklist */ - void UpdateTotalLength(); + void update_total_length(); }; } -#endif // TRACKLIST_H +#endif // OAK_TRACKLIST_H diff --git a/app/node/output/viewer/viewer.cpp b/app/node/output/viewer/viewer.cpp index fb77dbea0..8f6e7ea79 100644 --- a/app/node/output/viewer/viewer.cpp +++ b/app/node/output/viewer/viewer.cpp @@ -28,16 +28,16 @@ namespace olive { -const QString ViewerOutput::kVideoParamsInput = +const QString ViewerOutput::k_video_params_input = QStringLiteral("video_param_in"); -const QString ViewerOutput::kAudioParamsInput = +const QString ViewerOutput::k_audio_params_input = QStringLiteral("audio_param_in"); -const QString ViewerOutput::kSubtitleParamsInput = +const QString ViewerOutput::k_subtitle_params_input = QStringLiteral("subtitle_param_in"); -const QString ViewerOutput::kTextureInput = QStringLiteral("tex_in"); -const QString ViewerOutput::kSamplesInput = QStringLiteral("samples_in"); +const QString ViewerOutput::k_texture_input = QStringLiteral("tex_in"); +const QString ViewerOutput::k_samples_input = QStringLiteral("samples_in"); -const SampleFormat ViewerOutput::kDefaultSampleFormat = SampleFormat::F32P; +const SampleFormat ViewerOutput::k_default_sample_format = SampleFormat::f32_p; #define super Node @@ -50,38 +50,38 @@ ViewerOutput::ViewerOutput(bool create_buffer_inputs, , autocache_input_audio_(false) , waveform_requests_enabled_(false) { - AddInput(kVideoParamsInput, NodeValue::kVideoParams, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | - kInputFlagArray | kInputFlagHidden)); + add_input(k_video_params_input, NodeValue::k_video_params, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable | + k_input_flag_array | k_input_flag_hidden)); - AddInput(kAudioParamsInput, NodeValue::kAudioParams, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | - kInputFlagArray | kInputFlagHidden)); + add_input(k_audio_params_input, NodeValue::k_audio_params, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable | + k_input_flag_array | k_input_flag_hidden)); - AddInput(kSubtitleParamsInput, NodeValue::kSubtitleParams, - InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | - kInputFlagArray | kInputFlagHidden)); + add_input(k_subtitle_params_input, NodeValue::k_subtitle_params, + InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable | + k_input_flag_array | k_input_flag_hidden)); if (create_buffer_inputs) { - AddInput(kTextureInput, NodeValue::kTexture, - InputFlags(kInputFlagNotKeyframable)); - AddInput(kSamplesInput, NodeValue::kSamples, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_texture_input, NodeValue::k_texture, + InputFlags(k_input_flag_not_keyframable)); + add_input(k_samples_input, NodeValue::k_samples, + InputFlags(k_input_flag_not_keyframable)); } if (create_default_streams) { - AddStream(Track::kVideo, QVariant()); - AddStream(Track::kAudio, QVariant()); + add_stream(Track::k_video, QVariant()); + add_stream(Track::k_audio, QVariant()); set_default_parameters(); } - SetFlag(kDontShowInParamView); + set_flag(k_dont_show_in_param_view); workarea_ = new TimelineWorkArea(this); markers_ = new TimelineMarkerList(this); } -QString ViewerOutput::Name() const +QString ViewerOutput::name() const { return tr("Viewer"); } @@ -91,12 +91,12 @@ QString ViewerOutput::id() const return QStringLiteral("org.olivevideoeditor.Olive.vieweroutput"); } -QVector ViewerOutput::Category() const +QVector ViewerOutput::category() const { - return { kCategoryOutput }; + return { k_category_output }; } -QString ViewerOutput::Description() const +QString ViewerOutput::description() const { return tr("Interface between a Viewer panel and the node system."); } @@ -104,52 +104,52 @@ QString ViewerOutput::Description() const QVariant ViewerOutput::data(const DataType &d) const { switch (d) { - case DURATION: { - rational using_timebase; + case duration: { + Rational using_timebase; Timecode::Display using_display = - Core::instance()->GetTimecodeDisplay(); + Core::instance()->get_timecode_display(); // Get first enabled streams - VideoParams video = GetFirstEnabledVideoStream(); - AudioParams audio = GetFirstEnabledAudioStream(); - SubtitleParams sub = GetFirstEnabledSubtitleStream(); + VideoParams video = get_first_enabled_video_stream(); + AudioParams audio = get_first_enabled_audio_stream(); + SubtitleParams sub = get_first_enabled_subtitle_stream(); if (video.is_valid() && - video.video_type() != VideoParams::kVideoTypeStill) { + video.video_type() != VideoParams::k_video_type_still) { // Prioritize video using_timebase = video.frame_rate_as_time_base(); } else if (audio.is_valid()) { // Use audio as a backup // If we're showing in a timecode, we prefer showing audio in seconds instead - if (using_display == Timecode::kTimecodeDropFrame || - using_display == Timecode::kTimecodeNonDropFrame) { - using_display = Timecode::kTimecodeSeconds; + if (using_display == Timecode::k_timecode_drop_frame || + using_display == Timecode::k_timecode_non_drop_frame) { + using_display = Timecode::k_timecode_seconds; } using_timebase = audio.sample_rate_as_time_base(); } else if (sub.is_valid()) { using_timebase = - OLIVE_CONFIG("DefaultSequenceFrameRate").value(); + OAK_CONFIG("DefaultSequenceFrameRate").value(); } if (!using_timebase.isNull()) { // Return time transformed to timecode return QString::fromStdString(Timecode::time_to_timecode( - GetLength(), using_timebase, using_display)); + get_length(), using_timebase, using_display)); } break; } - case FREQUENCY_RATE: { + case frequency_rate: { VideoParams video_stream; - if (HasEnabledVideoStreams() && - (video_stream = GetFirstEnabledVideoStream()).video_type() != - VideoParams::kVideoTypeStill) { + if (has_enabled_video_streams() && + (video_stream = get_first_enabled_video_stream()).video_type() != + VideoParams::k_video_type_still) { // This is a video editor, prioritize video streams - return tr("%1 FPS").arg(video_stream.frame_rate().toDouble()); - } else if (HasEnabledAudioStreams()) { + return tr("%1 FPS").arg(video_stream.frame_rate().to_double()); + } else if (has_enabled_audio_streams()) { // No video streams, return audio - AudioParams audio_stream = GetFirstEnabledAudioStream(); + AudioParams audio_stream = get_first_enabled_audio_stream(); return tr("%1 Hz").arg(audio_stream.sample_rate()); } break; @@ -161,27 +161,27 @@ QVariant ViewerOutput::data(const DataType &d) const return super::data(d); } -bool ViewerOutput::HasEnabledVideoStreams() const +bool ViewerOutput::has_enabled_video_streams() const { - return GetFirstEnabledVideoStream().is_valid(); + return get_first_enabled_video_stream().is_valid(); } -bool ViewerOutput::HasEnabledAudioStreams() const +bool ViewerOutput::has_enabled_audio_streams() const { - return GetFirstEnabledAudioStream().is_valid(); + return get_first_enabled_audio_stream().is_valid(); } -bool ViewerOutput::HasEnabledSubtitleStreams() const +bool ViewerOutput::has_enabled_subtitle_streams() const { - return GetFirstEnabledSubtitleStream().is_valid(); + return get_first_enabled_subtitle_stream().is_valid(); } -VideoParams ViewerOutput::GetFirstEnabledVideoStream() const +VideoParams ViewerOutput::get_first_enabled_video_stream() const { - int sz = GetVideoStreamCount(); + int sz = get_video_stream_count(); for (int i = 0; i < sz; i++) { - VideoParams vp = GetVideoParams(i); + VideoParams vp = get_video_params(i); if (vp.enabled()) { return vp; @@ -191,12 +191,12 @@ VideoParams ViewerOutput::GetFirstEnabledVideoStream() const return VideoParams(); } -AudioParams ViewerOutput::GetFirstEnabledAudioStream() const +AudioParams ViewerOutput::get_first_enabled_audio_stream() const { - int sz = GetAudioStreamCount(); + int sz = get_audio_stream_count(); for (int i = 0; i < sz; i++) { - AudioParams ap = GetAudioParams(i); + AudioParams ap = get_audio_params(i); if (ap.enabled()) { return ap; @@ -206,12 +206,12 @@ AudioParams ViewerOutput::GetFirstEnabledAudioStream() const return AudioParams(); } -SubtitleParams ViewerOutput::GetFirstEnabledSubtitleStream() const +SubtitleParams ViewerOutput::get_first_enabled_subtitle_stream() const { - int sz = GetSubtitleStreamCount(); + int sz = get_subtitle_stream_count(); for (int i = 0; i < sz; i++) { - SubtitleParams sp = GetSubtitleParams(i); + SubtitleParams sp = get_subtitle_params(i); if (sp.enabled()) { return sp; @@ -223,88 +223,88 @@ SubtitleParams ViewerOutput::GetFirstEnabledSubtitleStream() const void ViewerOutput::set_default_parameters() { - int width = OLIVE_CONFIG("DefaultSequenceWidth").toInt(); - int height = OLIVE_CONFIG("DefaultSequenceHeight").toInt(); + int width = OAK_CONFIG("DefaultSequenceWidth").toInt(); + int height = OAK_CONFIG("DefaultSequenceHeight").toInt(); - SetVideoParams(VideoParams( + set_video_params(VideoParams( width, height, - OLIVE_CONFIG("DefaultSequenceFrameRate").value(), + OAK_CONFIG("DefaultSequenceFrameRate").value(), static_cast( - OLIVE_CONFIG("OfflinePixelFormat").toInt()), - VideoParams::kInternalChannelCount, - OLIVE_CONFIG("DefaultSequencePixelAspect").value(), - OLIVE_CONFIG("DefaultSequenceInterlacing") + OAK_CONFIG("OfflinePixelFormat").toInt()), + VideoParams::k_internal_channel_count, + OAK_CONFIG("DefaultSequencePixelAspect").value(), + OAK_CONFIG("DefaultSequenceInterlacing") .value(), 1)); - SetAudioParams( - AudioParams(OLIVE_CONFIG("DefaultSequenceAudioFrequency").toInt(), - OLIVE_CONFIG("DefaultSequenceAudioLayout").toULongLong(), - kDefaultSampleFormat)); + set_audio_params( + AudioParams(OAK_CONFIG("DefaultSequenceAudioFrequency").toInt(), + OAK_CONFIG("DefaultSequenceAudioLayout").toULongLong(), + k_default_sample_format)); } -void ViewerOutput::InvalidateCache(const TimeRange &range, const QString &from, +void ViewerOutput::invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) { Q_UNUSED(element) - if (Node *connected = GetConnectedOutput(from, element)) { - if (from == kTextureInput) { + if (Node *connected = get_connected_output(from, element)) { + if (from == k_texture_input) { //connected->thumbnail_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly); if (autocache_input_video_) { - TimeRange max_range = InputTimeAdjustment( - from, element, TimeRange(0, GetVideoLength()), false); - connected->video_frame_cache()->Request( - this, range.Intersected(max_range)); + TimeRange max_range = input_time_adjustment( + from, element, TimeRange(0, get_video_length()), false); + connected->video_frame_cache()->request( + this, range.intersected(max_range)); } - } else if (from == kSamplesInput) { - TimeRange max_range = InputTimeAdjustment( - from, element, TimeRange(0, GetAudioLength()), false); + } else if (from == k_samples_input) { + TimeRange max_range = input_time_adjustment( + from, element, TimeRange(0, get_audio_length()), false); if (waveform_requests_enabled_) { - connected->waveform_cache()->Request( - this, range.Intersected(max_range)); + connected->waveform_cache()->request( + this, range.intersected(max_range)); } if (autocache_input_audio_) { - connected->audio_playback_cache()->Request( - this, range.Intersected(max_range)); + connected->audio_playback_cache()->request( + this, range.intersected(max_range)); } } } - VerifyLength(); + verify_length(); - super::InvalidateCache(range, from, element, options); + super::invalidate_cache(range, from, element, options); } -QVector ViewerOutput::GetEnabledStreamsAsReferences() const +QVector ViewerOutput::get_enabled_streams_as_references() const { QVector refs; { - int vp_sz = GetVideoStreamCount(); + int vp_sz = get_video_stream_count(); for (int i = 0; i < vp_sz; i++) { - if (GetVideoParams(i).enabled()) { - refs.append(Track::Reference(Track::kVideo, i)); + if (get_video_params(i).enabled()) { + refs.append(Track::Reference(Track::k_video, i)); } } } { - int ap_sz = GetAudioStreamCount(); + int ap_sz = get_audio_stream_count(); for (int i = 0; i < ap_sz; i++) { - if (GetAudioParams(i).enabled()) { - refs.append(Track::Reference(Track::kAudio, i)); + if (get_audio_params(i).enabled()) { + refs.append(Track::Reference(Track::k_audio, i)); } } } { - int sp_sz = GetSubtitleStreamCount(); + int sp_sz = get_subtitle_stream_count(); for (int i = 0; i < sp_sz; i++) { - if (GetSubtitleParams(i).enabled()) { - refs.append(Track::Reference(Track::kSubtitle, i)); + if (get_subtitle_params(i).enabled()) { + refs.append(Track::Reference(Track::k_subtitle, i)); } } } @@ -312,54 +312,54 @@ QVector ViewerOutput::GetEnabledStreamsAsReferences() const return refs; } -void ViewerOutput::Retranslate() +void ViewerOutput::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kVideoParamsInput, tr("Video Parameters")); - SetInputName(kAudioParamsInput, tr("Audio Parameters")); - SetInputName(kSubtitleParamsInput, tr("Subtitle Parameters")); + set_input_name(k_video_params_input, tr("Video Parameters")); + set_input_name(k_audio_params_input, tr("Audio Parameters")); + set_input_name(k_subtitle_params_input, tr("Subtitle Parameters")); - if (HasInputWithID(kTextureInput)) { - SetInputName(kTextureInput, tr("Texture")); + if (has_input_with_id(k_texture_input)) { + set_input_name(k_texture_input, tr("Texture")); } - if (HasInputWithID(kSamplesInput)) { - SetInputName(kSamplesInput, tr("Samples")); + if (has_input_with_id(k_samples_input)) { + set_input_name(k_samples_input, tr("Samples")); } } -void ViewerOutput::VerifyLength() +void ViewerOutput::verify_length() { - video_length_ = VerifyLengthInternal(Track::kVideo); + video_length_ = verify_length_internal(Track::k_video); - audio_length_ = VerifyLengthInternal(Track::kAudio); + audio_length_ = verify_length_internal(Track::k_audio); - rational subtitle_length = VerifyLengthInternal(Track::kSubtitle); + Rational subtitle_length = verify_length_internal(Track::k_subtitle); - rational real_length = + Rational real_length = qMax(subtitle_length, qMax(video_length_, audio_length_)); if (real_length != last_length_) { last_length_ = real_length; - emit LengthChanged(last_length_); + emit length_changed(last_length_); } } -void ViewerOutput::SetPlayhead(const rational &t) +void ViewerOutput::set_playhead(const Rational &t) { playhead_ = t; - emit PlayheadChanged(t); + emit playhead_changed(t); } void ViewerOutput::InputConnectedEvent(const QString &input, int element, Node *output) { - if (input == kTextureInput) { - emit TextureInputChanged(); - } else if (input == kSamplesInput) { - connect(output->waveform_cache(), &AudioWaveformCache::Validated, this, - &ViewerOutput::ConnectedWaveformChanged); + if (input == k_texture_input) { + emit texture_input_changed(); + } else if (input == k_samples_input) { + connect(output->waveform_cache(), &AudioWaveformCache::validated, this, + &ViewerOutput::connected_waveform_changed); } super::InputConnectedEvent(input, element, output); @@ -368,111 +368,111 @@ void ViewerOutput::InputConnectedEvent(const QString &input, int element, void ViewerOutput::InputDisconnectedEvent(const QString &input, int element, Node *output) { - if (input == kTextureInput) { - emit TextureInputChanged(); - } else if (input == kSamplesInput) { - disconnect(output->waveform_cache(), &AudioWaveformCache::Validated, - this, &ViewerOutput::ConnectedWaveformChanged); + if (input == k_texture_input) { + emit texture_input_changed(); + } else if (input == k_samples_input) { + disconnect(output->waveform_cache(), &AudioWaveformCache::validated, + this, &ViewerOutput::connected_waveform_changed); } super::InputDisconnectedEvent(input, element, output); } -rational ViewerOutput::VerifyLengthInternal(Track::Type type) const +Rational ViewerOutput::verify_length_internal(Track::Type type) const { NodeTraverser traverser; switch (type) { - case Track::kVideo: - if (IsInputConnected(kTextureInput)) { - NodeValueTable t = traverser.GenerateTable( - GetConnectedOutput(kTextureInput), TimeRange(0, 0)); - rational r = t.Get(NodeValue::kRational, QStringLiteral("length")) - .toRational(); + case Track::k_video: + if (is_input_connected(k_texture_input)) { + NodeValueTable t = traverser.generate_table( + get_connected_output(k_texture_input), TimeRange(0, 0)); + Rational r = t.get(NodeValue::k_rational, QStringLiteral("length")) + .to_rational(); if (!r.isNaN()) { return r; } } break; - case Track::kAudio: - if (IsInputConnected(kSamplesInput)) { - NodeValueTable t = traverser.GenerateTable( - GetConnectedOutput(kSamplesInput), TimeRange(0, 0)); - rational r = t.Get(NodeValue::kRational, QStringLiteral("length")) - .toRational(); + case Track::k_audio: + if (is_input_connected(k_samples_input)) { + NodeValueTable t = traverser.generate_table( + get_connected_output(k_samples_input), TimeRange(0, 0)); + Rational r = t.get(NodeValue::k_rational, QStringLiteral("length")) + .to_rational(); if (!r.isNaN()) { return r; } } break; - case Track::kNone: - case Track::kSubtitle: - case Track::kCount: + case Track::k_none: + case Track::k_subtitle: + case Track::k_count: break; } return 0; } -Node *ViewerOutput::GetConnectedTextureOutput() +Node *ViewerOutput::get_connected_texture_output() { - return GetConnectedOutput(kTextureInput); + return get_connected_output(k_texture_input); } -Node::ValueHint ViewerOutput::GetConnectedTextureValueHint() +Node::ValueHint ViewerOutput::get_connected_texture_value_hint() { - return GetValueHintForInput(kTextureInput); + return get_value_hint_for_input(k_texture_input); } -Node *ViewerOutput::GetConnectedSampleOutput() +Node *ViewerOutput::get_connected_sample_output() { - return GetConnectedOutput(kSamplesInput); + return get_connected_output(k_samples_input); } -Node::ValueHint ViewerOutput::GetConnectedSampleValueHint() +Node::ValueHint ViewerOutput::get_connected_sample_value_hint() { - return GetValueHintForInput(kSamplesInput); + return get_value_hint_for_input(k_samples_input); } -void ViewerOutput::SetWaveformEnabled(bool e) +void ViewerOutput::set_waveform_enabled(bool e) { if ((waveform_requests_enabled_ = e)) { - if (Node *connected = this->GetConnectedSampleOutput()) { - TimeRange max_range = InputTimeAdjustment( - kSamplesInput, -1, TimeRange(0, GetAudioLength()), false); + if (Node *connected = this->get_connected_sample_output()) { + TimeRange max_range = input_time_adjustment( + k_samples_input, -1, TimeRange(0, get_audio_length()), false); TimeRangeList invalid = - connected->waveform_cache()->GetInvalidatedRanges(max_range); + connected->waveform_cache()->get_invalidated_ranges(max_range); for (const TimeRange &r : invalid) { - connected->waveform_cache()->Request(this, r); + connected->waveform_cache()->request(this, r); } } } } -void ViewerOutput::Value(const NodeValueRow &value, const NodeGlobals &globals, +void ViewerOutput::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - if (HasInputWithID(kTextureInput)) { - NodeValue repush = value[kTextureInput]; - repush.set_tag(Track::Reference(Track::kVideo, 0).ToString()); - table->Push(repush); + if (has_input_with_id(k_texture_input)) { + NodeValue repush = value[k_texture_input]; + repush.set_tag(Track::Reference(Track::k_video, 0).to_string()); + table->push(repush); } - if (HasInputWithID(kSamplesInput)) { - NodeValue repush = value[kSamplesInput]; - repush.set_tag(Track::Reference(Track::kAudio, 0).ToString()); - table->Push(repush); + if (has_input_with_id(k_samples_input)) { + NodeValue repush = value[k_samples_input]; + repush.set_tag(Track::Reference(Track::k_audio, 0).to_string()); + table->push(repush); } } -bool ViewerOutput::LoadCustom(QXmlStreamReader *reader, SerializedData *data) +bool ViewerOutput::load_custom(QXmlStreamReader *reader, SerializedData *data) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("markers")) { - if (!this->GetMarkers()->load(reader)) { + if (!this->get_markers()->load(reader)) { return false; } } else if (reader->name() == QStringLiteral("workarea")) { - if (!this->GetWorkArea()->load(reader)) { + if (!this->get_work_area()->load(reader)) { return false; } } else { @@ -483,66 +483,66 @@ bool ViewerOutput::LoadCustom(QXmlStreamReader *reader, SerializedData *data) return true; } -void ViewerOutput::SaveCustom(QXmlStreamWriter *writer) const +void ViewerOutput::save_custom(QXmlStreamWriter *writer) const { writer->writeStartElement(QStringLiteral("workarea")); - this->GetWorkArea()->save(writer); + this->get_work_area()->save(writer); writer->writeEndElement(); // workarea writer->writeStartElement(QStringLiteral("markers")); - this->GetMarkers()->save(writer); + this->get_markers()->save(writer); writer->writeEndElement(); // markers } void ViewerOutput::InputValueChangedEvent(const QString &input, int element) { if (element == 0) { - if (input == kVideoParamsInput) { - VideoParams new_video_params = GetVideoParams(); + if (input == k_video_params_input) { + VideoParams new_video_params = get_video_params(); - bool size_changed = + bool has_size_changed = cached_video_params_.width() != new_video_params.width() || cached_video_params_.height() != new_video_params.height(); - bool frame_rate_changed = cached_video_params_.frame_rate() != + bool has_frame_rate_changed = cached_video_params_.frame_rate() != new_video_params.frame_rate(); - bool pixel_aspect_changed = + bool has_pixel_aspect_changed = cached_video_params_.pixel_aspect_ratio() != new_video_params.pixel_aspect_ratio(); - bool interlacing_changed = cached_video_params_.interlacing() != + bool has_interlacing_changed = cached_video_params_.interlacing() != new_video_params.interlacing(); - if (size_changed) { - emit SizeChanged(new_video_params.width(), + if (has_size_changed) { + emit size_changed(new_video_params.width(), new_video_params.height()); } - if (pixel_aspect_changed) { - emit PixelAspectChanged(new_video_params.pixel_aspect_ratio()); + if (has_pixel_aspect_changed) { + emit pixel_aspect_changed(new_video_params.pixel_aspect_ratio()); } - if (interlacing_changed) { - emit InterlacingChanged(new_video_params.interlacing()); + if (has_interlacing_changed) { + emit interlacing_changed(new_video_params.interlacing()); } - if (frame_rate_changed) { - emit FrameRateChanged(new_video_params.frame_rate()); + if (has_frame_rate_changed) { + emit frame_rate_changed(new_video_params.frame_rate()); } - emit VideoParamsChanged(); + emit video_params_changed(); cached_video_params_ = new_video_params; - } else if (input == kAudioParamsInput) { - AudioParams new_audio_params = GetAudioParams(); + } else if (input == k_audio_params_input) { + AudioParams new_audio_params = get_audio_params(); - bool sample_rate_changed = new_audio_params.sample_rate() != + bool has_sample_rate_changed = new_audio_params.sample_rate() != cached_audio_params_.sample_rate(); - if (sample_rate_changed) { - emit SampleRateChanged(new_audio_params.sample_rate()); + if (has_sample_rate_changed) { + emit sample_rate_changed(new_audio_params.sample_rate()); } - emit AudioParamsChanged(); + emit audio_params_changed(); cached_audio_params_ = new_audio_params; } @@ -555,16 +555,16 @@ void ViewerOutput::set_parameters_from_footage( const QVector footage) { foreach (ViewerOutput *f, footage) { - QVector video_streams = f->GetEnabledVideoStreams(); - QVector audio_streams = f->GetEnabledAudioStreams(); + QVector video_streams = f->get_enabled_video_streams(); + QVector audio_streams = f->get_enabled_audio_streams(); for (int i = 0; i < video_streams.size(); i++) { const VideoParams &s = video_streams.at(i); bool found_video_params = false; - rational using_timebase; + Rational using_timebase; - if (s.video_type() == VideoParams::kVideoTypeStill) { + if (s.video_type() == VideoParams::k_video_type_still) { // If this is a still image, we'll use it's resolution but won't set // `found_video_params` in case something with a frame rate comes along which we'll // prioritize @@ -573,17 +573,17 @@ void ViewerOutput::set_parameters_from_footage( continue; } - using_timebase = GetVideoParams().time_base(); + using_timebase = get_video_params().time_base(); } else { using_timebase = s.frame_rate_as_time_base(); found_video_params = true; } - SetVideoParams( + set_video_params( VideoParams(s.width(), s.height(), using_timebase, static_cast( - OLIVE_CONFIG("OfflinePixelFormat").toInt()), - VideoParams::kInternalChannelCount, + OAK_CONFIG("OfflinePixelFormat").toInt()), + VideoParams::k_internal_channel_count, s.pixel_aspect_ratio(), s.interlacing(), 1)); if (found_video_params) { @@ -593,52 +593,52 @@ void ViewerOutput::set_parameters_from_footage( if (!audio_streams.isEmpty()) { const AudioParams &s = audio_streams.first(); - SetAudioParams(AudioParams(s.sample_rate(), s.channel_layout(), - kDefaultSampleFormat)); + set_audio_params(AudioParams(s.sample_rate(), s.channel_layout(), + k_default_sample_format)); } } } -int ViewerOutput::AddStream(Track::Type type, const QVariant &value) +int ViewerOutput::add_stream(Track::Type type, const QVariant &value) { - return SetStream(type, value, -1); + return set_stream(type, value, -1); } -int ViewerOutput::SetStream(Track::Type type, const QVariant &value, +int ViewerOutput::set_stream(Track::Type type, const QVariant &value, int index_in) { QString id; - if (type == Track::kVideo) { - id = kVideoParamsInput; - } else if (type == Track::kAudio) { - id = kAudioParamsInput; - } else if (type == Track::kSubtitle) { - id = kSubtitleParamsInput; + if (type == Track::k_video) { + id = k_video_params_input; + } else if (type == Track::k_audio) { + id = k_audio_params_input; + } else if (type == Track::k_subtitle) { + id = k_subtitle_params_input; } else { return -1; } // Add another video/audio param to the array for this stream - int index = (index_in == -1) ? InputArraySize(id) : index_in; + int index = (index_in == -1) ? input_array_size(id) : index_in; - if (index >= InputArraySize(id)) { - InputArrayResize(id, index + 1); + if (index >= input_array_size(id)) { + input_array_resize(id, index + 1); } - SetStandardValue(id, value, index); + set_standard_value(id, value, index); return index; } -QVector ViewerOutput::GetEnabledVideoStreams() const +QVector ViewerOutput::get_enabled_video_streams() const { QVector streams; - int vp_sz = GetVideoStreamCount(); + int vp_sz = get_video_stream_count(); for (int i = 0; i < vp_sz; i++) { - VideoParams vp = GetVideoParams(i); + VideoParams vp = get_video_params(i); if (vp.enabled()) { streams.append(vp); @@ -648,14 +648,14 @@ QVector ViewerOutput::GetEnabledVideoStreams() const return streams; } -QVector ViewerOutput::GetEnabledAudioStreams() const +QVector ViewerOutput::get_enabled_audio_streams() const { QVector streams; - int ap_sz = GetAudioStreamCount(); + int ap_sz = get_audio_stream_count(); for (int i = 0; i < ap_sz; i++) { - AudioParams ap = GetAudioParams(i); + AudioParams ap = get_audio_params(i); if (ap.enabled()) { streams.append(ap); diff --git a/app/node/output/viewer/viewer.h b/app/node/output/viewer/viewer.h index a97728e6f..034f2a761 100644 --- a/app/node/output/viewer/viewer.h +++ b/app/node/output/viewer/viewer.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWER_H -#define VIEWER_H +#ifndef OAK_VIEWER_H +#define OAK_VIEWER_H #include "codec/encoder.h" #include "node/node.h" @@ -50,10 +50,10 @@ public: NODE_DEFAULT_FUNCTIONS(ViewerOutput) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; virtual QVariant data(const DataType &d) const override; @@ -61,216 +61,216 @@ public: void set_parameters_from_footage(const QVector footage); - virtual void InvalidateCache(const TimeRange &range, const QString &from, + virtual void invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) override; - VideoParams GetVideoParams(int index = 0) const + VideoParams get_video_params(int index = 0) const { // This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway), // but it does suppress a warning message that we don't need - if (index < InputArraySize(kVideoParamsInput)) { - return GetStandardValue(kVideoParamsInput, index) + if (index < input_array_size(k_video_params_input)) { + return get_standard_value(k_video_params_input, index) .value(); } else { return VideoParams(); } } - AudioParams GetAudioParams(int index = 0) const + AudioParams get_audio_params(int index = 0) const { // This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway), // but it does suppress a warning message that we don't need - if (index < InputArraySize(kAudioParamsInput)) { - return GetStandardValue(kAudioParamsInput, index) + if (index < input_array_size(k_audio_params_input)) { + return get_standard_value(k_audio_params_input, index) .value(); } else { return AudioParams(); } } - SubtitleParams GetSubtitleParams(int index = 0) const + SubtitleParams get_subtitle_params(int index = 0) const { // This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway), // but it does suppress a warning message that we don't need - if (index < InputArraySize(kSubtitleParamsInput)) { - return GetStandardValue(kSubtitleParamsInput, index) + if (index < input_array_size(k_subtitle_params_input)) { + return get_standard_value(k_subtitle_params_input, index) .value(); } else { return SubtitleParams(); } } - const rational &GetPlayhead() + const Rational &get_playhead() { return playhead_; } - void SetVideoParams(const VideoParams &video, int index = 0) + void set_video_params(const VideoParams &video, int index = 0) { - SetStandardValue(kVideoParamsInput, QVariant::fromValue(video), index); + set_standard_value(k_video_params_input, QVariant::fromValue(video), index); } - void SetAudioParams(const AudioParams &audio, int index = 0) + void set_audio_params(const AudioParams &audio, int index = 0) { - SetStandardValue(kAudioParamsInput, QVariant::fromValue(audio), index); + set_standard_value(k_audio_params_input, QVariant::fromValue(audio), index); } - void SetSubtitleParams(const SubtitleParams &subs, int index = 0) + void set_subtitle_params(const SubtitleParams &subs, int index = 0) { - SetStandardValue(kSubtitleParamsInput, QVariant::fromValue(subs), + set_standard_value(k_subtitle_params_input, QVariant::fromValue(subs), index); } - int GetVideoStreamCount() const + int get_video_stream_count() const { - return InputArraySize(kVideoParamsInput); + return input_array_size(k_video_params_input); } - int GetAudioStreamCount() const + int get_audio_stream_count() const { - return InputArraySize(kAudioParamsInput); + return input_array_size(k_audio_params_input); } - int GetSubtitleStreamCount() const + int get_subtitle_stream_count() const { - return InputArraySize(kSubtitleParamsInput); + return input_array_size(k_subtitle_params_input); } - virtual int GetTotalStreamCount() const + virtual int get_total_stream_count() const { - return GetVideoStreamCount() + GetAudioStreamCount() + - GetSubtitleStreamCount(); + return get_video_stream_count() + get_audio_stream_count() + + get_subtitle_stream_count(); } - const AudioWaveformCache *GetConnectedWaveform() + const AudioWaveformCache *get_connected_waveform() { - if (Node *n = GetConnectedSampleOutput()) { + if (Node *n = get_connected_sample_output()) { return n->waveform_cache(); } else { return nullptr; } } - bool HasEnabledVideoStreams() const; - bool HasEnabledAudioStreams() const; - bool HasEnabledSubtitleStreams() const; + bool has_enabled_video_streams() const; + bool has_enabled_audio_streams() const; + bool has_enabled_subtitle_streams() const; - VideoParams GetFirstEnabledVideoStream() const; - AudioParams GetFirstEnabledAudioStream() const; - SubtitleParams GetFirstEnabledSubtitleStream() const; + VideoParams get_first_enabled_video_stream() const; + AudioParams get_first_enabled_audio_stream() const; + SubtitleParams get_first_enabled_subtitle_stream() const; - const rational &GetLength() const + const Rational &get_length() const { return last_length_; } - const rational &GetVideoLength() const + const Rational &get_video_length() const { return video_length_; } - const rational &GetAudioLength() const + const Rational &get_audio_length() const { return audio_length_; } - TimelineWorkArea *GetWorkArea() const + TimelineWorkArea *get_work_area() const { return workarea_; } - TimelineMarkerList *GetMarkers() const + TimelineMarkerList *get_markers() const { return markers_; } - virtual TimeRange GetVideoCacheRange() const override + virtual TimeRange get_video_cache_range() const override { - return TimeRange(0, GetVideoLength()); + return TimeRange(0, get_video_length()); } - virtual TimeRange GetAudioCacheRange() const override + virtual TimeRange get_audio_cache_range() const override { - return TimeRange(0, GetAudioLength()); + return TimeRange(0, get_audio_length()); } - QVector GetEnabledStreamsAsReferences() const; + QVector get_enabled_streams_as_references() const; - QVector GetEnabledVideoStreams() const; + QVector get_enabled_video_streams() const; - QVector GetEnabledAudioStreams() const; + QVector get_enabled_audio_streams() const; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual Node *GetConnectedTextureOutput(); + virtual Node *get_connected_texture_output(); - virtual ValueHint GetConnectedTextureValueHint(); + virtual ValueHint get_connected_texture_value_hint(); - virtual Node *GetConnectedSampleOutput(); + virtual Node *get_connected_sample_output(); - virtual ValueHint GetConnectedSampleValueHint(); + virtual ValueHint get_connected_sample_value_hint(); - void SetWaveformEnabled(bool e); + void set_waveform_enabled(bool e); - bool IsVideoAutoCacheEnabled() const + bool is_video_auto_cache_enabled() const { qDebug() << "sequence ac is a stub"; return false; } - void SetVideoAutoCacheEnabled(bool e) + void set_video_auto_cache_enabled(bool e) { qDebug() << "sequence ac is a stub"; } - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - const EncodingParams &GetLastUsedEncodingParams() const + const EncodingParams &get_last_used_encoding_params() const { return last_used_encoding_params_; } - void SetLastUsedEncodingParams(const EncodingParams &p) + void set_last_used_encoding_params(const EncodingParams &p) { last_used_encoding_params_ = p; } - virtual bool LoadCustom(QXmlStreamReader *reader, + virtual bool load_custom(QXmlStreamReader *reader, SerializedData *data) override; - virtual void SaveCustom(QXmlStreamWriter *writer) const override; + virtual void save_custom(QXmlStreamWriter *writer) const override; - static const QString kVideoParamsInput; - static const QString kAudioParamsInput; - static const QString kSubtitleParamsInput; + static const QString k_video_params_input; + static const QString k_audio_params_input; + static const QString k_subtitle_params_input; - static const QString kTextureInput; - static const QString kSamplesInput; + static const QString k_texture_input; + static const QString k_samples_input; - static const SampleFormat kDefaultSampleFormat; + static const SampleFormat k_default_sample_format; signals: - void FrameRateChanged(const rational &); + void frame_rate_changed(const Rational &); - void LengthChanged(const rational &length); + void length_changed(const Rational &length); - void SizeChanged(int width, int height); + void size_changed(int width, int height); - void PixelAspectChanged(const rational &pixel_aspect); + void pixel_aspect_changed(const Rational &pixel_aspect); - void InterlacingChanged(VideoParams::Interlacing mode); + void interlacing_changed(VideoParams::Interlacing mode); - void VideoParamsChanged(); - void AudioParamsChanged(); + void video_params_changed(); + void audio_params_changed(); - void TextureInputChanged(); + void texture_input_changed(); - void SampleRateChanged(int sr); + void sample_rate_changed(int sr); - void ConnectedWaveformChanged(); + void connected_waveform_changed(); - void PlayheadChanged(const rational &t); + void playhead_changed(const Rational &t); public slots: - void VerifyLength(); + void verify_length(); - void SetPlayhead(const rational &t); + void set_playhead(const Rational &t); protected: virtual void InputConnectedEvent(const QString &input, int element, @@ -279,18 +279,18 @@ protected: virtual void InputDisconnectedEvent(const QString &input, int element, Node *output) override; - virtual rational VerifyLengthInternal(Track::Type type) const; + virtual Rational verify_length_internal(Track::Type type) const; virtual void InputValueChangedEvent(const QString &input, int element) override; - int AddStream(Track::Type type, const QVariant &value); - int SetStream(Track::Type type, const QVariant &value, int index); + int add_stream(Track::Type type, const QVariant &value); + int set_stream(Track::Type type, const QVariant &value, int index); private: - rational last_length_; - rational video_length_; - rational audio_length_; + Rational last_length_; + Rational video_length_; + Rational audio_length_; VideoParams cached_video_params_; @@ -306,9 +306,9 @@ private: bool waveform_requests_enabled_; - rational playhead_; + Rational playhead_; }; } -#endif // VIEWER_H +#endif // OAK_VIEWER_H diff --git a/app/node/param.cpp b/app/node/param.cpp index 359f4e8ca..41b96814e 100644 --- a/app/node/param.cpp +++ b/app/node/param.cpp @@ -28,153 +28,153 @@ namespace olive QString NodeInput::name() const { - if (IsValid()) { - return node_->GetInputName(input_); + if (is_valid()) { + return node_->get_input_name(input_); } else { return QString(); } } -bool NodeInput::IsHidden() const +bool NodeInput::is_hidden() const { - if (IsValid()) { - return node_->IsInputHidden(input_); + if (is_valid()) { + return node_->is_input_hidden(input_); } else { return false; } } -bool NodeInput::IsConnected() const +bool NodeInput::is_connected() const { - if (IsValid()) { - return node_->IsInputConnected(*this); + if (is_valid()) { + return node_->is_input_connected(*this); } else { return false; } } -bool NodeInput::IsKeyframing() const +bool NodeInput::is_keyframing() const { - if (IsValid()) { - return node_->IsInputKeyframing(*this); + if (is_valid()) { + return node_->is_input_keyframing(*this); } else { return false; } } -bool NodeInput::IsArray() const +bool NodeInput::is_array() const { - if (IsValid()) { - return node_->InputIsArray(input_); + if (is_valid()) { + return node_->input_is_array(input_); } else { return false; } } -InputFlags NodeInput::GetFlags() const +InputFlags NodeInput::get_flags() const { - if (IsValid()) { - return node_->GetInputFlags(input_); + if (is_valid()) { + return node_->get_input_flags(input_); } else { - return InputFlags(kInputFlagNormal); + return InputFlags(k_input_flag_normal); } } -QString NodeInput::GetInputName() const +QString NodeInput::get_input_name() const { - if (IsValid()) { - return node_->GetInputName(input_); + if (is_valid()) { + return node_->get_input_name(input_); } else { return QString(); } } -Node *NodeInput::GetConnectedOutput() const +Node *NodeInput::get_connected_output() const { - if (IsValid()) { - return node_->GetConnectedOutput(*this); + if (is_valid()) { + return node_->get_connected_output(*this); } else { return nullptr; } } -NodeValue::Type NodeInput::GetDataType() const +NodeValue::Type NodeInput::get_data_type() const { - if (IsValid()) { - return node_->GetInputDataType(input_); + if (is_valid()) { + return node_->get_input_data_type(input_); } else { - return NodeValue::kNone; + return NodeValue::k_none; } } -QVariant NodeInput::GetDefaultValue() const +QVariant NodeInput::get_default_value() const { - if (IsValid()) { - return node_->GetDefaultValue(input_); + if (is_valid()) { + return node_->get_default_value(input_); } else { return QVariant(); } } -QStringList NodeInput::GetComboBoxStrings() const +QStringList NodeInput::get_combo_box_strings() const { - if (IsValid()) { - return node_->GetComboBoxStrings(input_); + if (is_valid()) { + return node_->get_combo_box_strings(input_); } else { return QStringList(); } } -QVariant NodeInput::GetProperty(const QString &key) const +QVariant NodeInput::get_property(const QString &key) const { - if (IsValid()) { - return node_->GetInputProperty(input_, key); + if (is_valid()) { + return node_->get_input_property(input_, key); } else { return QVariant(); } } -QHash NodeInput::GetProperties() const +QHash NodeInput::get_properties() const { - if (IsValid()) { - return node_->GetInputProperties(input_); + if (is_valid()) { + return node_->get_input_properties(input_); } else { return QHash(); } } -QVariant NodeInput::GetValueAtTime(const rational &time) const +QVariant NodeInput::get_value_at_time(const Rational &time) const { - if (IsValid()) { - return node_->GetValueAtTime(*this, time); + if (is_valid()) { + return node_->get_value_at_time(*this, time); } else { return QVariant(); } } -NodeKeyframe *NodeInput::GetKeyframeAtTimeOnTrack(const rational &time, +NodeKeyframe *NodeInput::get_keyframe_at_time_on_track(const Rational &time, int track) const { - if (IsValid()) { - return node_->GetKeyframeAtTimeOnTrack(*this, time, track); + if (is_valid()) { + return node_->get_keyframe_at_time_on_track(*this, time, track); } else { return nullptr; } } -QVariant NodeInput::GetSplitDefaultValueForTrack(int track) const +QVariant NodeInput::get_split_default_value_for_track(int track) const { - if (IsValid()) { - return node_->GetSplitDefaultValueOnTrack(input_, track); + if (is_valid()) { + return node_->get_split_default_value_on_track(input_, track); } else { return QVariant(); } } -int NodeInput::GetArraySize() const +int NodeInput::get_array_size() const { - if (IsValid() && element_ == -1) { - return node_->InputArraySize(input_); + if (is_valid() && element_ == -1) { + return node_->input_array_size(input_); } else { return 0; } diff --git a/app/node/param.h b/app/node/param.h index bcf6f5aa1..c135a8455 100644 --- a/app/node/param.h +++ b/app/node/param.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAM_H -#define NODEPARAM_H +#ifndef OAK_NODEPARAM_H +#define OAK_NODEPARAM_H #include @@ -34,21 +34,21 @@ class NodeKeyframe; enum InputFlag : uint64_t { /// By default, inputs are keyframable, connectable, and NOT arrays - kInputFlagNormal = 0x0, - kInputFlagArray = 0x1, - kInputFlagNotKeyframable = 0x2, - kInputFlagNotConnectable = 0x4, - kInputFlagHidden = 0x8, - kInputFlagIgnoreInvalidations = 0x10, + k_input_flag_normal = 0x0, + k_input_flag_array = 0x1, + k_input_flag_not_keyframable = 0x2, + k_input_flag_not_connectable = 0x4, + k_input_flag_hidden = 0x8, + k_input_flag_ignore_invalidations = 0x10, - kInputFlagStatic = kInputFlagNotKeyframable | kInputFlagNotConnectable + k_input_flag_static = k_input_flag_not_keyframable | k_input_flag_not_connectable }; class InputFlags { public: explicit InputFlags() { - f_ = kInputFlagNormal; + f_ = k_input_flag_normal; } explicit InputFlags(uint64_t flags) @@ -244,44 +244,44 @@ public: QString name() const; - bool IsValid() const + bool is_valid() const { return node_ && !input_.isEmpty() && element_ >= -1; } - bool IsHidden() const; + bool is_hidden() const; - bool IsConnected() const; + bool is_connected() const; - bool IsKeyframing() const; + bool is_keyframing() const; - bool IsArray() const; + bool is_array() const; - InputFlags GetFlags() const; + InputFlags get_flags() const; - QString GetInputName() const; + QString get_input_name() const; - Node *GetConnectedOutput() const; + Node *get_connected_output() const; - NodeValue::Type GetDataType() const; + NodeValue::Type get_data_type() const; - QVariant GetDefaultValue() const; + QVariant get_default_value() const; - QStringList GetComboBoxStrings() const; + QStringList get_combo_box_strings() const; - QVariant GetProperty(const QString &key) const; - QHash GetProperties() const; + QVariant get_property(const QString &key) const; + QHash get_properties() const; - QVariant GetValueAtTime(const rational &time) const; + QVariant get_value_at_time(const Rational &time) const; - NodeKeyframe *GetKeyframeAtTimeOnTrack(const rational &time, + NodeKeyframe *get_keyframe_at_time_on_track(const Rational &time, int track) const; - QVariant GetSplitDefaultValueForTrack(int track) const; + QVariant get_split_default_value_for_track(int track) const; - int GetArraySize() const; + int get_array_size() const; - void Reset() + void reset() { *this = NodeInput(); } @@ -344,12 +344,12 @@ public: return track_; } - bool IsValid() const + bool is_valid() const { - return input_.IsValid() && track_ >= 0; + return input_.is_valid() && track_ >= 0; } - void Reset() + void reset() { *this = NodeKeyframeTrackReference(); } @@ -368,4 +368,4 @@ uint qHash(const NodeKeyframeTrackReference &i); Q_DECLARE_METATYPE(olive::NodeInput) Q_DECLARE_METATYPE(olive::NodeKeyframeTrackReference) -#endif // NODEPARAM_H +#endif // OAK_NODEPARAM_H diff --git a/app/node/plugins/CMakeLists.txt b/app/node/plugins/CMakeLists.txt index 96a4e60f5..16f49fe94 100644 --- a/app/node/plugins/CMakeLists.txt +++ b/app/node/plugins/CMakeLists.txt @@ -16,7 +16,7 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} - node/plugins/Plugin.h - node/plugins/Plugin.cpp + node/plugins/plugin.h + node/plugins/plugin.cpp PARENT_SCOPE ) diff --git a/app/node/plugins/Plugin.cpp b/app/node/plugins/plugin.cpp similarity index 68% rename from app/node/plugins/Plugin.cpp rename to app/node/plugins/plugin.cpp index b2e4dd319..0d16f0f5a 100644 --- a/app/node/plugins/Plugin.cpp +++ b/app/node/plugins/plugin.cpp @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -#include "Plugin.h" +#include "plugin.h" #include "render/rendermanager.h" #include "render/job/pluginjob.h" -#include "pluginSupport/OlivePluginInstance.h" -#include "common/Current.h" +#include "pluginSupport/oliveplugininstance.h" +#include "common/current.h" #include #include @@ -36,79 +36,79 @@ namespace { QHash> g_plugin_param_defaults; -static bool IsNormalisedCoordSystem(const OFX::Host::Param::Base *param) +static bool is_normalised_coord_system(const OFX::Host::Param::Base *param) { return param->getDefaultCoordinateSystem() == kOfxParamCoordinatesNormalised; } -static void GetProjectExtent(double &xSize, double &ySize) +static void get_project_extent(double &x_size, double &y_size) { - auto &vp = Current::getInstance().currentVideoParams(); - xSize = vp.width() * vp.pixel_aspect_ratio().toDouble(); - ySize = vp.height(); + auto &vp = Current::getInstance().current_video_params(); + x_size = vp.width() * vp.pixel_aspect_ratio().to_double(); + y_size = vp.height(); } -static double ToCanonical(double normalised, double extent) +static double to_canonical(double normalised, double extent) { return extent > 0 ? normalised * extent : normalised; } -QVariant DefaultValueForParam(const OFX::Host::Param::Base *param) +QVariant default_value_for_param(const OFX::Host::Param::Base *param) { if (!param) { return QVariant(); } - const std::string &ofxType = param->getType(); + const std::string &ofx_type = param->getType(); const auto &props = param->getProperties(); - if (ofxType == kOfxParamTypeInteger || ofxType == kOfxParamTypeChoice) { + if (ofx_type == kOfxParamTypeInteger || ofx_type == kOfxParamTypeChoice) { return props.getIntProperty(kOfxParamPropDefault); } - if (ofxType == kOfxParamTypeBoolean) { + if (ofx_type == kOfxParamTypeBoolean) { return props.getIntProperty(kOfxParamPropDefault) != 0; } - if (ofxType == kOfxParamTypeDouble) { + if (ofx_type == kOfxParamTypeDouble) { double val = props.getDoubleProperty(kOfxParamPropDefault); - if (IsNormalisedCoordSystem(param)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - val = ToCanonical(val, xSize); + if (is_normalised_coord_system(param)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + val = to_canonical(val, x_size); } return val; } - if (ofxType == kOfxParamTypeString || ofxType == kOfxParamTypeStrChoice || - ofxType == kOfxParamTypeCustom) { + if (ofx_type == kOfxParamTypeString || ofx_type == kOfxParamTypeStrChoice || + ofx_type == kOfxParamTypeCustom) { return QString::fromStdString( props.getStringProperty(kOfxParamPropDefault)); } - if (ofxType == kOfxParamTypeRGB || ofxType == kOfxParamTypeRGBA) { - const int count = (ofxType == kOfxParamTypeRGBA) ? 4 : 3; + if (ofx_type == kOfxParamTypeRGB || ofx_type == kOfxParamTypeRGBA) { + const int count = (ofx_type == kOfxParamTypeRGBA) ? 4 : 3; double values[4] = { 0.0, 0.0, 0.0, 1.0 }; props.getDoublePropertyN(kOfxParamPropDefault, values, count); const double alpha = (count == 4) ? values[3] : 1.0; return QVariant::fromValue( olive::core::Color(values[0], values[1], values[2], alpha)); } - if (ofxType == kOfxParamTypeDouble2D || ofxType == kOfxParamTypeDouble3D || - ofxType == kOfxParamTypeInteger2D || - ofxType == kOfxParamTypeInteger3D) { - const bool is_double = (ofxType == kOfxParamTypeDouble2D || - ofxType == kOfxParamTypeDouble3D); - const int count = (ofxType == kOfxParamTypeDouble2D || - ofxType == kOfxParamTypeInteger2D) ? + if (ofx_type == kOfxParamTypeDouble2D || ofx_type == kOfxParamTypeDouble3D || + ofx_type == kOfxParamTypeInteger2D || + ofx_type == kOfxParamTypeInteger3D) { + const bool is_double = (ofx_type == kOfxParamTypeDouble2D || + ofx_type == kOfxParamTypeDouble3D); + const int count = (ofx_type == kOfxParamTypeDouble2D || + ofx_type == kOfxParamTypeInteger2D) ? 2 : 3; if (is_double) { double values[3] = { 0.0, 0.0, 0.0 }; props.getDoublePropertyN(kOfxParamPropDefault, values, count); - if (IsNormalisedCoordSystem(param)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - values[0] = ToCanonical(values[0], xSize); - values[1] = ToCanonical(values[1], ySize); + if (is_normalised_coord_system(param)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + values[0] = to_canonical(values[0], x_size); + values[1] = to_canonical(values[1], y_size); if (count == 3) { - values[2] = ToCanonical(values[2], xSize); + values[2] = to_canonical(values[2], x_size); } } if (count == 2) { @@ -123,7 +123,7 @@ QVariant DefaultValueForParam(const OFX::Host::Param::Base *param) } return QVector3D(values[0], values[1], values[2]); } - if (ofxType == kOfxParamTypeBytes) { + if (ofx_type == kOfxParamTypeBytes) { return QByteArray(); } @@ -137,11 +137,11 @@ QVariant DefaultValueForParam(const OFX::Host::Param::Base *param) * Uses heuristics based on label, hint, display range, default values, * and parent group name. */ -QString DeduceColorSemantic(const OFX::Host::Param::Base *param, +QString deduce_color_semantic(const OFX::Host::Param::Base *param, const QHash &group_labels) { - const std::string &ofxType = param->getType(); - if (ofxType != kOfxParamTypeRGB && ofxType != kOfxParamTypeRGBA) { + const std::string &ofx_type = param->getType(); + if (ofx_type != kOfxParamTypeRGB && ofx_type != kOfxParamTypeRGBA) { return QStringLiteral("color"); } @@ -150,18 +150,18 @@ QString DeduceColorSemantic(const OFX::Host::Param::Base *param, const QString name = QString::fromStdString(param->getName()).toLower(); // Rule 1: explicit color keywords → color - static const QStringList kColorKeywords = { + static const QStringList k_color_keywords = { QStringLiteral("color"), QStringLiteral("colour"), QStringLiteral("fill"), QStringLiteral("tint"), QStringLiteral("key") }; - for (const QString &kw : kColorKeywords) { + for (const QString &kw : k_color_keywords) { if (label.contains(kw) || hint.contains(kw) || name.contains(kw)) { return QStringLiteral("color"); } } // Rule 2: explicit scalar/adjustment keywords → scalar - static const QStringList kScalarKeywords = { + static const QStringList k_scalar_keywords = { QStringLiteral("gamma"), QStringLiteral("contrast"), QStringLiteral("gain"), QStringLiteral("offset"), QStringLiteral("saturation"), QStringLiteral("exposure"), @@ -169,7 +169,7 @@ QString DeduceColorSemantic(const OFX::Host::Param::Base *param, QStringLiteral("multiply"), QStringLiteral("scale"), QStringLiteral("pivot") }; - for (const QString &kw : kScalarKeywords) { + for (const QString &kw : k_scalar_keywords) { if (label.contains(kw) || hint.contains(kw) || name.contains(kw)) { return QStringLiteral("scalar"); } @@ -177,7 +177,7 @@ QString DeduceColorSemantic(const OFX::Host::Param::Base *param, // Rule 3: display range significantly outside/asymmetric to [0,1] → scalar const auto &props = param->getProperties(); - const int dim = (ofxType == kOfxParamTypeRGBA) ? 4 : 3; + const int dim = (ofx_type == kOfxParamTypeRGBA) ? 4 : 3; double dmin[4] = { 0, 0, 0, 0 }; double dmax[4] = { 1, 1, 1, 1 }; props.getDoublePropertyN(kOfxParamPropDisplayMin, dmin, dim); @@ -211,7 +211,7 @@ QString DeduceColorSemantic(const OFX::Host::Param::Base *param, const QString parent = QString::fromStdString(param->getParentName()).toLower(); if (!parent.isEmpty()) { - for (const QString &kw : kScalarKeywords) { + for (const QString &kw : k_scalar_keywords) { if (parent.contains(kw)) { return QStringLiteral("scalar"); } @@ -222,14 +222,14 @@ QString DeduceColorSemantic(const OFX::Host::Param::Base *param, return QStringLiteral("color"); } -QHash BuildDefaultValues( +QHash build_default_values( const std::map ¶ms) { QHash defaults; for (const auto ¶m : params) { - const std::string &ofxType = param.second->getType(); - if (ofxType == kOfxParamTypeGroup || ofxType == kOfxParamTypePage || - ofxType == kOfxParamTypePushButton) { + const std::string &ofx_type = param.second->getType(); + if (ofx_type == kOfxParamTypeGroup || ofx_type == kOfxParamTypePage || + ofx_type == kOfxParamTypePushButton) { continue; } const auto &props = param.second->getProperties(); @@ -239,7 +239,7 @@ QHash BuildDefaultValues( if (input_id.isEmpty()) { continue; } - QVariant default_value = DefaultValueForParam(param.second); + QVariant default_value = default_value_for_param(param.second); if (!default_value.isValid()) { continue; } @@ -249,7 +249,7 @@ QHash BuildDefaultValues( } } static QString -ClipLabelForName(const std::string &name, +clip_label_for_name(const std::string &name, const OFX::Host::ImageEffect::ClipDescriptor *desc) { if (name == kOfxImageEffectSimpleSourceClipName) { @@ -298,18 +298,18 @@ olive::plugin::PluginNode::PluginNode(OFX::Host::ImageEffect::Instance *plugin) QString::fromStdString(plugin_instance_->getPlugin()->getIdentifier()); auto defaults_iter = g_plugin_param_defaults.find(plugin_id); if (defaults_iter == g_plugin_param_defaults.end()) { - g_plugin_param_defaults.insert(plugin_id, BuildDefaultValues(params)); + g_plugin_param_defaults.insert(plugin_id, build_default_values(params)); defaults_iter = g_plugin_param_defaults.find(plugin_id); } const QHash &defaults = defaults_iter.value(); for (auto param : params) { - const std::string &ofxType = param.second->getType(); - if (ofxType == kOfxParamTypeGroup) { + const std::string &ofx_type = param.second->getType(); + if (ofx_type == kOfxParamTypeGroup) { const QString name = QString::fromStdString(param.first); const QString label = QString::fromStdString(param.second->getLabel()); group_labels.insert(name, label.isEmpty() ? name : label); - } else if (ofxType == kOfxParamTypePage) { + } else if (ofx_type == kOfxParamTypePage) { const QString name = QString::fromStdString(param.first); const QString label = QString::fromStdString(param.second->getLabel()); @@ -331,40 +331,40 @@ olive::plugin::PluginNode::PluginNode(OFX::Host::ImageEffect::Instance *plugin) } for (auto param : params) { - NodeValue::Type type = NodeValue::kNone; + NodeValue::Type type = NodeValue::k_none; - const std::string &ofxType = param.second->getType(); - if (ofxType == kOfxParamTypeInteger) { - type = NodeValue::kInt; - } else if (ofxType == kOfxParamTypeDouble) { - type = NodeValue::kFloat; - } else if (ofxType == kOfxParamTypeBoolean) { - type = NodeValue::kBoolean; - } else if (ofxType == kOfxParamTypeString) { - type = NodeValue::kText; - } else if (ofxType == kOfxParamTypeRGB || - ofxType == kOfxParamTypeRGBA) { - type = NodeValue::kColor; - } else if (ofxType == kOfxParamTypeChoice) { - type = NodeValue::kCombo; - } else if (ofxType == kOfxParamTypeDouble2D || - ofxType == kOfxParamTypeInteger2D) { - type = NodeValue::kVec2; - } else if (ofxType == kOfxParamTypeDouble3D || - ofxType == kOfxParamTypeInteger3D) { - type = NodeValue::kVec3; - } else if (ofxType == kOfxParamTypeStrChoice) { - type = NodeValue::kStrCombo; - } else if (ofxType == kOfxParamTypeBytes || - ofxType == kOfxParamTypeCustom) { - type = NodeValue::kBinary; - } else if (ofxType == kOfxParamTypePushButton) { - type = NodeValue::kPushButton; - } else if (ofxType == kOfxParamTypeGroup || - ofxType == kOfxParamTypePage) { + const std::string &ofx_type = param.second->getType(); + if (ofx_type == kOfxParamTypeInteger) { + type = NodeValue::k_int; + } else if (ofx_type == kOfxParamTypeDouble) { + type = NodeValue::k_float; + } else if (ofx_type == kOfxParamTypeBoolean) { + type = NodeValue::k_boolean; + } else if (ofx_type == kOfxParamTypeString) { + type = NodeValue::k_text; + } else if (ofx_type == kOfxParamTypeRGB || + ofx_type == kOfxParamTypeRGBA) { + type = NodeValue::k_color; + } else if (ofx_type == kOfxParamTypeChoice) { + type = NodeValue::k_combo; + } else if (ofx_type == kOfxParamTypeDouble2D || + ofx_type == kOfxParamTypeInteger2D) { + type = NodeValue::k_vec2; + } else if (ofx_type == kOfxParamTypeDouble3D || + ofx_type == kOfxParamTypeInteger3D) { + type = NodeValue::k_vec3; + } else if (ofx_type == kOfxParamTypeStrChoice) { + type = NodeValue::k_str_combo; + } else if (ofx_type == kOfxParamTypeBytes || + ofx_type == kOfxParamTypeCustom) { + type = NodeValue::k_binary; + } else if (ofx_type == kOfxParamTypePushButton) { + type = NodeValue::k_push_button; + } else if (ofx_type == kOfxParamTypeGroup || + ofx_type == kOfxParamTypePage) { continue; } else { - type = NodeValue::kNone; + type = NodeValue::k_none; } const QString input_id = @@ -374,57 +374,57 @@ olive::plugin::PluginNode::PluginNode(OFX::Host::ImageEffect::Instance *plugin) } const auto &props = param.second->getProperties(); bool is_secret = props.getIntProperty(kOfxParamPropSecret) != 0; - if (type == NodeValue::kNone) { + if (type == NodeValue::k_none) { continue; } QVariant default_value = defaults.value(input_id, QVariant()); if (default_value.isValid()) { - AddInput(input_id, type, default_value); - if (type != NodeValue::kPushButton) { - SetStandardValue(input_id, default_value); + add_input(input_id, type, default_value); + if (type != NodeValue::k_push_button) { + set_standard_value(input_id, default_value); } } else { - AddInput(input_id, type); + add_input(input_id, type); } if (is_secret) { - SetInputFlag(input_id, kInputFlagHidden); + set_input_flag(input_id, k_input_flag_hidden); } const QString label = QString::fromStdString(param.second->getLabel()); if (!label.isEmpty()) { - SetInputName(input_id, label); + set_input_name(input_id, label); } else { - SetInputName(input_id, input_id); + set_input_name(input_id, input_id); } const QString parent = QString::fromStdString(param.second->getParentName()); if (!parent.isEmpty()) { - SetInputProperty(input_id, QStringLiteral("ui_group"), + set_input_property(input_id, QStringLiteral("ui_group"), group_labels.value(parent, parent)); } if (page_for_param.contains(input_id)) { - SetInputProperty(input_id, QStringLiteral("ui_page"), + set_input_property(input_id, QStringLiteral("ui_page"), page_for_param.value(input_id)); } - if (type == NodeValue::kColor) { - QString semantic = DeduceColorSemantic(param.second, group_labels); - SetInputProperty(input_id, QStringLiteral("color_semantic"), + if (type == NodeValue::k_color) { + QString semantic = deduce_color_semantic(param.second, group_labels); + set_input_property(input_id, QStringLiteral("color_semantic"), semantic); - const int dim = (ofxType == kOfxParamTypeRGBA) ? 4 : 3; + const int dim = (ofx_type == kOfxParamTypeRGBA) ? 4 : 3; double dmin[4] = { 0, 0, 0, 0 }; double dmax[4] = { 1, 1, 1, 1 }; props.getDoublePropertyN(kOfxParamPropDisplayMin, dmin, dim); props.getDoublePropertyN(kOfxParamPropDisplayMax, dmax, dim); - SetInputProperty(input_id, QStringLiteral("min"), dmin[0]); - SetInputProperty(input_id, QStringLiteral("max"), dmax[0]); + set_input_property(input_id, QStringLiteral("min"), dmin[0]); + set_input_property(input_id, QStringLiteral("max"), dmax[0]); const QString hint = QString::fromStdString(param.second->getHint()); if (!hint.isEmpty()) { - SetInputProperty(input_id, QStringLiteral("tooltip"), hint); + set_input_property(input_id, QStringLiteral("tooltip"), hint); } } - if (type == NodeValue::kCombo || type == NodeValue::kStrCombo) { + if (type == NodeValue::k_combo || type == NodeValue::k_str_combo) { QStringList option_labels; QStringList option_values; const int label_count = @@ -478,9 +478,9 @@ olive::plugin::PluginNode::PluginNode(OFX::Host::ImageEffect::Instance *plugin) } if (!option_labels.isEmpty()) { - SetComboBoxStrings(input_id, option_labels); - if (type == NodeValue::kStrCombo) { - SetInputProperty(input_id, + set_combo_box_strings(input_id, option_labels); + if (type == NodeValue::k_str_combo) { + set_input_property(input_id, QStringLiteral("combo_value_str"), option_values); } @@ -494,28 +494,28 @@ olive::plugin::PluginNode::PluginNode(OFX::Host::ImageEffect::Instance *plugin) continue; } QString input_id = QString::fromStdString(entry.first); - AddInput(input_id, NodeValue::kTexture); - SetInputName(input_id, ClipLabelForName(entry.first, entry.second)); + add_input(input_id, NodeValue::k_texture); + set_input_name(input_id, clip_label_for_name(entry.first, entry.second)); has_texture_input = true; } const QString source_id = QString::fromUtf8(kOfxImageEffectSimpleSourceClipName); - if (HasInputWithID(source_id)) { - SetEffectInput(source_id); - } else if (HasInputWithID(kTextureInput)) { - SetEffectInput(kTextureInput); + if (has_input_with_id(source_id)) { + set_effect_input(source_id); + } else if (has_input_with_id(k_texture_input)) { + set_effect_input(k_texture_input); } else { if (has_texture_input) { - AddInput(kTextureInput, NodeValue::kTexture); - SetInputName(kTextureInput, tr("Texture")); - SetEffectInput(kTextureInput); + add_input(k_texture_input, NodeValue::k_texture); + set_input_name(k_texture_input, tr("Texture")); + set_effect_input(k_texture_input); } } } olive::plugin::PluginNode::~PluginNode() = default; -QString olive::plugin::PluginNode::Name() const +QString olive::plugin::PluginNode::name() const { const auto *plugin = plugin_instance_->getPlugin(); return plugin->getDescriptor() @@ -524,17 +524,17 @@ QString olive::plugin::PluginNode::Name() const .data(); } -QVector olive::plugin::PluginNode::Category() const +QVector olive::plugin::PluginNode::category() const { - return { olive::Node::kCategoryOpenFX }; + return { olive::Node::k_category_open_fx }; } -QString olive::plugin::PluginNode::SubCategory() const +QString olive::plugin::PluginNode::sub_category() const { return sub_category_; } -QString olive::plugin::PluginNode::Description() const +QString olive::plugin::PluginNode::description() const { const auto *plugin = plugin_instance_->getPlugin(); return plugin->getDescriptor() @@ -542,7 +542,7 @@ QString olive::plugin::PluginNode::Description() const .getStringProperty(kOfxPropPluginDescription) .data(); } -void olive::plugin::PluginNode::ProcessSamples(const NodeValueRow &values, +void olive::plugin::PluginNode::process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const @@ -575,7 +575,7 @@ void olive::plugin::PluginNode::ProcessSamples(const NodeValueRow &values, } } -void olive::plugin::PluginNode::GenerateFrame(FramePtr frame, +void olive::plugin::PluginNode::generate_frame(FramePtr frame, const GenerateJob &job) const { Q_UNUSED(job) @@ -594,34 +594,34 @@ void olive::plugin::PluginNode::GenerateFrame(FramePtr frame, std::memset(frame->data(), 0, static_cast(frame->allocated_size())); } -void olive::plugin::PluginNode::Value(const NodeValueRow &value, +void olive::plugin::PluginNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { for (auto it = value.cbegin(); it != value.cend(); ++it) { const NodeValue &input_value = it.value(); - if (input_value.type() == NodeValue::kTexture || - input_value.type() == NodeValue::kNone) { + if (input_value.type() == NodeValue::k_texture || + input_value.type() == NodeValue::k_none) { continue; } NodeValue tagged = input_value; tagged.set_tag(it.key()); - table->Push(tagged); + table->push(tagged); } TexturePtr tex = nullptr; const QString source_key = QString::fromUtf8(kOfxImageEffectSimpleSourceClipName); if (value.contains(source_key)) { - tex = value.value(source_key).toTexture(); + tex = value.value(source_key).to_texture(); } if (!tex) { - tex = value.value(kTextureInput).toTexture(); + tex = value.value(k_texture_input).to_texture(); } if (!tex) { for (auto it = value.cbegin(); it != value.cend(); ++it) { - if (it.value().type() == NodeValue::kTexture) { - tex = it.value().toTexture(); + if (it.value().type() == NodeValue::k_texture) { + tex = it.value().to_texture(); if (tex) { break; } @@ -631,10 +631,10 @@ void olive::plugin::PluginNode::Value(const NodeValueRow &value, if (tex && plugin_instance_) { PluginJob job(plugin_instance_, this, value, globals.time().in()); - table->Push(NodeValue::kTexture, tex->toJob(job), this); + table->push(NodeValue::k_texture, tex->to_job(job), this); } } -void olive::plugin::PluginNode::pushButtonClicked(QString name) +void olive::plugin::PluginNode::push_button_clicked(QString name) { } diff --git a/app/node/plugins/Plugin.h b/app/node/plugins/plugin.h similarity index 83% rename from app/node/plugins/Plugin.h rename to app/node/plugins/plugin.h index c46894939..7933b5378 100644 --- a/app/node/plugins/Plugin.h +++ b/app/node/plugins/plugin.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef PLUGIN_NODES_H -#define PLUGIN_NODES_H +#ifndef OAK_PLUGIN_NODES_H +#define OAK_PLUGIN_NODES_H #include "ofxhImageEffectAPI.h" #include "ofxhPluginCache.h" #include "ofxImageEffect.h" @@ -27,18 +27,18 @@ namespace olive { namespace plugin { -const QString kTextureInput = QStringLiteral("tex_in"); +const QString k_texture_input = QStringLiteral("tex_in"); class PluginNode : public olive::Node { public: PluginNode(OFX::Host::ImageEffect::Instance *plugin); ~PluginNode() override; - QString Name() const override; + QString name() const override; QString id() const override; - QVector Category() const override; - QString SubCategory() const override; - QString Description() const override; + QVector category() const override; + QString sub_category() const override; + QString description() const override; Node *copy() const override; /** @@ -54,13 +54,13 @@ public: * corresponding output if it's connected to one. If your node doesn't directly deal with time, the default behavior * of the NodeParam objects will handle everything related to it automatically. */ - void Value(const NodeValueRow &value, const NodeGlobals &globals, + void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; /** * @brief If Value() pushes a ShaderJob, this is the function that will process them. */ - virtual void ProcessSamples(const NodeValueRow &values, + virtual void process_samples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const; @@ -71,13 +71,13 @@ public: * * The destination buffer. It will already be allocated and ready for writing to. */ - virtual void GenerateFrame(FramePtr frame, const GenerateJob &job) const; + virtual void generate_frame(FramePtr frame, const GenerateJob &job) const; private: QString sub_category_; public slots: - void pushButtonClicked(QString name); + void push_button_clicked(QString name); }; } diff --git a/app/node/project.cpp b/app/node/project.cpp index 9084009b0..a5893a4a3 100644 --- a/app/node/project.cpp +++ b/app/node/project.cpp @@ -24,7 +24,7 @@ #include #include -#include "common/Current.h" +#include "common/current.h" #include "common/qtutils.h" #include "common/xmlutils.h" #include "core.h" @@ -32,7 +32,7 @@ #include "node/color/ociobase/ociobase.h" #include "node/factory.h" #include "node/serializeddata.h" -#include "pluginSupport/OliveHost.h" +#include "pluginSupport/olivehost.h" #include "ofxhPluginCache.h" #include "render/diskmanager.h" #include "window/mainwindow/mainwindow.h" @@ -42,18 +42,18 @@ namespace olive #define super QObject -const QString Project::kCacheLocationSettingKey = +const QString Project::k_cache_location_setting_key = QStringLiteral("cachesetting"); -const QString Project::kCachePathKey = QStringLiteral("customcachepath"); -const QString Project::kColorConfigFilename = +const QString Project::k_cache_path_key = QStringLiteral("customcachepath"); +const QString Project::k_color_config_filename = QStringLiteral("colorconfigfilename"); -const QString Project::kDefaultInputColorSpaceKey = +const QString Project::k_default_input_color_space_key = QStringLiteral("defaultinputcolorspace"); -const QString Project::kColorReferenceSpace = +const QString Project::k_color_reference_space = QStringLiteral("colorreferencespace"); -const QString Project::kRootKey = QStringLiteral("root"); +const QString Project::k_root_key = QStringLiteral("root"); -const QString Project::kItemMimeType = +const QString Project::k_item_mime_type = QStringLiteral("application/x-oliveprojectitemdata"); Project::Project() @@ -62,35 +62,35 @@ Project::Project() , autorecovery_saved_(true) { // Generate UUID for this project - RegenerateUuid(); + regenerate_uuid(); // Initialize color manager color_manager_ = new ColorManager(this); - color_manager_->Init(); + color_manager_->init(); } Project::~Project() { - Clear(); + clear(); } -void Project::Initialize() +void Project::initialize() { if (!root_) { root_ = new Folder(); root_->setParent(this); - root_->SetLabel(tr("Root")); - settings_.insert(kRootKey, + root_->set_label(tr("Root")); + settings_.insert(k_root_key, QString::number(reinterpret_cast(root_))); } } -void Project::Clear() +void Project::clear() { // By deleting the last nodes first, we assume that nodes that are most important are deleted last // (e.g. Project's ColorManager or ProjectSettingsNode. for (auto it = node_children_.cbegin(); it != node_children_.cend(); it++) { - (*it)->SetCachesEnabled(false); + (*it)->set_caches_enabled(false); } while (!node_children_.isEmpty()) { @@ -98,17 +98,17 @@ void Project::Clear() } } -SerializedData Project::Load(QXmlStreamReader *reader) +SerializedData Project::load(QXmlStreamReader *reader) { SerializedData data; QSet plugin_paths; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("uuid")) { - this->SetUuid(QUuid::fromString(reader->readElementText())); + this->set_uuid(QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("plugins")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("plugin")) { QString bundle_path; QString file_path; @@ -134,9 +134,9 @@ SerializedData Project::Load(QXmlStreamReader *reader) } if (!plugin_paths.isEmpty()) { - if (!Current::getInstance().pluginHost() || - !Current::getInstance().pluginCache()) { - plugin::loadPlugins(QString()); + if (!Current::getInstance().plugin_host() || + !Current::getInstance().plugin_cache()) { + plugin::load_plugins(QString()); } auto *cache = OFX::Host::PluginCache::getPluginCache(); @@ -144,11 +144,11 @@ SerializedData Project::Load(QXmlStreamReader *reader) cache->addFileToPath(path.toStdString(), true); } cache->scanPluginFiles(); - NodeFactory::RegisterPluginNodes(); + NodeFactory::register_plugin_nodes(); } } else if (reader->name() == QStringLiteral("nodes")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { QString id; @@ -165,16 +165,16 @@ SerializedData Project::Load(QXmlStreamReader *reader) qWarning() << "Failed to load node with empty ID"; reader->skipCurrentElement(); } else { - Node *node = NodeFactory::CreateFromID(id); + Node *node = NodeFactory::create_from_id(id); if (!node) { qWarning() << "Failed to find node with ID" << id; reader->skipCurrentElement(); } else { // Disable cache while node is being loaded (we'll re-enable it later) - node->SetCachesEnabled(false); + node->set_caches_enabled(false); - node->Load(reader, &data); + node->load(reader, &data); node->setParent(this); } @@ -185,10 +185,10 @@ SerializedData Project::Load(QXmlStreamReader *reader) } } else if (reader->name() == QStringLiteral("settings")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { QString key = reader->name().toString(); QString val = reader->readElementText(); - SetSetting(key, val); + set_setting(key, val); } } else { // Skip this @@ -197,13 +197,13 @@ SerializedData Project::Load(QXmlStreamReader *reader) } // Resolve root if applicable - QString root = GetSetting(kRootKey); + QString root = get_setting(k_root_key); if (!root.isEmpty()) { quintptr r = root.toULongLong(); if (Node *n = data.node_ptrs.value(r)) { Q_ASSERT(!root_); root_ = dynamic_cast(n); - SetSetting(kRootKey, + set_setting(k_root_key, QString::number(reinterpret_cast(root_))); } } @@ -211,12 +211,12 @@ SerializedData Project::Load(QXmlStreamReader *reader) return data; } -void Project::Save(QXmlStreamWriter *writer) const +void Project::save(QXmlStreamWriter *writer) const { writer->writeAttribute(QStringLiteral("version"), QString::number(1)); writer->writeTextElement(QStringLiteral("uuid"), - this->GetUuid().toString()); + this->get_uuid().toString()); QVector>> plugins_to_save; { @@ -282,7 +282,7 @@ void Project::Save(QXmlStreamWriter *writer) const foreach (Node *node, this->nodes()) { writer->writeStartElement(QStringLiteral("node")); - node->Save(writer); + node->save(writer); writer->writeEndElement(); // node } @@ -302,12 +302,12 @@ void Project::Save(QXmlStreamWriter *writer) const } } -int Project::GetNumberOfContextsNodeIsIn(Node *node, bool except_itself) const +int Project::get_number_of_contexts_node_is_in(Node *node, bool except_itself) const { int count = 0; foreach (Node *ctx, node_children_) { - if (ctx->ContextContainsNode(node) && (!except_itself || ctx != node)) { + if (ctx->context_contains_node(node) && (!except_itself || ctx != node)) { count++; } } @@ -326,36 +326,36 @@ void Project::childEvent(QChildEvent *event) node_children_.append(node); // Connect signals - connect(node, &Node::InputConnected, this, &Project::InputConnected, + connect(node, &Node::input_connected, this, &Project::input_connected, Qt::DirectConnection); - connect(node, &Node::InputDisconnected, this, - &Project::InputDisconnected, Qt::DirectConnection); - connect(node, &Node::ValueChanged, this, &Project::ValueChanged, + connect(node, &Node::input_disconnected, this, + &Project::input_disconnected, Qt::DirectConnection); + connect(node, &Node::value_changed, this, &Project::value_changed, Qt::DirectConnection); - connect(node, &Node::InputValueHintChanged, this, - &Project::InputValueHintChanged, Qt::DirectConnection); + connect(node, &Node::input_value_hint_changed, this, + &Project::input_value_hint_changed, Qt::DirectConnection); if (NodeGroup *group = dynamic_cast(node)) { - connect(group, &NodeGroup::InputPassthroughAdded, this, - &Project::GroupAddedInputPassthrough, + connect(group, &NodeGroup::input_passthrough_added, this, + &Project::group_added_input_passthrough, Qt::DirectConnection); - connect(group, &NodeGroup::InputPassthroughRemoved, this, - &Project::GroupRemovedInputPassthrough, + connect(group, &NodeGroup::input_passthrough_removed, this, + &Project::group_removed_input_passthrough, Qt::DirectConnection); - connect(group, &NodeGroup::OutputPassthroughChanged, this, - &Project::GroupChangedOutputPassthrough, + connect(group, &NodeGroup::output_passthrough_changed, this, + &Project::group_changed_output_passthrough, Qt::DirectConnection); } - emit NodeAdded(node); - emit node->AddedToGraph(this); + emit node_added(node); + emit node->added_to_graph(this); node->AddedToGraphEvent(this); // Emit input connections for (auto it = node->input_connections().cbegin(); it != node->input_connections().cend(); it++) { if (nodes().contains(it->second)) { - emit InputConnected(it->second, it->first); + emit input_connected(it->second, it->first); } } @@ -363,7 +363,7 @@ void Project::childEvent(QChildEvent *event) for (auto it = node->output_connections().cbegin(); it != node->output_connections().cend(); it++) { if (nodes().contains(it->second.node())) { - emit InputConnected(it->first, it->second); + emit input_connected(it->first, it->second); } } @@ -371,30 +371,30 @@ void Project::childEvent(QChildEvent *event) node_children_.removeOne(node); // Disconnect signals - disconnect(node, &Node::InputConnected, this, - &Project::InputConnected); - disconnect(node, &Node::InputDisconnected, this, - &Project::InputDisconnected); - disconnect(node, &Node::ValueChanged, this, &Project::ValueChanged); - disconnect(node, &Node::InputValueHintChanged, this, - &Project::InputValueHintChanged); + disconnect(node, &Node::input_connected, this, + &Project::input_connected); + disconnect(node, &Node::input_disconnected, this, + &Project::input_disconnected); + disconnect(node, &Node::value_changed, this, &Project::value_changed); + disconnect(node, &Node::input_value_hint_changed, this, + &Project::input_value_hint_changed); if (NodeGroup *group = dynamic_cast(node)) { - disconnect(group, &NodeGroup::InputPassthroughAdded, this, - &Project::GroupAddedInputPassthrough); - disconnect(group, &NodeGroup::InputPassthroughRemoved, this, - &Project::GroupRemovedInputPassthrough); - disconnect(group, &NodeGroup::OutputPassthroughChanged, this, - &Project::GroupChangedOutputPassthrough); + disconnect(group, &NodeGroup::input_passthrough_added, this, + &Project::group_added_input_passthrough); + disconnect(group, &NodeGroup::input_passthrough_removed, this, + &Project::group_removed_input_passthrough); + disconnect(group, &NodeGroup::output_passthrough_changed, this, + &Project::group_changed_output_passthrough); } - emit NodeRemoved(node); - emit node->RemovedFromGraph(this); + emit node_removed(node); + emit node->removed_from_graph(this); node->RemovedFromGraphEvent(this); // Remove from any contexts foreach (Node *context, node_children_) { - context->RemoveNodeFromContext(node); + context->remove_node_from_context(node); } } } @@ -434,7 +434,7 @@ void Project::set_filename(const QString &s) filename_.replace('/', '\\'); #endif - emit NameChanged(); + emit name_changed(); } void Project::set_modified(bool e) @@ -442,7 +442,7 @@ void Project::set_modified(bool e) is_modified_ = e; set_autorecovery_saved(!e); - emit ModifiedChanged(is_modified_); + emit modified_changed(is_modified_); } bool Project::has_autorecovery_been_saved() const @@ -471,19 +471,19 @@ QString Project::get_cache_alongside_project_path() const QString Project::cache_path() const { - CacheSetting setting = GetCacheLocationSetting(); + CacheSetting setting = get_cache_location_setting(); switch (setting) { - case kCacheUseDefaultLocation: + case k_cache_use_default_location: break; - case kCacheCustomPath: { - QString cache_path = GetCustomCachePath(); + case k_cache_custom_path: { + QString cache_path = get_custom_cache_path(); if (!cache_path.isEmpty()) { return cache_path; } break; } - case kCacheStoreAlongsideProject: { + case k_cache_store_alongside_project: { QString alongside = get_cache_alongside_project_path(); if (!alongside.isEmpty()) { return alongside; @@ -492,30 +492,30 @@ QString Project::cache_path() const } } - return DiskManager::instance()->GetDefaultCachePath(); + return DiskManager::instance()->get_default_cache_path(); } -void Project::RegenerateUuid() +void Project::regenerate_uuid() { uuid_ = QUuid::createUuid(); } -Project *Project::GetProjectFromObject(const QObject *o) +Project *Project::get_project_from_object(const QObject *o) { - return QtUtils::GetParentOfType(o); + return QtUtils::get_parent_of_type(o); } -void Project::SetSetting(const QString &key, const QString &value) +void Project::set_setting(const QString &key, const QString &value) { settings_.insert(key, value); - emit SettingChanged(key, value); + emit setting_changed(key, value); - if (key == kColorReferenceSpace) { - emit color_manager_->ReferenceSpaceChanged(value); - } else if (key == kColorConfigFilename) { - color_manager_->UpdateConfigFromFilename(); - } else if (key == kDefaultInputColorSpaceKey) { - emit color_manager_->DefaultInputChanged(value); + if (key == k_color_reference_space) { + emit color_manager_->reference_space_changed(value); + } else if (key == k_color_config_filename) { + color_manager_->update_config_from_filename(); + } else if (key == k_default_input_color_space_key) { + emit color_manager_->default_input_changed(value); } } diff --git a/app/node/project.h b/app/node/project.h index 54b06ddb7..71715f895 100644 --- a/app/node/project.h +++ b/app/node/project.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECT_H -#define PROJECT_H +#ifndef OAK_PROJECT_H +#define OAK_PROJECT_H #include #include @@ -49,9 +49,9 @@ class Project : public QObject { Q_OBJECT public: enum CacheSetting { - kCacheUseDefaultLocation, - kCacheStoreAlongsideProject, - kCacheCustomPath + k_cache_use_default_location, + k_cache_store_alongside_project, + k_cache_custom_path }; Project(); @@ -61,7 +61,7 @@ public: /** * @brief Destructively destroys all nodes in the graph */ - void Clear(); + void clear(); /** * @brief Retrieve a complete list of the nodes belonging to this graph @@ -71,12 +71,12 @@ public: return node_children_; } - void Initialize(); + void initialize(); - SerializedData Load(QXmlStreamReader *reader); - void Save(QXmlStreamWriter *writer) const; + SerializedData load(QXmlStreamReader *reader); + void save(QXmlStreamWriter *writer) const; - int GetNumberOfContextsNodeIsIn(Node *node, + int get_number_of_contexts_node_is_in(Node *node, bool except_itself = false) const; QString name() const; @@ -108,29 +108,29 @@ public: QString get_cache_alongside_project_path() const; QString cache_path() const; - const QUuid &GetUuid() const + const QUuid &get_uuid() const { return uuid_; } - void SetUuid(const QUuid &uuid) + void set_uuid(const QUuid &uuid) { uuid_ = uuid; } - void RegenerateUuid(); + void regenerate_uuid(); /** * @brief Returns the filename the project was saved as, but not necessarily where it is now * * May help for resolving relative paths. */ - const QString &GetSavedURL() const + const QString &get_saved_url() const { return saved_url_; } - void SetSavedURL(const QString &url) + void set_saved_url(const QString &url) { saved_url_ = url; } @@ -141,104 +141,104 @@ public: * If an object is expected to be a child of a project, this function will traverse its parent * tree until it finds it. */ - static Project *GetProjectFromObject(const QObject *o); + static Project *get_project_from_object(const QObject *o); - static void CopySettings(Project *from, Project *to) + static void copy_settings(Project *from, Project *to) { to->settings_ = from->settings_; } - static const QString kItemMimeType; + static const QString k_item_mime_type; - static const QString kCacheLocationSettingKey; - static const QString kCachePathKey; - static const QString kColorConfigFilename; - static const QString kColorReferenceSpace; - static const QString kDefaultInputColorSpaceKey; - static const QString kRootKey; + static const QString k_cache_location_setting_key; + static const QString k_cache_path_key; + static const QString k_color_config_filename; + static const QString k_color_reference_space; + static const QString k_default_input_color_space_key; + static const QString k_root_key; - QString GetSetting(const QString &key) const + QString get_setting(const QString &key) const { return settings_.value(key); } - void SetSetting(const QString &key, const QString &value); + void set_setting(const QString &key, const QString &value); - CacheSetting GetCacheLocationSetting() const + CacheSetting get_cache_location_setting() const { return static_cast( - GetSetting(kCacheLocationSettingKey).toInt()); + get_setting(k_cache_location_setting_key).toInt()); } - void SetCacheLocationSetting(CacheSetting s) + void set_cache_location_setting(CacheSetting s) { - SetSetting(kCacheLocationSettingKey, QString::number(s)); + set_setting(k_cache_location_setting_key, QString::number(s)); } - QString GetCustomCachePath() const + QString get_custom_cache_path() const { - return GetSetting(kCachePathKey); + return get_setting(k_cache_path_key); } - void SetCustomCachePath(const QString &path) + void set_custom_cache_path(const QString &path) { - SetSetting(kCachePathKey, path); + set_setting(k_cache_path_key, path); } - QString GetColorConfigFilename() const + QString get_color_config_filename() const { - return GetSetting(kColorConfigFilename); + return get_setting(k_color_config_filename); } - void SetColorConfigFilename(const QString &s) + void set_color_config_filename(const QString &s) { - SetSetting(kColorConfigFilename, s); + set_setting(k_color_config_filename, s); } - QString GetDefaultInputColorSpace() const + QString get_default_input_color_space() const { - return GetSetting(kDefaultInputColorSpaceKey); + return get_setting(k_default_input_color_space_key); } - void SetDefaultInputColorSpace(const QString &s) + void set_default_input_color_space(const QString &s) { - SetSetting(kDefaultInputColorSpaceKey, s); + set_setting(k_default_input_color_space_key, s); } - QString GetColorReferenceSpace() const + QString get_color_reference_space() const { - return GetSetting(kColorReferenceSpace); + return get_setting(k_color_reference_space); } - void SetColorReferenceSpace(const QString &s) + void set_color_reference_space(const QString &s) { - SetSetting(kColorReferenceSpace, s); + set_setting(k_color_reference_space, s); } signals: - void NameChanged(); + void name_changed(); - void ModifiedChanged(bool e); + void modified_changed(bool e); /** * @brief Signal emitted when a Node is added to the graph */ - void NodeAdded(Node *node); + void node_added(Node *node); /** * @brief Signal emitted when a Node is removed from the graph */ - void NodeRemoved(Node *node); + void node_removed(Node *node); - void InputConnected(Node *output, const NodeInput &input); + void input_connected(Node *output, const NodeInput &input); - void InputDisconnected(Node *output, const NodeInput &input); + void input_disconnected(Node *output, const NodeInput &input); - void ValueChanged(const NodeInput &input); + void value_changed(const NodeInput &input); - void InputValueHintChanged(const NodeInput &input); + void input_value_hint_changed(const NodeInput &input); - void GroupAddedInputPassthrough(NodeGroup *group, const NodeInput &input); + void group_added_input_passthrough(NodeGroup *group, const NodeInput &input); - void GroupRemovedInputPassthrough(NodeGroup *group, const NodeInput &input); + void group_removed_input_passthrough(NodeGroup *group, const NodeInput &input); - void GroupChangedOutputPassthrough(NodeGroup *group, Node *output); + void group_changed_output_passthrough(NodeGroup *group, Node *output); - void SettingChanged(const QString &key, const QString &value); + void setting_changed(const QString &key, const QString &value); protected: virtual void childEvent(QChildEvent *event) override; @@ -265,4 +265,4 @@ private: } -#endif // PROJECT_H +#endif // OAK_PROJECT_H diff --git a/app/node/project/folder/folder.cpp b/app/node/project/folder/folder.cpp index 7d0cd07c9..4756d3c36 100644 --- a/app/node/project/folder/folder.cpp +++ b/app/node/project/folder/folder.cpp @@ -32,41 +32,41 @@ namespace olive #define super Node -const QString Folder::kChildInput = QStringLiteral("child_in"); +const QString Folder::k_child_input = QStringLiteral("child_in"); Folder::Folder() { - SetFlag(kIsItem); + set_flag(k_is_item); - AddInput(kChildInput, NodeValue::kNone, - InputFlags(kInputFlagArray | kInputFlagNotKeyframable)); + add_input(k_child_input, NodeValue::k_none, + InputFlags(k_input_flag_array | k_input_flag_not_keyframable)); } QVariant Folder::data(const DataType &d) const { - if (d == ICON) { - return icon::Folder; + if (d == icon) { + return icon::folder; } return super::data(d); } -void Folder::Retranslate() +void Folder::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kChildInput, tr("Children")); + set_input_name(k_child_input, tr("Children")); } -Node *GetChildWithNameInternal(const Folder *n, const QString &s) +Node *get_child_with_name_internal(const Folder *n, const QString &s) { for (int i = 0; i < n->item_child_count(); i++) { Node *child = n->item_child(i); - if (child->GetLabel() == s) { + if (child->get_label() == s) { return child; } else if (Folder *subfolder = dynamic_cast(child)) { - if (Node *n2 = GetChildWithNameInternal(subfolder, s)) { + if (Node *n2 = get_child_with_name_internal(subfolder, s)) { return n2; } } @@ -75,18 +75,18 @@ Node *GetChildWithNameInternal(const Folder *n, const QString &s) return nullptr; } -Node *Folder::GetChildWithName(const QString &s) const +Node *Folder::get_child_with_name(const QString &s) const { - return GetChildWithNameInternal(this, s); + return get_child_with_name_internal(this, s); } -bool Folder::HasChildRecursive(Node *child) const +bool Folder::has_child_recursive(Node *child) const { for (Node *i : item_children_) { if (i == child) { return true; } else if (Folder *f = dynamic_cast(i)) { - if (f->HasChildRecursive(child)) { + if (f->has_child_recursive(child)) { return true; } } @@ -109,31 +109,31 @@ int Folder::index_of_child_in_array(Node *item) const void Folder::InputConnectedEvent(const QString &input, int element, Node *output) { - if (input == kChildInput && element != -1) { + if (input == k_child_input && element != -1) { Node *item = output; // The insert index is always our "count" because we only support appending in our internal // model. For sorting/organizing, a QSortFilterProxyModel is used instead. - emit BeginInsertItem(item, item_child_count()); + emit begin_insert_item(item, item_child_count()); item_children_.append(item); item_element_index_.append(element); - item->SetFolder(this); - emit EndInsertItem(); + item->set_folder(this); + emit end_insert_item(); } } void Folder::InputDisconnectedEvent(const QString &input, int element, Node *output) { - if (input == kChildInput && element != -1) { + if (input == k_child_input && element != -1) { Node *item = output; int child_index = item_children_.indexOf(item); - emit BeginRemoveItem(item, child_index); + emit begin_remove_item(item, child_index); item_children_.removeAt(child_index); item_element_index_.removeAt(child_index); - item->SetFolder(nullptr); - emit EndRemoveItem(); + item->set_folder(nullptr); + emit end_remove_item(); } } @@ -143,25 +143,25 @@ FolderAddChild::FolderAddChild(Folder *folder, Node *child) { } -Project *FolderAddChild::GetRelevantProject() const +Project *FolderAddChild::get_relevant_project() const { return folder_->project(); } void FolderAddChild::redo() { - int array_index = folder_->InputArraySize(Folder::kChildInput); - folder_->InputArrayAppend(Folder::kChildInput); - Node::ConnectEdge(child_, - NodeInput(folder_, Folder::kChildInput, array_index)); + int array_index = folder_->input_array_size(Folder::k_child_input); + folder_->input_array_append(Folder::k_child_input); + Node::connect_edge(child_, + NodeInput(folder_, Folder::k_child_input, array_index)); } void FolderAddChild::undo() { - Node::DisconnectEdge( - child_, NodeInput(folder_, Folder::kChildInput, - folder_->InputArraySize(Folder::kChildInput) - 1)); - folder_->InputArrayRemoveLast(Folder::kChildInput); + Node::disconnect_edge( + child_, NodeInput(folder_, Folder::k_child_input, + folder_->input_array_size(Folder::k_child_input) - 1)); + folder_->input_array_remove_last(Folder::k_child_input); } void Folder::RemoveElementCommand::redo() @@ -169,13 +169,13 @@ void Folder::RemoveElementCommand::redo() if (!subcommand_) { remove_index_ = folder_->index_of_child_in_array(child_); if (remove_index_ != -1) { - NodeInput connected_input(folder_, Folder::kChildInput, + NodeInput connected_input(folder_, Folder::k_child_input, remove_index_); subcommand_ = new MultiUndoCommand(); subcommand_->add_child(new NodeEdgeRemoveCommand( - folder_->GetConnectedOutput(connected_input), connected_input)); + folder_->get_connected_output(connected_input), connected_input)); subcommand_->add_child(new NodeArrayRemoveCommand( - folder_, Folder::kChildInput, remove_index_)); + folder_, Folder::k_child_input, remove_index_)); } } diff --git a/app/node/project/folder/folder.h b/app/node/project/folder/folder.h index 4317be764..907eb0585 100644 --- a/app/node/project/folder/folder.h +++ b/app/node/project/folder/folder.h @@ -19,8 +19,8 @@ ***/ -#ifndef FOLDER_H -#define FOLDER_H +#ifndef OAK_FOLDER_H +#define OAK_FOLDER_H #include "node/node.h" @@ -40,7 +40,7 @@ public: NODE_DEFAULT_FUNCTIONS(Folder) - virtual QString Name() const override + virtual QString name() const override { return tr("Folder"); } @@ -50,27 +50,27 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.folder"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryProject }; + return { k_category_project }; } - virtual QString Description() const override + virtual QString description() const override { return tr("Organize several items into a single collection."); } virtual QVariant data(const DataType &d) const override; - virtual void Retranslate() override; + virtual void retranslate() override; - Node *GetChildWithName(const QString &s) const; - bool ChildExistsWithName(const QString &s) const + Node *get_child_with_name(const QString &s) const; + bool child_exists_with_name(const QString &s) const { - return GetChildWithName(s); + return get_child_with_name(s); } - bool HasChildRecursive(Node *child) const; + bool has_child_recursive(Node *child) const; int item_child_count() const { @@ -94,7 +94,7 @@ public: int index_of_child_in_array(Node *item) const; - template QVector ListChildrenOfType() const + template QVector list_children_of_type() const { QVector list; @@ -106,14 +106,14 @@ public: Folder *folder_test = dynamic_cast(node); if (folder_test) { - list.append(folder_test->ListChildrenOfType()); + list.append(folder_test->list_children_of_type()); } } return list; } - static const QString kChildInput; + static const QString k_child_input; class RemoveElementCommand : public UndoCommand { public: @@ -129,7 +129,7 @@ public: delete subcommand_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return folder_->project(); } @@ -155,13 +155,13 @@ public: }; signals: - void BeginInsertItem(Node *n, int index); + void begin_insert_item(Node *n, int index); - void EndInsertItem(); + void end_insert_item(); - void BeginRemoveItem(Node *n, int index); + void begin_remove_item(Node *n, int index); - void EndRemoveItem(); + void end_remove_item(); protected: virtual void InputConnectedEvent(const QString &input, int element, @@ -172,7 +172,7 @@ protected: private: template - static void ListOutputsOfTypeInternal(const Folder *n, QVector &list, + static void list_outputs_of_type_internal(const Folder *n, QVector &list, bool recursive) { foreach (const Node::OutputConnection &c, n->output_connections()) { @@ -205,7 +205,7 @@ class FolderAddChild : public UndoCommand { public: FolderAddChild(Folder *folder, Node *child); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -220,4 +220,4 @@ private: } -#endif // FOLDER_H +#endif // OAK_FOLDER_H diff --git a/app/node/project/footage/footage.cpp b/app/node/project/footage/footage.cpp index ae27503f4..fa4462065 100644 --- a/app/node/project/footage/footage.cpp +++ b/app/node/project/footage/footage.cpp @@ -38,7 +38,7 @@ namespace olive { -const QString Footage::kFilenameInput = QStringLiteral("file_in"); +const QString Footage::k_filename_input = QStringLiteral("file_in"); #define super ViewerOutput @@ -47,7 +47,7 @@ Footage::Footage(const QString &filename) , timestamp_(0) , has_source_start_time_(false) , proxy_enabled_(false) - , proxy_state_(ProxyManager::kProxyMissing) + , proxy_state_(ProxyManager::k_proxy_missing) , proxy_video_stream_index_(-1) , proxy_preset_version_(0) , has_custom_proxy_params_(false) @@ -55,13 +55,13 @@ Footage::Footage(const QString &filename) , cancelled_(nullptr) , total_stream_count_(0) { - SetFlag(kIsItem); + set_flag(k_is_item); - PrependInput(kFilenameInput, NodeValue::kFile, - InputFlags(kInputFlagNotConnectable | - kInputFlagNotKeyframable)); + prepend_input(k_filename_input, NodeValue::k_file, + InputFlags(k_input_flag_not_connectable | + k_input_flag_not_keyframable)); - Clear(); + clear(); if (!filename.isEmpty()) { set_filename(filename); @@ -69,50 +69,50 @@ Footage::Footage(const QString &filename) QTimer *check_timer = new QTimer(this); check_timer->setInterval(5000); - connect(check_timer, &QTimer::timeout, this, &Footage::CheckFootage); + connect(check_timer, &QTimer::timeout, this, &Footage::check_footage); check_timer->start(); - connect(this->waveform_cache(), &AudioWaveformCache::Validated, this, - &ViewerOutput::ConnectedWaveformChanged); + connect(this->waveform_cache(), &AudioWaveformCache::validated, this, + &ViewerOutput::connected_waveform_changed); } -void Footage::Retranslate() +void Footage::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kFilenameInput, tr("Filename")); + set_input_name(k_filename_input, tr("Filename")); } void Footage::InputValueChangedEvent(const QString &input, int element) { - if (input == kFilenameInput) { + if (input == k_filename_input) { // Reset internal stream cache - Clear(); + clear(); - Reprobe(); + reprobe(); } else { super::InputValueChangedEvent(input, element); } } -rational Footage::VerifyLengthInternal(Track::Type type) const +Rational Footage::verify_length_internal(Track::Type type) const { - if (type == Track::kVideo) { - VideoParams first_stream = GetFirstEnabledVideoStream(); + if (type == Track::k_video) { + VideoParams first_stream = get_first_enabled_video_stream(); if (first_stream.is_valid()) { return Timecode::timestamp_to_time(first_stream.duration(), first_stream.time_base()); } - } else if (type == Track::kAudio) { - AudioParams first_stream = GetFirstEnabledAudioStream(); + } else if (type == Track::k_audio) { + AudioParams first_stream = get_first_enabled_audio_stream(); if (first_stream.is_valid()) { return Timecode::timestamp_to_time(first_stream.duration(), first_stream.time_base()); } - } else if (type == Track::kSubtitle) { - SubtitleParams first_stream = GetFirstEnabledSubtitleStream(); + } else if (type == Track::k_subtitle) { + SubtitleParams first_stream = get_first_enabled_subtitle_stream(); if (first_stream.is_valid()) { return first_stream.duration(); @@ -122,29 +122,29 @@ rational Footage::VerifyLengthInternal(Track::Type type) const return 0; } -QString Footage::GetColorspaceToUse(const VideoParams ¶ms) const +QString Footage::get_colorspace_to_use(const VideoParams ¶ms) const { if (params.colorspace().isEmpty()) { - return project()->color_manager()->GetDefaultInputColorSpace(); + return project()->color_manager()->get_default_input_color_space(); } else { return params.colorspace(); } } -void Footage::Clear() +void Footage::clear() { // Clear all dynamically created inputs - InputArrayResize(kVideoParamsInput, 0); - InputArrayResize(kAudioParamsInput, 0); - InputArrayResize(kSubtitleParamsInput, 0); + input_array_resize(k_video_params_input, 0); + input_array_resize(k_audio_params_input, 0); + input_array_resize(k_subtitle_params_input, 0); // Clear decoder link decoder_.clear(); has_source_start_time_ = false; - source_start_time_ = rational(); + source_start_time_ = Rational(); source_start_time_source_.clear(); - ClearProxy(); + clear_proxy(); // Clear total stream count total_stream_count_ = 0; @@ -153,19 +153,19 @@ void Footage::Clear() valid_ = false; } -void Footage::SetValid() +void Footage::set_valid() { valid_ = true; } QString Footage::filename() const { - return GetStandardValue(kFilenameInput).toString(); + return get_standard_value(k_filename_input).toString(); } void Footage::set_filename(const QString &s) { - SetStandardValue(kFilenameInput, s); + set_standard_value(k_filename_input, s); } const qint64 &Footage::timestamp() const @@ -178,50 +178,50 @@ void Footage::set_timestamp(const qint64 &t) timestamp_ = t; } -int Footage::GetStreamIndex(Track::Type type, int index) const +int Footage::get_stream_index(Track::Type type, int index) const { switch (type) { - case Track::kVideo: - if (index >= 0 && index < GetVideoStreamCount()) { - return GetVideoParams(index).stream_index(); + case Track::k_video: + if (index >= 0 && index < get_video_stream_count()) { + return get_video_params(index).stream_index(); } break; - case Track::kAudio: - if (index >= 0 && index < GetAudioStreamCount()) { - return GetAudioParams(index).stream_index(); + case Track::k_audio: + if (index >= 0 && index < get_audio_stream_count()) { + return get_audio_params(index).stream_index(); } break; - case Track::kSubtitle: - if (index >= 0 && index < GetSubtitleStreamCount()) { - return GetSubtitleParams(index).stream_index(); + case Track::k_subtitle: + if (index >= 0 && index < get_subtitle_stream_count()) { + return get_subtitle_params(index).stream_index(); } break; - case Track::kNone: - case Track::kCount: + case Track::k_none: + case Track::k_count: break; } return -1; } -Track::Reference Footage::GetReferenceFromRealIndex(int real_index) const +Track::Reference Footage::get_reference_from_real_index(int real_index) const { // Check video streams - for (int i = 0; i < GetVideoStreamCount(); i++) { - if (GetVideoParams(i).stream_index() == real_index) { - return Track::Reference(Track::kVideo, i); + for (int i = 0; i < get_video_stream_count(); i++) { + if (get_video_params(i).stream_index() == real_index) { + return Track::Reference(Track::k_video, i); } } - for (int i = 0; i < GetAudioStreamCount(); i++) { - if (GetAudioParams(i).stream_index() == real_index) { - return Track::Reference(Track::kAudio, i); + for (int i = 0; i < get_audio_stream_count(); i++) { + if (get_audio_params(i).stream_index() == real_index) { + return Track::Reference(Track::k_audio, i); } } - for (int i = 0; i < GetSubtitleStreamCount(); i++) { - if (GetSubtitleParams(i).stream_index() == real_index) { - return Track::Reference(Track::kSubtitle, i); + for (int i = 0; i < get_subtitle_stream_count(); i++) { + if (get_subtitle_params(i).stream_index() == real_index) { + return Track::Reference(Track::k_subtitle, i); } } @@ -233,16 +233,16 @@ const QString &Footage::decoder() const return decoder_; } -void Footage::SetSourceStartTime(const rational &time, const QString &source) +void Footage::set_source_start_time(const Rational &time, const QString &source) { source_start_time_ = time; source_start_time_source_ = source; has_source_start_time_ = true; } -void Footage::ClearSourceStartTime() +void Footage::clear_source_start_time() { - source_start_time_ = rational(); + source_start_time_ = Rational(); source_start_time_source_.clear(); has_source_start_time_ = false; } @@ -255,15 +255,15 @@ void Footage::set_proxy_enabled(bool enabled) if (Project *p = project()) { p->set_modified(true); } - emit ProxySettingsChanged(); + emit proxy_settings_changed(); } } -void Footage::SetProxy(const QString &path, ProxyManager::ProxyState state, +void Footage::set_proxy(const QString &path, ProxyManager::ProxyState state, int video_stream_index, int preset_version, bool enabled) { qDebug() << "Footage::SetProxy:" << filename() << "enabled=" << enabled - << "state=" << ProxyManager::ProxyStateToString(state) + << "state=" << ProxyManager::proxy_state_to_string(state) << "path=" << path; proxy_path_ = path; proxy_state_ = state; @@ -273,30 +273,30 @@ void Footage::SetProxy(const QString &path, ProxyManager::ProxyState state, if (Project *p = project()) { p->set_modified(true); } - emit ProxySettingsChanged(); + emit proxy_settings_changed(); } -void Footage::ClearProxy() +void Footage::clear_proxy() { proxy_enabled_ = false; proxy_path_.clear(); - proxy_state_ = ProxyManager::kProxyMissing; + proxy_state_ = ProxyManager::k_proxy_missing; proxy_video_stream_index_ = -1; proxy_preset_version_ = 0; - emit ProxySettingsChanged(); + emit proxy_settings_changed(); } -void Footage::SetCustomProxyParams(const ProxyManager::ProxyParams ¶ms) +void Footage::set_custom_proxy_params(const ProxyManager::ProxyParams ¶ms) { custom_proxy_params_ = params; has_custom_proxy_params_ = true; if (Project *p = project()) { p->set_modified(true); } - emit ProxySettingsChanged(); + emit proxy_settings_changed(); } -void Footage::ClearCustomProxyParams() +void Footage::clear_custom_proxy_params() { if (has_custom_proxy_params_) { has_custom_proxy_params_ = false; @@ -304,22 +304,22 @@ void Footage::ClearCustomProxyParams() if (Project *p = project()) { p->set_modified(true); } - emit ProxySettingsChanged(); + emit proxy_settings_changed(); } } -ProxyManager::ProxyParams Footage::GetEffectiveProxyParams() const +ProxyManager::ProxyParams Footage::get_effective_proxy_params() const { if (has_custom_proxy_params_) { return custom_proxy_params_; } - return ProxyManager::ProxyParamsFromConfig(); + return ProxyManager::proxy_params_from_config(); } -QString Footage::DescribeVideoStream(const VideoParams ¶ms) +QString Footage::describe_video_stream(const VideoParams ¶ms) { - if (params.video_type() == VideoParams::kVideoTypeStill) { + if (params.video_type() == VideoParams::k_video_type_still) { return tr("%1: Image - %2x%3") .arg(QString::number(params.stream_index()), QString::number(params.width()), @@ -332,7 +332,7 @@ QString Footage::DescribeVideoStream(const VideoParams ¶ms) } } -QString Footage::DescribeAudioStream(const AudioParams ¶ms) +QString Footage::describe_audio_stream(const AudioParams ¶ms) { return tr("%1: Audio - %n Channel(s), %2Hz", nullptr, params.channel_count()) @@ -340,48 +340,48 @@ QString Footage::DescribeAudioStream(const AudioParams ¶ms) QString::number(params.sample_rate())); } -QString Footage::DescribeSubtitleStream(const SubtitleParams ¶ms) +QString Footage::describe_subtitle_stream(const SubtitleParams ¶ms) { return tr("%1: Subtitle").arg(QString::number(params.stream_index())); } -void Footage::Value(const NodeValueRow &value, const NodeGlobals &globals, +void Footage::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { Q_UNUSED(globals) // Pop filename from table - QString file = value[kFilenameInput].toString(); + QString file = value[k_filename_input].to_string(); // If the file exists and the reference is valid, push a footage job to the renderer if (QFileInfo::exists(file)) { // Push length - table->Push(NodeValue::kRational, QVariant::fromValue(GetLength()), + table->push(NodeValue::k_rational, QVariant::fromValue(get_length()), this, QStringLiteral("length")); // Push each stream as a footage job - for (int i = 0; i < GetTotalStreamCount(); i++) { - Track::Reference ref = GetReferenceFromRealIndex(i); + for (int i = 0; i < get_total_stream_count(); i++) { + Track::Reference ref = get_reference_from_real_index(i); FootageJob job(globals.time(), decoder_, filename(), ref.type(), - GetLength(), globals.loop_mode()); + get_length(), globals.loop_mode()); - if (ref.type() == Track::kVideo) { - VideoParams vp = GetVideoParams(ref.index()); + if (ref.type() == Track::k_video) { + VideoParams vp = get_video_params(ref.index()); if (proxy_enabled_ && !proxy_path_.isEmpty() && proxy_video_stream_index_ == vp.stream_index() && - ProxyManager::GetProxyState(proxy_path_) == - ProxyManager::kProxyReady) { + ProxyManager::get_proxy_state(proxy_path_) == + ProxyManager::k_proxy_ready) { job.set_proxy(proxy_path_, QStringLiteral("ffmpeg"), 0); } // Ensure the colorspace is valid and not empty - vp.set_colorspace(GetColorspaceToUse(vp)); + vp.set_colorspace(get_colorspace_to_use(vp)); // Adjust footage job's divider if (globals.vparams().divider() > 1) { // Use a divider appropriate for this target resolution - int calculated = VideoParams::GetDividerForTargetResolution( + int calculated = VideoParams::get_divider_for_target_resolution( vp.width(), vp.height(), globals.vparams().effective_width(), globals.vparams().effective_height()); @@ -394,25 +394,25 @@ void Footage::Value(const NodeValueRow &value, const NodeGlobals &globals, job.set_video_params(vp); - table->Push(NodeValue::kTexture, Texture::Job(vp, job), this, - ref.ToString()); - } else if (ref.type() == Track::kAudio) { - AudioParams ap = GetAudioParams(ref.index()); + table->push(NodeValue::k_texture, Texture::job(vp, job), this, + ref.to_string()); + } else if (ref.type() == Track::k_audio) { + AudioParams ap = get_audio_params(ref.index()); job.set_audio_params(ap); job.set_cache_path(project()->cache_path()); // Proxies generated with audio contain the video stream at // index 0 followed by all source audio streams in source order if (proxy_enabled_ && !proxy_path_.isEmpty() && - ProxyManager::GetProxyState(proxy_path_) == - ProxyManager::kProxyReady && - ProxyManager::ProxyFilenameHasAudio(proxy_path_)) { + ProxyManager::get_proxy_state(proxy_path_) == + ProxyManager::k_proxy_ready && + ProxyManager::proxy_filename_has_audio(proxy_path_)) { int audio_rank = 0; - for (int i = 0; i < GetTotalStreamCount(); i++) { + for (int i = 0; i < get_total_stream_count(); i++) { const Track::Reference other = - GetReferenceFromRealIndex(i); - if (other.type() == Track::kAudio && - GetAudioParams(other.index()).stream_index() < + get_reference_from_real_index(i); + if (other.type() == Track::k_audio && + get_audio_params(other.index()).stream_index() < ap.stream_index()) { audio_rank++; } @@ -421,82 +421,82 @@ void Footage::Value(const NodeValueRow &value, const NodeGlobals &globals, audio_rank + 1); } - table->Push(NodeValue::kSamples, QVariant::fromValue(job), this, - ref.ToString()); + table->push(NodeValue::k_samples, QVariant::fromValue(job), this, + ref.to_string()); } } } } -QString Footage::GetStreamTypeName(Track::Type type) +QString Footage::get_stream_type_name(Track::Type type) { switch (type) { - case Track::kVideo: + case Track::k_video: return tr("Video"); - case Track::kAudio: + case Track::k_audio: return tr("Audio"); - case Track::kSubtitle: + case Track::k_subtitle: return tr("Subtitle"); - case Track::kNone: - case Track::kCount: + case Track::k_none: + case Track::k_count: break; } return tr("Unknown"); } -Node *Footage::GetConnectedTextureOutput() +Node *Footage::get_connected_texture_output() { - if (GetVideoStreamCount() > 0) { + if (get_video_stream_count() > 0) { return this; } else { return nullptr; } } -Node *Footage::GetConnectedSampleOutput() +Node *Footage::get_connected_sample_output() { - if (GetAudioStreamCount() > 0) { + if (get_audio_stream_count() > 0) { return this; } else { return nullptr; } } -bool TimeIsOutOfBounds(const rational &time, const rational &length) +bool time_is_out_of_bounds(const Rational &time, const Rational &length) { return time < 0 || time >= length; } -rational Footage::AdjustTimeByLoopMode(rational time, LoopMode loop_mode, - const rational &length, +Rational Footage::adjust_time_by_loop_mode(Rational time, LoopMode loop_mode, + const Rational &length, VideoParams::Type type, - const rational &timebase) + const Rational &timebase) { - if (type == VideoParams::kVideoTypeStill) { + if (type == VideoParams::k_video_type_still) { // No looping for still images return 0; } - if (TimeIsOutOfBounds(time, length)) { + if (time_is_out_of_bounds(time, length)) { switch (loop_mode) { - case LoopMode::kLoopModeOff: + case LoopMode::k_loop_mode_off: // Return no time to indicate no frame should be shown here - time = rational::NaN; + time = Rational::na_n; break; - case LoopMode::kLoopModeClamp: + case LoopMode::k_loop_mode_clamp: if (length < timebase) { // No full frame fits in the range, so there is nothing to clamp to - time = rational::NaN; + time = Rational::na_n; } else { // Clamp footage time to length - time = std::clamp(time, rational(0), length - timebase); + time = std::clamp(time, Rational(0), length - timebase); } break; - case LoopMode::kLoopModeLoop: + case LoopMode::k_loop_mode_loop: if (length <= 0) { // Cannot loop around an empty range - time = rational::NaN; + time = Rational::na_n; } else { // Loop footage time around job length do { @@ -505,7 +505,7 @@ rational Footage::AdjustTimeByLoopMode(rational time, LoopMode loop_mode, } else { time += length; } - } while (TimeIsOutOfBounds(time, length)); + } while (time_is_out_of_bounds(time, length)); } break; } @@ -517,15 +517,15 @@ rational Footage::AdjustTimeByLoopMode(rational time, LoopMode loop_mode, QVariant Footage::data(const DataType &d) const { switch (d) { - case CREATED_TIME: { + case created_time: { QFileInfo info(filename()); if (info.exists()) { - return QtUtils::GetCreationDate(info).toSecsSinceEpoch(); + return QtUtils::get_creation_date(info).toSecsSinceEpoch(); } break; } - case MODIFIED_TIME: { + case modified_time: { QFileInfo info(filename()); if (info.exists()) { @@ -533,57 +533,57 @@ QVariant Footage::data(const DataType &d) const } break; } - case ICON: { - if (valid_ && GetTotalStreamCount()) { + case icon: { + if (valid_ && get_total_stream_count()) { // Prioritize video > audio > image - VideoParams s = GetFirstEnabledVideoStream(); + VideoParams s = get_first_enabled_video_stream(); if (s.is_valid() && - s.video_type() != VideoParams::kVideoTypeStill) { - return icon::Video; - } else if (HasEnabledAudioStreams()) { - return icon::Audio; + s.video_type() != VideoParams::k_video_type_still) { + return icon::video; + } else if (has_enabled_audio_streams()) { + return icon::audio; } else if (s.is_valid() && - s.video_type() == VideoParams::kVideoTypeStill) { - return icon::Image; - } else if (HasEnabledSubtitleStreams()) { - return icon::Subtitles; + s.video_type() == VideoParams::k_video_type_still) { + return icon::image; + } else if (has_enabled_subtitle_streams()) { + return icon::subtitles; } } - return icon::Error; + return icon::error; } - case TOOLTIP: { + case tooltip: { if (valid_) { QString tip = tr("Filename: %1").arg(filename()); - int vp_sz = GetVideoStreamCount(); + int vp_sz = get_video_stream_count(); for (int i = 0; i < vp_sz; i++) { - VideoParams p = GetVideoParams(i); + VideoParams p = get_video_params(i); if (p.enabled()) { tip.append("\n"); - tip.append(DescribeVideoStream(p)); + tip.append(describe_video_stream(p)); } } - int ap_sz = GetAudioStreamCount(); + int ap_sz = get_audio_stream_count(); for (int i = 0; i < ap_sz; i++) { - AudioParams p = GetAudioParams(i); + AudioParams p = get_audio_params(i); if (p.enabled()) { tip.append("\n"); - tip.append(DescribeAudioStream(p)); + tip.append(describe_audio_stream(p)); } } - int sp_sz = GetSubtitleStreamCount(); + int sp_sz = get_subtitle_stream_count(); for (int i = 0; i < sp_sz; i++) { - SubtitleParams p = GetSubtitleParams(i); + SubtitleParams p = get_subtitle_params(i); if (p.enabled()) { tip.append("\n"); - tip.append(DescribeSubtitleStream(p)); + tip.append(describe_subtitle_stream(p)); } } @@ -599,14 +599,14 @@ QVariant Footage::data(const DataType &d) const return super::data(d); } -bool Footage::LoadCustom(QXmlStreamReader *reader, SerializedData *data) +bool Footage::load_custom(QXmlStreamReader *reader, SerializedData *data) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("timestamp")) { this->set_timestamp(reader->readElementText().toLongLong()); } else if (reader->name() == QStringLiteral("proxy")) { bool enabled = false; - ProxyManager::ProxyState state = ProxyManager::kProxyMissing; + ProxyManager::ProxyState state = ProxyManager::k_proxy_missing; int stream = -1; int preset_version = 0; bool has_custom_params = false; @@ -618,7 +618,7 @@ bool Footage::LoadCustom(QXmlStreamReader *reader, SerializedData *data) enabled = (attr.value() == QStringLiteral("1") || attr.value() == QStringLiteral("true")); } else if (attr.name() == QStringLiteral("state")) { - state = ProxyManager::ProxyStateFromString( + state = ProxyManager::proxy_state_from_string( attr.value().toString()); } else if (attr.name() == QStringLiteral("stream")) { stream = attr.value().toInt(); @@ -647,12 +647,12 @@ bool Footage::LoadCustom(QXmlStreamReader *reader, SerializedData *data) } if (has_custom_params) { - SetCustomProxyParams(custom_params); + set_custom_proxy_params(custom_params); } const QString path = reader->readElementText(); if (!path.isEmpty()) { - SetProxy(path, state, stream, preset_version, enabled); + set_proxy(path, state, stream, preset_version, enabled); } else if (enabled) { set_proxy_enabled(true); } @@ -674,12 +674,12 @@ bool Footage::LoadCustom(QXmlStreamReader *reader, SerializedData *data) const int numerator = split.at(0).toInt(&numerator_ok); const int denominator = split.at(1).toInt(&denominator_ok); if (numerator_ok && denominator_ok && denominator) { - SetSourceStartTime(rational(numerator, denominator), + set_source_start_time(Rational(numerator, denominator), source); } } } else if (reader->name() == QStringLiteral("viewer")) { - if (!ViewerOutput::LoadCustom(reader, data)) { + if (!ViewerOutput::load_custom(reader, data)) { return false; } } else { @@ -690,12 +690,12 @@ bool Footage::LoadCustom(QXmlStreamReader *reader, SerializedData *data) // The cached lengths are not serialized. Recompute them from the stream // parameters that were just loaded so that worker processes and any code // that reads GetLength() before InvalidateCache() runs sees valid values. - VerifyLength(); + verify_length(); return true; } -void Footage::SaveCustom(QXmlStreamWriter *writer) const +void Footage::save_custom(QXmlStreamWriter *writer) const { writer->writeTextElement(QStringLiteral("timestamp"), QString::number(this->timestamp())); @@ -706,7 +706,7 @@ void Footage::SaveCustom(QXmlStreamWriter *writer) const proxy_enabled_ ? QStringLiteral("1") : QStringLiteral("0")); writer->writeAttribute(QStringLiteral("state"), - ProxyManager::ProxyStateToString(proxy_state_)); + ProxyManager::proxy_state_to_string(proxy_state_)); writer->writeAttribute(QStringLiteral("stream"), QString::number(proxy_video_stream_index_)); writer->writeAttribute(QStringLiteral("preset"), @@ -748,36 +748,36 @@ void Footage::SaveCustom(QXmlStreamWriter *writer) const writer->writeStartElement(QStringLiteral("viewer")); - ViewerOutput::SaveCustom(writer); + ViewerOutput::save_custom(writer); writer->writeEndElement(); // viewer } void Footage::AddedToGraphEvent(Project *p) { - connect(p->color_manager(), &ColorManager::DefaultInputChanged, this, - &Footage::DefaultColorSpaceChanged); + connect(p->color_manager(), &ColorManager::default_input_changed, this, + &Footage::default_color_space_changed); if (ProxyManager::instance()) { - connect(ProxyManager::instance(), &ProxyManager::ProxyReady, this, - &Footage::ProxyReady); - connect(ProxyManager::instance(), &ProxyManager::ProxyFinished, this, - &Footage::ProxyFinished); + connect(ProxyManager::instance(), &ProxyManager::proxy_ready, this, + &Footage::proxy_ready); + connect(ProxyManager::instance(), &ProxyManager::proxy_finished, this, + &Footage::proxy_finished); } } void Footage::RemovedFromGraphEvent(Project *p) { - disconnect(p->color_manager(), &ColorManager::DefaultInputChanged, this, - &Footage::DefaultColorSpaceChanged); + disconnect(p->color_manager(), &ColorManager::default_input_changed, this, + &Footage::default_color_space_changed); if (ProxyManager::instance()) { - disconnect(ProxyManager::instance(), &ProxyManager::ProxyReady, this, - &Footage::ProxyReady); - disconnect(ProxyManager::instance(), &ProxyManager::ProxyFinished, this, - &Footage::ProxyFinished); + disconnect(ProxyManager::instance(), &ProxyManager::proxy_ready, this, + &Footage::proxy_ready); + disconnect(ProxyManager::instance(), &ProxyManager::proxy_finished, this, + &Footage::proxy_finished); } } -void Footage::Reprobe() +void Footage::reprobe() { // Determine if file still exists QString filename = this->filename(); @@ -797,91 +797,91 @@ void Footage::Reprobe() QString meta_cache_file = QDir(QStandardPaths::writableLocation( QStandardPaths::CacheLocation)) - .filePath(FileFunctions::GetUniqueFileIdentifier(filename)); + .filePath(FileFunctions::get_unique_file_identifier(filename)); FootageDescription footage_info; // Try to load footage info from cache if (!QFileInfo::exists(meta_cache_file) || - !footage_info.Load(meta_cache_file)) { + !footage_info.load(meta_cache_file)) { // Probe and create cache QVector decoder_list = - Decoder::ReceiveListOfAllDecoders(); + Decoder::receive_list_of_all_decoders(); foreach (DecoderPtr decoder, decoder_list) { - footage_info = decoder->Probe(filename, cancelled_); + footage_info = decoder->probe(filename, cancelled_); - if (footage_info.IsValid()) { + if (footage_info.is_valid()) { break; } } - if (!cancelled_ || !cancelled_->HeardCancel()) { + if (!cancelled_ || !cancelled_->heard_cancel()) { // Only cache successful probes; caching a failed probe // would make every future load re-use the invalid metadata - if (footage_info.IsValid() && - !footage_info.Save(meta_cache_file)) { + if (footage_info.is_valid() && + !footage_info.save(meta_cache_file)) { qWarning() << "Failed to save stream cache, footage will have to be re-probed"; } } } - if (footage_info.IsValid()) { + if (footage_info.is_valid()) { decoder_ = footage_info.decoder(); - InputArrayResize(kVideoParamsInput, - footage_info.GetVideoStreams().size()); - for (int i = 0; i < footage_info.GetVideoStreams().size(); + input_array_resize(k_video_params_input, + footage_info.get_video_streams().size()); + for (int i = 0; i < footage_info.get_video_streams().size(); i++) { VideoParams video_stream = - footage_info.GetVideoStreams().at(i); + footage_info.get_video_streams().at(i); - if (i < InputArraySize(kVideoParamsInput)) { - VideoParams existing = this->GetVideoParams(i); + if (i < input_array_size(k_video_params_input)) { + VideoParams existing = this->get_video_params(i); if (existing.is_valid()) { video_stream = - MergeVideoStream(video_stream, existing); + merge_video_stream(video_stream, existing); } } - SetStream(Track::kVideo, QVariant::fromValue(video_stream), + set_stream(Track::k_video, QVariant::fromValue(video_stream), i); } - InputArrayResize(kAudioParamsInput, - footage_info.GetAudioStreams().size()); - for (int i = 0; i < footage_info.GetAudioStreams().size(); + input_array_resize(k_audio_params_input, + footage_info.get_audio_streams().size()); + for (int i = 0; i < footage_info.get_audio_streams().size(); i++) { - SetStream(Track::kAudio, + set_stream(Track::k_audio, QVariant::fromValue( - footage_info.GetAudioStreams().at(i)), + footage_info.get_audio_streams().at(i)), i); } - InputArrayResize(kSubtitleParamsInput, - footage_info.GetSubtitleStreams().size()); - for (int i = 0; i < footage_info.GetSubtitleStreams().size(); + input_array_resize(k_subtitle_params_input, + footage_info.get_subtitle_streams().size()); + for (int i = 0; i < footage_info.get_subtitle_streams().size(); i++) { - SetStream(Track::kSubtitle, + set_stream(Track::k_subtitle, QVariant::fromValue( - footage_info.GetSubtitleStreams().at(i)), + footage_info.get_subtitle_streams().at(i)), i); } - total_stream_count_ = footage_info.GetStreamCount(); - if (footage_info.HasSourceStartTime()) { - SetSourceStartTime(footage_info.source_start_time(), + total_stream_count_ = footage_info.get_stream_count(); + if (footage_info.has_source_start_time()) { + set_source_start_time(footage_info.source_start_time(), footage_info.source_start_time_source()); } - SetValid(); + set_valid(); } } } } -VideoParams Footage::MergeVideoStream(const VideoParams &base, +VideoParams Footage::merge_video_stream(const VideoParams &base, const VideoParams &over) { VideoParams merged = base; @@ -892,7 +892,7 @@ VideoParams Footage::MergeVideoStream(const VideoParams &base, merged.set_premultiplied_alpha(over.premultiplied_alpha()); merged.set_video_type(over.video_type()); merged.set_color_range(over.color_range()); - if (merged.video_type() == VideoParams::kVideoTypeImageSequence) { + if (merged.video_type() == VideoParams::k_video_type_image_sequence) { merged.set_start_time(over.start_time()); merged.set_duration(over.duration()); merged.set_frame_rate(over.frame_rate()); @@ -902,7 +902,7 @@ VideoParams Footage::MergeVideoStream(const VideoParams &base, return merged; } -void Footage::CheckFootage() +void Footage::check_footage() { // Don't check files if not the active window if (qApp->activeWindow()) { @@ -921,39 +921,39 @@ void Footage::CheckFootage() if (current_file_timestamp != timestamp()) { // File has changed! - Clear(); - Reprobe(); - InvalidateAll(kFilenameInput); + clear(); + reprobe(); + invalidate_all(k_filename_input); } } } } -void Footage::DefaultColorSpaceChanged() +void Footage::default_color_space_changed() { bool inv = false; - int sz = GetVideoStreamCount(); + int sz = get_video_stream_count(); for (int i = 0; i < sz; i++) { // Check if any of our streams are using the default colorspace - if (GetVideoParams(i).colorspace().isEmpty()) { + if (get_video_params(i).colorspace().isEmpty()) { inv = true; break; } } if (inv) { - InvalidateAll(kVideoParamsInput); + invalidate_all(k_video_params_input); } } -void Footage::ProxyReady(const QString &source_filename, int stream_index, +void Footage::proxy_ready(const QString &source_filename, int stream_index, const QString &proxy_filename) { - ProxyFinished(source_filename, stream_index, proxy_filename, - ProxyManager::kProxyReady); + proxy_finished(source_filename, stream_index, proxy_filename, + ProxyManager::k_proxy_ready); } -void Footage::ProxyFinished(const QString &source_filename, int stream_index, +void Footage::proxy_finished(const QString &source_filename, int stream_index, const QString &proxy_filename, ProxyManager::ProxyState state) { @@ -964,7 +964,7 @@ void Footage::ProxyFinished(const QString &source_filename, int stream_index, } proxy_state_ = state; - InvalidateAll(kFilenameInput); + invalidate_all(k_filename_input); } } diff --git a/app/node/project/footage/footage.h b/app/node/project/footage/footage.h index 1557c78c6..4d3eb02a3 100644 --- a/app/node/project/footage/footage.h +++ b/app/node/project/footage/footage.h @@ -19,8 +19,8 @@ ***/ -#ifndef FOOTAGE_H -#define FOOTAGE_H +#ifndef OAK_FOOTAGE_H +#define OAK_FOOTAGE_H #include #include @@ -53,7 +53,7 @@ public: NODE_DEFAULT_FUNCTIONS(Footage) - virtual QString Name() const override + virtual QString name() const override { return tr("Media"); } @@ -63,18 +63,18 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.footage"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryProject }; + return { k_category_project }; } - virtual QString Description() const override + virtual QString description() const override { return tr( "Import video, audio, or still image files into the composition."); } - virtual void Retranslate() override; + virtual void retranslate() override; /** * @brief Reset Footage state ready for running through Probe() again @@ -86,9 +86,9 @@ public: * In most cases, you'll be using olive::ProbeMedia() for re-probing which already runs Clear(), so you won't need * to worry about this. */ - void Clear(); + void clear(); - bool IsValid() const + bool is_valid() const { return valid_; } @@ -96,7 +96,7 @@ public: /** * @brief Sets this footage to valid and ready to use */ - void SetValid(); + void set_valid(); /** * @brief Return the current filename of this Footage object @@ -134,18 +134,18 @@ public: */ void set_timestamp(const qint64 &t); - void SetCancelPointer(CancelAtom *c) + void set_cancel_pointer(CancelAtom *c) { cancelled_ = c; } - int GetStreamIndex(Track::Type type, int index) const; - int GetStreamIndex(const Track::Reference &ref) const + int get_stream_index(Track::Type type, int index) const; + int get_stream_index(const Track::Reference &ref) const { - return GetStreamIndex(ref.type(), ref.index()); + return get_stream_index(ref.type(), ref.index()); } - Track::Reference GetReferenceFromRealIndex(int real_index) const; + Track::Reference get_reference_from_real_index(int real_index) const; /** * @brief Get the Decoder ID set when this Footage was probed @@ -156,12 +156,12 @@ public: */ const QString &decoder() const; - bool HasSourceStartTime() const + bool has_source_start_time() const { return has_source_start_time_; } - const rational &source_start_time() const + const Rational &source_start_time() const { return source_start_time_; } @@ -171,12 +171,12 @@ public: return source_start_time_source_; } - void SetSourceStartTime(const rational &time, const QString &source); + void set_source_start_time(const Rational &time, const QString &source); /** * @brief Removes any source start time (auto-detected or manual) */ - void ClearSourceStartTime(); + void clear_source_start_time(); bool proxy_enabled() const { @@ -205,10 +205,10 @@ public: return proxy_state_; } - void SetProxy(const QString &path, ProxyManager::ProxyState state, + void set_proxy(const QString &path, ProxyManager::ProxyState state, int video_stream_index, int preset_version, bool enabled); - void ClearProxy(); + void clear_proxy(); /** * @brief Returns true if this footage uses its own proxy parameters @@ -227,53 +227,53 @@ public: /** * @brief Sets per-footage proxy parameters, overriding the global settings */ - void SetCustomProxyParams(const ProxyManager::ProxyParams ¶ms); + void set_custom_proxy_params(const ProxyManager::ProxyParams ¶ms); /** * @brief Reverts this footage to using the global proxy settings */ - void ClearCustomProxyParams(); + void clear_custom_proxy_params(); /** * @brief Returns the custom proxy parameters if set, otherwise the * parameters from the global application config */ - ProxyManager::ProxyParams GetEffectiveProxyParams() const; + ProxyManager::ProxyParams get_effective_proxy_params() const; - static QString DescribeVideoStream(const VideoParams ¶ms); - static QString DescribeAudioStream(const AudioParams ¶ms); - static QString DescribeSubtitleStream(const SubtitleParams ¶ms); + static QString describe_video_stream(const VideoParams ¶ms); + static QString describe_audio_stream(const AudioParams ¶ms); + static QString describe_subtitle_stream(const SubtitleParams ¶ms); - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static QString GetStreamTypeName(Track::Type type); + static QString get_stream_type_name(Track::Type type); - virtual Node *GetConnectedTextureOutput() override; + virtual Node *get_connected_texture_output() override; - virtual Node *GetConnectedSampleOutput() override; + virtual Node *get_connected_sample_output() override; - static rational AdjustTimeByLoopMode(rational time, LoopMode loop_mode, - const rational &length, + static Rational adjust_time_by_loop_mode(Rational time, LoopMode loop_mode, + const Rational &length, VideoParams::Type type, - const rational &timebase); + const Rational &timebase); virtual QVariant data(const DataType &d) const override; - virtual int GetTotalStreamCount() const override + virtual int get_total_stream_count() const override { return total_stream_count_; } - virtual bool LoadCustom(QXmlStreamReader *reader, + virtual bool load_custom(QXmlStreamReader *reader, SerializedData *data) override; - virtual void SaveCustom(QXmlStreamWriter *writer) const override; + virtual void save_custom(QXmlStreamWriter *writer) const override; signals: - void ProxySettingsChanged(); + void proxy_settings_changed(); public: - static const QString kFilenameInput; + static const QString k_filename_input; virtual void AddedToGraphEvent(Project *p) override; virtual void RemovedFromGraphEvent(Project *p) override; @@ -282,14 +282,14 @@ protected: virtual void InputValueChangedEvent(const QString &input, int element) override; - virtual rational VerifyLengthInternal(Track::Type type) const override; + virtual Rational verify_length_internal(Track::Type type) const override; private: - QString GetColorspaceToUse(const VideoParams ¶ms) const; + QString get_colorspace_to_use(const VideoParams ¶ms) const; - void Reprobe(); + void reprobe(); - VideoParams MergeVideoStream(const VideoParams &base, + VideoParams merge_video_stream(const VideoParams &base, const VideoParams &over); /** @@ -302,7 +302,7 @@ private: */ QString decoder_; - rational source_start_time_; + Rational source_start_time_; QString source_start_time_source_; @@ -329,17 +329,17 @@ private: int total_stream_count_; private slots: - void CheckFootage(); + void check_footage(); - void DefaultColorSpaceChanged(); + void default_color_space_changed(); - void ProxyReady(const QString &source_filename, int stream_index, + void proxy_ready(const QString &source_filename, int stream_index, const QString &proxy_filename); - void ProxyFinished(const QString &source_filename, int stream_index, + void proxy_finished(const QString &source_filename, int stream_index, const QString &proxy_filename, ProxyManager::ProxyState state); }; } -#endif // FOOTAGE_H +#endif // OAK_FOOTAGE_H diff --git a/app/node/project/footage/footagedescription.cpp b/app/node/project/footage/footagedescription.cpp index 28f88a46b..3a21aca9e 100644 --- a/app/node/project/footage/footagedescription.cpp +++ b/app/node/project/footage/footagedescription.cpp @@ -31,7 +31,7 @@ namespace olive { -bool FootageDescription::Load(const QString &filename) +bool FootageDescription::load(const QString &filename) { // Reset self *this = FootageDescription(); @@ -43,7 +43,7 @@ bool FootageDescription::Load(const QString &filename) bool found_streamcache = false; - while (XMLReadNextStartElement(&reader)) { + while (xml_read_next_start_element(&reader)) { if (reader.name() == QStringLiteral("streamcache")) { found_streamcache = true; // Default to first version of metadata (which wasn't versioned at all) @@ -58,12 +58,12 @@ bool FootageDescription::Load(const QString &filename) } } - if (version != kFootageMetaVersion) { + if (version != k_footage_meta_version) { // If this is a different version, discard so we can probe new data return false; } - while (XMLReadNextStartElement(&reader)) { + while (xml_read_next_start_element(&reader)) { if (reader.name() == QStringLiteral("decoder")) { decoder_ = reader.readElementText(); } else if (reader.name() == @@ -81,7 +81,7 @@ bool FootageDescription::Load(const QString &filename) const QStringList split = reader.readElementText().split('/'); if (split.size() == 2) { - SetSourceStartTime(rational(split.at(0).toInt(), + set_source_start_time(Rational(split.at(0).toInt(), split.at(1).toInt()), source); } @@ -95,21 +95,21 @@ bool FootageDescription::Load(const QString &filename) } } - while (XMLReadNextStartElement(&reader)) { + while (xml_read_next_start_element(&reader)) { if (reader.name() == QStringLiteral("video")) { VideoParams vp; - vp.Load(&reader); - AddVideoStream(vp); + vp.load(&reader); + add_video_stream(vp); } else if (reader.name() == QStringLiteral("audio")) { AudioParams ap = - TypeSerializer::LoadAudioParams(&reader); - AddAudioStream(ap); + TypeSerializer::load_audio_params(&reader); + add_audio_stream(ap); } else if (reader.name() == QStringLiteral("subtitle")) { SubtitleParams sp; - sp.Load(&reader); - AddSubtitleStream(sp); + sp.load(&reader); + add_subtitle_stream(sp); } else { reader.skipCurrentElement(); } @@ -137,7 +137,7 @@ bool FootageDescription::Load(const QString &filename) return false; } -bool FootageDescription::Save(const QString &filename) const +bool FootageDescription::save(const QString &filename) const { QFile file(filename); @@ -152,7 +152,7 @@ bool FootageDescription::Save(const QString &filename) const writer.writeStartElement(QStringLiteral("streamcache")); writer.writeAttribute(QStringLiteral("version"), - QString::number(kFootageMetaVersion)); + QString::number(k_footage_meta_version)); writer.writeTextElement(QStringLiteral("decoder"), decoder_); @@ -173,19 +173,19 @@ bool FootageDescription::Save(const QString &filename) const foreach (const VideoParams &vp, video_streams_) { writer.writeStartElement(QStringLiteral("video")); - vp.Save(&writer); + vp.save(&writer); writer.writeEndElement(); // video } foreach (const AudioParams &ap, audio_streams_) { writer.writeStartElement(QStringLiteral("audio")); - TypeSerializer::SaveAudioParams(&writer, ap); + TypeSerializer::save_audio_params(&writer, ap); writer.writeEndElement(); // audio } foreach (const SubtitleParams &sp, subtitle_streams_) { writer.writeStartElement(QStringLiteral("subtitle")); - sp.Save(&writer); + sp.save(&writer); writer.writeEndElement(); // audio } diff --git a/app/node/project/footage/footagedescription.h b/app/node/project/footage/footagedescription.h index f96d6d374..e29546b66 100644 --- a/app/node/project/footage/footagedescription.h +++ b/app/node/project/footage/footagedescription.h @@ -19,8 +19,8 @@ ***/ -#ifndef FOOTAGEDESCRIPTION_H -#define FOOTAGEDESCRIPTION_H +#ifndef OAK_FOOTAGEDESCRIPTION_H +#define OAK_FOOTAGEDESCRIPTION_H #include @@ -40,7 +40,7 @@ public: { } - bool IsValid() const + bool is_valid() const { return !decoder_.isEmpty() && (!video_streams_.isEmpty() || !audio_streams_.isEmpty() || @@ -52,41 +52,41 @@ public: return decoder_; } - void AddVideoStream(const VideoParams &video_params) + void add_video_stream(const VideoParams &video_params) { - Q_ASSERT(!HasStreamIndex(video_params.stream_index())); + Q_ASSERT(!has_stream_index(video_params.stream_index())); video_streams_.append(video_params); } - void AddAudioStream(const AudioParams &audio_params) + void add_audio_stream(const AudioParams &audio_params) { - Q_ASSERT(!HasStreamIndex(audio_params.stream_index())); + Q_ASSERT(!has_stream_index(audio_params.stream_index())); audio_streams_.append(audio_params); } - void AddSubtitleStream(const SubtitleParams &sub_params) + void add_subtitle_stream(const SubtitleParams &sub_params) { - Q_ASSERT(!HasStreamIndex(sub_params.stream_index())); + Q_ASSERT(!has_stream_index(sub_params.stream_index())); subtitle_streams_.append(sub_params); } - Track::Type GetTypeOfStream(int index) + Track::Type get_type_of_stream(int index) { - if (StreamIsVideo(index)) { - return Track::kVideo; - } else if (StreamIsAudio(index)) { - return Track::kAudio; - } else if (StreamIsSubtitle(index)) { - return Track::kSubtitle; + if (stream_is_video(index)) { + return Track::k_video; + } else if (stream_is_audio(index)) { + return Track::k_audio; + } else if (stream_is_subtitle(index)) { + return Track::k_subtitle; } else { - return Track::kNone; + return Track::k_none; } } - bool StreamIsVideo(int index) const + bool stream_is_video(int index) const { foreach (const VideoParams &vp, video_streams_) { if (vp.stream_index() == index) { @@ -97,7 +97,7 @@ public: return false; } - bool StreamIsAudio(int index) const + bool stream_is_audio(int index) const { foreach (const AudioParams &ap, audio_streams_) { if (ap.stream_index() == index) { @@ -108,7 +108,7 @@ public: return false; } - bool StreamIsSubtitle(int index) const + bool stream_is_subtitle(int index) const { foreach (const SubtitleParams &sp, subtitle_streams_) { if (sp.stream_index() == index) { @@ -119,34 +119,34 @@ public: return false; } - bool HasStreamIndex(int index) const + bool has_stream_index(int index) const { - return StreamIsVideo(index) || StreamIsAudio(index) || - StreamIsSubtitle(index); + return stream_is_video(index) || stream_is_audio(index) || + stream_is_subtitle(index); } - int GetStreamCount() const + int get_stream_count() const { return total_stream_count_; } - void SetStreamCount(int s) + void set_stream_count(int s) { total_stream_count_ = s; } - void SetSourceStartTime(const rational &time, const QString &source) + void set_source_start_time(const Rational &time, const QString &source) { source_start_time_ = time; source_start_time_source_ = source; has_source_start_time_ = true; } - bool HasSourceStartTime() const + bool has_source_start_time() const { return has_source_start_time_; } - const rational &source_start_time() const + const Rational &source_start_time() const { return source_start_time_; } @@ -156,39 +156,39 @@ public: return source_start_time_source_; } - bool Load(const QString &filename); + bool load(const QString &filename); - bool Save(const QString &filename) const; + bool save(const QString &filename) const; - const QVector &GetVideoStreams() const + const QVector &get_video_streams() const { return video_streams_; } - QVector &GetVideoStreams() + QVector &get_video_streams() { return video_streams_; } - const QVector &GetAudioStreams() const + const QVector &get_audio_streams() const { return audio_streams_; } - QVector &GetAudioStreams() + QVector &get_audio_streams() { return audio_streams_; } - const QVector &GetSubtitleStreams() const + const QVector &get_subtitle_streams() const { return subtitle_streams_; } - QVector &GetSubtitleStreams() + QVector &get_subtitle_streams() { return subtitle_streams_; } private: - static constexpr unsigned kFootageMetaVersion = 7; + static constexpr unsigned k_footage_meta_version = 7; QString decoder_; @@ -200,7 +200,7 @@ private: int total_stream_count_; - rational source_start_time_; + Rational source_start_time_; QString source_start_time_source_; @@ -209,4 +209,4 @@ private: } -#endif // FOOTAGEDESCRIPTION_H +#endif // OAK_FOOTAGEDESCRIPTION_H diff --git a/app/node/project/sequence/sequence.cpp b/app/node/project/sequence/sequence.cpp index 60febfb0f..1cb2a7c13 100644 --- a/app/node/project/sequence/sequence.cpp +++ b/app/node/project/sequence/sequence.cpp @@ -30,33 +30,33 @@ namespace olive { -const QString Sequence::kTrackInputFormat = QStringLiteral("track_in_%1"); +const QString Sequence::k_track_input_format = QStringLiteral("track_in_%1"); #define super ViewerOutput Sequence::Sequence() { - SetFlag(kIsItem); + set_flag(k_is_item); // Create TrackList instances - track_lists_.resize(Track::kCount); + track_lists_.resize(Track::k_count); - for (int i = 0; i < Track::kCount; i++) { + for (int i = 0; i < Track::k_count; i++) { // Create track input - QString track_input_id = kTrackInputFormat.arg(i); + QString track_input_id = k_track_input_format.arg(i); - AddInput(track_input_id, NodeValue::kNone, - InputFlags(kInputFlagNotKeyframable | kInputFlagArray | - kInputFlagHidden | kInputFlagIgnoreInvalidations)); + add_input(track_input_id, NodeValue::k_none, + InputFlags(k_input_flag_not_keyframable | k_input_flag_array | + k_input_flag_hidden | k_input_flag_ignore_invalidations)); TrackList *list = new TrackList(this, static_cast(i), track_input_id); track_lists_.replace(i, list); - connect(list, &TrackList::TrackListChanged, this, - &Sequence::UpdateTrackCache); - connect(list, &TrackList::LengthChanged, this, &Sequence::VerifyLength); - connect(list, &TrackList::TrackAdded, this, &Sequence::TrackAdded); - connect(list, &TrackList::TrackRemoved, this, &Sequence::TrackRemoved); + connect(list, &TrackList::track_list_changed, this, + &Sequence::update_track_cache); + connect(list, &TrackList::length_changed, this, &Sequence::verify_length); + connect(list, &TrackList::track_added, this, &Sequence::track_added); + connect(list, &TrackList::track_removed, this, &Sequence::track_removed); } } @@ -64,9 +64,9 @@ void Sequence::add_default_nodes(MultiUndoCommand *command) { // Create tracks and connect them to the viewer UndoCommand *video_track_command = - new TimelineAddTrackCommand(track_list(Track::kVideo)); + new TimelineAddTrackCommand(track_list(Track::k_video)); UndoCommand *audio_track_command = - new TimelineAddTrackCommand(track_list(Track::kAudio)); + new TimelineAddTrackCommand(track_list(Track::k_audio)); if (command) { command->add_child(video_track_command); @@ -81,19 +81,19 @@ void Sequence::add_default_nodes(MultiUndoCommand *command) QVariant Sequence::data(const DataType &d) const { - if (d == ICON) { - return icon::Sequence; + if (d == icon) { + return icon::sequence; } return super::data(d); } -QVector Sequence::GetUnlockedTracks() const +QVector Sequence::get_unlocked_tracks() const { - QVector tracks = GetTracks(); + QVector tracks = get_tracks(); for (int i = 0; i < tracks.size(); i++) { - if (tracks.at(i)->IsLocked()) { + if (tracks.at(i)->is_locked()) { tracks.removeAt(i); i--; } @@ -102,56 +102,56 @@ QVector Sequence::GetUnlockedTracks() const return tracks; } -void Sequence::Retranslate() +void Sequence::retranslate() { - super::Retranslate(); + super::retranslate(); - for (int i = 0; i < Track::kCount; i++) { + for (int i = 0; i < Track::k_count; i++) { QString input_name; switch (static_cast(i)) { - case Track::kVideo: + case Track::k_video: input_name = tr("Video Tracks"); break; - case Track::kAudio: + case Track::k_audio: input_name = tr("Audio Tracks"); break; - case Track::kSubtitle: + case Track::k_subtitle: input_name = tr("Subtitle Tracks"); break; - case Track::kNone: - case Track::kCount: + case Track::k_none: + case Track::k_count: break; } if (!input_name.isEmpty()) { - SetInputName(kTrackInputFormat.arg(i), input_name); + set_input_name(k_track_input_format.arg(i), input_name); } } } -void Sequence::InvalidateCache(const TimeRange &range, const QString &from, +void Sequence::invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) { - if (from == kTrackInputFormat.arg(Track::kSubtitle)) { - emit SubtitlesChanged(range); + if (from == k_track_input_format.arg(Track::k_subtitle)) { + emit subtitles_changed(range); } - super::InvalidateCache(range, from, element, options); + super::invalidate_cache(range, from, element, options); } -rational Sequence::VerifyLengthInternal(Track::Type type) const +Rational Sequence::verify_length_internal(Track::Type type) const { if (!track_lists_.isEmpty()) { switch (type) { - case Track::kVideo: - return track_lists_.at(Track::kVideo)->GetTotalLength(); - case Track::kAudio: - return track_lists_.at(Track::kAudio)->GetTotalLength(); - case Track::kSubtitle: - return track_lists_.at(Track::kSubtitle)->GetTotalLength(); - case Track::kNone: - case Track::kCount: + case Track::k_video: + return track_lists_.at(Track::k_video)->get_total_length(); + case Track::k_audio: + return track_lists_.at(Track::k_audio)->get_total_length(); + case Track::k_subtitle: + return track_lists_.at(Track::k_subtitle)->get_total_length(); + case Track::k_none: + case Track::k_count: break; } } @@ -165,7 +165,7 @@ void Sequence::InputConnectedEvent(const QString &input, int element, foreach (TrackList *list, track_lists_) { if (list->track_input() == input) { // Return because we found our input - list->TrackConnected(output, element); + list->track_connected(output, element); return; } } @@ -179,7 +179,7 @@ void Sequence::InputDisconnectedEvent(const QString &input, int element, foreach (TrackList *list, track_lists_) { if (list->track_input() == input) { // Return because we found our input - list->TrackDisconnected(output, element); + list->track_disconnected(output, element); return; } } @@ -187,12 +187,12 @@ void Sequence::InputDisconnectedEvent(const QString &input, int element, super::InputDisconnectedEvent(input, element, output); } -void Sequence::UpdateTrackCache() +void Sequence::update_track_cache() { track_cache_.clear(); foreach (TrackList *list, track_lists_) { - foreach (Track *track, list->GetTracks()) { + foreach (Track *track, list->get_tracks()) { track_cache_.append(track); } } diff --git a/app/node/project/sequence/sequence.h b/app/node/project/sequence/sequence.h index 4a5ac34f3..63cbc72d4 100644 --- a/app/node/project/sequence/sequence.h +++ b/app/node/project/sequence/sequence.h @@ -19,8 +19,8 @@ ***/ -#ifndef SEQUENCE_H -#define SEQUENCE_H +#ifndef OAK_SEQUENCE_H +#define OAK_SEQUENCE_H #include "node/output/track/tracklist.h" #include "node/output/viewer/viewer.h" @@ -38,7 +38,7 @@ public: NODE_DEFAULT_FUNCTIONS(Sequence) - virtual QString Name() const override + virtual QString name() const override { return tr("Sequence"); } @@ -48,12 +48,12 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.sequence"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryProject }; + return { k_category_project }; } - virtual QString Description() const override + virtual QString description() const override { return tr( "A series of cuts that result in an edited video. Also called a timeline."); @@ -63,36 +63,36 @@ public: virtual QVariant data(const DataType &d) const override; - const QVector &GetTracks() const + const QVector &get_tracks() const { return track_cache_; } - Track *GetTrackFromReference(const Track::Reference &track_ref) const + Track *get_track_from_reference(const Track::Reference &track_ref) const { if (track_ref.type() < 0 || track_ref.type() >= track_lists_.size()) { return nullptr; } - return track_lists_.at(track_ref.type())->GetTrackAt(track_ref.index()); + return track_lists_.at(track_ref.type())->get_track_at(track_ref.index()); } /** * @brief Same as GetTracks() but omits tracks that are locked. */ - QVector GetUnlockedTracks() const; + QVector get_unlocked_tracks() const; TrackList *track_list(Track::Type type) const { return track_lists_.at(type); } - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void InvalidateCache(const TimeRange &range, const QString &from, + virtual void invalidate_cache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options) override; - static const QString kTrackInputFormat; + static const QString k_track_input_format; protected: virtual void InputConnectedEvent(const QString &input, int element, @@ -101,13 +101,13 @@ protected: virtual void InputDisconnectedEvent(const QString &input, int element, Node *output) override; - virtual rational VerifyLengthInternal(Track::Type type) const override; + virtual Rational verify_length_internal(Track::Type type) const override; signals: - void TrackAdded(Track *track); - void TrackRemoved(Track *track); + void track_added(Track *track); + void track_removed(Track *track); - void SubtitlesChanged(const TimeRange &range); + void subtitles_changed(const TimeRange &range); private: QVector track_lists_; @@ -115,9 +115,9 @@ private: QVector track_cache_; private slots: - void UpdateTrackCache(); + void update_track_cache(); }; } -#endif // SEQUENCE_H +#endif // OAK_SEQUENCE_H diff --git a/app/node/project/serializer/serializer.cpp b/app/node/project/serializer/serializer.cpp index 7cd8e3d5c..8645bdb1c 100644 --- a/app/node/project/serializer/serializer.cpp +++ b/app/node/project/serializer/serializer.cpp @@ -38,29 +38,29 @@ namespace olive { -QVector ProjectSerializer::instances_; +QVector ProjectSerializer::instances; -void ProjectSerializer::Initialize() +void ProjectSerializer::initialize() { // Make sure to order these from oldest to newest // FIXME: Implement this - yes it's a 0.1 project loader //instances_.append(new ProjectSerializer190219); - instances_.append(new ProjectSerializer210528); - instances_.append(new ProjectSerializer210907); - instances_.append(new ProjectSerializer211228); - instances_.append(new ProjectSerializer220403); - instances_.append(new ProjectSerializer230220); + instances.append(new ProjectSerializer210528); + instances.append(new ProjectSerializer210907); + instances.append(new ProjectSerializer211228); + instances.append(new ProjectSerializer220403); + instances.append(new ProjectSerializer230220); } -void ProjectSerializer::Destroy() +void ProjectSerializer::destroy() { - qDeleteAll(instances_); - instances_.clear(); + qDeleteAll(instances); + instances.clear(); } -ProjectSerializer::Result ProjectSerializer::Load(Project *project, +ProjectSerializer::Result ProjectSerializer::load(Project *project, const QString &filename, LoadType load_type) { @@ -70,7 +70,7 @@ ProjectSerializer::Result ProjectSerializer::Load(Project *project, // Some project files are compressed, marked with "OVEC" at the beginning of the file. Check for // that signature now. std::unique_ptr reader; - if (CheckCompressedID(&project_file)) { + if (check_compressed_id(&project_file)) { // File is compressed, decompress into memory QByteArray b; b = qUncompress(project_file.readAll()); @@ -80,38 +80,38 @@ ProjectSerializer::Result ProjectSerializer::Load(Project *project, reader.reset(new QXmlStreamReader(&project_file)); } - Result inner_result = Load(project, reader.get(), load_type); + Result inner_result = load(project, reader.get(), load_type); project_file.close(); - if (inner_result.code() != kSuccess) { + if (inner_result.code() != k_success) { return inner_result; } if (reader->hasError()) { - Result r(kXmlError); - r.SetDetails(reader->errorString()); + Result r(k_xml_error); + r.set_details(reader->errorString()); return r; } else { return inner_result; } } else { - Result r(kFileError); - r.SetDetails(QStringLiteral("Unable to open '%1': %2") + Result r(k_file_error); + r.set_details(QStringLiteral("Unable to open '%1': %2") .arg(filename, project_file.errorString())); return r; } } -ProjectSerializer::Result ProjectSerializer::Load(Project *project, +ProjectSerializer::Result ProjectSerializer::load(Project *project, QXmlStreamReader *reader, LoadType load_type) { // Determine project version uint version = 0; - Result res = kUnknownVersion; + Result res = k_unknown_version; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("olive") || reader->name() == QStringLiteral("project")) { // 0.1 projects only @@ -123,25 +123,25 @@ ProjectSerializer::Result ProjectSerializer::Load(Project *project, } else if (attr.name() == QStringLiteral("url")) { // 230220+ projects if (project) { - project->SetSavedURL(attr.value().toString()); + project->set_saved_url(attr.value().toString()); } } } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("version")) { // projects <= 220403 version = reader->readElementText().toUInt(); } else if (reader->name() == QStringLiteral("url")) { // projects <= 220403 if (project) { - project->SetSavedURL(reader->readElementText()); + project->set_saved_url(reader->readElementText()); } else { reader->skipCurrentElement(); } } else { // Handle any other value with the serializer - res = LoadWithSerializerVersion(version, project, reader, + res = load_with_serializer_version(version, project, reader, load_type); } } @@ -153,24 +153,24 @@ ProjectSerializer::Result ProjectSerializer::Load(Project *project, return res; } -ProjectSerializer::Result ProjectSerializer::Paste(LoadType load_type, +ProjectSerializer::Result ProjectSerializer::paste(LoadType load_type, Project *project) { - QString clipboard = Core::PasteStringFromClipboard(); + QString clipboard = Core::paste_string_from_clipboard(); if (clipboard.isEmpty()) { - return kNoData; + return k_no_data; } QXmlStreamReader reader(clipboard); - return ProjectSerializer::Load(project, &reader, load_type); + return ProjectSerializer::load(project, &reader, load_type); } -ProjectSerializer::Result ProjectSerializer::Save(const SaveData &data, +ProjectSerializer::Result ProjectSerializer::save(const SaveData &data, bool compress) { QString temp_save = - FileFunctions::GetSafeTemporaryFilename(data.GetFilename()); + FileFunctions::get_safe_temporary_filename(data.get_filename()); QFile project_file(temp_save); @@ -178,10 +178,10 @@ ProjectSerializer::Result ProjectSerializer::Save(const SaveData &data, QByteArray b; QXmlStreamWriter writer(&b); - Result inner_result = Save(&writer, data); + Result inner_result = save(&writer, data); if (writer.hasError()) { - Result r(kXmlError); + Result r(k_xml_error); return r; } @@ -194,27 +194,27 @@ ProjectSerializer::Result ProjectSerializer::Save(const SaveData &data, project_file.close(); - if (inner_result != kSuccess) { + if (inner_result != k_success) { return inner_result; } // Save was successful, we can now rewrite the original file - if (FileFunctions::RenameFileAllowOverwrite(temp_save, - data.GetFilename())) { - return kSuccess; + if (FileFunctions::rename_file_allow_overwrite(temp_save, + data.get_filename())) { + return k_success; } else { - Result r(kOverwriteError); - r.SetDetails(temp_save); + Result r(k_overwrite_error); + r.set_details(temp_save); return r; } } else { - Result r(kFileError); - r.SetDetails(temp_save); + Result r(k_file_error); + r.set_details(temp_save); return r; } } -ProjectSerializer::Result ProjectSerializer::Save(QXmlStreamWriter *writer, +ProjectSerializer::Result ProjectSerializer::save(QXmlStreamWriter *writer, const SaveData &data) { writer->setAutoFormatting(true); @@ -225,106 +225,106 @@ ProjectSerializer::Result ProjectSerializer::Save(QXmlStreamWriter *writer, // By default, save as last serializer which, assuming the instances are ordered correctly, // will be the newest file format. But we may allow saving as older versions later on. - ProjectSerializer *serializer = instances_.last(); + ProjectSerializer *serializer = instances.last(); // Version is stored in YYMMDD from whenever the project format was last changed // Allows easy integer math for checking project versions. writer->writeAttribute(QStringLiteral("version"), - QString::number(serializer->Version())); + QString::number(serializer->version())); - if (!data.GetFilename().isEmpty()) { - writer->writeAttribute("url", data.GetFilename()); + if (!data.get_filename().isEmpty()) { + writer->writeAttribute("url", data.get_filename()); } - serializer->Save(writer, data, nullptr); + serializer->save(writer, data, nullptr); writer->writeEndElement(); // olive writer->writeEndDocument(); if (writer->hasError()) { - return kXmlError; + return k_xml_error; } - return kSuccess; + return k_success; } -ProjectSerializer::Result ProjectSerializer::Copy(const SaveData &data) +ProjectSerializer::Result ProjectSerializer::copy(const SaveData &data) { QString copy_str; QXmlStreamWriter writer(©_str); - ProjectSerializer::Result res = ProjectSerializer::Save(&writer, data); + ProjectSerializer::Result res = ProjectSerializer::save(&writer, data); - if (res == kSuccess) { - Core::CopyStringToClipboard(copy_str); + if (res == k_success) { + Core::copy_string_to_clipboard(copy_str); } return res; } -bool ProjectSerializer::CheckCompressedID(QFile *file) +bool ProjectSerializer::check_compressed_id(QFile *file) { QByteArray b = file->read(4); return !memcmp(b.data(), "OVEC", 4); } -bool ProjectSerializer::IsCancelled() const +bool ProjectSerializer::is_cancelled() const { return false; } ProjectSerializer::Result -ProjectSerializer::LoadWithSerializerVersion(uint version, Project *project, +ProjectSerializer::load_with_serializer_version(uint version, Project *project, QXmlStreamReader *reader, LoadType load_type) { // Failed to find version in file if (version == 0) { - return kUnknownVersion; + return k_unknown_version; } // We should now have the version, if we have a serializer for it, use it to load the project ProjectSerializer *serializer = nullptr; - foreach (ProjectSerializer *s, instances_) { - if (version == s->Version()) { + foreach (ProjectSerializer *s, instances) { + if (version == s->version()) { serializer = s; break; - } else if (version < s->Version()) { + } else if (version < s->version()) { // Assuming the instance list is in order, if the project version is less than any version // we find, we must not support it anymore - return kProjectTooOld; + return k_project_too_old; } } if (serializer) { - LoadData ld = serializer->Load(project, reader, load_type, nullptr); - Result r(kSuccess); + LoadData ld = serializer->load(project, reader, load_type, nullptr); + Result r(k_success); if (reader->hasError()) { - r = Result(kXmlError); - r.SetDetails( + r = Result(k_xml_error); + r.set_details( QCoreApplication::translate("Serializer", "%1 on line %2") .arg(reader->errorString(), QString::number(reader->lineNumber()))); } - r.SetLoadData(ld); + r.set_load_data(ld); return r; } else { // Reached the end of the list with no serializer, assume too new - return kProjectTooNew; + return k_project_too_new; } } -void ProjectSerializer::SaveData::SetOnlySerializeNodesAndResolveGroups( +void ProjectSerializer::SaveData::set_only_serialize_nodes_and_resolve_groups( QVector nodes) { // For any groups, add children for (int i = 0; i < nodes.size(); i++) { // If this is a group, add the child nodes too if (NodeGroup *g = dynamic_cast(nodes.at(i))) { - for (auto it = g->GetContextPositions().cbegin(); - it != g->GetContextPositions().cend(); it++) { + for (auto it = g->get_context_positions().cbegin(); + it != g->get_context_positions().cend(); it++) { if (!nodes.contains(it.key())) { nodes.append(it.key()); } @@ -332,7 +332,7 @@ void ProjectSerializer::SaveData::SetOnlySerializeNodesAndResolveGroups( } } - SetOnlySerializeNodes(nodes); + set_only_serialize_nodes(nodes); } } diff --git a/app/node/project/serializer/serializer.h b/app/node/project/serializer/serializer.h index fa311bd7e..960e1319e 100644 --- a/app/node/project/serializer/serializer.h +++ b/app/node/project/serializer/serializer.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTSERIALIZER_H -#define PROJECTSERIALIZER_H +#ifndef OAK_PROJECTSERIALIZER_H +#define OAK_PROJECTSERIALIZER_H #include @@ -40,11 +40,11 @@ namespace olive class ProjectSerializer { public: enum LoadType { - kProject, - kOnlyNodes, - kOnlyClips, - kOnlyMarkers, - kOnlyKeyframes + k_project, + k_only_nodes, + k_only_clips, + k_only_markers, + k_only_keyframes }; ProjectSerializer() = default; @@ -56,14 +56,14 @@ public: DISABLE_COPY_MOVE(ProjectSerializer) enum ResultCode { - kSuccess, - kProjectTooOld, - kProjectTooNew, - kUnknownVersion, - kFileError, - kXmlError, - kOverwriteError, - kNoData + k_success, + k_project_too_old, + k_project_too_new, + k_unknown_version, + k_file_error, + k_xml_error, + k_overwrite_error, + k_no_data }; using SerializedProperties = QHash>; @@ -111,22 +111,22 @@ public: return code_; } - const QString &GetDetails() const + const QString &get_details() const { return details_; } - void SetDetails(const QString &s) + void set_details(const QString &s) { details_ = s; } - const LoadData &GetLoadData() const + const LoadData &get_load_data() const { return load_data_; } - void SetLoadData(const LoadData &p) + void set_load_data(const LoadData &p) { load_data_ = p; } @@ -149,20 +149,20 @@ public: filename_ = filename; } - Project *GetProject() const + Project *get_project() const { return project_; } - void SetProject(Project *p) + void set_project(Project *p) { project_ = p; } - const QString &GetFilename() const + const QString &get_filename() const { return filename_; } - void SetFilename(const QString &s) + void set_filename(const QString &s) { filename_ = s; } @@ -172,48 +172,48 @@ public: return type_; } - const MainWindowLayoutInfo &GetLayout() const + const MainWindowLayoutInfo &get_layout() const { return layout_; } - void SetLayout(const MainWindowLayoutInfo &layout) + void set_layout(const MainWindowLayoutInfo &layout) { layout_ = layout; } - const QVector &GetOnlySerializeNodes() const + const QVector &get_only_serialize_nodes() const { return only_serialize_nodes_; } - void SetOnlySerializeNodes(const QVector &only) + void set_only_serialize_nodes(const QVector &only) { only_serialize_nodes_ = only; } - void SetOnlySerializeNodesAndResolveGroups(QVector only); + void set_only_serialize_nodes_and_resolve_groups(QVector only); - const std::vector &GetOnlySerializeMarkers() const + const std::vector &get_only_serialize_markers() const { return only_serialize_markers_; } - void SetOnlySerializeMarkers(const std::vector &only) + void set_only_serialize_markers(const std::vector &only) { only_serialize_markers_ = only; } - const std::vector &GetOnlySerializeKeyframes() const + const std::vector &get_only_serialize_keyframes() const { return only_serialize_keyframes_; } - void SetOnlySerializeKeyframes(const std::vector &only) + void set_only_serialize_keyframes(const std::vector &only) { only_serialize_keyframes_ = only; } - const SerializedProperties &GetProperties() const + const SerializedProperties &get_properties() const { return properties_; } - void SetProperties(const SerializedProperties &p) + void set_properties(const SerializedProperties &p) { properties_ = p; } @@ -236,43 +236,43 @@ public: std::vector only_serialize_keyframes_; }; - static void Initialize(); + static void initialize(); - static void Destroy(); + static void destroy(); - static Result Load(Project *project, const QString &filename, + static Result load(Project *project, const QString &filename, LoadType load_type); - static Result Load(Project *project, QXmlStreamReader *read_device, + static Result load(Project *project, QXmlStreamReader *read_device, LoadType load_type); - static Result Paste(LoadType load_type, Project *project = nullptr); + static Result paste(LoadType load_type, Project *project = nullptr); - static Result Save(const SaveData &data, bool compress); - static Result Save(QXmlStreamWriter *write_device, const SaveData &data); - static Result Copy(const SaveData &data); + static Result save(const SaveData &data, bool compress); + static Result save(QXmlStreamWriter *write_device, const SaveData &data); + static Result copy(const SaveData &data); - static bool CheckCompressedID(QFile *file); + static bool check_compressed_id(QFile *file); protected: - virtual LoadData Load(Project *project, QXmlStreamReader *reader, + virtual LoadData load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const = 0; - virtual void Save(QXmlStreamWriter *writer, const SaveData &data, + virtual void save(QXmlStreamWriter *writer, const SaveData &data, void *reserved) const { } - virtual uint Version() const = 0; + virtual uint version() const = 0; - bool IsCancelled() const; + bool is_cancelled() const; private: - static Result LoadWithSerializerVersion(uint version, Project *project, + static Result load_with_serializer_version(uint version, Project *project, QXmlStreamReader *reader, LoadType load_type); - static QVector instances_; + static QVector instances; }; } -#endif // PROJECTSERIALIZER_H +#endif // OAK_PROJECTSERIALIZER_H diff --git a/app/node/project/serializer/serializer190219.cpp b/app/node/project/serializer/serializer190219.cpp index bae440d65..f38b28fcc 100644 --- a/app/node/project/serializer/serializer190219.cpp +++ b/app/node/project/serializer/serializer190219.cpp @@ -25,7 +25,7 @@ namespace olive { ProjectSerializer::LoadData -ProjectSerializer190219::Load(Project *project, QXmlStreamReader *reader, +ProjectSerializer190219::load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const { return LoadData(); diff --git a/app/node/project/serializer/serializer190219.h b/app/node/project/serializer/serializer190219.h index eb2892622..5d7b9a393 100644 --- a/app/node/project/serializer/serializer190219.h +++ b/app/node/project/serializer/serializer190219.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTSERIALIZER190219_H -#define PROJECTSERIALIZER190219_H +#ifndef OAK_PROJECTSERIALIZER190219_H +#define OAK_PROJECTSERIALIZER190219_H #include "serializer.h" @@ -32,10 +32,10 @@ public: ProjectSerializer190219() = default; protected: - virtual LoadData Load(Project *project, QXmlStreamReader *reader, + virtual LoadData load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const override; - virtual uint Version() const override + virtual uint version() const override { return 190219; } diff --git a/app/node/project/serializer/serializer210528.cpp b/app/node/project/serializer/serializer210528.cpp index 4d4356a31..e24328d7e 100644 --- a/app/node/project/serializer/serializer210528.cpp +++ b/app/node/project/serializer/serializer210528.cpp @@ -29,17 +29,17 @@ namespace olive { ProjectSerializer210528::LoadData -ProjectSerializer210528::Load(Project *project, QXmlStreamReader *reader, +ProjectSerializer210528::load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const { XMLNodeData xml_node_data; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("uuid")) { - project->SetUuid(QUuid::fromString(reader->readElementText())); + project->set_uuid(QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("nodes")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { bool is_root = false; bool is_cm = false; @@ -73,16 +73,16 @@ ProjectSerializer210528::Load(Project *project, QXmlStreamReader *reader, bool handled_elsewhere = false; if (is_root) { - project->Initialize(); + project->initialize(); node = project->root(); } else if (is_cm) { - LoadColorManager(reader, project); + load_color_manager(reader, project); handled_elsewhere = true; } else if (is_settings) { - LoadProjectSettings(reader, project); + load_project_settings(reader, project); handled_elsewhere = true; } else { - node = NodeFactory::CreateFromID(id); + node = NodeFactory::create_from_id(id); } if (!handled_elsewhere) { @@ -91,7 +91,7 @@ ProjectSerializer210528::Load(Project *project, QXmlStreamReader *reader, << "Failed to find node with ID" << id; reader->skipCurrentElement(); } else { - LoadNode(node, xml_node_data, reader); + load_node(node, xml_node_data, reader); node->setParent(project); } } @@ -102,7 +102,7 @@ ProjectSerializer210528::Load(Project *project, QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("positions")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("context")) { quintptr context_ptr = 0; XMLAttributeLoop(reader, attr) @@ -119,18 +119,18 @@ ProjectSerializer210528::Load(Project *project, QXmlStreamReader *reader, qWarning() << "Failed to find pointer for context"; reader->skipCurrentElement(); } else { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { quintptr node_ptr; Node::Position node_pos; - if (LoadPosition(reader, &node_ptr, + if (load_position(reader, &node_ptr, &node_pos)) { Node *node = xml_node_data.node_ptrs.value(node_ptr); if (node) { - context->SetNodePositionInContext( + context->set_node_position_in_context( node, node_pos); } else { qWarning() @@ -156,18 +156,18 @@ ProjectSerializer210528::Load(Project *project, QXmlStreamReader *reader, } // Make connections - PostConnect(xml_node_data); + post_connect(xml_node_data); // Resolve tracks for (Node *n : project->nodes()) { - n->SetCachesEnabled(true); + n->set_caches_enabled(true); if (Track *t = dynamic_cast(n)) { - for (int i = 0; i < t->InputArraySize(Track::kBlockInput); i++) { + for (int i = 0; i < t->input_array_size(Track::k_block_input); i++) { Block *b = static_cast( - t->GetConnectedOutput(Track::kBlockInput, i)); + t->get_connected_output(Track::k_block_input, i)); if (!b->track()) { - t->AppendBlock(b); + t->append_block(b); } } } @@ -176,25 +176,25 @@ ProjectSerializer210528::Load(Project *project, QXmlStreamReader *reader, return LoadData(); } -void ProjectSerializer210528::LoadNode(Node *node, XMLNodeData &xml_node_data, +void ProjectSerializer210528::load_node(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const { - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("input")) { - LoadInput(node, reader, xml_node_data); + load_input(node, reader, xml_node_data); } else if (reader->name() == QStringLiteral("ptr")) { xml_node_data.node_ptrs.insert( reader->readElementText().toULongLong(), node); } else if (reader->name() == QStringLiteral("label")) { - node->SetLabel(reader->readElementText()); + node->set_label(reader->readElementText()); } else if (reader->name() == QStringLiteral("color")) { - node->SetOverrideColor(reader->readElementText().toInt()); + node->set_override_color(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("links")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("link")) { xml_node_data.block_links.append( { node, reader->readElementText().toULongLong() }); @@ -203,11 +203,11 @@ void ProjectSerializer210528::LoadNode(Node *node, XMLNodeData &xml_node_data, } } } else if (reader->name() == QStringLiteral("custom")) { - LoadNodeCustom(reader, node, xml_node_data); + load_node_custom(reader, node, xml_node_data); } else if (reader->name() == QStringLiteral("connections")) { // Load connections - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("connection")) { QString param_id; int ele = -1; @@ -224,7 +224,7 @@ void ProjectSerializer210528::LoadNode(Node *node, XMLNodeData &xml_node_data, QString output_node_id; QString output_param_id; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { output_node_id = reader->readElementText(); } else if (reader->name() == QStringLiteral("output")) { @@ -242,7 +242,7 @@ void ProjectSerializer210528::LoadNode(Node *node, XMLNodeData &xml_node_data, } } } else if (reader->name() == QStringLiteral("hints")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("hint")) { QString input; int element = -1; @@ -257,8 +257,8 @@ void ProjectSerializer210528::LoadNode(Node *node, XMLNodeData &xml_node_data, } Node::ValueHint vh; - LoadValueHint(&vh, reader); - node->SetValueHintForInput(input, vh, element); + load_value_hint(&vh, reader); + node->set_value_hint_for_input(input, vh, element); } else { reader->skipCurrentElement(); } @@ -271,10 +271,10 @@ void ProjectSerializer210528::LoadNode(Node *node, XMLNodeData &xml_node_data, node->LoadFinishedEvent(); } -void ProjectSerializer210528::LoadColorManager(QXmlStreamReader *reader, +void ProjectSerializer210528::load_color_manager(QXmlStreamReader *reader, Project *project) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString id; XMLAttributeLoop(reader, attr) @@ -289,11 +289,11 @@ void ProjectSerializer210528::LoadColorManager(QXmlStreamReader *reader, id == QStringLiteral("reference_space")) { QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { value = reader->readElementText(); @@ -335,18 +335,18 @@ void ProjectSerializer210528::LoadColorManager(QXmlStreamReader *reader, }; int num_value = value.toInt(); value = list.at(num_value); - project->SetDefaultInputColorSpace(value); + project->set_default_input_color_space(value); } else if (id == QStringLiteral("reference_space")) { // Reference space if (value == QStringLiteral("1")) { - value = OCIO::ROLE_COMPOSITING_LOG; + value = ocio::ROLE_COMPOSITING_LOG; } else { - value = OCIO::ROLE_SCENE_LINEAR; + value = ocio::ROLE_SCENE_LINEAR; } - project->SetColorReferenceSpace(value); + project->set_color_reference_space(value); } else { // Config filename - project->SetColorConfigFilename(value); + project->set_color_config_filename(value); } } else { reader->skipCurrentElement(); @@ -357,10 +357,10 @@ void ProjectSerializer210528::LoadColorManager(QXmlStreamReader *reader, } } -void ProjectSerializer210528::LoadProjectSettings(QXmlStreamReader *reader, +void ProjectSerializer210528::load_project_settings(QXmlStreamReader *reader, Project *project) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString id; XMLAttributeLoop(reader, attr) @@ -374,11 +374,11 @@ void ProjectSerializer210528::LoadProjectSettings(QXmlStreamReader *reader, id == QStringLiteral("cache_path")) { QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { value = reader->readElementText(); @@ -396,10 +396,10 @@ void ProjectSerializer210528::LoadProjectSettings(QXmlStreamReader *reader, } if (id == QStringLiteral("cache_setting")) { - project->SetCacheLocationSetting( + project->set_cache_location_setting( static_cast(value.toInt())); } else { - project->SetCustomCachePath(value); + project->set_custom_cache_path(value); } } else { reader->skipCurrentElement(); @@ -410,7 +410,7 @@ void ProjectSerializer210528::LoadProjectSettings(QXmlStreamReader *reader, } } -void ProjectSerializer210528::LoadInput(Node *node, QXmlStreamReader *reader, +void ProjectSerializer210528::load_input(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const { QString param_id; @@ -430,34 +430,34 @@ void ProjectSerializer210528::LoadInput(Node *node, QXmlStreamReader *reader, return; } - if (!node->HasInputWithID(param_id)) { + if (!node->has_input_with_id(param_id)) { qWarning() << "Failed to load parameter that didn't exist:" << param_id; reader->skipCurrentElement(); return; } - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("primary")) { // Load primary immediate - LoadImmediate(reader, node, param_id, -1, xml_node_data); + load_immediate(reader, node, param_id, -1, xml_node_data); } else if (reader->name() == QStringLiteral("subelements")) { // Load subelements XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("count")) { - node->InputArrayResize(param_id, attr.value().toInt()); + node->input_array_resize(param_id, attr.value().toInt()); } } int element_counter = 0; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("element")) { - LoadImmediate(reader, node, param_id, element_counter, + load_immediate(reader, node, param_id, element_counter, xml_node_data); element_counter++; @@ -471,46 +471,46 @@ void ProjectSerializer210528::LoadInput(Node *node, QXmlStreamReader *reader, } } -void ProjectSerializer210528::LoadImmediate(QXmlStreamReader *reader, +void ProjectSerializer210528::load_immediate(QXmlStreamReader *reader, Node *node, const QString &input, int element, XMLNodeData &xml_node_data) const { Q_UNUSED(xml_node_data) - NodeValue::Type data_type = node->GetInputDataType(input); + NodeValue::Type data_type = node->get_input_data_type(input); - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { // Load standard value int val_index = 0; - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("track")) { QVariant value_on_track; - if (data_type == NodeValue::kVideoParams) { + if (data_type == NodeValue::k_video_params) { VideoParams vp; - vp.Load(reader); + vp.load(reader); value_on_track = QVariant::fromValue(vp); - } else if (data_type == NodeValue::kAudioParams) { + } else if (data_type == NodeValue::k_audio_params) { AudioParams ap = - TypeSerializer::LoadAudioParams(reader); + TypeSerializer::load_audio_params(reader); value_on_track = QVariant::fromValue(ap); } else { QString value_text = reader->readElementText(); if (!value_text.isEmpty()) { - value_on_track = NodeValue::StringToValue( + value_on_track = NodeValue::string_to_value( data_type, value_text, true); } } - node->SetSplitStandardValueOnTrack(input, val_index, + node->set_split_standard_value_on_track(input, val_index, value_on_track, element); val_index++; @@ -519,34 +519,34 @@ void ProjectSerializer210528::LoadImmediate(QXmlStreamReader *reader, } } } else if (reader->name() == QStringLiteral("keyframing") && - node->IsInputKeyframable(input)) { - node->SetInputIsKeyframing(input, reader->readElementText().toInt(), + node->is_input_keyframable(input)) { + node->set_input_is_keyframing(input, reader->readElementText().toInt(), element); } else if (reader->name() == QStringLiteral("keyframes")) { int track = 0; - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("track")) { - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("key")) { QString key_input; - rational key_time; - NodeKeyframe::Type key_type = NodeKeyframe::kLinear; + Rational key_time; + NodeKeyframe::Type key_type = NodeKeyframe::k_linear; QVariant key_value; QPointF key_in_handle; QPointF key_out_handle; XMLAttributeLoop(reader, attr) { - if (IsCancelled()) { + if (is_cancelled()) { return; } @@ -554,7 +554,7 @@ void ProjectSerializer210528::LoadImmediate(QXmlStreamReader *reader, key_input = attr.value().toString(); } else if (attr.name() == QStringLiteral("time")) { - key_time = rational::fromString( + key_time = Rational::from_string( attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("type")) { @@ -577,7 +577,7 @@ void ProjectSerializer210528::LoadImmediate(QXmlStreamReader *reader, } } - key_value = NodeValue::StringToValue( + key_value = NodeValue::string_to_value( data_type, reader->readElementText(), true); NodeKeyframe *key = new NodeKeyframe( @@ -596,16 +596,16 @@ void ProjectSerializer210528::LoadImmediate(QXmlStreamReader *reader, } } } else if (reader->name() == QStringLiteral("csinput")) { - node->SetInputProperty(input, QStringLiteral("col_input"), + node->set_input_property(input, QStringLiteral("col_input"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csdisplay")) { - node->SetInputProperty(input, QStringLiteral("col_display"), + node->set_input_property(input, QStringLiteral("col_display"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csview")) { - node->SetInputProperty(input, QStringLiteral("col_view"), + node->set_input_property(input, QStringLiteral("col_view"), reader->readElementText()); } else if (reader->name() == QStringLiteral("cslook")) { - node->SetInputProperty(input, QStringLiteral("col_look"), + node->set_input_property(input, QStringLiteral("col_look"), reader->readElementText()); } else { reader->skipCurrentElement(); @@ -613,7 +613,7 @@ void ProjectSerializer210528::LoadImmediate(QXmlStreamReader *reader, } } -bool ProjectSerializer210528::LoadPosition(QXmlStreamReader *reader, +bool ProjectSerializer210528::load_position(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const { @@ -630,7 +630,7 @@ bool ProjectSerializer210528::LoadPosition(QXmlStreamReader *reader, } } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("x")) { pos->position.setX(reader->readElementText().toDouble()); got_pos_x = true; @@ -647,7 +647,7 @@ bool ProjectSerializer210528::LoadPosition(QXmlStreamReader *reader, return got_node_ptr && got_pos_x && got_pos_y; } -void ProjectSerializer210528::PostConnect(const XMLNodeData &xml_node_data) const +void ProjectSerializer210528::post_connect(const XMLNodeData &xml_node_data) const { foreach (const XMLNodeData::SerializedConnection &con, xml_node_data.desired_connections) { @@ -655,9 +655,9 @@ void ProjectSerializer210528::PostConnect(const XMLNodeData &xml_node_data) cons // Use output param as hint tag since we grandfathered those in Node::ValueHint hint(con.output_param); - Node::ConnectEdge(out, con.input); + Node::connect_edge(out, con.input); - con.input.node()->SetValueHintForInput(con.input.input(), hint, + con.input.node()->set_value_hint_for_input(con.input.input(), hint, con.input.element()); } } @@ -666,26 +666,26 @@ void ProjectSerializer210528::PostConnect(const XMLNodeData &xml_node_data) cons Node *a = l.block; Node *b = xml_node_data.node_ptrs.value(l.link); - Node::Link(a, b); + Node::link(a, b); } foreach (const XMLNodeData::GroupLink &l, xml_node_data.group_input_links) { if (Node *input_node = xml_node_data.node_ptrs.value(l.input_node)) { NodeInput resolved(input_node, l.input_id, l.input_element); - l.group->AddInputPassthrough(resolved); + l.group->add_input_passthrough(resolved); } } for (auto it = xml_node_data.group_output_links.cbegin(); it != xml_node_data.group_output_links.cend(); it++) { if (Node *output_node = xml_node_data.node_ptrs.value(it.value())) { - it.key()->SetOutputPassthrough(output_node); + it.key()->set_output_passthrough(output_node); } } } -void ProjectSerializer210528::LoadNodeCustom(QXmlStreamReader *reader, +void ProjectSerializer210528::load_node_custom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const { @@ -693,9 +693,9 @@ void ProjectSerializer210528::LoadNodeCustom(QXmlStreamReader *reader, if (ViewerOutput *viewer = dynamic_cast(node)) { Footage *footage = dynamic_cast(node); - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("points")) { - LoadTimelinePoints(reader, viewer); + load_timeline_points(reader, viewer); } else if (reader->name() == QStringLiteral("timestamp") && footage) { footage->set_timestamp(reader->readElementText().toLongLong()); @@ -705,24 +705,24 @@ void ProjectSerializer210528::LoadNodeCustom(QXmlStreamReader *reader, } } else if (Track *track = dynamic_cast(node)) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("height")) { - track->SetTrackHeight(reader->readElementText().toDouble()); + track->set_track_height(reader->readElementText().toDouble()); } else { reader->skipCurrentElement(); } } } else if (NodeGroup *group = dynamic_cast(node)) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthroughs")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthrough")) { XMLNodeData::GroupLink link; link.group = group; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { link.input_node = reader->readElementText().toULongLong(); @@ -756,25 +756,25 @@ void ProjectSerializer210528::LoadNodeCustom(QXmlStreamReader *reader, } } -void ProjectSerializer210528::LoadTimelinePoints(QXmlStreamReader *reader, +void ProjectSerializer210528::load_timeline_points(QXmlStreamReader *reader, ViewerOutput *points) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("markers")) { - LoadMarkerList(reader, points->GetMarkers()); + load_marker_list(reader, points->get_markers()); } else if (reader->name() == QStringLiteral("workarea")) { - LoadWorkArea(reader, points->GetWorkArea()); + load_work_area(reader, points->get_work_area()); } else { reader->skipCurrentElement(); } } } -void ProjectSerializer210528::LoadWorkArea(QXmlStreamReader *reader, +void ProjectSerializer210528::load_work_area(QXmlStreamReader *reader, TimelineWorkArea *workarea) const { - rational range_in = workarea->in(); - rational range_out = workarea->out(); + Rational range_in = workarea->in(); + Rational range_out = workarea->out(); XMLAttributeLoop(reader, attr) { @@ -782,10 +782,10 @@ void ProjectSerializer210528::LoadWorkArea(QXmlStreamReader *reader, workarea->set_enabled(attr.value() != QStringLiteral("0")); } else if (attr.name() == QStringLiteral("in")) { range_in = - rational::fromString(attr.value().toString().toStdString()); + Rational::from_string(attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { range_out = - rational::fromString(attr.value().toString().toStdString()); + Rational::from_string(attr.value().toString().toStdString()); } } @@ -798,28 +798,28 @@ void ProjectSerializer210528::LoadWorkArea(QXmlStreamReader *reader, reader->skipCurrentElement(); } -void ProjectSerializer210528::LoadMarkerList(QXmlStreamReader *reader, +void ProjectSerializer210528::load_marker_list(QXmlStreamReader *reader, TimelineMarkerList *markers) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("marker")) { QString name; - rational in, out; + Rational in, out; XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("name")) { name = attr.value().toString(); } else if (attr.name() == QStringLiteral("in")) { - in = rational::fromString( + in = Rational::from_string( attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { - out = rational::fromString( + out = Rational::from_string( attr.value().toString().toStdString()); } } - new TimelineMarker(OLIVE_CONFIG("MarkerColor").toInt(), + new TimelineMarker(OAK_CONFIG("MarkerColor").toInt(), TimeRange(in, out), name, markers); } @@ -827,14 +827,14 @@ void ProjectSerializer210528::LoadMarkerList(QXmlStreamReader *reader, } } -void ProjectSerializer210528::LoadValueHint(Node::ValueHint *hint, +void ProjectSerializer210528::load_value_hint(Node::ValueHint *hint, QXmlStreamReader *reader) const { QVector types; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("types")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("type")) { types.append(static_cast( reader->readElementText().toInt())); diff --git a/app/node/project/serializer/serializer210528.h b/app/node/project/serializer/serializer210528.h index 54617d93d..d50228a07 100644 --- a/app/node/project/serializer/serializer210528.h +++ b/app/node/project/serializer/serializer210528.h @@ -19,8 +19,8 @@ ***/ -#ifndef SERIALIZER210528_H -#define SERIALIZER210528_H +#ifndef OAK_SERIALIZER210528_H +#define OAK_SERIALIZER210528_H #include "serializer.h" @@ -32,10 +32,10 @@ public: ProjectSerializer210528() = default; protected: - virtual LoadData Load(Project *project, QXmlStreamReader *reader, + virtual LoadData load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const override; - virtual uint Version() const override + virtual uint version() const override { return 210528; } @@ -67,38 +67,38 @@ private: QHash group_output_links; }; - void LoadNode(Node *node, XMLNodeData &xml_node_data, + void load_node(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const; - void LoadColorManager(QXmlStreamReader *reader, Project *project) const; + void load_color_manager(QXmlStreamReader *reader, Project *project) const; - void LoadProjectSettings(QXmlStreamReader *reader, Project *project) const; + void load_project_settings(QXmlStreamReader *reader, Project *project) const; - void LoadInput(Node *node, QXmlStreamReader *reader, + void load_input(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const; - void LoadImmediate(QXmlStreamReader *reader, Node *node, + void load_immediate(QXmlStreamReader *reader, Node *node, const QString &input, int element, XMLNodeData &xml_node_data) const; - bool LoadPosition(QXmlStreamReader *reader, quintptr *node_ptr, + bool load_position(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const; - void PostConnect(const XMLNodeData &xml_node_data) const; + void post_connect(const XMLNodeData &xml_node_data) const; - void LoadNodeCustom(QXmlStreamReader *reader, Node *node, + void load_node_custom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const; - void LoadTimelinePoints(QXmlStreamReader *reader, + void load_timeline_points(QXmlStreamReader *reader, ViewerOutput *points) const; - void LoadWorkArea(QXmlStreamReader *reader, + void load_work_area(QXmlStreamReader *reader, TimelineWorkArea *workarea) const; - void LoadMarkerList(QXmlStreamReader *reader, + void load_marker_list(QXmlStreamReader *reader, TimelineMarkerList *markers) const; - void LoadValueHint(Node::ValueHint *hint, QXmlStreamReader *reader) const; + void load_value_hint(Node::ValueHint *hint, QXmlStreamReader *reader) const; }; } diff --git a/app/node/project/serializer/serializer210907.cpp b/app/node/project/serializer/serializer210907.cpp index 79936384e..fb673fe0e 100644 --- a/app/node/project/serializer/serializer210907.cpp +++ b/app/node/project/serializer/serializer210907.cpp @@ -29,17 +29,17 @@ namespace olive { ProjectSerializer210907::LoadData -ProjectSerializer210907::Load(Project *project, QXmlStreamReader *reader, +ProjectSerializer210907::load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const { XMLNodeData xml_node_data; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("uuid")) { - project->SetUuid(QUuid::fromString(reader->readElementText())); + project->set_uuid(QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("nodes")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { bool is_root = false; bool is_cm = false; @@ -73,16 +73,16 @@ ProjectSerializer210907::Load(Project *project, QXmlStreamReader *reader, bool handled_elsewhere = false; if (is_root) { - project->Initialize(); + project->initialize(); node = project->root(); } else if (is_cm) { - LoadColorManager(reader, project); + load_color_manager(reader, project); handled_elsewhere = true; } else if (is_settings) { - LoadProjectSettings(reader, project); + load_project_settings(reader, project); handled_elsewhere = true; } else { - node = NodeFactory::CreateFromID(id); + node = NodeFactory::create_from_id(id); } if (!handled_elsewhere) { @@ -91,7 +91,7 @@ ProjectSerializer210907::Load(Project *project, QXmlStreamReader *reader, << "Failed to find node with ID" << id; reader->skipCurrentElement(); } else { - LoadNode(node, xml_node_data, reader); + load_node(node, xml_node_data, reader); node->setParent(project); } } @@ -102,7 +102,7 @@ ProjectSerializer210907::Load(Project *project, QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("positions")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("context")) { quintptr context_ptr = 0; XMLAttributeLoop(reader, attr) @@ -119,18 +119,18 @@ ProjectSerializer210907::Load(Project *project, QXmlStreamReader *reader, qWarning() << "Failed to find pointer for context"; reader->skipCurrentElement(); } else { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { quintptr node_ptr; Node::Position node_pos; - if (LoadPosition(reader, &node_ptr, + if (load_position(reader, &node_ptr, &node_pos)) { Node *node = xml_node_data.node_ptrs.value(node_ptr); if (node) { - context->SetNodePositionInContext( + context->set_node_position_in_context( node, node_pos); } else { qWarning() @@ -156,18 +156,18 @@ ProjectSerializer210907::Load(Project *project, QXmlStreamReader *reader, } // Make connections - PostConnect(xml_node_data); + post_connect(xml_node_data); // Resolve tracks for (Node *n : project->nodes()) { - n->SetCachesEnabled(true); + n->set_caches_enabled(true); if (Track *t = dynamic_cast(n)) { - for (int i = 0; i < t->InputArraySize(Track::kBlockInput); i++) { + for (int i = 0; i < t->input_array_size(Track::k_block_input); i++) { Block *b = static_cast( - t->GetConnectedOutput(Track::kBlockInput, i)); + t->get_connected_output(Track::k_block_input, i)); if (!b->track()) { - t->AppendBlock(b); + t->append_block(b); } } } @@ -176,25 +176,25 @@ ProjectSerializer210907::Load(Project *project, QXmlStreamReader *reader, return LoadData(); } -void ProjectSerializer210907::LoadNode(Node *node, XMLNodeData &xml_node_data, +void ProjectSerializer210907::load_node(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const { - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("input")) { - LoadInput(node, reader, xml_node_data); + load_input(node, reader, xml_node_data); } else if (reader->name() == QStringLiteral("ptr")) { xml_node_data.node_ptrs.insert( reader->readElementText().toULongLong(), node); } else if (reader->name() == QStringLiteral("label")) { - node->SetLabel(reader->readElementText()); + node->set_label(reader->readElementText()); } else if (reader->name() == QStringLiteral("color")) { - node->SetOverrideColor(reader->readElementText().toInt()); + node->set_override_color(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("links")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("link")) { xml_node_data.block_links.append( { node, reader->readElementText().toULongLong() }); @@ -203,11 +203,11 @@ void ProjectSerializer210907::LoadNode(Node *node, XMLNodeData &xml_node_data, } } } else if (reader->name() == QStringLiteral("custom")) { - LoadNodeCustom(reader, node, xml_node_data); + load_node_custom(reader, node, xml_node_data); } else if (reader->name() == QStringLiteral("connections")) { // Load connections - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("connection")) { QString param_id; int ele = -1; @@ -223,7 +223,7 @@ void ProjectSerializer210907::LoadNode(Node *node, XMLNodeData &xml_node_data, QString output_node_id; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("output")) { output_node_id = reader->readElementText(); } else { @@ -239,7 +239,7 @@ void ProjectSerializer210907::LoadNode(Node *node, XMLNodeData &xml_node_data, } } } else if (reader->name() == QStringLiteral("hints")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("hint")) { QString input; int element = -1; @@ -254,8 +254,8 @@ void ProjectSerializer210907::LoadNode(Node *node, XMLNodeData &xml_node_data, } Node::ValueHint vh; - LoadValueHint(&vh, reader); - node->SetValueHintForInput(input, vh, element); + load_value_hint(&vh, reader); + node->set_value_hint_for_input(input, vh, element); } else { reader->skipCurrentElement(); } @@ -268,10 +268,10 @@ void ProjectSerializer210907::LoadNode(Node *node, XMLNodeData &xml_node_data, node->LoadFinishedEvent(); } -void ProjectSerializer210907::LoadColorManager(QXmlStreamReader *reader, +void ProjectSerializer210907::load_color_manager(QXmlStreamReader *reader, Project *project) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString id; XMLAttributeLoop(reader, attr) @@ -286,11 +286,11 @@ void ProjectSerializer210907::LoadColorManager(QXmlStreamReader *reader, id == QStringLiteral("reference_space")) { QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { value = reader->readElementText(); @@ -332,18 +332,18 @@ void ProjectSerializer210907::LoadColorManager(QXmlStreamReader *reader, }; int num_value = value.toInt(); value = list.at(num_value); - project->SetDefaultInputColorSpace(value); + project->set_default_input_color_space(value); } else if (id == QStringLiteral("reference_space")) { // Reference space if (value == QStringLiteral("1")) { - value = OCIO::ROLE_COMPOSITING_LOG; + value = ocio::ROLE_COMPOSITING_LOG; } else { - value = OCIO::ROLE_SCENE_LINEAR; + value = ocio::ROLE_SCENE_LINEAR; } - project->SetColorReferenceSpace(value); + project->set_color_reference_space(value); } else { // Config filename - project->SetColorConfigFilename(value); + project->set_color_config_filename(value); } } else { reader->skipCurrentElement(); @@ -354,10 +354,10 @@ void ProjectSerializer210907::LoadColorManager(QXmlStreamReader *reader, } } -void ProjectSerializer210907::LoadProjectSettings(QXmlStreamReader *reader, +void ProjectSerializer210907::load_project_settings(QXmlStreamReader *reader, Project *project) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString id; XMLAttributeLoop(reader, attr) @@ -371,11 +371,11 @@ void ProjectSerializer210907::LoadProjectSettings(QXmlStreamReader *reader, id == QStringLiteral("cache_path")) { QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { value = reader->readElementText(); @@ -393,10 +393,10 @@ void ProjectSerializer210907::LoadProjectSettings(QXmlStreamReader *reader, } if (id == QStringLiteral("cache_setting")) { - project->SetCacheLocationSetting( + project->set_cache_location_setting( static_cast(value.toInt())); } else { - project->SetCustomCachePath(value); + project->set_custom_cache_path(value); } } else { reader->skipCurrentElement(); @@ -407,7 +407,7 @@ void ProjectSerializer210907::LoadProjectSettings(QXmlStreamReader *reader, } } -void ProjectSerializer210907::LoadInput(Node *node, QXmlStreamReader *reader, +void ProjectSerializer210907::load_input(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const { QString param_id; @@ -427,34 +427,34 @@ void ProjectSerializer210907::LoadInput(Node *node, QXmlStreamReader *reader, return; } - if (!node->HasInputWithID(param_id)) { + if (!node->has_input_with_id(param_id)) { qWarning() << "Failed to load parameter that didn't exist:" << param_id; reader->skipCurrentElement(); return; } - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("primary")) { // Load primary immediate - LoadImmediate(reader, node, param_id, -1, xml_node_data); + load_immediate(reader, node, param_id, -1, xml_node_data); } else if (reader->name() == QStringLiteral("subelements")) { // Load subelements XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("count")) { - node->InputArrayResize(param_id, attr.value().toInt()); + node->input_array_resize(param_id, attr.value().toInt()); } } int element_counter = 0; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("element")) { - LoadImmediate(reader, node, param_id, element_counter, + load_immediate(reader, node, param_id, element_counter, xml_node_data); element_counter++; @@ -468,46 +468,46 @@ void ProjectSerializer210907::LoadInput(Node *node, QXmlStreamReader *reader, } } -void ProjectSerializer210907::LoadImmediate(QXmlStreamReader *reader, +void ProjectSerializer210907::load_immediate(QXmlStreamReader *reader, Node *node, const QString &input, int element, XMLNodeData &xml_node_data) const { Q_UNUSED(xml_node_data) - NodeValue::Type data_type = node->GetInputDataType(input); + NodeValue::Type data_type = node->get_input_data_type(input); - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { // Load standard value int val_index = 0; - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("track")) { QVariant value_on_track; - if (data_type == NodeValue::kVideoParams) { + if (data_type == NodeValue::k_video_params) { VideoParams vp; - vp.Load(reader); + vp.load(reader); value_on_track = QVariant::fromValue(vp); - } else if (data_type == NodeValue::kAudioParams) { + } else if (data_type == NodeValue::k_audio_params) { AudioParams ap = - TypeSerializer::LoadAudioParams(reader); + TypeSerializer::load_audio_params(reader); value_on_track = QVariant::fromValue(ap); } else { QString value_text = reader->readElementText(); if (!value_text.isEmpty()) { - value_on_track = NodeValue::StringToValue( + value_on_track = NodeValue::string_to_value( data_type, value_text, true); } } - node->SetSplitStandardValueOnTrack(input, val_index, + node->set_split_standard_value_on_track(input, val_index, value_on_track, element); val_index++; @@ -516,34 +516,34 @@ void ProjectSerializer210907::LoadImmediate(QXmlStreamReader *reader, } } } else if (reader->name() == QStringLiteral("keyframing") && - node->IsInputKeyframable(input)) { - node->SetInputIsKeyframing(input, reader->readElementText().toInt(), + node->is_input_keyframable(input)) { + node->set_input_is_keyframing(input, reader->readElementText().toInt(), element); } else if (reader->name() == QStringLiteral("keyframes")) { int track = 0; - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("track")) { - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("key")) { QString key_input; - rational key_time; - NodeKeyframe::Type key_type = NodeKeyframe::kLinear; + Rational key_time; + NodeKeyframe::Type key_type = NodeKeyframe::k_linear; QVariant key_value; QPointF key_in_handle; QPointF key_out_handle; XMLAttributeLoop(reader, attr) { - if (IsCancelled()) { + if (is_cancelled()) { return; } @@ -551,7 +551,7 @@ void ProjectSerializer210907::LoadImmediate(QXmlStreamReader *reader, key_input = attr.value().toString(); } else if (attr.name() == QStringLiteral("time")) { - key_time = rational::fromString( + key_time = Rational::from_string( attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("type")) { @@ -574,7 +574,7 @@ void ProjectSerializer210907::LoadImmediate(QXmlStreamReader *reader, } } - key_value = NodeValue::StringToValue( + key_value = NodeValue::string_to_value( data_type, reader->readElementText(), true); NodeKeyframe *key = new NodeKeyframe( @@ -593,16 +593,16 @@ void ProjectSerializer210907::LoadImmediate(QXmlStreamReader *reader, } } } else if (reader->name() == QStringLiteral("csinput")) { - node->SetInputProperty(input, QStringLiteral("col_input"), + node->set_input_property(input, QStringLiteral("col_input"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csdisplay")) { - node->SetInputProperty(input, QStringLiteral("col_display"), + node->set_input_property(input, QStringLiteral("col_display"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csview")) { - node->SetInputProperty(input, QStringLiteral("col_view"), + node->set_input_property(input, QStringLiteral("col_view"), reader->readElementText()); } else if (reader->name() == QStringLiteral("cslook")) { - node->SetInputProperty(input, QStringLiteral("col_look"), + node->set_input_property(input, QStringLiteral("col_look"), reader->readElementText()); } else { reader->skipCurrentElement(); @@ -610,7 +610,7 @@ void ProjectSerializer210907::LoadImmediate(QXmlStreamReader *reader, } } -bool ProjectSerializer210907::LoadPosition(QXmlStreamReader *reader, +bool ProjectSerializer210907::load_position(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const { @@ -627,7 +627,7 @@ bool ProjectSerializer210907::LoadPosition(QXmlStreamReader *reader, } } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("x")) { pos->position.setX(reader->readElementText().toDouble()); got_pos_x = true; @@ -644,12 +644,12 @@ bool ProjectSerializer210907::LoadPosition(QXmlStreamReader *reader, return got_node_ptr && got_pos_x && got_pos_y; } -void ProjectSerializer210907::PostConnect(const XMLNodeData &xml_node_data) const +void ProjectSerializer210907::post_connect(const XMLNodeData &xml_node_data) const { foreach (const XMLNodeData::SerializedConnection &con, xml_node_data.desired_connections) { if (Node *out = xml_node_data.node_ptrs.value(con.output_node)) { - Node::ConnectEdge(out, con.input); + Node::connect_edge(out, con.input); } } @@ -657,26 +657,26 @@ void ProjectSerializer210907::PostConnect(const XMLNodeData &xml_node_data) cons Node *a = l.block; Node *b = xml_node_data.node_ptrs.value(l.link); - Node::Link(a, b); + Node::link(a, b); } foreach (const XMLNodeData::GroupLink &l, xml_node_data.group_input_links) { if (Node *input_node = xml_node_data.node_ptrs.value(l.input_node)) { NodeInput resolved(input_node, l.input_id, l.input_element); - l.group->AddInputPassthrough(resolved); + l.group->add_input_passthrough(resolved); } } for (auto it = xml_node_data.group_output_links.cbegin(); it != xml_node_data.group_output_links.cend(); it++) { if (Node *output_node = xml_node_data.node_ptrs.value(it.value())) { - it.key()->SetOutputPassthrough(output_node); + it.key()->set_output_passthrough(output_node); } } } -void ProjectSerializer210907::LoadNodeCustom(QXmlStreamReader *reader, +void ProjectSerializer210907::load_node_custom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const { @@ -684,9 +684,9 @@ void ProjectSerializer210907::LoadNodeCustom(QXmlStreamReader *reader, if (ViewerOutput *viewer = dynamic_cast(node)) { Footage *footage = dynamic_cast(node); - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("points")) { - LoadTimelinePoints(reader, viewer); + load_timeline_points(reader, viewer); } else if (reader->name() == QStringLiteral("timestamp") && footage) { footage->set_timestamp(reader->readElementText().toLongLong()); @@ -696,24 +696,24 @@ void ProjectSerializer210907::LoadNodeCustom(QXmlStreamReader *reader, } } else if (Track *track = dynamic_cast(node)) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("height")) { - track->SetTrackHeight(reader->readElementText().toDouble()); + track->set_track_height(reader->readElementText().toDouble()); } else { reader->skipCurrentElement(); } } } else if (NodeGroup *group = dynamic_cast(node)) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthroughs")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthrough")) { XMLNodeData::GroupLink link; link.group = group; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { link.input_node = reader->readElementText().toULongLong(); @@ -747,25 +747,25 @@ void ProjectSerializer210907::LoadNodeCustom(QXmlStreamReader *reader, } } -void ProjectSerializer210907::LoadTimelinePoints(QXmlStreamReader *reader, +void ProjectSerializer210907::load_timeline_points(QXmlStreamReader *reader, ViewerOutput *points) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("markers")) { - LoadMarkerList(reader, points->GetMarkers()); + load_marker_list(reader, points->get_markers()); } else if (reader->name() == QStringLiteral("workarea")) { - LoadWorkArea(reader, points->GetWorkArea()); + load_work_area(reader, points->get_work_area()); } else { reader->skipCurrentElement(); } } } -void ProjectSerializer210907::LoadWorkArea(QXmlStreamReader *reader, +void ProjectSerializer210907::load_work_area(QXmlStreamReader *reader, TimelineWorkArea *workarea) const { - rational range_in = workarea->in(); - rational range_out = workarea->out(); + Rational range_in = workarea->in(); + Rational range_out = workarea->out(); XMLAttributeLoop(reader, attr) { @@ -773,10 +773,10 @@ void ProjectSerializer210907::LoadWorkArea(QXmlStreamReader *reader, workarea->set_enabled(attr.value() != QStringLiteral("0")); } else if (attr.name() == QStringLiteral("in")) { range_in = - rational::fromString(attr.value().toString().toStdString()); + Rational::from_string(attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { range_out = - rational::fromString(attr.value().toString().toStdString()); + Rational::from_string(attr.value().toString().toStdString()); } } @@ -789,28 +789,28 @@ void ProjectSerializer210907::LoadWorkArea(QXmlStreamReader *reader, reader->skipCurrentElement(); } -void ProjectSerializer210907::LoadMarkerList(QXmlStreamReader *reader, +void ProjectSerializer210907::load_marker_list(QXmlStreamReader *reader, TimelineMarkerList *markers) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("marker")) { QString name; - rational in, out; + Rational in, out; XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("name")) { name = attr.value().toString(); } else if (attr.name() == QStringLiteral("in")) { - in = rational::fromString( + in = Rational::from_string( attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { - out = rational::fromString( + out = Rational::from_string( attr.value().toString().toStdString()); } } - new TimelineMarker(OLIVE_CONFIG("MarkerColor").toInt(), + new TimelineMarker(OAK_CONFIG("MarkerColor").toInt(), TimeRange(in, out), name, markers); } @@ -818,14 +818,14 @@ void ProjectSerializer210907::LoadMarkerList(QXmlStreamReader *reader, } } -void ProjectSerializer210907::LoadValueHint(Node::ValueHint *hint, +void ProjectSerializer210907::load_value_hint(Node::ValueHint *hint, QXmlStreamReader *reader) const { QVector types; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("types")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("type")) { types.append(static_cast( reader->readElementText().toInt())); diff --git a/app/node/project/serializer/serializer210907.h b/app/node/project/serializer/serializer210907.h index 081d1d361..ec5bf54e9 100644 --- a/app/node/project/serializer/serializer210907.h +++ b/app/node/project/serializer/serializer210907.h @@ -19,8 +19,8 @@ ***/ -#ifndef SERIALIZER210907_H -#define SERIALIZER210907_H +#ifndef OAK_SERIALIZER210907_H +#define OAK_SERIALIZER210907_H #include "serializer.h" @@ -32,10 +32,10 @@ public: ProjectSerializer210907() = default; protected: - virtual LoadData Load(Project *project, QXmlStreamReader *reader, + virtual LoadData load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const override; - virtual uint Version() const override + virtual uint version() const override { return 210907; } @@ -66,38 +66,38 @@ private: QHash group_output_links; }; - void LoadNode(Node *node, XMLNodeData &xml_node_data, + void load_node(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const; - void LoadColorManager(QXmlStreamReader *reader, Project *project) const; + void load_color_manager(QXmlStreamReader *reader, Project *project) const; - void LoadProjectSettings(QXmlStreamReader *reader, Project *project) const; + void load_project_settings(QXmlStreamReader *reader, Project *project) const; - void LoadInput(Node *node, QXmlStreamReader *reader, + void load_input(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const; - void LoadImmediate(QXmlStreamReader *reader, Node *node, + void load_immediate(QXmlStreamReader *reader, Node *node, const QString &input, int element, XMLNodeData &xml_node_data) const; - bool LoadPosition(QXmlStreamReader *reader, quintptr *node_ptr, + bool load_position(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const; - void PostConnect(const XMLNodeData &xml_node_data) const; + void post_connect(const XMLNodeData &xml_node_data) const; - void LoadNodeCustom(QXmlStreamReader *reader, Node *node, + void load_node_custom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const; - void LoadTimelinePoints(QXmlStreamReader *reader, + void load_timeline_points(QXmlStreamReader *reader, ViewerOutput *points) const; - void LoadWorkArea(QXmlStreamReader *reader, + void load_work_area(QXmlStreamReader *reader, TimelineWorkArea *workarea) const; - void LoadMarkerList(QXmlStreamReader *reader, + void load_marker_list(QXmlStreamReader *reader, TimelineMarkerList *markers) const; - void LoadValueHint(Node::ValueHint *hint, QXmlStreamReader *reader) const; + void load_value_hint(Node::ValueHint *hint, QXmlStreamReader *reader) const; }; } diff --git a/app/node/project/serializer/serializer211228.cpp b/app/node/project/serializer/serializer211228.cpp index b6e29f4f3..3b95410f0 100644 --- a/app/node/project/serializer/serializer211228.cpp +++ b/app/node/project/serializer/serializer211228.cpp @@ -29,19 +29,19 @@ namespace olive { ProjectSerializer211228::LoadData -ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, +ProjectSerializer211228::load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const { QMap> properties; QMap> positions; XMLNodeData xml_node_data; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("uuid")) { - project->SetUuid(QUuid::fromString(reader->readElementText())); + project->set_uuid(QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("nodes")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { bool is_root = false; bool is_cm = false; @@ -75,16 +75,16 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, bool handled_elsewhere = false; if (is_root) { - project->Initialize(); + project->initialize(); node = project->root(); } else if (is_cm) { - LoadColorManager(reader, project); + load_color_manager(reader, project); handled_elsewhere = true; } else if (is_settings) { - LoadProjectSettings(reader, project); + load_project_settings(reader, project); handled_elsewhere = true; } else { - node = NodeFactory::CreateFromID(id); + node = NodeFactory::create_from_id(id); } if (!handled_elsewhere) { @@ -93,7 +93,7 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, << "Failed to find node with ID" << id; reader->skipCurrentElement(); } else { - LoadNode(node, xml_node_data, reader); + load_node(node, xml_node_data, reader); node->setParent(project); } } @@ -104,7 +104,7 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("positions")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("context")) { quintptr context_ptr = 0; XMLAttributeLoop(reader, attr) @@ -116,12 +116,12 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, } if (context_ptr) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { quintptr node_ptr; Node::Position node_pos; - if (LoadPosition(reader, &node_ptr, + if (load_position(reader, &node_ptr, &node_pos)) { if (node_ptr) { positions[context_ptr].insert(node_ptr, @@ -148,7 +148,7 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("properties")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { quintptr ptr = 0; @@ -164,7 +164,7 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, if (ptr) { QMap properties_for_node; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { properties_for_node.insert( reader->name().toString(), reader->readElementText()); @@ -189,14 +189,14 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, for (auto jt = it.value().cbegin(); jt != it.value().cend(); jt++) { Node *n = xml_node_data.node_ptrs.value(jt.key()); if (n) { - ctx->SetNodePositionInContext(n, jt.value()); + ctx->set_node_position_in_context(n, jt.value()); } } } } // Make connections - PostConnect(xml_node_data); + post_connect(xml_node_data); LoadData load_data; load_data.node_ptrs = xml_node_data.node_ptrs; @@ -212,14 +212,14 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, // Resolve tracks for (Node *n : project->nodes()) { - n->SetCachesEnabled(true); + n->set_caches_enabled(true); if (Track *t = dynamic_cast(n)) { - for (int i = 0; i < t->InputArraySize(Track::kBlockInput); i++) { + for (int i = 0; i < t->input_array_size(Track::k_block_input); i++) { Block *b = static_cast( - t->GetConnectedOutput(Track::kBlockInput, i)); + t->get_connected_output(Track::k_block_input, i)); if (!b->track()) { - t->AppendBlock(b); + t->append_block(b); } } } @@ -228,28 +228,28 @@ ProjectSerializer211228::Load(Project *project, QXmlStreamReader *reader, return load_data; } -void ProjectSerializer211228::LoadNode(Node *node, XMLNodeData &xml_node_data, +void ProjectSerializer211228::load_node(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const { - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("input")) { - LoadInput(node, reader, xml_node_data); + load_input(node, reader, xml_node_data); } else if (reader->name() == QStringLiteral("ptr")) { quintptr ptr = reader->readElementText().toULongLong(); xml_node_data.node_ptrs.insert(ptr, node); } else if (reader->name() == QStringLiteral("label")) { - node->SetLabel(reader->readElementText()); + node->set_label(reader->readElementText()); } else if (reader->name() == QStringLiteral("uuid")) { xml_node_data.node_uuids.insert( node, QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("color")) { - node->SetOverrideColor(reader->readElementText().toInt()); + node->set_override_color(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("links")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("link")) { xml_node_data.block_links.append( { node, reader->readElementText().toULongLong() }); @@ -258,10 +258,10 @@ void ProjectSerializer211228::LoadNode(Node *node, XMLNodeData &xml_node_data, } } } else if (reader->name() == QStringLiteral("custom")) { - LoadNodeCustom(reader, node, xml_node_data); + load_node_custom(reader, node, xml_node_data); } else if (reader->name() == QStringLiteral("connections")) { // Load connections - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("connection")) { QString param_id; int ele = -1; @@ -277,7 +277,7 @@ void ProjectSerializer211228::LoadNode(Node *node, XMLNodeData &xml_node_data, QString output_node_id; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("output")) { output_node_id = reader->readElementText(); } else { @@ -293,7 +293,7 @@ void ProjectSerializer211228::LoadNode(Node *node, XMLNodeData &xml_node_data, } } } else if (reader->name() == QStringLiteral("hints")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("hint")) { QString input; int element = -1; @@ -308,8 +308,8 @@ void ProjectSerializer211228::LoadNode(Node *node, XMLNodeData &xml_node_data, } Node::ValueHint vh; - LoadValueHint(&vh, reader); - node->SetValueHintForInput(input, vh, element); + load_value_hint(&vh, reader); + node->set_value_hint_for_input(input, vh, element); } else { reader->skipCurrentElement(); } @@ -322,10 +322,10 @@ void ProjectSerializer211228::LoadNode(Node *node, XMLNodeData &xml_node_data, node->LoadFinishedEvent(); } -void ProjectSerializer211228::LoadColorManager(QXmlStreamReader *reader, +void ProjectSerializer211228::load_color_manager(QXmlStreamReader *reader, Project *project) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString id; XMLAttributeLoop(reader, attr) @@ -340,11 +340,11 @@ void ProjectSerializer211228::LoadColorManager(QXmlStreamReader *reader, id == QStringLiteral("reference_space")) { QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { value = reader->readElementText(); @@ -386,18 +386,18 @@ void ProjectSerializer211228::LoadColorManager(QXmlStreamReader *reader, }; int num_value = value.toInt(); value = list.at(num_value); - project->SetDefaultInputColorSpace(value); + project->set_default_input_color_space(value); } else if (id == QStringLiteral("reference_space")) { // Reference space if (value == QStringLiteral("1")) { - value = OCIO::ROLE_COMPOSITING_LOG; + value = ocio::ROLE_COMPOSITING_LOG; } else { - value = OCIO::ROLE_SCENE_LINEAR; + value = ocio::ROLE_SCENE_LINEAR; } - project->SetColorReferenceSpace(value); + project->set_color_reference_space(value); } else { // Config filename - project->SetColorConfigFilename(value); + project->set_color_config_filename(value); } } else { reader->skipCurrentElement(); @@ -408,10 +408,10 @@ void ProjectSerializer211228::LoadColorManager(QXmlStreamReader *reader, } } -void ProjectSerializer211228::LoadProjectSettings(QXmlStreamReader *reader, +void ProjectSerializer211228::load_project_settings(QXmlStreamReader *reader, Project *project) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString id; XMLAttributeLoop(reader, attr) @@ -425,11 +425,11 @@ void ProjectSerializer211228::LoadProjectSettings(QXmlStreamReader *reader, id == QStringLiteral("cache_path")) { QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { value = reader->readElementText(); @@ -447,10 +447,10 @@ void ProjectSerializer211228::LoadProjectSettings(QXmlStreamReader *reader, } if (id == QStringLiteral("cache_setting")) { - project->SetCacheLocationSetting( + project->set_cache_location_setting( static_cast(value.toInt())); } else { - project->SetCustomCachePath(value); + project->set_custom_cache_path(value); } } else { reader->skipCurrentElement(); @@ -461,7 +461,7 @@ void ProjectSerializer211228::LoadProjectSettings(QXmlStreamReader *reader, } } -void ProjectSerializer211228::LoadInput(Node *node, QXmlStreamReader *reader, +void ProjectSerializer211228::load_input(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const { QString param_id; @@ -481,34 +481,34 @@ void ProjectSerializer211228::LoadInput(Node *node, QXmlStreamReader *reader, return; } - if (!node->HasInputWithID(param_id)) { + if (!node->has_input_with_id(param_id)) { qWarning() << "Failed to load parameter that didn't exist:" << param_id; reader->skipCurrentElement(); return; } - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("primary")) { // Load primary immediate - LoadImmediate(reader, node, param_id, -1, xml_node_data); + load_immediate(reader, node, param_id, -1, xml_node_data); } else if (reader->name() == QStringLiteral("subelements")) { // Load subelements XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("count")) { - node->InputArrayResize(param_id, attr.value().toInt()); + node->input_array_resize(param_id, attr.value().toInt()); } } int element_counter = 0; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("element")) { - LoadImmediate(reader, node, param_id, element_counter, + load_immediate(reader, node, param_id, element_counter, xml_node_data); element_counter++; @@ -522,46 +522,46 @@ void ProjectSerializer211228::LoadInput(Node *node, QXmlStreamReader *reader, } } -void ProjectSerializer211228::LoadImmediate(QXmlStreamReader *reader, +void ProjectSerializer211228::load_immediate(QXmlStreamReader *reader, Node *node, const QString &input, int element, XMLNodeData &xml_node_data) const { Q_UNUSED(xml_node_data) - NodeValue::Type data_type = node->GetInputDataType(input); + NodeValue::Type data_type = node->get_input_data_type(input); - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { // Load standard value int val_index = 0; - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("track")) { QVariant value_on_track; - if (data_type == NodeValue::kVideoParams) { + if (data_type == NodeValue::k_video_params) { VideoParams vp; - vp.Load(reader); + vp.load(reader); value_on_track = QVariant::fromValue(vp); - } else if (data_type == NodeValue::kAudioParams) { + } else if (data_type == NodeValue::k_audio_params) { AudioParams ap = - TypeSerializer::LoadAudioParams(reader); + TypeSerializer::load_audio_params(reader); value_on_track = QVariant::fromValue(ap); } else { QString value_text = reader->readElementText(); if (!value_text.isEmpty()) { - value_on_track = NodeValue::StringToValue( + value_on_track = NodeValue::string_to_value( data_type, value_text, true); } } - node->SetSplitStandardValueOnTrack(input, val_index, + node->set_split_standard_value_on_track(input, val_index, value_on_track, element); val_index++; @@ -570,34 +570,34 @@ void ProjectSerializer211228::LoadImmediate(QXmlStreamReader *reader, } } } else if (reader->name() == QStringLiteral("keyframing") && - node->IsInputKeyframable(input)) { - node->SetInputIsKeyframing(input, reader->readElementText().toInt(), + node->is_input_keyframable(input)) { + node->set_input_is_keyframing(input, reader->readElementText().toInt(), element); } else if (reader->name() == QStringLiteral("keyframes")) { int track = 0; - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("track")) { - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("key")) { QString key_input; - rational key_time; - NodeKeyframe::Type key_type = NodeKeyframe::kLinear; + Rational key_time; + NodeKeyframe::Type key_type = NodeKeyframe::k_linear; QVariant key_value; QPointF key_in_handle; QPointF key_out_handle; XMLAttributeLoop(reader, attr) { - if (IsCancelled()) { + if (is_cancelled()) { return; } @@ -605,7 +605,7 @@ void ProjectSerializer211228::LoadImmediate(QXmlStreamReader *reader, key_input = attr.value().toString(); } else if (attr.name() == QStringLiteral("time")) { - key_time = rational::fromString( + key_time = Rational::from_string( attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("type")) { @@ -628,7 +628,7 @@ void ProjectSerializer211228::LoadImmediate(QXmlStreamReader *reader, } } - key_value = NodeValue::StringToValue( + key_value = NodeValue::string_to_value( data_type, reader->readElementText(), true); NodeKeyframe *key = new NodeKeyframe( @@ -647,16 +647,16 @@ void ProjectSerializer211228::LoadImmediate(QXmlStreamReader *reader, } } } else if (reader->name() == QStringLiteral("csinput")) { - node->SetInputProperty(input, QStringLiteral("col_input"), + node->set_input_property(input, QStringLiteral("col_input"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csdisplay")) { - node->SetInputProperty(input, QStringLiteral("col_display"), + node->set_input_property(input, QStringLiteral("col_display"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csview")) { - node->SetInputProperty(input, QStringLiteral("col_view"), + node->set_input_property(input, QStringLiteral("col_view"), reader->readElementText()); } else if (reader->name() == QStringLiteral("cslook")) { - node->SetInputProperty(input, QStringLiteral("col_look"), + node->set_input_property(input, QStringLiteral("col_look"), reader->readElementText()); } else { reader->skipCurrentElement(); @@ -664,7 +664,7 @@ void ProjectSerializer211228::LoadImmediate(QXmlStreamReader *reader, } } -bool ProjectSerializer211228::LoadPosition(QXmlStreamReader *reader, +bool ProjectSerializer211228::load_position(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const { @@ -681,7 +681,7 @@ bool ProjectSerializer211228::LoadPosition(QXmlStreamReader *reader, } } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("x")) { pos->position.setX(reader->readElementText().toDouble()); got_pos_x = true; @@ -698,12 +698,12 @@ bool ProjectSerializer211228::LoadPosition(QXmlStreamReader *reader, return got_node_ptr && got_pos_x && got_pos_y; } -void ProjectSerializer211228::PostConnect(const XMLNodeData &xml_node_data) const +void ProjectSerializer211228::post_connect(const XMLNodeData &xml_node_data) const { foreach (const XMLNodeData::SerializedConnection &con, xml_node_data.desired_connections) { if (Node *out = xml_node_data.node_ptrs.value(con.output_node)) { - Node::ConnectEdge(out, con.input); + Node::connect_edge(out, con.input); } } @@ -711,26 +711,26 @@ void ProjectSerializer211228::PostConnect(const XMLNodeData &xml_node_data) cons Node *a = l.block; Node *b = xml_node_data.node_ptrs.value(l.link); - Node::Link(a, b); + Node::link(a, b); } foreach (const XMLNodeData::GroupLink &l, xml_node_data.group_input_links) { if (Node *input_node = xml_node_data.node_ptrs.value(l.input_node)) { NodeInput resolved(input_node, l.input_id, l.input_element); - l.group->AddInputPassthrough(resolved); + l.group->add_input_passthrough(resolved); } } for (auto it = xml_node_data.group_output_links.cbegin(); it != xml_node_data.group_output_links.cend(); it++) { if (Node *output_node = xml_node_data.node_ptrs.value(it.value())) { - it.key()->SetOutputPassthrough(output_node); + it.key()->set_output_passthrough(output_node); } } } -void ProjectSerializer211228::LoadNodeCustom(QXmlStreamReader *reader, +void ProjectSerializer211228::load_node_custom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const { @@ -738,9 +738,9 @@ void ProjectSerializer211228::LoadNodeCustom(QXmlStreamReader *reader, if (ViewerOutput *viewer = dynamic_cast(node)) { Footage *footage = dynamic_cast(node); - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("points")) { - LoadTimelinePoints(reader, viewer); + load_timeline_points(reader, viewer); } else if (reader->name() == QStringLiteral("timestamp") && footage) { footage->set_timestamp(reader->readElementText().toLongLong()); @@ -750,24 +750,24 @@ void ProjectSerializer211228::LoadNodeCustom(QXmlStreamReader *reader, } } else if (Track *track = dynamic_cast(node)) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("height")) { - track->SetTrackHeight(reader->readElementText().toDouble()); + track->set_track_height(reader->readElementText().toDouble()); } else { reader->skipCurrentElement(); } } } else if (NodeGroup *group = dynamic_cast(node)) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthroughs")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthrough")) { XMLNodeData::GroupLink link; link.group = group; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { link.input_node = reader->readElementText().toULongLong(); @@ -801,25 +801,25 @@ void ProjectSerializer211228::LoadNodeCustom(QXmlStreamReader *reader, } } -void ProjectSerializer211228::LoadTimelinePoints(QXmlStreamReader *reader, +void ProjectSerializer211228::load_timeline_points(QXmlStreamReader *reader, ViewerOutput *points) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("markers")) { - LoadMarkerList(reader, points->GetMarkers()); + load_marker_list(reader, points->get_markers()); } else if (reader->name() == QStringLiteral("workarea")) { - LoadWorkArea(reader, points->GetWorkArea()); + load_work_area(reader, points->get_work_area()); } else { reader->skipCurrentElement(); } } } -void ProjectSerializer211228::LoadWorkArea(QXmlStreamReader *reader, +void ProjectSerializer211228::load_work_area(QXmlStreamReader *reader, TimelineWorkArea *workarea) const { - rational range_in = workarea->in(); - rational range_out = workarea->out(); + Rational range_in = workarea->in(); + Rational range_out = workarea->out(); XMLAttributeLoop(reader, attr) { @@ -827,10 +827,10 @@ void ProjectSerializer211228::LoadWorkArea(QXmlStreamReader *reader, workarea->set_enabled(attr.value() != QStringLiteral("0")); } else if (attr.name() == QStringLiteral("in")) { range_in = - rational::fromString(attr.value().toString().toStdString()); + Rational::from_string(attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { range_out = - rational::fromString(attr.value().toString().toStdString()); + Rational::from_string(attr.value().toString().toStdString()); } } @@ -843,28 +843,28 @@ void ProjectSerializer211228::LoadWorkArea(QXmlStreamReader *reader, reader->skipCurrentElement(); } -void ProjectSerializer211228::LoadMarkerList(QXmlStreamReader *reader, +void ProjectSerializer211228::load_marker_list(QXmlStreamReader *reader, TimelineMarkerList *markers) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("marker")) { QString name; - rational in, out; + Rational in, out; XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("name")) { name = attr.value().toString(); } else if (attr.name() == QStringLiteral("in")) { - in = rational::fromString( + in = Rational::from_string( attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { - out = rational::fromString( + out = Rational::from_string( attr.value().toString().toStdString()); } } - new TimelineMarker(OLIVE_CONFIG("MarkerColor").toInt(), + new TimelineMarker(OAK_CONFIG("MarkerColor").toInt(), TimeRange(in, out), name, markers); } @@ -872,14 +872,14 @@ void ProjectSerializer211228::LoadMarkerList(QXmlStreamReader *reader, } } -void ProjectSerializer211228::LoadValueHint(Node::ValueHint *hint, +void ProjectSerializer211228::load_value_hint(Node::ValueHint *hint, QXmlStreamReader *reader) const { QVector types; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("types")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("type")) { types.append(static_cast( reader->readElementText().toInt())); diff --git a/app/node/project/serializer/serializer211228.h b/app/node/project/serializer/serializer211228.h index 20c56437a..58f07679e 100644 --- a/app/node/project/serializer/serializer211228.h +++ b/app/node/project/serializer/serializer211228.h @@ -19,8 +19,8 @@ ***/ -#ifndef SERIALIZER211228_H -#define SERIALIZER211228_H +#ifndef OAK_SERIALIZER211228_H +#define OAK_SERIALIZER211228_H #include "serializer.h" @@ -32,10 +32,10 @@ public: ProjectSerializer211228() = default; protected: - virtual LoadData Load(Project *project, QXmlStreamReader *reader, + virtual LoadData load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const override; - virtual uint Version() const override + virtual uint version() const override { return 211228; } @@ -67,40 +67,40 @@ private: QHash node_uuids; }; - void LoadNode(Node *node, XMLNodeData &xml_node_data, + void load_node(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const; - void LoadColorManager(QXmlStreamReader *reader, Project *project) const; + void load_color_manager(QXmlStreamReader *reader, Project *project) const; - void LoadProjectSettings(QXmlStreamReader *reader, Project *project) const; + void load_project_settings(QXmlStreamReader *reader, Project *project) const; - void LoadInput(Node *node, QXmlStreamReader *reader, + void load_input(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const; - void LoadImmediate(QXmlStreamReader *reader, Node *node, + void load_immediate(QXmlStreamReader *reader, Node *node, const QString &input, int element, XMLNodeData &xml_node_data) const; - bool LoadPosition(QXmlStreamReader *reader, quintptr *node_ptr, + bool load_position(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const; - void PostConnect(const XMLNodeData &xml_node_data) const; + void post_connect(const XMLNodeData &xml_node_data) const; - void LoadNodeCustom(QXmlStreamReader *reader, Node *node, + void load_node_custom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const; - void LoadTimelinePoints(QXmlStreamReader *reader, + void load_timeline_points(QXmlStreamReader *reader, ViewerOutput *points) const; - void LoadWorkArea(QXmlStreamReader *reader, + void load_work_area(QXmlStreamReader *reader, TimelineWorkArea *workarea) const; - void LoadMarkerList(QXmlStreamReader *reader, + void load_marker_list(QXmlStreamReader *reader, TimelineMarkerList *markers) const; - void LoadValueHint(Node::ValueHint *hint, QXmlStreamReader *reader) const; + void load_value_hint(Node::ValueHint *hint, QXmlStreamReader *reader) const; }; } -#endif // SERIALIZER211228_H +#endif // OAK_SERIALIZER211228_H diff --git a/app/node/project/serializer/serializer220403.cpp b/app/node/project/serializer/serializer220403.cpp index 2f3278729..2c1860538 100644 --- a/app/node/project/serializer/serializer220403.cpp +++ b/app/node/project/serializer/serializer220403.cpp @@ -29,7 +29,7 @@ namespace olive { ProjectSerializer220403::LoadData -ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, +ProjectSerializer220403::load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const { QMap> properties; @@ -38,36 +38,36 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, LoadData load_data; - if ((load_type == kProject && + if ((load_type == k_project && reader->name() == QStringLiteral("project")) || - ((load_type == kOnlyNodes && + ((load_type == k_only_nodes && reader->name() == QStringLiteral("nodes")) || - (load_type == kOnlyClips && + (load_type == k_only_clips && reader->name() == QStringLiteral("timeline"))) || - (load_type == kOnlyKeyframes && + (load_type == k_only_keyframes && reader->name() == QStringLiteral("keyframes")) || - (load_type == kOnlyMarkers && + (load_type == k_only_markers && reader->name() == QStringLiteral("markers"))) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("layout")) { // Since the main window's functions have to occur in the GUI thread (and we're likely // loading in a secondary thread), we load all necessary data into a separate struct so we // can continue loading and queue it with the main window so it can handle the data // appropriately in its own thread. - load_data.layout = MainWindowLayoutInfo::fromXml( + load_data.layout = MainWindowLayoutInfo::from_xml( reader, xml_node_data.node_ptrs); } else if (reader->name() == QStringLiteral("uuid")) { if (project) { - project->SetUuid( + project->set_uuid( QUuid::fromString(reader->readElementText())); } else { reader->skipCurrentElement(); } } else if (reader->name() == QStringLiteral("nodes")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { bool is_root = false; bool is_cm = false; @@ -106,16 +106,16 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, bool handled_elsewhere = false; if (is_root) { - project->Initialize(); + project->initialize(); node = project->root(); } else if (is_cm) { - LoadColorManager(reader, project); + load_color_manager(reader, project); handled_elsewhere = true; } else if (is_settings) { - LoadProjectSettings(reader, project); + load_project_settings(reader, project); handled_elsewhere = true; } else { - node = NodeFactory::CreateFromID(id); + node = NodeFactory::create_from_id(id); } if (!handled_elsewhere) { @@ -124,7 +124,7 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, << "Failed to find node with ID" << id; reader->skipCurrentElement(); } else { - LoadNode(node, xml_node_data, reader); + load_node(node, xml_node_data, reader); if (project) { node->setParent(project); } else { @@ -139,7 +139,7 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("keyframes")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { QString node_id; XMLAttributeLoop(reader, attr) @@ -152,13 +152,13 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, Node *n = nullptr; if (!node_id.isEmpty()) { - n = NodeFactory::CreateFromID(node_id); + n = NodeFactory::create_from_id(node_id); } if (!n) { reader->skipCurrentElement(); } else { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString input_id; XMLAttributeLoop(reader, attr) @@ -174,7 +174,7 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, reader->skipCurrentElement(); } else { while ( - XMLReadNextStartElement(reader)) { + xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("element")) { QString element_id; @@ -193,7 +193,7 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, reader->skipCurrentElement(); } else { while ( - XMLReadNextStartElement( + xml_read_next_start_element( reader)) { if (reader->name() == QStringLiteral( @@ -218,7 +218,7 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, ->skipCurrentElement(); } else { while ( - XMLReadNextStartElement( + xml_read_next_start_element( reader)) { if (reader ->name() == @@ -236,10 +236,10 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, track_id .toInt()); - LoadKeyframe( + load_keyframe( reader, key, - n->GetInputDataType( + n->get_input_data_type( input_id)); load_data @@ -277,10 +277,10 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("markers")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("marker")) { TimelineMarker *marker = new TimelineMarker(); - LoadMarker(reader, marker); + load_marker(reader, marker); load_data.markers.push_back(marker); } else { reader->skipCurrentElement(); @@ -288,7 +288,7 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("positions")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("context")) { quintptr context_ptr = 0; XMLAttributeLoop(reader, attr) @@ -300,12 +300,12 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, } if (context_ptr) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { quintptr node_ptr; Node::Position node_pos; - if (LoadPosition(reader, &node_ptr, + if (load_position(reader, &node_ptr, &node_pos)) { if (node_ptr) { positions[context_ptr].insert( @@ -332,7 +332,7 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("properties")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { quintptr ptr = 0; @@ -348,7 +348,7 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, if (ptr) { QMap properties_for_node; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { properties_for_node.insert( reader->name().toString(), reader->readElementText()); @@ -374,14 +374,14 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, for (auto jt = it.value().cbegin(); jt != it.value().cend(); jt++) { Node *n = xml_node_data.node_ptrs.value(jt.key()); if (n) { - ctx->SetNodePositionInContext(n, jt.value()); + ctx->set_node_position_in_context(n, jt.value()); } } } } // Make connections - PostConnect(xml_node_data); + post_connect(xml_node_data); load_data.node_ptrs = xml_node_data.node_ptrs; load_data.node_uuids = xml_node_data.node_uuids; @@ -397,14 +397,14 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, // Re-enable caches and resolve tracks const QVector &nodes = project ? project->nodes() : load_data.nodes; for (Node *n : nodes) { - n->SetCachesEnabled(true); + n->set_caches_enabled(true); if (Track *t = dynamic_cast(n)) { - for (int i = 0; i < t->InputArraySize(Track::kBlockInput); i++) { + for (int i = 0; i < t->input_array_size(Track::k_block_input); i++) { Block *b = static_cast( - t->GetConnectedOutput(Track::kBlockInput, i)); + t->get_connected_output(Track::k_block_input, i)); if (!b->track()) { - t->AppendBlock(b); + t->append_block(b); } } } @@ -412,8 +412,8 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, // Clear duplicate label (to facilitate #2147) if (ClipBlock *c = dynamic_cast(n)) { if (c->connected_viewer() && - c->GetLabel() == c->connected_viewer()->GetLabel()) { - c->SetLabel(QString()); + c->get_label() == c->connected_viewer()->get_label()) { + c->set_label(QString()); } } } @@ -421,28 +421,28 @@ ProjectSerializer220403::Load(Project *project, QXmlStreamReader *reader, return load_data; } -void ProjectSerializer220403::LoadNode(Node *node, XMLNodeData &xml_node_data, +void ProjectSerializer220403::load_node(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const { - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("input")) { - LoadInput(node, reader, xml_node_data); + load_input(node, reader, xml_node_data); } else if (reader->name() == QStringLiteral("ptr")) { quintptr ptr = reader->readElementText().toULongLong(); xml_node_data.node_ptrs.insert(ptr, node); } else if (reader->name() == QStringLiteral("label")) { - node->SetLabel(reader->readElementText()); + node->set_label(reader->readElementText()); } else if (reader->name() == QStringLiteral("uuid")) { xml_node_data.node_uuids.insert( node, QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("color")) { - node->SetOverrideColor(reader->readElementText().toInt()); + node->set_override_color(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("links")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("link")) { xml_node_data.block_links.append( { node, reader->readElementText().toULongLong() }); @@ -451,10 +451,10 @@ void ProjectSerializer220403::LoadNode(Node *node, XMLNodeData &xml_node_data, } } } else if (reader->name() == QStringLiteral("custom")) { - LoadNodeCustom(reader, node, xml_node_data); + load_node_custom(reader, node, xml_node_data); } else if (reader->name() == QStringLiteral("connections")) { // Load connections - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("connection")) { QString param_id; int ele = -1; @@ -470,7 +470,7 @@ void ProjectSerializer220403::LoadNode(Node *node, XMLNodeData &xml_node_data, QString output_node_id; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("output")) { output_node_id = reader->readElementText(); } else { @@ -486,7 +486,7 @@ void ProjectSerializer220403::LoadNode(Node *node, XMLNodeData &xml_node_data, } } } else if (reader->name() == QStringLiteral("hints")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("hint")) { QString input; int element = -1; @@ -501,25 +501,25 @@ void ProjectSerializer220403::LoadNode(Node *node, XMLNodeData &xml_node_data, } Node::ValueHint vh; - LoadValueHint(&vh, reader); - node->SetValueHintForInput(input, vh, element); + load_value_hint(&vh, reader); + node->set_value_hint_for_input(input, vh, element); } else { reader->skipCurrentElement(); } } } else if (reader->name() == QStringLiteral("caches")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("audio")) { - node->audio_playback_cache()->SetUuid( + node->audio_playback_cache()->set_uuid( QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("video")) { - node->video_frame_cache()->SetUuid( + node->video_frame_cache()->set_uuid( QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("thumb")) { - node->thumbnail_cache()->SetUuid( + node->thumbnail_cache()->set_uuid( QUuid::fromString(reader->readElementText())); } else if (reader->name() == QStringLiteral("waveform")) { - node->waveform_cache()->SetUuid( + node->waveform_cache()->set_uuid( QUuid::fromString(reader->readElementText())); } else { reader->skipCurrentElement(); @@ -533,10 +533,10 @@ void ProjectSerializer220403::LoadNode(Node *node, XMLNodeData &xml_node_data, node->LoadFinishedEvent(); } -void ProjectSerializer220403::LoadColorManager(QXmlStreamReader *reader, +void ProjectSerializer220403::load_color_manager(QXmlStreamReader *reader, Project *project) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString id; XMLAttributeLoop(reader, attr) @@ -551,11 +551,11 @@ void ProjectSerializer220403::LoadColorManager(QXmlStreamReader *reader, id == QStringLiteral("reference_space")) { QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { value = reader->readElementText(); @@ -596,18 +596,18 @@ void ProjectSerializer220403::LoadColorManager(QXmlStreamReader *reader, }; int num_value = value.toInt(); value = list.at(num_value); - project->SetDefaultInputColorSpace(value); + project->set_default_input_color_space(value); } else if (id == QStringLiteral("reference_space")) { // Reference space if (value == QStringLiteral("1")) { - value = OCIO::ROLE_COMPOSITING_LOG; + value = ocio::ROLE_COMPOSITING_LOG; } else { - value = OCIO::ROLE_SCENE_LINEAR; + value = ocio::ROLE_SCENE_LINEAR; } - project->SetColorReferenceSpace(value); + project->set_color_reference_space(value); } else { // Config filename - project->SetColorConfigFilename(value); + project->set_color_config_filename(value); } } else { reader->skipCurrentElement(); @@ -618,10 +618,10 @@ void ProjectSerializer220403::LoadColorManager(QXmlStreamReader *reader, } } -void ProjectSerializer220403::LoadProjectSettings(QXmlStreamReader *reader, +void ProjectSerializer220403::load_project_settings(QXmlStreamReader *reader, Project *project) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString id; XMLAttributeLoop(reader, attr) @@ -635,11 +635,11 @@ void ProjectSerializer220403::LoadProjectSettings(QXmlStreamReader *reader, id == QStringLiteral("cache_path")) { QString value; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("primary")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("track")) { value = reader->readElementText(); @@ -657,10 +657,10 @@ void ProjectSerializer220403::LoadProjectSettings(QXmlStreamReader *reader, } if (id == QStringLiteral("cache_setting")) { - project->SetCacheLocationSetting( + project->set_cache_location_setting( static_cast(value.toInt())); } else { - project->SetCustomCachePath(value); + project->set_custom_cache_path(value); } } else { reader->skipCurrentElement(); @@ -671,7 +671,7 @@ void ProjectSerializer220403::LoadProjectSettings(QXmlStreamReader *reader, } } -void ProjectSerializer220403::LoadInput(Node *node, QXmlStreamReader *reader, +void ProjectSerializer220403::load_input(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const { if (dynamic_cast(node)) { @@ -697,34 +697,34 @@ void ProjectSerializer220403::LoadInput(Node *node, QXmlStreamReader *reader, return; } - if (!node->HasInputWithID(param_id)) { + if (!node->has_input_with_id(param_id)) { qWarning() << "Failed to load parameter that didn't exist:" << param_id; reader->skipCurrentElement(); return; } - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("primary")) { // Load primary immediate - LoadImmediate(reader, node, param_id, -1, xml_node_data); + load_immediate(reader, node, param_id, -1, xml_node_data); } else if (reader->name() == QStringLiteral("subelements")) { // Load subelements XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("count")) { - node->InputArrayResize(param_id, attr.value().toInt()); + node->input_array_resize(param_id, attr.value().toInt()); } } int element_counter = 0; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("element")) { - LoadImmediate(reader, node, param_id, element_counter, + load_immediate(reader, node, param_id, element_counter, xml_node_data); element_counter++; @@ -738,54 +738,54 @@ void ProjectSerializer220403::LoadInput(Node *node, QXmlStreamReader *reader, } } -void ProjectSerializer220403::LoadImmediate(QXmlStreamReader *reader, +void ProjectSerializer220403::load_immediate(QXmlStreamReader *reader, Node *node, const QString &input, int element, XMLNodeData &xml_node_data) const { Q_UNUSED(xml_node_data) - NodeValue::Type data_type = node->GetInputDataType(input); + NodeValue::Type data_type = node->get_input_data_type(input); // HACK: SubtitleParams contain the actual subtitle data, so loading/replacing it will overwrite // the valid subtitles. We hack around it by simply skipping loading subtitles, we'll see // if this ends up being an issue in the future. - if (data_type == NodeValue::kSubtitleParams) { + if (data_type == NodeValue::k_subtitle_params) { reader->skipCurrentElement(); return; } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("standard")) { // Load standard value int val_index = 0; - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("track")) { QVariant value_on_track; - if (data_type == NodeValue::kVideoParams) { + if (data_type == NodeValue::k_video_params) { VideoParams vp; - vp.Load(reader); + vp.load(reader); value_on_track = QVariant::fromValue(vp); - } else if (data_type == NodeValue::kAudioParams) { + } else if (data_type == NodeValue::k_audio_params) { AudioParams ap = - TypeSerializer::LoadAudioParams(reader); + TypeSerializer::load_audio_params(reader); value_on_track = QVariant::fromValue(ap); } else { QString value_text = reader->readElementText(); if (!value_text.isEmpty()) { - value_on_track = NodeValue::StringToValue( + value_on_track = NodeValue::string_to_value( data_type, value_text, true); } } - node->SetSplitStandardValueOnTrack(input, val_index, + node->set_split_standard_value_on_track(input, val_index, value_on_track, element); val_index++; @@ -794,20 +794,20 @@ void ProjectSerializer220403::LoadImmediate(QXmlStreamReader *reader, } } } else if (reader->name() == QStringLiteral("keyframing") && - node->IsInputKeyframable(input)) { - node->SetInputIsKeyframing(input, reader->readElementText().toInt(), + node->is_input_keyframable(input)) { + node->set_input_is_keyframing(input, reader->readElementText().toInt(), element); } else if (reader->name() == QStringLiteral("keyframes")) { int track = 0; - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } if (reader->name() == QStringLiteral("track")) { - while (XMLReadNextStartElement(reader)) { - if (IsCancelled()) { + while (xml_read_next_start_element(reader)) { + if (is_cancelled()) { return; } @@ -817,7 +817,7 @@ void ProjectSerializer220403::LoadImmediate(QXmlStreamReader *reader, key->set_element(element); key->set_track(track); - LoadKeyframe(reader, key, data_type); + load_keyframe(reader, key, data_type); key->setParent(node); } else { reader->skipCurrentElement(); @@ -830,16 +830,16 @@ void ProjectSerializer220403::LoadImmediate(QXmlStreamReader *reader, } } } else if (reader->name() == QStringLiteral("csinput")) { - node->SetInputProperty(input, QStringLiteral("col_input"), + node->set_input_property(input, QStringLiteral("col_input"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csdisplay")) { - node->SetInputProperty(input, QStringLiteral("col_display"), + node->set_input_property(input, QStringLiteral("col_display"), reader->readElementText()); } else if (reader->name() == QStringLiteral("csview")) { - node->SetInputProperty(input, QStringLiteral("col_view"), + node->set_input_property(input, QStringLiteral("col_view"), reader->readElementText()); } else if (reader->name() == QStringLiteral("cslook")) { - node->SetInputProperty(input, QStringLiteral("col_look"), + node->set_input_property(input, QStringLiteral("col_look"), reader->readElementText()); } else { reader->skipCurrentElement(); @@ -847,7 +847,7 @@ void ProjectSerializer220403::LoadImmediate(QXmlStreamReader *reader, } } -void ProjectSerializer220403::LoadKeyframe(QXmlStreamReader *reader, +void ProjectSerializer220403::load_keyframe(QXmlStreamReader *reader, NodeKeyframe *key, NodeValue::Type data_type) const { @@ -857,7 +857,7 @@ void ProjectSerializer220403::LoadKeyframe(QXmlStreamReader *reader, XMLAttributeLoop(reader, attr) { - if (IsCancelled()) { + if (is_cancelled()) { return; } @@ -865,7 +865,7 @@ void ProjectSerializer220403::LoadKeyframe(QXmlStreamReader *reader, key_input = attr.value().toString(); } else if (attr.name() == QStringLiteral("time")) { key->set_time( - rational::fromString(attr.value().toString().toStdString())); + Rational::from_string(attr.value().toString().toStdString())); } else if (attr.name() == QStringLiteral("type")) { key->set_type_no_bezier_adj( static_cast(attr.value().toInt())); @@ -881,13 +881,13 @@ void ProjectSerializer220403::LoadKeyframe(QXmlStreamReader *reader, } key->set_value( - NodeValue::StringToValue(data_type, reader->readElementText(), true)); + NodeValue::string_to_value(data_type, reader->readElementText(), true)); key->set_bezier_control_in(key_in_handle); key->set_bezier_control_out(key_out_handle); } -bool ProjectSerializer220403::LoadPosition(QXmlStreamReader *reader, +bool ProjectSerializer220403::load_position(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const { @@ -904,7 +904,7 @@ bool ProjectSerializer220403::LoadPosition(QXmlStreamReader *reader, } } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("x")) { pos->position.setX(reader->readElementText().toDouble()); got_pos_x = true; @@ -921,12 +921,12 @@ bool ProjectSerializer220403::LoadPosition(QXmlStreamReader *reader, return got_node_ptr && got_pos_x && got_pos_y; } -void ProjectSerializer220403::PostConnect(const XMLNodeData &xml_node_data) const +void ProjectSerializer220403::post_connect(const XMLNodeData &xml_node_data) const { foreach (const XMLNodeData::SerializedConnection &con, xml_node_data.desired_connections) { if (Node *out = xml_node_data.node_ptrs.value(con.output_node)) { - Node::ConnectEdge(out, con.input); + Node::connect_edge(out, con.input); } } @@ -934,29 +934,29 @@ void ProjectSerializer220403::PostConnect(const XMLNodeData &xml_node_data) cons Node *a = l.block; Node *b = xml_node_data.node_ptrs.value(l.link); - Node::Link(a, b); + Node::link(a, b); } foreach (const XMLNodeData::GroupLink &l, xml_node_data.group_input_links) { if (Node *input_node = xml_node_data.node_ptrs.value(l.input_node)) { NodeInput resolved(input_node, l.input_id, l.input_element); - l.group->AddInputPassthrough(resolved, l.passthrough_id); + l.group->add_input_passthrough(resolved, l.passthrough_id); - l.group->SetInputFlag(l.passthrough_id, + l.group->set_input_flag(l.passthrough_id, InputFlag(l.custom_flags.value())); if (!l.custom_name.isEmpty()) { - l.group->SetInputName(l.passthrough_id, l.custom_name); + l.group->set_input_name(l.passthrough_id, l.custom_name); } - l.group->SetInputDataType(l.passthrough_id, l.data_type); + l.group->set_input_data_type(l.passthrough_id, l.data_type); - l.group->SetDefaultValue(l.passthrough_id, l.default_val); + l.group->set_default_value(l.passthrough_id, l.default_val); for (auto it = l.custom_properties.cbegin(); it != l.custom_properties.cend(); it++) { - l.group->SetInputProperty(l.passthrough_id, it.key(), + l.group->set_input_property(l.passthrough_id, it.key(), it.value()); } } @@ -965,12 +965,12 @@ void ProjectSerializer220403::PostConnect(const XMLNodeData &xml_node_data) cons for (auto it = xml_node_data.group_output_links.cbegin(); it != xml_node_data.group_output_links.cend(); it++) { if (Node *output_node = xml_node_data.node_ptrs.value(it.value())) { - it.key()->SetOutputPassthrough(output_node); + it.key()->set_output_passthrough(output_node); } } } -void ProjectSerializer220403::LoadNodeCustom(QXmlStreamReader *reader, +void ProjectSerializer220403::load_node_custom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const { @@ -978,9 +978,9 @@ void ProjectSerializer220403::LoadNodeCustom(QXmlStreamReader *reader, if (ViewerOutput *viewer = dynamic_cast(node)) { Footage *footage = dynamic_cast(node); - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("points")) { - LoadTimelinePoints(reader, viewer); + load_timeline_points(reader, viewer); } else if (reader->name() == QStringLiteral("timestamp") && footage) { footage->set_timestamp(reader->readElementText().toLongLong()); @@ -990,24 +990,24 @@ void ProjectSerializer220403::LoadNodeCustom(QXmlStreamReader *reader, } } else if (Track *track = dynamic_cast(node)) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("height")) { - track->SetTrackHeight(reader->readElementText().toDouble()); + track->set_track_height(reader->readElementText().toDouble()); } else { reader->skipCurrentElement(); } } } else if (NodeGroup *group = dynamic_cast(node)) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthroughs")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("inputpassthrough")) { XMLNodeData::GroupLink link; link.group = group; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { link.input_node = reader->readElementText().toULongLong(); @@ -1029,23 +1029,23 @@ void ProjectSerializer220403::LoadNodeCustom(QXmlStreamReader *reader, reader->readElementText().toULongLong()); } else if (reader->name() == QStringLiteral("type")) { - link.data_type = NodeValue::GetDataTypeFromName( + link.data_type = NodeValue::get_data_type_from_name( reader->readElementText()); } else if (reader->name() == QStringLiteral("default")) { - link.default_val = NodeValue::StringToValue( + link.default_val = NodeValue::string_to_value( link.data_type, reader->readElementText(), false); } else if (reader->name() == QStringLiteral("properties")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("property")) { QString key; QString value; while ( - XMLReadNextStartElement(reader)) { + xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("key")) { key = reader->readElementText(); @@ -1090,33 +1090,33 @@ void ProjectSerializer220403::LoadNodeCustom(QXmlStreamReader *reader, } } -void ProjectSerializer220403::LoadTimelinePoints(QXmlStreamReader *reader, +void ProjectSerializer220403::load_timeline_points(QXmlStreamReader *reader, ViewerOutput *viewer) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("markers")) { - LoadMarkerList(reader, viewer->GetMarkers()); + load_marker_list(reader, viewer->get_markers()); } else if (reader->name() == QStringLiteral("workarea")) { - LoadWorkArea(reader, viewer->GetWorkArea()); + load_work_area(reader, viewer->get_work_area()); } else { reader->skipCurrentElement(); } } } -void ProjectSerializer220403::LoadMarker(QXmlStreamReader *reader, +void ProjectSerializer220403::load_marker(QXmlStreamReader *reader, TimelineMarker *marker) const { - rational in, out; + Rational in, out; XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("name")) { marker->set_name(attr.value().toString()); } else if (attr.name() == QStringLiteral("in")) { - in = rational::fromString(attr.value().toString().toStdString()); + in = Rational::from_string(attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { - out = rational::fromString(attr.value().toString().toStdString()); + out = Rational::from_string(attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("color")) { marker->set_color(attr.value().toInt()); } @@ -1128,11 +1128,11 @@ void ProjectSerializer220403::LoadMarker(QXmlStreamReader *reader, reader->skipCurrentElement(); } -void ProjectSerializer220403::LoadWorkArea(QXmlStreamReader *reader, +void ProjectSerializer220403::load_work_area(QXmlStreamReader *reader, TimelineWorkArea *workarea) const { - rational range_in = workarea->in(); - rational range_out = workarea->out(); + Rational range_in = workarea->in(); + Rational range_out = workarea->out(); XMLAttributeLoop(reader, attr) { @@ -1140,10 +1140,10 @@ void ProjectSerializer220403::LoadWorkArea(QXmlStreamReader *reader, workarea->set_enabled(attr.value() != QStringLiteral("0")); } else if (attr.name() == QStringLiteral("in")) { range_in = - rational::fromString(attr.value().toString().toStdString()); + Rational::from_string(attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { range_out = - rational::fromString(attr.value().toString().toStdString()); + Rational::from_string(attr.value().toString().toStdString()); } } @@ -1156,27 +1156,27 @@ void ProjectSerializer220403::LoadWorkArea(QXmlStreamReader *reader, reader->skipCurrentElement(); } -void ProjectSerializer220403::LoadMarkerList(QXmlStreamReader *reader, +void ProjectSerializer220403::load_marker_list(QXmlStreamReader *reader, TimelineMarkerList *markers) const { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("marker")) { TimelineMarker *marker = new TimelineMarker(markers); - LoadMarker(reader, marker); + load_marker(reader, marker); } else { reader->skipCurrentElement(); } } } -void ProjectSerializer220403::LoadValueHint(Node::ValueHint *hint, +void ProjectSerializer220403::load_value_hint(Node::ValueHint *hint, QXmlStreamReader *reader) const { QVector types; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("types")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("type")) { types.append(static_cast( reader->readElementText().toInt())); diff --git a/app/node/project/serializer/serializer220403.h b/app/node/project/serializer/serializer220403.h index 813620692..0a5929293 100644 --- a/app/node/project/serializer/serializer220403.h +++ b/app/node/project/serializer/serializer220403.h @@ -19,8 +19,8 @@ ***/ -#ifndef SERIALIZER220403_H -#define SERIALIZER220403_H +#ifndef OAK_SERIALIZER220403_H +#define OAK_SERIALIZER220403_H #include "serializer.h" @@ -32,10 +32,10 @@ public: ProjectSerializer220403() = default; protected: - virtual LoadData Load(Project *project, QXmlStreamReader *reader, + virtual LoadData load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const override; - virtual uint Version() const override + virtual uint version() const override { return 220403; } @@ -73,45 +73,45 @@ private: QHash node_uuids; }; - void LoadNode(Node *node, XMLNodeData &xml_node_data, + void load_node(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const; - void LoadColorManager(QXmlStreamReader *reader, Project *project) const; + void load_color_manager(QXmlStreamReader *reader, Project *project) const; - void LoadProjectSettings(QXmlStreamReader *reader, Project *project) const; + void load_project_settings(QXmlStreamReader *reader, Project *project) const; - void LoadInput(Node *node, QXmlStreamReader *reader, + void load_input(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const; - void LoadImmediate(QXmlStreamReader *reader, Node *node, + void load_immediate(QXmlStreamReader *reader, Node *node, const QString &input, int element, XMLNodeData &xml_node_data) const; - void LoadKeyframe(QXmlStreamReader *reader, NodeKeyframe *key, + void load_keyframe(QXmlStreamReader *reader, NodeKeyframe *key, NodeValue::Type data_type) const; - bool LoadPosition(QXmlStreamReader *reader, quintptr *node_ptr, + bool load_position(QXmlStreamReader *reader, quintptr *node_ptr, Node::Position *pos) const; - void PostConnect(const XMLNodeData &xml_node_data) const; + void post_connect(const XMLNodeData &xml_node_data) const; - void LoadNodeCustom(QXmlStreamReader *reader, Node *node, + void load_node_custom(QXmlStreamReader *reader, Node *node, XMLNodeData &xml_node_data) const; - void LoadTimelinePoints(QXmlStreamReader *reader, + void load_timeline_points(QXmlStreamReader *reader, ViewerOutput *viewer) const; - void LoadMarker(QXmlStreamReader *reader, TimelineMarker *marker) const; + void load_marker(QXmlStreamReader *reader, TimelineMarker *marker) const; - void LoadWorkArea(QXmlStreamReader *reader, + void load_work_area(QXmlStreamReader *reader, TimelineWorkArea *workarea) const; - void LoadMarkerList(QXmlStreamReader *reader, + void load_marker_list(QXmlStreamReader *reader, TimelineMarkerList *markers) const; - void LoadValueHint(Node::ValueHint *hint, QXmlStreamReader *reader) const; + void load_value_hint(Node::ValueHint *hint, QXmlStreamReader *reader) const; }; } -#endif // SERIALIZER220403_H +#endif // OAK_SERIALIZER220403_H diff --git a/app/node/project/serializer/serializer230220.cpp b/app/node/project/serializer/serializer230220.cpp index dda191cd3..2037d87ff 100644 --- a/app/node/project/serializer/serializer230220.cpp +++ b/app/node/project/serializer/serializer230220.cpp @@ -33,7 +33,7 @@ namespace olive { ProjectSerializer230220::LoadData -ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, +ProjectSerializer230220::load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const { QMap> properties; @@ -42,29 +42,29 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, SerializedData project_data; switch (load_type) { - case kProject: { + case k_project: { if (reader->name() == QStringLiteral("project")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("project")) { - project_data = project->Load(reader); + project_data = project->load(reader); load_data.node_ptrs = project_data.node_ptrs; } else if (reader->name() == QStringLiteral("layout")) { - load_data.layout = MainWindowLayoutInfo::fromXml( + load_data.layout = MainWindowLayoutInfo::from_xml( reader, project_data.node_ptrs); } else { reader->skipCurrentElement(); } } - PostConnect(project->nodes(), &project_data); + post_connect(project->nodes(), &project_data); } else { reader->skipCurrentElement(); } break; } - case kOnlyMarkers: { + case k_only_markers: { if (reader->name() == QStringLiteral("markers")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("marker")) { TimelineMarker *marker = new TimelineMarker(); marker->load(reader); @@ -78,9 +78,9 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, } break; } - case kOnlyKeyframes: { + case k_only_keyframes: { if (reader->name() == QStringLiteral("keyframes")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { QString node_id; XMLAttributeLoop(reader, attr) @@ -93,13 +93,13 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, Node *n = nullptr; if (!node_id.isEmpty()) { - n = NodeFactory::CreateFromID(node_id); + n = NodeFactory::create_from_id(node_id); } if (!n) { reader->skipCurrentElement(); } else { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("input")) { QString input_id; XMLAttributeLoop(reader, attr) @@ -113,7 +113,7 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, if (input_id.isEmpty()) { reader->skipCurrentElement(); } else { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("element")) { QString element_id; @@ -130,7 +130,7 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, if (element_id.isEmpty()) { reader->skipCurrentElement(); } else { - while (XMLReadNextStartElement( + while (xml_read_next_start_element( reader)) { if (reader->name() == QStringLiteral( @@ -154,7 +154,7 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, ->skipCurrentElement(); } else { while ( - XMLReadNextStartElement( + xml_read_next_start_element( reader)) { if (reader ->name() == @@ -173,7 +173,7 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, key->load( reader, - n->GetInputDataType( + n->get_input_data_type( input_id)); load_data @@ -214,15 +214,15 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, } break; } - case kOnlyClips: - case kOnlyNodes: { - if ((load_type == kOnlyNodes && + case k_only_clips: + case k_only_nodes: { + if ((load_type == k_only_nodes && reader->name() == QStringLiteral("nodes")) || - (load_type == kOnlyClips && + (load_type == k_only_clips && reader->name() == QStringLiteral("timeline"))) { QMap skipped_items; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { QString id; quintptr ptr = 0; @@ -262,13 +262,13 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, if (dependency_of_item) { reader->skipCurrentElement(); } else { - Node *node = NodeFactory::CreateFromID(id); + Node *node = NodeFactory::create_from_id(id); if (!node) { qWarning() << "Failed to find node with ID" << id; reader->skipCurrentElement(); } else { - if (project && node->IsItem() && ptr) { + if (project && node->is_item() && ptr) { // If we're pasting an object into the same project, we should re-use the item // rather than duplicate. Node *existing = @@ -288,8 +288,8 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, if (node) { // Disable cache while node is being loaded (we'll re-enable it later) - node->SetCachesEnabled(false); - node->Load(reader, &project_data); + node->set_caches_enabled(false); + node->load(reader, &project_data); load_data.nodes.append(node); } } @@ -298,7 +298,7 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, load_data.node_ptrs = project_data.node_ptrs; } else if (reader->name() == QStringLiteral("properties")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("node")) { quintptr ptr = 0; @@ -314,7 +314,7 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, if (ptr) { QMap properties_for_node; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { properties_for_node.insert( reader->name().toString(), reader->readElementText()); @@ -354,7 +354,7 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, } } - PostConnect(load_data.nodes, &project_data); + post_connect(load_data.nodes, &project_data); } else { reader->skipCurrentElement(); } @@ -365,7 +365,7 @@ ProjectSerializer230220::Load(Project *project, QXmlStreamReader *reader, return load_data; } -void WriteNodeMap(QXmlStreamWriter *writer, Node *node, +void write_node_map(QXmlStreamWriter *writer, Node *node, const QVector &nodes) { writer->writeStartElement(QStringLiteral("node")); @@ -375,23 +375,23 @@ void WriteNodeMap(QXmlStreamWriter *writer, Node *node, for (auto oc : node->output_connections()) { if (nodes.contains(oc.second.node())) { - WriteNodeMap(writer, oc.second.node(), nodes); + write_node_map(writer, oc.second.node(), nodes); } } writer->writeEndElement(); } -void ProjectSerializer230220::Save(QXmlStreamWriter *writer, +void ProjectSerializer230220::save(QXmlStreamWriter *writer, const SaveData &data, void *reserved) const { - if (!data.GetOnlySerializeMarkers().empty()) { + if (!data.get_only_serialize_markers().empty()) { writer->writeStartElement(QStringLiteral("markers")); writer->writeAttribute(QStringLiteral("version"), QString::number(1)); - for (auto it = data.GetOnlySerializeMarkers().cbegin(); - it != data.GetOnlySerializeMarkers().cend(); it++) { + for (auto it = data.get_only_serialize_markers().cbegin(); + it != data.get_only_serialize_markers().cend(); it++) { TimelineMarker *marker = *it; writer->writeStartElement(QStringLiteral("marker")); marker->save(writer); @@ -399,7 +399,7 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, } writer->writeEndElement(); // markers - } else if (!data.GetOnlySerializeKeyframes().empty()) { + } else if (!data.get_only_serialize_keyframes().empty()) { writer->writeStartElement(QStringLiteral("keyframes")); writer->writeAttribute(QStringLiteral("version"), QString::number(1)); @@ -409,8 +409,8 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, QHash>>>> organized; - for (auto it = data.GetOnlySerializeKeyframes().cbegin(); - it != data.GetOnlySerializeKeyframes().cend(); it++) { + for (auto it = data.get_only_serialize_keyframes().cbegin(); + it != data.get_only_serialize_keyframes().cend(); it++) { NodeKeyframe *key = *it; organized[key->parent()->id()][key->input()][key->element()] [key->track()] @@ -445,7 +445,7 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, for (NodeKeyframe *key : keys) { writer->writeStartElement(QStringLiteral("key")); - key->save(writer, key->parent()->GetInputDataType( + key->save(writer, key->parent()->get_input_data_type( key->input())); writer->writeEndElement(); // key } @@ -463,8 +463,8 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, } writer->writeEndElement(); // keyframes - } else if (!data.GetOnlySerializeNodes().empty()) { - if (data.type() == kOnlyClips) { + } else if (!data.get_only_serialize_nodes().empty()) { + if (data.type() == k_only_clips) { writer->writeStartElement(QStringLiteral("timeline")); } else { writer->writeStartElement(QStringLiteral("nodes")); @@ -472,12 +472,12 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, writer->writeAttribute(QStringLiteral("version"), QString::number(1)); - for (Node *n : data.GetOnlySerializeNodes()) { + for (Node *n : data.get_only_serialize_nodes()) { writer->writeStartElement(QStringLiteral("node")); QStringList item_list; - for (Node *i : data.GetOnlySerializeNodes()) { - if (i->IsItem() && i->InputsFrom(n, true)) { + for (Node *i : data.get_only_serialize_nodes()) { + if (i->is_item() && i->inputs_from(n, true)) { item_list.append( QString::number(reinterpret_cast(i))); } @@ -487,14 +487,14 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, item_list.join(',')); } - n->Save(writer); + n->save(writer); writer->writeEndElement(); // node } - if (!data.GetProperties().empty()) { + if (!data.get_properties().empty()) { writer->writeStartElement(QStringLiteral("properties")); - for (auto it = data.GetProperties().cbegin(); - it != data.GetProperties().cend(); it++) { + for (auto it = data.get_properties().cbegin(); + it != data.get_properties().cend(); it++) { writer->writeStartElement(QStringLiteral("node")); writer->writeAttribute( @@ -512,15 +512,15 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, } writer->writeEndElement(); // nodes - } else if (Project *project = data.GetProject()) { + } else if (Project *project = data.get_project()) { writer->writeStartElement(QStringLiteral("project")); writer->writeStartElement(QStringLiteral("project")); - project->Save(writer); + project->save(writer); writer->writeEndElement(); // project writer->writeStartElement(QStringLiteral("layout")); - data.GetLayout().toXml(writer); + data.get_layout().to_xml(writer); writer->writeEndElement(); // layout writer->writeEndElement(); // project @@ -529,13 +529,13 @@ void ProjectSerializer230220::Save(QXmlStreamWriter *writer, } } -void ProjectSerializer230220::PostConnect(const QVector &nodes, +void ProjectSerializer230220::post_connect(const QVector &nodes, SerializedData *project_data) const { foreach (const SerializedData::SerializedConnection &con, project_data->desired_connections) { if (Node *out = project_data->node_ptrs.value(con.output_node)) { - Node::ConnectEdge(out, con.input); + Node::connect_edge(out, con.input); } } @@ -543,7 +543,7 @@ void ProjectSerializer230220::PostConnect(const QVector &nodes, Node *a = l.block; Node *b = project_data->node_ptrs.value(l.link); - Node::Link(a, b); + Node::link(a, b); } for (auto it = nodes.cbegin(); it != nodes.cend(); it++) { @@ -551,7 +551,7 @@ void ProjectSerializer230220::PostConnect(const QVector &nodes, n->PostLoadEvent(project_data); - n->SetCachesEnabled(true); + n->set_caches_enabled(true); } } diff --git a/app/node/project/serializer/serializer230220.h b/app/node/project/serializer/serializer230220.h index cb0923417..b1190b042 100644 --- a/app/node/project/serializer/serializer230220.h +++ b/app/node/project/serializer/serializer230220.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTSERIALIZER230220_H -#define PROJECTSERIALIZER230220_H +#ifndef OAK_PROJECTSERIALIZER230220_H +#define OAK_PROJECTSERIALIZER230220_H #include "serializer.h" @@ -32,22 +32,22 @@ public: ProjectSerializer230220() = default; protected: - virtual LoadData Load(Project *project, QXmlStreamReader *reader, + virtual LoadData load(Project *project, QXmlStreamReader *reader, LoadType load_type, void *reserved) const override; - virtual void Save(QXmlStreamWriter *writer, const SaveData &data, + virtual void save(QXmlStreamWriter *writer, const SaveData &data, void *reserved) const override; - virtual uint Version() const override + virtual uint version() const override { return 230220; } private: - void PostConnect(const QVector &nodes, + void post_connect(const QVector &nodes, SerializedData *project_data) const; }; } -#endif // PROJECTSERIALIZER230220_H +#endif // OAK_PROJECTSERIALIZER230220_H diff --git a/app/node/project/serializer/typeserializer.cpp b/app/node/project/serializer/typeserializer.cpp index 9d58f0030..a02cd1d9b 100644 --- a/app/node/project/serializer/typeserializer.cpp +++ b/app/node/project/serializer/typeserializer.cpp @@ -24,11 +24,11 @@ namespace olive { -AudioParams TypeSerializer::LoadAudioParams(QXmlStreamReader *reader) +AudioParams TypeSerializer::load_audio_params(QXmlStreamReader *reader) { AudioParams a; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("samplerate")) { a.set_sample_rate(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("channellayout")) { @@ -44,7 +44,7 @@ AudioParams TypeSerializer::LoadAudioParams(QXmlStreamReader *reader) a.set_duration(reader->readElementText().toLongLong()); } else if (reader->name() == QStringLiteral("timebase")) { a.set_time_base( - rational::fromString(reader->readElementText().toStdString())); + Rational::from_string(reader->readElementText().toStdString())); } else { reader->skipCurrentElement(); } @@ -53,7 +53,7 @@ AudioParams TypeSerializer::LoadAudioParams(QXmlStreamReader *reader) return a; } -void TypeSerializer::SaveAudioParams(QXmlStreamWriter *writer, +void TypeSerializer::save_audio_params(QXmlStreamWriter *writer, const AudioParams &a) { writer->writeTextElement(QStringLiteral("samplerate"), @@ -69,7 +69,7 @@ void TypeSerializer::SaveAudioParams(QXmlStreamWriter *writer, writer->writeTextElement(QStringLiteral("duration"), QString::number(a.duration())); writer->writeTextElement(QStringLiteral("timebase"), - QString::fromStdString(a.time_base().toString())); + QString::fromStdString(a.time_base().to_string())); } } diff --git a/app/node/project/serializer/typeserializer.h b/app/node/project/serializer/typeserializer.h index f061eb756..e06efcd7d 100644 --- a/app/node/project/serializer/typeserializer.h +++ b/app/node/project/serializer/typeserializer.h @@ -19,8 +19,8 @@ ***/ -#ifndef TYPESERIALIZER_H -#define TYPESERIALIZER_H +#ifndef OAK_TYPESERIALIZER_H +#define OAK_TYPESERIALIZER_H #include #include @@ -37,10 +37,10 @@ class TypeSerializer { public: TypeSerializer() = default; - static AudioParams LoadAudioParams(QXmlStreamReader *reader); - static void SaveAudioParams(QXmlStreamWriter *writer, const AudioParams &a); + static AudioParams load_audio_params(QXmlStreamReader *reader); + static void save_audio_params(QXmlStreamWriter *writer, const AudioParams &a); }; } -#endif // TYPESERIALIZER_H +#endif // OAK_TYPESERIALIZER_H diff --git a/app/node/serializeddata.h b/app/node/serializeddata.h index 7f97c0ded..4691ecaf1 100644 --- a/app/node/serializeddata.h +++ b/app/node/serializeddata.h @@ -19,8 +19,8 @@ ***/ -#ifndef SERIALIZEDDATA_H -#define SERIALIZEDDATA_H +#ifndef OAK_SERIALIZEDDATA_H +#define OAK_SERIALIZEDDATA_H #include #include @@ -66,4 +66,4 @@ struct SerializedData { } -#endif // SERIALIZEDDATA_H +#endif // OAK_SERIALIZEDDATA_H diff --git a/app/node/splitvalue.h b/app/node/splitvalue.h index 31b837aa3..80fa85b0f 100644 --- a/app/node/splitvalue.h +++ b/app/node/splitvalue.h @@ -19,8 +19,8 @@ ***/ -#ifndef SPLITVALUE_H -#define SPLITVALUE_H +#ifndef OAK_SPLITVALUE_H +#define OAK_SPLITVALUE_H #include #include @@ -32,4 +32,4 @@ using SplitValue = QVector; } -#endif // SPLITVALUE_H +#endif // OAK_SPLITVALUE_H diff --git a/app/node/time/timeformat/timeformat.cpp b/app/node/time/timeformat/timeformat.cpp index f037c3086..170fffb94 100644 --- a/app/node/time/timeformat/timeformat.cpp +++ b/app/node/time/timeformat/timeformat.cpp @@ -28,18 +28,18 @@ namespace olive #define super Node -const QString TimeFormatNode::kTimeInput = QStringLiteral("time_in"); -const QString TimeFormatNode::kFormatInput = QStringLiteral("format_in"); -const QString TimeFormatNode::kLocalTimeInput = QStringLiteral("localtime_in"); +const QString TimeFormatNode::k_time_input = QStringLiteral("time_in"); +const QString TimeFormatNode::k_format_input = QStringLiteral("format_in"); +const QString TimeFormatNode::k_local_time_input = QStringLiteral("localtime_in"); TimeFormatNode::TimeFormatNode() { - AddInput(kTimeInput, NodeValue::kFloat); - AddInput(kFormatInput, NodeValue::kText, QStringLiteral("hh:mm:ss")); - AddInput(kLocalTimeInput, NodeValue::kBoolean); + add_input(k_time_input, NodeValue::k_float); + add_input(k_format_input, NodeValue::k_text, QStringLiteral("hh:mm:ss")); + add_input(k_local_time_input, NodeValue::k_boolean); } -QString TimeFormatNode::Name() const +QString TimeFormatNode::name() const { return tr("Time Format"); } @@ -49,36 +49,36 @@ QString TimeFormatNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.timeformat"); } -QVector TimeFormatNode::Category() const +QVector TimeFormatNode::category() const { - return { kCategoryGenerator }; + return { k_category_generator }; } -QString TimeFormatNode::Description() const +QString TimeFormatNode::description() const { return tr("Format time (in Unix epoch seconds) into a string."); } -void TimeFormatNode::Retranslate() +void TimeFormatNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTimeInput, tr("Time")); - SetInputName(kFormatInput, tr("Format")); - SetInputName(kLocalTimeInput, tr("Interpret time as local time")); + set_input_name(k_time_input, tr("Time")); + set_input_name(k_format_input, tr("Format")); + set_input_name(k_local_time_input, tr("Interpret time as local time")); } -void TimeFormatNode::Value(const NodeValueRow &value, +void TimeFormatNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - qint64 ms_since_epoch = value[kTimeInput].toDouble() * 1000; - bool time_is_local = value[kLocalTimeInput].toBool(); + qint64 ms_since_epoch = value[k_time_input].to_double() * 1000; + bool time_is_local = value[k_local_time_input].to_bool(); QDateTime dt = QDateTime::fromMSecsSinceEpoch( ms_since_epoch, time_is_local ? Qt::LocalTime : Qt::UTC); - QString format = value[kFormatInput].toString(); + QString format = value[k_format_input].to_string(); QString output = dt.toString(format); - table->Push(NodeValue(NodeValue::kText, output, this)); + table->push(NodeValue(NodeValue::k_text, output, this)); } } diff --git a/app/node/time/timeformat/timeformat.h b/app/node/time/timeformat/timeformat.h index bcbdbb2d4..cbdc2d9c4 100644 --- a/app/node/time/timeformat/timeformat.h +++ b/app/node/time/timeformat/timeformat.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMEFORMAT_H -#define TIMEFORMAT_H +#ifndef OAK_TIMEFORMAT_H +#define OAK_TIMEFORMAT_H #include "node/node.h" @@ -34,21 +34,21 @@ public: NODE_DEFAULT_FUNCTIONS(TimeFormatNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTimeInput; - static const QString kFormatInput; - static const QString kLocalTimeInput; + static const QString k_time_input; + static const QString k_format_input; + static const QString k_local_time_input; }; } -#endif // TIMEFORMAT_H +#endif // OAK_TIMEFORMAT_H diff --git a/app/node/time/timeoffset/timeoffsetnode.cpp b/app/node/time/timeoffset/timeoffsetnode.cpp index 6bf3c1eec..8e709b27f 100644 --- a/app/node/time/timeoffset/timeoffsetnode.cpp +++ b/app/node/time/timeoffset/timeoffsetnode.cpp @@ -26,71 +26,71 @@ namespace olive { -const QString TimeOffsetNode::kTimeInput = QStringLiteral("time_in"); -const QString TimeOffsetNode::kInputInput = QStringLiteral("input_in"); +const QString TimeOffsetNode::k_time_input = QStringLiteral("time_in"); +const QString TimeOffsetNode::k_input_input = QStringLiteral("input_in"); #define super Node TimeOffsetNode::TimeOffsetNode() { - AddInput(kTimeInput, NodeValue::kRational, QVariant::fromValue(rational(0)), - InputFlags(kInputFlagNotConnectable)); - SetInputProperty(kTimeInput, QStringLiteral("view"), RationalSlider::kTime); - SetInputProperty(kTimeInput, QStringLiteral("viewlock"), true); + add_input(k_time_input, NodeValue::k_rational, QVariant::fromValue(Rational(0)), + InputFlags(k_input_flag_not_connectable)); + set_input_property(k_time_input, QStringLiteral("view"), RationalSlider::k_time); + set_input_property(k_time_input, QStringLiteral("viewlock"), true); - AddInput(kInputInput, NodeValue::kNone, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_input_input, NodeValue::k_none, + InputFlags(k_input_flag_not_keyframable)); } -void TimeOffsetNode::Retranslate() +void TimeOffsetNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTimeInput, QStringLiteral("Time")); - SetInputName(kInputInput, QStringLiteral("Input")); + set_input_name(k_time_input, QStringLiteral("Time")); + set_input_name(k_input_input, QStringLiteral("Input")); } -TimeRange TimeOffsetNode::InputTimeAdjustment(const QString &input, int element, +TimeRange TimeOffsetNode::input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const { - if (input == kInputInput) { - return TimeRange(GetRemappedTime(input_time.in()), - GetRemappedTime(input_time.out())); + if (input == k_input_input) { + return TimeRange(get_remapped_time(input_time.in()), + get_remapped_time(input_time.out())); } else { - return super::InputTimeAdjustment(input, element, input_time, clamp); + return super::input_time_adjustment(input, element, input_time, clamp); } } TimeRange -TimeOffsetNode::OutputTimeAdjustment(const QString &input, int element, +TimeOffsetNode::output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const { - if (input == kInputInput) { + if (input == k_input_input) { // The inverse of InputTimeAdjustment(): times at the input are mapped // back to the output by subtracting the offset again - return TimeRange(GetRemappedOutputTime(input_time.in()), - GetRemappedOutputTime(input_time.out())); + return TimeRange(get_remapped_output_time(input_time.in()), + get_remapped_output_time(input_time.out())); } else { - return super::OutputTimeAdjustment(input, element, input_time); + return super::output_time_adjustment(input, element, input_time); } } -void TimeOffsetNode::Value(const NodeValueRow &value, +void TimeOffsetNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - table->Push(value[kInputInput]); + table->push(value[k_input_input]); } -rational TimeOffsetNode::GetRemappedTime(const rational &input) const +Rational TimeOffsetNode::get_remapped_time(const Rational &input) const { - return input + GetValueAtTime(kTimeInput, input).value(); + return input + get_value_at_time(k_time_input, input).value(); } -rational TimeOffsetNode::GetRemappedOutputTime(const rational &input) const +Rational TimeOffsetNode::get_remapped_output_time(const Rational &input) const { - return input - GetValueAtTime(kTimeInput, input).value(); + return input - get_value_at_time(k_time_input, input).value(); } } diff --git a/app/node/time/timeoffset/timeoffsetnode.h b/app/node/time/timeoffset/timeoffsetnode.h index 5f89534f3..aa413bdfd 100644 --- a/app/node/time/timeoffset/timeoffsetnode.h +++ b/app/node/time/timeoffset/timeoffsetnode.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMEOFFSETNODE_H -#define TIMEOFFSETNODE_H +#ifndef OAK_TIMEOFFSETNODE_H +#define OAK_TIMEOFFSETNODE_H #include "node/node.h" @@ -33,7 +33,7 @@ public: NODE_DEFAULT_FUNCTIONS(TimeOffsetNode) - virtual QString Name() const override + virtual QString name() const override { return tr("Time Offset"); } @@ -43,36 +43,36 @@ public: return QStringLiteral("org.olivevideoeditor.Olive.timeoffset"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryTime }; + return { k_category_time }; } - virtual QString Description() const override + virtual QString description() const override { return tr("Offset time passing through the graph."); } - virtual TimeRange InputTimeAdjustment(const QString &input, int element, + virtual TimeRange input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const override; virtual TimeRange - OutputTimeAdjustment(const QString &input, int element, + output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTimeInput; - static const QString kInputInput; + static const QString k_time_input; + static const QString k_input_input; private: - rational GetRemappedTime(const rational &input) const; - rational GetRemappedOutputTime(const rational &input) const; + Rational get_remapped_time(const Rational &input) const; + Rational get_remapped_output_time(const Rational &input) const; }; } -#endif // TIMEOFFSETNODE_H +#endif // OAK_TIMEOFFSETNODE_H diff --git a/app/node/time/timeremap/timeremap.cpp b/app/node/time/timeremap/timeremap.cpp index 20f2e026c..0d973df1d 100644 --- a/app/node/time/timeremap/timeremap.cpp +++ b/app/node/time/timeremap/timeremap.cpp @@ -26,23 +26,23 @@ namespace olive { -const QString TimeRemapNode::kTimeInput = QStringLiteral("time_in"); -const QString TimeRemapNode::kInputInput = QStringLiteral("input_in"); +const QString TimeRemapNode::k_time_input = QStringLiteral("time_in"); +const QString TimeRemapNode::k_input_input = QStringLiteral("input_in"); #define super Node TimeRemapNode::TimeRemapNode() { - AddInput(kTimeInput, NodeValue::kRational, QVariant::fromValue(rational(0)), - InputFlags(kInputFlagNotConnectable)); - SetInputProperty(kTimeInput, QStringLiteral("view"), RationalSlider::kTime); - SetInputProperty(kTimeInput, QStringLiteral("viewlock"), true); + add_input(k_time_input, NodeValue::k_rational, QVariant::fromValue(Rational(0)), + InputFlags(k_input_flag_not_connectable)); + set_input_property(k_time_input, QStringLiteral("view"), RationalSlider::k_time); + set_input_property(k_time_input, QStringLiteral("viewlock"), true); - AddInput(kInputInput, NodeValue::kNone, - InputFlags(kInputFlagNotKeyframable)); + add_input(k_input_input, NodeValue::k_none, + InputFlags(k_input_flag_not_keyframable)); } -QString TimeRemapNode::Name() const +QString TimeRemapNode::name() const { return tr("Time Remap"); } @@ -52,58 +52,58 @@ QString TimeRemapNode::id() const return QStringLiteral("org.olivevideoeditor.Olive.timeremap"); } -QVector TimeRemapNode::Category() const +QVector TimeRemapNode::category() const { - return { kCategoryTime }; + return { k_category_time }; } -QString TimeRemapNode::Description() const +QString TimeRemapNode::description() const { return tr("Arbitrarily remap time through the nodes."); } -TimeRange TimeRemapNode::InputTimeAdjustment(const QString &input, int element, +TimeRange TimeRemapNode::input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const { - if (input == kInputInput) { - return TimeRange(GetRemappedTime(input_time.in()), - GetRemappedTime(input_time.out())); + if (input == k_input_input) { + return TimeRange(get_remapped_time(input_time.in()), + get_remapped_time(input_time.out())); } else { - return super::InputTimeAdjustment(input, element, input_time, clamp); + return super::input_time_adjustment(input, element, input_time, clamp); } } -TimeRange TimeRemapNode::OutputTimeAdjustment(const QString &input, int element, +TimeRange TimeRemapNode::output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const { /*if (input == kInputInput) { - rational target_time = GetValueAtTime(kTimeInput, input_time.in()).value(); + Rational target_time = GetValueAtTime(kTimeInput, input_time.in()).value(); return TimeRange(target_time, target_time + input_time.length()); } else { - return super::OutputTimeAdjustment(input, element, input_time); + return super::output_time_adjustment(input, element, input_time); }*/ - return super::OutputTimeAdjustment(input, element, input_time); + return super::output_time_adjustment(input, element, input_time); } -void TimeRemapNode::Retranslate() +void TimeRemapNode::retranslate() { - super::Retranslate(); + super::retranslate(); - SetInputName(kTimeInput, QStringLiteral("Time")); - SetInputName(kInputInput, QStringLiteral("Input")); + set_input_name(k_time_input, QStringLiteral("Time")); + set_input_name(k_input_input, QStringLiteral("Input")); } -void TimeRemapNode::Value(const NodeValueRow &value, const NodeGlobals &globals, +void TimeRemapNode::value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const { - table->Push(value[kInputInput]); + table->push(value[k_input_input]); } -rational TimeRemapNode::GetRemappedTime(const rational &input) const +Rational TimeRemapNode::get_remapped_time(const Rational &input) const { - return GetValueAtTime(kTimeInput, input).value(); + return get_value_at_time(k_time_input, input).value(); } } diff --git a/app/node/time/timeremap/timeremap.h b/app/node/time/timeremap/timeremap.h index 1035847cd..64dc47fa8 100644 --- a/app/node/time/timeremap/timeremap.h +++ b/app/node/time/timeremap/timeremap.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMEREMAPNODE_H -#define TIMEREMAPNODE_H +#ifndef OAK_TIMEREMAPNODE_H +#define OAK_TIMEREMAPNODE_H #include "node/node.h" @@ -34,30 +34,30 @@ public: NODE_DEFAULT_FUNCTIONS(TimeRemapNode) - virtual QString Name() const override; + virtual QString name() const override; virtual QString id() const override; - virtual QVector Category() const override; - virtual QString Description() const override; + virtual QVector category() const override; + virtual QString description() const override; - virtual TimeRange InputTimeAdjustment(const QString &input, int element, + virtual TimeRange input_time_adjustment(const QString &input, int element, const TimeRange &input_time, bool clamp) const override; virtual TimeRange - OutputTimeAdjustment(const QString &input, int element, + output_time_adjustment(const QString &input, int element, const TimeRange &input_time) const override; - virtual void Retranslate() override; + virtual void retranslate() override; - virtual void Value(const NodeValueRow &value, const NodeGlobals &globals, + virtual void value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const override; - static const QString kTimeInput; - static const QString kInputInput; + static const QString k_time_input; + static const QString k_input_input; private: - rational GetRemappedTime(const rational &input) const; + Rational get_remapped_time(const Rational &input) const; }; } -#endif // TIMEREMAPNODE_H +#endif // OAK_TIMEREMAPNODE_H diff --git a/app/node/traverser.cpp b/app/node/traverser.cpp index 7d3c8bbea..c1b1b0692 100644 --- a/app/node/traverser.cpp +++ b/app/node/traverser.cpp @@ -30,7 +30,7 @@ namespace olive { -NodeValueDatabase NodeTraverser::GenerateDatabase(const Node *node, +NodeValueDatabase NodeTraverser::generate_database(const Node *node, const TimeRange &range) { NodeValueDatabase database; @@ -42,9 +42,9 @@ NodeValueDatabase NodeTraverser::GenerateDatabase(const Node *node, } // We need to insert tables into the database for each input - auto ignore = node->IgnoreInputsForRendering(); + auto ignore = node->ignore_inputs_for_rendering(); foreach (const QString &input, node->inputs()) { - if (IsCancelled()) { + if (is_cancelled()) { return NodeValueDatabase(); } @@ -52,7 +52,7 @@ NodeValueDatabase NodeTraverser::GenerateDatabase(const Node *node, continue; } - database.Insert(input, ProcessInput(node, input, range)); + database.insert(input, process_input(node, input, range)); } loop_mode_ = old_loop_mode; @@ -60,7 +60,7 @@ NodeValueDatabase NodeTraverser::GenerateDatabase(const Node *node, return database; } -NodeValueRow NodeTraverser::GenerateRow(NodeValueDatabase *database, +NodeValueRow NodeTraverser::generate_row(NodeValueDatabase *database, const Node *node, const TimeRange &range) { @@ -68,7 +68,7 @@ NodeValueRow NodeTraverser::GenerateRow(NodeValueDatabase *database, NodeValueRow row; for (auto it = database->begin(); it != database->end(); it++) { // Get hint for which value should be pulled - NodeValue value = GenerateRowValue(node, it.key(), &it.value(), range); + NodeValue value = generate_row_value(node, it.key(), &it.value(), range); row.insert(it.key(), value); } @@ -76,8 +76,8 @@ NodeValueRow NodeTraverser::GenerateRow(NodeValueDatabase *database, // done yet, so we emulate old behavior here JUST FOR AUDIO. for (auto it = row.begin(); it != row.end(); it++) { NodeValue &val = it.value(); - if (val.type() == NodeValue::kSamples) { - ResolveJobs(val); + if (val.type() == NodeValue::k_samples) { + resolve_jobs(val); } } // END TEMP @@ -85,21 +85,21 @@ NodeValueRow NodeTraverser::GenerateRow(NodeValueDatabase *database, return row; } -NodeValueRow NodeTraverser::GenerateRow(const Node *node, +NodeValueRow NodeTraverser::generate_row(const Node *node, const TimeRange &range) { // Generate database of input values of node - NodeValueDatabase database = GenerateDatabase(node, range); + NodeValueDatabase database = generate_database(node, range); - return GenerateRow(&database, node, range); + return generate_row(&database, node, range); } -NodeValue NodeTraverser::GenerateRowValue(const Node *node, +NodeValue NodeTraverser::generate_row_value(const Node *node, const QString &input, NodeValueTable *table, const TimeRange &time) { - NodeValue value = GenerateRowValueElement(node, input, -1, table, time); + NodeValue value = generate_row_value_element(node, input, -1, table, time); if (value.array()) { // Resolve each element of array @@ -107,7 +107,7 @@ NodeValue NodeTraverser::GenerateRowValue(const Node *node, NodeValueArray output; for (auto it = tables.begin(); it != tables.end(); it++) { - output[it->first] = GenerateRowValueElement(node, input, it->first, + output[it->first] = generate_row_value_element(node, input, it->first, &it->second, time); } @@ -118,19 +118,19 @@ NodeValue NodeTraverser::GenerateRowValue(const Node *node, return value; } -NodeValue NodeTraverser::GenerateRowValueElement(const Node *node, +NodeValue NodeTraverser::generate_row_value_element(const Node *node, const QString &input, int element, NodeValueTable *table, const TimeRange &time) { int value_index = - GenerateRowValueElementIndex(node->GetValueHintForInput(input, element), - node->GetInputDataType(input), table); + generate_row_value_element_index(node->get_value_hint_for_input(input, element), + node->get_input_data_type(input), table); if (value_index == -1) { // If value was -1, try getting the last value - value_index = table->Count() - 1; + value_index = table->count() - 1; } if (value_index == -1) { @@ -138,18 +138,18 @@ NodeValue NodeTraverser::GenerateRowValueElement(const Node *node, return NodeValue(); } - NodeValue value = table->TakeAt(value_index); + NodeValue value = table->take_at(value_index); - if (value.type() == NodeValue::kTexture && UseCache()) { - if (TexturePtr tex = value.toTexture()) { + if (value.type() == NodeValue::k_texture && use_cache()) { + if (TexturePtr tex = value.to_texture()) { QMutexLocker locker(node->video_frame_cache()->mutex()); - node->video_frame_cache()->LoadState(); + node->video_frame_cache()->load_state(); QString cache = - node->video_frame_cache()->GetValidCacheFilename(time.in()); + node->video_frame_cache()->get_valid_cache_filename(time.in()); if (!cache.isEmpty()) { - value.set_value(tex->toJob(CacheJob(cache, value))); + value.set_value(tex->to_job(CacheJob(cache, value))); } } } @@ -157,7 +157,7 @@ NodeValue NodeTraverser::GenerateRowValueElement(const Node *node, return value; } -int NodeTraverser::GenerateRowValueElementIndex(const Node::ValueHint &hint, +int NodeTraverser::generate_row_value_element_index(const Node::ValueHint &hint, NodeValue::Type preferred_type, const NodeValueTable *table) { @@ -169,14 +169,14 @@ int NodeTraverser::GenerateRowValueElementIndex(const Node::ValueHint &hint, if (hint.index() == -1) { // Get most recent value with this type and tag - return table->GetValueIndex(types, hint.tag()); + return table->get_value_index(types, hint.tag()); } else { // Try to find value at this index - int index = table->Count() - 1 - hint.index(); + int index = table->count() - 1 - hint.index(); int diff = 0; - while (index + diff < table->Count() && index - diff >= 0) { - if (index + diff < table->Count() && + while (index + diff < table->count() && index - diff >= 0) { + if (index + diff < table->count() && types.contains(table->at(index + diff).type())) { return index + diff; } @@ -191,61 +191,61 @@ int NodeTraverser::GenerateRowValueElementIndex(const Node::ValueHint &hint, } } -int NodeTraverser::GenerateRowValueElementIndex(const Node *node, +int NodeTraverser::generate_row_value_element_index(const Node *node, const QString &input, int element, const NodeValueTable *table) { - return GenerateRowValueElementIndex(node->GetValueHintForInput(input, + return generate_row_value_element_index(node->get_value_hint_for_input(input, element), - node->GetInputDataType(input), table); + node->get_input_data_type(input), table); } -void NodeTraverser::Transform(QTransform *transform, const Node *start, +void NodeTraverser::transform(QTransform *transform, const Node *start, const Node *end, const TimeRange &range) { transform_ = transform; transform_start_ = start; transform_now_ = nullptr; - GenerateTable(end, range); + generate_table(end, range); transform_ = nullptr; } -NodeValueTable NodeTraverser::ProcessInput(const Node *node, +NodeValueTable NodeTraverser::process_input(const Node *node, const QString &input, const TimeRange &range) { // If input is connected, retrieve value directly - if (node->IsInputConnectedForRender(input)) { + if (node->is_input_connected_for_render(input)) { TimeRange adjusted_range = - node->InputTimeAdjustment(input, -1, range, true); + node->input_time_adjustment(input, -1, range, true); // Value will equal something from the connected node, follow it - Node *output = node->GetConnectedRenderOutput(input); - NodeValueTable table = GenerateTable(output, adjusted_range, node); + Node *output = node->get_connected_render_output(input); + NodeValueTable table = generate_table(output, adjusted_range, node); return table; } else { // Store node QVariant return_val; - bool is_array = node->InputIsArray(input); + bool is_array = node->input_is_array(input); if (is_array) { // Value is an array, we will return a list of NodeValueTables NodeValueTableArray array_tbl; Node::ActiveElements a = - node->GetActiveElementsAtTime(input, range); - if (a.mode() == Node::ActiveElements::kAllElements) { - int sz = node->InputArraySize(input); + node->get_active_elements_at_time(input, range); + if (a.mode() == Node::ActiveElements::k_all_elements) { + int sz = node->input_array_size(input); for (int i = 0; i < sz; i++) { - ProcessInputElement(array_tbl, node, input, i, range); + process_input_element(array_tbl, node, input, i, range); } - } else if (a.mode() == Node::ActiveElements::kSpecified) { + } else if (a.mode() == Node::ActiveElements::k_specified) { for (int ele : a.elements()) { - ProcessInputElement(array_tbl, node, input, ele, range); + process_input_element(array_tbl, node, input, ele, range); } } @@ -254,40 +254,40 @@ NodeValueTable NodeTraverser::ProcessInput(const Node *node, } else { // Not connected or an array, just pull the immediate TimeRange adjusted_range = - node->InputTimeAdjustment(input, -1, range, true); + node->input_time_adjustment(input, -1, range, true); - return_val = node->GetValueAtTime(input, adjusted_range.in()); + return_val = node->get_value_at_time(input, adjusted_range.in()); } NodeValueTable return_table; - return_table.Push(node->GetInputDataType(input), return_val, node, + return_table.push(node->get_input_data_type(input), return_val, node, is_array); return return_table; } } -void NodeTraverser::ProcessInputElement(NodeValueTableArray &array_tbl, +void NodeTraverser::process_input_element(NodeValueTableArray &array_tbl, const Node *node, const QString &input, int element, const TimeRange &range) { NodeValueTable &sub_tbl = array_tbl[element]; TimeRange adjusted_range = - node->InputTimeAdjustment(input, element, range, true); + node->input_time_adjustment(input, element, range, true); - if (node->IsInputConnectedForRender(input, element)) { - Node *output = node->GetConnectedRenderOutput(input, element); - sub_tbl = GenerateTable(output, adjusted_range, node); + if (node->is_input_connected_for_render(input, element)) { + Node *output = node->get_connected_render_output(input, element); + sub_tbl = generate_table(output, adjusted_range, node); } else { QVariant input_value = - node->GetValueAtTime(input, adjusted_range.in(), element); - sub_tbl.Push(node->GetInputDataType(input), input_value, node); + node->get_value_at_time(input, adjusted_range.in(), element); + sub_tbl.push(node->get_input_data_type(input), input_value, node); } } NodeTraverser::NodeTraverser() : cancel_(nullptr) , transform_(nullptr) - , loop_mode_(LoopMode::kLoopModeOff) + , loop_mode_(LoopMode::k_loop_mode_off) { } @@ -309,7 +309,7 @@ public: const Node *node; }; -NodeValueTable NodeTraverser::GenerateTable(const Node *n, +NodeValueTable NodeTraverser::generate_table(const Node *n, const TimeRange &range, const Node *next_node) { @@ -325,29 +325,29 @@ NodeValueTable NodeTraverser::GenerateTable(const Node *n, } // Generate row for node - NodeValueDatabase database = GenerateDatabase(n, range); + NodeValueDatabase database = generate_database(n, range); // Check for bypass bool is_enabled; - if (!database[Node::kEnabledInput].Has(NodeValue::kBoolean)) { + if (!database[Node::k_enabled_input].has(NodeValue::k_boolean)) { // Fallback if we couldn't find a bool value is_enabled = true; } else { is_enabled = - database[Node::kEnabledInput].Get(NodeValue::kBoolean).toBool(); + database[Node::k_enabled_input].get(NodeValue::k_boolean).to_bool(); } NodeValueTable table; if (is_enabled) { - NodeValueRow row = GenerateRow(&database, n, range); + NodeValueRow row = generate_row(&database, n, range); // Generate output table - table = database.Merge(); + table = database.merge(); // By this point, the node should have all the inputs it needs to render correctly NodeGlobals globals(video_params_, audio_params_, range, loop_mode_); - n->Value(row, globals, &table); + n->value(row, globals, &table); // `transform_now_` is the next node in the path that needs to be traversed. It only ever goes // "down" the graph so that any traversing going back up doesn't unnecessarily transform @@ -355,7 +355,7 @@ NodeValueTable NodeTraverser::GenerateTable(const Node *n, if (transform_) { if (transform_now_ == n || transform_start_ == n) { if (transform_now_ == n) { - QTransform t = n->GizmoTransformation(row, globals); + QTransform t = n->gizmo_transformation(row, globals); if (!t.isIdentity()) { (*transform_) *= t; } @@ -367,12 +367,12 @@ NodeValueTable NodeTraverser::GenerateTable(const Node *n, } else { // If this node has an effect input, ensure that is pushed last NodeValueTable primary; - if (!n->GetEffectInputID().isEmpty()) { - primary = database.Take(n->GetEffectInputID()); + if (!n->get_effect_input_id().isEmpty()) { + primary = database.take(n->get_effect_input_id()); } - table = database.Merge(); - table.Push(primary); + table = database.merge(); + table.push(primary); } value_cache_[n][range] = table; @@ -380,19 +380,19 @@ NodeValueTable NodeTraverser::GenerateTable(const Node *n, return table; } -TexturePtr NodeTraverser::ProcessVideoCacheJob(const CacheJob *val) +TexturePtr NodeTraverser::process_video_cache_job(const CacheJob *val) { return nullptr; } -TexturePtr NodeTraverser::ProcessPluginJob(TexturePtr texture, +TexturePtr NodeTraverser::process_plugin_job(TexturePtr texture, TexturePtr destination, const Node *node) { // TODO return nullptr; } -QVector2D NodeTraverser::GenerateResolution() const +QVector2D NodeTraverser::generate_resolution() const { return QVector2D(video_params_.square_pixel_width(), video_params_.height()); @@ -402,28 +402,28 @@ QVector2D NodeTraverser::GenerateResolution() const * Resolve Jobs. I need to add a PluginJob here and move the plugin code here. * @param val */ -void NodeTraverser::ResolveJobs(NodeValue &val) +void NodeTraverser::resolve_jobs(NodeValue &val) { - if (val.type() == NodeValue::kTexture) { - if (TexturePtr job_tex = val.toTexture()) { + if (val.type() == NodeValue::k_texture) { + if (TexturePtr job_tex = val.to_texture()) { if (AcceleratedJob *base_job = job_tex->job()) { if (resolved_texture_cache_.contains(job_tex.get())) { val.set_value(resolved_texture_cache_.value(job_tex.get())); } else { // Resolve any sub-jobs - for (auto it = base_job->GetValues().begin(); - it != base_job->GetValues().end(); it++) { + for (auto it = base_job->get_values().begin(); + it != base_job->get_values().end(); it++) { // Jobs will almost always be submitted with one of these types NodeValue &subval = it.value(); - ResolveJobs(subval); + resolve_jobs(subval); } if (CacheJob *cj = dynamic_cast(base_job)) { - TexturePtr tex = ProcessVideoCacheJob(cj); + TexturePtr tex = process_video_cache_job(cj); if (tex) { val.set_value(tex); } else { - val.set_value(cj->GetFallback()); + val.set_value(cj->get_fallback()); } } else if (ColorTransformJob *ctj = @@ -431,16 +431,16 @@ void NodeTraverser::ResolveJobs(NodeValue &val) base_job)) { VideoParams ctj_params = job_tex->params(); - ctj_params.set_format(GetCacheVideoParams().format()); + ctj_params.set_format(get_cache_video_params().format()); - TexturePtr dest = CreateTexture(ctj_params); + TexturePtr dest = create_texture(ctj_params); // Resolve input texture - NodeValue v = ctj->GetInputTexture(); - ResolveJobs(v); - ctj->SetInputTexture(v); + NodeValue v = ctj->get_input_texture(); + resolve_jobs(v); + ctj->set_input_texture(v); - ProcessColorTransform(dest, val.source(), ctj); + process_color_transform(dest, val.source(), ctj); val.set_value(dest); @@ -448,9 +448,9 @@ void NodeTraverser::ResolveJobs(NodeValue &val) dynamic_cast(base_job)) { VideoParams tex_params = job_tex->params(); - TexturePtr tex = CreateTexture(tex_params); + TexturePtr tex = create_texture(tex_params); - ProcessShader(tex, val.source(), sj); + process_shader(tex, val.source(), sj); val.set_value(tex); @@ -458,20 +458,20 @@ void NodeTraverser::ResolveJobs(NodeValue &val) dynamic_cast(base_job)) { VideoParams tex_params = job_tex->params(); - TexturePtr tex = CreateTexture(tex_params); + TexturePtr tex = create_texture(tex_params); - ProcessFrameGeneration(tex, val.source(), gj); + process_frame_generation(tex, val.source(), gj); // Convert to reference space const QString &colorspace = tex_params.colorspace(); if (!colorspace.isEmpty()) { // Set format to primary format tex_params.set_format( - GetCacheVideoParams().format()); + get_cache_video_params().format()); - TexturePtr dest = CreateTexture(tex_params); + TexturePtr dest = create_texture(tex_params); - ConvertToReferenceSpace(dest, tex, colorspace); + convert_to_reference_space(dest, tex, colorspace); tex = dest; } @@ -480,7 +480,7 @@ void NodeTraverser::ResolveJobs(NodeValue &val) } else if (FootageJob *fj = dynamic_cast(base_job)) { - rational footage_time = Footage::AdjustTimeByLoopMode( + Rational footage_time = Footage::adjust_time_by_loop_mode( fj->time().in(), fj->loop_mode(), fj->length(), fj->video_params().video_type(), fj->video_params().frame_rate_as_time_base()); @@ -489,15 +489,15 @@ void NodeTraverser::ResolveJobs(NodeValue &val) if (footage_time.isNaN()) { // Push dummy texture - tex = CreateDummyTexture(fj->video_params()); + tex = create_dummy_texture(fj->video_params()); } else { VideoParams managed_params = fj->video_params(); managed_params.set_format( - GetCacheVideoParams().format()); + get_cache_video_params().format()); - tex = CreateTexture(managed_params); + tex = create_texture(managed_params); if (tex) { - ProcessVideoFootage(tex, fj, footage_time); + process_video_footage(tex, fj, footage_time); } } @@ -508,42 +508,42 @@ void NodeTraverser::ResolveJobs(NodeValue &val) VideoParams tex_params = job_tex->params(); // Force internal working format (F32) for plugin processing, // matching FootageJob/GenerateJob behavior. - tex_params.set_format(GetCacheVideoParams().format()); + tex_params.set_format(get_cache_video_params().format()); tex_params.set_channel_count( - VideoParams::kRGBAChannelCount); + VideoParams::k_rgba_channel_count); - TexturePtr tex = CreateTexture(tex_params); + TexturePtr tex = create_texture(tex_params); - ProcessPluginJob(job_tex, tex, val.source()); + process_plugin_job(job_tex, tex, val.source()); val.set_value(tex); } // Cache resolved value resolved_texture_cache_.insert(job_tex.get(), - val.toTexture()); + val.to_texture()); } } } - } else if (val.type() == NodeValue::kSamples) { + } else if (val.type() == NodeValue::k_samples) { if (val.canConvert()) { SampleJob job = val.value(); - SampleBuffer output_buffer = CreateSampleBuffer( + SampleBuffer output_buffer = create_sample_buffer( job.samples().audio_params(), job.samples().sample_count()); - ProcessSamples(output_buffer, val.source(), job.time(), job); + process_samples(output_buffer, val.source(), job.time(), job); val.set_value(QVariant::fromValue(output_buffer)); } else if (val.canConvert()) { FootageJob job = val.value(); SampleBuffer buffer = - CreateSampleBuffer(GetCacheAudioParams(), job.time().length()); - ProcessAudioFootage(buffer, &job, job.time()); + create_sample_buffer(get_cache_audio_params(), job.time().length()); + process_audio_footage(buffer, &job, job.time()); val.set_value(buffer); } } } -TexturePtr NodeTraverser::CreateDummyTexture(const VideoParams &p) +TexturePtr NodeTraverser::create_dummy_texture(const VideoParams &p) { return std::make_shared(p); } diff --git a/app/node/traverser.h b/app/node/traverser.h index ad6c2720a..50f64ace9 100644 --- a/app/node/traverser.h +++ b/app/node/traverser.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODETRAVERSER_H -#define NODETRAVERSER_H +#ifndef OAK_NODETRAVERSER_H +#define OAK_NODETRAVERSER_H #include @@ -42,149 +42,149 @@ class NodeTraverser { public: NodeTraverser(); - NodeValueTable GenerateTable(const Node *n, const TimeRange &range, + NodeValueTable generate_table(const Node *n, const TimeRange &range, const Node *next_node = nullptr); - virtual NodeValueDatabase GenerateDatabase(const Node *node, + virtual NodeValueDatabase generate_database(const Node *node, const TimeRange &range); - NodeValueRow GenerateRow(NodeValueDatabase *database, const Node *node, + NodeValueRow generate_row(NodeValueDatabase *database, const Node *node, const TimeRange &range); - NodeValueRow GenerateRow(const Node *node, const TimeRange &range); + NodeValueRow generate_row(const Node *node, const TimeRange &range); - NodeValue GenerateRowValue(const Node *node, const QString &input, + NodeValue generate_row_value(const Node *node, const QString &input, NodeValueTable *table, const TimeRange &time); - NodeValue GenerateRowValueElement(const Node *node, const QString &input, + NodeValue generate_row_value_element(const Node *node, const QString &input, int element, NodeValueTable *table, const TimeRange &time); - int GenerateRowValueElementIndex(const Node::ValueHint &hint, + int generate_row_value_element_index(const Node::ValueHint &hint, NodeValue::Type preferred_type, const NodeValueTable *table); - int GenerateRowValueElementIndex(const Node *node, const QString &input, + int generate_row_value_element_index(const Node *node, const QString &input, int element, const NodeValueTable *table); - void Transform(QTransform *transform, const Node *start, const Node *end, + void transform(QTransform *transform, const Node *start, const Node *end, const TimeRange &range); - const VideoParams &GetCacheVideoParams() const + const VideoParams &get_cache_video_params() const { return video_params_; } - void SetCacheVideoParams(const VideoParams ¶ms) + void set_cache_video_params(const VideoParams ¶ms) { video_params_ = params; } - const AudioParams &GetCacheAudioParams() const + const AudioParams &get_cache_audio_params() const { return audio_params_; } - void SetCacheAudioParams(const AudioParams ¶ms) + void set_cache_audio_params(const AudioParams ¶ms) { audio_params_ = params; } protected: - NodeValueTable ProcessInput(const Node *node, const QString &input, + NodeValueTable process_input(const Node *node, const QString &input, const TimeRange &range); - void ProcessInputElement(NodeValueTableArray &array_tbl, const Node *node, + void process_input_element(NodeValueTableArray &array_tbl, const Node *node, const QString &input, int element, const TimeRange &range); - virtual void ProcessVideoFootage(TexturePtr destination, + virtual void process_video_footage(TexturePtr destination, const FootageJob *stream, - const rational &input_time) + const Rational &input_time) { } - virtual void ProcessAudioFootage(SampleBuffer &destination, + virtual void process_audio_footage(SampleBuffer &destination, const FootageJob *stream, const TimeRange &input_time) { } - virtual void ProcessShader(TexturePtr destination, const Node *node, + virtual void process_shader(TexturePtr destination, const Node *node, const ShaderJob *job) { } - virtual void ProcessColorTransform(TexturePtr destination, const Node *node, + virtual void process_color_transform(TexturePtr destination, const Node *node, const ColorTransformJob *job) { } - virtual void ProcessSamples(SampleBuffer &destination, const Node *node, + virtual void process_samples(SampleBuffer &destination, const Node *node, const TimeRange &range, const SampleJob &job) { } - virtual void ProcessFrameGeneration(TexturePtr destination, + virtual void process_frame_generation(TexturePtr destination, const Node *node, const GenerateJob *job) { } - virtual void ConvertToReferenceSpace(TexturePtr destination, + virtual void convert_to_reference_space(TexturePtr destination, TexturePtr source, const QString &input_cs) { } - virtual TexturePtr ProcessVideoCacheJob(const CacheJob *val); + virtual TexturePtr process_video_cache_job(const CacheJob *val); - virtual TexturePtr CreateTexture(const VideoParams &p) + virtual TexturePtr create_texture(const VideoParams &p) { - return CreateDummyTexture(p); + return create_dummy_texture(p); } - virtual SampleBuffer CreateSampleBuffer(const AudioParams ¶ms, + virtual SampleBuffer create_sample_buffer(const AudioParams ¶ms, int sample_count) { // Return dummy by default return SampleBuffer(); } - virtual TexturePtr ProcessPluginJob(TexturePtr texture, + virtual TexturePtr process_plugin_job(TexturePtr texture, TexturePtr destination, const Node *node); - SampleBuffer CreateSampleBuffer(const AudioParams ¶ms, - const rational &length) + SampleBuffer create_sample_buffer(const AudioParams ¶ms, + const Rational &length) { if (params.is_valid()) { - return CreateSampleBuffer(params, params.time_to_samples(length)); + return create_sample_buffer(params, params.time_to_samples(length)); } else { return SampleBuffer(); } } - QVector2D GenerateResolution() const; + QVector2D generate_resolution() const; - bool IsCancelled() + bool is_cancelled() { - return cancel_ && cancel_->IsCancelled(); + return cancel_ && cancel_->is_cancelled(); } - bool HeardCancel() const + bool heard_cancel() const { - return cancel_ && cancel_->HeardCancel(); + return cancel_ && cancel_->heard_cancel(); } - CancelAtom *GetCancelPointer() const + CancelAtom *get_cancel_pointer() const { return cancel_; } - void SetCancelPointer(CancelAtom *cancel) + void set_cancel_pointer(CancelAtom *cancel) { cancel_ = cancel; } - void ResolveJobs(NodeValue &value); - void ResolveAudioJobs(NodeValue &value); + void resolve_jobs(NodeValue &value); + void resolve_audio_jobs(NodeValue &value); - Block *GetCurrentBlock() const + Block *get_current_block() const { return block_stack_.empty() ? nullptr : block_stack_.back(); } @@ -194,13 +194,13 @@ protected: return loop_mode_; } - virtual bool UseCache() const + virtual bool use_cache() const { return false; } private: - TexturePtr CreateDummyTexture(const VideoParams &p); + TexturePtr create_dummy_texture(const VideoParams &p); VideoParams video_params_; @@ -222,4 +222,4 @@ private: } -#endif // NODETRAVERSER_H +#endif // OAK_NODETRAVERSER_H diff --git a/app/node/value.cpp b/app/node/value.cpp index aae95c56b..98846e37c 100644 --- a/app/node/value.cpp +++ b/app/node/value.cpp @@ -34,48 +34,48 @@ namespace olive { -QString NodeValue::ValueToString(Type data_type, const QVariant &value, +QString NodeValue::value_to_string(Type data_type, const QVariant &value, bool value_is_a_key_track) { - if (!value_is_a_key_track && data_type == kVec2) { + if (!value_is_a_key_track && data_type == k_vec2) { QVector2D vec = value.value(); return QStringLiteral("%1:%2").arg(QString::number(vec.x()), QString::number(vec.y())); - } else if (!value_is_a_key_track && data_type == kVec3) { + } else if (!value_is_a_key_track && data_type == k_vec3) { QVector3D vec = value.value(); return QStringLiteral("%1:%2:%3") .arg(QString::number(vec.x()), QString::number(vec.y()), QString::number(vec.z())); - } else if (!value_is_a_key_track && data_type == kVec4) { + } else if (!value_is_a_key_track && data_type == k_vec4) { QVector4D vec = value.value(); return QStringLiteral("%1:%2:%3:%4") .arg(QString::number(vec.x()), QString::number(vec.y()), QString::number(vec.z()), QString::number(vec.w())); - } else if (!value_is_a_key_track && data_type == kColor) { + } else if (!value_is_a_key_track && data_type == k_color) { Color c = value.value(); return QStringLiteral("%1:%2:%3:%4") .arg(QString::number(c.red()), QString::number(c.green()), QString::number(c.blue()), QString::number(c.alpha())); - } else if (!value_is_a_key_track && data_type == kBezier) { + } else if (!value_is_a_key_track && data_type == k_bezier) { Bezier b = value.value(); return QStringLiteral("%1:%2:%3:%4:%5:%6") .arg(QString::number(b.x()), QString::number(b.y()), QString::number(b.cp1_x()), QString::number(b.cp1_y()), QString::number(b.cp2_x()), QString::number(b.cp2_y())); - } else if (data_type == kRational) { - return QString::fromStdString(value.value().toString()); - } else if (data_type == kTexture || data_type == kSamples || - data_type == kNone) { + } else if (data_type == k_rational) { + return QString::fromStdString(value.value().to_string()); + } else if (data_type == k_texture || data_type == k_samples || + data_type == k_none) { // These data types need no XML representation return QString(); - } else if (data_type == kInt) { + } else if (data_type == k_int) { return QString::number(value.value()); - } else if (data_type == kBinary) { + } else if (data_type == k_binary) { return value.toByteArray().toBase64(); } else { if (value.canConvert()) { @@ -84,7 +84,7 @@ QString NodeValue::ValueToString(Type data_type, const QVariant &value, if (!value.isNull()) { qWarning() - << "Failed to convert type" << ToHex(data_type) << "to string"; + << "Failed to convert type" << to_hex(data_type) << "to string"; } return QString(); @@ -98,20 +98,20 @@ NodeValue::split_normal_value_into_track_values(Type type, QVector vals(get_number_of_keyframe_tracks(type)); switch (type) { - case kVec2: { + case k_vec2: { QVector2D vec = value.value(); vals.replace(0, vec.x()); vals.replace(1, vec.y()); break; } - case kVec3: { + case k_vec3: { QVector3D vec = value.value(); vals.replace(0, vec.x()); vals.replace(1, vec.y()); vals.replace(2, vec.z()); break; } - case kVec4: { + case k_vec4: { QVector4D vec = value.value(); vals.replace(0, vec.x()); vals.replace(1, vec.y()); @@ -119,7 +119,7 @@ NodeValue::split_normal_value_into_track_values(Type type, vals.replace(3, vec.w()); break; } - case kColor: { + case k_color: { Color c = value.value(); vals.replace(0, c.red()); vals.replace(1, c.green()); @@ -127,7 +127,7 @@ NodeValue::split_normal_value_into_track_values(Type type, vals.replace(3, c.alpha()); break; } - case kBezier: { + case k_bezier: { Bezier b = value.value(); vals.replace(0, b.x()); vals.replace(1, b.y()); @@ -152,23 +152,23 @@ QVariant NodeValue::combine_track_values_into_normal_value( } switch (type) { - case kVec2: { + case k_vec2: { return QVector2D(split.at(0).toFloat(), split.at(1).toFloat()); } - case kVec3: { + case k_vec3: { return QVector3D(split.at(0).toFloat(), split.at(1).toFloat(), split.at(2).toFloat()); } - case kVec4: { + case k_vec4: { return QVector4D(split.at(0).toFloat(), split.at(1).toFloat(), split.at(2).toFloat(), split.at(3).toFloat()); } - case kColor: { + case k_color: { return QVariant::fromValue( Color(split.at(0).toFloat(), split.at(1).toFloat(), split.at(2).toFloat(), split.at(3).toFloat())); } - case kBezier: + case k_bezier: return QVariant::fromValue( Bezier(split.at(0).toDouble(), split.at(1).toDouble(), split.at(2).toDouble(), split.at(3).toDouble(), @@ -181,207 +181,207 @@ QVariant NodeValue::combine_track_values_into_normal_value( int NodeValue::get_number_of_keyframe_tracks(Type type) { switch (type) { - case NodeValue::kVec2: + case NodeValue::k_vec2: return 2; - case NodeValue::kVec3: + case NodeValue::k_vec3: return 3; - case NodeValue::kVec4: - case NodeValue::kColor: + case NodeValue::k_vec4: + case NodeValue::k_color: return 4; - case NodeValue::kBezier: + case NodeValue::k_bezier: return 6; default: return 1; } } -QVariant NodeValue::StringToValue(Type data_type, const QString &string, +QVariant NodeValue::string_to_value(Type data_type, const QString &string, bool value_is_a_key_track) { - if (!value_is_a_key_track && data_type == kVec2) { + if (!value_is_a_key_track && data_type == k_vec2) { QStringList vals = string.split(':'); - ValidateVectorString(&vals, 2); + validate_vector_string(&vals, 2); return QVector2D(vals.at(0).toFloat(), vals.at(1).toFloat()); - } else if (!value_is_a_key_track && data_type == kVec3) { + } else if (!value_is_a_key_track && data_type == k_vec3) { QStringList vals = string.split(':'); - ValidateVectorString(&vals, 3); + validate_vector_string(&vals, 3); return QVector3D(vals.at(0).toFloat(), vals.at(1).toFloat(), vals.at(2).toFloat()); - } else if (!value_is_a_key_track && data_type == kVec4) { + } else if (!value_is_a_key_track && data_type == k_vec4) { QStringList vals = string.split(':'); - ValidateVectorString(&vals, 4); + validate_vector_string(&vals, 4); return QVector4D(vals.at(0).toFloat(), vals.at(1).toFloat(), vals.at(2).toFloat(), vals.at(3).toFloat()); - } else if (!value_is_a_key_track && data_type == kColor) { + } else if (!value_is_a_key_track && data_type == k_color) { QStringList vals = string.split(':'); - ValidateVectorString(&vals, 4); + validate_vector_string(&vals, 4); return QVariant::fromValue( Color(vals.at(0).toDouble(), vals.at(1).toDouble(), vals.at(2).toDouble(), vals.at(3).toDouble())); - } else if (!value_is_a_key_track && data_type == kBezier) { + } else if (!value_is_a_key_track && data_type == k_bezier) { QStringList vals = string.split(':'); - ValidateVectorString(&vals, 6); + validate_vector_string(&vals, 6); return QVariant::fromValue( Bezier(vals.at(0).toDouble(), vals.at(1).toDouble(), vals.at(2).toDouble(), vals.at(3).toDouble(), vals.at(4).toDouble(), vals.at(5).toDouble())); - } else if (data_type == kInt) { + } else if (data_type == k_int) { return QVariant::fromValue(string.toLongLong()); - } else if (data_type == kRational) { - return QVariant::fromValue(rational::fromString(string.toStdString())); - } else if (data_type == kBinary) { + } else if (data_type == k_rational) { + return QVariant::fromValue(Rational::from_string(string.toStdString())); + } else if (data_type == k_binary) { return QByteArray::fromBase64(string.toLatin1()); } else { return string; } } -void NodeValue::ValidateVectorString(QStringList *list, int count) +void NodeValue::validate_vector_string(QStringList *list, int count) { while (list->size() < count) { list->append(QStringLiteral("0")); } } -QString NodeValue::GetPrettyDataTypeName(Type type) +QString NodeValue::get_pretty_data_type_name(Type type) { switch (type) { - case kNone: + case k_none: return QCoreApplication::translate("NodeValue", "None"); - case kInt: - case kCombo: + case k_int: + case k_combo: return QCoreApplication::translate("NodeValue", "Integer"); - case kStrCombo: + case k_str_combo: return QCoreApplication::translate("NodeValue", "String Combo"); - case kFloat: + case k_float: return QCoreApplication::translate("NodeValue", "Float"); - case kRational: + case k_rational: return QCoreApplication::translate("NodeValue", "Rational"); - case kBoolean: + case k_boolean: return QCoreApplication::translate("NodeValue", "Boolean"); - case kColor: + case k_color: return QCoreApplication::translate("NodeValue", "Color"); - case kMatrix: + case k_matrix: return QCoreApplication::translate("NodeValue", "Matrix"); - case kText: + case k_text: return QCoreApplication::translate("NodeValue", "Text"); - case kFont: + case k_font: return QCoreApplication::translate("NodeValue", "Font"); - case kFile: + case k_file: return QCoreApplication::translate("NodeValue", "File"); - case kTexture: + case k_texture: return QCoreApplication::translate("NodeValue", "Texture"); - case kSamples: + case k_samples: return QCoreApplication::translate("NodeValue", "Samples"); - case kVec2: + case k_vec2: return QCoreApplication::translate("NodeValue", "Vector 2D"); - case kVec3: + case k_vec3: return QCoreApplication::translate("NodeValue", "Vector 3D"); - case kVec4: + case k_vec4: return QCoreApplication::translate("NodeValue", "Vector 4D"); - case kBezier: + case k_bezier: return QCoreApplication::translate("NodeValue", "Bezier"); - case kVideoParams: + case k_video_params: return QCoreApplication::translate("NodeValue", "Video Parameters"); - case kAudioParams: + case k_audio_params: return QCoreApplication::translate("NodeValue", "Audio Parameters"); - case kSubtitleParams: + case k_subtitle_params: return QCoreApplication::translate("NodeValue", "Subtitle Parameters"); - case kBinary: + case k_binary: return QCoreApplication::translate("NodeValue", "Binary"); - case kPushButton: + case k_push_button: return QCoreApplication::translate("NodeValue", "Push Button"); - case kDataTypeCount: + case k_data_type_count: break; } return QCoreApplication::translate("NodeValue", "Unknown"); } -QString NodeValue::GetDataTypeName(Type type) +QString NodeValue::get_data_type_name(Type type) { switch (type) { - case kNone: + case k_none: return QStringLiteral("none"); - case kInt: + case k_int: return QStringLiteral("int"); - case kCombo: + case k_combo: return QStringLiteral("combo"); - case kStrCombo: + case k_str_combo: return QStringLiteral("strcombo"); - case kFloat: + case k_float: return QStringLiteral("float"); - case kRational: - return QStringLiteral("rational"); - case kBoolean: + case k_rational: + return QStringLiteral("Rational"); + case k_boolean: return QStringLiteral("bool"); - case kColor: + case k_color: return QStringLiteral("color"); - case kMatrix: + case k_matrix: return QStringLiteral("matrix"); - case kText: + case k_text: return QStringLiteral("text"); - case kFont: + case k_font: return QStringLiteral("font"); - case kFile: + case k_file: return QStringLiteral("file"); - case kTexture: + case k_texture: return QStringLiteral("texture"); - case kSamples: + case k_samples: return QStringLiteral("samples"); - case kVec2: + case k_vec2: return QStringLiteral("vec2"); - case kVec3: + case k_vec3: return QStringLiteral("vec3"); - case kVec4: + case k_vec4: return QStringLiteral("vec4"); - case kBezier: + case k_bezier: return QStringLiteral("bezier"); - case kVideoParams: + case k_video_params: return QStringLiteral("vparam"); - case kAudioParams: + case k_audio_params: return QStringLiteral("aparam"); - case kSubtitleParams: + case k_subtitle_params: return QStringLiteral("sparam"); - case kBinary: + case k_binary: return QStringLiteral("binary"); - case kPushButton: + case k_push_button: return QStringLiteral("pushbutton"); - case kDataTypeCount: + case k_data_type_count: break; } return QString(); } -NodeValue::Type NodeValue::GetDataTypeFromName(const QString &n) +NodeValue::Type NodeValue::get_data_type_from_name(const QString &n) { // Slow but easy to maintain - for (int i = 0; i < kDataTypeCount; i++) { + for (int i = 0; i < k_data_type_count; i++) { Type t = static_cast(i); - if (GetDataTypeName(t) == n) { + if (get_data_type_name(t) == n) { return t; } } - return NodeValue::kNone; + return NodeValue::k_none; } -NodeValue NodeValueTable::Get(const QVector &type, +NodeValue NodeValueTable::get(const QVector &type, const QString &tag) const { - int value_index = GetValueIndex(type, tag); + int value_index = get_value_index(type, tag); if (value_index >= 0) { return values_.at(value_index); @@ -390,10 +390,10 @@ NodeValue NodeValueTable::Get(const QVector &type, return NodeValue(); } -NodeValue NodeValueTable::Take(const QVector &type, +NodeValue NodeValueTable::take(const QVector &type, const QString &tag) { - int value_index = GetValueIndex(type, tag); + int value_index = get_value_index(type, tag); if (value_index >= 0) { return values_.takeAt(value_index); @@ -402,7 +402,7 @@ NodeValue NodeValueTable::Take(const QVector &type, return NodeValue(); } -bool NodeValueTable::Has(NodeValue::Type type) const +bool NodeValueTable::has(NodeValue::Type type) const { for (int i = values_.size() - 1; i >= 0; i--) { const NodeValue &v = values_.at(i); @@ -415,7 +415,7 @@ bool NodeValueTable::Has(NodeValue::Type type) const return false; } -void NodeValueTable::Remove(const NodeValue &v) +void NodeValueTable::remove(const NodeValue &v) { for (int i = values_.size() - 1; i >= 0; i--) { const NodeValue &compare = values_.at(i); @@ -427,7 +427,7 @@ void NodeValueTable::Remove(const NodeValue &v) } } -NodeValueTable NodeValueTable::Merge(QList tables) +NodeValueTable NodeValueTable::merge(QList tables) { if (tables.size() == 1) { return tables.first(); @@ -442,15 +442,15 @@ NodeValueTable NodeValueTable::Merge(QList tables) bool all_merged = true; foreach (const NodeValueTable &t, tables) { - if (row < t.Count()) { + if (row < t.count()) { all_merged = false; } else { continue; } - int row_index = t.Count() - 1 - row; + int row_index = t.count() - 1 - row; - merged_table.Prepend(t.at(row_index)); + merged_table.prepend(t.at(row_index)); } row++; @@ -463,7 +463,7 @@ NodeValueTable NodeValueTable::Merge(QList tables) return merged_table; } -int NodeValueTable::GetValueIndex(const QVector &types, +int NodeValueTable::get_value_index(const QVector &types, const QString &tag) const { int index = -1; diff --git a/app/node/value.h b/app/node/value.h index 2df8f3e25..59ccf8ecc 100644 --- a/app/node/value.h +++ b/app/node/value.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEVALUE_H -#define NODEVALUE_H +#ifndef OAK_NODEVALUE_H +#define OAK_NODEVALUE_H #include #include @@ -47,7 +47,7 @@ public: * @brief The types of data that can be passed between Nodes */ enum Type { - kNone, + k_none, /** ****************************** SPECIFIC IDENTIFIERS ****************************** @@ -58,28 +58,28 @@ public: * * Resolves to int64_t. */ - kInt, + k_int, /** * Decimal (floating-point) type * * Resolves to `double`. */ - kFloat, + k_float, /** - * Decimal (rational) type + * Decimal (Rational) type * * Resolves to `double`. */ - kRational, + k_rational, /** * Boolean type * * Resolves to `bool`. */ - kBoolean, + k_boolean, /** * Floating-point type @@ -88,129 +88,129 @@ public: * * Colors passed around the nodes should always be in reference space and preferably use */ - kColor, + k_color, /** * Matrix type * * Resolves to `QMatrix4x4`. */ - kMatrix, + k_matrix, /** * Text type * * Resolves to `QString`. */ - kText, + k_text, /** * Font type * * Resolves to `QFont`. */ - kFont, + k_font, /** * File type * * Resolves to a `QString` containing an absolute file path. */ - kFile, + k_file, /** * Image buffer type * * True value type depends on the render engine used. */ - kTexture, + k_texture, /** * Audio samples type * * Resolves to `SampleBufferPtr`. */ - kSamples, + k_samples, /** * Two-dimensional vector (XY) type * * Resolves to `QVector2D`. */ - kVec2, + k_vec2, /** * Three-dimensional vector (XYZ) type * * Resolves to `QVector3D`. */ - kVec3, + k_vec3, /** * Four-dimensional vector (XYZW) type * * Resolves to `QVector4D`. */ - kVec4, + k_vec4, /** * Cubic bezier type that contains three X/Y coordinates, the main point, and two control points * * Resolves to `Bezier` */ - kBezier, + k_bezier, /** * ComboBox type * * Resolves to `int` - the index currently selected */ - kCombo, + k_combo, /** * ComboBox type * * Resolves to `QString` - the text of choice currently selected * This is to support the OpenFX type kOfxParamTypeStrChoice */ - kStrCombo, + k_str_combo, /** * Video Parameters type * * Resolves to `VideoParams` */ - kVideoParams, + k_video_params, /** * Audio Parameters type * * Resolves to `AudioParams` */ - kAudioParams, + k_audio_params, /** * Subtitle Parameters type * * Resolves to `SubtitleParams` */ - kSubtitleParams, + k_subtitle_params, /** * Binary Data */ - kBinary, + k_binary, /** *Push Button */ - kPushButton, + k_push_button, /** * End of list */ - kDataTypeCount + k_data_type_count }; NodeValue() - : type_(kNone) + : type_(k_none) , from_(nullptr) , array_(false) { @@ -288,19 +288,19 @@ public: return !data_.isNull(); } - static QString GetPrettyDataTypeName(Type type); + static QString get_pretty_data_type_name(Type type); - static QString GetDataTypeName(Type type); - static NodeValue::Type GetDataTypeFromName(const QString &n); + static QString get_data_type_name(Type type); + static NodeValue::Type get_data_type_from_name(const QString &n); - static QString ValueToString(Type data_type, const QVariant &value, + static QString value_to_string(Type data_type, const QVariant &value, bool value_is_a_key_track); - static QString ValueToString(const NodeValue &v, bool value_is_a_key_track) + static QString value_to_string(const NodeValue &v, bool value_is_a_key_track) { - return ValueToString(v.type_, v.data_, value_is_a_key_track); + return value_to_string(v.type_, v.data_, value_is_a_key_track); } - static QVariant StringToValue(Type data_type, const QString &string, + static QVariant string_to_value(Type data_type, const QString &string, bool value_is_a_key_track); static QVector @@ -320,91 +320,91 @@ public: */ static bool type_can_be_interpolated(NodeValue::Type type) { - return type == kFloat || type == kVec2 || type == kVec3 || - type == kVec4 || type == kBezier || type == kColor || - type == kRational; + return type == k_float || type == k_vec2 || type == k_vec3 || + type == k_vec4 || type == k_bezier || type == k_color || + type == k_rational; } static bool type_is_numeric(NodeValue::Type type) { - return type == kFloat || type == kInt || type == kRational; + return type == k_float || type == k_int || type == k_rational; } static bool type_is_vector(NodeValue::Type type) { - return type == kVec2 || type == kVec3 || type == kVec4; + return type == k_vec2 || type == k_vec3 || type == k_vec4; } static bool type_is_buffer(NodeValue::Type type) { - return type == kTexture || type == kSamples; + return type == k_texture || type == k_samples; } static int get_number_of_keyframe_tracks(Type type); - static void ValidateVectorString(QStringList *list, int count); + static void validate_vector_string(QStringList *list, int count); - TexturePtr toTexture() const + TexturePtr to_texture() const { return value(); } - SampleBuffer toSamples() const + SampleBuffer to_samples() const { return value(); } - bool toBool() const + bool to_bool() const { return value(); } - double toDouble() const + double to_double() const { return value(); } - int64_t toInt() const + int64_t to_int() const { return value(); } - rational toRational() const + Rational to_rational() const { - return value(); + return value(); } - QString toString() const + QString to_string() const { return value(); } - Color toColor() const + Color to_color() const { return value(); } - QMatrix4x4 toMatrix() const + QMatrix4x4 to_matrix() const { return value(); } - VideoParams toVideoParams() const + VideoParams to_video_params() const { return value(); } - AudioParams toAudioParams() const + AudioParams to_audio_params() const { return value(); } - QVector2D toVec2() const + QVector2D to_vec2() const { return value(); } - QVector3D toVec3() const + QVector3D to_vec3() const { return value(); } - QVector4D toVec4() const + QVector4D to_vec4() const { return value(); } - Bezier toBezier() const + Bezier to_bezier() const { return value(); } - NodeValueArray toArray() const + NodeValueArray to_array() const { return value(); } @@ -421,85 +421,85 @@ class NodeValueTable { public: NodeValueTable() = default; - NodeValue Get(NodeValue::Type type, const QString &tag = QString()) const + NodeValue get(NodeValue::Type type, const QString &tag = QString()) const { QVector types = { type }; - return Get(types, tag); + return get(types, tag); } - NodeValue Get(const QVector &type, + NodeValue get(const QVector &type, const QString &tag = QString()) const; - NodeValue Take(NodeValue::Type type, const QString &tag = QString()) + NodeValue take(NodeValue::Type type, const QString &tag = QString()) { QVector types = { type }; - return Take(types, tag); + return take(types, tag); } - NodeValue Take(const QVector &type, + NodeValue take(const QVector &type, const QString &tag = QString()); - void Push(const NodeValue &value) + void push(const NodeValue &value) { values_.append(value); } - void Push(const NodeValueTable &value) + void push(const NodeValueTable &value) { values_.append(value.values_); } template - void Push(NodeValue::Type type, const T &data, const Node *from, + void push(NodeValue::Type type, const T &data, const Node *from, bool array = false, const QString &tag = QString()) { - Push(NodeValue(type, data, from, array, tag)); + push(NodeValue(type, data, from, array, tag)); } template - void Push(NodeValue::Type type, const T &data, const Node *from, + void push(NodeValue::Type type, const T &data, const Node *from, const QString &tag) { - Push(NodeValue(type, data, from, false, tag)); + push(NodeValue(type, data, from, false, tag)); } - void Prepend(const NodeValue &value) + void prepend(const NodeValue &value) { values_.prepend(value); } template - void Prepend(NodeValue::Type type, const T &data, const Node *from, + void prepend(NodeValue::Type type, const T &data, const Node *from, bool array = false, const QString &tag = QString()) { - Prepend(NodeValue(type, data, from, array, tag)); + prepend(NodeValue(type, data, from, array, tag)); } template - void Prepend(NodeValue::Type type, const T &data, const Node *from, + void prepend(NodeValue::Type type, const T &data, const Node *from, const QString &tag) { - Prepend(NodeValue(type, data, from, false, tag)); + prepend(NodeValue(type, data, from, false, tag)); } const NodeValue &at(int index) const { return values_.at(index); } - NodeValue TakeAt(int index) + NodeValue take_at(int index) { return values_.takeAt(index); } - int Count() const + int count() const { return values_.size(); } - bool Has(NodeValue::Type type) const; - void Remove(const NodeValue &v); + bool has(NodeValue::Type type) const; + void remove(const NodeValue &v); - void Clear() + void clear() { values_.clear(); } @@ -509,10 +509,10 @@ public: return values_.isEmpty(); } - int GetValueIndex(const QVector &type, + int get_value_index(const QVector &type, const QString &tag) const; - static NodeValueTable Merge(QList tables); + static NodeValueTable merge(QList tables); private: QVector values_; @@ -525,4 +525,4 @@ using NodeValueRow = QHash; Q_DECLARE_METATYPE(olive::NodeValue) Q_DECLARE_METATYPE(olive::NodeValueTable) -#endif // NODEVALUE_H +#endif // OAK_NODEVALUE_H diff --git a/app/node/valuedatabase.cpp b/app/node/valuedatabase.cpp index a43ad61a8..3c453e5be 100644 --- a/app/node/valuedatabase.cpp +++ b/app/node/valuedatabase.cpp @@ -24,14 +24,14 @@ namespace olive { -NodeValueTable NodeValueDatabase::Merge() const +NodeValueTable NodeValueDatabase::merge() const { QHash copy = tables_; // Kinda hacky, but we don't need this table to slipstream copy.remove(QStringLiteral("global")); - return NodeValueTable::Merge(copy.values()); + return NodeValueTable::merge(copy.values()); } } diff --git a/app/node/valuedatabase.h b/app/node/valuedatabase.h index 189d741a9..3fa232e90 100644 --- a/app/node/valuedatabase.h +++ b/app/node/valuedatabase.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEVALUEDATABASE_H -#define NODEVALUEDATABASE_H +#ifndef OAK_NODEVALUEDATABASE_H +#define OAK_NODEVALUEDATABASE_H #include "param.h" #include "value.h" @@ -37,17 +37,17 @@ public: return tables_[input_id]; } - void Insert(const QString &key, const NodeValueTable &value) + void insert(const QString &key, const NodeValueTable &value) { tables_.insert(key, value); } - NodeValueTable Take(const QString &key) + NodeValueTable take(const QString &key) { return tables_.take(key); } - NodeValueTable Merge() const; + NodeValueTable merge() const; using Tables = QHash; using const_iterator = Tables::const_iterator; @@ -86,4 +86,4 @@ private: Q_DECLARE_METATYPE(olive::NodeValueDatabase) -#endif // NODEVALUEDATABASE_H +#endif // OAK_NODEVALUEDATABASE_H diff --git a/app/packaging/windows/version.h b/app/packaging/windows/version.h index 55206e9ed..7d1d6621c 100644 --- a/app/packaging/windows/version.h +++ b/app/packaging/windows/version.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef VERSION_H -#define VERSION_H +#ifndef OAK_VERSION_H +#define OAK_VERSION_H #define VER_FILEVERSION 1, 0, 0, 0 #define VER_FILEVERSION_STR "1.0.0.0\0" @@ -36,4 +36,4 @@ #define VER_COMPANYDOMAIN_STR "www.oakvideoeditor.org" -#endif // VERSION_H +#endif // OAK_VERSION_H diff --git a/app/panel/audiomonitor/audiomonitor.cpp b/app/panel/audiomonitor/audiomonitor.cpp index e15e2d789..9fff58015 100644 --- a/app/panel/audiomonitor/audiomonitor.cpp +++ b/app/panel/audiomonitor/audiomonitor.cpp @@ -33,14 +33,14 @@ AudioMonitorPanel::AudioMonitorPanel() { audio_monitor_ = new AudioMonitor(this); - SetWidgetWithPadding(audio_monitor_); + set_widget_with_padding(audio_monitor_); - Retranslate(); + retranslate(); } -void AudioMonitorPanel::Retranslate() +void AudioMonitorPanel::retranslate() { - SetTitle(tr("Audio Monitor")); + set_title(tr("Audio Monitor")); } } diff --git a/app/panel/audiomonitor/audiomonitor.h b/app/panel/audiomonitor/audiomonitor.h index dad5dd03c..28c0ebfaa 100644 --- a/app/panel/audiomonitor/audiomonitor.h +++ b/app/panel/audiomonitor/audiomonitor.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUDIOMONITORPANEL_H -#define AUDIOMONITORPANEL_H +#ifndef OAK_AUDIOMONITORPANEL_H +#define OAK_AUDIOMONITORPANEL_H #include "panel/panel.h" #include "widget/audiomonitor/audiomonitor.h" @@ -36,22 +36,22 @@ class AudioMonitorPanel : public PanelWidget { public: AudioMonitorPanel(); - bool IsPlaying() const + bool is_playing() const { - return audio_monitor_->IsPlaying(); + return audio_monitor_->is_playing(); } - void SetParams(const AudioParams ¶ms) + void set_params(const AudioParams ¶ms) { - audio_monitor_->SetParams(params); + audio_monitor_->set_params(params); } private: - virtual void Retranslate() override; + virtual void retranslate() override; AudioMonitor *audio_monitor_; }; } -#endif // AUDIOMONITORPANEL_H +#endif // OAK_AUDIOMONITORPANEL_H diff --git a/app/panel/curve/curve.cpp b/app/panel/curve/curve.cpp index 29f9769ed..8ac5f1330 100644 --- a/app/panel/curve/curve.cpp +++ b/app/panel/curve/curve.cpp @@ -28,49 +28,49 @@ CurvePanel::CurvePanel() : TimeBasedPanel(QStringLiteral("CurvePanel")) { // Create main widget and set it - SetTimeBasedWidget(new CurveWidget(this)); + set_time_based_widget(new CurveWidget(this)); // Set strings - Retranslate(); + retranslate(); } -void CurvePanel::DeleteSelected() +void CurvePanel::delete_selected() { - static_cast(GetTimeBasedWidget())->DeleteSelected(); + static_cast(get_time_based_widget())->DeleteSelected(); } -void CurvePanel::SelectAll() +void CurvePanel::select_all() { - static_cast(GetTimeBasedWidget())->SelectAll(); + static_cast(get_time_based_widget())->select_all(); } -void CurvePanel::DeselectAll() +void CurvePanel::deselect_all() { - static_cast(GetTimeBasedWidget())->DeselectAll(); + static_cast(get_time_based_widget())->deselect_all(); } -void CurvePanel::SetNodes(const QVector &nodes) +void CurvePanel::set_nodes(const QVector &nodes) { - static_cast(GetTimeBasedWidget())->SetNodes(nodes); + static_cast(get_time_based_widget())->set_nodes(nodes); } -void CurvePanel::IncreaseTrackHeight() +void CurvePanel::increase_track_height() { - CurveWidget *c = static_cast(GetTimeBasedWidget()); - c->SetVerticalScale(c->GetVerticalScale() * 2); + CurveWidget *c = static_cast(get_time_based_widget()); + c->set_vertical_scale(c->get_vertical_scale() * 2); } -void CurvePanel::DecreaseTrackHeight() +void CurvePanel::decrease_track_height() { - CurveWidget *c = static_cast(GetTimeBasedWidget()); - c->SetVerticalScale(c->GetVerticalScale() * 0.5); + CurveWidget *c = static_cast(get_time_based_widget()); + c->set_vertical_scale(c->get_vertical_scale() * 0.5); } -void CurvePanel::Retranslate() +void CurvePanel::retranslate() { - TimeBasedPanel::Retranslate(); + TimeBasedPanel::retranslate(); - SetTitle(tr("Curve Editor")); + set_title(tr("Curve Editor")); } } diff --git a/app/panel/curve/curve.h b/app/panel/curve/curve.h index 35b868845..7180ca1f7 100644 --- a/app/panel/curve/curve.h +++ b/app/panel/curve/curve.h @@ -19,8 +19,8 @@ ***/ -#ifndef CURVEPANEL_H -#define CURVEPANEL_H +#ifndef OAK_CURVEPANEL_H +#define OAK_CURVEPANEL_H #include "panel/timebased/timebased.h" #include "widget/curvewidget/curvewidget.h" @@ -33,14 +33,14 @@ class CurvePanel : public TimeBasedPanel { public: CurvePanel(); - virtual void DeleteSelected() override; + virtual void delete_selected() override; - virtual void SelectAll() override; + virtual void select_all() override; - virtual void DeselectAll() override; + virtual void deselect_all() override; public slots: - void SetNode(Node *node) + void set_node(Node *node) { // Convert single pointer to either an empty vector or a vector of one QVector nodes; @@ -49,19 +49,19 @@ public slots: nodes.append(node); } - SetNodes(nodes); + set_nodes(nodes); } - void SetNodes(const QVector &nodes); + void set_nodes(const QVector &nodes); - virtual void IncreaseTrackHeight() override; + virtual void increase_track_height() override; - virtual void DecreaseTrackHeight() override; + virtual void decrease_track_height() override; protected: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // CURVEPANEL_H +#endif // OAK_CURVEPANEL_H diff --git a/app/panel/footageviewer/footageviewer.cpp b/app/panel/footageviewer/footageviewer.cpp index 70d7d709a..714e9ad7f 100644 --- a/app/panel/footageviewer/footageviewer.cpp +++ b/app/panel/footageviewer/footageviewer.cpp @@ -31,36 +31,36 @@ FootageViewerPanel::FootageViewerPanel() { // Set ViewerWidget as the central widget FootageViewerWidget *fvw = new FootageViewerWidget(this); - SetViewerWidget(fvw); + set_viewer_widget(fvw); // Set strings - Retranslate(); + retranslate(); // Show and raise on connect - SetShowAndRaiseOnConnect(); + set_show_and_raise_on_connect(); } -void FootageViewerPanel::OverrideWorkArea(const TimeRange &r) +void FootageViewerPanel::override_work_area(const TimeRange &r) { - GetFootageViewerWidget()->OverrideWorkArea(r); + get_footage_viewer_widget()->override_work_area(r); } -QVector FootageViewerPanel::GetSelectedFootage() const +QVector FootageViewerPanel::get_selected_footage() const { QVector list; - if (GetConnectedViewer()) { - list.append(GetConnectedViewer()); + if (get_connected_viewer()) { + list.append(get_connected_viewer()); } return list; } -void FootageViewerPanel::Retranslate() +void FootageViewerPanel::retranslate() { - super::Retranslate(); + super::retranslate(); - SetTitle(tr("Footage Viewer")); + set_title(tr("Footage Viewer")); } } diff --git a/app/panel/footageviewer/footageviewer.h b/app/panel/footageviewer/footageviewer.h index 6a1cc5b87..f36dd118d 100644 --- a/app/panel/footageviewer/footageviewer.h +++ b/app/panel/footageviewer/footageviewer.h @@ -19,8 +19,8 @@ ***/ -#ifndef FOOTAGE_VIEWER_PANEL_H -#define FOOTAGE_VIEWER_PANEL_H +#ifndef OAK_FOOTAGE_VIEWER_PANEL_H +#define OAK_FOOTAGE_VIEWER_PANEL_H #include @@ -40,19 +40,19 @@ class FootageViewerPanel : public ViewerPanelBase, public: FootageViewerPanel(); - void OverrideWorkArea(const TimeRange &r); + void override_work_area(const TimeRange &r); - FootageViewerWidget *GetFootageViewerWidget() const + FootageViewerWidget *get_footage_viewer_widget() const { - return static_cast(GetTimeBasedWidget()); + return static_cast(get_time_based_widget()); } - virtual QVector GetSelectedFootage() const override; + virtual QVector get_selected_footage() const override; protected: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // FOOTAGE_VIEWER_PANEL_H +#endif // OAK_FOOTAGE_VIEWER_PANEL_H diff --git a/app/panel/history/historypanel.cpp b/app/panel/history/historypanel.cpp index 0c9796832..c52a787c8 100644 --- a/app/panel/history/historypanel.cpp +++ b/app/panel/history/historypanel.cpp @@ -29,14 +29,14 @@ namespace olive HistoryPanel::HistoryPanel() : PanelWidget(QStringLiteral("HistoryPanel")) { - SetWidgetWithPadding(new HistoryWidget(this)); + set_widget_with_padding(new HistoryWidget(this)); - Retranslate(); + retranslate(); } -void HistoryPanel::Retranslate() +void HistoryPanel::retranslate() { - SetTitle(tr("History")); + set_title(tr("History")); } } diff --git a/app/panel/history/historypanel.h b/app/panel/history/historypanel.h index 2322cbf50..a7a47946b 100644 --- a/app/panel/history/historypanel.h +++ b/app/panel/history/historypanel.h @@ -19,8 +19,8 @@ ***/ -#ifndef HISTORYPANEL_H -#define HISTORYPANEL_H +#ifndef OAK_HISTORYPANEL_H +#define OAK_HISTORYPANEL_H #include "panel/panel.h" @@ -33,9 +33,9 @@ public: HistoryPanel(); protected: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // HISTORYPANEL_H +#endif // OAK_HISTORYPANEL_H diff --git a/app/panel/multicam/multicampanel.cpp b/app/panel/multicam/multicampanel.cpp index b4ed442ea..1585e10ac 100644 --- a/app/panel/multicam/multicampanel.cpp +++ b/app/panel/multicam/multicampanel.cpp @@ -26,16 +26,16 @@ namespace olive MulticamPanel::MulticamPanel() : super(QStringLiteral("MultiCamPanel")) { - SetTimeBasedWidget(new MulticamWidget(this)); + set_time_based_widget(new MulticamWidget(this)); - Retranslate(); + retranslate(); } -void MulticamPanel::Retranslate() +void MulticamPanel::retranslate() { - super::Retranslate(); + super::retranslate(); - SetTitle(tr("Multi-Cam")); + set_title(tr("Multi-Cam")); } } diff --git a/app/panel/multicam/multicampanel.h b/app/panel/multicam/multicampanel.h index 81f2e5608..c6d5e3498 100644 --- a/app/panel/multicam/multicampanel.h +++ b/app/panel/multicam/multicampanel.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef MULTICAMPANEL_H -#define MULTICAMPANEL_H +#ifndef OAK_MULTICAMPANEL_H +#define OAK_MULTICAMPANEL_H #include "panel/viewer/viewerbase.h" #include "widget/multicam/multicamwidget.h" @@ -30,15 +30,15 @@ class MulticamPanel : public TimeBasedPanel { public: MulticamPanel(); - MulticamWidget *GetMulticamWidget() const + MulticamWidget *get_multicam_widget() const { - return static_cast(GetTimeBasedWidget()); + return static_cast(get_time_based_widget()); } protected: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // MULTICAMPANEL_H +#endif // OAK_MULTICAMPANEL_H diff --git a/app/panel/node/node.cpp b/app/panel/node/node.cpp index 734a710b8..346e1470b 100644 --- a/app/panel/node/node.cpp +++ b/app/panel/node/node.cpp @@ -29,26 +29,26 @@ NodePanel::NodePanel() { node_widget_ = new NodeWidget(this); connect(this, &NodePanel::shown, node_widget_->view(), - &NodeView::CenterOnItemsBoundingRect); + &NodeView::center_on_items_bounding_rect); - connect(node_widget_->view(), &NodeView::NodesSelected, this, - &NodePanel::NodesSelected); - connect(node_widget_->view(), &NodeView::NodesDeselected, this, - &NodePanel::NodesDeselected); - connect(node_widget_->view(), &NodeView::NodeSelectionChanged, this, - &NodePanel::NodeSelectionChanged); - connect(node_widget_->view(), &NodeView::NodeSelectionChangedWithContexts, - this, &NodePanel::NodeSelectionChangedWithContexts); - connect(node_widget_->view(), &NodeView::NodeGroupOpened, this, - &NodePanel::NodeGroupOpened); - connect(node_widget_->view(), &NodeView::NodeGroupClosed, this, - &NodePanel::NodeGroupClosed); + connect(node_widget_->view(), &NodeView::nodes_selected, this, + &NodePanel::nodes_selected); + connect(node_widget_->view(), &NodeView::nodes_deselected, this, + &NodePanel::nodes_deselected); + connect(node_widget_->view(), &NodeView::node_selection_changed, this, + &NodePanel::node_selection_changed); + connect(node_widget_->view(), &NodeView::node_selection_changed_with_contexts, + this, &NodePanel::node_selection_changed_with_contexts); + connect(node_widget_->view(), &NodeView::node_group_opened, this, + &NodePanel::node_group_opened); + connect(node_widget_->view(), &NodeView::node_group_closed, this, + &NodePanel::node_group_closed); // Set it as the main widget of this panel - SetWidgetWithPadding(node_widget_); + set_widget_with_padding(node_widget_); // Set strings - Retranslate(); + retranslate(); } } diff --git a/app/panel/node/node.h b/app/panel/node/node.h index 6f5d14477..b0693dd84 100644 --- a/app/panel/node/node.h +++ b/app/panel/node/node.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPANEL_H -#define NODEPANEL_H +#ifndef OAK_NODEPANEL_H +#define OAK_NODEPANEL_H #include "panel/panel.h" #include "widget/nodeview/nodewidget.h" @@ -36,109 +36,109 @@ class NodePanel : public PanelWidget { public: NodePanel(); - NodeWidget *GetNodeWidget() const + NodeWidget *get_node_widget() const { return node_widget_; } - const QVector &GetContexts() const + const QVector &get_contexts() const { - return node_widget_->view()->GetContexts(); + return node_widget_->view()->get_contexts(); } - bool IsGroupOverlay() const + bool is_group_overlay() const { - return node_widget_->view()->IsGroupOverlay(); + return node_widget_->view()->is_group_overlay(); } - void SetContexts(const QVector &nodes) + void set_contexts(const QVector &nodes) { - node_widget_->SetContexts(nodes); + node_widget_->set_contexts(nodes); } - void CloseContextsBelongingToProject(Project *project) + void close_contexts_belonging_to_project(Project *project) { - node_widget_->view()->CloseContextsBelongingToProject(project); + node_widget_->view()->close_contexts_belonging_to_project(project); } - virtual void SelectAll() override + virtual void select_all() override { - node_widget_->view()->SelectAll(); + node_widget_->view()->select_all(); } - virtual void DeselectAll() override + virtual void deselect_all() override { - node_widget_->view()->DeselectAll(); + node_widget_->view()->deselect_all(); } - virtual void DeleteSelected() override + virtual void delete_selected() override { - node_widget_->view()->DeleteSelected(); + node_widget_->view()->delete_selected(); } - virtual void CutSelected() override + virtual void cut_selected() override { - node_widget_->view()->CopySelected(true); + node_widget_->view()->copy_selected(true); } - virtual void CopySelected() override + virtual void copy_selected() override { - node_widget_->view()->CopySelected(false); + node_widget_->view()->copy_selected(false); } - virtual void Paste() override + virtual void paste() override { - node_widget_->view()->Paste(); + node_widget_->view()->paste(); } - virtual void Duplicate() override + virtual void duplicate() override { - node_widget_->view()->Duplicate(); + node_widget_->view()->duplicate(); } - virtual void SetColorLabel(int index) override + virtual void set_color_label(int index) override { - node_widget_->view()->SetColorLabel(index); + node_widget_->view()->set_color_label(index); } - virtual void ZoomIn() override + virtual void zoom_in() override { - node_widget_->view()->ZoomIn(); + node_widget_->view()->zoom_in(); } - virtual void ZoomOut() override + virtual void zoom_out() override { - node_widget_->view()->ZoomOut(); + node_widget_->view()->zoom_out(); } - virtual void RenameSelected() override + virtual void rename_selected() override { - node_widget_->view()->LabelSelectedNodes(); + node_widget_->view()->label_selected_nodes(); } public slots: - void Select(const QVector &p) + void select(const QVector &p) { - node_widget_->view()->Select(p, true); + node_widget_->view()->select(p, true); } signals: - void NodesSelected(const QVector &nodes); + void nodes_selected(const QVector &nodes); - void NodesDeselected(const QVector &nodes); + void nodes_deselected(const QVector &nodes); - void NodeSelectionChanged(const QVector &nodes); + void node_selection_changed(const QVector &nodes); void - NodeSelectionChangedWithContexts(const QVector &nodes); + node_selection_changed_with_contexts(const QVector &nodes); - void NodeGroupOpened(NodeGroup *group); + void node_group_opened(NodeGroup *group); - void NodeGroupClosed(); + void node_group_closed(); private: - virtual void Retranslate() override + virtual void retranslate() override { - SetTitle(tr("Node Editor")); + set_title(tr("Node Editor")); } NodeWidget *node_widget_; @@ -146,4 +146,4 @@ private: } -#endif // NODEPANEL_H +#endif // OAK_NODEPANEL_H diff --git a/app/panel/panel.cpp b/app/panel/panel.cpp index a991a4fbb..2778b38c2 100644 --- a/app/panel/panel.cpp +++ b/app/panel/panel.cpp @@ -52,31 +52,31 @@ PanelWidget::PanelWidget(const QString &object_name) connect(this, &PanelWidget::shown, this, reinterpret_cast(&PanelWidget::setFocus)); - PanelManager::instance()->RegisterPanel(this); + PanelManager::instance()->register_panel(this); } PanelWidget::~PanelWidget() { - PanelManager::instance()->UnregisterPanel(this); + PanelManager::instance()->unregister_panel(this); } -void PanelWidget::SetBorderVisible(bool enabled) +void PanelWidget::set_border_visible(bool enabled) { border_visible_ = enabled; update(); } -void PanelWidget::SetTitle(const QString &t) +void PanelWidget::set_title(const QString &t) { title_ = t; - UpdateTitle(); + update_title(); } -void PanelWidget::SetSubtitle(const QString &t) +void PanelWidget::set_subtitle(const QString &t) { subtitle_ = t; - UpdateTitle(); + update_title(); } void PanelWidget::paintEvent(QPaintEvent *event) @@ -101,7 +101,7 @@ void PanelWidget::paintEvent(QPaintEvent *event) } } -void PanelWidget::UpdateTitle() +void PanelWidget::update_title() { // If there's no subtitle, just use the title. Otherwise, we set a formatted combination of the two that can // differ based on translation @@ -112,7 +112,7 @@ void PanelWidget::UpdateTitle() } } -void PanelWidget::SetSignalInsteadOfClose(bool e) +void PanelWidget::set_signal_instead_of_close(bool e) { signal_instead_of_close_ = e; } @@ -121,7 +121,7 @@ void PanelWidget::closeEvent(QCloseEvent *event) { if (signal_instead_of_close_) { event->ignore(); - emit CloseRequested(); + emit close_requested(); } else { super::closeEvent(event); } @@ -130,7 +130,7 @@ void PanelWidget::closeEvent(QCloseEvent *event) void PanelWidget::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } if (e->type() == QEvent::WindowStateChange) { @@ -143,11 +143,11 @@ void PanelWidget::changeEvent(QEvent *e) super::changeEvent(e); } -void PanelWidget::Retranslate() +void PanelWidget::retranslate() { } -void PanelWidget::SetWidgetWithPadding(QWidget *widget) +void PanelWidget::set_widget_with_padding(QWidget *widget) { QWidget *wrapper = new QWidget(); QHBoxLayout *layout = new QHBoxLayout(wrapper); diff --git a/app/panel/panel.h b/app/panel/panel.h index 6a400a3b1..045f772d6 100644 --- a/app/panel/panel.h +++ b/app/panel/panel.h @@ -19,8 +19,8 @@ ***/ -#ifndef PANEL_WIDGET_H -#define PANEL_WIDGET_H +#ifndef OAK_PANEL_WIDGET_H +#define OAK_PANEL_WIDGET_H #include "KDDockWidgets/src/core/Window_p.h" #include "KDDockWidgets/src/qtwidgets/views/TabBar.h" @@ -58,21 +58,21 @@ public: * * @param enabled */ - void SetBorderVisible(bool enabled); + void set_border_visible(bool enabled); /** * @brief If enabled, sends signal CloseRequested() when the user closes instead of closing * * Defaults to FALSE. Use this to override default panel closing functionality. */ - void SetSignalInsteadOfClose(bool e); + void set_signal_instead_of_close(bool e); using Info = std::map; - virtual void LoadData(const Info &info) + virtual void load_data(const Info &info) { } - virtual Info SaveData() const + virtual Info save_data() const { return Info(); } @@ -83,7 +83,7 @@ public: * This function is up to the Panel's interpretation of what the user intends to zoom into. Default behavior is a * no-op. */ - virtual void ZoomIn() + virtual void zoom_in() { } @@ -93,15 +93,15 @@ public: * This function is up to the Panel's interpretation of what the user intends to zoom out of. Default behavior is a * no-op. */ - virtual void ZoomOut() + virtual void zoom_out() { } - virtual void GoToStart() + virtual void go_to_start() { } - virtual void PrevFrame() + virtual void prev_frame() { } @@ -111,180 +111,180 @@ public: * This function is up to the Panel's interpretation of what the user intends to zoom out of. Default behavior is a * no-op. */ - virtual void PlayPause() + virtual void play_pause() { } - virtual void PlayInToOut() + virtual void play_in_to_out() { } - virtual void NextFrame() + virtual void next_frame() { } - virtual void GoToEnd() + virtual void go_to_end() { } - virtual void SelectAll() + virtual void select_all() { } - virtual void DeselectAll() + virtual void deselect_all() { } - virtual void RippleToIn() + virtual void ripple_to_in() { } - virtual void RippleToOut() + virtual void ripple_to_out() { } - virtual void EditToIn() + virtual void edit_to_in() { } - virtual void EditToOut() + virtual void edit_to_out() { } - virtual void ShuttleLeft() + virtual void shuttle_left() { } - virtual void ShuttleStop() + virtual void shuttle_stop() { } - virtual void ShuttleRight() + virtual void shuttle_right() { } - virtual void GoToPrevCut() + virtual void go_to_prev_cut() { } - virtual void GoToNextCut() + virtual void go_to_next_cut() { } - virtual void RenameSelected() + virtual void rename_selected() { } - virtual void DeleteSelected() + virtual void delete_selected() { } - virtual void RippleDelete() + virtual void ripple_delete() { } - virtual void IncreaseTrackHeight() + virtual void increase_track_height() { } - virtual void DecreaseTrackHeight() + virtual void decrease_track_height() { } - virtual void SetIn() + virtual void set_in() { } - virtual void SetOut() + virtual void set_out() { } - virtual void ResetIn() + virtual void reset_in() { } - virtual void ResetOut() + virtual void reset_out() { } - virtual void ClearInOut() + virtual void clear_in_out() { } - virtual void SetMarker() + virtual void set_marker() { } - virtual void ToggleLinks() + virtual void toggle_links() { } - virtual void CutSelected() + virtual void cut_selected() { } - virtual void CopySelected() + virtual void copy_selected() { } - virtual void Paste() + virtual void paste() { } - virtual void PasteInsert() + virtual void paste_insert() { } - virtual void ToggleShowAll() + virtual void toggle_show_all() { } - virtual void GoToIn() + virtual void go_to_in() { } - virtual void GoToOut() + virtual void go_to_out() { } - virtual void DeleteInToOut() + virtual void delete_in_to_out() { } - virtual void RippleDeleteInToOut() + virtual void ripple_delete_in_to_out() { } - virtual void ToggleSelectedEnabled() + virtual void toggle_selected_enabled() { } - virtual void Duplicate() + virtual void duplicate() { } - virtual void SetColorLabel(int) + virtual void set_color_label(int) { } - virtual void NudgeLeft() + virtual void nudge_left() { } - virtual void NudgeRight() + virtual void nudge_right() { } - virtual void MoveInToPlayhead() + virtual void move_in_to_playhead() { } - virtual void MoveOutToPlayhead() + virtual void move_out_to_playhead() { } signals: - void CloseRequested(); + void close_requested(); void shown(Qt::FocusReason reason); void hidden(); @@ -299,9 +299,9 @@ protected: virtual void closeEvent(QCloseEvent *event) override; - virtual void Retranslate(); + virtual void retranslate(); - void SetWidgetWithPadding(QWidget *widget); + void set_widget_with_padding(QWidget *widget); protected slots: /** @@ -316,7 +316,7 @@ protected slots: * * String to set the title to */ - void SetTitle(const QString &t); + void set_title(const QString &t); /** * @brief Set panel's subtitle @@ -330,7 +330,7 @@ protected slots: * * String to set the subtitle to */ - void SetSubtitle(const QString &t); + void set_subtitle(const QString &t); protected slots: private: /** @@ -338,7 +338,7 @@ private: * * Should be called any time a change is made to title_ or subtitle_ */ - void UpdateTitle(); + void update_title(); QString title_; @@ -348,11 +348,11 @@ private: bool signal_instead_of_close_; - QMetaObject::Connection m_tabBarConnection; - QMetaObject::Connection m_windowConnection; - bool m_lastVisibleState = false; + QMetaObject::Connection m_tabBarConnection_; + QMetaObject::Connection m_windowConnection_; + bool m_lastVisibleState_ = false; }; } -#endif // PANEL_WIDGET_H +#endif // OAK_PANEL_WIDGET_H diff --git a/app/panel/panelmanager.cpp b/app/panel/panelmanager.cpp index c88110b53..4d12e601a 100644 --- a/app/panel/panelmanager.cpp +++ b/app/panel/panelmanager.cpp @@ -34,7 +34,7 @@ PanelManager::PanelManager(QObject *parent) { } -void PanelManager::DeleteAllPanels() +void PanelManager::delete_all_panels() { // Prevent any confusion regarding focus history by clearing it first QList copy = focus_history_; @@ -47,12 +47,12 @@ const QList &PanelManager::panels() return focus_history_; } -PanelWidget *PanelManager::CurrentlyFocused(bool enable_hover) const +PanelWidget *PanelManager::currently_focused(bool enable_hover) const { // If hover focus is enabled, find the currently hovered panel and return it (if no panel is hovered, resort to // default behavior) - if (enable_hover && OLIVE_CONFIG("HoverFocus").toBool()) { - PanelWidget *hovered = CurrentlyHovered(); + if (enable_hover && OAK_CONFIG("HoverFocus").toBool()) { + PanelWidget *hovered = currently_hovered(); if (hovered != nullptr) { return hovered; @@ -66,7 +66,7 @@ PanelWidget *PanelManager::CurrentlyFocused(bool enable_hover) const return focus_history_.first(); } -PanelWidget *PanelManager::CurrentlyHovered() const +PanelWidget *PanelManager::currently_hovered() const { QPoint global_mouse = QCursor::pos(); @@ -79,7 +79,7 @@ PanelWidget *PanelManager::CurrentlyHovered() const return nullptr; } -PanelWidget *PanelManager::GetPanelWithName(const QString &name) const +PanelWidget *PanelManager::get_panel_with_name(const QString &name) const { foreach (PanelWidget *panel, focus_history_) { if (panel->objectName() == name) { @@ -90,12 +90,12 @@ PanelWidget *PanelManager::GetPanelWithName(const QString &name) const return nullptr; } -void PanelManager::CreateInstance() +void PanelManager::create_instance() { instance_ = new PanelManager(); } -void PanelManager::DestroyInstance() +void PanelManager::destroy_instance() { delete instance_; instance_ = nullptr; @@ -106,7 +106,7 @@ PanelManager *PanelManager::instance() return instance_; } -void PanelManager::RegisterPanel(PanelWidget *panel) +void PanelManager::register_panel(PanelWidget *panel) { // Add panel to the bottom of the focus history focus_history_.append(panel); @@ -117,17 +117,17 @@ void PanelManager::RegisterPanel(PanelWidget *panel) if (focus_history_.size() == 1) { // This is the first panel, focus it - panel->SetBorderVisible(true); - emit FocusedPanelChanged(panel); + panel->set_border_visible(true); + emit focused_panel_changed(panel); } } -void PanelManager::UnregisterPanel(PanelWidget *panel) +void PanelManager::unregister_panel(PanelWidget *panel) { focus_history_.removeOne(panel); } -void PanelManager::FocusChanged(QWidget *old, QWidget *now) +void PanelManager::focus_changed(QWidget *old, QWidget *now) { Q_UNUSED(old) @@ -147,11 +147,11 @@ void PanelManager::FocusChanged(QWidget *old, QWidget *now) // Disable highlight border on old panel if (!focus_history_.isEmpty()) { - focus_history_.first()->SetBorderVisible(false); + focus_history_.first()->set_border_visible(false); } // Enable new border's highlight - panel_cast_test->SetBorderVisible(true); + panel_cast_test->set_border_visible(true); // If it's not in the focus history, prepend it, otherwise move it if (panel_index == -1) { @@ -161,7 +161,7 @@ void PanelManager::FocusChanged(QWidget *old, QWidget *now) } if (!suppress_changed_signal_) { - emit FocusedPanelChanged(panel_cast_test); + emit focused_panel_changed(panel_cast_test); } } diff --git a/app/panel/panelmanager.h b/app/panel/panelmanager.h index a0bba59b6..d385a063a 100644 --- a/app/panel/panelmanager.h +++ b/app/panel/panelmanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef PANELFOCUSMANAGER_H -#define PANELFOCUSMANAGER_H +#ifndef OAK_PANELFOCUSMANAGER_H +#define OAK_PANELFOCUSMANAGER_H #include #include @@ -41,7 +41,7 @@ namespace olive * aims to be less specific than a single QPushButton or QLineEdit, and rather specific to the panel widgets like * that belong to. * - * PanelFocusManager's SLOT(FocusChanged()) connects to the QApplication instance's SIGNAL(focusChanged()) so that + * PanelFocusManager's SLOT(focus_changed()) connects to the QApplication instance_'s SIGNAL(focusChanged()) so that * it always knows when focus has changed within the application. */ class PanelManager : public QObject { @@ -54,7 +54,7 @@ public: * * Should only be used on application exit to cleanly free all panels. */ - void DeleteAllPanels(); + void delete_all_panels(); /** * @brief Get a list of all existing panels @@ -68,14 +68,14 @@ public: * * This result == CurrentlyFocused() if HoverFocus is true and panel is hovered */ - PanelWidget *CurrentlyFocused(bool enable_hover = true) const; + PanelWidget *currently_focused(bool enable_hover = true) const; /** * @brief Return the widget that the mouse is currently hovering over, or nullptr if nothing is hovered over */ - PanelWidget *CurrentlyHovered() const; + PanelWidget *currently_hovered() const; - PanelWidget *GetPanelWithName(const QString &name) const; + PanelWidget *get_panel_with_name(const QString &name) const; template /** @@ -85,22 +85,22 @@ public: * * The most recently focused panel of the specified type, or nullptr if none exists */ - T *MostRecentlyFocused(); + T *most_recently_focused(); /** - * @brief Create PanelManager singleton instance + * @brief Create PanelManager singleton instance_ */ - static void CreateInstance(); + static void create_instance(); /** - * @brief Destroy PanelManager singleton instance + * @brief Destroy PanelManager singleton instance_ * * If no PanelManager was created, this is a no-op. */ - static void DestroyInstance(); + static void destroy_instance(); /** - * @brief Access to PanelManager singleton instance + * @brief Access to PanelManager singleton instance_ */ static PanelManager *instance(); @@ -108,19 +108,19 @@ public: /** * @brief Get a list of panels of a certain type */ - QList GetPanelsOfType(); + QList get_panels_of_type(); /** * @brief Panel should call this upon construction so it can be kept track of */ - void RegisterPanel(PanelWidget *panel); + void register_panel(PanelWidget *panel); /** * @brief Panel should call this upon destruction so no invalid pointers will be kept for it */ - void UnregisterPanel(PanelWidget *panel); + void unregister_panel(PanelWidget *panel); - void SetSuppressChangedSignal(bool e) + void set_suppress_changed_signal(bool e) { suppress_changed_signal_ = e; } @@ -131,13 +131,13 @@ public slots: * * Interprets focus information to determine the currently focused panel */ - void FocusChanged(QWidget *old, QWidget *now); + void focus_changed(QWidget *old, QWidget *now); signals: /** * @brief Signal emitted when the currently focused panel changes */ - void FocusedPanelChanged(PanelWidget *panel); + void focused_panel_changed(PanelWidget *panel); private: /** @@ -146,14 +146,14 @@ private: QList focus_history_; /** - * @brief PanelManager singleton instance + * @brief PanelManager singleton instance_ */ static PanelManager *instance_; bool suppress_changed_signal_; }; -template T *PanelManager::MostRecentlyFocused() +template T *PanelManager::most_recently_focused() { T *cast_test; @@ -168,7 +168,7 @@ template T *PanelManager::MostRecentlyFocused() return nullptr; } -template QList PanelManager::GetPanelsOfType() +template QList PanelManager::get_panels_of_type() { QList panels; @@ -187,4 +187,4 @@ template QList PanelManager::GetPanelsOfType() } -#endif // PANELFOCUSMANAGER_H +#endif // OAK_PANELFOCUSMANAGER_H diff --git a/app/panel/param/param.cpp b/app/panel/param/param.cpp index 107a8368f..d0b43565a 100644 --- a/app/panel/param/param.cpp +++ b/app/panel/param/param.cpp @@ -30,41 +30,41 @@ ParamPanel::ParamPanel() : TimeBasedPanel(QStringLiteral("ParamPanel")) { NodeParamView *view = new NodeParamView(this); - connect(view, &NodeParamView::FocusedNodeChanged, this, - &ParamPanel::FocusedNodeChanged); - connect(view, &NodeParamView::SelectedNodesChanged, this, - &ParamPanel::SelectedNodesChanged); - connect(view, &NodeParamView::RequestViewerToStartEditingText, this, - &ParamPanel::RequestViewerToStartEditingText); - connect(this, &ParamPanel::shown, view, &NodeParamView::UpdateElementY); - SetTimeBasedWidget(view); + connect(view, &NodeParamView::focused_node_changed, this, + &ParamPanel::focused_node_changed); + connect(view, &NodeParamView::selected_nodes_changed, this, + &ParamPanel::selected_nodes_changed); + connect(view, &NodeParamView::request_viewer_to_start_editing_text, this, + &ParamPanel::request_viewer_to_start_editing_text); + connect(this, &ParamPanel::shown, view, &NodeParamView::update_element_y); + set_time_based_widget(view); - Retranslate(); + retranslate(); } -void ParamPanel::DeleteSelected() +void ParamPanel::delete_selected() { - static_cast(GetTimeBasedWidget())->DeleteSelected(); + static_cast(get_time_based_widget())->DeleteSelected(); } -void ParamPanel::SelectAll() +void ParamPanel::select_all() { - static_cast(GetTimeBasedWidget())->SelectAll(); + static_cast(get_time_based_widget())->select_all(); } -void ParamPanel::DeselectAll() +void ParamPanel::deselect_all() { - static_cast(GetTimeBasedWidget())->DeselectAll(); + static_cast(get_time_based_widget())->deselect_all(); } -void ParamPanel::SetContexts(const QVector &contexts) +void ParamPanel::set_contexts(const QVector &contexts) { - static_cast(GetTimeBasedWidget())->SetContexts(contexts); + static_cast(get_time_based_widget())->set_contexts(contexts); } -void ParamPanel::Retranslate() +void ParamPanel::retranslate() { - SetTitle(tr("Parameter Editor")); + set_title(tr("Parameter Editor")); } } diff --git a/app/panel/param/param.h b/app/panel/param/param.h index 1c2e900ea..72117c854 100644 --- a/app/panel/param/param.h +++ b/app/panel/param/param.h @@ -19,8 +19,8 @@ ***/ -#ifndef PARAM_H -#define PARAM_H +#ifndef OAK_PARAM_H +#define OAK_PARAM_H #include "panel/curve/curve.h" #include "panel/timebased/timebased.h" @@ -34,46 +34,46 @@ class ParamPanel : public TimeBasedPanel { public: ParamPanel(); - NodeParamView *GetParamView() const + NodeParamView *get_param_view() const { - return static_cast(GetTimeBasedWidget()); + return static_cast(get_time_based_widget()); } - const QVector &GetContexts() const + const QVector &get_contexts() const { - return GetParamView()->GetContexts(); + return get_param_view()->get_contexts(); } - void CloseContextsBelongingToProject(Project *p) + void close_contexts_belonging_to_project(Project *p) { - GetParamView()->CloseContextsBelongingToProject(p); + get_param_view()->close_contexts_belonging_to_project(p); } public slots: - void SetSelectedNodes(const QVector &nodes) + void set_selected_nodes(const QVector &nodes) { - GetParamView()->SetSelectedNodes(nodes, false); + get_param_view()->set_selected_nodes(nodes, false); } - virtual void DeleteSelected() override; + virtual void delete_selected() override; - virtual void SelectAll() override; + virtual void select_all() override; - virtual void DeselectAll() override; + virtual void deselect_all() override; - void SetContexts(const QVector &contexts); + void set_contexts(const QVector &contexts); signals: - void FocusedNodeChanged(Node *n); + void focused_node_changed(Node *n); - void SelectedNodesChanged(const QVector &nodes); + void selected_nodes_changed(const QVector &nodes); - void RequestViewerToStartEditingText(); + void request_viewer_to_start_editing_text(); protected: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // PARAM_H +#endif // OAK_PARAM_H diff --git a/app/panel/pixelsampler/pixelsamplerpanel.cpp b/app/panel/pixelsampler/pixelsamplerpanel.cpp index 465a94ca6..35568d7d7 100644 --- a/app/panel/pixelsampler/pixelsamplerpanel.cpp +++ b/app/panel/pixelsampler/pixelsamplerpanel.cpp @@ -30,26 +30,26 @@ PixelSamplerPanel::PixelSamplerPanel() : PanelWidget(QStringLiteral("PixelSamplerPanel")) { sampler_widget_ = new ManagedPixelSamplerWidget(this); - SetWidgetWithPadding(sampler_widget_); + set_widget_with_padding(sampler_widget_); connect(this, &PixelSamplerPanel::shown, Core::instance(), - [] { Core::instance()->RequestPixelSamplingInViewers(true); }); + [] { Core::instance()->request_pixel_sampling_in_viewers(true); }); connect(this, &PixelSamplerPanel::hidden, Core::instance(), - [] { Core::instance()->RequestPixelSamplingInViewers(false); }); - connect(Core::instance(), &Core::ColorPickerColorEmitted, this, - &PixelSamplerPanel::SetValues); + [] { Core::instance()->request_pixel_sampling_in_viewers(false); }); + connect(Core::instance(), &Core::color_picker_color_emitted, this, + &PixelSamplerPanel::set_values); - Retranslate(); + retranslate(); } -void PixelSamplerPanel::SetValues(const Color &reference, const Color &display) +void PixelSamplerPanel::set_values(const Color &reference, const Color &display) { - sampler_widget_->SetValues(reference, display); + sampler_widget_->set_values(reference, display); } -void PixelSamplerPanel::Retranslate() +void PixelSamplerPanel::retranslate() { - SetTitle(tr("Pixel Sampler")); + set_title(tr("Pixel Sampler")); } } diff --git a/app/panel/pixelsampler/pixelsamplerpanel.h b/app/panel/pixelsampler/pixelsamplerpanel.h index 6cf24fc16..686113082 100644 --- a/app/panel/pixelsampler/pixelsamplerpanel.h +++ b/app/panel/pixelsampler/pixelsamplerpanel.h @@ -19,8 +19,8 @@ ***/ -#ifndef PIXELSAMPLERPANEL_H -#define PIXELSAMPLERPANEL_H +#ifndef OAK_PIXELSAMPLERPANEL_H +#define OAK_PIXELSAMPLERPANEL_H #include "panel/panel.h" #include "widget/pixelsampler/pixelsampler.h" @@ -34,14 +34,14 @@ public: PixelSamplerPanel(); public slots: - void SetValues(const Color &reference, const Color &display); + void set_values(const Color &reference, const Color &display); private: - virtual void Retranslate() override; + virtual void retranslate() override; ManagedPixelSamplerWidget *sampler_widget_; }; } -#endif // PIXELSAMPLERPANEL_H +#endif // OAK_PIXELSAMPLERPANEL_H diff --git a/app/panel/project/footagemanagementpanel.h b/app/panel/project/footagemanagementpanel.h index 510b82baa..176054936 100644 --- a/app/panel/project/footagemanagementpanel.h +++ b/app/panel/project/footagemanagementpanel.h @@ -19,8 +19,8 @@ ***/ -#ifndef FOOTAGEMANAGEMENTPANEL_H -#define FOOTAGEMANAGEMENTPANEL_H +#ifndef OAK_FOOTAGEMANAGEMENTPANEL_H +#define OAK_FOOTAGEMANAGEMENTPANEL_H #include @@ -31,9 +31,9 @@ namespace olive class FootageManagementPanel { public: - virtual QVector GetSelectedFootage() const = 0; + virtual QVector get_selected_footage() const = 0; }; } -#endif // FOOTAGEMANAGEMENTPANEL_H +#endif // OAK_FOOTAGEMANAGEMENTPANEL_H diff --git a/app/panel/project/project.cpp b/app/panel/project/project.cpp index 9886f8572..63ff0cff4 100644 --- a/app/panel/project/project.cpp +++ b/app/panel/project/project.cpp @@ -44,39 +44,39 @@ ProjectPanel::ProjectPanel(const QString &unique_name) QVBoxLayout *layout = new QVBoxLayout(central_widget); layout->setContentsMargins(0, 0, 0, 0); - SetWidgetWithPadding(central_widget); + set_widget_with_padding(central_widget); // Set up project toolbar ProjectToolbar *toolbar = new ProjectToolbar(this); layout->addWidget(toolbar); // Make toolbar connections - connect(toolbar, &ProjectToolbar::NewClicked, this, - &ProjectPanel::ShowNewMenu); - connect(toolbar, &ProjectToolbar::OpenClicked, Core::instance(), - &Core::OpenProject); - connect(toolbar, &ProjectToolbar::SaveClicked, this, - &ProjectPanel::SaveConnectedProject); + connect(toolbar, &ProjectToolbar::new_clicked, this, + &ProjectPanel::show_new_menu); + connect(toolbar, &ProjectToolbar::open_clicked, Core::instance(), + &Core::open_project); + connect(toolbar, &ProjectToolbar::save_clicked, this, + &ProjectPanel::save_connected_project); // Set up main explorer object explorer_ = new ProjectExplorer(this); layout->addWidget(explorer_); - connect(explorer_, &ProjectExplorer::DoubleClickedItem, this, - &ProjectPanel::ItemDoubleClickSlot); - connect(explorer_, &ProjectExplorer::SelectionChanged, this, - &ProjectPanel::SelectionChanged); - connect(toolbar, &ProjectToolbar::SearchChanged, explorer_, - &ProjectExplorer::SetSearchFilter); + connect(explorer_, &ProjectExplorer::double_clicked_item, this, + &ProjectPanel::item_double_click_slot); + connect(explorer_, &ProjectExplorer::selection_changed, this, + &ProjectPanel::selection_changed); + connect(toolbar, &ProjectToolbar::search_changed, explorer_, + &ProjectExplorer::set_search_filter); // Set toolbar's view to the explorer's view - toolbar->SetView(explorer_->view_type()); + toolbar->set_view(explorer_->view_type()); // Connect toolbar's view change signal to the explorer's view change slot - connect(toolbar, &ProjectToolbar::ViewChanged, explorer_, + connect(toolbar, &ProjectToolbar::view_changed, explorer_, &ProjectExplorer::set_view_type); // Set strings - Retranslate(); + retranslate(); } Project *ProjectPanel::project() const @@ -87,24 +87,24 @@ Project *ProjectPanel::project() const void ProjectPanel::set_project(Project *p) { if (project()) { - disconnect(project(), &Project::NameChanged, this, - &ProjectPanel::UpdateSubtitle); - disconnect(project(), &Project::NameChanged, this, - &ProjectPanel::ProjectNameChanged); + disconnect(project(), &Project::name_changed, this, + &ProjectPanel::update_subtitle); + disconnect(project(), &Project::name_changed, this, + &ProjectPanel::project_name_changed); } explorer_->set_project(p); if (project()) { - connect(project(), &Project::NameChanged, this, - &ProjectPanel::UpdateSubtitle); - connect(project(), &Project::NameChanged, this, - &ProjectPanel::ProjectNameChanged); + connect(project(), &Project::name_changed, this, + &ProjectPanel::update_subtitle); + connect(project(), &Project::name_changed, this, + &ProjectPanel::project_name_changed); } - UpdateSubtitle(); + update_subtitle(); - emit ProjectNameChanged(); + emit project_name_changed(); } Folder *ProjectPanel::get_root() const @@ -116,17 +116,17 @@ void ProjectPanel::set_root(Folder *item) { explorer_->set_root(item); - Retranslate(); + retranslate(); } -QVector ProjectPanel::SelectedItems() const +QVector ProjectPanel::selected_items() const { - return explorer_->SelectedItems(); + return explorer_->selected_items(); } -Folder *ProjectPanel::GetSelectedFolder() const +Folder *ProjectPanel::get_selected_folder() const { - return explorer_->GetSelectedFolder(); + return explorer_->get_selected_folder(); } ProjectViewModel *ProjectPanel::model() const @@ -134,71 +134,71 @@ ProjectViewModel *ProjectPanel::model() const return explorer_->model(); } -void ProjectPanel::SelectAll() +void ProjectPanel::select_all() { - explorer_->SelectAll(); + explorer_->select_all(); } -void ProjectPanel::DeselectAll() +void ProjectPanel::deselect_all() { - explorer_->DeselectAll(); + explorer_->deselect_all(); } -void ProjectPanel::DeleteSelected() +void ProjectPanel::delete_selected() { - explorer_->DeleteSelected(); + explorer_->delete_selected(); } -void ProjectPanel::RenameSelected() +void ProjectPanel::rename_selected() { - explorer_->RenameSelectedItem(); + explorer_->rename_selected_item(); } -void ProjectPanel::Edit(Node *item) +void ProjectPanel::edit(Node *item) { - explorer_->Edit(item); + explorer_->edit(item); } -void ProjectPanel::Retranslate() +void ProjectPanel::retranslate() { if (project() && explorer_->get_root() != project()->root()) { - SetTitle(tr("Folder")); + set_title(tr("Folder")); } else { - SetTitle(tr("Project")); + set_title(tr("Project")); } - UpdateSubtitle(); + update_subtitle(); } -void ProjectPanel::ItemDoubleClickSlot(Node *item) +void ProjectPanel::item_double_click_slot(Node *item) { if (item == nullptr) { // If the user double clicks on empty space, show the import dialog - Core::instance()->DialogImportShow(); + Core::instance()->dialog_import_show(); } else if (dynamic_cast(item)) { // Open this footage in a FootageViewer auto panel = - PanelManager::instance()->MostRecentlyFocused(); - panel->ConnectViewerNode(static_cast(item)); + PanelManager::instance()->most_recently_focused(); + panel->connect_viewer_node(static_cast(item)); panel->raise(); panel->setFocus(Qt::FocusReason::MouseFocusReason); } else if (dynamic_cast(item)) { // Open this sequence in the Timeline - Core::instance()->main_window()->OpenSequence( + Core::instance()->main_window()->open_sequence( static_cast(item)); } } -void ProjectPanel::ShowNewMenu() +void ProjectPanel::show_new_menu() { Menu new_menu(this); - MenuShared::instance()->AddItemsForNewMenu(&new_menu); + MenuShared::instance()->add_items_for_new_menu(&new_menu); new_menu.exec(QCursor::pos()); } -void ProjectPanel::UpdateSubtitle() +void ProjectPanel::update_subtitle() { if (project()) { QString project_title = QStringLiteral("%1").arg(project()->name()); @@ -210,7 +210,7 @@ void ProjectPanel::UpdateSubtitle() do { folder_path.prepend( - QStringLiteral("/%1").arg(item->GetLabel())); + QStringLiteral("/%1").arg(item->get_label())); item = item->folder(); } while (item != project()->root()); @@ -218,20 +218,20 @@ void ProjectPanel::UpdateSubtitle() project_title.append(folder_path); } - SetSubtitle(project_title); + set_subtitle(project_title); } else { - SetSubtitle(tr("(none)")); + set_subtitle(tr("(none)")); } } -void ProjectPanel::SaveConnectedProject() +void ProjectPanel::save_connected_project() { - Core::instance()->SaveProject(); + Core::instance()->save_project(); } -QVector ProjectPanel::GetSelectedFootage() const +QVector ProjectPanel::get_selected_footage() const { - QVector items = SelectedItems(); + QVector items = selected_items(); QVector footage; foreach (Node *i, items) { diff --git a/app/panel/project/project.h b/app/panel/project/project.h index 185185185..2b9bae66a 100644 --- a/app/panel/project/project.h +++ b/app/panel/project/project.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECT_PANEL_H -#define PROJECT_PANEL_H +#ifndef OAK_PROJECT_PANEL_H +#define OAK_PROJECT_PANEL_H #include "footagemanagementpanel.h" #include "node/project.h" @@ -45,49 +45,49 @@ public: void set_root(Folder *item); - QVector SelectedItems() const; + QVector selected_items() const; - Folder *GetSelectedFolder() const; + Folder *get_selected_folder() const; - virtual QVector GetSelectedFootage() const override; + virtual QVector get_selected_footage() const override; ProjectViewModel *model() const; - bool SelectItem(Node *n, bool deselect_all_first = true) + bool select_item(Node *n, bool deselect_all_first = true) { - return explorer_->SelectItem(n, deselect_all_first); + return explorer_->select_item(n, deselect_all_first); } - virtual void SelectAll() override; - virtual void DeselectAll() override; + virtual void select_all() override; + virtual void deselect_all() override; - virtual void DeleteSelected() override; + virtual void delete_selected() override; - virtual void RenameSelected() override; + virtual void rename_selected() override; public slots: - void Edit(Node *item); + void edit(Node *item); signals: - void ProjectNameChanged(); + void project_name_changed(); - void SelectionChanged(const QVector &selected); + void selection_changed(const QVector &selected); private: - virtual void Retranslate() override; + virtual void retranslate() override; ProjectExplorer *explorer_; private slots: - void ItemDoubleClickSlot(Node *item); + void item_double_click_slot(Node *item); - void ShowNewMenu(); + void show_new_menu(); - void UpdateSubtitle(); + void update_subtitle(); - void SaveConnectedProject(); + void save_connected_project(); }; } -#endif // PROJECT_PANEL_H +#endif // OAK_PROJECT_PANEL_H diff --git a/app/panel/scope/scope.cpp b/app/panel/scope/scope.cpp index d6aedbef0..1f30bf5e6 100644 --- a/app/panel/scope/scope.cpp +++ b/app/panel/scope/scope.cpp @@ -42,7 +42,7 @@ ScopePanel::ScopePanel() scope_type_combobox_ = new QComboBox(); - for (int i = 0; i < ScopePanel::kTypeCount; i++) { + for (int i = 0; i < ScopePanel::k_type_count; i++) { // These strings get filled in later in Retranslate() scope_type_combobox_->addItem(QString()); } @@ -72,81 +72,81 @@ ScopePanel::ScopePanel() static_cast(&QComboBox::currentIndexChanged), stack_, &QStackedWidget::setCurrentIndex); - Retranslate(); + retranslate(); } -void ScopePanel::SetType(ScopePanel::Type t) +void ScopePanel::set_type(ScopePanel::Type t) { scope_type_combobox_->setCurrentIndex(t); } -QString ScopePanel::TypeToName(ScopePanel::Type t) +QString ScopePanel::type_to_name(ScopePanel::Type t) { switch (t) { - case kTypeWaveform: + case k_type_waveform: return tr("Waveform"); - case kTypeVectorscope: + case k_type_vectorscope: return tr("Vectorscope"); - case kTypeHistogram: + case k_type_histogram: return tr("Histogram"); - case kTypeCount: + case k_type_count: break; } return QString(); } -void ScopePanel::SetViewerPanel(ViewerPanelBase *vp) +void ScopePanel::set_viewer_panel(ViewerPanelBase *vp) { if (viewer_ == vp) { return; } if (viewer_) { - disconnect(viewer_, &ViewerPanelBase::TextureChanged, this, - &ScopePanel::SetReferenceBuffer); - disconnect(viewer_, &ViewerPanelBase::ColorManagerChanged, this, - &ScopePanel::SetColorManager); + disconnect(viewer_, &ViewerPanelBase::texture_changed, this, + &ScopePanel::set_reference_buffer); + disconnect(viewer_, &ViewerPanelBase::color_manager_changed, this, + &ScopePanel::set_color_manager); } viewer_ = vp; if (viewer_) { // Connect viewer widget texture drawing to scope panel - connect(viewer_, &ViewerPanelBase::TextureChanged, this, - &ScopePanel::SetReferenceBuffer); - connect(viewer_, &ViewerPanelBase::ColorManagerChanged, this, - &ScopePanel::SetColorManager); + connect(viewer_, &ViewerPanelBase::texture_changed, this, + &ScopePanel::set_reference_buffer); + connect(viewer_, &ViewerPanelBase::color_manager_changed, this, + &ScopePanel::set_color_manager); - SetColorManager(viewer_->GetColorManager()); + set_color_manager(viewer_->get_color_manager()); - viewer_->UpdateTextureFromNode(); + viewer_->update_texture_from_node(); } else { - SetReferenceBuffer(nullptr); - SetColorManager(nullptr); + set_reference_buffer(nullptr); + set_color_manager(nullptr); } } -void ScopePanel::SetReferenceBuffer(TexturePtr frame) +void ScopePanel::set_reference_buffer(TexturePtr frame) { - histogram_->SetBuffer(frame); - vectorscope_->SetBuffer(frame); - waveform_view_->SetBuffer(frame); + histogram_->set_buffer(frame); + vectorscope_->set_buffer(frame); + waveform_view_->set_buffer(frame); } -void ScopePanel::SetColorManager(ColorManager *manager) +void ScopePanel::set_color_manager(ColorManager *manager) { - histogram_->ConnectColorManager(manager); - vectorscope_->ConnectColorManager(manager); - waveform_view_->ConnectColorManager(manager); + histogram_->connect_color_manager(manager); + vectorscope_->connect_color_manager(manager); + waveform_view_->connect_color_manager(manager); } -void ScopePanel::Retranslate() +void ScopePanel::retranslate() { - SetTitle(tr("Scopes")); + set_title(tr("Scopes")); - for (int i = 0; i < ScopePanel::kTypeCount; i++) { - scope_type_combobox_->setItemText(i, TypeToName(static_cast(i))); + for (int i = 0; i < ScopePanel::k_type_count; i++) { + scope_type_combobox_->setItemText(i, type_to_name(static_cast(i))); } } diff --git a/app/panel/scope/scope.h b/app/panel/scope/scope.h index 3286bab7c..ddb661d9b 100644 --- a/app/panel/scope/scope.h +++ b/app/panel/scope/scope.h @@ -19,8 +19,8 @@ ***/ -#ifndef SCOPE_PANEL_H -#define SCOPE_PANEL_H +#ifndef OAK_SCOPE_PANEL_H +#define OAK_SCOPE_PANEL_H #include #include @@ -38,33 +38,33 @@ class ScopePanel : public PanelWidget { Q_OBJECT public: enum Type { - kTypeWaveform, - kTypeVectorscope, - kTypeHistogram, + k_type_waveform, + k_type_vectorscope, + k_type_histogram, - kTypeCount + k_type_count }; ScopePanel(); - void SetType(Type t); + void set_type(Type t); - static QString TypeToName(Type t); + static QString type_to_name(Type t); - void SetViewerPanel(ViewerPanelBase *vp); + void set_viewer_panel(ViewerPanelBase *vp); - ViewerPanelBase *GetConnectedViewerPanel() const + ViewerPanelBase *get_connected_viewer_panel() const { return viewer_; } public slots: - void SetReferenceBuffer(TexturePtr frame); + void set_reference_buffer(TexturePtr frame); - void SetColorManager(ColorManager *manager); + void set_color_manager(ColorManager *manager); protected: - virtual void Retranslate() override; + virtual void retranslate() override; private: Type type_; @@ -84,4 +84,4 @@ private: } -#endif // SCOPE_PANEL_H +#endif // OAK_SCOPE_PANEL_H diff --git a/app/panel/sequenceviewer/sequenceviewer.cpp b/app/panel/sequenceviewer/sequenceviewer.cpp index 372efbcbd..dd8101218 100644 --- a/app/panel/sequenceviewer/sequenceviewer.cpp +++ b/app/panel/sequenceviewer/sequenceviewer.cpp @@ -29,22 +29,22 @@ SequenceViewerPanel::SequenceViewerPanel() : ViewerPanel(QStringLiteral("SequenceViewerPanel")) { // Set strings - Retranslate(); + retranslate(); } -void SequenceViewerPanel::StartCapture(const TimeRange &time, +void SequenceViewerPanel::start_capture(const TimeRange &time, const Track::Reference &track) { TimelinePanel *tp = static_cast(sender()); - static_cast(GetTimeBasedWidget()) - ->StartCapture(tp->timeline_widget(), time, track); + static_cast(get_time_based_widget()) + ->start_capture(tp->timeline_widget(), time, track); } -void SequenceViewerPanel::Retranslate() +void SequenceViewerPanel::retranslate() { - ViewerPanel::Retranslate(); + ViewerPanel::retranslate(); - SetTitle(tr("Sequence Viewer")); + set_title(tr("Sequence Viewer")); } } diff --git a/app/panel/sequenceviewer/sequenceviewer.h b/app/panel/sequenceviewer/sequenceviewer.h index 352a8c5c1..35520cdcb 100644 --- a/app/panel/sequenceviewer/sequenceviewer.h +++ b/app/panel/sequenceviewer/sequenceviewer.h @@ -19,8 +19,8 @@ ***/ -#ifndef SEQUENCEVIEWERPANEL_H -#define SEQUENCEVIEWERPANEL_H +#ifndef OAK_SEQUENCEVIEWERPANEL_H +#define OAK_SEQUENCEVIEWERPANEL_H #include "panel/viewer/viewer.h" @@ -33,12 +33,12 @@ public: SequenceViewerPanel(); public slots: - void StartCapture(const TimeRange &time, const Track::Reference &track); + void start_capture(const TimeRange &time, const Track::Reference &track); protected: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // SEQUENCEVIEWERPANEL_H +#endif // OAK_SEQUENCEVIEWERPANEL_H diff --git a/app/panel/table/table.cpp b/app/panel/table/table.cpp index cfb072d03..adaf478e8 100644 --- a/app/panel/table/table.cpp +++ b/app/panel/table/table.cpp @@ -27,14 +27,14 @@ namespace olive NodeTablePanel::NodeTablePanel() : TimeBasedPanel(QStringLiteral("NodeTablePanel")) { - SetTimeBasedWidget(new NodeTableWidget(this)); + set_time_based_widget(new NodeTableWidget(this)); - Retranslate(); + retranslate(); } -void NodeTablePanel::Retranslate() +void NodeTablePanel::retranslate() { - SetTitle(tr("Table View")); + set_title(tr("Table View")); } } diff --git a/app/panel/table/table.h b/app/panel/table/table.h index 5d70bf8dd..fefaaa8ec 100644 --- a/app/panel/table/table.h +++ b/app/panel/table/table.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODETABLEPANEL_H -#define NODETABLEPANEL_H +#ifndef OAK_NODETABLEPANEL_H +#define OAK_NODETABLEPANEL_H #include "panel/timebased/timebased.h" #include "widget/nodetableview/nodetablewidget.h" @@ -34,21 +34,21 @@ public: NodeTablePanel(); public slots: - void SelectNodes(const QVector &nodes) + void select_nodes(const QVector &nodes) { - static_cast(GetTimeBasedWidget())->SelectNodes(nodes); + static_cast(get_time_based_widget())->select_nodes(nodes); } - void DeselectNodes(const QVector &nodes) + void deselect_nodes(const QVector &nodes) { - static_cast(GetTimeBasedWidget()) - ->DeselectNodes(nodes); + static_cast(get_time_based_widget()) + ->deselect_nodes(nodes); } private: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // NODETABLEPANEL_H +#endif // OAK_NODETABLEPANEL_H diff --git a/app/panel/taskmanager/taskmanager.cpp b/app/panel/taskmanager/taskmanager.cpp index f81a17d01..1868e9f3d 100644 --- a/app/panel/taskmanager/taskmanager.cpp +++ b/app/panel/taskmanager/taskmanager.cpp @@ -36,22 +36,22 @@ TaskManagerPanel::TaskManagerPanel() setWidget(view_); // Connect task view to the task manager - connect(TaskManager::instance(), &TaskManager::TaskAdded, view_, - &TaskView::AddTask); - connect(TaskManager::instance(), &TaskManager::TaskRemoved, view_, - &TaskView::RemoveTask); - connect(TaskManager::instance(), &TaskManager::TaskFailed, view_, - &TaskView::TaskFailed); - connect(view_, &TaskView::TaskCancelled, TaskManager::instance(), - &TaskManager::CancelTask); + connect(TaskManager::instance(), &TaskManager::task_added, view_, + &TaskView::add_task); + connect(TaskManager::instance(), &TaskManager::task_removed, view_, + &TaskView::remove_task); + connect(TaskManager::instance(), &TaskManager::task_failed, view_, + &TaskView::task_failed); + connect(view_, &TaskView::task_cancelled, TaskManager::instance(), + &TaskManager::cancel_task); // Set strings - Retranslate(); + retranslate(); } -void TaskManagerPanel::Retranslate() +void TaskManagerPanel::retranslate() { - SetTitle(tr("Task Manager")); + set_title(tr("Task Manager")); } } diff --git a/app/panel/taskmanager/taskmanager.h b/app/panel/taskmanager/taskmanager.h index 3cc033850..716de7a83 100644 --- a/app/panel/taskmanager/taskmanager.h +++ b/app/panel/taskmanager/taskmanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef TASKMANAGER_PANEL_H -#define TASKMANAGER_PANEL_H +#ifndef OAK_TASKMANAGER_PANEL_H +#define OAK_TASKMANAGER_PANEL_H #include "panel/panel.h" #include "widget/taskview/taskview.h" @@ -37,7 +37,7 @@ public: TaskManagerPanel(); private: - virtual void Retranslate() override; + virtual void retranslate() override; TaskView *view_; }; diff --git a/app/panel/timebased/timebased.cpp b/app/panel/timebased/timebased.cpp index 429f60c39..9658312d7 100644 --- a/app/panel/timebased/timebased.cpp +++ b/app/panel/timebased/timebased.cpp @@ -36,122 +36,122 @@ TimeBasedPanel::~TimeBasedPanel() delete widget_; } -const rational &TimeBasedPanel::timebase() +const Rational &TimeBasedPanel::timebase() { return widget_->timebase(); } -void TimeBasedPanel::GoToStart() +void TimeBasedPanel::go_to_start() { - widget_->GoToStart(); + widget_->go_to_start(); } -void TimeBasedPanel::PrevFrame() +void TimeBasedPanel::prev_frame() { - widget_->PrevFrame(); + widget_->prev_frame(); } -void TimeBasedPanel::NextFrame() +void TimeBasedPanel::next_frame() { - widget_->NextFrame(); + widget_->next_frame(); } -void TimeBasedPanel::GoToEnd() +void TimeBasedPanel::go_to_end() { - widget_->GoToEnd(); + widget_->go_to_end(); } -void TimeBasedPanel::ZoomIn() +void TimeBasedPanel::zoom_in() { - widget_->ZoomIn(); + widget_->zoom_in(); } -void TimeBasedPanel::ZoomOut() +void TimeBasedPanel::zoom_out() { - widget_->ZoomOut(); + widget_->zoom_out(); } -void TimeBasedPanel::SetTimebase(const rational &timebase) +void TimeBasedPanel::set_timebase(const Rational &timebase) { widget_->SetTimebase(timebase); } -void TimeBasedPanel::GoToPrevCut() +void TimeBasedPanel::go_to_prev_cut() { - widget_->GoToPrevCut(); + widget_->go_to_prev_cut(); } -void TimeBasedPanel::GoToNextCut() +void TimeBasedPanel::go_to_next_cut() { - widget_->GoToNextCut(); + widget_->go_to_next_cut(); } -void TimeBasedPanel::PlayPause() +void TimeBasedPanel::play_pause() { - emit PlayPauseRequested(); + emit play_pause_requested(); } -void TimeBasedPanel::PlayInToOut() +void TimeBasedPanel::play_in_to_out() { - emit PlayInToOutRequested(); + emit play_in_to_out_requested(); } -void TimeBasedPanel::ShuttleLeft() +void TimeBasedPanel::shuttle_left() { - emit ShuttleLeftRequested(); + emit shuttle_left_requested(); } -void TimeBasedPanel::ShuttleStop() +void TimeBasedPanel::shuttle_stop() { - emit ShuttleStopRequested(); + emit shuttle_stop_requested(); } -void TimeBasedPanel::ShuttleRight() +void TimeBasedPanel::shuttle_right() { - emit ShuttleRightRequested(); + emit shuttle_right_requested(); } -void TimeBasedPanel::ConnectViewerNode(ViewerOutput *node) +void TimeBasedPanel::connect_viewer_node(ViewerOutput *node) { - widget_->ConnectViewerNode(node); + widget_->connect_viewer_node(node); } -void TimeBasedPanel::SetTimeBasedWidget(TimeBasedWidget *widget) +void TimeBasedPanel::set_time_based_widget(TimeBasedWidget *widget) { if (widget_) { - disconnect(widget_, &TimeBasedWidget::ConnectedNodeChanged, this, - &TimeBasedPanel::ConnectedNodeChanged); + disconnect(widget_, &TimeBasedWidget::connected_node_changed, this, + &TimeBasedPanel::connected_node_changed); } widget_ = widget; if (widget_) { - connect(widget_, &TimeBasedWidget::ConnectedNodeChanged, this, - &TimeBasedPanel::ConnectedNodeChanged); + connect(widget_, &TimeBasedWidget::connected_node_changed, this, + &TimeBasedPanel::connected_node_changed); } - SetWidgetWithPadding(widget_); + set_widget_with_padding(widget_); } -void TimeBasedPanel::Retranslate() +void TimeBasedPanel::retranslate() { - if (GetTimeBasedWidget()->GetConnectedNode()) { - SetSubtitle(GetTimeBasedWidget()->GetConnectedNode()->GetLabel()); + if (get_time_based_widget()->get_connected_node()) { + set_subtitle(get_time_based_widget()->get_connected_node()->get_label()); } else { - SetSubtitle(tr("(none)")); + set_subtitle(tr("(none)")); } } -void TimeBasedPanel::ConnectedNodeChanged(ViewerOutput *old, ViewerOutput *now) +void TimeBasedPanel::connected_node_changed(ViewerOutput *old, ViewerOutput *now) { if (old) { - disconnect(old, &ViewerOutput::LabelChanged, this, - &TimeBasedPanel::SetSubtitle); + disconnect(old, &ViewerOutput::label_changed, this, + &TimeBasedPanel::set_subtitle); } if (now) { - connect(now, &ViewerOutput::LabelChanged, this, - &TimeBasedPanel::SetSubtitle); + connect(now, &ViewerOutput::label_changed, this, + &TimeBasedPanel::set_subtitle); if (show_and_raise_on_connect_) { this->show(); @@ -160,72 +160,72 @@ void TimeBasedPanel::ConnectedNodeChanged(ViewerOutput *old, ViewerOutput *now) } // Update strings - Retranslate(); + retranslate(); } -void TimeBasedPanel::SetIn() +void TimeBasedPanel::set_in() { - GetTimeBasedWidget()->SetInAtPlayhead(); + get_time_based_widget()->set_in_at_playhead(); } -void TimeBasedPanel::SetOut() +void TimeBasedPanel::set_out() { - GetTimeBasedWidget()->SetOutAtPlayhead(); + get_time_based_widget()->set_out_at_playhead(); } -void TimeBasedPanel::ResetIn() +void TimeBasedPanel::reset_in() { - GetTimeBasedWidget()->ResetIn(); + get_time_based_widget()->reset_in(); } -void TimeBasedPanel::ResetOut() +void TimeBasedPanel::reset_out() { - GetTimeBasedWidget()->ResetOut(); + get_time_based_widget()->reset_out(); } -void TimeBasedPanel::ClearInOut() +void TimeBasedPanel::clear_in_out() { - GetTimeBasedWidget()->ClearInOutPoints(); + get_time_based_widget()->clear_in_out_points(); } -void TimeBasedPanel::SetMarker() +void TimeBasedPanel::set_marker() { - GetTimeBasedWidget()->SetMarker(); + get_time_based_widget()->set_marker(); } -void TimeBasedPanel::ToggleShowAll() +void TimeBasedPanel::toggle_show_all() { - GetTimeBasedWidget()->ToggleShowAll(); + get_time_based_widget()->toggle_show_all(); } -void TimeBasedPanel::GoToIn() +void TimeBasedPanel::go_to_in() { - GetTimeBasedWidget()->GoToIn(); + get_time_based_widget()->go_to_in(); } -void TimeBasedPanel::GoToOut() +void TimeBasedPanel::go_to_out() { - GetTimeBasedWidget()->GoToOut(); + get_time_based_widget()->go_to_out(); } -void TimeBasedPanel::DeleteSelected() +void TimeBasedPanel::delete_selected() { - GetTimeBasedWidget()->DeleteSelected(); + get_time_based_widget()->delete_selected(); } -void TimeBasedPanel::CutSelected() +void TimeBasedPanel::cut_selected() { - GetTimeBasedWidget()->CopySelected(true); + get_time_based_widget()->copy_selected(true); } -void TimeBasedPanel::CopySelected() +void TimeBasedPanel::copy_selected() { - GetTimeBasedWidget()->CopySelected(false); + get_time_based_widget()->copy_selected(false); } -void TimeBasedPanel::Paste() +void TimeBasedPanel::paste() { - GetTimeBasedWidget()->Paste(); + get_time_based_widget()->paste(); } } diff --git a/app/panel/timebased/timebased.h b/app/panel/timebased/timebased.h index 36871a22e..4d3e4cdd6 100644 --- a/app/panel/timebased/timebased.h +++ b/app/panel/timebased/timebased.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMEBASEDPANEL_H -#define TIMEBASEDPANEL_H +#ifndef OAK_TIMEBASEDPANEL_H +#define OAK_TIMEBASEDPANEL_H #include "panel/panel.h" #include "widget/timebased/timebasedwidget.h" @@ -35,19 +35,19 @@ public: virtual ~TimeBasedPanel() override; - void ConnectViewerNode(ViewerOutput *node); + void connect_viewer_node(ViewerOutput *node); - void DisconnectViewerNode() + void disconnect_viewer_node() { - ConnectViewerNode(nullptr); + connect_viewer_node(nullptr); } // Get the timebase of this panels widget - const rational &timebase(); + const Rational &timebase(); - ViewerOutput *GetConnectedViewer() const + ViewerOutput *get_connected_viewer() const { - return widget_->GetConnectedNode(); + return widget_->get_connected_node(); } TimeRuler *ruler() const @@ -55,83 +55,83 @@ public: return widget_->ruler(); } - virtual void ZoomIn() override; + virtual void zoom_in() override; - virtual void ZoomOut() override; + virtual void zoom_out() override; - virtual void GoToStart() override; + virtual void go_to_start() override; - virtual void PrevFrame() override; + virtual void prev_frame() override; - virtual void NextFrame() override; + virtual void next_frame() override; - virtual void GoToEnd() override; + virtual void go_to_end() override; - virtual void GoToPrevCut() override; + virtual void go_to_prev_cut() override; - virtual void GoToNextCut() override; + virtual void go_to_next_cut() override; - virtual void PlayPause() override; + virtual void play_pause() override; - virtual void PlayInToOut() override; + virtual void play_in_to_out() override; - virtual void ShuttleLeft() override; + virtual void shuttle_left() override; - virtual void ShuttleStop() override; + virtual void shuttle_stop() override; - virtual void ShuttleRight() override; + virtual void shuttle_right() override; - virtual void SetIn() override; + virtual void set_in() override; - virtual void SetOut() override; + virtual void set_out() override; - virtual void ResetIn() override; + virtual void reset_in() override; - virtual void ResetOut() override; + virtual void reset_out() override; - virtual void ClearInOut() override; + virtual void clear_in_out() override; - virtual void SetMarker() override; + virtual void set_marker() override; - virtual void ToggleShowAll() override; + virtual void toggle_show_all() override; - virtual void GoToIn() override; + virtual void go_to_in() override; - virtual void GoToOut() override; + virtual void go_to_out() override; - virtual void DeleteSelected() override; + virtual void delete_selected() override; - virtual void CutSelected() override; + virtual void cut_selected() override; - virtual void CopySelected() override; + virtual void copy_selected() override; - virtual void Paste() override; + virtual void paste() override; - TimeBasedWidget *GetTimeBasedWidget() const + TimeBasedWidget *get_time_based_widget() const { return widget_; } public slots: - void SetTimebase(const rational &timebase); + void set_timebase(const Rational &timebase); signals: - void PlayPauseRequested(); + void play_pause_requested(); - void PlayInToOutRequested(); + void play_in_to_out_requested(); - void ShuttleLeftRequested(); + void shuttle_left_requested(); - void ShuttleStopRequested(); + void shuttle_stop_requested(); - void ShuttleRightRequested(); + void shuttle_right_requested(); protected: - void SetTimeBasedWidget(TimeBasedWidget *widget); + void set_time_based_widget(TimeBasedWidget *widget); - virtual void Retranslate() override; + virtual void retranslate() override; - void SetShowAndRaiseOnConnect() + void set_show_and_raise_on_connect() { show_and_raise_on_connect_ = true; } @@ -142,9 +142,9 @@ private: bool show_and_raise_on_connect_; private slots: - void ConnectedNodeChanged(ViewerOutput *old, ViewerOutput *now); + void connected_node_changed(ViewerOutput *old, ViewerOutput *now); }; } -#endif // TIMEBASEDPANEL_H +#endif // OAK_TIMEBASEDPANEL_H diff --git a/app/panel/timeline/timeline.cpp b/app/panel/timeline/timeline.cpp index 8d4a72240..919e8cbec 100644 --- a/app/panel/timeline/timeline.cpp +++ b/app/panel/timeline/timeline.cpp @@ -31,162 +31,162 @@ TimelinePanel::TimelinePanel(const QString &name) : TimeBasedPanel(name) { TimelineWidget *tw = new TimelineWidget(this); - SetTimeBasedWidget(tw); + set_time_based_widget(tw); - Retranslate(); + retranslate(); - connect(tw, &TimelineWidget::BlockSelectionChanged, this, - &TimelinePanel::BlockSelectionChanged); - connect(tw, &TimelineWidget::RequestCaptureStart, this, - &TimelinePanel::RequestCaptureStart); - connect(tw, &TimelineWidget::RevealViewerInProject, this, - &TimelinePanel::RevealViewerInProject); - connect(tw, &TimelineWidget::RevealViewerInFootageViewer, this, - &TimelinePanel::RevealViewerInFootageViewer); + connect(tw, &TimelineWidget::block_selection_changed, this, + &TimelinePanel::block_selection_changed); + connect(tw, &TimelineWidget::request_capture_start, this, + &TimelinePanel::request_capture_start); + connect(tw, &TimelineWidget::reveal_viewer_in_project, this, + &TimelinePanel::reveal_viewer_in_project); + connect(tw, &TimelineWidget::reveal_viewer_in_footage_viewer, this, + &TimelinePanel::reveal_viewer_in_footage_viewer); } -void TimelinePanel::SplitAtPlayhead() +void TimelinePanel::split_at_playhead() { - timeline_widget()->SplitAtPlayhead(); + timeline_widget()->split_at_playhead(); } -void TimelinePanel::LoadData(const Info &info) +void TimelinePanel::load_data(const Info &info) { - timeline_widget()->RestoreSplitterState( + timeline_widget()->restore_splitter_state( QByteArray::fromBase64(info.at("splitter").toUtf8())); } -PanelWidget::Info TimelinePanel::SaveData() const +PanelWidget::Info TimelinePanel::save_data() const { Info i; - i["splitter"] = timeline_widget()->SaveSplitterState().toBase64(); + i["splitter"] = timeline_widget()->save_splitter_state().toBase64(); return i; } -void TimelinePanel::SelectAll() +void TimelinePanel::select_all() { - timeline_widget()->SelectAll(); + timeline_widget()->select_all(); } -void TimelinePanel::DeselectAll() +void TimelinePanel::deselect_all() { - timeline_widget()->DeselectAll(); + timeline_widget()->deselect_all(); } -void TimelinePanel::RippleToIn() +void TimelinePanel::ripple_to_in() { - timeline_widget()->RippleToIn(); + timeline_widget()->ripple_to_in(); } -void TimelinePanel::RippleToOut() +void TimelinePanel::ripple_to_out() { - timeline_widget()->RippleToOut(); + timeline_widget()->ripple_to_out(); } -void TimelinePanel::EditToIn() +void TimelinePanel::edit_to_in() { - timeline_widget()->EditToIn(); + timeline_widget()->edit_to_in(); } -void TimelinePanel::EditToOut() +void TimelinePanel::edit_to_out() { - timeline_widget()->EditToOut(); + timeline_widget()->edit_to_out(); } -void TimelinePanel::DeleteSelected() +void TimelinePanel::delete_selected() { timeline_widget()->DeleteSelected(false); } -void TimelinePanel::RippleDelete() +void TimelinePanel::ripple_delete() { timeline_widget()->DeleteSelected(true); } -void TimelinePanel::IncreaseTrackHeight() +void TimelinePanel::increase_track_height() { - timeline_widget()->IncreaseTrackHeight(); + timeline_widget()->increase_track_height(); } -void TimelinePanel::DecreaseTrackHeight() +void TimelinePanel::decrease_track_height() { - timeline_widget()->DecreaseTrackHeight(); + timeline_widget()->decrease_track_height(); } -void TimelinePanel::ToggleLinks() +void TimelinePanel::toggle_links() { - timeline_widget()->ToggleLinksOnSelected(); + timeline_widget()->toggle_links_on_selected(); } -void TimelinePanel::PasteInsert() +void TimelinePanel::paste_insert() { - timeline_widget()->PasteInsert(); + timeline_widget()->paste_insert(); } -void TimelinePanel::DeleteInToOut() +void TimelinePanel::delete_in_to_out() { - timeline_widget()->DeleteInToOut(false); + timeline_widget()->delete_in_to_out(false); } -void TimelinePanel::RippleDeleteInToOut() +void TimelinePanel::ripple_delete_in_to_out() { - timeline_widget()->DeleteInToOut(true); + timeline_widget()->delete_in_to_out(true); } -void TimelinePanel::ToggleSelectedEnabled() +void TimelinePanel::toggle_selected_enabled() { - timeline_widget()->ToggleSelectedEnabled(); + timeline_widget()->toggle_selected_enabled(); } -void TimelinePanel::SetColorLabel(int index) +void TimelinePanel::set_color_label(int index) { - timeline_widget()->SetColorLabel(index); + timeline_widget()->set_color_label(index); } -void TimelinePanel::NudgeLeft() +void TimelinePanel::nudge_left() { - timeline_widget()->NudgeLeft(); + timeline_widget()->nudge_left(); } -void TimelinePanel::NudgeRight() +void TimelinePanel::nudge_right() { - timeline_widget()->NudgeRight(); + timeline_widget()->nudge_right(); } -void TimelinePanel::MoveInToPlayhead() +void TimelinePanel::move_in_to_playhead() { - timeline_widget()->MoveInToPlayhead(); + timeline_widget()->move_in_to_playhead(); } -void TimelinePanel::MoveOutToPlayhead() +void TimelinePanel::move_out_to_playhead() { - timeline_widget()->MoveOutToPlayhead(); + timeline_widget()->move_out_to_playhead(); } -void TimelinePanel::RenameSelected() +void TimelinePanel::rename_selected() { - timeline_widget()->RenameSelectedBlocks(); + timeline_widget()->rename_selected_blocks(); } -void TimelinePanel::InsertFootageAtPlayhead( +void TimelinePanel::insert_footage_at_playhead( const QVector &footage) { - timeline_widget()->InsertFootageAtPlayhead(footage); + timeline_widget()->insert_footage_at_playhead(footage); } -void TimelinePanel::OverwriteFootageAtPlayhead( +void TimelinePanel::overwrite_footage_at_playhead( const QVector &footage) { - timeline_widget()->OverwriteFootageAtPlayhead(footage); + timeline_widget()->overwrite_footage_at_playhead(footage); } -void TimelinePanel::Retranslate() +void TimelinePanel::retranslate() { - TimeBasedPanel::Retranslate(); + TimeBasedPanel::retranslate(); - SetTitle(tr("Timeline")); + set_title(tr("Timeline")); } } diff --git a/app/panel/timeline/timeline.h b/app/panel/timeline/timeline.h index 75383a0fc..a9f5dbbb4 100644 --- a/app/panel/timeline/timeline.h +++ b/app/panel/timeline/timeline.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINE_PANEL_H -#define TIMELINE_PANEL_H +#ifndef OAK_TIMELINE_PANEL_H +#define OAK_TIMELINE_PANEL_H #include "panel/timebased/timebased.h" #include "widget/timelinewidget/timelinewidget.h" @@ -38,98 +38,98 @@ public: inline TimelineWidget *timeline_widget() const { - return static_cast(GetTimeBasedWidget()); + return static_cast(get_time_based_widget()); } - void SplitAtPlayhead(); + void split_at_playhead(); - virtual void LoadData(const Info &info) override; - virtual Info SaveData() const override; + virtual void load_data(const Info &info) override; + virtual Info save_data() const override; - virtual void SelectAll() override; + virtual void select_all() override; - virtual void DeselectAll() override; + virtual void deselect_all() override; - virtual void RippleToIn() override; + virtual void ripple_to_in() override; - virtual void RippleToOut() override; + virtual void ripple_to_out() override; - virtual void EditToIn() override; + virtual void edit_to_in() override; - virtual void EditToOut() override; + virtual void edit_to_out() override; - virtual void DeleteSelected() override; + virtual void delete_selected() override; - virtual void RippleDelete() override; + virtual void ripple_delete() override; - virtual void IncreaseTrackHeight() override; + virtual void increase_track_height() override; - virtual void DecreaseTrackHeight() override; + virtual void decrease_track_height() override; - virtual void ToggleLinks() override; + virtual void toggle_links() override; - virtual void PasteInsert() override; + virtual void paste_insert() override; - virtual void DeleteInToOut() override; + virtual void delete_in_to_out() override; - virtual void RippleDeleteInToOut() override; + virtual void ripple_delete_in_to_out() override; - virtual void ToggleSelectedEnabled() override; + virtual void toggle_selected_enabled() override; - virtual void SetColorLabel(int index) override; + virtual void set_color_label(int index) override; - virtual void NudgeLeft() override; + virtual void nudge_left() override; - virtual void NudgeRight() override; + virtual void nudge_right() override; - virtual void MoveInToPlayhead() override; + virtual void move_in_to_playhead() override; - virtual void MoveOutToPlayhead() override; + virtual void move_out_to_playhead() override; - virtual void RenameSelected() override; + virtual void rename_selected() override; - void AddDefaultTransitionsToSelected() + void add_default_transitions_to_selected() { - timeline_widget()->AddDefaultTransitionsToSelected(); + timeline_widget()->add_default_transitions_to_selected(); } - void ShowSpeedDurationDialogForSelectedClips() + void show_speed_duration_dialog_for_selected_clips() { - timeline_widget()->ShowSpeedDurationDialogForSelectedClips(); + timeline_widget()->show_speed_duration_dialog_for_selected_clips(); } - void NestSelectedClips() + void nest_selected_clips() { - timeline_widget()->NestSelectedClips(); + timeline_widget()->nest_selected_clips(); } - void InsertFootageAtPlayhead(const QVector &footage); + void insert_footage_at_playhead(const QVector &footage); - void OverwriteFootageAtPlayhead(const QVector &footage); + void overwrite_footage_at_playhead(const QVector &footage); - const QVector &GetSelectedBlocks() const + const QVector &get_selected_blocks() const { - return timeline_widget()->GetSelectedBlocks(); + return timeline_widget()->get_selected_blocks(); } - Sequence *GetSequence() const + Sequence *get_sequence() const { - return dynamic_cast(GetConnectedViewer()); + return dynamic_cast(get_connected_viewer()); } protected: - virtual void Retranslate() override; + virtual void retranslate() override; signals: - void BlockSelectionChanged(const QVector &selected_blocks); + void block_selection_changed(const QVector &selected_blocks); - void RequestCaptureStart(const TimeRange &time, + void request_capture_start(const TimeRange &time, const Track::Reference &track); - void RevealViewerInProject(ViewerOutput *r); - void RevealViewerInFootageViewer(ViewerOutput *r, const TimeRange &range); + void reveal_viewer_in_project(ViewerOutput *r); + void reveal_viewer_in_footage_viewer(ViewerOutput *r, const TimeRange &range); }; } -#endif // TIMELINE_PANEL_H +#endif // OAK_TIMELINE_PANEL_H diff --git a/app/panel/tool/tool.cpp b/app/panel/tool/tool.cpp index d5592a898..c32503ed9 100644 --- a/app/panel/tool/tool.cpp +++ b/app/panel/tool/tool.cpp @@ -32,26 +32,26 @@ ToolPanel::ToolPanel() { Toolbar *t = new Toolbar(this); - t->SetTool(Core::instance()->tool()); - t->SetSnapping(Core::instance()->snapping()); + t->set_tool(Core::instance()->tool()); + t->set_snapping(Core::instance()->snapping()); - SetWidgetWithPadding(t); + set_widget_with_padding(t); - connect(t, &Toolbar::ToolChanged, Core::instance(), &Core::SetTool); - connect(Core::instance(), &Core::ToolChanged, t, &Toolbar::SetTool); + connect(t, &Toolbar::tool_changed, Core::instance(), &Core::set_tool); + connect(Core::instance(), &Core::tool_changed, t, &Toolbar::set_tool); - connect(t, &Toolbar::SnappingChanged, Core::instance(), &Core::SetSnapping); - connect(Core::instance(), &Core::SnappingChanged, t, &Toolbar::SetSnapping); + connect(t, &Toolbar::snapping_changed, Core::instance(), &Core::set_snapping); + connect(Core::instance(), &Core::snapping_changed, t, &Toolbar::set_snapping); - connect(t, &Toolbar::SelectedTransitionChanged, Core::instance(), - &Core::SetSelectedTransitionObject); + connect(t, &Toolbar::selected_transition_changed, Core::instance(), + &Core::set_selected_transition_object); - Retranslate(); + retranslate(); } -void ToolPanel::Retranslate() +void ToolPanel::retranslate() { - SetTitle(tr("Tools")); + set_title(tr("Tools")); } } diff --git a/app/panel/tool/tool.h b/app/panel/tool/tool.h index d2c18c669..38d505544 100644 --- a/app/panel/tool/tool.h +++ b/app/panel/tool/tool.h @@ -19,8 +19,8 @@ ***/ -#ifndef TOOL_PANEL_H -#define TOOL_PANEL_H +#ifndef OAK_TOOL_PANEL_H +#define OAK_TOOL_PANEL_H #include "panel/panel.h" @@ -36,9 +36,9 @@ public: ToolPanel(); private: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // TOOL_PANEL_H +#endif // OAK_TOOL_PANEL_H diff --git a/app/panel/viewer/viewer.cpp b/app/panel/viewer/viewer.cpp index 26654f921..f2fd29026 100644 --- a/app/panel/viewer/viewer.cpp +++ b/app/panel/viewer/viewer.cpp @@ -29,17 +29,17 @@ ViewerPanel::ViewerPanel(const QString &object_name) { // Set ViewerWidget as the central widget ViewerWidget *vw = new ViewerWidget(this); - SetViewerWidget(vw); + set_viewer_widget(vw); // Set strings - Retranslate(); + retranslate(); } -void ViewerPanel::Retranslate() +void ViewerPanel::retranslate() { - ViewerPanelBase::Retranslate(); + ViewerPanelBase::retranslate(); - SetTitle(tr("Viewer")); + set_title(tr("Viewer")); } } diff --git a/app/panel/viewer/viewer.h b/app/panel/viewer/viewer.h index 9a71f6a2a..1cf454e9e 100644 --- a/app/panel/viewer/viewer.h +++ b/app/panel/viewer/viewer.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWER_PANEL_H -#define VIEWER_PANEL_H +#ifndef OAK_VIEWER_PANEL_H +#define OAK_VIEWER_PANEL_H #include @@ -38,9 +38,9 @@ public: ViewerPanel(const QString &object_name); protected: - virtual void Retranslate() override; + virtual void retranslate() override; }; } -#endif // VIEWER_PANEL_H +#endif // OAK_VIEWER_PANEL_H diff --git a/app/panel/viewer/viewerbase.cpp b/app/panel/viewer/viewerbase.cpp index 85c0e6973..3e8c2dad1 100644 --- a/app/panel/viewer/viewerbase.cpp +++ b/app/panel/viewer/viewerbase.cpp @@ -31,101 +31,101 @@ namespace olive ViewerPanelBase::ViewerPanelBase(const QString &object_name) : super(object_name) { - connect(PanelManager::instance(), &PanelManager::FocusedPanelChanged, this, - &ViewerPanelBase::FocusedPanelChanged); + connect(PanelManager::instance(), &PanelManager::focused_panel_changed, this, + &ViewerPanelBase::focused_panel_changed); } -void ViewerPanelBase::PlayPause() +void ViewerPanelBase::play_pause() { - GetViewerWidget()->TogglePlayPause(); + get_viewer_widget()->toggle_play_pause(); } -void ViewerPanelBase::PlayInToOut() +void ViewerPanelBase::play_in_to_out() { - GetViewerWidget()->Play(true); + get_viewer_widget()->play(true); } -void ViewerPanelBase::ShuttleLeft() +void ViewerPanelBase::shuttle_left() { - GetViewerWidget()->ShuttleLeft(); + get_viewer_widget()->shuttle_left(); } -void ViewerPanelBase::ShuttleStop() +void ViewerPanelBase::shuttle_stop() { - GetViewerWidget()->ShuttleStop(); + get_viewer_widget()->shuttle_stop(); } -void ViewerPanelBase::ShuttleRight() +void ViewerPanelBase::shuttle_right() { - GetViewerWidget()->ShuttleRight(); + get_viewer_widget()->shuttle_right(); } -void ViewerPanelBase::ConnectTimeBasedPanel(TimeBasedPanel *panel) +void ViewerPanelBase::connect_time_based_panel(TimeBasedPanel *panel) { - connect(panel, &TimeBasedPanel::PlayPauseRequested, this, - &ViewerPanelBase::PlayPause); - connect(panel, &TimeBasedPanel::PlayInToOutRequested, this, - &ViewerPanelBase::PlayInToOut); - connect(panel, &TimeBasedPanel::ShuttleLeftRequested, this, - &ViewerPanelBase::ShuttleLeft); - connect(panel, &TimeBasedPanel::ShuttleStopRequested, this, - &ViewerPanelBase::ShuttleStop); - connect(panel, &TimeBasedPanel::ShuttleRightRequested, this, - &ViewerPanelBase::ShuttleRight); + connect(panel, &TimeBasedPanel::play_pause_requested, this, + &ViewerPanelBase::play_pause); + connect(panel, &TimeBasedPanel::play_in_to_out_requested, this, + &ViewerPanelBase::play_in_to_out); + connect(panel, &TimeBasedPanel::shuttle_left_requested, this, + &ViewerPanelBase::shuttle_left); + connect(panel, &TimeBasedPanel::shuttle_stop_requested, this, + &ViewerPanelBase::shuttle_stop); + connect(panel, &TimeBasedPanel::shuttle_right_requested, this, + &ViewerPanelBase::shuttle_right); } -void ViewerPanelBase::DisconnectTimeBasedPanel(TimeBasedPanel *panel) +void ViewerPanelBase::disconnect_time_based_panel(TimeBasedPanel *panel) { - disconnect(panel, &TimeBasedPanel::PlayPauseRequested, this, - &ViewerPanelBase::PlayPause); - disconnect(panel, &TimeBasedPanel::PlayInToOutRequested, this, - &ViewerPanelBase::PlayInToOut); - disconnect(panel, &TimeBasedPanel::ShuttleLeftRequested, this, - &ViewerPanelBase::ShuttleLeft); - disconnect(panel, &TimeBasedPanel::ShuttleStopRequested, this, - &ViewerPanelBase::ShuttleStop); - disconnect(panel, &TimeBasedPanel::ShuttleRightRequested, this, - &ViewerPanelBase::ShuttleRight); + disconnect(panel, &TimeBasedPanel::play_pause_requested, this, + &ViewerPanelBase::play_pause); + disconnect(panel, &TimeBasedPanel::play_in_to_out_requested, this, + &ViewerPanelBase::play_in_to_out); + disconnect(panel, &TimeBasedPanel::shuttle_left_requested, this, + &ViewerPanelBase::shuttle_left); + disconnect(panel, &TimeBasedPanel::shuttle_stop_requested, this, + &ViewerPanelBase::shuttle_stop); + disconnect(panel, &TimeBasedPanel::shuttle_right_requested, this, + &ViewerPanelBase::shuttle_right); } -void ViewerPanelBase::SetFullScreen(QScreen *screen) +void ViewerPanelBase::set_full_screen(QScreen *screen) { - GetViewerWidget()->SetFullScreen(screen); + get_viewer_widget()->set_full_screen(screen); } -void ViewerPanelBase::SetGizmos(Node *node) +void ViewerPanelBase::set_gizmos(Node *node) { - GetViewerWidget()->SetGizmos(node); + get_viewer_widget()->set_gizmos(node); } -void ViewerPanelBase::CacheEntireSequence() +void ViewerPanelBase::cache_entire_sequence() { - GetViewerWidget()->CacheEntireSequence(); + get_viewer_widget()->cache_entire_sequence(); } -void ViewerPanelBase::CacheSequenceInOut() +void ViewerPanelBase::cache_sequence_in_out() { - GetViewerWidget()->CacheSequenceInOut(); + get_viewer_widget()->cache_sequence_in_out(); } -void ViewerPanelBase::SetViewerWidget(ViewerWidget *vw) +void ViewerPanelBase::set_viewer_widget(ViewerWidget *vw) { - connect(vw, &ViewerWidget::TextureChanged, this, - &ViewerPanelBase::TextureChanged); - connect(vw, &ViewerWidget::ColorProcessorChanged, this, - &ViewerPanelBase::ColorProcessorChanged); - connect(vw, &ViewerWidget::ColorManagerChanged, this, - &ViewerPanelBase::ColorManagerChanged); + connect(vw, &ViewerWidget::texture_changed, this, + &ViewerPanelBase::texture_changed); + connect(vw, &ViewerWidget::color_processor_changed, this, + &ViewerPanelBase::color_processor_changed); + connect(vw, &ViewerWidget::color_manager_changed, this, + &ViewerPanelBase::color_manager_changed); - SetTimeBasedWidget(vw); + set_time_based_widget(vw); } -void ViewerPanelBase::FocusedPanelChanged(PanelWidget *panel) +void ViewerPanelBase::focused_panel_changed(PanelWidget *panel) { if (dynamic_cast(panel)) { - auto vw = GetViewerWidget(); - if (vw->IsPlaying() && panel != this) { - vw->Pause(); + auto vw = get_viewer_widget(); + if (vw->is_playing() && panel != this) { + vw->pause(); } } } diff --git a/app/panel/viewer/viewerbase.h b/app/panel/viewer/viewerbase.h index 24d5ab4df..e15e1cd4a 100644 --- a/app/panel/viewer/viewerbase.h +++ b/app/panel/viewer/viewerbase.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWERPANELBASE_H -#define VIEWERPANELBASE_H +#ifndef OAK_VIEWERPANELBASE_H +#define OAK_VIEWERPANELBASE_H #include "panel/pixelsampler/pixelsamplerpanel.h" #include "panel/timebased/timebased.h" @@ -34,95 +34,95 @@ class ViewerPanelBase : public TimeBasedPanel { public: ViewerPanelBase(const QString &object_name); - ViewerWidget *GetViewerWidget() const + ViewerWidget *get_viewer_widget() const { - return static_cast(GetTimeBasedWidget()); + return static_cast(get_time_based_widget()); } - virtual void PlayPause() override; + virtual void play_pause() override; - virtual void PlayInToOut() override; + virtual void play_in_to_out() override; - virtual void ShuttleLeft() override; + virtual void shuttle_left() override; - virtual void ShuttleStop() override; + virtual void shuttle_stop() override; - virtual void ShuttleRight() override; + virtual void shuttle_right() override; - void ConnectTimeBasedPanel(TimeBasedPanel *panel); + void connect_time_based_panel(TimeBasedPanel *panel); - void DisconnectTimeBasedPanel(TimeBasedPanel *panel); + void disconnect_time_based_panel(TimeBasedPanel *panel); /** * @brief Wrapper for ViewerWidget::SetFullScreen() */ - void SetFullScreen(QScreen *screen = nullptr); + void set_full_screen(QScreen *screen = nullptr); - ColorManager *GetColorManager() + ColorManager *get_color_manager() { - return GetViewerWidget()->color_manager(); + return get_viewer_widget()->color_manager(); } - void UpdateTextureFromNode() + void update_texture_from_node() { - GetViewerWidget()->UpdateTextureFromNode(); + get_viewer_widget()->update_texture_from_node(); } - void AddPlaybackDevice(ViewerDisplayWidget *vw) + void add_playback_device(ViewerDisplayWidget *vw) { - GetViewerWidget()->AddPlaybackDevice(vw); + get_viewer_widget()->add_playback_device(vw); } - void SetTimelineSelectedBlocks(const QVector &b) + void set_timeline_selected_blocks(const QVector &b) { - GetViewerWidget()->SetTimelineSelectedBlocks(b); + get_viewer_widget()->set_timeline_selected_blocks(b); } - void SetNodeViewSelections(const QVector &n) + void set_node_view_selections(const QVector &n) { - GetViewerWidget()->SetNodeViewSelections(n); + get_viewer_widget()->set_node_view_selections(n); } - void ConnectMulticamWidget(MulticamWidget *p) + void connect_multicam_widget(MulticamWidget *p) { - GetViewerWidget()->ConnectMulticamWidget(p); + get_viewer_widget()->connect_multicam_widget(p); } public slots: - void SetGizmos(Node *node); + void set_gizmos(Node *node); - void CacheEntireSequence(); + void cache_entire_sequence(); - void CacheSequenceInOut(); + void cache_sequence_in_out(); - void RequestStartEditingText() + void request_start_editing_text() { - GetViewerWidget()->RequestStartEditingText(); + get_viewer_widget()->request_start_editing_text(); } signals: /** * @brief Signal emitted when a new frame is loaded */ - void TextureChanged(TexturePtr t); + void texture_changed(TexturePtr t); /** * @brief Wrapper for ViewerGLWidget::ColorProcessorChanged() */ - void ColorProcessorChanged(ColorProcessorPtr processor); + void color_processor_changed(ColorProcessorPtr processor); /** * @brief Wrapper for ViewerGLWidget::ColorManagerChanged() */ - void ColorManagerChanged(ColorManager *color_manager); + void color_manager_changed(ColorManager *color_manager); protected: - void SetViewerWidget(ViewerWidget *vw); + void set_viewer_widget(ViewerWidget *vw); private slots: - void FocusedPanelChanged(PanelWidget *panel); + void focused_panel_changed(PanelWidget *panel); }; } -#endif // VIEWERPANELBASE_H +#endif // OAK_VIEWERPANELBASE_H diff --git a/app/pluginSupport/CMakeLists.txt b/app/pluginSupport/CMakeLists.txt index ce057b228..c2f67121a 100644 --- a/app/pluginSupport/CMakeLists.txt +++ b/app/pluginSupport/CMakeLists.txt @@ -1,10 +1,10 @@ target_sources(libolive-editor PRIVATE - OliveHost.h - OliveHost.cpp - OlivePluginInstance.h - OlivePluginInstance.cpp - OliveClip.cpp - OliveClip.h + olivehost.h + olivehost.cpp + oliveplugininstance.h + oliveplugininstance.cpp + oliveclip.cpp + oliveclip.h paraminstance.cpp paraminstance.h image.cpp diff --git a/app/pluginSupport/image.cpp b/app/pluginSupport/image.cpp index 0d55b7352..a6a2cd218 100644 --- a/app/pluginSupport/image.cpp +++ b/app/pluginSupport/image.cpp @@ -28,26 +28,26 @@ namespace olive namespace plugin { -static const char *PixelDepthToOfx(core::PixelFormat format) +static const char *pixel_depth_to_ofx(core::PixelFormat format) { switch (format) { - case core::PixelFormat::U8: + case core::PixelFormat::u8: return kOfxBitDepthByte; - case core::PixelFormat::U16: + case core::PixelFormat::u16: return kOfxBitDepthShort; - case core::PixelFormat::F16: + case core::PixelFormat::f16: return kOfxBitDepthHalf; - case core::PixelFormat::F32: + case core::PixelFormat::f32: return kOfxBitDepthFloat; - case core::PixelFormat::INVALID: - case core::PixelFormat::COUNT: + case core::PixelFormat::invalid: + case core::PixelFormat::count: break; } return kOfxBitDepthNone; } -static const char *ComponentsToOfx(int channel_count) +static const char *components_to_ofx(int channel_count) { switch (channel_count) { case 1: @@ -67,7 +67,7 @@ Image::Image(OFX::Host::ImageEffect::ClipInstance &clip_instance) : OFX::Host::ImageEffect::Image(clip_instance) , width_(0) , height_(0) - , format_(core::PixelFormat::INVALID) + , format_(core::PixelFormat::invalid) , premultiplied_alpha_(false) , channel_count_(0) , row_bytes_(0) @@ -82,30 +82,30 @@ Image::Image(OFX::Host::ImageEffect::ClipInstance &clip_instance, : OFX::Host::ImageEffect::Image(clip_instance) , width_(0) , height_(0) - , format_(core::PixelFormat::INVALID) + , format_(core::PixelFormat::invalid) , premultiplied_alpha_(false) , channel_count_(0) , row_bytes_(0) , bounds_{ 0, 0, 0, 0 } , rod_{ 0, 0, 0, 0 } { - AllocateFromParams(params, bounds, rod, clear); + allocate_from_params(params, bounds, rod, clear); } Image::~Image() { } -void Image::AllocateFromParams(const VideoParams ¶ms, +void Image::allocate_from_params(const VideoParams ¶ms, const OfxRectI &bounds, const OfxRectI &rod, bool clear) { - Allocate(bounds.x2 - bounds.x1, bounds.y2 - bounds.y1, params.format(), + allocate(bounds.x2 - bounds.x1, bounds.y2 - bounds.y1, params.format(), params.channel_count(), params.premultiplied_alpha(), bounds, rod, clear); } -void Image::EnsureAllocatedFromParams(const VideoParams ¶ms, +void Image::ensure_allocated_from_params(const VideoParams ¶ms, const OfxRectI &bounds, const OfxRectI &rod, bool clear) { @@ -120,13 +120,13 @@ void Image::EnsureAllocatedFromParams(const VideoParams ¶ms, (rod_.x2 == rod.x2) && (rod_.y2 == rod.y2); if (!same) { - AllocateFromParams(params, bounds, rod, clear); + allocate_from_params(params, bounds, rod, clear); } else if (clear && !image_.empty()) { std::fill(image_.begin(), image_.end(), 0); } } -void Image::Allocate(int width, int height, core::PixelFormat format, +void Image::allocate(int width, int height, core::PixelFormat format, int channel_count, bool premultiplied_alpha, const OfxRectI &bounds, const OfxRectI &rod, bool clear) { @@ -161,8 +161,8 @@ void Image::Allocate(int width, int height, core::PixelFormat format, setIntProperty(kOfxImagePropRegionOfDefinition, rod.x2, 2); setIntProperty(kOfxImagePropRegionOfDefinition, rod.y2, 3); setStringProperty(kOfxImageEffectPropComponents, - ComponentsToOfx(channel_count_)); - setStringProperty(kOfxImageEffectPropPixelDepth, PixelDepthToOfx(format_)); + components_to_ofx(channel_count_)); + setStringProperty(kOfxImageEffectPropPixelDepth, pixel_depth_to_ofx(format_)); setStringProperty(kOfxImageEffectPropPreMultiplication, premultiplied_alpha_ ? kOfxImagePreMultiplied : kOfxImageUnPreMultiplied); @@ -170,21 +170,21 @@ void Image::Allocate(int width, int height, core::PixelFormat format, core::PixelFormat Image::pixel_format() { - if (format_ != core::PixelFormat::INVALID) { + if (format_ != core::PixelFormat::invalid) { return format_; } std::string type = getStringProperty(kOfxImageEffectPropPixelDepth); if (type == kOfxBitDepthByte) { - format_ = core::PixelFormat::U8; + format_ = core::PixelFormat::u8; } else if (type == kOfxBitDepthShort) { - format_ = core::PixelFormat::U16; + format_ = core::PixelFormat::u16; } else if (type == kOfxBitDepthHalf) { - format_ = core::PixelFormat::F16; + format_ = core::PixelFormat::f16; } else if (type == kOfxBitDepthFloat) { - format_ = core::PixelFormat::F32; + format_ = core::PixelFormat::f32; } else { - format_ = core::PixelFormat::INVALID; + format_ = core::PixelFormat::invalid; } return format_; } diff --git a/app/pluginSupport/image.h b/app/pluginSupport/image.h index c210c1aa0..69b472e30 100644 --- a/app/pluginSupport/image.h +++ b/app/pluginSupport/image.h @@ -17,8 +17,8 @@ * */ -#ifndef OLIVE_EDITOR_PLUGIN_IMAGE_H -#define OLIVE_EDITOR_PLUGIN_IMAGE_H +#ifndef OAK_OLIVE_EDITOR_PLUGIN_IMAGE_H +#define OAK_OLIVE_EDITOR_PLUGIN_IMAGE_H #include "ofxCore.h" #include "ofxImageEffect.h" @@ -50,12 +50,12 @@ public: bool premultiplied_alpha(); int channel_count(); - void AllocateFromParams(const VideoParams ¶ms, const OfxRectI &bounds, + void allocate_from_params(const VideoParams ¶ms, const OfxRectI &bounds, const OfxRectI &rod, bool clear = true); - void EnsureAllocatedFromParams(const VideoParams ¶ms, + void ensure_allocated_from_params(const VideoParams ¶ms, const OfxRectI &bounds, const OfxRectI &rod, bool clear = false); - void Allocate(int width, int height, core::PixelFormat format, + void allocate(int width, int height, core::PixelFormat format, int channel_count, bool premultiplied_alpha, const OfxRectI &bounds, const OfxRectI &rod, bool clear = true); @@ -78,4 +78,4 @@ protected: } } -#endif //OLIVE_EDITOR_PLUGIN_IMAGE_H +#endif //OAK_OLIVE_EDITOR_PLUGIN_IMAGE_H diff --git a/app/pluginSupport/OliveClip.cpp b/app/pluginSupport/oliveclip.cpp similarity index 76% rename from app/pluginSupport/OliveClip.cpp rename to app/pluginSupport/oliveclip.cpp index 78079dec7..5e5c11450 100644 --- a/app/pluginSupport/OliveClip.cpp +++ b/app/pluginSupport/oliveclip.cpp @@ -21,9 +21,9 @@ // Created by mikesolar on 25-10-1. // -#include "OliveClip.h" +#include "oliveclip.h" -#include "common/Current.h" +#include "common/current.h" #include "common/ffmpegutils.h" #include "ofxCore.h" #include "ofxhClip.h" @@ -43,26 +43,26 @@ namespace // The bridge header only defines the little-endian pixel formats. FFmpeg // numbers each big-endian variant immediately before its little-endian // counterpart (BE == LE - 1), so derive the BE constants used below. -constexpr int FB_PIX_FMT_GRAYF32BE = FB_PIX_FMT_GRAYF32LE - 1; -constexpr int FB_PIX_FMT_RGBF32BE = FB_PIX_FMT_RGBF32LE - 1; -constexpr int FB_PIX_FMT_RGBAF32BE = FB_PIX_FMT_RGBAF32LE - 1; +constexpr int fb_pix_fmt_gray_f32_be = fb_pix_fmt_gray_f32_le - 1; +constexpr int fb_pix_fmt_rgb_f32_be = fb_pix_fmt_rgb_f32_le - 1; +constexpr int fb_pix_fmt_rgba_f32_be = fb_pix_fmt_rgba_f32_le - 1; -const std::string kBitDepthNoneStr(kOfxBitDepthNone); -const std::string kBitDepthByteStr(kOfxBitDepthByte); -const std::string kBitDepthShortStr(kOfxBitDepthShort); -const std::string kBitDepthHalfStr(kOfxBitDepthHalf); -const std::string kBitDepthFloatStr(kOfxBitDepthFloat); -const std::string kImageComponentNoneStr(kOfxImageComponentNone); -const std::string kImageComponentAlphaStr(kOfxImageComponentAlpha); -const std::string kImageComponentRGBStr(kOfxImageComponentRGB); -const std::string kImageComponentRGBAStr(kOfxImageComponentRGBA); -const std::string kImagePremultStr(kOfxImagePreMultiplied); -const std::string kImageUnPremultStr(kOfxImageUnPreMultiplied); -const std::string kImageFieldNoneStr(kOfxImageFieldNone); -const std::string kImageFieldUpperStr(kOfxImageFieldUpper); -const std::string kImageFieldLowerStr(kOfxImageFieldLower); +const std::string k_bit_depth_none_str(kOfxBitDepthNone); +const std::string k_bit_depth_byte_str(kOfxBitDepthByte); +const std::string k_bit_depth_short_str(kOfxBitDepthShort); +const std::string k_bit_depth_half_str(kOfxBitDepthHalf); +const std::string k_bit_depth_float_str(kOfxBitDepthFloat); +const std::string k_image_component_none_str(kOfxImageComponentNone); +const std::string k_image_component_alpha_str(kOfxImageComponentAlpha); +const std::string k_image_component_rgb_str(kOfxImageComponentRGB); +const std::string k_image_component_rgba_str(kOfxImageComponentRGBA); +const std::string k_image_premult_str(kOfxImagePreMultiplied); +const std::string k_image_un_premult_str(kOfxImageUnPreMultiplied); +const std::string k_image_field_none_str(kOfxImageFieldNone); +const std::string k_image_field_upper_str(kOfxImageFieldUpper); +const std::string k_image_field_lower_str(kOfxImageFieldLower); -static int BytesToPixels(int byte_linesize, const olive::VideoParams ¶ms) +static int bytes_to_pixels(int byte_linesize, const olive::VideoParams ¶ms) { const int bytes_per_pixel = params.channel_count() * params.format().byte_count(); @@ -72,48 +72,48 @@ static int BytesToPixels(int byte_linesize, const olive::VideoParams ¶ms) return byte_linesize / bytes_per_pixel; } -static int PackedFloatChannels(int fmt) +static int packed_float_channels(int fmt) { switch (fmt) { - case FB_PIX_FMT_GRAYF32LE: - case FB_PIX_FMT_GRAYF32BE: + case fb_pix_fmt_gray_f32_le: + case fb_pix_fmt_gray_f32_be: return 1; - case FB_PIX_FMT_RGBF32LE: - case FB_PIX_FMT_RGBF32BE: + case fb_pix_fmt_rgb_f32_le: + case fb_pix_fmt_rgb_f32_be: return 3; - case FB_PIX_FMT_RGBAF32LE: - case FB_PIX_FMT_RGBAF32BE: + case fb_pix_fmt_rgba_f32_le: + case fb_pix_fmt_rgba_f32_be: return 4; default: return 0; } } -static bool PackedDstInfo(int fmt, int *channels, +static bool packed_dst_info(int fmt, int *channels, int *bytes_per_component) { switch (fmt) { - case FB_PIX_FMT_GRAY8: + case fb_pix_fmt_gra_y8: *channels = 1; *bytes_per_component = 1; return true; - case FB_PIX_FMT_RGB24: + case fb_pix_fmt_rg_b24: *channels = 3; *bytes_per_component = 1; return true; - case FB_PIX_FMT_RGBA: + case fb_pix_fmt_rgba: *channels = 4; *bytes_per_component = 1; return true; - case FB_PIX_FMT_GRAY16LE: + case fb_pix_fmt_gra_y16_le: *channels = 1; *bytes_per_component = 2; return true; - case FB_PIX_FMT_RGB48LE: + case fb_pix_fmt_rg_b48_le: *channels = 3; *bytes_per_component = 2; return true; - case FB_PIX_FMT_RGBA64LE: + case fb_pix_fmt_rgb_a64_le: *channels = 4; *bytes_per_component = 2; return true; @@ -123,40 +123,40 @@ static bool PackedDstInfo(int fmt, int *channels, } static olive::AVFramePtr -ReadbackTextureToFrame(olive::TexturePtr texture, +readback_texture_to_frame(olive::TexturePtr texture, const olive::VideoParams ¶ms) { - if (!texture || texture->IsDummy() || !texture->renderer()) { + if (!texture || texture->is_dummy() || !texture->renderer()) { return nullptr; } - int pix_fmt = olive::FFmpegUtils::GetFFmpegPixelFormat( + int pix_fmt = olive::FFmpegUtils::get_f_fmpeg_pixel_format( params.format(), params.channel_count()); - if (pix_fmt == FB_PIX_FMT_NONE) { + if (pix_fmt == fb_pix_fmt_none) { return nullptr; } if (!fb_pix_fmt_is_planar(pix_fmt)) { - olive::AVFramePtr frame = olive::CreateAVFramePtr(); + olive::AVFramePtr frame = olive::create_av_frame_ptr(); frame->set_format(pix_fmt); frame->set_width(params.width()); frame->set_height(params.height()); if (frame->get_buffer(0) < 0) { return nullptr; } - const int linesize_pixels = BytesToPixels(frame->linesize(0), params); - texture->renderer()->DownloadFromTexture( + const int linesize_pixels = bytes_to_pixels(frame->linesize(0), params); + texture->renderer()->download_from_texture( texture->id(), params, frame->data(0), linesize_pixels); return frame; } olive::VideoParams rgba_params(params.width(), params.height(), - olive::core::PixelFormat::U8, 4, + olive::core::PixelFormat::u8, 4, params.pixel_aspect_ratio(), params.interlacing(), params.divider()); - olive::AVFramePtr rgba_frame = olive::CreateAVFramePtr(); - rgba_frame->set_format(FB_PIX_FMT_RGBA); + olive::AVFramePtr rgba_frame = olive::create_av_frame_ptr(); + rgba_frame->set_format(fb_pix_fmt_rgba); rgba_frame->set_width(params.width()); rgba_frame->set_height(params.height()); if (rgba_frame->get_buffer(0) < 0) { @@ -164,11 +164,11 @@ ReadbackTextureToFrame(olive::TexturePtr texture, } const int linesize_pixels = - BytesToPixels(rgba_frame->linesize(0), rgba_params); - texture->renderer()->DownloadFromTexture( + bytes_to_pixels(rgba_frame->linesize(0), rgba_params); + texture->renderer()->download_from_texture( texture->id(), rgba_params, rgba_frame->data(0), linesize_pixels); - olive::AVFramePtr dst = olive::CreateAVFramePtr(); + olive::AVFramePtr dst = olive::create_av_frame_ptr(); dst->set_format(pix_fmt); dst->set_width(params.width()); dst->set_height(params.height()); @@ -199,25 +199,25 @@ ReadbackTextureToFrame(olive::TexturePtr texture, return dst; } -static olive::AVFramePtr ConvertPackedFloatFrame(olive::AVFramePtr src, +static olive::AVFramePtr convert_packed_float_frame(olive::AVFramePtr src, int dst_fmt) { if (!src || !src->data(0)) { return nullptr; } const int src_channels = - PackedFloatChannels(src->format()); + packed_float_channels(src->format()); if (src_channels == 0) { return nullptr; } int dst_channels = 0; int bytes_per_component = 0; - if (!PackedDstInfo(dst_fmt, &dst_channels, &bytes_per_component)) { + if (!packed_dst_info(dst_fmt, &dst_channels, &bytes_per_component)) { return nullptr; } - olive::AVFramePtr dst = olive::CreateAVFramePtr(); + olive::AVFramePtr dst = olive::create_av_frame_ptr(); dst->set_format(dst_fmt); dst->set_width(src->width()); dst->set_height(src->height()); @@ -293,25 +293,25 @@ const std::string &olive::plugin::OliveClipInstance::getUnmappedBitDepth() const // Return the plugin's preferred pixel depth from base class // This is set during getClipPreferences action via setPixelDepth() const std::string &depth = getPixelDepth(); - if (!depth.empty() && depth != kBitDepthNoneStr) { + if (!depth.empty() && depth != k_bit_depth_none_str) { return depth; } // Fallback to params_ if base class value is not set switch (params_.format()) { - case PixelFormat::INVALID: - return kBitDepthNoneStr; - case PixelFormat::U8: - return kBitDepthByteStr; - case PixelFormat::U10: - return kBitDepthNoneStr; - case PixelFormat::U16: - return kBitDepthShortStr; - case PixelFormat::F16: - return kBitDepthHalfStr; - case PixelFormat::F32: - return kBitDepthFloatStr; + case PixelFormat::invalid: + return k_bit_depth_none_str; + case PixelFormat::u8: + return k_bit_depth_byte_str; + case PixelFormat::u10: + return k_bit_depth_none_str; + case PixelFormat::u16: + return k_bit_depth_short_str; + case PixelFormat::f16: + return k_bit_depth_half_str; + case PixelFormat::f32: + return k_bit_depth_float_str; default: - return kBitDepthNoneStr; + return k_bit_depth_none_str; } } const std::string & @@ -320,32 +320,32 @@ olive::plugin::OliveClipInstance::getUnmappedComponents() const // Return the plugin's preferred components from base class // This is set during getClipPreferences action via setComponents() const std::string &comp = getComponents(); - if (!comp.empty() && comp != kImageComponentNoneStr) { + if (!comp.empty() && comp != k_image_component_none_str) { return comp; } // Fallback to params_ if base class value is not set switch (params_.channel_count()) { case 1: - return kImageComponentAlphaStr; + return k_image_component_alpha_str; case 3: - return kImageComponentRGBStr; + return k_image_component_rgb_str; case 4: - return kImageComponentRGBAStr; + return k_image_component_rgba_str; default: - return kImageComponentNoneStr; + return k_image_component_none_str; } } const std::string &olive::plugin::OliveClipInstance::getPremult() const { if (params_.premultiplied_alpha()) { - return kImagePremultStr; + return k_image_premult_str; } else { - return kImageUnPremultStr; + return k_image_un_premult_str; } } double olive::plugin::OliveClipInstance::getAspectRatio() const { - double par = params_.pixel_aspect_ratio().toDouble(); + double par = params_.pixel_aspect_ratio().to_double(); if (par == 0.0) { return 1.0; // default PAR when not explicitly set } @@ -353,26 +353,26 @@ double olive::plugin::OliveClipInstance::getAspectRatio() const } double olive::plugin::OliveClipInstance::getFrameRate() const { - return params_.frame_rate().toDouble(); + return params_.frame_rate().to_double(); } -void olive::plugin::OliveClipInstance::getFrameRange(double &startFrame, - double &endFrame) const +void olive::plugin::OliveClipInstance::getFrameRange(double &start_frame, + double &end_frame) const { - startFrame = params_.frame_rate().toDouble() * params_.start_time(); - endFrame = - startFrame + params_.frame_rate().toDouble() * params_.duration(); + start_frame = params_.frame_rate().to_double() * params_.start_time(); + end_frame = + start_frame + params_.frame_rate().to_double() * params_.duration(); } const std::string &olive::plugin::OliveClipInstance::getFieldOrder() const { switch (params_.interlacing()) { - case VideoParams::kInterlaceNone: - return kImageFieldNoneStr; - case VideoParams::kInterlacedTopFirst: - return kImageFieldUpperStr; - case VideoParams::kInterlacedBottomFirst: - return kImageFieldLowerStr; + case VideoParams::k_interlace_none: + return k_image_field_none_str; + case VideoParams::k_interlaced_top_first: + return k_image_field_upper_str; + case VideoParams::k_interlaced_bottom_first: + return k_image_field_lower_str; } - return kImageFieldNoneStr; + return k_image_field_none_str; } bool olive::plugin::OliveClipInstance::getConnected() const { @@ -400,9 +400,9 @@ double olive::plugin::OliveClipInstance::getUnmappedFrameRate() const return getFrameRate(); } void olive::plugin::OliveClipInstance::getUnmappedFrameRange( - double &startFrame, double &endFrame) const + double &start_frame, double &end_frame) const { - getFrameRange(startFrame, endFrame); + getFrameRange(start_frame, end_frame); } bool olive::plugin::OliveClipInstance::getContinuousSamples() const { @@ -410,14 +410,14 @@ bool olive::plugin::OliveClipInstance::getContinuousSamples() const } OFX::Host::ImageEffect::Image * olive::plugin::OliveClipInstance::getImage(OfxTime time, - const OfxRectD *optionalBounds) + const OfxRectD *optional_bounds) { OfxRectD rod_d = getRegionOfDefinition(time); OfxRectI rod = { static_cast(std::floor(rod_d.x1)), static_cast(std::floor(rod_d.y1)), static_cast(std::ceil(rod_d.x2)), static_cast(std::ceil(rod_d.y2)) }; - (void)optionalBounds; + (void)optional_bounds; // Always return full-frame images to keep input data consistent. OfxRectI bounds = rod; @@ -435,14 +435,14 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time, // when it releases the image images_[time]->addReference(); - images_[time]->EnsureAllocatedFromParams(params_, bounds, rod, true); + images_[time]->ensure_allocated_from_params(params_, bounds, rod, true); // return it return images_[time]; } else { if (images_.contains(time)) { Image *image = images_.value(time); - image->EnsureAllocatedFromParams(params_, bounds, rod, false); + image->ensure_allocated_from_params(params_, bounds, rod, false); image->addReference(); return image; } @@ -451,7 +451,7 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time, // Use plugin-preferred params to ensure the image format matches // what the plugin expects (may differ from input texture format) VideoParams preferred_params = getPluginPreferredParams(); - if (preferred_params.format() == core::PixelFormat::INVALID) { + if (preferred_params.format() == core::PixelFormat::invalid) { preferred_params = params_; } // Keep dimensions and other settings from params_ @@ -462,7 +462,7 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time, // Guard against zero-size or invalid-format images that would // cause EXC_BAD_ACCESS when the plugin accesses pixel data. if (preferred_params.width() <= 0 || preferred_params.height() <= 0 || - preferred_params.format() == core::PixelFormat::INVALID || + preferred_params.format() == core::PixelFormat::invalid || preferred_params.channel_count() <= 0) { return nullptr; } @@ -471,7 +471,7 @@ olive::plugin::OliveClipInstance::getImage(OfxTime time, // fetches at the same time reuse it and getConnected() reflects it. // The extra reference keeps the cached image alive when the plugin // releases its own. - pruneImagesCache(); + prune_images_cache(); Image *image = new Image(*this, preferred_params, bounds, rod, true); images_.insert(time, image); image->addReference(); @@ -496,7 +496,7 @@ olive::plugin::OliveClipInstance::getOutputImage(OfxTime time) // Use plugin-preferred params instead of params_ to ensure the image // is created with the format the plugin expects VideoParams preferred_params = getPluginPreferredParams(); - if (preferred_params.format() == core::PixelFormat::INVALID) { + if (preferred_params.format() == core::PixelFormat::invalid) { preferred_params = params_; } // Keep the dimensions and other settings from params_ @@ -518,13 +518,13 @@ olive::plugin::OliveClipInstance::getPluginPreferredParams() const const std::string &depth = getPixelDepth(); if (!depth.empty()) { if (depth == kOfxBitDepthByte) { - result.set_format(core::PixelFormat::U8); + result.set_format(core::PixelFormat::u8); } else if (depth == kOfxBitDepthShort) { - result.set_format(core::PixelFormat::U16); + result.set_format(core::PixelFormat::u16); } else if (depth == kOfxBitDepthHalf) { - result.set_format(core::PixelFormat::F16); + result.set_format(core::PixelFormat::f16); } else if (depth == kOfxBitDepthFloat) { - result.set_format(core::PixelFormat::F32); + result.set_format(core::PixelFormat::f32); } } @@ -548,38 +548,38 @@ olive::plugin::OliveClipInstance::getRegionOfDefinition(OfxTime time) const if (regionOfDefinitions_.contains(time)) { return regionOfDefinitions_.value(time); } - OfxRectD regionOfDefinition; - regionOfDefinition.x1 = regionOfDefinition.y1 = 0; - double par = params_.pixel_aspect_ratio().toDouble(); - regionOfDefinition.x2 = params_.width() * par; - regionOfDefinition.y2 = params_.height(); - if (regionOfDefinition.x2 <= 0 || regionOfDefinition.y2 <= 0) { + OfxRectD region_of_definition; + region_of_definition.x1 = region_of_definition.y1 = 0; + double par = params_.pixel_aspect_ratio().to_double(); + region_of_definition.x2 = params_.width() * par; + region_of_definition.y2 = params_.height(); + if (region_of_definition.x2 <= 0 || region_of_definition.y2 <= 0) { // The params provide no usable region; fall back to the default set // via setDefaultRegionOfDefinition(). return defaultRegionOfDefinitions_; } - return regionOfDefinition; + return region_of_definition; } void olive::plugin::OliveClipInstance::setRegionOfDefinition( - OfxRectD regionOfDefinition, OfxTime time) + OfxRectD region_of_definition, OfxTime time) { - regionOfDefinitions_[time] = regionOfDefinition; + regionOfDefinitions_[time] = region_of_definition; } void olive::plugin::OliveClipInstance::setDefaultRegionOfDefinition( - OfxRectD regionOfDefinition) + OfxRectD region_of_definition) { - defaultRegionOfDefinitions_ = regionOfDefinition; + defaultRegionOfDefinitions_ = region_of_definition; } -void olive::plugin::OliveClipInstance::pruneImagesCache() +void olive::plugin::OliveClipInstance::prune_images_cache() { // Do not prune output clip images; they may have external references // added by getImage()/addReference() and are typically single-frame. if (name_ == kOfxImageEffectOutputClipName) { return; } - while (images_.size() > kMaxInputImageCache) { + while (images_.size() > k_max_input_image_cache) { auto it = images_.begin(); Image *img = it.value(); images_.erase(it); @@ -608,8 +608,8 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, // The frame rate of an OFX clip should reflect the project's frame rate, // not the individual input texture's frame rate. If different inputs // have different frame rates, setupClipPreferencesArgs throws an exception. - rational saved_frame_rate = params_.frame_rate(); - rational saved_time_base = params_.time_base(); + Rational saved_frame_rate = params_.frame_rate(); + Rational saved_time_base = params_.time_base(); this->params_ = incoming; @@ -634,16 +634,16 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, AVFramePtr frame = texture->frame(); if (!frame || !frame->data(0)) { - frame = ReadbackTextureToFrame(texture, params_); + frame = readback_texture_to_frame(texture, params_); } - int expected_fmt = FFmpegUtils::GetFFmpegPixelFormat( + int expected_fmt = FFmpegUtils::get_f_fmpeg_pixel_format( params_.format(), params_.channel_count()); - if (expected_fmt == FB_PIX_FMT_NONE) { + if (expected_fmt == fb_pix_fmt_none) { return; } OfxRectI bounds = { 0, 0, params_.width(), params_.height() }; OfxRectD rod_d = getRegionOfDefinition(time); - OfxRectI regionOfDefinition = { static_cast(std::floor(rod_d.x1)), + OfxRectI region_of_definition = { static_cast(std::floor(rod_d.x1)), static_cast(std::floor(rod_d.y1)), static_cast(std::ceil(rod_d.x2)), static_cast(std::ceil(rod_d.y2)) }; @@ -651,12 +651,12 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, Image *image; if (images_.contains(time)) { image = images_.value(time); - image->EnsureAllocatedFromParams(params_, bounds, regionOfDefinition, + image->ensure_allocated_from_params(params_, bounds, region_of_definition, false); } else { - pruneImagesCache(); - image = new Image(*this, params_, bounds, regionOfDefinition, false); - image->EnsureAllocatedFromParams(params_, bounds, regionOfDefinition, + prune_images_cache(); + image = new Image(*this, params_, bounds, region_of_definition, false); + image->ensure_allocated_from_params(params_, bounds, region_of_definition, false); images_.insert(time, image); } @@ -676,7 +676,7 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, // undefined behaviour when val is NaN, leading to out-of-bounds indexing // and SIGSEGV on Apple Silicon (where (int)NaN often evaluates to 0 or // INT_MIN, causing huge offsets into bgrid._data). - if (params_.format() == core::PixelFormat::F32) { + if (params_.format() == core::PixelFormat::f32) { const float *fptr = reinterpret_cast(frame->data(0)); int row_floats = frame->linesize(0) / static_cast(sizeof(float)); bool has_nan = false; @@ -706,15 +706,15 @@ void olive::plugin::OliveClipInstance::setInputTexture(TexturePtr texture, AVFramePtr src_frame = frame; if (frame->format() != expected_fmt || frame->width() != params_.width() || frame->height() != params_.height()) { - if (PackedFloatChannels(frame->format()) > + if (packed_float_channels(frame->format()) > 0) { - AVFramePtr converted = ConvertPackedFloatFrame(frame, expected_fmt); + AVFramePtr converted = convert_packed_float_frame(frame, expected_fmt); if (converted) { src_frame = converted; goto copy_pixels; } } - AVFramePtr converted = CreateAVFramePtr(); + AVFramePtr converted = create_av_frame_ptr(); converted->set_format(expected_fmt); converted->set_width(params_.width()); converted->set_height(params_.height()); @@ -758,7 +758,7 @@ copy_pixels: int copy_height = std::min(image->height(), src_frame->height()); const uint8_t *src = src_frame->data(0); - if (params_.format() == core::PixelFormat::F32) { + if (params_.format() == core::PixelFormat::f32) { const float *src_f = reinterpret_cast(src); float *dst_f = reinterpret_cast(dst); int src_stride = src_row_bytes / static_cast(sizeof(float)); @@ -806,7 +806,7 @@ void olive::plugin::OliveClipInstance::setOutputTexture(TexturePtr texture, #ifdef OFX_SUPPORTS_OPENGLRENDER OFX::Host::ImageEffect::Texture * olive::plugin::OliveClipInstance::loadTexture(OfxTime time, const char *format, - const OfxRectD *optionalBounds) + const OfxRectD *optional_bounds) { (void)format; @@ -818,7 +818,7 @@ olive::plugin::OliveClipInstance::loadTexture(OfxTime time, const char *format, gl_texture = input ? input : nullptr; } - if (!gl_texture || gl_texture->IsDummy() || !gl_texture->id().isValid()) { + if (!gl_texture || gl_texture->is_dummy() || !gl_texture->id().isValid()) { return nullptr; } @@ -828,11 +828,11 @@ olive::plugin::OliveClipInstance::loadTexture(OfxTime time, const char *format, static_cast(std::ceil(rod_d.x2)), static_cast(std::ceil(rod_d.y2)) }; OfxRectI bounds = rod; - if (optionalBounds) { - bounds.x1 = static_cast(std::floor(optionalBounds->x1)); - bounds.y1 = static_cast(std::floor(optionalBounds->y1)); - bounds.x2 = static_cast(std::ceil(optionalBounds->x2)); - bounds.y2 = static_cast(std::ceil(optionalBounds->y2)); + if (optional_bounds) { + bounds.x1 = static_cast(std::floor(optional_bounds->x1)); + bounds.y1 = static_cast(std::floor(optional_bounds->y1)); + bounds.x2 = static_cast(std::ceil(optional_bounds->x2)); + bounds.y2 = static_cast(std::ceil(optional_bounds->y2)); } bounds.x1 = std::max(bounds.x1, rod.x1); bounds.y1 = std::max(bounds.y1, rod.y1); diff --git a/app/pluginSupport/OliveClip.h b/app/pluginSupport/oliveclip.h similarity index 79% rename from app/pluginSupport/OliveClip.h rename to app/pluginSupport/oliveclip.h index a61dd3009..7c5dbba27 100644 --- a/app/pluginSupport/OliveClip.h +++ b/app/pluginSupport/oliveclip.h @@ -21,8 +21,8 @@ // Created by mikesolar on 25-10-1. // -#ifndef OLIVECLIP_H -#define OLIVECLIP_H +#ifndef OAK_OLIVECLIP_H +#define OAK_OLIVECLIP_H #include "image.h" #include "ofxCore.h" #include "ofxhClip.h" @@ -37,10 +37,10 @@ namespace plugin { class OliveClipInstance : public OFX::Host::ImageEffect::ClipInstance { public: - OliveClipInstance(OFX::Host::ImageEffect::Instance *effectInstance, + OliveClipInstance(OFX::Host::ImageEffect::Instance *effect_instance, OFX::Host::ImageEffect::ClipDescriptor &desc, VideoParams ¶ms) - : ClipInstance(effectInstance, desc) + : ClipInstance(effect_instance, desc) , params_(params) , defaultRegionOfDefinitions_{ 0, 0, 0, 0 } , name_(desc.getName()) @@ -53,24 +53,24 @@ public: const std::string &getPremult() const override; double getAspectRatio() const override; double getFrameRate() const override; - void getFrameRange(double &startFrame, double &endFrame) const override; + void getFrameRange(double &start_frame, double &end_frame) const override; const std::string &getFieldOrder() const override; bool getConnected() const override; double getUnmappedFrameRate() const override; - void getUnmappedFrameRange(double &startFrame, - double &endFrame) const override; + void getUnmappedFrameRange(double &start_frame, + double &end_frame) const override; bool getContinuousSamples() const override; OFX::Host::ImageEffect::Image * - getImage(OfxTime time, const OfxRectD *optionalBounds) override; + getImage(OfxTime time, const OfxRectD *optional_bounds) override; OfxRectD getRegionOfDefinition(OfxTime time) const override; - void setRegionOfDefinition(OfxRectD regionOfDefinition, OfxTime time); - void setDefaultRegionOfDefinition(OfxRectD regionOfDefinition); + void setRegionOfDefinition(OfxRectD region_of_definition, OfxTime time); + void setDefaultRegionOfDefinition(OfxRectD region_of_definition); void setParams(const VideoParams ¶ms); #ifdef OFX_SUPPORTS_OPENGLRENDER OFX::Host::ImageEffect::Texture * loadTexture(OfxTime time, const char *format, - const OfxRectD *optionalBounds) override; + const OfxRectD *optional_bounds) override; #endif void setInputTexture(TexturePtr texture, OfxTime time, @@ -82,9 +82,9 @@ public: // Prune old entries from the images_ cache to prevent unbounded growth. // Output clip images are not pruned (they are typically single-frame). - void pruneImagesCache(); + void prune_images_cache(); - static constexpr int kMaxInputImageCache = 8; + static constexpr int k_max_input_image_cache = 8; private: VideoParams params_; @@ -103,4 +103,4 @@ private: } } -#endif //OLIVECLIP_H +#endif //OAK_OLIVECLIP_H diff --git a/app/pluginSupport/OliveHost.cpp b/app/pluginSupport/olivehost.cpp similarity index 78% rename from app/pluginSupport/OliveHost.cpp rename to app/pluginSupport/olivehost.cpp index 812c1512f..a5e9b1ac3 100644 --- a/app/pluginSupport/OliveHost.cpp +++ b/app/pluginSupport/olivehost.cpp @@ -28,10 +28,10 @@ #include #include #include -#include "OliveHost.h" +#include "olivehost.h" -#include "OlivePluginInstance.h" -#include "common/Current.h" +#include "oliveplugininstance.h" +#include "common/current.h" #include "ofxMessage.h" #include "version.h" #include @@ -48,7 +48,7 @@ class PluginNode; namespace { -void AddPluginPath(OFX::Host::PluginCache *cache, const QString &path, +void add_plugin_path(OFX::Host::PluginCache *cache, const QString &path, bool recurse = true) { if (!cache || path.isEmpty()) { @@ -61,7 +61,7 @@ void AddPluginPath(OFX::Host::PluginCache *cache, const QString &path, cache->addFileToPath(dir.canonicalPath().toStdString(), recurse); } -void AddPluginPathsFromEnv(OFX::Host::PluginCache *cache, const char *env_var) +void add_plugin_paths_from_env(OFX::Host::PluginCache *cache, const char *env_var) { QString raw = qEnvironmentVariable(env_var); if (raw.isEmpty()) { @@ -70,47 +70,47 @@ void AddPluginPathsFromEnv(OFX::Host::PluginCache *cache, const char *env_var) const QChar separator = QDir::listSeparator(); const QStringList paths = raw.split(separator, Qt::SkipEmptyParts); for (const QString &path : paths) { - AddPluginPath(cache, path); + add_plugin_path(cache, path); } } } -void olive::plugin::loadPlugins(QString path) +void olive::plugin::load_plugins(QString path) { - std::shared_ptr host = Current::getInstance().pluginHost(); - std::shared_ptr imageEffectPluginCache = - Current::getInstance().pluginCache(); + std::shared_ptr host = Current::getInstance().plugin_host(); + std::shared_ptr image_effect_plugin_cache = + Current::getInstance().plugin_cache(); - if (!host || !imageEffectPluginCache) { + if (!host || !image_effect_plugin_cache) { host = std::make_shared(); Current::getInstance().setPluginHost(host); - imageEffectPluginCache = + image_effect_plugin_cache = std::make_shared(*host); - Current::getInstance().setPluginCache(imageEffectPluginCache); + Current::getInstance().setPluginCache(image_effect_plugin_cache); - imageEffectPluginCache->registerInCache( + image_effect_plugin_cache->registerInCache( *OFX::Host::PluginCache::getPluginCache()); } OFX::Host::PluginCache *cache = OFX::Host::PluginCache::getPluginCache(); cache->setPluginHostPath("Olive"); const QString home_path = QDir::homePath(); - AddPluginPath(cache, QDir(home_path).filePath(".OFX/Plugins")); - AddPluginPath(cache, QDir(home_path).filePath(".local/share/OFX/Plugins")); - AddPluginPath(cache, + add_plugin_path(cache, QDir(home_path).filePath(".OFX/Plugins")); + add_plugin_path(cache, QDir(home_path).filePath(".local/share/OFX/Plugins")); + add_plugin_path(cache, QDir(home_path).filePath(".local/share/olive/ofx/Plugins")); const QString app_dir = QCoreApplication::applicationDirPath(); - AddPluginPath(cache, QDir(app_dir).filePath("../OFX/Plugins")); - AddPluginPath(cache, QDir(app_dir).filePath("../share/olive/ofx/Plugins")); - AddPluginPath(cache, QDir(app_dir).filePath("../lib/olive/ofx/Plugins")); + add_plugin_path(cache, QDir(app_dir).filePath("../OFX/Plugins")); + add_plugin_path(cache, QDir(app_dir).filePath("../share/olive/ofx/Plugins")); + add_plugin_path(cache, QDir(app_dir).filePath("../lib/olive/ofx/Plugins")); - AddPluginPathsFromEnv(cache, "OLIVE_OFX_PLUGIN_PATH"); - AddPluginPathsFromEnv(cache, "OLIVE_PLUGIN_PATH"); + add_plugin_paths_from_env(cache, "OLIVE_OFX_PLUGIN_PATH"); + add_plugin_paths_from_env(cache, "OLIVE_PLUGIN_PATH"); if (!path.isEmpty()) { - AddPluginPath(cache, path, true); + add_plugin_path(cache, path, true); } cache->scanPluginFiles(); } @@ -120,11 +120,11 @@ OliveHost::OliveHost() _properties.setStringProperty(kOfxPropName, "Oak Video Editor"); _properties.setStringProperty(kOfxPropLabel, "Oak Video Editor"); _properties.setStringProperty(kOfxPropVersionLabel, - olive::kAppVersion.toStdString()); + olive::k_app_version.toStdString()); // Numeric version for plugins that query kOfxPropVersion directly. const QStringList version_parts = - olive::kAppVersion.section(QLatin1Char('-'), 0, 0) + olive::k_app_version.section(QLatin1Char('-'), 0, 0) .split(QLatin1Char('.')); _properties.setIntProperty(kOfxPropVersion, version_parts.value(0).toInt(), 0); @@ -138,7 +138,7 @@ OliveHost::~OliveHost() { } -void OliveHost::destroyInstance(OFX::Host::ImageEffect::Instance *instance) +void OliveHost::destroy_instance(OFX::Host::ImageEffect::Instance *instance) { if (!instance) { return; @@ -159,33 +159,33 @@ OliveHost::makeDescriptor(ImageEffect::ImageEffectPlugin *plugin) return desc; } std::shared_ptr -OliveHost::makeDescriptor(const ImageEffect::Descriptor &rootContext, +OliveHost::makeDescriptor(const ImageEffect::Descriptor &root_context, ImageEffect::ImageEffectPlugin *plugin) { std::shared_ptr desc = - std::make_shared(rootContext, plugin); + std::make_shared(root_context, plugin); descriptors_.append(std::shared_ptr(desc)); return desc; } std::shared_ptr -OliveHost::makeDescriptor(const std::string &bundlePath, +OliveHost::makeDescriptor(const std::string &bundle_path, ImageEffect::ImageEffectPlugin *plugin) { std::shared_ptr desc = - std::make_shared(bundlePath, plugin); + std::make_shared(bundle_path, plugin); descriptors_.append(std::shared_ptr(desc)); return desc; } ImageEffect::Instance * -OliveHost::newInstance(void *clientData, ImageEffect::ImageEffectPlugin *plugin, +OliveHost::newInstance(void *client_data, ImageEffect::ImageEffectPlugin *plugin, ImageEffect::Descriptor &desc, const std::string &context) { auto *instance = new OlivePluginInstance( plugin, desc, context, Current::getInstance().interactive()); - if (clientData) { - auto *node = static_cast(clientData); + if (client_data) { + auto *node = static_cast(client_data); instance->setNode( std::shared_ptr(node, [](PluginNode *) {})); } @@ -252,21 +252,21 @@ OfxStatus olive::plugin::OliveHost::setPersistentMessage(const char *type, QGuiApplication::platformName() == QLatin1String("offscreen"); if (strcmp(type, kOfxMessageError) == 0) { - persistent_messages_.append({ HostMessageType::Error, message }); + persistent_messages_.append({ HostMessageType::error, message }); if (headless) { qWarning().noquote() << "OFX error:" << message; } else { QMessageBox::critical(nullptr, "", message); } } else if (strcmp(type, kOfxMessageWarning) == 0) { - persistent_messages_.append({ HostMessageType::Warning, message }); + persistent_messages_.append({ HostMessageType::warning, message }); if (headless) { qWarning().noquote() << "OFX warning:" << message; } else { QMessageBox::warning(nullptr, "", message); } } else if (strcmp(type, kOfxMessageMessage) == 0) { - persistent_messages_.append({ HostMessageType::Message, message }); + persistent_messages_.append({ HostMessageType::message, message }); if (headless) { qWarning().noquote() << "OFX message:" << message; } else { diff --git a/app/pluginSupport/OliveHost.h b/app/pluginSupport/olivehost.h similarity index 87% rename from app/pluginSupport/OliveHost.h rename to app/pluginSupport/olivehost.h index 8ac2cc0b7..9e976cbe1 100644 --- a/app/pluginSupport/OliveHost.h +++ b/app/pluginSupport/olivehost.h @@ -15,9 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef OLIVE_HOST_H -#define OLIVE_HOST_H -#include "node/plugins/Plugin.h" +#ifndef OAK_OLIVE_HOST_H +#define OAK_OLIVE_HOST_H +#include "node/plugins/plugin.h" #include "ofxhHost.h" #include "ofxhImageEffectAPI.h" #include "ofxCore.h" @@ -35,18 +35,18 @@ namespace olive { namespace plugin { -enum class HostMessageType { Error, Warning, Message }; +enum class HostMessageType { error, warning, message }; struct HostPersistentMessage { HostMessageType type; QString message; }; -void loadPlugins(QString path); +void load_plugins(QString path); class OliveHost : public OFX::Host::ImageEffect::Host { public: OliveHost(); ~OliveHost() override; - void destroyInstance(OFX::Host::ImageEffect::Instance *instance); + void destroy_instance(OFX::Host::ImageEffect::Instance *instance); bool pluginSupported(OFX::Host::ImageEffect::ImageEffectPlugin *plugin, std::string &reason) const override @@ -63,7 +63,7 @@ public: }; OFX::Host::ImageEffect::Instance * - newInstance(void *clientData, + newInstance(void *client_data, OFX::Host::ImageEffect::ImageEffectPlugin *plugin, OFX::Host::ImageEffect::Descriptor &desc, const std::string &context) override; @@ -72,11 +72,11 @@ public: makeDescriptor(OFX::Host::ImageEffect::ImageEffectPlugin *plugin) override; std::shared_ptr - makeDescriptor(const OFX::Host::ImageEffect::Descriptor &rootContext, + makeDescriptor(const OFX::Host::ImageEffect::Descriptor &root_context, OFX::Host::ImageEffect::ImageEffectPlugin *plugin) override; std::shared_ptr - makeDescriptor(const std::string &bundlePath, + makeDescriptor(const std::string &bundle_path, OFX::Host::ImageEffect::ImageEffectPlugin *plugin) override; /// vmessage virtual OfxStatus vmessage(const char *type, const char *id, diff --git a/app/pluginSupport/OlivePluginInstance.cpp b/app/pluginSupport/oliveplugininstance.cpp similarity index 79% rename from app/pluginSupport/OlivePluginInstance.cpp rename to app/pluginSupport/oliveplugininstance.cpp index 5b79b4e0f..ea0579fd5 100644 --- a/app/pluginSupport/OlivePluginInstance.cpp +++ b/app/pluginSupport/oliveplugininstance.cpp @@ -15,13 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "OlivePluginInstance.h" +#include "oliveplugininstance.h" -#include "OliveClip.h" +#include "oliveclip.h" #include "ofxGPURender.h" #include "ofxCore.h" #include "ofxMessage.h" -#include "common/Current.h" +#include "common/current.h" #include "core.h" #include "dialog/progress/progress.h" #include "node/output/viewer/viewer.h" @@ -45,11 +45,11 @@ namespace plugin { namespace { -const std::string kImageFieldNoneStr(kOfxImageFieldNone); -const std::string kImageFieldUpperStr(kOfxImageFieldUpper); -const std::string kImageFieldLowerStr(kOfxImageFieldLower); +const std::string k_image_field_none_str(kOfxImageFieldNone); +const std::string k_image_field_upper_str(kOfxImageFieldUpper); +const std::string k_image_field_lower_str(kOfxImageFieldLower); -QString FormatOfxMessage(const char *format, va_list args) +QString format_ofx_message(const char *format, va_list args) { char buffer[1024]; va_list args_copy; @@ -71,17 +71,17 @@ QString FormatOfxMessage(const char *format, va_list args) return QString::fromUtf8(dynamic_buffer.constData()); } -const std::string &FieldOrderForParams(const VideoParams ¶ms) +const std::string &field_order_for_params(const VideoParams ¶ms) { switch (params.interlacing()) { - case VideoParams::kInterlaceNone: - return kImageFieldNoneStr; - case VideoParams::kInterlacedTopFirst: - return kImageFieldUpperStr; - case VideoParams::kInterlacedBottomFirst: - return kImageFieldLowerStr; + case VideoParams::k_interlace_none: + return k_image_field_none_str; + case VideoParams::k_interlaced_top_first: + return k_image_field_upper_str; + case VideoParams::k_interlaced_bottom_first: + return k_image_field_lower_str; } - return kImageFieldNoneStr; + return k_image_field_none_str; } class DeferredRedoCommand : public UndoCommand { @@ -96,9 +96,9 @@ public: delete inner_; } - Project *GetRelevantProject() const override + Project *get_relevant_project() const override { - return inner_ ? inner_->GetRelevantProject() : nullptr; + return inner_ ? inner_->get_relevant_project() : nullptr; } protected: @@ -125,24 +125,24 @@ private: bool skip_first_redo_ = true; }; -ViewerOutput *GetActiveViewerOutput() +ViewerOutput *get_active_viewer_output() { PanelManager *manager = PanelManager::instance(); if (!manager) { return nullptr; } - if (auto *time_panel = manager->MostRecentlyFocused()) { - if (time_panel->GetConnectedViewer()) { - return time_panel->GetConnectedViewer(); + if (auto *time_panel = manager->most_recently_focused()) { + if (time_panel->get_connected_viewer()) { + return time_panel->get_connected_viewer(); } } QList timelines = - manager->GetPanelsOfType(); + manager->get_panels_of_type(); for (TimelinePanel *panel : timelines) { - if (panel && panel->GetConnectedViewer()) { - return panel->GetConnectedViewer(); + if (panel && panel->get_connected_viewer()) { + return panel->get_connected_viewer(); } } @@ -152,7 +152,7 @@ ViewerOutput *GetActiveViewerOutput() const std::string &OlivePluginInstance::getDefaultOutputFielding() const { - return FieldOrderForParams(params_); + return field_order_for_params(params_); } void OlivePluginInstance::setNode(std::shared_ptr node) @@ -163,7 +163,7 @@ void OlivePluginInstance::setNode(std::shared_ptr node) continue; } if (auto *bound = dynamic_cast(entry.second)) { - bound->SetNode(node_); + bound->set_node(node_); } } } @@ -171,7 +171,7 @@ void OlivePluginInstance::setNode(std::shared_ptr node) OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id, const char *format, va_list args) { - const QString message = FormatOfxMessage(format, args); + const QString message = format_ofx_message(format, args); if (message.isEmpty()) { return kOfxStatFailed; } @@ -191,7 +191,7 @@ OfxStatus OlivePluginInstance::vmessage(const char *type, const char *id, } }; - if (IsGuiThread()) { + if (is_gui_thread()) { show_message(); } else if (auto *app = QCoreApplication::instance()) { if (is_question) { @@ -211,7 +211,7 @@ OfxStatus OlivePluginInstance::setPersistentMessage(const char *type, const char *format, va_list args) { - const QString message = FormatOfxMessage(format, args); + const QString message = format_ofx_message(format, args); if (message.isEmpty()) { return kOfxStatFailed; } @@ -219,17 +219,17 @@ OfxStatus OlivePluginInstance::setPersistentMessage(const char *type, ErrorType error_type; // If This is a error message if (strncmp(type, kOfxMessageError, strlen(kOfxMessageError)) == 0) { - error_type = ErrorType::Error; + error_type = ErrorType::error; } // A warning else if (strncmp(type, kOfxMessageWarning, strlen(kOfxMessageWarning)) == 0) { - error_type = ErrorType::Warning; + error_type = ErrorType::warning; } // A simple information else if (strncmp(type, kOfxMessageMessage, strlen(kOfxMessageMessage)) == 0) { - error_type = ErrorType::Message; + error_type = ErrorType::message; } else { return kOfxStatFailed; } @@ -237,22 +237,22 @@ OfxStatus OlivePluginInstance::setPersistentMessage(const char *type, auto update_ui = [this, error_type, message]() { persistentErrors_.append({ error_type, message }); switch (error_type) { - case ErrorType::Error: + case ErrorType::error: QMessageBox::critical(nullptr, "", message); break; - case ErrorType::Warning: + case ErrorType::warning: QMessageBox::warning(nullptr, "", message); break; - case ErrorType::Message: + case ErrorType::message: QMessageBox::information(nullptr, "", message); break; } if (node_) { - emit node_->MessageCountChanged(); + emit node_->message_count_changed(); } }; - if (IsGuiThread()) { + if (is_gui_thread()) { update_ui(); } else if (auto *app = QCoreApplication::instance()) { QMetaObject::invokeMethod(app, update_ui, Qt::QueuedConnection); @@ -265,38 +265,38 @@ OfxStatus OlivePluginInstance::clearPersistentMessage() persistentErrors_.clear(); // TODO: tell the shell to remove message. if (node_) { - emit node_->MessageCountChanged(); + emit node_->message_count_changed(); } }; - if (IsGuiThread()) { + if (is_gui_thread()) { clear_ui(); } else if (auto *app = QCoreApplication::instance()) { QMetaObject::invokeMethod(app, clear_ui, Qt::QueuedConnection); } return kOfxStatOK; } -void OlivePluginInstance::getProjectSize(double &xSize, double &ySize) const +void OlivePluginInstance::getProjectSize(double &x_size, double &y_size) const { - double par = params_.pixel_aspect_ratio().toDouble(); - xSize = params_.width() * par; - ySize = params_.height(); + double par = params_.pixel_aspect_ratio().to_double(); + x_size = params_.width() * par; + y_size = params_.height(); } -void OlivePluginInstance::getProjectOffset(double &xOffset, - double &yOffset) const +void OlivePluginInstance::getProjectOffset(double &x_offset, + double &y_offset) const { - double par = params_.pixel_aspect_ratio().toDouble(); - xOffset = params_.x() * par; - yOffset = params_.y(); + double par = params_.pixel_aspect_ratio().to_double(); + x_offset = params_.x() * par; + y_offset = params_.y(); } -void OlivePluginInstance::getProjectExtent(double &xSize, double &ySize) const +void OlivePluginInstance::getProjectExtent(double &x_size, double &y_size) const { - double par = params_.pixel_aspect_ratio().toDouble(); - xSize = params_.width() * par; - ySize = params_.height(); + double par = params_.pixel_aspect_ratio().to_double(); + x_size = params_.width() * par; + y_size = params_.height(); } double OlivePluginInstance::getProjectPixelAspectRatio() const { - double par = params_.pixel_aspect_ratio().toDouble(); + double par = params_.pixel_aspect_ratio().to_double(); if (par == 0.0) { return 1.0; // default PAR when not explicitly set } @@ -304,7 +304,7 @@ double OlivePluginInstance::getProjectPixelAspectRatio() const } double OlivePluginInstance::getFrameRate() const { - return params_.frame_rate().toDouble(); + return params_.frame_rate().to_double(); } double OlivePluginInstance::getEffectDuration() const @@ -410,7 +410,7 @@ OfxStatus OlivePluginInstance::editEnd() return kOfxStatOK; } -void OlivePluginInstance::SubmitUndoCommand(UndoCommand *command, +void OlivePluginInstance::submit_undo_command(UndoCommand *command, const QString &label) { if (!command) { @@ -431,7 +431,7 @@ void OlivePluginInstance::SubmitUndoCommand(UndoCommand *command, return; } - if (!IsGuiThread()) { + if (!is_gui_thread()) { command->redo_now(); delete command; return; @@ -463,7 +463,7 @@ void OlivePluginInstance::progressStart(const std::string &message, progress_dialog_ = new ::olive::ProgressDialog( dialog_message, QStringLiteral("OpenFX"), nullptr); progress_dialog_->setAttribute(Qt::WA_DeleteOnClose); - QObject::connect(progress_dialog_, &::olive::ProgressDialog::Cancelled, + QObject::connect(progress_dialog_, &::olive::ProgressDialog::cancelled, progress_dialog_, [this]() { progress_cancelled_ = true; }); progress_dialog_->show(); @@ -488,7 +488,7 @@ bool OlivePluginInstance::progressUpdate(double t) if (progress_dialog_) { double clamped = qBound(0.0, t, 1.0); - progress_dialog_->SetProgress(clamped); + progress_dialog_->set_progress(clamped); } return !progress_cancelled_; @@ -514,8 +514,8 @@ OfxStatus OlivePluginInstance::contextDetachedAction() double OlivePluginInstance::timeLineGetTime() { - if (ViewerOutput *viewer = GetActiveViewerOutput()) { - return viewer->GetPlayhead().toDouble(); + if (ViewerOutput *viewer = get_active_viewer_output()) { + return viewer->get_playhead().to_double(); } return 0.0; @@ -523,16 +523,16 @@ double OlivePluginInstance::timeLineGetTime() void OlivePluginInstance::timeLineGotoTime(double t) { - if (ViewerOutput *viewer = GetActiveViewerOutput()) { - viewer->SetPlayhead(olive::core::rational::fromDouble(t)); + if (ViewerOutput *viewer = get_active_viewer_output()) { + viewer->set_playhead(olive::core::Rational::from_double(t)); } } void OlivePluginInstance::timeLineGetBounds(double &t1, double &t2) { - if (ViewerOutput *viewer = GetActiveViewerOutput()) { + if (ViewerOutput *viewer = get_active_viewer_output()) { t1 = 0.0; - t2 = viewer->GetLength().toDouble(); + t2 = viewer->get_length().to_double(); return; } @@ -541,12 +541,12 @@ void OlivePluginInstance::timeLineGetBounds(double &t1, double &t2) } void OlivePluginInstance::setCustomInArgs(const std::string &action, - OFX::Host::Property::Set &inArgs) + OFX::Host::Property::Set &in_args) { if (action == kOfxImageEffectActionRender || action == kOfxImageEffectActionBeginSequenceRender || action == kOfxImageEffectActionEndSequenceRender) { - inArgs.setIntProperty(kOfxImageEffectPropOpenGLEnabled, + in_args.setIntProperty(kOfxImageEffectPropOpenGLEnabled, open_gl_enabled_ ? 1 : 0); } } @@ -556,7 +556,7 @@ OFX::Host::ImageEffect::ClipInstance *OlivePluginInstance::newClipInstance( OFX::Host::ImageEffect::ClipDescriptor *descriptor, int index) { // Create a new clip instance - OliveClipInstance *clipInstance = + OliveClipInstance *clip_instance = new OliveClipInstance(plugin, *descriptor, params_); // Initialize base class clip properties from VideoParams so that @@ -567,16 +567,16 @@ OFX::Host::ImageEffect::ClipInstance *OlivePluginInstance::newClipInstance( std::string comp = kOfxImageComponentRGBA; // host default switch (params_.format()) { - case core::PixelFormat::U8: + case core::PixelFormat::u8: depth = kOfxBitDepthByte; break; - case core::PixelFormat::U16: + case core::PixelFormat::u16: depth = kOfxBitDepthShort; break; - case core::PixelFormat::F16: + case core::PixelFormat::f16: depth = kOfxBitDepthHalf; break; - case core::PixelFormat::F32: + case core::PixelFormat::f32: depth = kOfxBitDepthFloat; break; default: @@ -597,10 +597,10 @@ OFX::Host::ImageEffect::ClipInstance *OlivePluginInstance::newClipInstance( break; // keep RGBA default } - clipInstance->setPixelDepth(depth); - clipInstance->setComponents(comp); + clip_instance->setPixelDepth(depth); + clip_instance->setComponents(comp); - return clipInstance; + return clip_instance; } OlivePluginInstance::~OlivePluginInstance() diff --git a/app/pluginSupport/OlivePluginInstance.h b/app/pluginSupport/oliveplugininstance.h similarity index 91% rename from app/pluginSupport/OlivePluginInstance.h rename to app/pluginSupport/oliveplugininstance.h index 9dc95d189..fd8208c92 100644 --- a/app/pluginSupport/OlivePluginInstance.h +++ b/app/pluginSupport/oliveplugininstance.h @@ -15,13 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef OLIVE_INSTANCE_H -#define OLIVE_INSTANCE_H +#ifndef OAK_OLIVE_INSTANCE_H +#define OAK_OLIVE_INSTANCE_H #include "ofxCore.h" #include "ofxImageEffect.h" #include #include "ofxhImageEffect.h" -#include "node/plugins/Plugin.h" +#include "node/plugins/plugin.h" #include "render/videoparams.h" #include "undo/undocommand.h" @@ -36,7 +36,7 @@ namespace olive { -inline bool IsGuiThread() +inline bool is_gui_thread() { if (auto *app = QCoreApplication::instance()) { return QThread::currentThread() == app->thread(); @@ -47,7 +47,7 @@ class ProgressDialog; namespace plugin { class PluginNode; -enum class ErrorType { Error, Warning, Message }; +enum class ErrorType { error, warning, message }; struct PersistentErrors { ErrorType type; QString message; @@ -108,18 +108,18 @@ public: const char *format, va_list args) override; OfxStatus clearPersistentMessage() override; - int persistentMessageCount() const + int persistent_message_count() const { return persistentErrors_.size(); } - const QList &persistentMessages() const + const QList &persistent_messages() const { return persistentErrors_; } - void getProjectSize(double &xSize, double &ySize) const override; - void getProjectOffset(double &xOffset, double &yOffset) const override; - void getProjectExtent(double &xSize, double &ySize) const override; + void getProjectSize(double &x_size, double &y_size) const override; + void getProjectOffset(double &x_offset, double &y_offset) const override; + void getProjectExtent(double &x_size, double &y_size) const override; // The pixel aspect ratio of the current project double getProjectPixelAspectRatio() const override; @@ -148,9 +148,9 @@ public: /// Client host code needs to implement this OFX::Host::Param::Instance * newParam(const std::string &name, - OFX::Host::Param::Descriptor &Descriptor) override; + OFX::Host::Param::Descriptor &descriptor) override; - void SubmitUndoCommand(UndoCommand *command, const QString &label); + void submit_undo_command(UndoCommand *command, const QString &label); /// Triggered when the plug-in calls OfxParameterSuiteV1::paramEditBegin /// @@ -203,7 +203,7 @@ public: virtual void timeLineGetBounds(double &t1, double &t2); void setCustomInArgs(const std::string &action, - OFX::Host::Property::Set &inArgs) override; + OFX::Host::Property::Set &in_args) override; private: QList persistentErrors_; diff --git a/app/pluginSupport/paraminstance.cpp b/app/pluginSupport/paraminstance.cpp index c01056c1a..650265ed4 100644 --- a/app/pluginSupport/paraminstance.cpp +++ b/app/pluginSupport/paraminstance.cpp @@ -19,13 +19,13 @@ #include "paraminstance.h" -#include "OlivePluginInstance.h" +#include "oliveplugininstance.h" namespace olive { namespace plugin { -void SubmitUndoCommand(const std::shared_ptr &node, +void submit_undo_command(const std::shared_ptr &node, UndoCommand *command, const QString &label) { if (!command) { @@ -36,12 +36,12 @@ void SubmitUndoCommand(const std::shared_ptr &node, auto *instance = node->getPluginInstance(); auto *olive_instance = dynamic_cast(instance); if (olive_instance) { - olive_instance->SubmitUndoCommand(command, label); + olive_instance->submit_undo_command(command, label); return; } } - if (!IsGuiThread()) { + if (!is_gui_thread()) { command->redo_now(); delete command; return; diff --git a/app/pluginSupport/paraminstance.h b/app/pluginSupport/paraminstance.h index 47fab5f1d..72f2770d0 100644 --- a/app/pluginSupport/paraminstance.h +++ b/app/pluginSupport/paraminstance.h @@ -18,21 +18,21 @@ */ // Copyright OpenFX and contributors to the OpenFX project. -#ifndef PARAM_INSTANCE_H -#define PARAM_INSTANCE_H +#ifndef OAK_PARAM_INSTANCE_H +#define OAK_PARAM_INSTANCE_H #include "olive/core/util/rational.h" -#include "pluginSupport/OlivePluginInstance.h" +#include "pluginSupport/oliveplugininstance.h" #include #include #include #include #include "ofxhParam.h" #include "node/nodeundo.h" -#include "node/plugins/Plugin.h" +#include "node/plugins/plugin.h" #include "core.h" #include "undo/undocommand.h" -#include "common/Current.h" +#include "common/current.h" #include #include #include @@ -42,71 +42,71 @@ namespace plugin { inline bool -IsNormalisedCoordinateSystem(const OFX::Host::Param::Descriptor &descriptor) +is_normalised_coordinate_system(const OFX::Host::Param::Descriptor &descriptor) { return descriptor.getDefaultCoordinateSystem() == kOfxParamCoordinatesNormalised; } -inline void GetProjectExtent(double &xSize, double &ySize) +inline void get_project_extent(double &x_size, double &y_size) { - auto &vp = Current::getInstance().currentVideoParams(); - xSize = vp.width() * vp.pixel_aspect_ratio().toDouble(); - ySize = vp.height(); + auto &vp = Current::getInstance().current_video_params(); + x_size = vp.width() * vp.pixel_aspect_ratio().to_double(); + y_size = vp.height(); } -inline double ToNormalised(double canonical, double extent) +inline double to_normalised(double canonical, double extent) { return extent > 0 ? canonical / extent : canonical; } -inline double ToCanonical(double normalised, double extent) +inline double to_canonical(double normalised, double extent) { return extent > 0 ? normalised * extent : normalised; } -inline QString ParamChangeLabel(const OFX::Host::Param::Descriptor &descriptor) +inline QString param_change_label(const OFX::Host::Param::Descriptor &descriptor) { return QStringLiteral("Change %1") .arg(QString::fromStdString(descriptor.getName())); } -void SubmitUndoCommand(const std::shared_ptr &node, +void submit_undo_command(const std::shared_ptr &node, UndoCommand *command, const QString &label); class NodeBoundParam { public: virtual ~NodeBoundParam() = default; - virtual void SetNode(const std::shared_ptr &node) = 0; + virtual void set_node(const std::shared_ptr &node) = 0; }; class PushbuttonInstance : public OFX::Host::Param::PushbuttonInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor *_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor *descriptor_; public: PushbuttonInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::PushbuttonInstance(descriptor, paramSet) - , node(effect) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::PushbuttonInstance(descriptor, param_set) + , node_(effect) { - _descriptor = &descriptor; + descriptor_ = &descriptor; }; - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } }; class IntegerInstance : public OFX::Host::Param::IntegerInstance, public NodeBoundParam { protected: - std::shared_ptr _node; - OFX::Host::Param::Descriptor &_descriptor; - QString id; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; + QString id_; mutable std::mutex no_node_mutex_; bool has_value_ = false; int value_ = 0; @@ -114,14 +114,14 @@ protected: public: IntegerInstance(std::shared_ptr node, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::IntegerInstance(descriptor, paramSet) - , _node(node) - , _descriptor(descriptor) - , id(_descriptor.getName().c_str()) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::IntegerInstance(descriptor, param_set) + , node_(node) + , descriptor_(descriptor) + , id_(descriptor_.getName().c_str()) { try { - value_ = _descriptor.getProperties().getIntProperty( + value_ = descriptor_.getProperties().getIntProperty( kOfxParamPropDefault); has_value_ = true; } catch (...) { @@ -129,21 +129,21 @@ public: has_value_ = false; } } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - _node = new_node; + node_ = new_node; } OfxStatus get(int &a) { - if (!_node) { + if (!node_) { std::lock_guard lock(no_node_mutex_); a = has_value_ ? value_ : 0; return kOfxStatOK; } - if (id.isEmpty()) { + if (id_.isEmpty()) { return kOfxStatErrBadHandle; } - QVariant variant = _node->GetStandardValue(id); + QVariant variant = node_->get_standard_value(id_); if (variant.canConvert()) { a = variant.toInt(); @@ -154,16 +154,16 @@ public: } OfxStatus get(OfxTime time, int &data) { - if (!_node) { + if (!node_) { std::lock_guard lock(no_node_mutex_); data = has_value_ ? value_ : 0; return kOfxStatOK; } - if (id.isEmpty()) { + if (id_.isEmpty()) { return kOfxStatErrBadHandle; } QVariant variant = - _node->GetValueAtTime(id, rational::fromDouble(time)); + node_->get_value_at_time(id_, Rational::from_double(time)); if (variant.canConvert()) { data = variant.toInt(); return kOfxStatOK; @@ -173,33 +173,33 @@ public: } OfxStatus set(int data) { - if (!_node) { + if (!node_) { std::lock_guard lock(no_node_mutex_); value_ = data; has_value_ = true; return kOfxStatOK; } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kInt, data); + NodeValue::k_int, data); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(_node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(_node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, int data) { - if (!_node) { + if (!node_) { std::lock_guard lock(no_node_mutex_); value_ = data; has_value_ = true; return kOfxStatOK; } auto command = new MultiUndoCommand(); - Node::SetValueAtTime( - NodeInput(_node.get(), _descriptor.getName().c_str()), - rational::fromDouble(time), data, 0, command, true); - SubmitUndoCommand(_node, command, ParamChangeLabel(_descriptor)); + Node::set_value_at_time( + NodeInput(node_.get(), descriptor_.getName().c_str()), + Rational::from_double(time), data, 0, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -207,22 +207,22 @@ public: class DoubleInstance : public OFX::Host::Param::DoubleInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; double value_ = 0.0; public: DoubleInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::DoubleInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::DoubleInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; try { - value_ = _descriptor.getProperties().getDoubleProperty( + value_ = descriptor_.getProperties().getDoubleProperty( kOfxParamPropDefault); has_value_ = true; } catch (...) { @@ -230,24 +230,24 @@ public: has_value_ = false; } } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(double &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : 0.0; return kOfxStatOK; } QVariant variant = - node->GetStandardValue(_descriptor.getName().c_str()); + node_->get_standard_value(descriptor_.getName().c_str()); if (variant.canConvert()) { data = variant.toDouble(); - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - data = ToNormalised(data, xSize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + data = to_normalised(data, x_size); } return kOfxStatOK; } @@ -256,18 +256,18 @@ public: } OfxStatus get(OfxTime time, double &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : 0.0; return kOfxStatOK; } - QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)); + QVariant variant = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)); if (variant.canConvert()) { data = variant.toDouble(); - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - data = ToNormalised(data, xSize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + data = to_normalised(data, x_size); } return kOfxStatOK; } @@ -276,42 +276,42 @@ public: } OfxStatus set(double data) { - if (!node) { + if (!node_) { value_ = data; has_value_ = true; return kOfxStatOK; } double val = data; - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - val = ToCanonical(val, xSize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + val = to_canonical(val, x_size); } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kFloat, val); + NodeValue::k_float, val); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, double data) { - if (!node) { + if (!node_) { value_ = data; has_value_ = true; return kOfxStatOK; } double val = data; - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - val = ToCanonical(val, xSize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + val = to_canonical(val, x_size); } auto command = new MultiUndoCommand(); - Node::SetValueAtTime(NodeInput(node.get(), - _descriptor.getName().c_str()), - rational::fromDouble(time), val, 0, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + Node::set_value_at_time(NodeInput(node_.get(), + descriptor_.getName().c_str()), + Rational::from_double(time), val, 0, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus derive(OfxTime, double &) @@ -327,98 +327,98 @@ public: class BooleanInstance : public OFX::Host::Param::BooleanInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; bool value_ = false; - bool DefaultValue() const + bool default_value() const { - return _descriptor.getProperties().getIntProperty( + return descriptor_.getProperties().getIntProperty( kOfxParamPropDefault) != 0; } public: BooleanInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::BooleanInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::BooleanInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; - value_ = DefaultValue(); + value_ = default_value(); has_value_ = true; } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(bool &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : false; return kOfxStatOK; } QVariant variant = - node->GetStandardValue(_descriptor.getName().c_str()); + node_->get_standard_value(descriptor_.getName().c_str()); if (variant.canConvert()) { data = variant.toBool(); return kOfxStatOK; } - data = DefaultValue(); + data = default_value(); return kOfxStatOK; } OfxStatus get(OfxTime time, bool &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : false; return kOfxStatOK; } - QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)); + QVariant variant = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)); if (variant.isNull()) { qWarning().noquote() << "Boolean get failed: Varient is null" << time - << rational::fromDouble(time).toDouble(); + << Rational::from_double(time).to_double(); } if (!variant.isValid()) { qWarning().noquote() << "Boolean get failed: Varient is invalid" << time - << rational::fromDouble(time).toDouble(); + << Rational::from_double(time).to_double(); } if (variant.canConvert()) { data = variant.toBool(); return kOfxStatOK; } - data = DefaultValue(); + data = default_value(); return kOfxStatOK; } OfxStatus set(bool data) { - if (!node) { + if (!node_) { value_ = data; has_value_ = true; return kOfxStatOK; } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kBoolean, data); + NodeValue::k_boolean, data); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, bool data) { - if (!node) { + if (!node_) { value_ = data; has_value_ = true; return kOfxStatOK; } auto command = new MultiUndoCommand(); - Node::SetValueAtTime( - NodeInput(node.get(), _descriptor.getName().c_str()), - rational::fromDouble(time), data, 0, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + Node::set_value_at_time( + NodeInput(node_.get(), descriptor_.getName().c_str()), + Rational::from_double(time), data, 0, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -426,22 +426,22 @@ public: class ChoiceInstance : public OFX::Host::Param::ChoiceInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; int value_ = 0; public: ChoiceInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::ChoiceInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::ChoiceInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; try { - value_ = _descriptor.getProperties().getIntProperty( + value_ = descriptor_.getProperties().getIntProperty( kOfxParamPropDefault); has_value_ = true; } catch (...) { @@ -449,18 +449,18 @@ public: has_value_ = false; } } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(int &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : 0; return kOfxStatOK; } QVariant variant = - node->GetStandardValue(_descriptor.getName().c_str()); + node_->get_standard_value(descriptor_.getName().c_str()); if (variant.canConvert()) { data = variant.toInt(); return kOfxStatOK; @@ -470,12 +470,12 @@ public: } OfxStatus get(OfxTime time, int &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : 0; return kOfxStatOK; } - QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)); + QVariant variant = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)); if (variant.canConvert()) { data = variant.toInt(); return kOfxStatOK; @@ -485,30 +485,30 @@ public: } OfxStatus set(int data) { - if (!node) { + if (!node_) { value_ = data; has_value_ = true; return kOfxStatOK; } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kCombo, data); + NodeValue::k_combo, data); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, int data) { - if (!node) { + if (!node_) { value_ = data; has_value_ = true; return kOfxStatOK; } auto command = new MultiUndoCommand(); - Node::SetValueAtTime( - NodeInput(node.get(), _descriptor.getName().c_str()), - rational::fromDouble(time), data, 0, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + Node::set_value_at_time( + NodeInput(node_.get(), descriptor_.getName().c_str()), + Rational::from_double(time), data, 0, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -516,28 +516,28 @@ public: class RGBAInstance : public OFX::Host::Param::RGBAInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; double value_[4] = { 0.0, 0.0, 0.0, 0.0 }; public: RGBAInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::RGBAInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::RGBAInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(double &r, double &g, double &b, double &a) { - if (!node) { + if (!node_) { if (has_value_) { r = value_[0]; g = value_[1]; @@ -549,7 +549,7 @@ public: return kOfxStatOK; } olive::core::Color c = - node->GetStandardValue(_descriptor.getName().c_str()) + node_->get_standard_value(descriptor_.getName().c_str()) .value(); r = static_cast(c.red()); @@ -560,7 +560,7 @@ public: } OfxStatus get(OfxTime time, double &r, double &g, double &b, double &a) { - if (!node) { + if (!node_) { if (has_value_) { r = value_[0]; g = value_[1]; @@ -572,8 +572,8 @@ public: return kOfxStatOK; } olive::core::Color c = - node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)) + node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)) .value(); r = static_cast(c.red()); @@ -584,7 +584,7 @@ public: } OfxStatus set(double r, double g, double b, double a) { - if (!node) { + if (!node_) { value_[0] = r; value_[1] = g; value_[2] = b; @@ -593,16 +593,16 @@ public: return kOfxStatOK; } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kColor, + NodeValue::k_color, QVariant::fromValue(olive::core::Color(r, g, b, a))); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, double r, double g, double b, double a) { - if (!node) { + if (!node_) { value_[0] = r; value_[1] = g; value_[2] = b; @@ -611,16 +611,16 @@ public: return kOfxStatOK; } auto command = new MultiUndoCommand(); - const QString name = _descriptor.getName().c_str(); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), r, 0, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), g, 1, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), b, 2, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), a, 3, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + const QString name = descriptor_.getName().c_str(); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), r, 0, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), g, 1, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), b, 2, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), a, 3, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -628,28 +628,28 @@ public: class RGBInstance : public OFX::Host::Param::RGBInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; double value_[3] = { 0.0, 0.0, 0.0 }; public: RGBInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::RGBInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::RGBInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(double &r, double &g, double &b) { - if (!node) { + if (!node_) { if (has_value_) { r = value_[0]; g = value_[1]; @@ -660,7 +660,7 @@ public: return kOfxStatOK; } olive::core::Color c = - node->GetStandardValue(_descriptor.getName().c_str()) + node_->get_standard_value(descriptor_.getName().c_str()) .value(); r = static_cast(c.red()); @@ -670,7 +670,7 @@ public: } OfxStatus get(OfxTime time, double &r, double &g, double &b) { - if (!node) { + if (!node_) { if (has_value_) { r = value_[0]; g = value_[1]; @@ -681,8 +681,8 @@ public: return kOfxStatOK; } olive::core::Color c = - node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)) + node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)) .value(); r = static_cast(c.red()); @@ -692,7 +692,7 @@ public: } OfxStatus set(double r, double g, double b) { - if (!node) { + if (!node_) { value_[0] = r; value_[1] = g; value_[2] = b; @@ -700,16 +700,16 @@ public: return kOfxStatOK; } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kColor, + NodeValue::k_color, QVariant::fromValue(olive::core::Color(r, g, b))); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, double r, double g, double b) { - if (!node) { + if (!node_) { value_[0] = r; value_[1] = g; value_[2] = b; @@ -717,14 +717,14 @@ public: return kOfxStatOK; } auto command = new MultiUndoCommand(); - const QString name = _descriptor.getName().c_str(); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), r, 0, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), g, 1, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), b, 2, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + const QString name = descriptor_.getName().c_str(); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), r, 0, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), g, 1, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), b, 2, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -732,8 +732,8 @@ public: class Double2DInstance : public OFX::Host::Param::Double2DInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; double value_[2] = { 0.0, 0.0 }; @@ -741,20 +741,20 @@ public: Double2DInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::Double2DInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::Double2DInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(double &x, double &y) { - if (!node) { + if (!node_) { if (has_value_) { x = value_[0]; y = value_[1]; @@ -763,21 +763,21 @@ public: } return kOfxStatOK; } - QVector2D vec = node->GetStandardValue(_descriptor.getName().c_str()) + QVector2D vec = node_->get_standard_value(descriptor_.getName().c_str()) .value(); x = static_cast(vec.x()); y = static_cast(vec.y()); - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - x = ToNormalised(x, xSize); - y = ToNormalised(y, ySize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + x = to_normalised(x, x_size); + y = to_normalised(y, y_size); } return kOfxStatOK; } OfxStatus get(OfxTime time, double &x, double &y) { - if (!node) { + if (!node_) { if (has_value_) { x = value_[0]; y = value_[1]; @@ -786,63 +786,63 @@ public: } return kOfxStatOK; } - QVector2D vec = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)) + QVector2D vec = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)) .value(); x = static_cast(vec.x()); y = static_cast(vec.y()); - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - x = ToNormalised(x, xSize); - y = ToNormalised(y, ySize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + x = to_normalised(x, x_size); + y = to_normalised(y, y_size); } return kOfxStatOK; } OfxStatus set(double x, double y) { - if (!node) { + if (!node_) { value_[0] = x; value_[1] = y; has_value_ = true; return kOfxStatOK; } double xv = x, yv = y; - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - xv = ToCanonical(xv, xSize); - yv = ToCanonical(yv, ySize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + xv = to_canonical(xv, x_size); + yv = to_canonical(yv, y_size); } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kVec2, QVector2D(xv, yv)); + NodeValue::k_vec2, QVector2D(xv, yv)); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, double x, double y) { - if (!node) { + if (!node_) { value_[0] = x; value_[1] = y; has_value_ = true; return kOfxStatOK; } double xv = x, yv = y; - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - xv = ToCanonical(xv, xSize); - yv = ToCanonical(yv, ySize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + xv = to_canonical(xv, x_size); + yv = to_canonical(yv, y_size); } auto command = new MultiUndoCommand(); - const QString name = _descriptor.getName().c_str(); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), xv, 0, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), yv, 1, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + const QString name = descriptor_.getName().c_str(); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), xv, 0, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), yv, 1, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -850,8 +850,8 @@ public: class Integer2DInstance : public OFX::Host::Param::Integer2DInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; int value_[2] = { 0, 0 }; @@ -859,20 +859,20 @@ public: Integer2DInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::Integer2DInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::Integer2DInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(int &x, int &y) { - if (!node) { + if (!node_) { if (has_value_) { x = value_[0]; y = value_[1]; @@ -881,7 +881,7 @@ public: } return kOfxStatOK; } - QVector2D vec = node->GetStandardValue(_descriptor.getName().c_str()) + QVector2D vec = node_->get_standard_value(descriptor_.getName().c_str()) .value(); x = static_cast(vec.x()); y = static_cast(vec.y()); @@ -889,7 +889,7 @@ public: } OfxStatus get(OfxTime time, int &x, int &y) { - if (!node) { + if (!node_) { if (has_value_) { x = value_[0]; y = value_[1]; @@ -898,8 +898,8 @@ public: } return kOfxStatOK; } - QVector2D vec = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)) + QVector2D vec = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)) .value(); x = static_cast(vec.x()); y = static_cast(vec.y()); @@ -907,34 +907,34 @@ public: } OfxStatus set(int x, int y) { - if (!node) { + if (!node_) { value_[0] = x; value_[1] = y; has_value_ = true; return kOfxStatOK; } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kVec2, QVector2D(x, y)); + NodeValue::k_vec2, QVector2D(x, y)); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, int x, int y) { - if (!node) { + if (!node_) { value_[0] = x; value_[1] = y; has_value_ = true; return kOfxStatOK; } auto command = new MultiUndoCommand(); - const QString name = _descriptor.getName().c_str(); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), x, 0, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), y, 1, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + const QString name = descriptor_.getName().c_str(); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), x, 0, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), y, 1, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -942,8 +942,8 @@ public: class Double3DInstance : public OFX::Host::Param::Double3DInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; double value_[3] = { 0.0, 0.0, 0.0 }; @@ -951,20 +951,20 @@ public: Double3DInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::Double3DInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::Double3DInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(double &x, double &y, double &z) { - if (!node) { + if (!node_) { if (has_value_) { x = value_[0]; y = value_[1]; @@ -974,23 +974,23 @@ public: } return kOfxStatOK; } - QVector3D vec = node->GetStandardValue(_descriptor.getName().c_str()) + QVector3D vec = node_->get_standard_value(descriptor_.getName().c_str()) .value(); x = static_cast(vec.x()); y = static_cast(vec.y()); z = static_cast(vec.z()); - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - x = ToNormalised(x, xSize); - y = ToNormalised(y, ySize); - z = ToNormalised(z, xSize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + x = to_normalised(x, x_size); + y = to_normalised(y, y_size); + z = to_normalised(z, x_size); } return kOfxStatOK; } OfxStatus get(OfxTime time, double &x, double &y, double &z) { - if (!node) { + if (!node_) { if (has_value_) { x = value_[0]; y = value_[1]; @@ -1000,24 +1000,24 @@ public: } return kOfxStatOK; } - QVector3D vec = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)) + QVector3D vec = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)) .value(); x = static_cast(vec.x()); y = static_cast(vec.y()); z = static_cast(vec.z()); - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - x = ToNormalised(x, xSize); - y = ToNormalised(y, ySize); - z = ToNormalised(z, xSize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + x = to_normalised(x, x_size); + y = to_normalised(y, y_size); + z = to_normalised(z, x_size); } return kOfxStatOK; } OfxStatus set(double x, double y, double z) { - if (!node) { + if (!node_) { value_[0] = x; value_[1] = y; value_[2] = z; @@ -1025,23 +1025,23 @@ public: return kOfxStatOK; } double xv = x, yv = y, zv = z; - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - xv = ToCanonical(xv, xSize); - yv = ToCanonical(yv, ySize); - zv = ToCanonical(zv, xSize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + xv = to_canonical(xv, x_size); + yv = to_canonical(yv, y_size); + zv = to_canonical(zv, x_size); } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kVec3, QVector3D(xv, yv, zv)); + NodeValue::k_vec3, QVector3D(xv, yv, zv)); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, double x, double y, double z) { - if (!node) { + if (!node_) { value_[0] = x; value_[1] = y; value_[2] = z; @@ -1049,22 +1049,22 @@ public: return kOfxStatOK; } double xv = x, yv = y, zv = z; - if (IsNormalisedCoordinateSystem(_descriptor)) { - double xSize, ySize; - GetProjectExtent(xSize, ySize); - xv = ToCanonical(xv, xSize); - yv = ToCanonical(yv, ySize); - zv = ToCanonical(zv, xSize); + if (is_normalised_coordinate_system(descriptor_)) { + double x_size, y_size; + get_project_extent(x_size, y_size); + xv = to_canonical(xv, x_size); + yv = to_canonical(yv, y_size); + zv = to_canonical(zv, x_size); } auto command = new MultiUndoCommand(); - const QString name = _descriptor.getName().c_str(); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), xv, 0, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), yv, 1, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), zv, 2, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + const QString name = descriptor_.getName().c_str(); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), xv, 0, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), yv, 1, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), zv, 2, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -1072,8 +1072,8 @@ public: class Integer3DInstance : public OFX::Host::Param::Integer3DInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; int value_[3] = { 0, 0, 0 }; @@ -1081,20 +1081,20 @@ public: Integer3DInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::Integer3DInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::Integer3DInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(int &x, int &y, int &z) { - if (!node) { + if (!node_) { if (has_value_) { x = value_[0]; y = value_[1]; @@ -1104,7 +1104,7 @@ public: } return kOfxStatOK; } - QVector3D vec = node->GetStandardValue(_descriptor.getName().c_str()) + QVector3D vec = node_->get_standard_value(descriptor_.getName().c_str()) .value(); x = static_cast(vec.x()); y = static_cast(vec.y()); @@ -1113,7 +1113,7 @@ public: } OfxStatus get(OfxTime time, int &x, int &y, int &z) { - if (!node) { + if (!node_) { if (has_value_) { x = value_[0]; y = value_[1]; @@ -1123,8 +1123,8 @@ public: } return kOfxStatOK; } - QVector3D vec = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)) + QVector3D vec = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)) .value(); x = static_cast(vec.x()); y = static_cast(vec.y()); @@ -1133,7 +1133,7 @@ public: } OfxStatus set(int x, int y, int z) { - if (!node) { + if (!node_) { value_[0] = x; value_[1] = y; value_[2] = z; @@ -1141,15 +1141,15 @@ public: return kOfxStatOK; } SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kVec3, QVector3D(x, y, z)); + NodeValue::k_vec3, QVector3D(x, y, z)); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, int x, int y, int z) { - if (!node) { + if (!node_) { value_[0] = x; value_[1] = y; value_[2] = z; @@ -1157,14 +1157,14 @@ public: return kOfxStatOK; } auto command = new MultiUndoCommand(); - const QString name = _descriptor.getName().c_str(); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), x, 0, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), y, 1, command, true); - Node::SetValueAtTime(NodeInput(node.get(), name), - rational::fromDouble(time), z, 2, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + const QString name = descriptor_.getName().c_str(); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), x, 0, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), y, 1, command, true); + Node::set_value_at_time(NodeInput(node_.get(), name), + Rational::from_double(time), z, 2, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -1172,22 +1172,22 @@ public: class StringInstance : public OFX::Host::Param::StringInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; std::string value_; public: StringInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::StringInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::StringInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; try { - value_ = _descriptor.getProperties().getStringProperty( + value_ = descriptor_.getProperties().getStringProperty( kOfxParamPropDefault); has_value_ = true; } catch (...) { @@ -1195,18 +1195,18 @@ public: has_value_ = false; } } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(std::string &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : std::string(); return kOfxStatOK; } QVariant variant = - node->GetStandardValue(_descriptor.getName().c_str()); + node_->get_standard_value(descriptor_.getName().c_str()); if (variant.canConvert()) { data = variant.toString().toStdString(); return kOfxStatOK; @@ -1216,12 +1216,12 @@ public: } OfxStatus get(OfxTime time, std::string &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : std::string(); return kOfxStatOK; } - QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)); + QVariant variant = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)); if (variant.canConvert()) { data = variant.toString().toStdString(); return kOfxStatOK; @@ -1231,32 +1231,32 @@ public: } OfxStatus set(const char *data) { - if (!node) { + if (!node_) { value_ = data ? data : ""; has_value_ = true; return kOfxStatOK; } QString v = QString::fromUtf8(data); SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kText, v); + NodeValue::k_text, v); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, const char *data) { - if (!node) { + if (!node_) { value_ = data ? data : ""; has_value_ = true; return kOfxStatOK; } auto command = new MultiUndoCommand(); - Node::SetValueAtTime(NodeInput(node.get(), - _descriptor.getName().c_str()), - rational::fromDouble(time), + Node::set_value_at_time(NodeInput(node_.get(), + descriptor_.getName().c_str()), + Rational::from_double(time), QString::fromUtf8(data), 0, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -1264,33 +1264,33 @@ public: class CustomInstance : public OFX::Host::Param::CustomInstance, public NodeBoundParam { protected: - std::shared_ptr node; - OFX::Host::Param::Descriptor &_descriptor; + std::shared_ptr node_; + OFX::Host::Param::Descriptor &descriptor_; bool has_value_ = false; std::string value_; public: CustomInstance(std::shared_ptr effect, const std::string &name, OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::CustomInstance(descriptor, paramSet) - , node(effect) - , _descriptor(descriptor) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::CustomInstance(descriptor, param_set) + , node_(effect) + , descriptor_(descriptor) { (void)name; } - void SetNode(const std::shared_ptr &new_node) override + void set_node(const std::shared_ptr &new_node) override { - node = new_node; + node_ = new_node; } OfxStatus get(std::string &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : std::string(); return kOfxStatOK; } QVariant variant = - node->GetStandardValue(_descriptor.getName().c_str()); + node_->get_standard_value(descriptor_.getName().c_str()); if (variant.canConvert()) { data = variant.toByteArray().toStdString(); return kOfxStatOK; @@ -1304,12 +1304,12 @@ public: } OfxStatus get(OfxTime time, std::string &data) { - if (!node) { + if (!node_) { data = has_value_ ? value_ : std::string(); return kOfxStatOK; } - QVariant variant = node->GetValueAtTime(_descriptor.getName().c_str(), - rational::fromDouble(time)); + QVariant variant = node_->get_value_at_time(descriptor_.getName().c_str(), + Rational::from_double(time)); if (variant.canConvert()) { data = variant.toByteArray().toStdString(); return kOfxStatOK; @@ -1323,31 +1323,31 @@ public: } OfxStatus set(const char *data) { - if (!node) { + if (!node_) { value_ = data ? data : ""; has_value_ = true; return kOfxStatOK; } QByteArray v = QByteArray(data); SplitValue split = NodeValue::split_normal_value_into_track_values( - NodeValue::kBinary, v); + NodeValue::k_binary, v); auto command = new NodeParamSetSplitStandardValueCommand( - NodeInput(node.get(), _descriptor.getName().c_str()), split); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + NodeInput(node_.get(), descriptor_.getName().c_str()), split); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } OfxStatus set(OfxTime time, const char *data) { - if (!node) { + if (!node_) { value_ = data ? data : ""; has_value_ = true; return kOfxStatOK; } auto command = new MultiUndoCommand(); - Node::SetValueAtTime( - NodeInput(node.get(), _descriptor.getName().c_str()), - rational::fromDouble(time), QByteArray(data), 0, command, true); - SubmitUndoCommand(node, command, ParamChangeLabel(_descriptor)); + Node::set_value_at_time( + NodeInput(node_.get(), descriptor_.getName().c_str()), + Rational::from_double(time), QByteArray(data), 0, command, true); + submit_undo_command(node_, command, param_change_label(descriptor_)); return kOfxStatOK; } }; @@ -1355,8 +1355,8 @@ public: class GroupInstance : public OFX::Host::Param::GroupInstance { public: GroupInstance(OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::GroupInstance(descriptor, paramSet) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::GroupInstance(descriptor, param_set) { } }; @@ -1364,8 +1364,8 @@ public: class PageInstance : public OFX::Host::Param::PageInstance { public: PageInstance(OFX::Host::Param::Descriptor &descriptor, - OFX::Host::Param::SetInstance *paramSet = nullptr) - : OFX::Host::Param::PageInstance(descriptor, paramSet) + OFX::Host::Param::SetInstance *param_set = nullptr) + : OFX::Host::Param::PageInstance(descriptor, param_set) { } }; diff --git a/app/render/alphaassoc.h b/app/render/alphaassoc.h index 977afe35b..7294611a7 100644 --- a/app/render/alphaassoc.h +++ b/app/render/alphaassoc.h @@ -19,14 +19,14 @@ ***/ -#ifndef ALPHAASSOC_H -#define ALPHAASSOC_H +#ifndef OAK_ALPHAASSOC_H +#define OAK_ALPHAASSOC_H namespace olive { -enum AlphaAssociated { kAlphaNone, kAlphaUnassociated, kAlphaAssociated }; +enum AlphaAssociated { k_alpha_none, k_alpha_unassociated, k_alpha_associated }; } -#endif // ALPHAASSOC_H +#endif // OAK_ALPHAASSOC_H diff --git a/app/render/audioplaybackcache.cpp b/app/render/audioplaybackcache.cpp index 173a9ad3c..0e83a696b 100644 --- a/app/render/audioplaybackcache.cpp +++ b/app/render/audioplaybackcache.cpp @@ -32,7 +32,7 @@ namespace olive { -const qint64 AudioPlaybackCache::kDefaultSegmentSizePerChannel = +const qint64 AudioPlaybackCache::k_default_segment_size_per_channel = 10 * 1024 * 1024; AudioPlaybackCache::AudioPlaybackCache(QObject *parent) @@ -44,7 +44,7 @@ AudioPlaybackCache::~AudioPlaybackCache() { } -void AudioPlaybackCache::SetParameters(const AudioParams ¶ms) +void AudioPlaybackCache::set_parameters(const AudioParams ¶ms) { if (params_ == params) { return; @@ -53,29 +53,29 @@ void AudioPlaybackCache::SetParameters(const AudioParams ¶ms) params_ = params; } -void AudioPlaybackCache::WritePCM(const TimeRange &range, +void AudioPlaybackCache::write_pcm(const TimeRange &range, const TimeRangeList &valid_ranges, const SampleBuffer &samples) { for (const TimeRange &r : valid_ranges) { - if (WritePartOfSampleBuffer(samples, r.in(), r.in() - range.in(), + if (write_part_of_sample_buffer(samples, r.in(), r.in() - range.in(), r.length())) { - Validate(r); + validate(r); } } } -void AudioPlaybackCache::WriteSilence(const TimeRange &range) +void AudioPlaybackCache::write_silence(const TimeRange &range) { // WritePCM will automatically fill non-existent bytes with silence, so we just have to send // it an empty sample buffer - WritePCM(range, { range }, SampleBuffer()); + write_pcm(range, { range }, SampleBuffer()); } -bool AudioPlaybackCache::WritePartOfSampleBuffer(const SampleBuffer &samples, - const rational &write_start, - const rational &buffer_start, - const rational &length) +bool AudioPlaybackCache::write_part_of_sample_buffer(const SampleBuffer &samples, + const Rational &write_start, + const Rational &buffer_start, + const Rational &length) { int64_t length_in_bytes = params_.time_to_bytes_per_channel(length); @@ -94,9 +94,9 @@ bool AudioPlaybackCache::WritePartOfSampleBuffer(const SampleBuffer &samples, bool success = true; while (current_cache_offset != end_cache_offset) { - int64_t segment = current_cache_offset / kDefaultSegmentSizePerChannel; - int64_t segment_start = segment * kDefaultSegmentSizePerChannel; - int64_t segment_end = segment_start + kDefaultSegmentSizePerChannel; + int64_t segment = current_cache_offset / k_default_segment_size_per_channel; + int64_t segment_start = segment * k_default_segment_size_per_channel; + int64_t segment_end = segment_start + k_default_segment_size_per_channel; int64_t offset_in_segment = current_cache_offset - segment_start; // Never write past the end of the requested range @@ -111,9 +111,9 @@ bool AudioPlaybackCache::WritePartOfSampleBuffer(const SampleBuffer &samples, } for (int channel = 0; channel < params_.channel_count(); channel++) { - QString filename = GetSegmentFilename(segment, channel); + QString filename = get_segment_filename(segment, channel); - if (!FileFunctions::DirectoryIsValid(QFileInfo(filename).dir())) { + if (!FileFunctions::directory_is_valid(QFileInfo(filename).dir())) { success = false; break; } @@ -147,10 +147,10 @@ bool AudioPlaybackCache::WritePartOfSampleBuffer(const SampleBuffer &samples, return success; } -QString AudioPlaybackCache::GetSegmentFilename(qint64 segment_index, +QString AudioPlaybackCache::get_segment_filename(qint64 segment_index, int channel) { - return GetThisCacheDirectory().filePath(QStringLiteral("%1.%2").arg( + return get_this_cache_directory().filePath(QStringLiteral("%1.%2").arg( QString::number(segment_index), QString::number(channel))); } diff --git a/app/render/audioplaybackcache.h b/app/render/audioplaybackcache.h index 21776fc37..8eab10e8a 100644 --- a/app/render/audioplaybackcache.h +++ b/app/render/audioplaybackcache.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUDIOPLAYBACKCACHE_H -#define AUDIOPLAYBACKCACHE_H +#ifndef OAK_AUDIOPLAYBACKCACHE_H +#define OAK_AUDIOPLAYBACKCACHE_H #include "audio/audiovisualwaveform.h" #include "render/playbackcache.h" @@ -58,31 +58,31 @@ public: virtual ~AudioPlaybackCache() override; - AudioParams GetParameters() + AudioParams get_parameters() { return params_; } - void SetParameters(const AudioParams ¶ms); + void set_parameters(const AudioParams ¶ms); - void WritePCM(const TimeRange &range, const TimeRangeList &valid_ranges, + void write_pcm(const TimeRange &range, const TimeRangeList &valid_ranges, const SampleBuffer &samples); - void WriteSilence(const TimeRange &range); + void write_silence(const TimeRange &range); private: - bool WritePartOfSampleBuffer(const SampleBuffer &samples, - const rational &write_start, - const rational &buffer_start, - const rational &length); + bool write_part_of_sample_buffer(const SampleBuffer &samples, + const Rational &write_start, + const Rational &buffer_start, + const Rational &length); - QString GetSegmentFilename(qint64 segment_index, int channel); + QString get_segment_filename(qint64 segment_index, int channel); - static const qint64 kDefaultSegmentSizePerChannel; + static const qint64 k_default_segment_size_per_channel; AudioParams params_; }; } -#endif // AUDIOPLAYBACKCACHE_H +#endif // OAK_AUDIOPLAYBACKCACHE_H diff --git a/app/render/audiowaveformcache.cpp b/app/render/audiowaveformcache.cpp index 438177782..9117d2d0c 100644 --- a/app/render/audiowaveformcache.cpp +++ b/app/render/audiowaveformcache.cpp @@ -32,51 +32,51 @@ AudioWaveformCache::AudioWaveformCache(QObject *parent) waveforms_ = std::make_shared(); } -void AudioWaveformCache::WriteWaveform(const TimeRange &range, +void AudioWaveformCache::write_waveform(const TimeRange &range, const TimeRangeList &valid_ranges, const AudioVisualWaveform *waveform) { // Write each valid range to the segments foreach (const TimeRange &r, valid_ranges) { if (waveform) { - waveforms_->OverwriteSums(*waveform, r.in(), r.in() - range.in(), + waveforms_->overwrite_sums(*waveform, r.in(), r.in() - range.in(), r.length()); } - Validate(r); + validate(r); } } -void DrawSubRect(QPainter *painter, const QRect &rect, const double &scale, +void draw_sub_rect(QPainter *painter, const QRect &rect, const double &scale, const TimeRange &wave_range, const AudioVisualWaveform &waveform, const TimeRange &subrange) { // Find start time of passthrough - TimeRange intersect = wave_range.Intersected(subrange); + TimeRange intersect = wave_range.intersected(subrange); // Create new rect that starts at the offset of pass_start from start_time // Set rect width to either length of passthrough or until the end QRect pass_rect( - rect.x() + (intersect.in() - wave_range.in()).toDouble() * scale, - rect.y(), intersect.length().toDouble() * scale, rect.height()); + rect.x() + (intersect.in() - wave_range.in()).to_double() * scale, + rect.y(), intersect.length().to_double() * scale, rect.height()); // Draw waveform with this info - AudioVisualWaveform::DrawWaveform(painter, pass_rect, scale, waveform, + AudioVisualWaveform::draw_waveform(painter, pass_rect, scale, waveform, intersect.in()); } void AudioWaveformCache::Draw(QPainter *painter, const QRect &rect, const double &scale, - const rational &start_time) const + const Rational &start_time) const { if (!passthroughs_.empty()) { TimeRange wave_range(start_time, start_time + - rational::fromDouble(rect.width() / scale)); + Rational::from_double(rect.width() / scale)); TimeRangeList draw_range = { wave_range }; for (const WaveformPassthrough &p : passthroughs_) { - if (draw_range.OverlapsWith(p, true, false)) { - DrawSubRect(painter, rect, scale, wave_range, *p.waveform, p); + if (draw_range.overlaps_with(p, true, false)) { + draw_sub_rect(painter, rect, scale, wave_range, *p.waveform, p); // Remove this range draw_range.remove(p); @@ -84,31 +84,31 @@ void AudioWaveformCache::Draw(QPainter *painter, const QRect &rect, } for (const TimeRange &r : draw_range) { - DrawSubRect(painter, rect, scale, wave_range, *waveforms_, r); + draw_sub_rect(painter, rect, scale, wave_range, *waveforms_, r); } } else { - AudioVisualWaveform::DrawWaveform(painter, rect, scale, *waveforms_, + AudioVisualWaveform::draw_waveform(painter, rect, scale, *waveforms_, start_time); } } AudioVisualWaveform::Sample -AudioWaveformCache::GetSummaryFromTime(const rational &start, - const rational &length) const +AudioWaveformCache::get_summary_from_time(const Rational &start, + const Rational &length) const { - return waveforms_->GetSummaryFromTime(start, length); + return waveforms_->get_summary_from_time(start, length); } -rational AudioWaveformCache::length() const +Rational AudioWaveformCache::length() const { return waveforms_->length(); } -void AudioWaveformCache::SetPassthrough(PlaybackCache *cache) +void AudioWaveformCache::set_passthrough(PlaybackCache *cache) { AudioWaveformCache *c = static_cast(cache); - for (const TimeRange &r : c->GetValidatedRanges()) { + for (const TimeRange &r : c->get_validated_ranges()) { WaveformPassthrough t = r; t.waveform = c->waveforms_; passthroughs_.push_back(t); @@ -116,8 +116,8 @@ void AudioWaveformCache::SetPassthrough(PlaybackCache *cache) passthroughs_.insert(passthroughs_.end(), c->passthroughs_.begin(), c->passthroughs_.end()); - SetParameters(c->GetParameters()); - SetSavingEnabled(c->IsSavingEnabled()); + set_parameters(c->get_parameters()); + set_saving_enabled(c->is_saving_enabled()); } void AudioWaveformCache::InvalidateEvent(const TimeRange &range) diff --git a/app/render/audiowaveformcache.h b/app/render/audiowaveformcache.h index 68b927e84..47cca2a2b 100644 --- a/app/render/audiowaveformcache.h +++ b/app/render/audiowaveformcache.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUDIOWAVEFORMCACHE_H -#define AUDIOWAVEFORMCACHE_H +#ifndef OAK_AUDIOWAVEFORMCACHE_H +#define OAK_AUDIOWAVEFORMCACHE_H #include "audio/audiovisualwaveform.h" #include "playbackcache.h" @@ -33,29 +33,29 @@ class AudioWaveformCache : public PlaybackCache { public: AudioWaveformCache(QObject *parent = nullptr); - void WriteWaveform(const TimeRange &range, + void write_waveform(const TimeRange &range, const TimeRangeList &valid_ranges, const AudioVisualWaveform *waveform); - const AudioParams &GetParameters() const + const AudioParams &get_parameters() const { return params_; } - void SetParameters(const AudioParams &p) + void set_parameters(const AudioParams &p) { params_ = p; waveforms_->set_channel_count(p.channel_count()); } void Draw(QPainter *painter, const QRect &rect, const double &scale, - const rational &start_time) const; + const Rational &start_time) const; AudioVisualWaveform::Sample - GetSummaryFromTime(const rational &start, const rational &length) const; + get_summary_from_time(const Rational &start, const Rational &length) const; - rational length() const; + Rational length() const; - virtual void SetPassthrough(PlaybackCache *cache) override; + virtual void set_passthrough(PlaybackCache *cache) override; protected: virtual void InvalidateEvent(const TimeRange &range) override; @@ -82,4 +82,4 @@ private: } -#endif // AUDIOWAVEFORMCACHE_H +#endif // OAK_AUDIOWAVEFORMCACHE_H diff --git a/app/render/backend/dynamicrenderer.cpp b/app/render/backend/dynamicrenderer.cpp index ee72751c9..14a9e9e6f 100644 --- a/app/render/backend/dynamicrenderer.cpp +++ b/app/render/backend/dynamicrenderer.cpp @@ -21,8 +21,8 @@ DynamicRenderer::DynamicRenderer(const QString &backend, QObject *parent) // resources, destroy the opaque backend object, then unload the shared library. DynamicRenderer::~DynamicRenderer() { - Destroy(); - PostDestroy(); + destroy(); + post_destroy(); if (handle_ && destroy_) { destroy_(handle_); handle_ = nullptr; @@ -35,7 +35,7 @@ DynamicRenderer::~DynamicRenderer() // Builds the private backend library path for the current platform. // The search is intentionally restricted to Oak-controlled directories so a // system libGL/libvulkan loader is never mistaken for an Oak render backend. -QString DynamicRenderer::LibraryFilename() const +QString DynamicRenderer::library_filename() const { QString base; if (backend_ == QStringLiteral("opengl")) { @@ -78,20 +78,20 @@ QString DynamicRenderer::LibraryFilename() const // Loads the selected backend, resolves its C ABI table, creates the opaque // backend object, and optionally falls back from Vulkan to OpenGL when runtime // availability checks fail. -bool DynamicRenderer::Load() +bool DynamicRenderer::load() { if (handle_) { return true; } - library_.setFileName(LibraryFilename()); + library_.setFileName(library_filename()); if (!library_.load()) { if (backend_ == QStringLiteral("vulkan")) { qWarning() << "Failed to load Vulkan render backend" << library_.fileName() << library_.errorString() << "falling back to OpenGL backend"; backend_ = QStringLiteral("opengl"); - library_.setFileName(LibraryFilename()); + library_.setFileName(library_filename()); } if (!library_.load()) { @@ -101,7 +101,7 @@ bool DynamicRenderer::Load() } } - if (!ResolveFunctions()) { + if (!resolve_functions()) { qWarning() << "Render backend is missing required symbols" << backend_; library_.unload(); return false; @@ -121,7 +121,7 @@ bool DynamicRenderer::Load() qWarning() << "Render backend is not available" << backend_ << library_.fileName(); if (backend_ == QStringLiteral("vulkan")) { - return FallbackToOpenGL(); + return fallback_to_open_gl(); } destroy_(handle_); handle_ = nullptr; @@ -133,9 +133,9 @@ bool DynamicRenderer::Load() // Resolves the mandatory C ABI entry points from the loaded shared library. // Optional information probes are resolved after the required render interface. -bool DynamicRenderer::ResolveFunctions() +bool DynamicRenderer::resolve_functions() { - ResetFunctions(); + reset_functions(); #define RESOLVE(member, type, symbol) \ member = reinterpret_cast(library_.resolve(symbol)); \ if (!member) \ @@ -185,7 +185,7 @@ bool DynamicRenderer::ResolveFunctions() // Discards a partially-created backend and restarts loading with the OpenGL // backend. This keeps RenderManager's fallback path inside the adapter. -bool DynamicRenderer::FallbackToOpenGL() +bool DynamicRenderer::fallback_to_open_gl() { if (handle_ && destroy_) { destroy_(handle_); @@ -194,14 +194,14 @@ bool DynamicRenderer::FallbackToOpenGL() if (library_.isLoaded()) { library_.unload(); } - ResetFunctions(); + reset_functions(); backend_ = QStringLiteral("opengl"); - return Load(); + return load(); } // Clears all cached C function pointers so a failed backend cannot leave stale // call targets behind for a later fallback load. -void DynamicRenderer::ResetFunctions() +void DynamicRenderer::reset_functions() { create_ = nullptr; destroy_ = nullptr; @@ -228,22 +228,22 @@ void DynamicRenderer::ResetFunctions() } // Returns backend metadata exposed by the dynamic library when available. -bool DynamicRenderer::GetBackendInfo(OakRenderBackendInfo *out_info) const +bool DynamicRenderer::get_backend_info(OakRenderBackendInfo *out_info) const { return handle_ && get_info_ && out_info && get_info_(handle_, out_info); } // Initializes the loaded backend using its own context/device creation path. -bool DynamicRenderer::Init() +bool DynamicRenderer::init() { - return Load() && init_(handle_); + return load() && init_(handle_); } // Initializes an OpenGL backend against an existing widget context; non-OpenGL // backends may ignore the context on the library side. -bool DynamicRenderer::InitWithOpenGLContext(QOpenGLContext *context) +bool DynamicRenderer::init_with_open_gl_context(QOpenGLContext *context) { - if (!Load()) { + if (!load()) { return false; } init_with_context_(handle_, context); @@ -252,7 +252,7 @@ bool DynamicRenderer::InitWithOpenGLContext(QOpenGLContext *context) // Forwards post-destroy cleanup to the backend while the library is still // loaded and its symbols are still valid. -void DynamicRenderer::PostDestroy() +void DynamicRenderer::post_destroy() { if (handle_ && post_destroy_) { post_destroy_(handle_); @@ -261,7 +261,7 @@ void DynamicRenderer::PostDestroy() // Runs backend post-initialization after Init/InitWithOpenGLContext has // established the device or GL context. -void DynamicRenderer::PostInit() +void DynamicRenderer::post_init() { if (handle_) { post_init_(handle_); @@ -269,7 +269,7 @@ void DynamicRenderer::PostInit() } // Forwards render target clearing through the C ABI. -void DynamicRenderer::ClearDestination(Texture *texture, double r, double g, +void DynamicRenderer::clear_destination(Texture *texture, double r, double g, double b, double a) { clear_destination_(handle_, texture, r, g, b, a); @@ -277,7 +277,7 @@ void DynamicRenderer::ClearDestination(Texture *texture, double r, double g, // Creates a backend-native shader and receives the result as an opaque QVariant // because this first-generation ABI still shares C++/Qt types between modules. -QVariant DynamicRenderer::CreateNativeShader(ShaderCode code) +QVariant DynamicRenderer::create_native_shader(ShaderCode code) { QVariant out; create_native_shader_(handle_, &code, &out); @@ -285,13 +285,13 @@ QVariant DynamicRenderer::CreateNativeShader(ShaderCode code) } // Releases a backend-native shader handle. -void DynamicRenderer::DestroyNativeShader(QVariant shader) +void DynamicRenderer::destroy_native_shader(QVariant shader) { destroy_native_shader_(handle_, &shader); } // Uploads CPU pixel data into a backend texture through the dynamic ABI. -void DynamicRenderer::UploadToTexture(const QVariant &handle, +void DynamicRenderer::upload_to_texture(const QVariant &handle, const VideoParams ¶ms, const void *data, int linesize) { @@ -299,7 +299,7 @@ void DynamicRenderer::UploadToTexture(const QVariant &handle, } // Downloads backend texture data into a caller-provided CPU buffer. -void DynamicRenderer::DownloadFromTexture(const QVariant &handle, +void DynamicRenderer::download_from_texture(const QVariant &handle, const VideoParams ¶ms, void *data, int linesize) { @@ -307,13 +307,13 @@ void DynamicRenderer::DownloadFromTexture(const QVariant &handle, } // Waits for backend work to become visible to subsequent CPU or GPU consumers. -void DynamicRenderer::Flush() +void DynamicRenderer::flush() { flush_(handle_); } // Reads a single pixel through the backend-provided readback hook. -Color DynamicRenderer::GetPixelFromTexture(Texture *texture, const QPointF &pt) +Color DynamicRenderer::get_pixel_from_texture(Texture *texture, const QPointF &pt) { Color out; get_pixel_from_texture_(handle_, texture, &pt, &out); @@ -322,7 +322,7 @@ Color DynamicRenderer::GetPixelFromTexture(Texture *texture, const QPointF &pt) // Exposes the wrapped OpenGL context when the backend is OpenGL; Vulkan returns // null so callers can avoid GL-only paths. -QOpenGLContext *DynamicRenderer::OpenGLContext() const +QOpenGLContext *DynamicRenderer::open_gl_context() const { return opengl_context_ && handle_ ? static_cast(opengl_context_(handle_)) : @@ -330,18 +330,18 @@ QOpenGLContext *DynamicRenderer::OpenGLContext() const } // Reports the effective backend after any load-time fallback has completed. -bool DynamicRenderer::IsOpenGL() const +bool DynamicRenderer::is_open_gl() const { return backend_ == QStringLiteral("opengl"); } -bool DynamicRenderer::IsVulkan() const +bool DynamicRenderer::is_vulkan() const { return backend_ == QStringLiteral("vulkan"); } // Dispatches a shader blit to the loaded backend. -void DynamicRenderer::Blit(QVariant shader, AcceleratedJob &job, +void DynamicRenderer::blit(QVariant shader, AcceleratedJob &job, Texture *destination, VideoParams destination_params, bool clear_destination) { @@ -350,7 +350,7 @@ void DynamicRenderer::Blit(QVariant shader, AcceleratedJob &job, } // Allocates a backend-native texture and wraps its opaque handle in QVariant. -QVariant DynamicRenderer::CreateNativeTexture(int width, int height, int depth, +QVariant DynamicRenderer::create_native_texture(int width, int height, int depth, PixelFormat format, int channel_count, const void *data, int linesize) @@ -362,14 +362,14 @@ QVariant DynamicRenderer::CreateNativeTexture(int width, int height, int depth, } // Releases a backend-native texture handle. -void DynamicRenderer::DestroyNativeTexture(QVariant texture) +void DynamicRenderer::destroy_native_texture(QVariant texture) { destroy_native_texture_(handle_, &texture); } // Releases renderer-owned backend resources before the backend object itself is // destroyed. -void DynamicRenderer::DestroyInternal() +void DynamicRenderer::destroy_internal() { if (handle_) { destroy_internal_(handle_); @@ -377,7 +377,7 @@ void DynamicRenderer::DestroyInternal() } // Exposes OFX OpenGL output binding through the dynamic backend when supported. -void DynamicRenderer::AttachOutputTexture(Texture *texture) +void DynamicRenderer::attach_output_texture(Texture *texture) { if (attach_output_texture_ && texture) { QVariant id = texture->id(); @@ -386,7 +386,7 @@ void DynamicRenderer::AttachOutputTexture(Texture *texture) } // Clears any OFX output texture binding owned by the backend. -void DynamicRenderer::DetachOutputTexture() +void DynamicRenderer::detach_output_texture() { if (detach_output_texture_) { detach_output_texture_(handle_); diff --git a/app/render/backend/dynamicrenderer.h b/app/render/backend/dynamicrenderer.h index 5ea0b684b..3c3ca563d 100644 --- a/app/render/backend/dynamicrenderer.h +++ b/app/render/backend/dynamicrenderer.h @@ -1,5 +1,5 @@ -#ifndef DYNAMICRENDERER_H -#define DYNAMICRENDERER_H +#ifndef OAK_DYNAMICRENDERER_H +#define OAK_DYNAMICRENDERER_H #include #include @@ -21,14 +21,14 @@ public: // Destroys backend resources and unloads the dynamic library. virtual ~DynamicRenderer() override; - using Renderer::Blit; + using Renderer::blit; // Loads the backend library, resolves C ABI symbols, and creates the handle. - bool Load(); + bool load(); // Initializes an OpenGL backend with a caller-owned viewer context. - bool InitWithOpenGLContext(QOpenGLContext *context); + bool init_with_open_gl_context(QOpenGLContext *context); // Retrieves backend metadata through the optional info entry point. - bool GetBackendInfo(OakRenderBackendInfo *out_info) const; + bool get_backend_info(OakRenderBackendInfo *out_info) const; // Returns the effective backend after any load-time fallback. QString backend_name() const { @@ -36,70 +36,70 @@ public: } // Initializes the backend using its default device/context path. - virtual bool Init() override; + virtual bool init() override; // Runs backend post-destroy cleanup. - virtual void PostDestroy() override; + virtual void post_destroy() override; // Runs backend post-init setup. - virtual void PostInit() override; + virtual void post_init() override; // Clears either a native texture destination or the backend output target. - virtual void ClearDestination(Texture *texture = nullptr, double r = 0.0, + virtual void clear_destination(Texture *texture = nullptr, double r = 0.0, double g = 0.0, double b = 0.0, double a = 0.0) override; // Creates a native shader through the dynamic backend. - virtual QVariant CreateNativeShader(ShaderCode code) override; + virtual QVariant create_native_shader(ShaderCode code) override; // Destroys a native shader through the dynamic backend. - virtual void DestroyNativeShader(QVariant shader) override; + virtual void destroy_native_shader(QVariant shader) override; // Uploads CPU pixels to a backend texture. - virtual void UploadToTexture(const QVariant &handle, + virtual void upload_to_texture(const QVariant &handle, const VideoParams ¶ms, const void *data, int linesize) override; // Downloads backend texture pixels to CPU memory. - virtual void DownloadFromTexture(const QVariant &handle, + virtual void download_from_texture(const QVariant &handle, const VideoParams ¶ms, void *data, int linesize) override; // Waits for backend work to complete. - virtual void Flush() override; + virtual void flush() override; // Reads one pixel from a backend texture. - virtual Color GetPixelFromTexture(Texture *texture, + virtual Color get_pixel_from_texture(Texture *texture, const QPointF &pt) override; // Returns the wrapped OpenGL context for OpenGL backends. - virtual QOpenGLContext *OpenGLContext() const override; + virtual QOpenGLContext *open_gl_context() const override; // Reports whether the effective backend is OpenGL. - virtual bool IsOpenGL() const override; + virtual bool is_open_gl() const override; // Reports whether the effective backend is Vulkan. - virtual bool IsVulkan() const override; + virtual bool is_vulkan() const override; // Attaches a texture for OFX OpenGL output when supported. - virtual void AttachOutputTexture(Texture *texture) override; + virtual void attach_output_texture(Texture *texture) override; // Detaches any OFX output texture binding when supported. - virtual void DetachOutputTexture() override; + virtual void detach_output_texture() override; protected: // Dispatches a shader blit through the dynamic backend. - virtual void Blit(QVariant shader, AcceleratedJob &job, + virtual void blit(QVariant shader, AcceleratedJob &job, Texture *destination, VideoParams destination_params, bool clear_destination) override; // Allocates a native texture through the dynamic backend. - virtual QVariant CreateNativeTexture(int width, int height, int depth, + virtual QVariant create_native_texture(int width, int height, int depth, PixelFormat format, int channel_count, const void *data = nullptr, int linesize = 0) override; // Releases a native texture through the dynamic backend. - virtual void DestroyNativeTexture(QVariant texture) override; + virtual void destroy_native_texture(QVariant texture) override; // Releases backend-owned renderer resources. - virtual void DestroyInternal() override; + virtual void destroy_internal() override; private: // Resolves required backend C ABI symbols. - bool ResolveFunctions(); + bool resolve_functions(); // Replaces a failed Vulkan backend with OpenGL. - bool FallbackToOpenGL(); + bool fallback_to_open_gl(); // Clears all cached function pointers. - void ResetFunctions(); + void reset_functions(); // Resolves the private backend library path. - QString LibraryFilename() const; + QString library_filename() const; QString backend_; QLibrary library_; @@ -131,4 +131,4 @@ private: } -#endif // DYNAMICRENDERER_H +#endif // OAK_DYNAMICRENDERER_H diff --git a/app/render/backend/renderbackend_c.h b/app/render/backend/renderbackend_c.h index 11ebc0ea3..817ea533d 100644 --- a/app/render/backend/renderbackend_c.h +++ b/app/render/backend/renderbackend_c.h @@ -1,5 +1,5 @@ -#ifndef RENDERBACKEND_C_H -#define RENDERBACKEND_C_H +#ifndef OAK_RENDERBACKEND_C_H +#define OAK_RENDERBACKEND_C_H #include #include @@ -20,20 +20,20 @@ typedef void *OakRenderBackendHandle; /* Identifies the concrete backend behind a dynamically loaded library. */ enum OakRenderBackendKind { - OAK_RENDER_BACKEND_UNKNOWN = 0, - OAK_RENDER_BACKEND_OPENGL = 1, - OAK_RENDER_BACKEND_VULKAN = 2 + oak_render_backend_unknown = 0, + oak_render_backend_opengl = 1, + oak_render_backend_vulkan = 2 }; /* Capability bits advertised by a backend through oak_renderer_get_info(). */ enum OakRenderBackendCapability { - OAK_RENDER_BACKEND_CAP_TEXTURES = 1ULL << 0, - OAK_RENDER_BACKEND_CAP_SHADERS = 1ULL << 1, - OAK_RENDER_BACKEND_CAP_BLIT = 1ULL << 2, - OAK_RENDER_BACKEND_CAP_READBACK = 1ULL << 3, - OAK_RENDER_BACKEND_CAP_VIEWER_CONTEXT = 1ULL << 4, - OAK_RENDER_BACKEND_CAP_INSTANCE = 1ULL << 5, - OAK_RENDER_BACKEND_CAP_DEVICE = 1ULL << 6 + oak_render_backend_cap_textures = 1ULL << 0, + oak_render_backend_cap_shaders = 1ULL << 1, + oak_render_backend_cap_blit = 1ULL << 2, + oak_render_backend_cap_readback = 1ULL << 3, + oak_render_backend_cap_viewer_context = 1ULL << 4, + oak_render_backend_cap_instance = 1ULL << 5, + oak_render_backend_cap_device = 1ULL << 6 }; /* Static and runtime metadata returned by the backend. */ @@ -118,4 +118,4 @@ typedef void *(*OakBackendOpenGLContextFn)(OakRenderBackendHandle handle); } #endif -#endif // RENDERBACKEND_C_H +#endif // OAK_RENDERBACKEND_C_H diff --git a/app/render/cancelatom.h b/app/render/cancelatom.h index caa2aadbe..7d2f47df8 100644 --- a/app/render/cancelatom.h +++ b/app/render/cancelatom.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef CANCELATOM_H -#define CANCELATOM_H +#ifndef OAK_CANCELATOM_H +#define OAK_CANCELATOM_H #include @@ -32,7 +32,7 @@ public: { } - bool IsCancelled() + bool is_cancelled() { QMutexLocker locker(&mutex_); if (cancelled_) { @@ -41,13 +41,13 @@ public: return cancelled_; } - void Cancel() + void cancel() { QMutexLocker locker(&mutex_); cancelled_ = true; } - bool HeardCancel() + bool heard_cancel() { QMutexLocker locker(&mutex_); return heard_; @@ -63,4 +63,4 @@ private: } -#endif // CANCELATOM_H +#endif // OAK_CANCELATOM_H diff --git a/app/render/colormanagement.cpp b/app/render/colormanagement.cpp index de57bd8b4..9837047aa 100644 --- a/app/render/colormanagement.cpp +++ b/app/render/colormanagement.cpp @@ -30,7 +30,7 @@ namespace olive { -bool Renderer::GetColorContext(const ColorTransformJob &color_job, +bool Renderer::get_color_context(const ColorTransformJob &color_job, Renderer::ColorContext *ctx) { QMutexLocker locker(&color_cache_mutex_); @@ -47,37 +47,37 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, // Create shader description QString ocio_func_name; - if (color_job.GetFunctionName().isEmpty()) { + if (color_job.get_function_name().isEmpty()) { ocio_func_name = "OCIODisplay"; } else { - ocio_func_name = color_job.GetFunctionName(); + ocio_func_name = color_job.get_function_name(); } - auto shader_desc = OCIO::GpuShaderDesc::CreateShaderDesc(); - shader_desc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_ES_3_0); + auto shader_desc = ocio::GpuShaderDesc::CreateShaderDesc(); + shader_desc->setLanguage(ocio::GPU_LANGUAGE_GLSL_ES_3_0); shader_desc->setFunctionName(ocio_func_name.toUtf8()); shader_desc->setResourcePrefix("ocio_"); // Generate shader - color_job.GetColorProcessor() - ->GetProcessor() + color_job.get_color_processor() + ->get_processor() ->getDefaultGPUProcessor() ->extractGpuShaderInfo(shader_desc); ShaderCode code; - if (const Node *shader_src = color_job.CustomShaderSource()) { + if (const Node *shader_src = color_job.custom_shader_source()) { // Use shader code from associated node - code = shader_src->GetShaderCode( - { color_job.CustomShaderID(), shader_desc->getShaderText() }); + code = shader_src->get_shader_code( + { color_job.custom_shader_id(), shader_desc->getShaderText() }); } else { // Generate shader code using OCIO stub and our auto-generated name - code = FileFunctions::ReadFileAsString( + code = FileFunctions::read_file_as_string( QStringLiteral(":/shaders/colormanage.frag")); code.set_frag_code( code.frag_code().arg(shader_desc->getShaderText())); } // Try to compile shader - color_ctx.compiled_shader = CreateNativeShader(code); + color_ctx.compiled_shader = create_native_shader(code); if (color_ctx.compiled_shader.isNull()) { return false; @@ -88,7 +88,7 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, const char *tex_name = nullptr; const char *sampler_name = nullptr; unsigned int edge_len = 0; - OCIO::Interpolation interpolation = OCIO::INTERP_LINEAR; + ocio::Interpolation interpolation = ocio::INTERP_LINEAR; shader_desc->get3DTexture(i, tex_name, sampler_name, edge_len, interpolation); @@ -107,14 +107,14 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, } // Allocate 3D LUT - color_ctx.lut3d_textures[i].texture = CreateTexture( - VideoParams(edge_len, edge_len, edge_len, PixelFormat::F32, - VideoParams::kRGBChannelCount), + color_ctx.lut3d_textures[i].texture = create_texture( + VideoParams(edge_len, edge_len, edge_len, PixelFormat::f32, + VideoParams::k_rgb_channel_count), values); color_ctx.lut3d_textures[i].name = sampler_name; color_ctx.lut3d_textures[i].interpolation = - (interpolation == OCIO::INTERP_NEAREST) ? Texture::kNearest : - Texture::kLinear; + (interpolation == ocio::INTERP_NEAREST) ? Texture::k_nearest : + Texture::k_linear; } color_ctx.lut1d_textures.resize(shader_desc->getNumTextures()); @@ -122,13 +122,13 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, const char *tex_name = nullptr; const char *sampler_name = nullptr; unsigned int width = 0, height = 0; - OCIO::GpuShaderDesc::TextureType channel = - OCIO::GpuShaderDesc::TEXTURE_RGB_CHANNEL; - OCIO::Interpolation interpolation = OCIO::INTERP_LINEAR; + ocio::GpuShaderDesc::TextureType channel = + ocio::GpuShaderDesc::TEXTURE_RGB_CHANNEL; + ocio::Interpolation interpolation = ocio::INTERP_LINEAR; #if OCIO_VERSION_MAJOR > 2 || \ (OCIO_VERSION_MAJOR == 2 && OCIO_VERSION_MINOR >= 3) - OCIO::GpuShaderDesc::TextureDimensions dimensions = - OCIO::GpuShaderDesc::TEXTURE_2D; + ocio::GpuShaderDesc::TextureDimensions dimensions = + ocio::GpuShaderDesc::TEXTURE_2D; shader_desc->getTexture(i, tex_name, sampler_name, width, height, channel, dimensions, interpolation); #else @@ -151,17 +151,17 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, // Allocate 1D LUT int lut_channels = - (channel == OCIO::GpuShaderDesc::TEXTURE_RED_CHANNEL) ? + (channel == ocio::GpuShaderDesc::TEXTURE_RED_CHANNEL) ? 1 : - VideoParams::kRGBChannelCount; - VideoParams lut_params(width, height, PixelFormat::F32, + VideoParams::k_rgb_channel_count; + VideoParams lut_params(width, height, PixelFormat::f32, lut_channels); color_ctx.lut1d_textures[i].texture = - CreateTexture(lut_params, values); + create_texture(lut_params, values); color_ctx.lut1d_textures[i].name = sampler_name; color_ctx.lut1d_textures[i].interpolation = - (interpolation == OCIO::INTERP_NEAREST) ? Texture::kNearest : - Texture::kLinear; + (interpolation == ocio::INTERP_NEAREST) ? Texture::k_nearest : + Texture::k_linear; } locker.relock(); @@ -171,59 +171,59 @@ bool Renderer::GetColorContext(const ColorTransformJob &color_job, } } -void Renderer::BlitColorManaged(const ColorTransformJob &color_job, +void Renderer::blit_color_managed(const ColorTransformJob &color_job, Texture *destination, const VideoParams ¶ms) { ColorContext color_ctx; - if (!GetColorContext(color_job, &color_ctx)) { + if (!get_color_context(color_job, &color_ctx)) { ShaderJob fallback_job; - fallback_job.Insert(QStringLiteral("ove_maintex"), - color_job.GetInputTexture()); - fallback_job.Insert(QStringLiteral("ove_mvpmat"), - NodeValue(NodeValue::kMatrix, - color_job.GetTransformMatrix())); + fallback_job.insert(QStringLiteral("ove_maintex"), + color_job.get_input_texture()); + fallback_job.insert(QStringLiteral("ove_mvpmat"), + NodeValue(NodeValue::k_matrix, + color_job.get_transform_matrix())); if (destination) { - BlitToTexture(GetDefaultShader(), fallback_job, destination, - color_job.IsClearDestinationEnabled()); + blit_to_texture(get_default_shader(), fallback_job, destination, + color_job.is_clear_destination_enabled()); } else { - Blit(GetDefaultShader(), fallback_job, params, - color_job.IsClearDestinationEnabled()); + blit(get_default_shader(), fallback_job, params, + color_job.is_clear_destination_enabled()); } return; } ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), color_job.GetInputTexture()); - job.Insert(QStringLiteral("ove_mvpmat"), - NodeValue(NodeValue::kMatrix, color_job.GetTransformMatrix())); - job.Insert(QStringLiteral("ove_cropmatrix"), - NodeValue(NodeValue::kMatrix, - color_job.GetCropMatrix().inverted())); - job.Insert(QStringLiteral("ove_maintex_alpha"), - NodeValue(NodeValue::kInt, - int(color_job.GetInputAlphaAssociation()))); - job.Insert(QStringLiteral("ove_force_opaque"), - NodeValue(NodeValue::kBoolean, color_job.GetForceOpaque())); - job.Insert(color_job.GetValues()); + job.insert(QStringLiteral("ove_maintex"), color_job.get_input_texture()); + job.insert(QStringLiteral("ove_mvpmat"), + NodeValue(NodeValue::k_matrix, color_job.get_transform_matrix())); + job.insert(QStringLiteral("ove_cropmatrix"), + NodeValue(NodeValue::k_matrix, + color_job.get_crop_matrix().inverted())); + job.insert(QStringLiteral("ove_maintex_alpha"), + NodeValue(NodeValue::k_int, + int(color_job.get_input_alpha_association()))); + job.insert(QStringLiteral("ove_force_opaque"), + NodeValue(NodeValue::k_boolean, color_job.get_force_opaque())); + job.insert(color_job.get_values()); foreach (const ColorContext::LUT &l, color_ctx.lut3d_textures) { - job.Insert(l.name, NodeValue(NodeValue::kTexture, + job.insert(l.name, NodeValue(NodeValue::k_texture, QVariant::fromValue(l.texture))); - job.SetInterpolation(l.name, l.interpolation); + job.set_interpolation(l.name, l.interpolation); } foreach (const ColorContext::LUT &l, color_ctx.lut1d_textures) { - job.Insert(l.name, NodeValue(NodeValue::kTexture, + job.insert(l.name, NodeValue(NodeValue::k_texture, QVariant::fromValue(l.texture))); - job.SetInterpolation(l.name, l.interpolation); + job.set_interpolation(l.name, l.interpolation); } if (destination) { - BlitToTexture(color_ctx.compiled_shader, job, destination, - color_job.IsClearDestinationEnabled()); + blit_to_texture(color_ctx.compiled_shader, job, destination, + color_job.is_clear_destination_enabled()); } else { - Blit(color_ctx.compiled_shader, job, params, - color_job.IsClearDestinationEnabled()); + blit(color_ctx.compiled_shader, job, params, + color_job.is_clear_destination_enabled()); } } diff --git a/app/render/colorprocessor.cpp b/app/render/colorprocessor.cpp index e9a5cd4c5..a2d707d74 100644 --- a/app/render/colorprocessor.cpp +++ b/app/render/colorprocessor.cpp @@ -39,40 +39,40 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, // Resolve role names (e.g. "scene_linear") to canonical colorspace names // so they can be passed to getProcessor()/DisplayViewTransform. QString resolved_input = input; - OCIO::ConstConfigRcPtr ocio_config = config->GetConfig(); + ocio::ConstConfigRcPtr ocio_config = config->get_config(); if (ocio_config && ocio_config->hasRole(input.toUtf8())) { resolved_input = ocio_config->getCanonicalName(input.toUtf8()); } const QString &output = (transform.output().isEmpty()) ? - config->GetDefaultDisplay() : + config->get_default_display() : transform.output(); if (transform.is_display()) { const QString &view = (transform.view().isEmpty()) ? - config->GetDefaultView(output) : + config->get_default_view(output) : transform.view(); - auto display_transform = OCIO::DisplayViewTransform::Create(); + auto display_transform = ocio::DisplayViewTransform::Create(); display_transform->setSrc(resolved_input.toUtf8()); display_transform->setDisplay(output.toUtf8()); display_transform->setView(view.toUtf8()); - display_transform->setDirection(direction == kNormal ? - OCIO::TRANSFORM_DIR_FORWARD : - OCIO::TRANSFORM_DIR_INVERSE); + display_transform->setDirection(direction == k_normal ? + ocio::TRANSFORM_DIR_FORWARD : + ocio::TRANSFORM_DIR_INVERSE); if (transform.look().isEmpty()) { processor_ = ocio_config->getProcessor(display_transform); } else { - auto group = OCIO::GroupTransform::Create(); + auto group = ocio::GroupTransform::Create(); const char *out_cs = - OCIO::LookTransform::GetLooksResultColorSpace( + ocio::LookTransform::GetLooksResultColorSpace( ocio_config, ocio_config->getCurrentContext(), transform.look().toUtf8()); - auto lt = OCIO::LookTransform::Create(); + auto lt = ocio::LookTransform::Create(); lt->setSrc(resolved_input.toUtf8()); lt->setDst(out_cs); lt->setLooks(transform.look().toUtf8()); @@ -86,7 +86,7 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, } } else { - if (direction == kNormal) { + if (direction == k_normal) { processor_ = ocio_config->getProcessor(resolved_input.toUtf8(), output.toUtf8()); } else { @@ -98,41 +98,41 @@ ColorProcessor::ColorProcessor(ColorManager *config, const QString &input, if (processor_) { cpu_processor_ = processor_->getDefaultCPUProcessor(); } - } catch (OCIO::Exception &e) { + } catch (ocio::Exception &e) { qWarning() << "ColorProcessor exception:" << e.what(); } } -ColorProcessor::ColorProcessor(OCIO::ConstProcessorRcPtr processor) +ColorProcessor::ColorProcessor(ocio::ConstProcessorRcPtr processor) { processor_ = processor; cpu_processor_ = processor_ ? processor_->getDefaultCPUProcessor() : nullptr; } -void ColorProcessor::ConvertFrame(Frame *f) +void ColorProcessor::convert_frame(Frame *f) { if (!cpu_processor_) { return; } - OCIO::BitDepth ocio_bit_depth = - OCIOUtils::GetOCIOBitDepthFromPixelFormat(f->format()); + ocio::BitDepth ocio_bit_depth = + OCIOUtils::get_ocio_bit_depth_from_pixel_format(f->format()); - if (ocio_bit_depth == OCIO::BIT_DEPTH_UNKNOWN) { + if (ocio_bit_depth == ocio::BIT_DEPTH_UNKNOWN) { qCritical() << "Tried to color convert frame with no format"; return; } - OCIO::PackedImageDesc img(f->data(), f->width(), f->height(), + ocio::PackedImageDesc img(f->data(), f->width(), f->height(), f->channel_count(), ocio_bit_depth, - OCIO::AutoStride, OCIO::AutoStride, + ocio::AutoStride, ocio::AutoStride, f->linesize_bytes()); cpu_processor_->apply(img); } -Color ColorProcessor::ConvertColor(const Color &in) +Color ColorProcessor::convert_color(const Color &in) { if (!cpu_processor_) { return in; @@ -147,7 +147,7 @@ Color ColorProcessor::ConvertColor(const Color &in) return Color(c[0], c[1], c[2], c[3]); } -ColorProcessorPtr ColorProcessor::Create(ColorManager *config, +ColorProcessorPtr ColorProcessor::create(ColorManager *config, const QString &input, const ColorTransform &transform, Direction direction) @@ -156,19 +156,19 @@ ColorProcessorPtr ColorProcessor::Create(ColorManager *config, direction); } -ColorProcessorPtr ColorProcessor::Create(OCIO::ConstProcessorRcPtr processor) +ColorProcessorPtr ColorProcessor::create(ocio::ConstProcessorRcPtr processor) { return std::make_shared(processor); } -OCIO::ConstProcessorRcPtr ColorProcessor::GetProcessor() +ocio::ConstProcessorRcPtr ColorProcessor::get_processor() { return processor_; } -void ColorProcessor::ConvertFrame(FramePtr f) +void ColorProcessor::convert_frame(FramePtr f) { - ConvertFrame(f.get()); + convert_frame(f.get()); } } diff --git a/app/render/colorprocessor.h b/app/render/colorprocessor.h index 360262866..474219374 100644 --- a/app/render/colorprocessor.h +++ b/app/render/colorprocessor.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORPROCESSOR_H -#define COLORPROCESSOR_H +#ifndef OAK_COLORPROCESSOR_H +#define OAK_COLORPROCESSOR_H #include "codec/frame.h" #include "common/ocioutils.h" @@ -36,26 +36,26 @@ using ColorProcessorPtr = std::shared_ptr; class ColorProcessor { public: - enum Direction { kNormal, kInverse }; + enum Direction { k_normal, k_inverse }; ColorProcessor(ColorManager *config, const QString &input, const ColorTransform &dest_space, - Direction direction = kNormal); - ColorProcessor(OCIO::ConstProcessorRcPtr processor); + Direction direction = k_normal); + ColorProcessor(ocio::ConstProcessorRcPtr processor); DISABLE_COPY_MOVE(ColorProcessor) - static ColorProcessorPtr Create(ColorManager *config, const QString &input, + static ColorProcessorPtr create(ColorManager *config, const QString &input, const ColorTransform &dest_space, - Direction direction = kNormal); - static ColorProcessorPtr Create(OCIO::ConstProcessorRcPtr processor); + Direction direction = k_normal); + static ColorProcessorPtr create(ocio::ConstProcessorRcPtr processor); - OCIO::ConstProcessorRcPtr GetProcessor(); + ocio::ConstProcessorRcPtr get_processor(); - void ConvertFrame(FramePtr f); - void ConvertFrame(Frame *f); + void convert_frame(FramePtr f); + void convert_frame(Frame *f); - Color ConvertColor(const Color &in); + Color convert_color(const Color &in); const char *id() const { @@ -63,9 +63,9 @@ public: } private: - OCIO::ConstProcessorRcPtr processor_; + ocio::ConstProcessorRcPtr processor_; - OCIO::ConstCPUProcessorRcPtr cpu_processor_; + ocio::ConstCPUProcessorRcPtr cpu_processor_; }; using ColorProcessorChain = QVector; @@ -74,4 +74,4 @@ using ColorProcessorChain = QVector; Q_DECLARE_METATYPE(olive::ColorProcessorPtr) -#endif // COLORPROCESSOR_H +#endif // OAK_COLORPROCESSOR_H diff --git a/app/render/colorprocessorcache.h b/app/render/colorprocessorcache.h index 12f8db82d..4b354f27d 100644 --- a/app/render/colorprocessorcache.h +++ b/app/render/colorprocessorcache.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORPROCESSORCACHE_H -#define COLORPROCESSORCACHE_H +#ifndef OAK_COLORPROCESSORCACHE_H +#define OAK_COLORPROCESSORCACHE_H #include "render/colorprocessor.h" @@ -31,4 +31,4 @@ using ColorProcessorCache = QHash; } -#endif // COLORPROCESSORCACHE_H +#endif // OAK_COLORPROCESSORCACHE_H diff --git a/app/render/colortransform.h b/app/render/colortransform.h index 703bcf0e6..dd149ae0f 100644 --- a/app/render/colortransform.h +++ b/app/render/colortransform.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORTRANSFORM_H -#define COLORTRANSFORM_H +#ifndef OAK_COLORTRANSFORM_H +#define OAK_COLORTRANSFORM_H #include @@ -89,4 +89,4 @@ private: Q_DECLARE_METATYPE(olive::ColorTransform) -#endif // COLORTRANSFORM_H +#endif // OAK_COLORTRANSFORM_H diff --git a/app/render/diskmanager.cpp b/app/render/diskmanager.cpp index 494fdf79a..6111b25aa 100644 --- a/app/render/diskmanager.cpp +++ b/app/render/diskmanager.cpp @@ -41,13 +41,13 @@ DiskManager *DiskManager::instance_ = nullptr; DiskManager::DiskManager() { // Add default cache location - QFile default_disk_cache_file(GetDefaultDiskCacheConfigFile()); + QFile default_disk_cache_file(get_default_disk_cache_config_file()); if (default_disk_cache_file.open(QFile::ReadOnly)) { QString default_dir = default_disk_cache_file.readAll(); if (!default_dir.isEmpty()) { - if (FileFunctions::DirectoryIsValid(default_dir)) { - GetOpenFolder(default_dir); + if (FileFunctions::directory_is_valid(default_dir)) { + get_open_folder(default_dir); } else { QMessageBox::warning( nullptr, tr("Disk Cache Error"), @@ -60,10 +60,10 @@ DiskManager::DiskManager() // If no custom default was loaded, load default if (open_folders_.isEmpty()) { - GetOpenFolder(GetDefaultDiskCachePath()); + get_open_folder(get_default_disk_cache_path()); } - QFile disk_cache_index(QDir(FileFunctions::GetConfigurationLocation()) + QFile disk_cache_index(QDir(FileFunctions::get_configuration_location()) .filePath(QStringLiteral("diskcache2"))); if (disk_cache_index.open(QFile::ReadOnly)) { @@ -71,7 +71,7 @@ DiskManager::DiskManager() QString line; while (stream.readLineInto(&line)) { - GetOpenFolder(line); + get_open_folder(line); } disk_cache_index.close(); @@ -80,22 +80,22 @@ DiskManager::DiskManager() DiskManager::~DiskManager() { - QFile default_disk_cache_file(GetDefaultDiskCacheConfigFile()); + QFile default_disk_cache_file(get_default_disk_cache_config_file()); if (default_disk_cache_file.open(QFile::WriteOnly)) { - if (GetDefaultDiskCachePath() != GetDefaultCachePath()) { - default_disk_cache_file.write(GetDefaultCachePath().toUtf8()); + if (get_default_disk_cache_path() != get_default_cache_path()) { + default_disk_cache_file.write(get_default_cache_path().toUtf8()); } default_disk_cache_file.close(); } } -void DiskManager::CreateInstance() +void DiskManager::create_instance() { instance_ = new DiskManager(); } -void DiskManager::DestroyInstance() +void DiskManager::destroy_instance() { delete instance_; instance_ = nullptr; @@ -106,59 +106,59 @@ DiskManager *DiskManager::instance() return instance_; } -void DiskManager::Accessed(const QString &cache_folder, const QString &filename) +void DiskManager::accessed(const QString &cache_folder, const QString &filename) { - DiskCacheFolder *f = GetOpenFolder(cache_folder); + DiskCacheFolder *f = get_open_folder(cache_folder); - f->Accessed(filename); + f->accessed(filename); } -void DiskManager::CreatedFile(const QString &cache_folder, +void DiskManager::created_file(const QString &cache_folder, const QString &filename) { - DiskCacheFolder *f = GetOpenFolder(cache_folder); + DiskCacheFolder *f = get_open_folder(cache_folder); - f->CreatedFile(filename); + f->created_file(filename); } -void DiskManager::DeleteSpecificFile(const QString &filename) +void DiskManager::delete_specific_file(const QString &filename) { foreach (DiskCacheFolder *f, open_folders_) { - f->DeleteSpecificFile(filename); + f->delete_specific_file(filename); } } -bool DiskManager::ClearDiskCache(const QString &cache_folder) +bool DiskManager::clear_disk_cache(const QString &cache_folder) { - DiskCacheFolder *f = GetOpenFolder(cache_folder); + DiskCacheFolder *f = get_open_folder(cache_folder); - return f->ClearCache(); + return f->clear_cache(); } -DiskCacheFolder *DiskManager::GetOpenFolder(const QString &path) +DiskCacheFolder *DiskManager::get_open_folder(const QString &path) { // If path is empty, this must mean default if (path.isEmpty()) { - return GetDefaultCacheFolder(); + return get_default_cache_folder(); } // See if we have an existing path with this name foreach (DiskCacheFolder *f, open_folders_) { - if (f->GetPath() == path) { + if (f->get_path() == path) { return f; } } // We must have to open this folder DiskCacheFolder *f = new DiskCacheFolder(path, this); - connect(f, &DiskCacheFolder::DeletedFrame, this, - &DiskManager::DeletedFrame); + connect(f, &DiskCacheFolder::deleted_frame, this, + &DiskManager::deleted_frame); open_folders_.append(f); return f; } -bool DiskManager::ShowDiskCacheChangeConfirmationDialog(QWidget *parent) +bool DiskManager::show_disk_cache_change_confirmation_dialog(QWidget *parent) { return ( QMessageBox::question( @@ -168,30 +168,30 @@ bool DiskManager::ShowDiskCacheChangeConfirmationDialog(QWidget *parent) QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok); } -QString DiskManager::GetDefaultDiskCacheConfigFile() +QString DiskManager::get_default_disk_cache_config_file() { - return QDir(FileFunctions::GetConfigurationLocation()) + return QDir(FileFunctions::get_configuration_location()) .filePath(QStringLiteral("defaultdiskcache")); } -QString DiskManager::GetDefaultDiskCachePath() +QString DiskManager::get_default_disk_cache_path() { return QDir(QStandardPaths::writableLocation( QStandardPaths::AppLocalDataLocation)) .filePath("mediacache"); } -void DiskManager::ShowDiskCacheSettingsDialog(DiskCacheFolder *folder, +void DiskManager::show_disk_cache_settings_dialog(DiskCacheFolder *folder, QWidget *parent) { DiskCacheDialog d(folder, parent); d.exec(); } -void DiskManager::ShowDiskCacheSettingsDialog(const QString &path, +void DiskManager::show_disk_cache_settings_dialog(const QString &path, QWidget *parent) { - if (!FileFunctions::DirectoryIsValid(path)) { + if (!FileFunctions::directory_is_valid(path)) { QMessageBox::critical( parent, tr("Disk Cache Error"), tr("Failed to open disk cache at \"%1\". Try a different folder.") @@ -199,28 +199,28 @@ void DiskManager::ShowDiskCacheSettingsDialog(const QString &path, return; } - DiskCacheFolder *folder = GetOpenFolder(path); + DiskCacheFolder *folder = get_open_folder(path); - ShowDiskCacheSettingsDialog(folder, parent); + show_disk_cache_settings_dialog(folder, parent); } DiskCacheFolder::DiskCacheFolder(const QString &path, QObject *parent) : QObject(parent) { - SetPath(path); + set_path(path); - save_timer_.setInterval(OLIVE_CONFIG("DiskCacheSaveInterval").toInt()); + save_timer_.setInterval(OAK_CONFIG("DiskCacheSaveInterval").toInt()); connect(&save_timer_, &QTimer::timeout, this, - &DiskCacheFolder::SaveDiskCacheIndex); + &DiskCacheFolder::save_disk_cache_index); save_timer_.start(); } DiskCacheFolder::~DiskCacheFolder() { - CloseCacheFolder(); + close_cache_folder(); } -bool DiskCacheFolder::ClearCache() +bool DiskCacheFolder::clear_cache() { bool deleted_files = true; @@ -231,7 +231,7 @@ bool DiskCacheFolder::ClearCache() QString filename = i.key(); if (QFile::remove(filename) || !QFileInfo::exists(filename)) { - emit DeletedFrame(path_, filename); + emit deleted_frame(path_, filename); i = disk_data_.erase(i); } else { qWarning() << "Failed to delete" << filename; @@ -243,7 +243,7 @@ bool DiskCacheFolder::ClearCache() return deleted_files; } -void DiskCacheFolder::Accessed(const QString &filename) +void DiskCacheFolder::accessed(const QString &filename) { if (!disk_data_.contains(filename)) { return; @@ -252,7 +252,7 @@ void DiskCacheFolder::Accessed(const QString &filename) disk_data_[filename].access_time = QDateTime::currentMSecsSinceEpoch(); } -void DiskCacheFolder::CreatedFile(const QString &filename) +void DiskCacheFolder::created_file(const QString &filename) { qint64 file_size = QFile(filename).size(); @@ -262,19 +262,19 @@ void DiskCacheFolder::CreatedFile(const QString &filename) consumption_ += file_size; while (consumption_ > limit_) { - DeleteLeastRecent(); + delete_least_recent(); } } -void DiskCacheFolder::SetPath(const QString &path) +void DiskCacheFolder::set_path(const QString &path) { // If this is currently set to a folder, close it out now - CloseCacheFolder(); + close_cache_folder(); // Signal that disk cache is gone if (!disk_data_.empty()) { for (auto it = disk_data_.cbegin(); it != disk_data_.cend(); it++) { - emit DeletedFrame(path_, it.key()); + emit deleted_frame(path_, it.key()); } disk_data_.clear(); } @@ -289,7 +289,7 @@ void DiskCacheFolder::SetPath(const QString &path) // Attempt to load existing index file from path QDir path_dir(path_); - FileFunctions::DirectoryIsValid(path_dir); + FileFunctions::directory_is_valid(path_dir); index_path_ = path_dir.filePath(QStringLiteral("index")); @@ -320,7 +320,7 @@ void DiskCacheFolder::SetPath(const QString &path) } } -bool DiskCacheFolder::DeleteFileInternal( +bool DiskCacheFolder::delete_file_internal( QMap::iterator hash_to_delete) { // Cache HashTime object @@ -337,26 +337,26 @@ bool DiskCacheFolder::DeleteFileInternal( // Reduce consumption consumption_ -= ht.file_size; - emit DeletedFrame(path_, filename); + emit deleted_frame(path_, filename); return true; } return false; } -bool DiskCacheFolder::DeleteSpecificFile(const QString &f) +bool DiskCacheFolder::delete_specific_file(const QString &f) { for (auto it = disk_data_.begin(); it != disk_data_.end(); it++) { if (it.key() == f) { - // Break out of this loop, assuming we'll only have one instance of each filename - return DeleteFileInternal(it); + // Break out of this loop, assuming we'll only have one instance_ of each filename + return delete_file_internal(it); } } return false; } -bool DiskCacheFolder::DeleteLeastRecent() +bool DiskCacheFolder::delete_least_recent() { auto hash_to_delete = disk_data_.begin(); @@ -367,10 +367,10 @@ bool DiskCacheFolder::DeleteLeastRecent() } } - bool e = DeleteFileInternal(hash_to_delete); + bool e = delete_file_internal(hash_to_delete); if (e) { - Core::instance()->WarnCacheFull(); + Core::instance()->warn_cache_full(); } return e; @@ -379,7 +379,7 @@ bool DiskCacheFolder::DeleteLeastRecent() } } -void DiskCacheFolder::CloseCacheFolder() +void DiskCacheFolder::close_cache_folder() { if (path_.isEmpty()) { return; @@ -388,14 +388,14 @@ void DiskCacheFolder::CloseCacheFolder() if (clear_on_close_) { // If we're not moving to new and we're set to clear on close, clear now or else it'll never // get cleared later - ClearCache(); + clear_cache(); } // Save current cache index - SaveDiskCacheIndex(); + save_disk_cache_index(); } -void DiskCacheFolder::SaveDiskCacheIndex() +void DiskCacheFolder::save_disk_cache_index() { QFile cache_index_file(index_path_); diff --git a/app/render/diskmanager.h b/app/render/diskmanager.h index 113730453..75d1e41c5 100644 --- a/app/render/diskmanager.h +++ b/app/render/diskmanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef DISKMANAGER_H -#define DISKMANAGER_H +#ifndef OAK_DISKMANAGER_H +#define OAK_DISKMANAGER_H #include #include @@ -40,43 +40,43 @@ public: virtual ~DiskCacheFolder() override; - bool ClearCache(); + bool clear_cache(); - void Accessed(const QString &filename); + void accessed(const QString &filename); - void CreatedFile(const QString &filename); + void created_file(const QString &filename); - const QString &GetPath() const + const QString &get_path() const { return path_; } - void SetPath(const QString &path); + void set_path(const QString &path); - qint64 GetLimit() const + qint64 get_limit() const { return limit_; } - bool GetClearOnClose() const + bool get_clear_on_close() const { return clear_on_close_; } - void SetLimit(qint64 l) + void set_limit(qint64 l) { limit_ = l; } - void SetClearOnClose(bool e) + void set_clear_on_close(bool e) { clear_on_close_ = e; } - bool DeleteSpecificFile(const QString &f); + bool delete_specific_file(const QString &f); signals: - void DeletedFrame(const QString &path, const QString &filename); + void deleted_frame(const QString &path, const QString &filename); private: struct HashTime { @@ -84,11 +84,11 @@ private: qint64 access_time; }; - bool DeleteFileInternal(QMap::iterator hash_to_delete); + bool delete_file_internal(QMap::iterator hash_to_delete); - bool DeleteLeastRecent(); + bool delete_least_recent(); - void CloseCacheFolder(); + void close_cache_folder(); QString path_; @@ -105,58 +105,58 @@ private: QTimer save_timer_; private slots: - void SaveDiskCacheIndex(); + void save_disk_cache_index(); }; class DiskManager : public QObject { Q_OBJECT public: - static void CreateInstance(); + static void create_instance(); - static void DestroyInstance(); + static void destroy_instance(); static DiskManager *instance(); - bool ClearDiskCache(const QString &cache_folder); + bool clear_disk_cache(const QString &cache_folder); - DiskCacheFolder *GetDefaultCacheFolder() const + DiskCacheFolder *get_default_cache_folder() const { // The first folder will always be the default return open_folders_.first(); } - const QString &GetDefaultCachePath() const + const QString &get_default_cache_path() const { - return GetDefaultCacheFolder()->GetPath(); + return get_default_cache_folder()->get_path(); } - DiskCacheFolder *GetOpenFolder(const QString &path); + DiskCacheFolder *get_open_folder(const QString &path); - const QVector &GetOpenFolders() const + const QVector &get_open_folders() const { return open_folders_; } - static bool ShowDiskCacheChangeConfirmationDialog(QWidget *parent); + static bool show_disk_cache_change_confirmation_dialog(QWidget *parent); - static QString GetDefaultDiskCacheConfigFile(); + static QString get_default_disk_cache_config_file(); - static QString GetDefaultDiskCachePath(); + static QString get_default_disk_cache_path(); - void ShowDiskCacheSettingsDialog(DiskCacheFolder *folder, QWidget *parent); - void ShowDiskCacheSettingsDialog(const QString &path, QWidget *parent); + void show_disk_cache_settings_dialog(DiskCacheFolder *folder, QWidget *parent); + void show_disk_cache_settings_dialog(const QString &path, QWidget *parent); public slots: - void Accessed(const QString &cache_folder, const QString &filename); + void accessed(const QString &cache_folder, const QString &filename); - void CreatedFile(const QString &cache_folder, const QString &filename); + void created_file(const QString &cache_folder, const QString &filename); - void DeleteSpecificFile(const QString &filename); + void delete_specific_file(const QString &filename); signals: - void DeletedFrame(const QString &path, const QString &filename); + void deleted_frame(const QString &path, const QString &filename); - void InvalidateProject(Project *p); + void invalidate_project(Project *p); private: DiskManager(); @@ -170,4 +170,4 @@ private: } -#endif // DISKMANAGER_H +#endif // OAK_DISKMANAGER_H diff --git a/app/render/framehashcache.cpp b/app/render/framehashcache.cpp index e124e619e..15432a7ab 100644 --- a/app/render/framehashcache.cpp +++ b/app/render/framehashcache.cpp @@ -42,37 +42,37 @@ FrameHashCache::FrameHashCache(QObject *parent) : super(parent) { if (DiskManager::instance()) { - connect(DiskManager::instance(), &DiskManager::DeletedFrame, this, - &FrameHashCache::HashDeleted); - connect(DiskManager::instance(), &DiskManager::InvalidateProject, this, - &FrameHashCache::ProjectInvalidated); + connect(DiskManager::instance(), &DiskManager::deleted_frame, this, + &FrameHashCache::hash_deleted); + connect(DiskManager::instance(), &DiskManager::invalidate_project, this, + &FrameHashCache::project_invalidated); } } -void FrameHashCache::SetTimebase(const rational &tb) +void FrameHashCache::set_timebase(const Rational &tb) { timebase_ = tb; } -void FrameHashCache::ValidateTimestamp(const int64_t &ts) +void FrameHashCache::validate_timestamp(const int64_t &ts) { - TimeRange frame_range(ToTime(ts), ToTime(ts + 1)); - Validate(frame_range); + TimeRange frame_range(to_time(ts), to_time(ts + 1)); + validate(frame_range); } -void FrameHashCache::ValidateTime(const rational &time) +void FrameHashCache::validate_time(const Rational &time) { - Validate(TimeRange(time, time + timebase_)); + validate(TimeRange(time, time + timebase_)); } -QString FrameHashCache::GetValidCacheFilename(const rational &time) const +QString FrameHashCache::get_valid_cache_filename(const Rational &time) const { - if (IsFrameCached(time)) { - return CachePathName(time); - } else if (!GetPassthroughs().empty()) { - for (const Passthrough &p : GetPassthroughs()) { - if (p.Contains(time)) { - return CachePathName(GetCacheDirectory(), p.cache, time, + if (is_frame_cached(time)) { + return cache_path_name(time); + } else if (!get_passthroughs().empty()) { + for (const Passthrough &p : get_passthroughs()) { + if (p.contains(time)) { + return cache_path_name(get_cache_directory(), p.cache, time, timebase_); } } @@ -81,12 +81,12 @@ QString FrameHashCache::GetValidCacheFilename(const rational &time) const return QString(); } -bool FrameHashCache::SaveCacheFrame(const int64_t &time, FramePtr frame) const +bool FrameHashCache::save_cache_frame(const int64_t &time, FramePtr frame) const { - return SaveCacheFrame(GetCacheDirectory(), GetUuid(), time, frame); + return save_cache_frame(get_cache_directory(), get_uuid(), time, frame); } -bool FrameHashCache::SaveCacheFrame(const QString &cache_path, +bool FrameHashCache::save_cache_frame(const QString &cache_path, const QUuid &uuid, const int64_t &time, FramePtr frame) { @@ -95,13 +95,13 @@ bool FrameHashCache::SaveCacheFrame(const QString &cache_path, return false; } - QString fn = CachePathName(cache_path, uuid, time); + QString fn = cache_path_name(cache_path, uuid, time); - bool ret = SaveCacheFrame(fn, frame); + bool ret = save_cache_frame(fn, frame); // Register frame with the disk manager if (ret) { - QMetaObject::invokeMethod(DiskManager::instance(), "CreatedFile", + QMetaObject::invokeMethod(DiskManager::instance(), "created_file", Q_ARG(QString, cache_path), Q_ARG(QString, fn)); } @@ -109,22 +109,22 @@ bool FrameHashCache::SaveCacheFrame(const QString &cache_path, return ret; } -bool FrameHashCache::SaveCacheFrame(const QString &cache_path, - const QUuid &uuid, const rational &time, - const rational &tb, FramePtr frame) +bool FrameHashCache::save_cache_frame(const QString &cache_path, + const QUuid &uuid, const Rational &time, + const Rational &tb, FramePtr frame) { if (cache_path.isEmpty()) { qWarning() << "Failed to save cache frame with empty path"; return false; } - QString fn = CachePathName(cache_path, uuid, time, tb); + QString fn = cache_path_name(cache_path, uuid, time, tb); - bool ret = SaveCacheFrame(fn, frame); + bool ret = save_cache_frame(fn, frame); // Register frame with the disk manager if (ret) { - QMetaObject::invokeMethod(DiskManager::instance(), "CreatedFile", + QMetaObject::invokeMethod(DiskManager::instance(), "created_file", Q_ARG(QString, cache_path), Q_ARG(QString, fn)); } @@ -132,28 +132,28 @@ bool FrameHashCache::SaveCacheFrame(const QString &cache_path, return ret; } -FramePtr FrameHashCache::LoadCacheFrame(const QString &cache_path, +FramePtr FrameHashCache::load_cache_frame(const QString &cache_path, const QUuid &uuid, const int64_t &time) { // Minor optimization, we store frames currently being saved just in case something tries to load // while we're saving. This should *occasionally* optimize and also prevent scenarios where // we try to load a frame that's half way through being saved. - QString filename = CachePathName(cache_path, uuid, time); + QString filename = cache_path_name(cache_path, uuid, time); if (cache_path.isEmpty()) { qWarning() << "Failed to load cache frame with empty path"; return nullptr; } - return LoadCacheFrame(filename); + return load_cache_frame(filename); } -FramePtr FrameHashCache::LoadCacheFrame(const int64_t &hash) const +FramePtr FrameHashCache::load_cache_frame(const int64_t &hash) const { - return LoadCacheFrame(GetCacheDirectory(), GetUuid(), hash); + return load_cache_frame(get_cache_directory(), get_uuid(), hash); } -FramePtr FrameHashCache::LoadCacheFrame(const QString &fn) +FramePtr FrameHashCache::load_cache_frame(const QString &fn) { FramePtr frame = nullptr; @@ -174,23 +174,23 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn) PixelFormat image_format; if (pix_type == Imf::HALF) { - image_format = PixelFormat::F16; + image_format = PixelFormat::f16; } else { - image_format = PixelFormat::F32; + image_format = PixelFormat::f32; } - int channel_count = has_alpha ? VideoParams::kRGBAChannelCount : - VideoParams::kRGBChannelCount; + int channel_count = has_alpha ? VideoParams::k_rgba_channel_count : + VideoParams::k_rgb_channel_count; - frame = Frame::Create(); + frame = Frame::create(); frame->set_video_params(VideoParams( width * div, height * div, image_format, channel_count, - rational::fromDouble(file.header().pixelAspectRatio()), - VideoParams::kInterlaceNone, div)); + Rational::from_double(file.header().pixelAspectRatio()), + VideoParams::k_interlace_none, div)); frame->allocate(); - int bpc = VideoParams::GetBytesPerChannel(image_format); + int bpc = VideoParams::get_bytes_per_channel(image_format); size_t xs = channel_count * bpc; size_t ys = frame->linesize_bytes(); @@ -217,17 +217,17 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn) if (img.load(fn, "jpg")) { // FIXME: Hardcoded const int div = 1; - const PixelFormat image_format = PixelFormat::U8; + const PixelFormat image_format = PixelFormat::u8; const int channel_count = 4; - const rational par(1, 1); + const Rational par(1, 1); // Convert to frame (FIXME: might be slow? may be a better way to do this on the GPU) img.convertTo(QImage::Format_RGBA8888_Premultiplied); - frame = Frame::Create(); + frame = Frame::create(); frame->set_video_params(VideoParams( img.width() * div, img.height() * div, image_format, - channel_count, par, VideoParams::kInterlaceNone, div)); + channel_count, par, VideoParams::k_interlace_none, div)); frame->allocate(); @@ -235,7 +235,7 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn) memcpy(frame->data() + frame->linesize_bytes() * i, img.bits() + img.bytesPerLine() * i, frame->width() * - frame->video_params().GetBytesPerPixel()); + frame->video_params().get_bytes_per_pixel()); } } else { @@ -246,7 +246,7 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn) // Assume this frame is corrupt in some way and delete it QMetaObject::invokeMethod(DiskManager::instance(), - "DeleteSpecificFile", + "delete_specific_file", Q_ARG(QString, fn)); } } @@ -255,10 +255,10 @@ FramePtr FrameHashCache::LoadCacheFrame(const QString &fn) return frame; } -void FrameHashCache::SetPassthrough(PlaybackCache *cache) +void FrameHashCache::set_passthrough(PlaybackCache *cache) { - super::SetPassthrough(cache); - SetTimebase(static_cast(cache)->GetTimebase()); + super::set_passthrough(cache); + set_timebase(static_cast(cache)->get_timebase()); } void FrameHashCache::LoadStateEvent(QDataStream &stream) @@ -272,7 +272,7 @@ void FrameHashCache::LoadStateEvent(QDataStream &stream) case 1: stream >> num; stream >> den; - timebase_ = rational(num, den); + timebase_ = Rational(num, den); break; } } @@ -287,60 +287,60 @@ void FrameHashCache::SaveStateEvent(QDataStream &stream) stream << timebase_.denominator(); } -rational FrameHashCache::ToTime(const int64_t &ts) const +Rational FrameHashCache::to_time(const int64_t &ts) const { return Timecode::timestamp_to_time(ts, timebase_); } -int64_t FrameHashCache::ToTimestamp(const rational &ts, +int64_t FrameHashCache::to_timestamp(const Rational &ts, Timecode::Rounding rounding) const { return Timecode::time_to_timestamp(ts, timebase_, rounding); } -void FrameHashCache::HashDeleted(const QString &path, const QString &filename) +void FrameHashCache::hash_deleted(const QString &path, const QString &filename) { - QString cache_dir = GetCacheDirectory(); + QString cache_dir = get_cache_directory(); if (cache_dir.isEmpty() || path != cache_dir) { return; } QFileInfo info(filename); - if (GetUuid().toString() != info.dir().dirName()) { + if (get_uuid().toString() != info.dir().dirName()) { return; } int64_t timestamp = info.fileName().toLongLong(); - Invalidate(TimeRange(ToTime(timestamp), ToTime(timestamp + 1))); + invalidate(TimeRange(to_time(timestamp), to_time(timestamp + 1))); } -void FrameHashCache::ProjectInvalidated(Project *p) +void FrameHashCache::project_invalidated(Project *p) { - if (GetProject() == p) { - InvalidateAll(); + if (get_project() == p) { + invalidate_all(); } } -QString FrameHashCache::CachePathName(const int64_t &time) const +QString FrameHashCache::cache_path_name(const int64_t &time) const { - return CachePathName(GetCacheDirectory(), GetUuid(), time); + return cache_path_name(get_cache_directory(), get_uuid(), time); } -QString FrameHashCache::CachePathName(const rational &time) const +QString FrameHashCache::cache_path_name(const Rational &time) const { - return CachePathName(GetCacheDirectory(), GetUuid(), time, timebase_); + return cache_path_name(get_cache_directory(), get_uuid(), time, timebase_); } -QString FrameHashCache::CachePathName(const QString &cache_path, +QString FrameHashCache::cache_path_name(const QString &cache_path, const QUuid &cache_id, const int64_t &time) { - QString filename = GetThisCacheDirectory(cache_path, cache_id) + QString filename = get_this_cache_directory(cache_path, cache_id) .filePath(QString::number(time)); // Register that in some way this hash has been accessed if (DiskManager::instance()) { - QMetaObject::invokeMethod(DiskManager::instance(), "Accessed", + QMetaObject::invokeMethod(DiskManager::instance(), "accessed", Q_ARG(QString, cache_path), Q_ARG(QString, filename)); } @@ -348,29 +348,29 @@ QString FrameHashCache::CachePathName(const QString &cache_path, return filename; } -QString FrameHashCache::CachePathName(const QString &cache_path, +QString FrameHashCache::cache_path_name(const QString &cache_path, const QUuid &cache_id, - const rational &time, const rational &tb) + const Rational &time, const Rational &tb) { - return CachePathName(cache_path, cache_id, + return cache_path_name(cache_path, cache_id, Timecode::time_to_timestamp(time, tb, - Timecode::kRound)); + Timecode::k_round)); } -bool FrameHashCache::SaveCacheFrame(const QString &filename, +bool FrameHashCache::save_cache_frame(const QString &filename, const FramePtr frame) { // Ensure directory is created QDir cache_dir = QFileInfo(filename).dir(); - if (!FileFunctions::DirectoryIsValid(cache_dir)) { + if (!FileFunctions::directory_is_valid(cache_dir)) { return false; } - if (VideoParams::FormatIsFloat(frame->format())) { + if (VideoParams::format_is_float(frame->format())) { // Floating point types are stored in EXR Imf::PixelType pix_type; - if (frame->format() == PixelFormat::F16) { + if (frame->format() == PixelFormat::f16) { pix_type = Imf::HALF; } else { pix_type = Imf::FLOAT; @@ -380,14 +380,14 @@ bool FrameHashCache::SaveCacheFrame(const QString &filename, header.channels().insert("R", Imf::Channel(pix_type)); header.channels().insert("G", Imf::Channel(pix_type)); header.channels().insert("B", Imf::Channel(pix_type)); - if (frame->channel_count() == VideoParams::kRGBAChannelCount) { + if (frame->channel_count() == VideoParams::k_rgba_channel_count) { header.channels().insert("A", Imf::Channel(pix_type)); } header.compression() = Imf::DWAA_COMPRESSION; header.insert("dwaCompressionLevel", Imf::FloatAttribute(200.0f)); header.pixelAspectRatio() = - frame->video_params().pixel_aspect_ratio().toDouble(); + frame->video_params().pixel_aspect_ratio().to_double(); header.insert("oliveDivider", Imf::IntAttribute(frame->video_params().divider())); @@ -395,7 +395,7 @@ bool FrameHashCache::SaveCacheFrame(const QString &filename, try { Imf::OutputFile out(filename.toUtf8(), header, 0); - int bpc = VideoParams::GetBytesPerChannel(frame->format()); + int bpc = VideoParams::get_bytes_per_channel(frame->format()); size_t xs = frame->channel_count() * bpc; size_t ys = frame->linesize_bytes(); @@ -407,7 +407,7 @@ bool FrameHashCache::SaveCacheFrame(const QString &filename, xs, ys)); framebuffer.insert( "B", Imf::Slice(pix_type, frame->data() + 2 * bpc, xs, ys)); - if (frame->channel_count() == VideoParams::kRGBAChannelCount) { + if (frame->channel_count() == VideoParams::k_rgba_channel_count) { framebuffer.insert( "A", Imf::Slice(pix_type, frame->data() + 3 * bpc, xs, ys)); } @@ -425,25 +425,25 @@ bool FrameHashCache::SaveCacheFrame(const QString &filename, QImage::Format fmt = QImage::Format_Invalid; switch (frame->format()) { - case PixelFormat::U8: - if (frame->channel_count() == VideoParams::kRGBAChannelCount) { + case PixelFormat::u8: + if (frame->channel_count() == VideoParams::k_rgba_channel_count) { fmt = QImage::Format_RGBA8888_Premultiplied; } else if (frame->channel_count() == - VideoParams::kRGBChannelCount) { + VideoParams::k_rgb_channel_count) { fmt = QImage::Format_RGB888; } break; - case PixelFormat::U10: + case PixelFormat::u10: break; - case PixelFormat::U16: - if (frame->channel_count() == VideoParams::kRGBAChannelCount) { + case PixelFormat::u16: + if (frame->channel_count() == VideoParams::k_rgba_channel_count) { fmt = QImage::Format_RGBA64_Premultiplied; } break; - case PixelFormat::F16: - case PixelFormat::F32: - case PixelFormat::COUNT: - case PixelFormat::INVALID: + case PixelFormat::f16: + case PixelFormat::f32: + case PixelFormat::count: + case PixelFormat::invalid: break; } diff --git a/app/render/framehashcache.h b/app/render/framehashcache.h index 100cd1d7a..ea67ded30 100644 --- a/app/render/framehashcache.h +++ b/app/render/framehashcache.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIDEORENDERFRAMECACHE_H -#define VIDEORENDERFRAMECACHE_H +#ifndef OAK_VIDEORENDERFRAMECACHE_H +#define OAK_VIDEORENDERFRAMECACHE_H #include "codec/frame.h" #include "render/playbackcache.h" @@ -34,64 +34,64 @@ class FrameHashCache : public PlaybackCache { public: FrameHashCache(QObject *parent = nullptr); - const rational &GetTimebase() const + const Rational &get_timebase() const { return timebase_; } - void SetTimebase(const rational &tb); + void set_timebase(const Rational &tb); - void ValidateTimestamp(const int64_t &ts); - void ValidateTime(const rational &time); + void validate_timestamp(const int64_t &ts); + void validate_time(const Rational &time); - bool IsFrameCached(const rational &time) const + bool is_frame_cached(const Rational &time) const { - return GetValidatedRanges().contains(time); + return get_validated_ranges().contains(time); } - QString GetValidCacheFilename(const rational &time) const; + QString get_valid_cache_filename(const Rational &time) const; - static bool SaveCacheFrame(const QString &filename, FramePtr frame); - bool SaveCacheFrame(const int64_t &time, FramePtr frame) const; - static bool SaveCacheFrame(const QString &cache_path, const QUuid &uuid, + static bool save_cache_frame(const QString &filename, FramePtr frame); + bool save_cache_frame(const int64_t &time, FramePtr frame) const; + static bool save_cache_frame(const QString &cache_path, const QUuid &uuid, const int64_t &time, FramePtr frame); - static bool SaveCacheFrame(const QString &cache_path, const QUuid &uuid, - const rational &time, const rational &tb, + static bool save_cache_frame(const QString &cache_path, const QUuid &uuid, + const Rational &time, const Rational &tb, FramePtr frame); - static FramePtr LoadCacheFrame(const QString &cache_path, const QUuid &uuid, + static FramePtr load_cache_frame(const QString &cache_path, const QUuid &uuid, const int64_t &time); - FramePtr LoadCacheFrame(const int64_t &time) const; - static FramePtr LoadCacheFrame(const QString &fn); + FramePtr load_cache_frame(const int64_t &time) const; + static FramePtr load_cache_frame(const QString &fn); - virtual void SetPassthrough(PlaybackCache *cache) override; + virtual void set_passthrough(PlaybackCache *cache) override; protected: virtual void LoadStateEvent(QDataStream &stream) override; virtual void SaveStateEvent(QDataStream &stream) override; private: - rational ToTime(const int64_t &ts) const; - int64_t ToTimestamp(const rational &ts, - Timecode::Rounding rounding = Timecode::kRound) const; + Rational to_time(const int64_t &ts) const; + int64_t to_timestamp(const Rational &ts, + Timecode::Rounding rounding = Timecode::k_round) const; /** * @brief Return the path of the cached image at this time */ - QString CachePathName(const int64_t &time) const; - QString CachePathName(const rational &time) const; + QString cache_path_name(const int64_t &time) const; + QString cache_path_name(const Rational &time) const; - static QString CachePathName(const QString &cache_path, + static QString cache_path_name(const QString &cache_path, const QUuid &cache_id, const int64_t &time); - static QString CachePathName(const QString &cache_path, - const QUuid &cache_id, const rational &time, - const rational &tb); + static QString cache_path_name(const QString &cache_path, + const QUuid &cache_id, const Rational &time, + const Rational &tb); - rational timebase_; + Rational timebase_; private slots: - void HashDeleted(const QString &path, const QString &filename); + void hash_deleted(const QString &path, const QString &filename); - void ProjectInvalidated(Project *p); + void project_invalidated(Project *p); }; class ThumbnailCache : public FrameHashCache { @@ -100,10 +100,10 @@ public: ThumbnailCache(QObject *parent = nullptr) : FrameHashCache(parent) { - SetTimebase(rational(1, 10)); + set_timebase(Rational(1, 10)); } }; } -#endif // VIDEORENDERFRAMECACHE_H +#endif // OAK_VIDEORENDERFRAMECACHE_H diff --git a/app/render/framemanager.cpp b/app/render/framemanager.cpp index d700a6a1e..54f0b2f29 100644 --- a/app/render/framemanager.cpp +++ b/app/render/framemanager.cpp @@ -28,14 +28,14 @@ namespace olive { FrameManager *FrameManager::instance_ = nullptr; -const int FrameManager::kFrameLifetime = 5000; +const int FrameManager::k_frame_lifetime = 5000; -void FrameManager::CreateInstance() +void FrameManager::create_instance() { instance_ = new FrameManager(); } -void FrameManager::DestroyInstance() +void FrameManager::destroy_instance() { delete instance_; instance_ = nullptr; @@ -46,19 +46,19 @@ FrameManager *FrameManager::instance() return instance_; } -char *FrameManager::Allocate(int size) +char *FrameManager::allocate(int size) { if (instance()) { - return instance()->AllocateFromPool(size); + return instance()->allocate_from_pool(size); } else { return new char[size]; } } -void FrameManager::Deallocate(int size, char *buffer) +void FrameManager::deallocate(int size, char *buffer) { if (instance()) { - instance()->DeallocateToPool(size, buffer); + instance()->deallocate_to_pool(size, buffer); } else { delete[] buffer; } @@ -66,13 +66,13 @@ void FrameManager::Deallocate(int size, char *buffer) FrameManager::FrameManager() { - clear_timer_.setInterval(kFrameLifetime); + clear_timer_.setInterval(k_frame_lifetime); connect(&clear_timer_, &QTimer::timeout, this, - &FrameManager::GarbageCollection); + &FrameManager::garbage_collection); clear_timer_.start(); } -char *FrameManager::AllocateFromPool(int size) +char *FrameManager::allocate_from_pool(int size) { QMutexLocker locker(&mutex_); @@ -90,7 +90,7 @@ char *FrameManager::AllocateFromPool(int size) return buf; } -void FrameManager::DeallocateToPool(int size, char *buffer) +void FrameManager::deallocate_to_pool(int size, char *buffer) { QMutexLocker locker(&mutex_); @@ -99,11 +99,11 @@ void FrameManager::DeallocateToPool(int size, char *buffer) buffer_list.push_back({ QDateTime::currentMSecsSinceEpoch(), buffer }); } -void FrameManager::GarbageCollection() +void FrameManager::garbage_collection() { QMutexLocker locker(&mutex_); - qint64 min_life = QDateTime::currentMSecsSinceEpoch() - kFrameLifetime; + qint64 min_life = QDateTime::currentMSecsSinceEpoch() - k_frame_lifetime; for (auto it = pool_.begin(); it != pool_.end(); it++) { std::list &list = it->second; diff --git a/app/render/framemanager.h b/app/render/framemanager.h index 14fd20616..2a5308480 100644 --- a/app/render/framemanager.h +++ b/app/render/framemanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef FRAMEMANAGER_H -#define FRAMEMANAGER_H +#ifndef OAK_FRAMEMANAGER_H +#define OAK_FRAMEMANAGER_H #include #include @@ -32,15 +32,15 @@ namespace olive class FrameManager : public QObject { Q_OBJECT public: - static void CreateInstance(); + static void create_instance(); - static void DestroyInstance(); + static void destroy_instance(); static FrameManager *instance(); - static char *Allocate(int size); + static char *allocate(int size); - static void Deallocate(int size, char *buffer); + static void deallocate(int size, char *buffer); private: FrameManager(); @@ -55,7 +55,7 @@ private: * * Thread-safe. */ - char *AllocateFromPool(int size); + char *allocate_from_pool(int size); /** * @brief Deallocate buffer @@ -65,11 +65,11 @@ private: * * Thread-safe. */ - void DeallocateToPool(int size, char *buffer); + void deallocate_to_pool(int size, char *buffer); static FrameManager *instance_; - static const int kFrameLifetime; + static const int k_frame_lifetime; struct Buffer { qint64 time; @@ -83,9 +83,9 @@ private: QTimer clear_timer_; private slots: - void GarbageCollection(); + void garbage_collection(); }; } -#endif // FRAMEMANAGER_H +#endif // OAK_FRAMEMANAGER_H diff --git a/app/render/interlacetexture.cpp b/app/render/interlacetexture.cpp index 08de4a662..f4d45f6c9 100644 --- a/app/render/interlacetexture.cpp +++ b/app/render/interlacetexture.cpp @@ -28,30 +28,30 @@ namespace olive { -TexturePtr Renderer::InterlaceTexture(TexturePtr top, TexturePtr bottom, +TexturePtr Renderer::interlace_texture(TexturePtr top, TexturePtr bottom, const VideoParams ¶ms) { color_cache_mutex_.lock(); if (interlace_texture_.isNull()) { interlace_texture_ = - CreateNativeShader(ShaderCode(FileFunctions::ReadFileAsString( + create_native_shader(ShaderCode(FileFunctions::read_file_as_string( QStringLiteral(":/shaders/interlace.frag")))); } color_cache_mutex_.unlock(); ShaderJob job; - job.Insert(QStringLiteral("top_tex_in"), - NodeValue(NodeValue::kTexture, QVariant::fromValue(top))); - job.Insert(QStringLiteral("bottom_tex_in"), - NodeValue(NodeValue::kTexture, QVariant::fromValue(bottom))); - job.Insert(QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, + job.insert(QStringLiteral("top_tex_in"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(top))); + job.insert(QStringLiteral("bottom_tex_in"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(bottom))); + job.insert(QStringLiteral("resolution_in"), + NodeValue(NodeValue::k_vec2, QVector2D(params.effective_width(), params.effective_height()))); - TexturePtr output = CreateTexture(params); + TexturePtr output = create_texture(params); - BlitToTexture(interlace_texture_, job, output.get()); + blit_to_texture(interlace_texture_, job, output.get()); return output; } diff --git a/app/render/ipc/frameslotpool.cpp b/app/render/ipc/frameslotpool.cpp index 218d54a33..9729d7f13 100644 --- a/app/render/ipc/frameslotpool.cpp +++ b/app/render/ipc/frameslotpool.cpp @@ -31,54 +31,54 @@ namespace { // Round `value` up to the next multiple of `align` (align must be a power of two). -size_t AlignUp(size_t value, size_t align) +size_t align_up(size_t value, size_t align) { return (value + (align - 1)) & ~(align - 1); } -constexpr size_t kAlign = 64; // Cache-line alignment for each sub-region. +constexpr size_t k_align = 64; // Cache-line alignment for each sub-region. } // namespace -size_t FrameSlotPool::BytesNeeded(uint32_t slot_count, size_t slot_data_bytes) +size_t FrameSlotPool::bytes_needed(uint32_t slot_count, size_t slot_data_bytes) { - const uint32_t ring_cap = RingCapacity(slot_count); - size_t total = AlignUp(sizeof(Header), kAlign); + const uint32_t ring_cap = ring_capacity(slot_count); + size_t total = align_up(sizeof(Header), k_align); total += - AlignUp(SpscRingBuffer::BytesNeeded(ring_cap), kAlign); // free ring + align_up(SpscRingBuffer::bytes_needed(ring_cap), k_align); // free ring total += - AlignUp(SpscRingBuffer::BytesNeeded(ring_cap), kAlign); // ready ring + align_up(SpscRingBuffer::bytes_needed(ring_cap), k_align); // ready ring total += - AlignUp(sizeof(FrameSlotMeta) * slot_count, kAlign); // metadata array - total += AlignUp(slot_data_bytes, kAlign) * slot_count; // pixel data blocks + align_up(sizeof(FrameSlotMeta) * slot_count, k_align); // metadata array + total += align_up(slot_data_bytes, k_align) * slot_count; // pixel data blocks return total; } -FrameSlotPool FrameSlotPool::Create(void *mem, uint32_t slot_count, +FrameSlotPool FrameSlotPool::create(void *mem, uint32_t slot_count, size_t slot_data_bytes) { FrameSlotPool pool; pool.base_ = reinterpret_cast(mem); - const uint32_t ring_cap = RingCapacity(slot_count); + const uint32_t ring_cap = ring_capacity(slot_count); size_t offset = 0; const size_t header_off = offset; - offset += AlignUp(sizeof(Header), kAlign); + offset += align_up(sizeof(Header), k_align); const size_t free_off = offset; - offset += AlignUp(SpscRingBuffer::BytesNeeded(ring_cap), kAlign); + offset += align_up(SpscRingBuffer::bytes_needed(ring_cap), k_align); const size_t ready_off = offset; - offset += AlignUp(SpscRingBuffer::BytesNeeded(ring_cap), kAlign); + offset += align_up(SpscRingBuffer::bytes_needed(ring_cap), k_align); const size_t meta_off = offset; - offset += AlignUp(sizeof(FrameSlotMeta) * slot_count, kAlign); + offset += align_up(sizeof(FrameSlotMeta) * slot_count, k_align); const size_t data_off = offset; pool.header_ = reinterpret_cast
(pool.base_ + header_off); - pool.header_->magic = kMagic; + pool.header_->magic = k_magic; pool.header_->slot_count = slot_count; pool.header_->slot_data_bytes = slot_data_bytes; pool.header_->free_ring_offset = free_off; @@ -86,8 +86,8 @@ FrameSlotPool FrameSlotPool::Create(void *mem, uint32_t slot_count, pool.header_->meta_offset = meta_off; pool.header_->data_offset = data_off; - pool.free_ring_ = SpscRingBuffer::Create(pool.base_ + free_off, ring_cap); - pool.ready_ring_ = SpscRingBuffer::Create(pool.base_ + ready_off, ring_cap); + pool.free_ring_ = SpscRingBuffer::create(pool.base_ + free_off, ring_cap); + pool.ready_ring_ = SpscRingBuffer::create(pool.base_ + ready_off, ring_cap); pool.meta_ = reinterpret_cast(pool.base_ + meta_off); pool.data_ = pool.base_ + data_off; @@ -95,19 +95,19 @@ FrameSlotPool FrameSlotPool::Create(void *mem, uint32_t slot_count, // Seed the free ring with every slot index so the filler can Acquire() immediately. for (uint32_t i = 0; i < slot_count; i++) { - pool.free_ring_->Push(i); + pool.free_ring_->push(i); } return pool; } -FrameSlotPool FrameSlotPool::Attach(void *mem) +FrameSlotPool FrameSlotPool::attach(void *mem) { FrameSlotPool pool; pool.base_ = reinterpret_cast(mem); pool.header_ = reinterpret_cast
(pool.base_); - if (pool.header_->magic != kMagic) { + if (pool.header_->magic != k_magic) { // Caller will see IsValid() == false via a null header reset. pool.header_ = nullptr; pool.base_ = nullptr; @@ -115,9 +115,9 @@ FrameSlotPool FrameSlotPool::Attach(void *mem) } pool.free_ring_ = - SpscRingBuffer::Attach(pool.base_ + pool.header_->free_ring_offset); + SpscRingBuffer::attach(pool.base_ + pool.header_->free_ring_offset); pool.ready_ring_ = - SpscRingBuffer::Attach(pool.base_ + pool.header_->ready_ring_offset); + SpscRingBuffer::attach(pool.base_ + pool.header_->ready_ring_offset); pool.meta_ = reinterpret_cast(pool.base_ + pool.header_->meta_offset); pool.data_ = pool.base_ + pool.header_->data_offset; @@ -135,44 +135,44 @@ size_t FrameSlotPool::slot_data_bytes() const return header_ ? size_t(header_->slot_data_bytes) : 0; } -bool FrameSlotPool::Acquire(uint32_t *index) +bool FrameSlotPool::acquire(uint32_t *index) { - return free_ring_->Pop(index); + return free_ring_->pop(index); } -void *FrameSlotPool::SlotData(uint32_t index) +void *FrameSlotPool::slot_data(uint32_t index) { - return data_ + size_t(index) * AlignUp(slot_data_bytes(), kAlign); + return data_ + size_t(index) * align_up(slot_data_bytes(), k_align); } -const void *FrameSlotPool::SlotData(uint32_t index) const +const void *FrameSlotPool::slot_data(uint32_t index) const { - return data_ + size_t(index) * AlignUp(slot_data_bytes(), kAlign); + return data_ + size_t(index) * align_up(slot_data_bytes(), k_align); } -FrameSlotMeta *FrameSlotPool::Meta(uint32_t index) +FrameSlotMeta *FrameSlotPool::meta(uint32_t index) { return &meta_[index]; } -const FrameSlotMeta *FrameSlotPool::Meta(uint32_t index) const +const FrameSlotMeta *FrameSlotPool::meta(uint32_t index) const { return &meta_[index]; } -bool FrameSlotPool::Publish(uint32_t index) +bool FrameSlotPool::publish(uint32_t index) { - return ready_ring_->Push(index); + return ready_ring_->push(index); } -bool FrameSlotPool::Consume(uint32_t *index) +bool FrameSlotPool::consume(uint32_t *index) { - return ready_ring_->Pop(index); + return ready_ring_->pop(index); } -bool FrameSlotPool::Release(uint32_t index) +bool FrameSlotPool::release(uint32_t index) { - return free_ring_->Push(index); + return free_ring_->push(index); } } // namespace ipc diff --git a/app/render/ipc/frameslotpool.h b/app/render/ipc/frameslotpool.h index 39020fd9d..27fb5c378 100644 --- a/app/render/ipc/frameslotpool.h +++ b/app/render/ipc/frameslotpool.h @@ -18,8 +18,8 @@ ***/ -#ifndef IPC_FRAMESLOTPOOL_H -#define IPC_FRAMESLOTPOOL_H +#ifndef OAK_IPC_FRAMESLOTPOOL_H +#define OAK_IPC_FRAMESLOTPOOL_H #include #include @@ -36,7 +36,7 @@ namespace ipc * * Trivially-copyable POD that lives in shared memory alongside the pixel data. Carries everything * the consumer needs to reconstruct an olive::Frame without any out-of-band information. We store - * the rational timestamp as an explicit numerator/denominator pair to stay POD (olive::rational is + * the Rational timestamp as an explicit numerator/denominator pair to stay POD (olive::Rational is * not guaranteed shared-memory-safe). */ struct FrameSlotMeta { @@ -82,7 +82,7 @@ public: /** * @brief Total bytes a region must provide to back a pool of `slot_count` x `slot_data_bytes`. */ - static size_t BytesNeeded(uint32_t slot_count, size_t slot_data_bytes); + static size_t bytes_needed(uint32_t slot_count, size_t slot_data_bytes); /** * @brief Lay out and initialize a brand-new pool over `mem` (owner side, once). @@ -90,7 +90,7 @@ public: * Initializes both rings, seeds the free ring with every slot index, and zeroes metadata. * `mem` must provide at least BytesNeeded(slot_count, slot_data_bytes) bytes. */ - static FrameSlotPool Create(void *mem, uint32_t slot_count, + static FrameSlotPool create(void *mem, uint32_t slot_count, size_t slot_data_bytes); /** @@ -98,9 +98,9 @@ public: * * Reads slot_count/slot_data_bytes from the in-memory header written by Create(). */ - static FrameSlotPool Attach(void *mem); + static FrameSlotPool attach(void *mem); - bool IsValid() const + bool is_valid() const { return header_ != nullptr; } @@ -113,37 +113,37 @@ public: /** * @brief Take ownership of a free slot. Returns false (and leaves *index untouched) if none free. */ - bool Acquire(uint32_t *index); + bool acquire(uint32_t *index); /** * @brief Pointer to a slot's pixel data block (slot_data_bytes available). */ - void *SlotData(uint32_t index); + void *slot_data(uint32_t index); /** * @brief Mutable metadata for a slot. Filler writes this before Publish(). */ - FrameSlotMeta *Meta(uint32_t index); + FrameSlotMeta *meta(uint32_t index); /** * @brief Publish a filled slot to the drainer. Must follow a successful Acquire() of `index`. */ - bool Publish(uint32_t index); + bool publish(uint32_t index); // ---- Drainer side ---- /** * @brief Take the next published slot. Returns false if nothing is ready. */ - bool Consume(uint32_t *index); + bool consume(uint32_t *index); /** * @brief Return a consumed slot to the free pool for reuse. Must follow Consume() of `index`. */ - bool Release(uint32_t index); + bool release(uint32_t index); - const FrameSlotMeta *Meta(uint32_t index) const; - const void *SlotData(uint32_t index) const; + const FrameSlotMeta *meta(uint32_t index) const; + const void *slot_data(uint32_t index) const; public: FrameSlotPool() = default; @@ -160,11 +160,11 @@ private: uint64_t data_offset; }; - static constexpr uint32_t kMagic = 0x4F4B5350; // 'OKSP' + static constexpr uint32_t k_magic = 0x4F4B5350; // 'OKSP' // Ring capacity must exceed slot_count by one because a ring can hold at most capacity-1 entries // and we need to be able to enqueue every slot at once. - static uint32_t RingCapacity(uint32_t slot_count) + static uint32_t ring_capacity(uint32_t slot_count) { return slot_count + 1; } @@ -180,4 +180,4 @@ private: } // namespace ipc } // namespace olive -#endif // IPC_FRAMESLOTPOOL_H \ No newline at end of file +#endif // OAK_IPC_FRAMESLOTPOOL_H \ No newline at end of file diff --git a/app/render/ipc/ipcmessage.cpp b/app/render/ipc/ipcmessage.cpp index 90aac2a09..0309ad2f3 100644 --- a/app/render/ipc/ipcmessage.cpp +++ b/app/render/ipc/ipcmessage.cpp @@ -29,14 +29,14 @@ namespace olive namespace ipc { -bool WriteMessage(QIODevice *device, const QJsonObject &obj) +bool write_message(QIODevice *device, const QJsonObject &obj) { QByteArray line = QJsonDocument(obj).toJson(QJsonDocument::Compact); line.append('\n'); return device->write(line) == line.size(); } -bool ReadMessage(QByteArray *buffer, QJsonObject *out, bool *ok) +bool read_message(QByteArray *buffer, QJsonObject *out, bool *ok) { while (true) { const int newline = buffer->indexOf('\n'); @@ -72,10 +72,10 @@ bool ReadMessage(QByteArray *buffer, QJsonObject *out, bool *ok) // ---- HandshakeMsg --------------------------------------------------------------------------- -QJsonObject HandshakeMsg::ToJson() const +QJsonObject HandshakeMsg::to_json() const { QJsonObject o; - o["type"] = msgtype::kHandshake; + o["type"] = msgtype::k_handshake; o["protocol_version"] = protocol_version; o["shm_key"] = shm_key; o["input_shm_key"] = input_shm_key; @@ -86,9 +86,9 @@ QJsonObject HandshakeMsg::ToJson() const return o; } -bool HandshakeMsg::FromJson(const QJsonObject &o, HandshakeMsg *out) +bool HandshakeMsg::from_json(const QJsonObject &o, HandshakeMsg *out) { - if (o["type"].toString() != QLatin1String(msgtype::kHandshake)) { + if (o["type"].toString() != QLatin1String(msgtype::k_handshake)) { return false; } out->protocol_version = o["protocol_version"].toInt(); @@ -103,10 +103,10 @@ bool HandshakeMsg::FromJson(const QJsonObject &o, HandshakeMsg *out) // ---- RenderFrameMsg ------------------------------------------------------------------------- -QJsonObject RenderFrameMsg::ToJson() const +QJsonObject RenderFrameMsg::to_json() const { QJsonObject o; - o["type"] = msgtype::kRenderFrame; + o["type"] = msgtype::k_render_frame; o["ticket"] = double(ticket_id); o["node"] = node_uuid; o["time_num"] = double(time_num); @@ -133,9 +133,9 @@ QJsonObject RenderFrameMsg::ToJson() const return o; } -bool RenderFrameMsg::FromJson(const QJsonObject &o, RenderFrameMsg *out) +bool RenderFrameMsg::from_json(const QJsonObject &o, RenderFrameMsg *out) { - if (o["type"].toString() != QLatin1String(msgtype::kRenderFrame)) { + if (o["type"].toString() != QLatin1String(msgtype::k_render_frame)) { return false; } out->ticket_id = qint64(o["ticket"].toDouble()); @@ -169,18 +169,18 @@ bool RenderFrameMsg::FromJson(const QJsonObject &o, RenderFrameMsg *out) // ---- FrameReadyMsg -------------------------------------------------------------------------- -QJsonObject FrameReadyMsg::ToJson() const +QJsonObject FrameReadyMsg::to_json() const { QJsonObject o; - o["type"] = msgtype::kFrameReady; + o["type"] = msgtype::k_frame_ready; o["ticket"] = double(ticket_id); o["slot"] = output_slot; return o; } -bool FrameReadyMsg::FromJson(const QJsonObject &o, FrameReadyMsg *out) +bool FrameReadyMsg::from_json(const QJsonObject &o, FrameReadyMsg *out) { - if (o["type"].toString() != QLatin1String(msgtype::kFrameReady)) { + if (o["type"].toString() != QLatin1String(msgtype::k_frame_ready)) { return false; } out->ticket_id = qint64(o["ticket"].toDouble()); @@ -190,17 +190,17 @@ bool FrameReadyMsg::FromJson(const QJsonObject &o, FrameReadyMsg *out) // ---- CancelMsg ------------------------------------------------------------------------------ -QJsonObject CancelMsg::ToJson() const +QJsonObject CancelMsg::to_json() const { QJsonObject o; - o["type"] = msgtype::kCancel; + o["type"] = msgtype::k_cancel; o["ticket"] = double(ticket_id); return o; } -bool CancelMsg::FromJson(const QJsonObject &o, CancelMsg *out) +bool CancelMsg::from_json(const QJsonObject &o, CancelMsg *out) { - if (o["type"].toString() != QLatin1String(msgtype::kCancel)) { + if (o["type"].toString() != QLatin1String(msgtype::k_cancel)) { return false; } out->ticket_id = qint64(o["ticket"].toDouble()); @@ -209,17 +209,17 @@ bool CancelMsg::FromJson(const QJsonObject &o, CancelMsg *out) // ---- LoadGraphMsg --------------------------------------------------------------------------- -QJsonObject LoadGraphMsg::ToJson() const +QJsonObject LoadGraphMsg::to_json() const { QJsonObject o; - o["type"] = msgtype::kLoadGraph; + o["type"] = msgtype::k_load_graph; o["path"] = path; return o; } -bool LoadGraphMsg::FromJson(const QJsonObject &o, LoadGraphMsg *out) +bool LoadGraphMsg::from_json(const QJsonObject &o, LoadGraphMsg *out) { - if (o["type"].toString() != QLatin1String(msgtype::kLoadGraph)) { + if (o["type"].toString() != QLatin1String(msgtype::k_load_graph)) { return false; } out->path = o["path"].toString(); diff --git a/app/render/ipc/ipcmessage.h b/app/render/ipc/ipcmessage.h index f822dd2e4..4cd40e912 100644 --- a/app/render/ipc/ipcmessage.h +++ b/app/render/ipc/ipcmessage.h @@ -18,8 +18,8 @@ ***/ -#ifndef IPC_IPCMESSAGE_H -#define IPC_IPCMESSAGE_H +#ifndef OAK_IPC_IPCMESSAGE_H +#define OAK_IPC_IPCMESSAGE_H #include #include @@ -55,14 +55,14 @@ namespace ipc */ namespace msgtype { -constexpr const char *kHandshake = "handshake"; -constexpr const char *kLoadGraph = "load_graph"; -constexpr const char *kRenderFrame = "render_frame"; -constexpr const char *kFrameReady = "frame_ready"; -constexpr const char *kCancel = "cancel"; -constexpr const char *kGraphUpdate = "graph_update"; -constexpr const char *kShutdown = "shutdown"; -constexpr const char *kError = "error"; +constexpr const char *k_handshake = "handshake"; +constexpr const char *k_load_graph = "load_graph"; +constexpr const char *k_render_frame = "render_frame"; +constexpr const char *k_frame_ready = "frame_ready"; +constexpr const char *k_cancel = "cancel"; +constexpr const char *k_graph_update = "graph_update"; +constexpr const char *k_shutdown = "shutdown"; +constexpr const char *k_error = "error"; } // namespace msgtype /** @@ -71,7 +71,7 @@ constexpr const char *kError = "error"; * Serializes `obj` to compact JSON, appends '\n', and writes the whole line in one call. Returns * true only if the full line was written. */ -bool WriteMessage(QIODevice *device, const QJsonObject &obj); +bool write_message(QIODevice *device, const QJsonObject &obj); /** * @brief Pull one complete NDJSON line out of `buffer` and parse it. @@ -82,7 +82,7 @@ bool WriteMessage(QIODevice *device, const QJsonObject &obj); * and continue rather than wedge. Supports the typical "append bytes as they arrive, then drain * complete lines" reader loop on a pipe. */ -bool ReadMessage(QByteArray *buffer, QJsonObject *out, bool *ok = nullptr); +bool read_message(QByteArray *buffer, QJsonObject *out, bool *ok = nullptr); // ---- Typed message builders / parsers ------------------------------------------------------- // @@ -100,8 +100,8 @@ struct HandshakeMsg { qint64 slot_data_bytes = 0; ///< Per-output-slot pixel block size. qint64 input_slot_data_bytes = 0; ///< Per-input-slot pixel block size. - QJsonObject ToJson() const; - static bool FromJson(const QJsonObject &o, HandshakeMsg *out); + QJsonObject to_json() const; + static bool from_json(const QJsonObject &o, HandshakeMsg *out); }; struct RenderFrameMsg { @@ -129,33 +129,33 @@ struct RenderFrameMsg { QString color_view; QString color_look; - QJsonObject ToJson() const; - static bool FromJson(const QJsonObject &o, RenderFrameMsg *out); + QJsonObject to_json() const; + static bool from_json(const QJsonObject &o, RenderFrameMsg *out); }; struct FrameReadyMsg { qint64 ticket_id = 0; int output_slot = 0; ///< Index into the worker->main output FrameSlotPool. - QJsonObject ToJson() const; - static bool FromJson(const QJsonObject &o, FrameReadyMsg *out); + QJsonObject to_json() const; + static bool from_json(const QJsonObject &o, FrameReadyMsg *out); }; struct CancelMsg { qint64 ticket_id = 0; - QJsonObject ToJson() const; - static bool FromJson(const QJsonObject &o, CancelMsg *out); + QJsonObject to_json() const; + static bool from_json(const QJsonObject &o, CancelMsg *out); }; struct LoadGraphMsg { QString path; ///< Temporary file holding the serialized node graph. - QJsonObject ToJson() const; - static bool FromJson(const QJsonObject &o, LoadGraphMsg *out); + QJsonObject to_json() const; + static bool from_json(const QJsonObject &o, LoadGraphMsg *out); }; } // namespace ipc } // namespace olive -#endif // IPC_IPCMESSAGE_H +#endif // OAK_IPC_IPCMESSAGE_H diff --git a/app/render/ipc/sharedmemoryregion.cpp b/app/render/ipc/sharedmemoryregion.cpp index 3d58382d9..860dc14ac 100644 --- a/app/render/ipc/sharedmemoryregion.cpp +++ b/app/render/ipc/sharedmemoryregion.cpp @@ -41,7 +41,7 @@ namespace ipc SharedMemoryRegion::SharedMemoryRegion() : size_(0) , data_(nullptr) - , mode_(kAttach) + , mode_(k_attach) #if defined(Q_OS_WIN) , handle_(nullptr) #else @@ -52,10 +52,10 @@ SharedMemoryRegion::SharedMemoryRegion() SharedMemoryRegion::~SharedMemoryRegion() { - Close(); + close(); } -QString SharedMemoryRegion::MakeKey(qint64 owner_pid, int worker_index) +QString SharedMemoryRegion::make_key(qint64 owner_pid, int worker_index) { return QStringLiteral("olive-rw-%1-%2").arg(owner_pid).arg(worker_index); } @@ -131,9 +131,9 @@ void SharedMemoryRegion::Close() #else // POSIX -bool SharedMemoryRegion::Open(const QString &key, size_t size, Mode mode) +bool SharedMemoryRegion::open(const QString &key, size_t size, Mode mode) { - Close(); + close(); key_ = key; size_ = size; @@ -144,7 +144,7 @@ bool SharedMemoryRegion::Open(const QString &key, size_t size, Mode mode) const QByteArray name_bytes = shm_name_.toUtf8(); int oflag = O_RDWR; - if (mode == kCreate) { + if (mode == k_create) { oflag |= O_CREAT | O_EXCL; // Clear any stale segment left by a crashed previous run with the same name. shm_unlink(name_bytes.constData()); @@ -157,7 +157,7 @@ bool SharedMemoryRegion::Open(const QString &key, size_t size, Mode mode) return false; } - if (mode == kCreate) { + if (mode == k_create) { if (ftruncate(fd_, off_t(size)) != 0) { error_ = QStringLiteral("ftruncate failed: %1") .arg(QString::fromUtf8(strerror(errno))); @@ -195,19 +195,19 @@ bool SharedMemoryRegion::Open(const QString &key, size_t size, Mode mode) data_ = nullptr; ::close(fd_); fd_ = -1; - if (mode == kCreate) { + if (mode == k_create) { shm_unlink(name_bytes.constData()); } return false; } - if (mode == kCreate) { + if (mode == k_create) { memset(data_, 0, size); } return true; } -void SharedMemoryRegion::Close() +void SharedMemoryRegion::close() { if (data_) { munmap(data_, size_); @@ -217,7 +217,7 @@ void SharedMemoryRegion::Close() ::close(fd_); fd_ = -1; } - if (mode_ == kCreate && !shm_name_.isEmpty()) { + if (mode_ == k_create && !shm_name_.isEmpty()) { // Only the owner unlinks, so the name is freed once both sides have unmapped. shm_unlink(shm_name_.toUtf8().constData()); shm_name_.clear(); diff --git a/app/render/ipc/sharedmemoryregion.h b/app/render/ipc/sharedmemoryregion.h index 31437b5e2..e6af0ef66 100644 --- a/app/render/ipc/sharedmemoryregion.h +++ b/app/render/ipc/sharedmemoryregion.h @@ -18,8 +18,8 @@ ***/ -#ifndef IPC_SHAREDMEMORYREGION_H -#define IPC_SHAREDMEMORYREGION_H +#ifndef OAK_IPC_SHAREDMEMORYREGION_H +#define OAK_IPC_SHAREDMEMORYREGION_H #include #include @@ -46,9 +46,9 @@ class SharedMemoryRegion { public: enum Mode { /// Create (and own) the segment. Fails if it already exists; unlinks on destruction. - kCreate, + k_create, /// Attach to a segment created by the peer. Does not unlink on destruction. - kAttach + k_attach }; SharedMemoryRegion(); @@ -63,14 +63,14 @@ public: * `key` is a short identifier (no leading slash needed; the platform prefix is added internally). * Returns true on success. On failure, error() carries a human-readable reason. */ - bool Open(const QString &key, size_t size, Mode mode); + bool open(const QString &key, size_t size, Mode mode); /** * @brief Unmap and (if owner) unlink the segment. Called automatically by the destructor. */ - void Close(); + void close(); - bool IsValid() const + bool is_valid() const { return data_ != nullptr; } @@ -100,7 +100,7 @@ public: * * Centralized so the owner and the spawned worker agree on the same name. */ - static QString MakeKey(qint64 owner_pid, int worker_index); + static QString make_key(qint64 owner_pid, int worker_index); private: QString key_; @@ -120,4 +120,4 @@ private: } // namespace ipc } // namespace olive -#endif // IPC_SHAREDMEMORYREGION_H \ No newline at end of file +#endif // OAK_IPC_SHAREDMEMORYREGION_H \ No newline at end of file diff --git a/app/render/ipc/spscringbuffer.h b/app/render/ipc/spscringbuffer.h index 200eb8fb6..0ef6ae028 100644 --- a/app/render/ipc/spscringbuffer.h +++ b/app/render/ipc/spscringbuffer.h @@ -18,8 +18,8 @@ ***/ -#ifndef IPC_SPSCRINGBUFFER_H -#define IPC_SPSCRINGBUFFER_H +#ifndef OAK_IPC_SPSCRINGBUFFER_H +#define OAK_IPC_SPSCRINGBUFFER_H #include #include @@ -60,7 +60,7 @@ public: * intended to be placement-style initialization performed exactly once by whichever process owns * the segment's creation; the peer process uses Attach() instead. */ - static SpscRingBuffer *Create(void *mem, uint32_t capacity) + static SpscRingBuffer *create(void *mem, uint32_t capacity) { auto *self = reinterpret_cast(mem); self->capacity_ = capacity; @@ -77,7 +77,7 @@ public: * * No writes are performed; the cursors and capacity are assumed already set by Create(). */ - static SpscRingBuffer *Attach(void *mem) + static SpscRingBuffer *attach(void *mem) { return reinterpret_cast(mem); } @@ -85,7 +85,7 @@ public: /** * @brief Total bytes required to hold the header plus `capacity` index slots. */ - static size_t BytesNeeded(uint32_t capacity) + static size_t bytes_needed(uint32_t capacity) { return sizeof(SpscRingBuffer) + size_t(capacity) * sizeof(uint32_t); } @@ -93,10 +93,10 @@ public: /** * @brief Producer side: enqueue an index. Returns false if the buffer is full. */ - bool Push(uint32_t value) + bool push(uint32_t value) { const uint32_t head = head_.load(std::memory_order_relaxed); - const uint32_t next = Increment(head); + const uint32_t next = increment(head); // Buffer is full if advancing head would collide with the consumer's tail. if (next == tail_.load(std::memory_order_acquire)) { @@ -111,7 +111,7 @@ public: /** * @brief Consumer side: dequeue an index into `out`. Returns false if the buffer is empty. */ - bool Pop(uint32_t *out) + bool pop(uint32_t *out) { const uint32_t tail = tail_.load(std::memory_order_relaxed); @@ -121,7 +121,7 @@ public: } *out = slot_array()[tail]; - tail_.store(Increment(tail), std::memory_order_release); + tail_.store(increment(tail), std::memory_order_release); return true; } @@ -131,14 +131,14 @@ public: * Safe to call from either side, but the value may be stale the instant it returns. Intended for * metrics/backpressure heuristics, not for correctness decisions. */ - uint32_t SizeApprox() const + uint32_t size_approx() const { const uint32_t head = head_.load(std::memory_order_acquire); const uint32_t tail = tail_.load(std::memory_order_acquire); return (head + capacity_ - tail) % capacity_; } - bool IsEmptyApprox() const + bool is_empty_approx() const { return head_.load(std::memory_order_acquire) == tail_.load(std::memory_order_acquire); @@ -150,7 +150,7 @@ public: } private: - uint32_t Increment(uint32_t index) const + uint32_t increment(uint32_t index) const { // capacity_ is small and this avoids requiring a power-of-two capacity. return (index + 1) % capacity_; @@ -182,4 +182,4 @@ private: } // namespace ipc } // namespace olive -#endif // IPC_SPSCRINGBUFFER_H +#endif // OAK_IPC_SPSCRINGBUFFER_H diff --git a/app/render/job/acceleratedjob.h b/app/render/job/acceleratedjob.h index d2410595e..c98509504 100644 --- a/app/render/job/acceleratedjob.h +++ b/app/render/job/acceleratedjob.h @@ -19,8 +19,8 @@ ***/ -#ifndef ACCELERATEDJOB_H -#define ACCELERATEDJOB_H +#ifndef OAK_ACCELERATEDJOB_H +#define OAK_ACCELERATEDJOB_H #include "node/param.h" #include "node/valuedatabase.h" @@ -36,22 +36,22 @@ public: { } - virtual NodeValue Get(const QString &input) const + virtual NodeValue get(const QString &input) const { return value_map_.value(input); } - virtual void Insert(const QString &input, const NodeValueRow &row) + virtual void insert(const QString &input, const NodeValueRow &row) { value_map_.insert(input, row.value(input)); } - virtual void Insert(const QString &input, const NodeValue &value) + virtual void insert(const QString &input, const NodeValue &value) { value_map_.insert(input, value); } - virtual void Insert(const NodeValueRow &row) + virtual void insert(const NodeValueRow &row) { #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) value_map_.insert(row); @@ -62,11 +62,11 @@ public: #endif } - virtual const NodeValueRow &GetValues() const + virtual const NodeValueRow &get_values() const { return value_map_; } - virtual NodeValueRow &GetValues() + virtual NodeValueRow &get_values() { return value_map_; } @@ -77,4 +77,4 @@ protected: } -#endif // ACCELERATEDJOB_H +#endif // OAK_ACCELERATEDJOB_H diff --git a/app/render/job/cachejob.h b/app/render/job/cachejob.h index cff208992..22d2e1147 100644 --- a/app/render/job/cachejob.h +++ b/app/render/job/cachejob.h @@ -19,8 +19,8 @@ ***/ -#ifndef CACHEJOB_H -#define CACHEJOB_H +#ifndef OAK_CACHEJOB_H +#define OAK_CACHEJOB_H #include #include @@ -39,20 +39,20 @@ public: filename_ = filename; } - const QString &GetFilename() const + const QString &get_filename() const { return filename_; } - void SetFilename(const QString &s) + void set_filename(const QString &s) { filename_ = s; } - const NodeValue &GetFallback() const + const NodeValue &get_fallback() const { return fallback_; } - void SetFallback(const NodeValue &val) + void set_fallback(const NodeValue &val) { fallback_ = val; } @@ -65,4 +65,4 @@ private: } -#endif // CACHEJOB_H +#endif // OAK_CACHEJOB_H diff --git a/app/render/job/colortransformjob.h b/app/render/job/colortransformjob.h index f2ccead64..b61db2445 100644 --- a/app/render/job/colortransformjob.h +++ b/app/render/job/colortransformjob.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORTRANSFORMJOB_H -#define COLORTRANSFORMJOB_H +#ifndef OAK_COLORTRANSFORMJOB_H +#define OAK_COLORTRANSFORMJOB_H #include #include @@ -41,7 +41,7 @@ public: { processor_ = nullptr; custom_shader_src_ = nullptr; - input_alpha_association_ = kAlphaNone; + input_alpha_association_ = k_alpha_none; clear_destination_ = true; force_opaque_ = false; } @@ -49,7 +49,7 @@ public: ColorTransformJob(const NodeValueRow &row) : ColorTransformJob() { - Insert(row); + insert(row); } QString id() const @@ -61,98 +61,98 @@ public: } } - void SetOverrideID(const QString &id) + void set_override_id(const QString &id) { id_ = id; } - const NodeValue &GetInputTexture() const + const NodeValue &get_input_texture() const { return input_texture_; } - void SetInputTexture(const NodeValue &tex) + void set_input_texture(const NodeValue &tex) { input_texture_ = tex; } - void SetInputTexture(TexturePtr tex) + void set_input_texture(TexturePtr tex) { - Q_ASSERT(!tex->IsDummy()); - input_texture_ = NodeValue(NodeValue::kTexture, tex); + Q_ASSERT(!tex->is_dummy()); + input_texture_ = NodeValue(NodeValue::k_texture, tex); } - ColorProcessorPtr GetColorProcessor() const + ColorProcessorPtr get_color_processor() const { return processor_; } - void SetColorProcessor(ColorProcessorPtr p) + void set_color_processor(ColorProcessorPtr p) { processor_ = p; } - const AlphaAssociated &GetInputAlphaAssociation() const + const AlphaAssociated &get_input_alpha_association() const { return input_alpha_association_; } - void SetInputAlphaAssociation(const AlphaAssociated &e) + void set_input_alpha_association(const AlphaAssociated &e) { input_alpha_association_ = e; } - const Node *CustomShaderSource() const + const Node *custom_shader_source() const { return custom_shader_src_; } - const QString &CustomShaderID() const + const QString &custom_shader_id() const { return custom_shader_id_; } - void SetNeedsCustomShader(const Node *node, const QString &id = QString()) + void set_needs_custom_shader(const Node *node, const QString &id = QString()) { custom_shader_src_ = node; custom_shader_id_ = id; } - bool IsClearDestinationEnabled() const + bool is_clear_destination_enabled() const { return clear_destination_; } - void SetClearDestinationEnabled(bool e) + void set_clear_destination_enabled(bool e) { clear_destination_ = e; } - const QMatrix4x4 &GetTransformMatrix() const + const QMatrix4x4 &get_transform_matrix() const { return matrix_; } - void SetTransformMatrix(const QMatrix4x4 &m) + void set_transform_matrix(const QMatrix4x4 &m) { matrix_ = m; } - const QMatrix4x4 &GetCropMatrix() const + const QMatrix4x4 &get_crop_matrix() const { return crop_matrix_; } - void SetCropMatrix(const QMatrix4x4 &m) + void set_crop_matrix(const QMatrix4x4 &m) { crop_matrix_ = m; } - const QString &GetFunctionName() const + const QString &get_function_name() const { return function_name_; } - void SetFunctionName(const QString &function_name = QString()) + void set_function_name(const QString &function_name = QString()) { function_name_ = function_name; }; - bool GetForceOpaque() const + bool get_force_opaque() const { return force_opaque_; } - void SetForceOpaque(bool e) + void set_force_opaque(bool e) { force_opaque_ = e; } @@ -181,4 +181,4 @@ private: } -#endif // COLORTRANSFORMJOB_H +#endif // OAK_COLORTRANSFORMJOB_H diff --git a/app/render/job/footagejob.h b/app/render/job/footagejob.h index e5e8e386c..ecb6851fa 100644 --- a/app/render/job/footagejob.h +++ b/app/render/job/footagejob.h @@ -19,8 +19,8 @@ ***/ -#ifndef FOOTAGEJOB_H -#define FOOTAGEJOB_H +#ifndef OAK_FOOTAGEJOB_H +#define OAK_FOOTAGEJOB_H #include "node/project/footage/footage.h" @@ -30,13 +30,13 @@ namespace olive class FootageJob : public AcceleratedJob { public: FootageJob() - : type_(Track::kNone) + : type_(Track::k_none) { } FootageJob(const TimeRange &time, const QString &decoder, const QString &filename, Track::Type type, - const rational &length, LoopMode loop_mode) + const Rational &length, LoopMode loop_mode) : time_(time) , decoder_(decoder) , filename_(filename) @@ -120,12 +120,12 @@ public: cache_path_ = p; } - const rational &length() const + const Rational &length() const { return length_; } - void set_length(const rational &length) + void set_length(const Rational &length) { length_ = length; } @@ -167,7 +167,7 @@ private: QString cache_path_; - rational length_; + Rational length_; LoopMode loop_mode_; }; @@ -176,4 +176,4 @@ private: Q_DECLARE_METATYPE(olive::FootageJob) -#endif // FOOTAGEJOB_H +#endif // OAK_FOOTAGEJOB_H diff --git a/app/render/job/generatejob.h b/app/render/job/generatejob.h index 934598efc..2eae246d2 100644 --- a/app/render/job/generatejob.h +++ b/app/render/job/generatejob.h @@ -19,8 +19,8 @@ ***/ -#ifndef GENERATEJOB_H -#define GENERATEJOB_H +#ifndef OAK_GENERATEJOB_H +#define OAK_GENERATEJOB_H #include "acceleratedjob.h" #include "codec/frame.h" @@ -34,10 +34,10 @@ public: GenerateJob(const NodeValueRow &row) : GenerateJob() { - Insert(row); + insert(row); } }; } -#endif // GENERATEJOB_H +#endif // OAK_GENERATEJOB_H diff --git a/app/render/job/pluginjob.h b/app/render/job/pluginjob.h index 985c303cc..8c772c655 100644 --- a/app/render/job/pluginjob.h +++ b/app/render/job/pluginjob.h @@ -17,10 +17,10 @@ * */ -#ifndef PLUGINJOB_H -#define PLUGINJOB_H +#ifndef OAK_PLUGINJOB_H +#define OAK_PLUGINJOB_H #include "acceleratedjob.h" -#include "pluginSupport/OlivePluginInstance.h" +#include "pluginSupport/oliveplugininstance.h" #include "olive/core/util/rational.h" #include @@ -33,19 +33,19 @@ namespace plugin class PluginJob : public AcceleratedJob { public: - explicit PluginJob(const OFX::Host::ImageEffect::Instance *pluginInstance, + explicit PluginJob(const OFX::Host::ImageEffect::Instance *plugin_instance, const PluginNode *node, NodeValueRow row, - const olive::core::rational &time) + const olive::core::Rational &time) : AcceleratedJob() - , time_seconds_(time.toDouble()) + , time_seconds_(time.to_double()) { - this->pluginInstance_ = pluginInstance; + this->pluginInstance_ = plugin_instance; this->node_ = node; - Insert(row); + insert(row); } - explicit PluginJob(const OFX::Host::ImageEffect::Instance *pluginInstance, + explicit PluginJob(const OFX::Host::ImageEffect::Instance *plugin_instance, const PluginNode *node, NodeValueRow row) - : PluginJob(pluginInstance, node, row, olive::core::rational(0)) + : PluginJob(plugin_instance, node, row, olive::core::Rational(0)) { } @@ -54,7 +54,7 @@ public: return const_cast(node_); } - OFX::Host::ImageEffect::Instance *pluginInstance() + OFX::Host::ImageEffect::Instance *plugin_instance() { return const_cast(pluginInstance_); } @@ -67,9 +67,9 @@ public: private: const OFX::Host::ImageEffect::Instance *pluginInstance_ = nullptr; - QHash> paramsOnTime; + QHash> paramsOnTime_; - QHash params; + QHash params_; const PluginNode *node_ = nullptr; double time_seconds_ = 0.0; @@ -78,4 +78,4 @@ private: } // plugin } // olive -#endif //PLUGINJOB_H +#endif //OAK_PLUGINJOB_H diff --git a/app/render/job/samplejob.h b/app/render/job/samplejob.h index dbabc2079..bb252aa11 100644 --- a/app/render/job/samplejob.h +++ b/app/render/job/samplejob.h @@ -19,8 +19,8 @@ ***/ -#ifndef SAMPLEJOB_H -#define SAMPLEJOB_H +#ifndef OAK_SAMPLEJOB_H +#define OAK_SAMPLEJOB_H #include "acceleratedjob.h" @@ -35,14 +35,14 @@ public: SampleJob(const TimeRange &time, const NodeValue &value) { - samples_ = value.toSamples(); + samples_ = value.to_samples(); time_ = time; } SampleJob(const TimeRange &time, const QString &from, const NodeValueRow &row) { - samples_ = row[from].toSamples(); + samples_ = row[from].to_samples(); time_ = time; } @@ -51,7 +51,7 @@ public: return samples_; } - bool HasSamples() const + bool has_samples() const { return samples_.is_allocated(); } @@ -71,4 +71,4 @@ private: Q_DECLARE_METATYPE(olive::SampleJob) -#endif // SAMPLEJOB_H +#endif // OAK_SAMPLEJOB_H diff --git a/app/render/job/shaderjob.h b/app/render/job/shaderjob.h index d1ad16a4d..9550c42ea 100644 --- a/app/render/job/shaderjob.h +++ b/app/render/job/shaderjob.h @@ -19,8 +19,8 @@ ***/ -#ifndef SHADERJOB_H -#define SHADERJOB_H +#ifndef OAK_SHADERJOB_H +#define OAK_SHADERJOB_H #include #include @@ -42,66 +42,66 @@ public: ShaderJob(const NodeValueRow &row) : ShaderJob() { - Insert(row); + insert(row); } - const QString &GetShaderID() const + const QString &get_shader_id() const { return shader_id_; } - void SetShaderID(const QString &id) + void set_shader_id(const QString &id) { shader_id_ = id; } - void SetIterations(int iterations, const NodeInput &iterative_input) + void set_iterations(int iterations, const NodeInput &iterative_input) { - SetIterations(iterations, iterative_input.input()); + set_iterations(iterations, iterative_input.input()); } - void SetIterations(int iterations, const QString &iterative_input) + void set_iterations(int iterations, const QString &iterative_input) { iterations_ = iterations; iterative_input_ = iterative_input; } - int GetIterationCount() const + int get_iteration_count() const { return iterations_; } - const QString &GetIterativeInput() const + const QString &get_iterative_input() const { return iterative_input_; } - Texture::Interpolation GetInterpolation(const QString &id) const + Texture::Interpolation get_interpolation(const QString &id) const { - return interpolation_.value(id, Texture::kDefaultInterpolation); + return interpolation_.value(id, Texture::k_default_interpolation); } - const QHash &GetInterpolationMap() const + const QHash &get_interpolation_map() const { return interpolation_; } - void SetInterpolation(const NodeInput &input, Texture::Interpolation interp) + void set_interpolation(const NodeInput &input, Texture::Interpolation interp) { interpolation_.insert(input.input(), interp); } - void SetInterpolation(const QString &id, Texture::Interpolation interp) + void set_interpolation(const QString &id, Texture::Interpolation interp) { interpolation_.insert(id, interp); } - void SetVertexCoordinates(const QVector &vertex_coords) + void set_vertex_coordinates(const QVector &vertex_coords) { vertex_overrides_ = vertex_coords; } - const QVector &GetVertexCoordinates() + const QVector &get_vertex_coordinates() { return vertex_overrides_; } @@ -120,4 +120,4 @@ private: } -#endif // SHADERJOB_H +#endif // OAK_SHADERJOB_H diff --git a/app/render/loopmode.h b/app/render/loopmode.h index a33c89257..8006280df 100644 --- a/app/render/loopmode.h +++ b/app/render/loopmode.h @@ -16,14 +16,14 @@ * along with this program. If not, see . */ -#ifndef LOOPMODE_H -#define LOOPMODE_H +#ifndef OAK_LOOPMODE_H +#define OAK_LOOPMODE_H namespace olive { -enum class LoopMode { kLoopModeOff, kLoopModeLoop, kLoopModeClamp }; +enum class LoopMode { k_loop_mode_off, k_loop_mode_loop, k_loop_mode_clamp }; } -#endif // LOOPMODE_H +#endif // OAK_LOOPMODE_H diff --git a/app/render/lutlibrary.cpp b/app/render/lutlibrary.cpp index c9d4be2e8..54e96b1da 100644 --- a/app/render/lutlibrary.cpp +++ b/app/render/lutlibrary.cpp @@ -29,7 +29,7 @@ namespace olive { -bool LUTLibrary::IsSupportedExtension(const QString &suffix) +bool LUTLibrary::is_supported_extension(const QString &suffix) { QString s = suffix; if (s.startsWith(QLatin1Char('.'))) { @@ -40,9 +40,9 @@ bool LUTLibrary::IsSupportedExtension(const QString &suffix) return lower == QStringLiteral("cube") || lower == QStringLiteral("3dl"); } -QStringList LUTLibrary::GetDirectories() +QStringList LUTLibrary::get_directories() { - const QString serialized = OLIVE_CONFIG("LUTLibraryPaths").toString(); + const QString serialized = OAK_CONFIG("LUTLibraryPaths").toString(); QStringList dirs = serialized.split(QLatin1Char(';'), Qt::SkipEmptyParts); for (QString &dir : dirs) { @@ -51,7 +51,7 @@ QStringList LUTLibrary::GetDirectories() return dirs; } -void LUTLibrary::SetDirectories(const QStringList &dirs) +void LUTLibrary::set_directories(const QStringList &dirs) { QStringList cleaned; for (const QString &dir : dirs) { @@ -61,19 +61,19 @@ void LUTLibrary::SetDirectories(const QStringList &dirs) } } - Config::Current()[QStringLiteral("LUTLibraryPaths")] = + Config::current()[QStringLiteral("LUTLibraryPaths")] = cleaned.join(QLatin1Char(';')); } -QStringList LUTLibrary::GetLutFiles() +QStringList LUTLibrary::get_lut_files() { QStringList files; - static const QStringList kFilters = { QStringLiteral("*.cube"), + static const QStringList k_filters = { QStringLiteral("*.cube"), QStringLiteral("*.3dl") }; - for (const QString &dir : GetDirectories()) { - QDirIterator it(dir, kFilters, QDir::Files, + for (const QString &dir : get_directories()) { + QDirIterator it(dir, k_filters, QDir::Files, QDirIterator::Subdirectories); while (it.hasNext()) { files.append(it.next()); diff --git a/app/render/lutlibrary.h b/app/render/lutlibrary.h index 2dbb7e19c..f171b8fb4 100644 --- a/app/render/lutlibrary.h +++ b/app/render/lutlibrary.h @@ -18,8 +18,8 @@ ***/ -#ifndef LUTLIBRARY_H -#define LUTLIBRARY_H +#ifndef OAK_LUTLIBRARY_H +#define OAK_LUTLIBRARY_H #include #include @@ -41,18 +41,18 @@ public: * @brief Returns true if the given file suffix is a supported LUT * extension (.cube or .3dl, case-insensitive, leading dot tolerated) */ - static bool IsSupportedExtension(const QString &suffix); + static bool is_supported_extension(const QString &suffix); /** * @brief The directories that make up the LUT library */ - static QStringList GetDirectories(); + static QStringList get_directories(); /** * @brief Replaces the LUT library directories and saves them to the * application config */ - static void SetDirectories(const QStringList &dirs); + static void set_directories(const QStringList &dirs); /** * @brief All supported LUT files found under the library directories @@ -60,9 +60,9 @@ public: * Directories are scanned recursively. Files in earlier directories * are listed first. */ - static QStringList GetLutFiles(); + static QStringList get_lut_files(); }; } -#endif // LUTLIBRARY_H +#endif // OAK_LUTLIBRARY_H diff --git a/app/render/managedcolor.h b/app/render/managedcolor.h index 70e4e3475..2eb378f14 100644 --- a/app/render/managedcolor.h +++ b/app/render/managedcolor.h @@ -19,8 +19,8 @@ ***/ -#ifndef MANAGEDCOLOR_H -#define MANAGEDCOLOR_H +#ifndef OAK_MANAGEDCOLOR_H +#define OAK_MANAGEDCOLOR_H #include @@ -52,4 +52,4 @@ private: } -#endif // MANAGEDCOLOR_H +#endif // OAK_MANAGEDCOLOR_H diff --git a/app/render/opengl/openglbackend_c.cpp b/app/render/opengl/openglbackend_c.cpp index 754b1620b..a0899cb1b 100644 --- a/app/render/opengl/openglbackend_c.cpp +++ b/app/render/opengl/openglbackend_c.cpp @@ -16,23 +16,23 @@ namespace class BackendOpenGLRenderer : public olive::OpenGLRenderer { public: using olive::OpenGLRenderer::OpenGLRenderer; - using olive::OpenGLRenderer::Blit; - using olive::OpenGLRenderer::CreateNativeTexture; - using olive::OpenGLRenderer::DestroyInternal; - using olive::OpenGLRenderer::DestroyNativeTexture; - using olive::OpenGLRenderer::AttachTextureAsDestination; - using olive::OpenGLRenderer::DetachTextureAsDestination; + using olive::OpenGLRenderer::blit; + using olive::OpenGLRenderer::create_native_texture; + using olive::OpenGLRenderer::destroy_internal; + using olive::OpenGLRenderer::destroy_native_texture; + using olive::OpenGLRenderer::attach_texture_as_destination; + using olive::OpenGLRenderer::detach_texture_as_destination; }; // Converts the opaque C ABI handle back to the C++ renderer used internally. -BackendOpenGLRenderer *Renderer(OakRenderBackendHandle handle) +BackendOpenGLRenderer *renderer(OakRenderBackendHandle handle) { return static_cast(handle); } // Interprets ABI QVariant payloads without copying; both modules are built // against the same Qt/C++ ABI in this first-generation dynamic backend. -const QVariant &VariantRef(const void *variant) +const QVariant &variant_ref(const void *variant) { return *static_cast(variant); } @@ -50,7 +50,7 @@ oak_renderer_create(void *parent) OAK_RENDER_BACKEND_EXPORT void oak_renderer_destroy(OakRenderBackendHandle handle) { - delete Renderer(handle); + delete renderer(handle); } // Reports static OpenGL backend capabilities to the adapter. @@ -62,11 +62,11 @@ oak_renderer_get_info(OakRenderBackendHandle handle, return false; } out_info->abi_version = 1; - out_info->kind = OAK_RENDER_BACKEND_OPENGL; + out_info->kind = oak_render_backend_opengl; out_info->capabilities = - OAK_RENDER_BACKEND_CAP_TEXTURES | OAK_RENDER_BACKEND_CAP_SHADERS | - OAK_RENDER_BACKEND_CAP_BLIT | OAK_RENDER_BACKEND_CAP_READBACK | - OAK_RENDER_BACKEND_CAP_VIEWER_CONTEXT; + oak_render_backend_cap_textures | oak_render_backend_cap_shaders | + oak_render_backend_cap_blit | oak_render_backend_cap_readback | + oak_render_backend_cap_viewer_context; out_info->name = "opengl"; out_info->status = "available"; return true; @@ -83,35 +83,35 @@ oak_renderer_is_available(OakRenderBackendHandle handle) // Initializes an offscreen OpenGL context for non-viewer users. OAK_RENDER_BACKEND_EXPORT bool oak_renderer_init(OakRenderBackendHandle handle) { - return Renderer(handle)->Init(); + return renderer(handle)->init(); } // Initializes the backend against a caller-owned viewer OpenGL context. OAK_RENDER_BACKEND_EXPORT void oak_renderer_init_with_context(OakRenderBackendHandle handle, void *context) { - Renderer(handle)->Init(static_cast(context)); + renderer(handle)->init(static_cast(context)); } // Runs renderer post-initialization once the GL context is available. OAK_RENDER_BACKEND_EXPORT void oak_renderer_post_init(OakRenderBackendHandle handle) { - Renderer(handle)->PostInit(); + renderer(handle)->post_init(); } // Releases post-init OpenGL surface/context state. OAK_RENDER_BACKEND_EXPORT void oak_renderer_post_destroy(OakRenderBackendHandle handle) { - Renderer(handle)->PostDestroy(); + renderer(handle)->post_destroy(); } // Releases renderer-owned GL resources before object destruction. OAK_RENDER_BACKEND_EXPORT void oak_renderer_destroy_internal(OakRenderBackendHandle handle) { - Renderer(handle)->DestroyInternal(); + renderer(handle)->destroy_internal(); } // Clears either the widget framebuffer or a texture destination. @@ -119,7 +119,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_clear_destination(OakRenderBackendHandle handle, void *texture, double r, double g, double b, double a) { - Renderer(handle)->ClearDestination(static_cast(texture), + renderer(handle)->clear_destination(static_cast(texture), r, g, b, a); } @@ -129,7 +129,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_create_native_texture( int channel_count, const void *data, int linesize, void *out_variant) { *static_cast(out_variant) = - Renderer(handle)->CreateNativeTexture( + renderer(handle)->create_native_texture( width, height, depth, static_cast(format), channel_count, data, linesize); @@ -140,7 +140,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_destroy_native_texture(OakRenderBackendHandle handle, const void *variant) { - Renderer(handle)->DestroyNativeTexture(VariantRef(variant)); + renderer(handle)->destroy_native_texture(variant_ref(variant)); } // Compiles an OpenGL shader program and returns its QVariant handle. @@ -149,7 +149,7 @@ oak_renderer_create_native_shader(OakRenderBackendHandle handle, const void *shader_code, void *out_variant) { *static_cast(out_variant) = - Renderer(handle)->CreateNativeShader( + renderer(handle)->create_native_shader( *static_cast(shader_code)); } @@ -158,7 +158,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_destroy_native_shader(OakRenderBackendHandle handle, const void *variant) { - Renderer(handle)->DestroyNativeShader(VariantRef(variant)); + renderer(handle)->destroy_native_shader(variant_ref(variant)); } // Uploads CPU pixel data into an OpenGL texture. @@ -167,8 +167,8 @@ oak_renderer_upload_to_texture(OakRenderBackendHandle handle, const void *variant, const void *video_params, const void *data, int linesize) { - Renderer(handle)->UploadToTexture( - VariantRef(variant), + renderer(handle)->upload_to_texture( + variant_ref(variant), *static_cast(video_params), data, linesize); } @@ -177,15 +177,15 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_download_from_texture( OakRenderBackendHandle handle, const void *variant, const void *video_params, void *data, int linesize) { - Renderer(handle)->DownloadFromTexture( - VariantRef(variant), + renderer(handle)->download_from_texture( + variant_ref(variant), *static_cast(video_params), data, linesize); } // Flushes/waits for pending OpenGL work as required by the renderer. OAK_RENDER_BACKEND_EXPORT void oak_renderer_flush(OakRenderBackendHandle handle) { - Renderer(handle)->Flush(); + renderer(handle)->flush(); } // Reads one pixel from an OpenGL texture. @@ -195,7 +195,7 @@ oak_renderer_get_pixel_from_texture(OakRenderBackendHandle handle, void *out_color) { *static_cast(out_color) = - Renderer(handle)->GetPixelFromTexture( + renderer(handle)->get_pixel_from_texture( static_cast(texture), *static_cast(point)); } @@ -207,8 +207,8 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_blit(OakRenderBackendHandle handle, const void *destination_params, bool clear_destination) { - Renderer(handle)->Blit( - VariantRef(shader), *static_cast(job), + renderer(handle)->blit( + variant_ref(shader), *static_cast(job), static_cast(destination), *static_cast(destination_params), clear_destination); @@ -218,7 +218,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_blit(OakRenderBackendHandle handle, OAK_RENDER_BACKEND_EXPORT void * oak_renderer_opengl_context(OakRenderBackendHandle handle) { - return Renderer(handle)->context(); + return renderer(handle)->context(); } // Binds an output texture for OFX OpenGL rendering. @@ -226,12 +226,12 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_attach_output_texture(OakRenderBackendHandle handle, const void *texture_id) { - Renderer(handle)->AttachTextureAsDestination(VariantRef(texture_id)); + renderer(handle)->attach_texture_as_destination(variant_ref(texture_id)); } // Detaches any OFX OpenGL output texture binding. OAK_RENDER_BACKEND_EXPORT void oak_renderer_detach_output_texture(OakRenderBackendHandle handle) { - Renderer(handle)->DetachTextureAsDestination(); + renderer(handle)->detach_texture_as_destination(); } diff --git a/app/render/opengl/openglcontextprovider.h b/app/render/opengl/openglcontextprovider.h index 9b0a97f20..4bdc94b60 100644 --- a/app/render/opengl/openglcontextprovider.h +++ b/app/render/opengl/openglcontextprovider.h @@ -1,5 +1,5 @@ -#ifndef OPENGLCONTEXTPROVIDER_H -#define OPENGLCONTEXTPROVIDER_H +#ifndef OAK_OPENGLCONTEXTPROVIDER_H +#define OAK_OPENGLCONTEXTPROVIDER_H class QOpenGLContext; @@ -9,9 +9,9 @@ namespace olive class OpenGLContextProvider { public: virtual ~OpenGLContextProvider() = default; - virtual QOpenGLContext *OpenGLContext() const = 0; + virtual QOpenGLContext *open_gl_context() const = 0; }; } -#endif // OPENGLCONTEXTPROVIDER_H +#endif // OAK_OPENGLCONTEXTPROVIDER_H diff --git a/app/render/opengl/openglrenderer.cpp b/app/render/opengl/openglrenderer.cpp index fa9acedf7..106f22d27 100644 --- a/app/render/opengl/openglrenderer.cpp +++ b/app/render/opengl/openglrenderer.cpp @@ -36,7 +36,7 @@ namespace olive { -const int OpenGLRenderer::kTextureCacheMaxSize = 5000; +const int OpenGLRenderer::k_texture_cache_max_size = 5000; const QVector blit_vertices = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, @@ -73,9 +73,9 @@ private: QOpenGLFunctions *functions_; }; -#define PRINT_GL_ERRORS ErrorPrinter __e(__FUNCTION__, functions_) +#define OAK_PRINT_GL_ERRORS ErrorPrinter __e(__FUNCTION__, functions_) -#define GL_PREAMBLE //QMutexLocker __l(&global_opengl_mutex); +#define OAK_GL_PREAMBLE //QMutexLocker __l(&global_opengl_mutex); //QMutex global_opengl_mutex; @@ -90,11 +90,11 @@ OpenGLRenderer::OpenGLRenderer(QObject *parent) OpenGLRenderer::~OpenGLRenderer() { - Destroy(); - PostDestroy(); + destroy(); + post_destroy(); } -void OpenGLRenderer::Init(QOpenGLContext *existing_ctx) +void OpenGLRenderer::init(QOpenGLContext *existing_ctx) { if (context_) { qCritical() << "Can't initialize already initialized OpenGLRenderer"; @@ -104,9 +104,9 @@ void OpenGLRenderer::Init(QOpenGLContext *existing_ctx) context_ = existing_ctx; } -bool OpenGLRenderer::Init() +bool OpenGLRenderer::init() { - GL_PREAMBLE; + OAK_GL_PREAMBLE; if (context_) { qCritical() << "Can't initialize already initialized OpenGLRenderer"; @@ -125,7 +125,7 @@ bool OpenGLRenderer::Init() return true; } -void OpenGLRenderer::PostDestroy() +void OpenGLRenderer::post_destroy() { // Destroy surface if we created it if (surface_.isValid()) { @@ -133,9 +133,9 @@ void OpenGLRenderer::PostDestroy() } } -void OpenGLRenderer::PostInit() +void OpenGLRenderer::post_init() { - GL_PREAMBLE; + OAK_GL_PREAMBLE; if (!context_) { qWarning() << __FUNCTION__ << "called without an OpenGL context"; @@ -162,12 +162,12 @@ void OpenGLRenderer::PostInit() } } -void OpenGLRenderer::DestroyInternal() +void OpenGLRenderer::destroy_internal() { // context_ is guarded: if a caller-owned context was already destroyed, // this is null and there is nothing GL-side left to release. if (context_) { - GL_PREAMBLE; + OAK_GL_PREAMBLE; if (functions_ && framebuffer_) { functions_->glDeleteFramebuffers(1, &framebuffer_); @@ -186,33 +186,33 @@ void OpenGLRenderer::DestroyInternal() functions_ = nullptr; } -void OpenGLRenderer::ClearDestination(Texture *texture, double r, double g, +void OpenGLRenderer::clear_destination(Texture *texture, double r, double g, double b, double a) { - GL_PREAMBLE; + OAK_GL_PREAMBLE; - if (!EnsureContextCurrent(__FUNCTION__)) { + if (!ensure_context_current(__FUNCTION__)) { return; } if (texture) { - AttachTextureAsDestination(texture->id()); + attach_texture_as_destination(texture->id()); } - ClearDestinationInternal(r, g, b, a); + clear_destination_internal(r, g, b, a); if (texture) { - DetachTextureAsDestination(); + detach_texture_as_destination(); } } -QVariant OpenGLRenderer::CreateNativeTexture(int width, int height, int depth, +QVariant OpenGLRenderer::create_native_texture(int width, int height, int depth, PixelFormat format, int channel_count, const void *data, int linesize) { - GL_PREAMBLE; - if (!EnsureContextCurrent(__FUNCTION__)) { + OAK_GL_PREAMBLE; + if (!ensure_context_current(__FUNCTION__)) { return QVariant(); } @@ -237,13 +237,13 @@ QVariant OpenGLRenderer::CreateNativeTexture(int width, int height, int depth, if (is_3d) { context_->extraFunctions()->glTexImage3D( - target, 0, GetInternalFormat(format, channel_count), width, height, - depth, 0, GetPixelFormat(channel_count), GetPixelType(format), + target, 0, get_internal_format(format, channel_count), width, height, + depth, 0, get_pixel_format(channel_count), get_pixel_type(format), data); } else { functions_->glTexImage2D( - target, 0, GetInternalFormat(format, channel_count), width, height, - 0, GetPixelFormat(channel_count), GetPixelType(format), data); + target, 0, get_internal_format(format, channel_count), width, height, + 0, get_pixel_format(channel_count), get_pixel_type(format), data); } functions_->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); @@ -253,9 +253,9 @@ QVariant OpenGLRenderer::CreateNativeTexture(int width, int height, int depth, return texture; } -void OpenGLRenderer::AttachTextureAsDestination(const QVariant &texture) +void OpenGLRenderer::attach_texture_as_destination(const QVariant &texture) { - PRINT_GL_ERRORS; + OAK_PRINT_GL_ERRORS; if (!framebuffer_) { functions_->glGenFramebuffers(1, &framebuffer_); @@ -267,7 +267,7 @@ void OpenGLRenderer::AttachTextureAsDestination(const QVariant &texture) 0); } -void OpenGLRenderer::DetachTextureAsDestination() +void OpenGLRenderer::detach_texture_as_destination() { // QOpenGLWidget renders to a non-zero default FBO. const GLuint default_fbo = context_ ? context_->defaultFramebufferObject() : @@ -275,9 +275,9 @@ void OpenGLRenderer::DetachTextureAsDestination() functions_->glBindFramebuffer(GL_FRAMEBUFFER, default_fbo); } -void OpenGLRenderer::DestroyNativeTexture(QVariant texture) +void OpenGLRenderer::destroy_native_texture(QVariant texture) { - if (!EnsureContextCurrent(__FUNCTION__)) { + if (!ensure_context_current(__FUNCTION__)) { return; } @@ -288,18 +288,18 @@ void OpenGLRenderer::DestroyNativeTexture(QVariant texture) } } -QVariant OpenGLRenderer::CreateNativeShader(ShaderCode code) +QVariant OpenGLRenderer::create_native_shader(ShaderCode code) { - GL_PREAMBLE; + OAK_GL_PREAMBLE; - if (!EnsureContextCurrent(__FUNCTION__)) { + if (!ensure_context_current(__FUNCTION__)) { return QVariant(); } - PRINT_GL_ERRORS; + OAK_PRINT_GL_ERRORS; - GLuint vert = CompileShader(GL_VERTEX_SHADER, code.vert_code()); - GLuint frag = CompileShader(GL_FRAGMENT_SHADER, code.frag_code()); + GLuint vert = compile_shader(GL_VERTEX_SHADER, code.vert_code()); + GLuint frag = compile_shader(GL_FRAGMENT_SHADER, code.frag_code()); GLuint program = 0; @@ -324,11 +324,11 @@ QVariant OpenGLRenderer::CreateNativeShader(ShaderCode code) return program; } -void OpenGLRenderer::DestroyNativeShader(QVariant shader) +void OpenGLRenderer::destroy_native_shader(QVariant shader) { - GL_PREAMBLE; + OAK_GL_PREAMBLE; - if (!EnsureContextCurrent(__FUNCTION__)) { + if (!ensure_context_current(__FUNCTION__)) { return; } @@ -336,11 +336,11 @@ void OpenGLRenderer::DestroyNativeShader(QVariant shader) functions_->glDeleteProgram(program); } -void OpenGLRenderer::UploadToTexture(const QVariant &handle, +void OpenGLRenderer::upload_to_texture(const QVariant &handle, const VideoParams &p, const void *data, int linesize) { - GL_PREAMBLE; + OAK_GL_PREAMBLE; GLuint t = handle.value(); @@ -358,18 +358,18 @@ void OpenGLRenderer::UploadToTexture(const QVariant &handle, functions_->glPixelStorei(GL_UNPACK_ROW_LENGTH, linesize); { - PRINT_GL_ERRORS; + OAK_PRINT_GL_ERRORS; if (!is_3d) { functions_->glTexSubImage2D(tex_type, 0, 0, 0, p.effective_width(), p.effective_height(), - GetPixelFormat(p.channel_count()), - GetPixelType(p.format()), data); + get_pixel_format(p.channel_count()), + get_pixel_type(p.format()), data); } else { context_->extraFunctions()->glTexSubImage3D( tex_type, 0, 0, 0, 0, p.effective_width(), p.effective_height(), - p.effective_depth(), GetPixelFormat(p.channel_count()), - GetPixelType(p.format()), data); + p.effective_depth(), get_pixel_format(p.channel_count()), + get_pixel_type(p.format()), data); } } @@ -378,13 +378,13 @@ void OpenGLRenderer::UploadToTexture(const QVariant &handle, functions_->glBindTexture(tex_type, current_tex); } -void OpenGLRenderer::DownloadFromTexture(const QVariant &id, +void OpenGLRenderer::download_from_texture(const QVariant &id, const VideoParams &p, void *data, int linesize) { - GL_PREAMBLE; + OAK_GL_PREAMBLE; - if (!EnsureContextCurrent(__FUNCTION__)) { + if (!ensure_context_current(__FUNCTION__)) { return; } @@ -397,12 +397,12 @@ void OpenGLRenderer::DownloadFromTexture(const QVariant &id, GLint current_tex; functions_->glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_tex); - AttachTextureAsDestination(id); + attach_texture_as_destination(id); GLenum status = functions_->glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { qWarning() << "DownloadFromTexture framebuffer incomplete" << status; - DetachTextureAsDestination(); + detach_texture_as_destination(); return; } @@ -412,30 +412,30 @@ void OpenGLRenderer::DownloadFromTexture(const QVariant &id, functions_->glFinish(); { - PRINT_GL_ERRORS; + OAK_PRINT_GL_ERRORS; functions_->glReadPixels(0, 0, p.effective_width(), p.effective_height(), - GetPixelFormat(p.channel_count()), - GetPixelType(p.format()), data); + get_pixel_format(p.channel_count()), + get_pixel_type(p.format()), data); } functions_->glPixelStorei(GL_PACK_ROW_LENGTH, 0); - DetachTextureAsDestination(); + detach_texture_as_destination(); functions_->glBindTexture(GL_TEXTURE_2D, current_tex); } -void OpenGLRenderer::Flush() +void OpenGLRenderer::flush() { - GL_PREAMBLE; + OAK_GL_PREAMBLE; - if (!EnsureContextCurrent(__FUNCTION__)) { + if (!ensure_context_current(__FUNCTION__)) { return; } #if !defined(OAK_RENDER_BACKEND_PLUGIN) - if (OLIVE_CONFIG("UseGLFinish").toBool()) { + if (OAK_CONFIG("UseGLFinish").toBool()) { functions_->glFinish(); return; } @@ -454,52 +454,52 @@ void OpenGLRenderer::Flush() // Adapts the generic Renderer output attachment hook to OpenGL's framebuffer // attachment path used by OFX OpenGL rendering. -void OpenGLRenderer::AttachOutputTexture(olive::Texture *texture) +void OpenGLRenderer::attach_output_texture(olive::Texture *texture) { - if (!EnsureContextCurrent(__FUNCTION__)) { + if (!ensure_context_current(__FUNCTION__)) { return; } if (texture) { - AttachTextureAsDestination(texture->id()); + attach_texture_as_destination(texture->id()); } } // Clears the framebuffer attachment installed by AttachOutputTexture(). -void OpenGLRenderer::DetachOutputTexture() +void OpenGLRenderer::detach_output_texture() { - if (!EnsureContextCurrent(__FUNCTION__)) { + if (!ensure_context_current(__FUNCTION__)) { return; } - DetachTextureAsDestination(); + detach_texture_as_destination(); } -Color OpenGLRenderer::GetPixelFromTexture(Texture *texture, const QPointF &pt) +Color OpenGLRenderer::get_pixel_from_texture(Texture *texture, const QPointF &pt) { - if (!texture || !EnsureContextCurrent(__FUNCTION__)) { + if (!texture || !ensure_context_current(__FUNCTION__)) { return Color(); } - AttachTextureAsDestination(texture->id()); + attach_texture_as_destination(texture->id()); - QByteArray data(VideoParams::GetBytesPerPixel(texture->format(), + QByteArray data(VideoParams::get_bytes_per_pixel(texture->format(), texture->channel_count()), Qt::Uninitialized); functions_->glReadPixels(pt.x(), pt.y(), 1, 1, - GetPixelFormat(texture->channel_count()), - GetPixelType(texture->format()), data.data()); + get_pixel_format(texture->channel_count()), + get_pixel_type(texture->format()), data.data()); - Color c = Color::fromData(data.data(), texture->format(), + Color c = Color::from_data(data.data(), texture->format(), texture->channel_count()); - if (texture->channel_count() == VideoParams::kRGBChannelCount) { + if (texture->channel_count() == VideoParams::k_rgb_channel_count) { // No alpha channel, set to 1.0 c.set_alpha(1.0); } - DetachTextureAsDestination(); + detach_texture_as_destination(); return c; } @@ -509,12 +509,12 @@ struct TextureToBind { Texture::Interpolation interpolation; }; -void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, +void OpenGLRenderer::blit(QVariant s, AcceleratedJob &a_job, Texture *destination, VideoParams destination_params, bool clear_destination) { - GL_PREAMBLE; - if (!EnsureContextCurrent(__FUNCTION__)) { + OAK_GL_PREAMBLE; + if (!ensure_context_current(__FUNCTION__)) { return; } try { @@ -534,8 +534,8 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, functions_->glUseProgram(shader); - for (auto it = job.GetValues().constBegin(); - it != job.GetValues().constEnd(); it++) { + for (auto it = job.get_values().constBegin(); + it != job.get_values().constEnd(); it++) { // See if the shader has takes this parameter as an input GLint variable_location = functions_->glGetUniformLocation( shader, it.key().toUtf8().constData()); @@ -553,52 +553,52 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, } switch (value.type()) { - case NodeValue::kInt: + case NodeValue::k_int: // kInt technically specifies a LongLong, but OpenGL doesn't support those. This may lead to // over/underflows if the number is large enough, but the likelihood of that is quite low. - functions_->glUniform1i(variable_location, value.toInt()); + functions_->glUniform1i(variable_location, value.to_int()); break; - case NodeValue::kFloat: + case NodeValue::k_float: // kFloat technically specifies a double but as above, OpenGL doesn't support those. - functions_->glUniform1f(variable_location, value.toDouble()); + functions_->glUniform1f(variable_location, value.to_double()); break; - case NodeValue::kVec2: { - QVector2D v = value.toVec2(); + case NodeValue::k_vec2: { + QVector2D v = value.to_vec2(); functions_->glUniform2fv(variable_location, 1, reinterpret_cast(&v)); break; } - case NodeValue::kVec3: { - QVector3D v = value.toVec3(); + case NodeValue::k_vec3: { + QVector3D v = value.to_vec3(); functions_->glUniform3fv(variable_location, 1, reinterpret_cast(&v)); break; } - case NodeValue::kVec4: { - QVector4D v = value.toVec4(); + case NodeValue::k_vec4: { + QVector4D v = value.to_vec4(); functions_->glUniform4fv(variable_location, 1, reinterpret_cast(&v)); break; } - case NodeValue::kMatrix: + case NodeValue::k_matrix: functions_->glUniformMatrix4fv(variable_location, 1, false, - value.toMatrix().constData()); + value.to_matrix().constData()); break; - case NodeValue::kCombo: - functions_->glUniform1i(variable_location, value.toInt()); + case NodeValue::k_combo: + functions_->glUniform1i(variable_location, value.to_int()); break; - case NodeValue::kColor: { - Color color = value.toColor(); + case NodeValue::k_color: { + Color color = value.to_color(); functions_->glUniform4f(variable_location, color.red(), color.green(), color.blue(), color.alpha()); break; } - case NodeValue::kBoolean: - functions_->glUniform1i(variable_location, value.toBool()); + case NodeValue::k_boolean: + functions_->glUniform1i(variable_location, value.to_bool()); break; - case NodeValue::kTexture: { - TexturePtr texture = value.toTexture(); + case NodeValue::k_texture: { + TexturePtr texture = value.to_texture(); // Set value to bound texture functions_->glUniform1i(variable_location, @@ -607,7 +607,7 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, texture_index_map.insert(it.key(), textures_to_bind.size()); textures_to_bind.append( - { texture, job.GetInterpolation(it.key()) }); + { texture, job.get_interpolation(it.key()) }); // Set enable flag if shader wants it GLuint tex_id = texture ? texture->id().value() : 0; @@ -621,18 +621,18 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, } break; } - case NodeValue::kSamples: - case NodeValue::kText: - case NodeValue::kRational: - case NodeValue::kFont: - case NodeValue::kFile: - case NodeValue::kVideoParams: - case NodeValue::kAudioParams: - case NodeValue::kSubtitleParams: - case NodeValue::kBezier: - case NodeValue::kBinary: - case NodeValue::kNone: - case NodeValue::kDataTypeCount: + case NodeValue::k_samples: + case NodeValue::k_text: + case NodeValue::k_rational: + case NodeValue::k_font: + case NodeValue::k_file: + case NodeValue::k_video_params: + case NodeValue::k_audio_params: + case NodeValue::k_subtitle_params: + case NodeValue::k_bezier: + case NodeValue::k_binary: + case NodeValue::k_none: + case NodeValue::k_data_type_count: break; } } @@ -652,7 +652,7 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, functions_->glBindTexture(target, tex_id); if (tex_id) { - PrepareInputTexture(target, t.interpolation); + prepare_input_texture(target, t.interpolation); if (texture->channel_count() == 1 && destination_params.channel_count() != 1) { @@ -673,7 +673,7 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, if (mvpmat_location > -1) { functions_->glUniformMatrix4fv( mvpmat_location, 1, false, - job.Get(QStringLiteral("ove_mvpmat")).toMatrix().constData()); + job.get(QStringLiteral("ove_mvpmat")).to_matrix().constData()); } // Set the viewport to the "physical" resolution of the destination @@ -681,51 +681,51 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, destination_params.effective_height()); // Bind vertex array object - QOpenGLVertexArrayObject vao_; - vao_.create(); - vao_.bind(); + QOpenGLVertexArrayObject vao; + vao.create(); + vao.bind(); // Set buffers - QOpenGLBuffer vert_vbo_; - vert_vbo_.create(); - vert_vbo_.bind(); + QOpenGLBuffer vert_vbo; + vert_vbo.create(); + vert_vbo.bind(); // If the job has vertex coordinate overrides use them instead of the defaults. - if (!job.GetVertexCoordinates().isEmpty()) { - Q_ASSERT(job.GetVertexCoordinates().size() == 18); - vert_vbo_.allocate(job.GetVertexCoordinates().constData(), - job.GetVertexCoordinates().size() * + if (!job.get_vertex_coordinates().isEmpty()) { + Q_ASSERT(job.get_vertex_coordinates().size() == 18); + vert_vbo.allocate(job.get_vertex_coordinates().constData(), + job.get_vertex_coordinates().size() * sizeof(float)); } else { - vert_vbo_.allocate(blit_vertices.constData(), + vert_vbo.allocate(blit_vertices.constData(), blit_vertices.size() * sizeof(GLfloat)); } - vert_vbo_.release(); + vert_vbo.release(); - QOpenGLBuffer frag_vbo_; - frag_vbo_.create(); - frag_vbo_.bind(); - frag_vbo_.allocate(blit_texcoords.constData(), + QOpenGLBuffer frag_vbo; + frag_vbo.create(); + frag_vbo.bind(); + frag_vbo.allocate(blit_texcoords.constData(), blit_texcoords.size() * sizeof(GLfloat)); - frag_vbo_.release(); + frag_vbo.release(); GLint vertex_location = functions_->glGetAttribLocation(shader, "a_position"); if (vertex_location != -1) { - vert_vbo_.bind(); + vert_vbo.bind(); functions_->glEnableVertexAttribArray(vertex_location); functions_->glVertexAttribPointer(vertex_location, 3, GL_FLOAT, GL_FALSE, 0, nullptr); - vert_vbo_.release(); + vert_vbo.release(); } GLint tex_location = functions_->glGetAttribLocation(shader, "a_texcoord"); if (tex_location != -1) { - frag_vbo_.bind(); + frag_vbo.bind(); functions_->glEnableVertexAttribArray(tex_location); functions_->glVertexAttribPointer(tex_location, 2, GL_FLOAT, GL_FALSE, 0, nullptr); - frag_vbo_.release(); + frag_vbo.release(); } // Some shaders optimize through multiple iterations which requires ping-ponging textures @@ -735,8 +735,8 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, // textures. We can still use the destination as the last iteration, but we'll need textures // for the iterative process. int real_iteration_count; - if (job.GetIterationCount() > 1 && !job.GetIterativeInput().isEmpty()) { - real_iteration_count = job.GetIterationCount(); + if (job.get_iteration_count() > 1 && !job.get_iterative_input().isEmpty()) { + real_iteration_count = job.get_iteration_count(); } else { real_iteration_count = 1; } @@ -744,11 +744,11 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, TexturePtr output_tex, input_tex; if (real_iteration_count > 1) { // Create one texture to bounce off - output_tex = CreateTexture(destination_params); + output_tex = create_texture(destination_params); if (real_iteration_count > 2) { // Create a second texture bounce off - input_tex = CreateTexture(destination_params); + input_tex = create_texture(destination_params); } } @@ -765,33 +765,33 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, // This is the last iteration, draw to the destination if (destination) { // If we have a destination texture, draw to it - AttachTextureAsDestination(destination->id()); + attach_texture_as_destination(destination->id()); } else if (iteration > 0) { // Otherwise, if we were iterating before, detach texture now - DetachTextureAsDestination(); + detach_texture_as_destination(); } // Clear the destination if the caller requested it if (clear_destination) { - ClearDestinationInternal(); + clear_destination_internal(); } } else { // Always draw to output_tex, which gets swapped with input_tex every iteration - AttachTextureAsDestination(output_tex->id()); + attach_texture_as_destination(output_tex->id()); } if (iteration > 0) { // If this is not the first iteration, replace the iterative texture with the one we // last drew - const QString &iterative_input = job.GetIterativeInput(); + const QString &iterative_input = job.get_iterative_input(); functions_->glActiveTexture( GL_TEXTURE0 + texture_index_map.value(iterative_input)); functions_->glBindTexture(GL_TEXTURE_2D, input_tex->id().value()); // At this time, we only support iterating 2D textures - PrepareInputTexture(GL_TEXTURE_2D, - job.GetInterpolation(iterative_input)); + prepare_input_texture(GL_TEXTURE_2D, + job.get_interpolation(iterative_input)); } // Swap so that the next iteration, the texture we draw now will be the input texture next @@ -799,7 +799,7 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, // Blit this texture through this shader { - PRINT_GL_ERRORS; + OAK_PRINT_GL_ERRORS; functions_->glDrawArrays(GL_TRIANGLES, 0, blit_vertices.size() / 3); } @@ -807,7 +807,7 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, if (destination) { // Reset framebuffer to default if we were drawing to a texture - DetachTextureAsDestination(); + detach_texture_as_destination(); } // Release any textures we bound before @@ -824,18 +824,18 @@ void OpenGLRenderer::Blit(QVariant s, AcceleratedJob &a_job, functions_->glUseProgram(0); // Release vertex array object - frag_vbo_.destroy(); - vert_vbo_.destroy(); - vao_.release(); - vao_.destroy(); + frag_vbo.destroy(); + vert_vbo.destroy(); + vao.release(); + vao.destroy(); } catch (std::bad_cast e) { } } -GLint OpenGLRenderer::GetInternalFormat(PixelFormat format, int channel_layout) +GLint OpenGLRenderer::get_internal_format(PixelFormat format, int channel_layout) { switch (format) { - case PixelFormat::U8: + case PixelFormat::u8: switch (channel_layout) { case 1: return GL_R8; @@ -847,12 +847,12 @@ GLint OpenGLRenderer::GetInternalFormat(PixelFormat format, int channel_layout) return GL_RGBA8; } break; - case PixelFormat::U10: + case PixelFormat::u10: if (channel_layout == 4) { return GL_RGB10_A2; } break; - case PixelFormat::U16: + case PixelFormat::u16: switch (channel_layout) { case 1: return GL_R16; @@ -864,7 +864,7 @@ GLint OpenGLRenderer::GetInternalFormat(PixelFormat format, int channel_layout) return GL_RGBA16; } break; - case PixelFormat::F16: + case PixelFormat::f16: switch (channel_layout) { case 1: return GL_R16F; @@ -876,7 +876,7 @@ GLint OpenGLRenderer::GetInternalFormat(PixelFormat format, int channel_layout) return GL_RGBA16F; } break; - case PixelFormat::F32: + case PixelFormat::f32: switch (channel_layout) { case 1: return GL_R32F; @@ -888,37 +888,37 @@ GLint OpenGLRenderer::GetInternalFormat(PixelFormat format, int channel_layout) return GL_RGBA32F; } break; - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; } return GL_INVALID_VALUE; } -GLenum OpenGLRenderer::GetPixelType(PixelFormat format) +GLenum OpenGLRenderer::get_pixel_type(PixelFormat format) { switch (format) { - case PixelFormat::U8: + case PixelFormat::u8: return GL_UNSIGNED_BYTE; - case PixelFormat::U10: + case PixelFormat::u10: return GL_UNSIGNED_INT_2_10_10_10_REV; - case PixelFormat::U16: + case PixelFormat::u16: return GL_UNSIGNED_SHORT; - case PixelFormat::F16: + case PixelFormat::f16: return GL_HALF_FLOAT; - case PixelFormat::F32: + case PixelFormat::f32: return GL_FLOAT; - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; } return GL_INVALID_VALUE; } -GLenum OpenGLRenderer::GetPixelFormat(int channel_count) +GLenum OpenGLRenderer::get_pixel_format(int channel_count) { switch (channel_count) { case 1: @@ -932,19 +932,19 @@ GLenum OpenGLRenderer::GetPixelFormat(int channel_count) } } -void OpenGLRenderer::PrepareInputTexture(GLenum target, +void OpenGLRenderer::prepare_input_texture(GLenum target, Texture::Interpolation interp) { switch (interp) { - case Texture::kNearest: + case Texture::k_nearest: functions_->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); functions_->glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); break; - case Texture::kLinear: + case Texture::k_linear: functions_->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); functions_->glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); break; - case Texture::kMipmappedLinear: + case Texture::k_mipmapped_linear: functions_->glGenerateMipmap(target); functions_->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); @@ -961,7 +961,7 @@ void OpenGLRenderer::PrepareInputTexture(GLenum target, } } -void OpenGLRenderer::ClearDestinationInternal(double r, double g, double b, +void OpenGLRenderer::clear_destination_internal(double r, double g, double b, double a) { if (!functions_) { @@ -971,7 +971,7 @@ void OpenGLRenderer::ClearDestinationInternal(double r, double g, double b, functions_->glClear(GL_COLOR_BUFFER_BIT); } -GLuint OpenGLRenderer::CompileShader(GLenum type, const QString &code) +GLuint OpenGLRenderer::compile_shader(GLenum type, const QString &code) { const bool is_gles = context_ && context_->isOpenGLES(); const int major = context_ ? context_->format().majorVersion() : 0; @@ -993,10 +993,10 @@ GLuint OpenGLRenderer::CompileShader(GLenum type, const QString &code) if (base_code.isEmpty()) { // Use default code if (type == GL_FRAGMENT_SHADER) { - base_code = FileFunctions::ReadFileAsString( + base_code = FileFunctions::read_file_as_string( QStringLiteral(":/shaders/default.frag")); } else if (type == GL_VERTEX_SHADER) { - base_code = FileFunctions::ReadFileAsString( + base_code = FileFunctions::read_file_as_string( QStringLiteral(":/shaders/default.vert")); } } @@ -1064,7 +1064,7 @@ GLuint OpenGLRenderer::CompileShader(GLenum type, const QString &code) return shader; } -bool OpenGLRenderer::EnsureContextCurrent(const char *caller) +bool OpenGLRenderer::ensure_context_current(const char *caller) { if (!context_) { qWarning() << caller << "called without an OpenGL context"; diff --git a/app/render/opengl/openglrenderer.h b/app/render/opengl/openglrenderer.h index 6f0aa6b87..ee2264c36 100644 --- a/app/render/opengl/openglrenderer.h +++ b/app/render/opengl/openglrenderer.h @@ -19,8 +19,8 @@ ***/ -#ifndef OPENGLCONTEXT_H -#define OPENGLCONTEXT_H +#ifndef OAK_OPENGLCONTEXT_H +#define OAK_OPENGLCONTEXT_H #include #include @@ -44,33 +44,33 @@ public: virtual ~OpenGLRenderer() override; - void Init(QOpenGLContext *existing_ctx); + void init(QOpenGLContext *existing_ctx); - virtual bool Init() override; + virtual bool init() override; - virtual void PostDestroy() override; + virtual void post_destroy() override; - virtual void PostInit() override; + virtual void post_init() override; - virtual void ClearDestination(olive::Texture *texture = nullptr, + virtual void clear_destination(olive::Texture *texture = nullptr, double r = 0.0, double g = 0.0, double b = 0.0, double a = 0.0) override; - virtual QVariant CreateNativeShader(olive::ShaderCode code) override; + virtual QVariant create_native_shader(olive::ShaderCode code) override; - virtual void DestroyNativeShader(QVariant shader) override; + virtual void destroy_native_shader(QVariant shader) override; - virtual void UploadToTexture(const QVariant &handle, + virtual void upload_to_texture(const QVariant &handle, const VideoParams ¶ms, const void *data, int linesize) override; - virtual void DownloadFromTexture(const QVariant &handle, + virtual void download_from_texture(const QVariant &handle, const VideoParams ¶ms, void *data, int linesize) override; - virtual void Flush() override; + virtual void flush() override; - virtual Color GetPixelFromTexture(olive::Texture *texture, + virtual Color get_pixel_from_texture(olive::Texture *texture, const QPointF &pt) override; QOpenGLContext *context() const @@ -78,54 +78,54 @@ public: return context_.data(); } - virtual QOpenGLContext *OpenGLContext() const override + virtual QOpenGLContext *open_gl_context() const override { return context(); } - virtual bool IsOpenGL() const override + virtual bool is_open_gl() const override { return true; } - virtual void AttachOutputTexture(olive::Texture *texture) override; + virtual void attach_output_texture(olive::Texture *texture) override; - virtual void DetachOutputTexture() override; + virtual void detach_output_texture() override; - bool EnsureContextCurrent(const char *caller); + bool ensure_context_current(const char *caller); protected: - virtual void Blit(QVariant shader, olive::AcceleratedJob &job, + virtual void blit(QVariant shader, olive::AcceleratedJob &job, olive::Texture *destination, olive::VideoParams destination_params, bool clear_destination) override; - virtual QVariant CreateNativeTexture(int width, int height, int depth, + virtual QVariant create_native_texture(int width, int height, int depth, PixelFormat format, int channel_count, const void *data = nullptr, int linesize = 0) override; - virtual void DestroyNativeTexture(QVariant texture) override; + virtual void destroy_native_texture(QVariant texture) override; - virtual void DestroyInternal() override; + virtual void destroy_internal() override; - void AttachTextureAsDestination(const QVariant &texture); + void attach_texture_as_destination(const QVariant &texture); - void DetachTextureAsDestination(); + void detach_texture_as_destination(); private: - static GLint GetInternalFormat(PixelFormat format, int channel_layout); + static GLint get_internal_format(PixelFormat format, int channel_layout); - static GLenum GetPixelType(PixelFormat format); + static GLenum get_pixel_type(PixelFormat format); - static GLenum GetPixelFormat(int channel_count); + static GLenum get_pixel_format(int channel_count); - void PrepareInputTexture(GLenum target, Texture::Interpolation interp); + void prepare_input_texture(GLenum target, Texture::Interpolation interp); - void ClearDestinationInternal(double r = 0.0, double g = 0.0, + void clear_destination_internal(double r = 0.0, double g = 0.0, double b = 0.0, double a = 0.0); - GLuint CompileShader(GLenum type, const QString &code); + GLuint compile_shader(GLenum type, const QString &code); // Guarded pointer: viewer contexts are owned by the widget that created // them and may be destroyed before this renderer (e.g. when a QOpenGLWidget @@ -156,9 +156,9 @@ private: QMap texture_params_; - static const int kTextureCacheMaxSize; + static const int k_texture_cache_max_size; }; } -#endif // OPENGLCONTEXT_H +#endif // OAK_OPENGLCONTEXT_H diff --git a/app/render/playbackcache.cpp b/app/render/playbackcache.cpp index 0a136984a..b31f1672f 100644 --- a/app/render/playbackcache.cpp +++ b/app/render/playbackcache.cpp @@ -29,7 +29,7 @@ namespace olive { -void PlaybackCache::Invalidate(const TimeRange &r) +void PlaybackCache::invalidate(const TimeRange &r) { if (r.in() == r.out()) { qWarning() << "Tried to invalidate zero-length range"; @@ -44,10 +44,10 @@ void PlaybackCache::Invalidate(const TimeRange &r) InvalidateEvent(r); - emit Invalidated(r); + emit invalidated(r); if (saving_enabled_) { - SaveState(); + save_state(); } } @@ -56,20 +56,20 @@ Node *PlaybackCache::parent() const return dynamic_cast(QObject::parent()); } -QDir PlaybackCache::GetThisCacheDirectory() const +QDir PlaybackCache::get_this_cache_directory() const { - return GetThisCacheDirectory(GetCacheDirectory(), GetUuid()); + return get_this_cache_directory(get_cache_directory(), get_uuid()); } -QDir PlaybackCache::GetThisCacheDirectory(const QString &cache_path, +QDir PlaybackCache::get_this_cache_directory(const QString &cache_path, const QUuid &cache_id) { return QDir(cache_path).filePath(cache_id.toString()); } -void PlaybackCache::LoadState() +void PlaybackCache::load_state() { - QDir cache_dir = GetThisCacheDirectory(); + QDir cache_dir = get_this_cache_directory(); QFile f(cache_dir.filePath(QStringLiteral("state"))); if (!f.exists()) { @@ -102,8 +102,8 @@ void PlaybackCache::LoadState() s >> out_num; s >> out_den; - validated_.insert(TimeRange(rational(in_num, in_den), - rational(out_num, out_den))); + validated_.insert(TimeRange(Rational(in_num, in_den), + Rational(out_num, out_den))); } s >> pass_count; @@ -117,8 +117,8 @@ void PlaybackCache::LoadState() s >> out_den; s >> id; - Passthrough p = TimeRange(rational(in_num, in_den), - rational(out_num, out_den)); + Passthrough p = TimeRange(Rational(in_num, in_den), + Rational(out_num, out_den)); p.cache = id; passthroughs_.push_back(p); } @@ -133,20 +133,20 @@ void PlaybackCache::LoadState() } } -void PlaybackCache::SaveState() +void PlaybackCache::save_state() { if (!DiskManager::instance()) { return; } - QDir cache_dir = GetThisCacheDirectory(); + QDir cache_dir = get_this_cache_directory(); QFile f(cache_dir.filePath(QStringLiteral("state"))); if (validated_.isEmpty() && passthroughs_.empty()) { if (f.exists()) { f.remove(); } } else { - if (FileFunctions::DirectoryIsValid(cache_dir)) { + if (FileFunctions::directory_is_valid(cache_dir)) { if (f.open(QFile::WriteOnly)) { QDataStream s(&f); @@ -186,19 +186,19 @@ void PlaybackCache::SaveState() } } -void PlaybackCache::Draw(QPainter *p, const rational &start, double scale, +void PlaybackCache::draw(QPainter *p, const Rational &start, double scale, const QRect &rect) const { p->fillRect(rect, Qt::red); - foreach (const TimeRange &range, GetValidatedRanges()) { - int range_left = rect.left() + (range.in() - start).toDouble() * scale; + foreach (const TimeRange &range, get_validated_ranges()) { + int range_left = rect.left() + (range.in() - start).to_double() * scale; if (range_left >= rect.right()) { continue; } int range_right = - rect.left() + (range.out() - start).toDouble() * scale; + rect.left() + (range.out() - start).to_double() * scale; if (range_right < rect.left()) { continue; } @@ -211,45 +211,45 @@ void PlaybackCache::Draw(QPainter *p, const rational &start, double scale, } } -void PlaybackCache::SetPassthrough(PlaybackCache *cache) +void PlaybackCache::set_passthrough(PlaybackCache *cache) { - for (const TimeRange &r : cache->GetValidatedRanges()) { + for (const TimeRange &r : cache->get_validated_ranges()) { Passthrough p = r; - p.cache = cache->GetUuid(); + p.cache = cache->get_uuid(); passthroughs_.push_back(p); } - passthroughs_.insert(passthroughs_.end(), cache->GetPassthroughs().begin(), - cache->GetPassthroughs().end()); + passthroughs_.insert(passthroughs_.end(), cache->get_passthroughs().begin(), + cache->get_passthroughs().end()); if (saving_enabled_) { - SaveState(); + save_state(); } } -void PlaybackCache::InvalidateAll() +void PlaybackCache::invalidate_all() { - Invalidate(TimeRange(0, RATIONAL_MAX)); + invalidate(TimeRange(0, RATIONAL_MAX)); } -void PlaybackCache::Request(ViewerOutput *context, const TimeRange &r) +void PlaybackCache::request(ViewerOutput *context, const TimeRange &r) { request_context_ = context; requested_.insert(r); - emit Requested(request_context_, r); + emit requested(request_context_, r); } -void PlaybackCache::Validate(const TimeRange &r, bool signal) +void PlaybackCache::validate(const TimeRange &r, bool signal) { validated_.insert(r); if (signal) { - emit Validated(r); + emit validated(r); } if (saving_enabled_) { - SaveState(); + save_state(); } } @@ -257,9 +257,9 @@ void PlaybackCache::InvalidateEvent(const TimeRange &) { } -Project *PlaybackCache::GetProject() const +Project *PlaybackCache::get_project() const { - return Project::GetProjectFromObject(this); + return Project::get_project_from_object(this); } PlaybackCache::PlaybackCache(QObject *parent) @@ -270,21 +270,21 @@ PlaybackCache::PlaybackCache(QObject *parent) uuid_ = QUuid::createUuid(); } -void PlaybackCache::SetUuid(const QUuid &u) +void PlaybackCache::set_uuid(const QUuid &u) { uuid_ = u; - LoadState(); + load_state(); } -TimeRangeList PlaybackCache::GetInvalidatedRanges(TimeRange intersecting) const +TimeRangeList PlaybackCache::get_invalidated_ranges(TimeRange intersecting) const { TimeRangeList invalidated; // Prevent TimeRange from being below 0, some other behavior in Olive relies on this behavior // and it seemed reasonable to have safety code in here - intersecting.set_out(qMax(rational(0), intersecting.out())); - intersecting.set_in(qMax(rational(0), intersecting.in())); + intersecting.set_out(qMax(Rational(0), intersecting.out())); + intersecting.set_in(qMax(Rational(0), intersecting.in())); invalidated.insert(intersecting); @@ -299,19 +299,19 @@ TimeRangeList PlaybackCache::GetInvalidatedRanges(TimeRange intersecting) const return invalidated; } -bool PlaybackCache::HasInvalidatedRanges(const TimeRange &intersecting) const +bool PlaybackCache::has_invalidated_ranges(const TimeRange &intersecting) const { return !validated_.contains(intersecting); } -QString PlaybackCache::GetCacheDirectory() const +QString PlaybackCache::get_cache_directory() const { - Project *project = GetProject(); + Project *project = get_project(); if (project) { return project->cache_path(); } else { - return DiskManager::instance()->GetDefaultCachePath(); + return DiskManager::instance()->get_default_cache_path(); } } diff --git a/app/render/playbackcache.h b/app/render/playbackcache.h index c1747b874..a6cc8db96 100644 --- a/app/render/playbackcache.h +++ b/app/render/playbackcache.h @@ -19,8 +19,8 @@ ***/ -#ifndef PLAYBACKCACHE_H -#define PLAYBACKCACHE_H +#ifndef OAK_PLAYBACKCACHE_H +#define OAK_PLAYBACKCACHE_H #include #include @@ -45,64 +45,64 @@ class PlaybackCache : public QObject { public: PlaybackCache(QObject *parent = nullptr); - const QUuid &GetUuid() const + const QUuid &get_uuid() const { return uuid_; } - void SetUuid(const QUuid &u); + void set_uuid(const QUuid &u); - TimeRangeList GetInvalidatedRanges(TimeRange intersecting) const; - TimeRangeList GetInvalidatedRanges(const rational &length) const + TimeRangeList get_invalidated_ranges(TimeRange intersecting) const; + TimeRangeList get_invalidated_ranges(const Rational &length) const { - return GetInvalidatedRanges(TimeRange(0, length)); + return get_invalidated_ranges(TimeRange(0, length)); } - bool HasInvalidatedRanges(const TimeRange &intersecting) const; - bool HasInvalidatedRanges(const rational &length) const + bool has_invalidated_ranges(const TimeRange &intersecting) const; + bool has_invalidated_ranges(const Rational &length) const { - return HasInvalidatedRanges(TimeRange(0, length)); + return has_invalidated_ranges(TimeRange(0, length)); } - QString GetCacheDirectory() const; + QString get_cache_directory() const; - void Invalidate(const TimeRange &r); + void invalidate(const TimeRange &r); - bool HasValidatedRanges() const + bool has_validated_ranges() const { return !validated_.isEmpty(); } - const TimeRangeList &GetValidatedRanges() const + const TimeRangeList &get_validated_ranges() const { return validated_; } Node *parent() const; - QDir GetThisCacheDirectory() const; - static QDir GetThisCacheDirectory(const QString &cache_path, + QDir get_this_cache_directory() const; + static QDir get_this_cache_directory(const QString &cache_path, const QUuid &cache_id); - void LoadState(); - void SaveState(); + void load_state(); + void save_state(); - void Draw(QPainter *painter, const rational &start, double scale, + void draw(QPainter *painter, const Rational &start, double scale, const QRect &rect) const; - static int GetCacheIndicatorHeight() + static int get_cache_indicator_height() { return QFontMetrics(QFont()).height() / 4; } - bool IsSavingEnabled() const + bool is_saving_enabled() const { return saving_enabled_; } - void SetSavingEnabled(bool e) + void set_saving_enabled(bool e) { saving_enabled_ = e; } - virtual void SetPassthrough(PlaybackCache *cache); + virtual void set_passthrough(PlaybackCache *cache); QMutex *mutex() { @@ -119,39 +119,39 @@ public: QUuid cache; }; - const std::vector &GetPassthroughs() const + const std::vector &get_passthroughs() const { return passthroughs_; } - void ClearRequestRange(const TimeRange &r) + void clear_request_range(const TimeRange &r) { requested_.remove(r); } - void ResignalRequests() + void resignal_requests() { for (const TimeRange &r : requested_) { - emit Requested(request_context_, r); + emit requested(request_context_, r); } } public slots: - void InvalidateAll(); + void invalidate_all(); - void Request(ViewerOutput *context, const TimeRange &r); + void request(ViewerOutput *context, const TimeRange &r); signals: - void Invalidated(const TimeRange &r); + void invalidated(const TimeRange &r); - void Validated(const TimeRange &r); + void validated(const TimeRange &r); - void Requested(ViewerOutput *context, const TimeRange &r); + void requested(ViewerOutput *context, const TimeRange &r); - void CancelAll(); + void cancel_all(); protected: - void Validate(const TimeRange &r, bool signal = true); + void validate(const TimeRange &r, bool signal = true); virtual void InvalidateEvent(const TimeRange &range); @@ -163,7 +163,7 @@ protected: { } - Project *GetProject() const; + Project *get_project() const; private: TimeRangeList validated_; @@ -184,4 +184,4 @@ private: } -#endif // PLAYBACKCACHE_H +#endif // OAK_PLAYBACKCACHE_H diff --git a/app/render/plugin/pluginrenderer.cpp b/app/render/plugin/pluginrenderer.cpp index 66cd52bf0..f5660a63e 100644 --- a/app/render/plugin/pluginrenderer.cpp +++ b/app/render/plugin/pluginrenderer.cpp @@ -43,8 +43,8 @@ #include "pluginrenderer.h" #include "core.h" #include "undo/undostack.h" -#include "pluginSupport/OliveClip.h" -#include "pluginSupport/OlivePluginInstance.h" +#include "pluginSupport/oliveclip.h" +#include "pluginSupport/oliveplugininstance.h" #include "common/ffmpegutils.h" #include "ofxhParam.h" #include "ofxImageEffect.h" @@ -56,17 +56,17 @@ // The bridge header only defines the little-endian pixel formats. FFmpeg // numbers each big-endian variant immediately before its little-endian // counterpart (BE == LE - 1), so derive the BE constants used below. -constexpr int FB_PIX_FMT_GRAY16BE = FB_PIX_FMT_GRAY16LE - 1; -constexpr int FB_PIX_FMT_RGB48BE = FB_PIX_FMT_RGB48LE - 1; -constexpr int FB_PIX_FMT_RGBA64BE = FB_PIX_FMT_RGBA64LE - 1; -constexpr int FB_PIX_FMT_GRAYF32BE = FB_PIX_FMT_GRAYF32LE - 1; -constexpr int FB_PIX_FMT_RGBF32BE = FB_PIX_FMT_RGBF32LE - 1; -constexpr int FB_PIX_FMT_RGBAF32BE = FB_PIX_FMT_RGBAF32LE - 1; +constexpr int fb_pix_fmt_gra_y16_be = fb_pix_fmt_gra_y16_le - 1; +constexpr int fb_pix_fmt_rg_b48_be = fb_pix_fmt_rg_b48_le - 1; +constexpr int fb_pix_fmt_rgb_a64_be = fb_pix_fmt_rgb_a64_le - 1; +constexpr int fb_pix_fmt_gray_f32_be = fb_pix_fmt_gray_f32_le - 1; +constexpr int fb_pix_fmt_rgb_f32_be = fb_pix_fmt_rgb_f32_le - 1; +constexpr int fb_pix_fmt_rgba_f32_be = fb_pix_fmt_rgba_f32_le - 1; // 作用:从 OFX Image 属性推导 FFmpeg 像素格式,并返回每像素字节数。 // Purpose: Infer FFmpeg pixel format from OFX image properties and return bytes-per-pixel. static int -GetOfxAVPixelFormat(const OFX::Host::ImageEffect::Image &image, +get_ofx_av_pixel_format(const OFX::Host::ImageEffect::Image &image, int *bytes_per_pixel) { const std::string &depth = @@ -74,15 +74,15 @@ GetOfxAVPixelFormat(const OFX::Host::ImageEffect::Image &image, const std::string &components = image.getStringProperty(kOfxImageEffectPropComponents); - olive::core::PixelFormat pixel_format = olive::core::PixelFormat::INVALID; + olive::core::PixelFormat pixel_format = olive::core::PixelFormat::invalid; if (depth == kOfxBitDepthByte) { - pixel_format = olive::core::PixelFormat::U8; + pixel_format = olive::core::PixelFormat::u8; } else if (depth == kOfxBitDepthShort) { - pixel_format = olive::core::PixelFormat::U16; + pixel_format = olive::core::PixelFormat::u16; } else if (depth == kOfxBitDepthHalf) { - pixel_format = olive::core::PixelFormat::F16; + pixel_format = olive::core::PixelFormat::f16; } else if (depth == kOfxBitDepthFloat) { - pixel_format = olive::core::PixelFormat::F32; + pixel_format = olive::core::PixelFormat::f32; } int channel_count = 0; @@ -95,28 +95,28 @@ GetOfxAVPixelFormat(const OFX::Host::ImageEffect::Image &image, } int pix_fmt = - olive::FFmpegUtils::GetFFmpegPixelFormat(pixel_format, channel_count); - if (pix_fmt == FB_PIX_FMT_NONE && channel_count == 1) { - if (pixel_format == olive::core::PixelFormat::U8) { - pix_fmt = FB_PIX_FMT_GRAY8; - } else if (pixel_format == olive::core::PixelFormat::U16) { - pix_fmt = FB_PIX_FMT_GRAY16LE; - } else if (pixel_format == olive::core::PixelFormat::F16) { - pix_fmt = FB_PIX_FMT_GRAYF16LE; - } else if (pixel_format == olive::core::PixelFormat::F32) { - pix_fmt = FB_PIX_FMT_GRAYF32LE; + olive::FFmpegUtils::get_f_fmpeg_pixel_format(pixel_format, channel_count); + if (pix_fmt == fb_pix_fmt_none && channel_count == 1) { + if (pixel_format == olive::core::PixelFormat::u8) { + pix_fmt = fb_pix_fmt_gra_y8; + } else if (pixel_format == olive::core::PixelFormat::u16) { + pix_fmt = fb_pix_fmt_gra_y16_le; + } else if (pixel_format == olive::core::PixelFormat::f16) { + pix_fmt = fb_pix_fmt_gray_f16_le; + } else if (pixel_format == olive::core::PixelFormat::f32) { + pix_fmt = fb_pix_fmt_gray_f32_le; } } - if (pix_fmt == FB_PIX_FMT_NONE) { - return FB_PIX_FMT_NONE; + if (pix_fmt == fb_pix_fmt_none) { + return fb_pix_fmt_none; } // fb_pix_fmt_bits_per_pixel returns 0 for unknown formats, which also // covers the old "av_pix_fmt_desc_get returned nullptr" case. int bits_per_pixel = fb_pix_fmt_bits_per_pixel(pix_fmt); if (bits_per_pixel <= 0 || bits_per_pixel % 8 != 0) { - return FB_PIX_FMT_NONE; + return fb_pix_fmt_none; } *bytes_per_pixel = bits_per_pixel / 8; @@ -124,7 +124,7 @@ GetOfxAVPixelFormat(const OFX::Host::ImageEffect::Image &image, } // 作用:为插件实例注入当前帧的参数值,避免依赖节点实时回读。 -static void ApplyParamOverrides(OFX::Host::ImageEffect::Instance &instance, +static void apply_param_overrides(OFX::Host::ImageEffect::Instance &instance, const olive::NodeValueRow &values, OfxTime time) { const auto ¶ms = instance.getParams(); @@ -137,9 +137,9 @@ static void ApplyParamOverrides(OFX::Host::ImageEffect::Instance &instance, continue; } const olive::NodeValue &value = values.value(key); - if (value.type() == olive::NodeValue::kNone || - value.type() == olive::NodeValue::kTexture || - value.type() == olive::NodeValue::kSamples) { + if (value.type() == olive::NodeValue::k_none || + value.type() == olive::NodeValue::k_texture || + value.type() == olive::NodeValue::k_samples) { continue; } const std::string &type = entry.second->getType(); @@ -285,28 +285,28 @@ static void ApplyParamOverrides(OFX::Host::ImageEffect::Instance &instance, } static int -GetDestinationAVPixelFormat(const olive::VideoParams ¶ms); +get_destination_av_pixel_format(const olive::VideoParams ¶ms); // 作用:读取 clip 偏好(像素深度与分量)并更新 VideoParams。 // Purpose: Apply clip preferences (depth/components) into VideoParams. static bool -ApplyClipPreferencesToParams(const OFX::Host::ImageEffect::ClipInstance &clip, +apply_clip_preferences_to_params(const OFX::Host::ImageEffect::ClipInstance &clip, olive::VideoParams *params) { if (!params) { return false; } - olive::core::PixelFormat format = olive::core::PixelFormat::INVALID; + olive::core::PixelFormat format = olive::core::PixelFormat::invalid; const std::string &depth = clip.getPixelDepth(); if (depth == kOfxBitDepthByte) { - format = olive::core::PixelFormat::U8; + format = olive::core::PixelFormat::u8; } else if (depth == kOfxBitDepthShort) { - format = olive::core::PixelFormat::U16; + format = olive::core::PixelFormat::u16; } else if (depth == kOfxBitDepthHalf) { - format = olive::core::PixelFormat::F16; + format = olive::core::PixelFormat::f16; } else if (depth == kOfxBitDepthFloat) { - format = olive::core::PixelFormat::F32; + format = olive::core::PixelFormat::f32; } int channels = 0; @@ -319,7 +319,7 @@ ApplyClipPreferencesToParams(const OFX::Host::ImageEffect::ClipInstance &clip, channels = 1; } - if (format == olive::core::PixelFormat::INVALID || channels == 0) { + if (format == olive::core::PixelFormat::invalid || channels == 0) { return false; } @@ -331,38 +331,38 @@ ApplyClipPreferencesToParams(const OFX::Host::ImageEffect::ClipInstance &clip, // 作用:将 OFX bit depth 字符串映射为内部 PixelFormat。 // Purpose: Map OFX bit depth string to internal PixelFormat. static olive::core::PixelFormat -PixelFormatFromOfxDepth(const std::string &depth) +pixel_format_from_ofx_depth(const std::string &depth) { if (depth == kOfxBitDepthByte) { - return olive::core::PixelFormat::U8; + return olive::core::PixelFormat::u8; } if (depth == kOfxBitDepthShort) { - return olive::core::PixelFormat::U16; + return olive::core::PixelFormat::u16; } if (depth == kOfxBitDepthHalf) { - return olive::core::PixelFormat::F16; + return olive::core::PixelFormat::f16; } if (depth == kOfxBitDepthFloat) { - return olive::core::PixelFormat::F32; + return olive::core::PixelFormat::f32; } - return olive::core::PixelFormat::INVALID; + return olive::core::PixelFormat::invalid; } // 作用:将内部 PixelFormat 转为 OFX bit depth 字符串。 // Purpose: Map internal PixelFormat to OFX bit depth string. -static const char *OfxDepthFromPixelFormat(olive::core::PixelFormat format) +static const char *ofx_depth_from_pixel_format(olive::core::PixelFormat format) { switch (format) { - case olive::core::PixelFormat::U8: + case olive::core::PixelFormat::u8: return kOfxBitDepthByte; - case olive::core::PixelFormat::U16: + case olive::core::PixelFormat::u16: return kOfxBitDepthShort; - case olive::core::PixelFormat::F16: + case olive::core::PixelFormat::f16: return kOfxBitDepthHalf; - case olive::core::PixelFormat::F32: + case olive::core::PixelFormat::f32: return kOfxBitDepthFloat; - case olive::core::PixelFormat::INVALID: - case olive::core::PixelFormat::COUNT: + case olive::core::PixelFormat::invalid: + case olive::core::PixelFormat::count: break; } return kOfxBitDepthNone; @@ -370,7 +370,7 @@ static const char *OfxDepthFromPixelFormat(olive::core::PixelFormat format) // 作用:将 OFX components 字符串映射为通道数。 // Purpose: Map OFX components string to channel count. -static int ChannelCountFromOfxComponent(const std::string &components) +static int channel_count_from_ofx_component(const std::string &components) { if (components == kOfxImageComponentRGBA) { return 4; @@ -386,7 +386,7 @@ static int ChannelCountFromOfxComponent(const std::string &components) // 作用:将通道数映射为 OFX components 字符串。 // Purpose: Map channel count to OFX components string. -static const char *OfxComponentsFromChannels(int channel_count) +static const char *ofx_components_from_channels(int channel_count) { switch (channel_count) { case 1: @@ -404,7 +404,7 @@ static const char *OfxComponentsFromChannels(int channel_count) // 作用:判断插件是否支持指定像素深度。 // Purpose: Check whether effect supports a given pixel depth. static bool -EffectSupportsPixelDepth(const OFX::Host::ImageEffect::Instance &instance, +effect_supports_pixel_depth(const OFX::Host::ImageEffect::Instance &instance, const std::string &depth) { const auto &effect_props = instance.getDescriptor().getProps(); @@ -422,7 +422,7 @@ EffectSupportsPixelDepth(const OFX::Host::ImageEffect::Instance &instance, // 作用:判断 clip 是否支持指定组件格式。 // Purpose: Check whether clip supports a given components string. static bool -ClipSupportsComponents(const OFX::Host::ImageEffect::ClipInstance &clip, +clip_supports_components(const OFX::Host::ImageEffect::ClipInstance &clip, const std::string &components) { const auto &supported_components = clip.getSupportedComponents(); @@ -436,7 +436,7 @@ ClipSupportsComponents(const OFX::Host::ImageEffect::ClipInstance &clip, // 作用:估算从源参数到目标参数的转换代价,用于排序选择。 // Purpose: Estimate conversion cost from source to target params for ranking. -static int ConversionCost(const olive::VideoParams &src, +static int conversion_cost(const olive::VideoParams &src, const olive::VideoParams &dst) { const int src_bpp = src.channel_count() * src.format().byte_count(); @@ -453,15 +453,15 @@ static int ConversionCost(const olive::VideoParams &src, // 作用:判断目标参数能否转换为可用的 AVPixelFormat。 // Purpose: Check if params map to a valid AVPixelFormat. -static bool ParamsConvertible(const olive::VideoParams ¶ms) +static bool params_convertible(const olive::VideoParams ¶ms) { - return GetDestinationAVPixelFormat(params) != FB_PIX_FMT_NONE; + return get_destination_av_pixel_format(params) != fb_pix_fmt_none; } // 作用:在 clip 偏好无效时,选择一个插件支持的输出格式。 // Purpose: Pick a supported output format when clip preferences are invalid. static void -ChooseSupportedOutputParams(const OFX::Host::ImageEffect::Instance &instance, +choose_supported_output_params(const OFX::Host::ImageEffect::Instance &instance, const OFX::Host::ImageEffect::ClipInstance &clip, const olive::VideoParams &preferred, olive::VideoParams *out) @@ -473,37 +473,37 @@ ChooseSupportedOutputParams(const OFX::Host::ImageEffect::Instance &instance, *out = preferred; const char *preferred_components = - OfxComponentsFromChannels(preferred.channel_count()); + ofx_components_from_channels(preferred.channel_count()); if (std::strcmp(preferred_components, kOfxImageComponentNone) != 0 && - ClipSupportsComponents(clip, preferred_components)) { + clip_supports_components(clip, preferred_components)) { out->set_channel_count(preferred.channel_count()); - } else if (ClipSupportsComponents(clip, kOfxImageComponentRGBA)) { + } else if (clip_supports_components(clip, kOfxImageComponentRGBA)) { out->set_channel_count(4); - } else if (ClipSupportsComponents(clip, kOfxImageComponentRGB)) { + } else if (clip_supports_components(clip, kOfxImageComponentRGB)) { out->set_channel_count(3); - } else if (ClipSupportsComponents(clip, kOfxImageComponentAlpha)) { + } else if (clip_supports_components(clip, kOfxImageComponentAlpha)) { out->set_channel_count(1); } const olive::core::PixelFormat preferred_format = preferred.format(); const std::array candidates = { preferred_format, - olive::core::PixelFormat::F16, - olive::core::PixelFormat::F32, - olive::core::PixelFormat::U16, - olive::core::PixelFormat::U8, + olive::core::PixelFormat::f16, + olive::core::PixelFormat::f32, + olive::core::PixelFormat::u16, + olive::core::PixelFormat::u8, }; for (const auto &candidate : candidates) { - if (candidate == olive::core::PixelFormat::INVALID) { + if (candidate == olive::core::PixelFormat::invalid) { continue; } - if (!EffectSupportsPixelDepth(instance, - OfxDepthFromPixelFormat(candidate))) { + if (!effect_supports_pixel_depth(instance, + ofx_depth_from_pixel_format(candidate))) { continue; } olive::VideoParams test_params = *out; test_params.set_format(candidate); - if (!ParamsConvertible(test_params)) { + if (!params_convertible(test_params)) { continue; } out->set_format(candidate); @@ -513,17 +513,17 @@ ChooseSupportedOutputParams(const OFX::Host::ImageEffect::Instance &instance, // Forward declarations for functions defined later in this file. static olive::AVFramePtr -ConvertFrameIfNeeded(olive::AVFramePtr src, +convert_frame_if_needed(olive::AVFramePtr src, const olive::VideoParams &dst_params, olive::Renderer *renderer); static olive::TexturePtr -ConvertTextureForParams(olive::TexturePtr src, +convert_texture_for_params(olive::TexturePtr src, const olive::VideoParams &dst_params); // 作用:根据插件能力与偏好选择输入格式并执行转换。 // Purpose: Select a supported input format and convert texture for the clip. static olive::TexturePtr -ConvertTextureForClip(const OFX::Host::ImageEffect::Instance &instance, +convert_texture_for_clip(const OFX::Host::ImageEffect::Instance &instance, const OFX::Host::ImageEffect::ClipInstance &clip, olive::TexturePtr src, const olive::VideoParams &preferred_params, @@ -548,7 +548,7 @@ ConvertTextureForClip(const OFX::Host::ImageEffect::Instance &instance, std::vector channel_candidates; const auto &supported_components = clip.getSupportedComponents(); for (const auto &comp : supported_components) { - int channels = ChannelCountFromOfxComponent(comp); + int channels = channel_count_from_ofx_component(comp); if (channels > 0 && std::find(channel_candidates.begin(), channel_candidates.end(), channels) == channel_candidates.end()) { @@ -565,16 +565,16 @@ ConvertTextureForClip(const OFX::Host::ImageEffect::Instance &instance, effect_props.getDimension(kOfxImageEffectPropSupportedPixelDepths); for (int i = 0; i < depth_count; ++i) { olive::core::PixelFormat fmt = - PixelFormatFromOfxDepth(effect_props.getStringProperty( + pixel_format_from_ofx_depth(effect_props.getStringProperty( kOfxImageEffectPropSupportedPixelDepths, i)); - if (fmt != olive::core::PixelFormat::INVALID && + if (fmt != olive::core::PixelFormat::invalid && std::find(format_candidates.begin(), format_candidates.end(), fmt) == format_candidates.end()) { format_candidates.push_back(fmt); } } if (format_candidates.empty() && - preferred_params.format() != olive::core::PixelFormat::INVALID) { + preferred_params.format() != olive::core::PixelFormat::invalid) { format_candidates.push_back(preferred_params.format()); } @@ -582,28 +582,28 @@ ConvertTextureForClip(const OFX::Host::ImageEffect::Instance &instance, add_candidate(candidates, preferred_params); const bool prefer_rgba8 = - (preferred_params.format() == olive::core::PixelFormat::U8 || - preferred_params.format() == olive::core::PixelFormat::INVALID) && - ClipSupportsComponents(clip, kOfxImageComponentRGBA) && - EffectSupportsPixelDepth(instance, kOfxBitDepthByte); + (preferred_params.format() == olive::core::PixelFormat::u8 || + preferred_params.format() == olive::core::PixelFormat::invalid) && + clip_supports_components(clip, kOfxImageComponentRGBA) && + effect_supports_pixel_depth(instance, kOfxBitDepthByte); if (prefer_rgba8) { olive::VideoParams rgba_candidate = src_params; - rgba_candidate.set_format(olive::core::PixelFormat::U8); + rgba_candidate.set_format(olive::core::PixelFormat::u8); rgba_candidate.set_channel_count(4); - if (ParamsConvertible(rgba_candidate)) { + if (params_convertible(rgba_candidate)) { add_candidate(candidates, rgba_candidate); } } for (olive::core::PixelFormat fmt : format_candidates) { for (int channels : channel_candidates) { - if (fmt == olive::core::PixelFormat::INVALID || channels <= 0) { + if (fmt == olive::core::PixelFormat::invalid || channels <= 0) { continue; } olive::VideoParams candidate = src_params; candidate.set_format(fmt); candidate.set_channel_count(channels); - if (!ParamsConvertible(candidate)) { + if (!params_convertible(candidate)) { continue; } add_candidate(candidates, candidate); @@ -631,17 +631,17 @@ ConvertTextureForClip(const OFX::Host::ImageEffect::Instance &instance, } if (prefer_rgba8) { const bool a_rgba8 = a.format() == - olive::core::PixelFormat::U8 && + olive::core::PixelFormat::u8 && a.channel_count() == 4; const bool b_rgba8 = b.format() == - olive::core::PixelFormat::U8 && + olive::core::PixelFormat::u8 && b.channel_count() == 4; if (a_rgba8 != b_rgba8) { return a_rgba8; } } - const int cost_a = ConversionCost(src_params, a); - const int cost_b = ConversionCost(src_params, b); + const int cost_a = conversion_cost(src_params, a); + const int cost_b = conversion_cost(src_params, b); if (cost_a != cost_b) { return cost_a < cost_b; } @@ -658,7 +658,7 @@ ConvertTextureForClip(const OFX::Host::ImageEffect::Instance &instance, *out_params = src_params; return src; } - olive::TexturePtr converted = ConvertTextureForParams(src, candidate); + olive::TexturePtr converted = convert_texture_for_params(src, candidate); if (converted) { *out_params = candidate; return converted; @@ -691,8 +691,8 @@ create_avframe_from_ofx_image(OFX::Host::ImageEffect::Image &image) } int bytes_per_pixel = 0; - int pix_fmt = GetOfxAVPixelFormat(image, &bytes_per_pixel); - if (pix_fmt == FB_PIX_FMT_NONE || bytes_per_pixel <= 0) { + int pix_fmt = get_ofx_av_pixel_format(image, &bytes_per_pixel); + if (pix_fmt == fb_pix_fmt_none || bytes_per_pixel <= 0) { qWarning().noquote() << "OFX output image has unsupported pixel format depth=" << QString::fromStdString( @@ -711,7 +711,7 @@ create_avframe_from_ofx_image(OFX::Host::ImageEffect::Image &image) uint8_t *src = static_cast(data_ptr); src += bounds[1] * row_bytes + bounds[0] * bytes_per_pixel; - olive::AVFramePtr frame = olive::CreateAVFramePtr(); + olive::AVFramePtr frame = olive::create_av_frame_ptr(); frame->set_width(width); frame->set_height(height); frame->set_format(pix_fmt); @@ -796,33 +796,33 @@ create_avframe_from_ofx_image_with_params(OFX::Host::ImageEffect::Image &image, if (needs_conversion) { // Create source frame with actual format - int src_fmt = FB_PIX_FMT_NONE; + int src_fmt = fb_pix_fmt_none; if (src_channel_count == 4) { if (src_bytes_per_component == 1) - src_fmt = FB_PIX_FMT_RGBA; + src_fmt = fb_pix_fmt_rgba; else if (src_bytes_per_component == 2) - src_fmt = FB_PIX_FMT_RGBA64LE; + src_fmt = fb_pix_fmt_rgb_a64_le; else if (src_bytes_per_component == 4) - src_fmt = FB_PIX_FMT_RGBAF32LE; + src_fmt = fb_pix_fmt_rgba_f32_le; } else if (src_channel_count == 3) { if (src_bytes_per_component == 1) - src_fmt = FB_PIX_FMT_RGB24; + src_fmt = fb_pix_fmt_rg_b24; else if (src_bytes_per_component == 2) - src_fmt = FB_PIX_FMT_RGB48LE; + src_fmt = fb_pix_fmt_rg_b48_le; else if (src_bytes_per_component == 4) - src_fmt = FB_PIX_FMT_RGBF32LE; + src_fmt = fb_pix_fmt_rgb_f32_le; } else if (src_channel_count == 1) { if (src_bytes_per_component == 1) - src_fmt = FB_PIX_FMT_GRAY8; + src_fmt = fb_pix_fmt_gra_y8; else if (src_bytes_per_component == 2) - src_fmt = FB_PIX_FMT_GRAY16LE; + src_fmt = fb_pix_fmt_gra_y16_le; else if (src_bytes_per_component == 4) - src_fmt = FB_PIX_FMT_GRAYF32LE; + src_fmt = fb_pix_fmt_gray_f32_le; } - if (src_fmt != FB_PIX_FMT_NONE) { - olive::AVFramePtr src_frame = olive::CreateAVFramePtr(); + if (src_fmt != fb_pix_fmt_none) { + olive::AVFramePtr src_frame = olive::create_av_frame_ptr(); src_frame->set_width(width); src_frame->set_height(height); src_frame->set_format(src_fmt); @@ -839,7 +839,7 @@ create_avframe_from_ofx_image_with_params(OFX::Host::ImageEffect::Image &image, } } // Convert to destination format - return ConvertFrameIfNeeded(src_frame, params, renderer); + return convert_frame_if_needed(src_frame, params, renderer); } else { qWarning().noquote() << "[WARN] av_frame_get_buffer failed for src_fmt=" @@ -852,12 +852,12 @@ create_avframe_from_ofx_image_with_params(OFX::Host::ImageEffect::Image &image, } // Same format - direct copy - int pix_fmt = GetDestinationAVPixelFormat(params); - if (pix_fmt == FB_PIX_FMT_NONE) { + int pix_fmt = get_destination_av_pixel_format(params); + if (pix_fmt == fb_pix_fmt_none) { return nullptr; } - olive::AVFramePtr frame = olive::CreateAVFramePtr(); + olive::AVFramePtr frame = olive::create_av_frame_ptr(); frame->set_width(width); frame->set_height(height); frame->set_format(pix_fmt); @@ -879,19 +879,19 @@ create_avframe_from_ofx_image_with_params(OFX::Host::ImageEffect::Image &image, // 作用:将 VideoParams 映射为最终输出的 AVPixelFormat。 // Purpose: Map VideoParams to the final AVPixelFormat. static int -GetDestinationAVPixelFormat(const olive::VideoParams ¶ms) +get_destination_av_pixel_format(const olive::VideoParams ¶ms) { - int pix_fmt = olive::FFmpegUtils::GetFFmpegPixelFormat( + int pix_fmt = olive::FFmpegUtils::get_f_fmpeg_pixel_format( params.format(), params.channel_count()); - if (pix_fmt == FB_PIX_FMT_NONE && params.channel_count() == 1) { - if (params.format() == olive::core::PixelFormat::U8) { - pix_fmt = FB_PIX_FMT_GRAY8; - } else if (params.format() == olive::core::PixelFormat::U16) { - pix_fmt = FB_PIX_FMT_GRAY16LE; - } else if (params.format() == olive::core::PixelFormat::F16) { - pix_fmt = FB_PIX_FMT_GRAYF16LE; - } else if (params.format() == olive::core::PixelFormat::F32) { - pix_fmt = FB_PIX_FMT_GRAYF32LE; + if (pix_fmt == fb_pix_fmt_none && params.channel_count() == 1) { + if (params.format() == olive::core::PixelFormat::u8) { + pix_fmt = fb_pix_fmt_gra_y8; + } else if (params.format() == olive::core::PixelFormat::u16) { + pix_fmt = fb_pix_fmt_gra_y16_le; + } else if (params.format() == olive::core::PixelFormat::f16) { + pix_fmt = fb_pix_fmt_gray_f16_le; + } else if (params.format() == olive::core::PixelFormat::f32) { + pix_fmt = fb_pix_fmt_gray_f32_le; } } return pix_fmt; @@ -899,13 +899,13 @@ GetDestinationAVPixelFormat(const olive::VideoParams ¶ms) // 作用:根据交错设置返回 OFX render field 字符串。 // Purpose: Return OFX render field string based on interlacing. -static const char *GetRenderFieldForParams(const olive::VideoParams ¶ms) +static const char *get_render_field_for_params(const olive::VideoParams ¶ms) { switch (params.interlacing()) { - case olive::VideoParams::kInterlaceNone: + case olive::VideoParams::k_interlace_none: return kOfxImageFieldNone; - case olive::VideoParams::kInterlacedTopFirst: - case olive::VideoParams::kInterlacedBottomFirst: + case olive::VideoParams::k_interlaced_top_first: + case olive::VideoParams::k_interlaced_bottom_first: return kOfxImageFieldBoth; } return kOfxImageFieldNone; @@ -914,20 +914,20 @@ static const char *GetRenderFieldForParams(const olive::VideoParams ¶ms) // 作用:从 GPU 纹理回读到 AVFrame(必要时做格式转换)。 // Purpose: Read back GPU texture into AVFrame with format conversion if needed. static olive::AVFramePtr -ReadbackTextureToFrame(olive::TexturePtr texture, +readback_texture_to_frame(olive::TexturePtr texture, const olive::VideoParams ¶ms) { - if (!texture || texture->IsDummy()) { + if (!texture || texture->is_dummy()) { return nullptr; } - int pix_fmt = GetDestinationAVPixelFormat(params); - if (pix_fmt == FB_PIX_FMT_NONE) { + int pix_fmt = get_destination_av_pixel_format(params); + if (pix_fmt == fb_pix_fmt_none) { return nullptr; } if (!fb_pix_fmt_is_planar(pix_fmt)) { - olive::AVFramePtr frame = olive::CreateAVFramePtr(); + olive::AVFramePtr frame = olive::create_av_frame_ptr(); frame->set_format(pix_fmt); frame->set_width(params.width()); frame->set_height(params.height()); @@ -936,9 +936,9 @@ ReadbackTextureToFrame(olive::TexturePtr texture, } if (texture->renderer()) { - const int linesize_pixels = olive::plugin::detail::BytesToPixels( + const int linesize_pixels = olive::plugin::detail::bytes_to_pixels( frame->linesize(0), params); - texture->renderer()->DownloadFromTexture( + texture->renderer()->download_from_texture( texture->id(), params, frame->data(0), linesize_pixels); } return frame; @@ -946,12 +946,12 @@ ReadbackTextureToFrame(olive::TexturePtr texture, // Planar formats: read back as RGBA and convert. olive::VideoParams rgba_params(params.width(), params.height(), - olive::core::PixelFormat::U8, 4, + olive::core::PixelFormat::u8, 4, params.pixel_aspect_ratio(), params.interlacing(), params.divider()); - olive::AVFramePtr rgba_frame = olive::CreateAVFramePtr(); - rgba_frame->set_format(FB_PIX_FMT_RGBA); + olive::AVFramePtr rgba_frame = olive::create_av_frame_ptr(); + rgba_frame->set_format(fb_pix_fmt_rgba); rgba_frame->set_width(params.width()); rgba_frame->set_height(params.height()); if (rgba_frame->get_buffer(0) < 0) { @@ -959,13 +959,13 @@ ReadbackTextureToFrame(olive::TexturePtr texture, } if (texture->renderer()) { - const int linesize_pixels = olive::plugin::detail::BytesToPixels( + const int linesize_pixels = olive::plugin::detail::bytes_to_pixels( rgba_frame->linesize(0), rgba_params); - texture->renderer()->DownloadFromTexture( + texture->renderer()->download_from_texture( texture->id(), rgba_params, rgba_frame->data(0), linesize_pixels); } - olive::AVFramePtr dst = olive::CreateAVFramePtr(); + olive::AVFramePtr dst = olive::create_av_frame_ptr(); dst->set_format(pix_fmt); dst->set_width(params.width()); dst->set_height(params.height()); @@ -999,10 +999,10 @@ ReadbackTextureToFrame(olive::TexturePtr texture, // 作用:将字节行跨度转换为像素行跨度。 // Purpose: Convert byte stride to pixel stride. -int olive::plugin::detail::BytesToPixels(int byte_linesize, +int olive::plugin::detail::bytes_to_pixels(int byte_linesize, const olive::VideoParams ¶ms) { - const int bytes_per_pixel = olive::VideoParams::GetBytesPerPixel( + const int bytes_per_pixel = olive::VideoParams::get_bytes_per_pixel( params.format(), params.channel_count()); if (byte_linesize <= 0 || bytes_per_pixel <= 0) { return 0; @@ -1011,54 +1011,54 @@ int olive::plugin::detail::BytesToPixels(int byte_linesize, } // 作用:将 AVPixelFormat 映射为 Olive 的 PixelFormat 和通道数(仅常见 packed 格式)。 -static void GetOliveFormatFromAV(int fmt, +static void get_olive_format_from_av(int fmt, olive::core::PixelFormat *out_fmt, int *out_ch) { switch (fmt) { - case FB_PIX_FMT_GRAY8: - *out_fmt = olive::core::PixelFormat::U8; + case fb_pix_fmt_gra_y8: + *out_fmt = olive::core::PixelFormat::u8; *out_ch = 1; return; - case FB_PIX_FMT_RGB24: - *out_fmt = olive::core::PixelFormat::U8; + case fb_pix_fmt_rg_b24: + *out_fmt = olive::core::PixelFormat::u8; *out_ch = 3; return; - case FB_PIX_FMT_RGBA: - *out_fmt = olive::core::PixelFormat::U8; + case fb_pix_fmt_rgba: + *out_fmt = olive::core::PixelFormat::u8; *out_ch = 4; return; - case FB_PIX_FMT_GRAY16LE: - case FB_PIX_FMT_GRAY16BE: - *out_fmt = olive::core::PixelFormat::U16; + case fb_pix_fmt_gra_y16_le: + case fb_pix_fmt_gra_y16_be: + *out_fmt = olive::core::PixelFormat::u16; *out_ch = 1; return; - case FB_PIX_FMT_RGB48LE: - case FB_PIX_FMT_RGB48BE: - *out_fmt = olive::core::PixelFormat::U16; + case fb_pix_fmt_rg_b48_le: + case fb_pix_fmt_rg_b48_be: + *out_fmt = olive::core::PixelFormat::u16; *out_ch = 3; return; - case FB_PIX_FMT_RGBA64LE: - case FB_PIX_FMT_RGBA64BE: - *out_fmt = olive::core::PixelFormat::U16; + case fb_pix_fmt_rgb_a64_le: + case fb_pix_fmt_rgb_a64_be: + *out_fmt = olive::core::PixelFormat::u16; *out_ch = 4; return; - case FB_PIX_FMT_GRAYF32LE: - case FB_PIX_FMT_GRAYF32BE: - *out_fmt = olive::core::PixelFormat::F32; + case fb_pix_fmt_gray_f32_le: + case fb_pix_fmt_gray_f32_be: + *out_fmt = olive::core::PixelFormat::f32; *out_ch = 1; return; - case FB_PIX_FMT_RGBF32LE: - case FB_PIX_FMT_RGBF32BE: - *out_fmt = olive::core::PixelFormat::F32; + case fb_pix_fmt_rgb_f32_le: + case fb_pix_fmt_rgb_f32_be: + *out_fmt = olive::core::PixelFormat::f32; *out_ch = 3; return; - case FB_PIX_FMT_RGBAF32LE: - case FB_PIX_FMT_RGBAF32BE: - *out_fmt = olive::core::PixelFormat::F32; + case fb_pix_fmt_rgba_f32_le: + case fb_pix_fmt_rgba_f32_be: + *out_fmt = olive::core::PixelFormat::f32; *out_ch = 4; return; default: - *out_fmt = olive::core::PixelFormat::INVALID; + *out_fmt = olive::core::PixelFormat::invalid; *out_ch = 0; return; } @@ -1068,7 +1068,7 @@ static void GetOliveFormatFromAV(int fmt, // 优先使用 FFmpeg sws_scale;若不支持且 renderer 可用,则走 GPU 路径。 // 删除所有手写 CPU 像素循环,避免精度损失与性能瓶颈。 static olive::AVFramePtr -ConvertFrameIfNeeded(olive::AVFramePtr src, +convert_frame_if_needed(olive::AVFramePtr src, const olive::VideoParams &dst_params, olive::Renderer *renderer = nullptr) { @@ -1076,8 +1076,8 @@ ConvertFrameIfNeeded(olive::AVFramePtr src, return nullptr; } - int dst_fmt = GetDestinationAVPixelFormat(dst_params); - if (dst_fmt == FB_PIX_FMT_NONE) { + int dst_fmt = get_destination_av_pixel_format(dst_params); + if (dst_fmt == fb_pix_fmt_none) { return src; } @@ -1087,7 +1087,7 @@ ConvertFrameIfNeeded(olive::AVFramePtr src, return src; } - olive::AVFramePtr dst = olive::CreateAVFramePtr(); + olive::AVFramePtr dst = olive::create_av_frame_ptr(); dst->set_format(dst_fmt); dst->set_width(dst_params.width()); dst->set_height(dst_params.height()); @@ -1124,38 +1124,38 @@ ConvertFrameIfNeeded(olive::AVFramePtr src, if (renderer && src->data(0)) { olive::core::PixelFormat src_fmt; int src_ch; - GetOliveFormatFromAV(src->format(), &src_fmt, + get_olive_format_from_av(src->format(), &src_fmt, &src_ch); - if (src_fmt != olive::core::PixelFormat::INVALID && src_ch > 0) { + if (src_fmt != olive::core::PixelFormat::invalid && src_ch > 0) { // Ensure renderer's OpenGL context is current before GPU operations. // The context may have been switched by upstream DownloadFromTexture calls. auto *gl_renderer = dynamic_cast(renderer); if (gl_renderer) { - gl_renderer->EnsureContextCurrent(__FUNCTION__); + gl_renderer->ensure_context_current(__FUNCTION__); } olive::VideoParams src_vp(src->width(), src->height(), src_fmt, src_ch); - int src_bpp = olive::VideoParams::GetBytesPerPixel(src_fmt, src_ch); + int src_bpp = olive::VideoParams::get_bytes_per_pixel(src_fmt, src_ch); int src_linesize_pixels = (src_bpp > 0) ? src->linesize(0) / src_bpp : src->width(); - olive::TexturePtr src_tex = renderer->CreateTexture( + olive::TexturePtr src_tex = renderer->create_texture( src_vp, src->data(0), src_linesize_pixels); if (src_tex) { - olive::TexturePtr dst_tex = renderer->CreateTexture(dst_params); + olive::TexturePtr dst_tex = renderer->create_texture(dst_params); if (dst_tex) { olive::ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), - olive::NodeValue(olive::NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + olive::NodeValue(olive::NodeValue::k_texture, QVariant::fromValue(src_tex))); - renderer->BlitToTexture(renderer->GetDefaultShader(), job, + renderer->blit_to_texture(renderer->get_default_shader(), job, dst_tex.get(), false); // Download result back to AVFrame - int dst_bpp = dst_params.GetBytesPerPixel(); + int dst_bpp = dst_params.get_bytes_per_pixel(); int dst_linesize_pixels = (dst_bpp > 0) ? dst->linesize(0) / dst_bpp : dst->width(); - dst_tex->Download(dst->data(0), dst_linesize_pixels); + dst_tex->download(dst->data(0), dst_linesize_pixels); return dst; } } @@ -1171,7 +1171,7 @@ ConvertFrameIfNeeded(olive::AVFramePtr src, // 作用:从字节行跨度换算像素行跨度。 // Purpose: Convert byte line size to pixel line size. -static int LinesizeToPixels(const olive::VideoParams ¶ms, +static int linesize_to_pixels(const olive::VideoParams ¶ms, int linesize_bytes) { const int bytes_per_pixel = @@ -1185,7 +1185,7 @@ static int LinesizeToPixels(const olive::VideoParams ¶ms, // 作用:将纹理转换为指定 VideoParams。优先使用 GPU shader 做格式转换, // 避免 CPU 回读/转换/上传的性能损失和精度损失。 static olive::TexturePtr -ConvertTextureForParams(olive::TexturePtr src, +convert_texture_for_params(olive::TexturePtr src, const olive::VideoParams &dst_params) { if (!src) { @@ -1203,13 +1203,13 @@ ConvertTextureForParams(olive::TexturePtr src, // OpenGL texture sampling automatically normalizes U8/U16 to float, // and write-out quantizes float back to U8/U16 when needed. if (auto *renderer = src->renderer()) { - olive::TexturePtr dst = renderer->CreateTexture(dst_params); + olive::TexturePtr dst = renderer->create_texture(dst_params); if (dst) { olive::ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), - olive::NodeValue(olive::NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + olive::NodeValue(olive::NodeValue::k_texture, QVariant::fromValue(src))); - renderer->BlitToTexture(renderer->GetDefaultShader(), job, + renderer->blit_to_texture(renderer->get_default_shader(), job, dst.get(), false); return dst; } @@ -1218,14 +1218,14 @@ ConvertTextureForParams(olive::TexturePtr src, // CPU fallback: readback, sws_scale, re-upload olive::AVFramePtr frame = src->frame(); if (!frame || !frame->data(0)) { - frame = ReadbackTextureToFrame(src, src_params); + frame = readback_texture_to_frame(src, src_params); } if (!frame || !frame->data(0)) { return nullptr; } olive::AVFramePtr converted = - ConvertFrameIfNeeded(frame, dst_params, nullptr); + convert_frame_if_needed(frame, dst_params, nullptr); if (!converted || !converted->data(0)) { return nullptr; } @@ -1236,23 +1236,23 @@ ConvertTextureForParams(olive::TexturePtr src, olive::TexturePtr dst; if (auto *renderer = src->renderer()) { int linesize_pixels = - LinesizeToPixels(dst_params, converted->linesize(0)); + linesize_to_pixels(dst_params, converted->linesize(0)); if (linesize_pixels <= 0) { linesize_pixels = dst_params.effective_width(); } - dst = renderer->CreateTexture(dst_params, converted->data(0), + dst = renderer->create_texture(dst_params, converted->data(0), linesize_pixels); } else { dst = std::make_shared(dst_params); int linesize_pixels = - LinesizeToPixels(dst_params, converted->linesize(0)); + linesize_to_pixels(dst_params, converted->linesize(0)); if (linesize_pixels <= 0) { linesize_pixels = dst_params.effective_width(); } - dst->Upload(converted->data(0), linesize_pixels); + dst->upload(converted->data(0), linesize_pixels); } if (dst) { - dst->handleFrame(converted); + dst->handle_frame(converted); } return dst; } @@ -1260,7 +1260,7 @@ ConvertTextureForParams(olive::TexturePtr src, // 作用:安全获取插件标识符,便于日志输出。 // Purpose: Safely fetch plugin identifier for logging. static QString -PluginIdForInstance(const OFX::Host::ImageEffect::Instance *instance) +plugin_id_for_instance(const OFX::Host::ImageEffect::Instance *instance) { if (!instance) { return QStringLiteral(""); @@ -1274,7 +1274,7 @@ PluginIdForInstance(const OFX::Host::ImageEffect::Instance *instance) // 作用:统一 OFX 调用失败日志输出。 // Purpose: Centralized logging for OFX action failures. -static void LogOfxFailure(const char *action, OfxStatus stat, +static void log_ofx_failure(const char *action, OfxStatus stat, const OFX::Host::ImageEffect::Instance *instance) { if (stat == kOfxStatOK || stat == kOfxStatReplyDefault) { @@ -1282,13 +1282,13 @@ static void LogOfxFailure(const char *action, OfxStatus stat, } qWarning().noquote() << "OFX action failed:" << action - << "plugin=" << PluginIdForInstance(instance) + << "plugin=" << plugin_id_for_instance(instance) << "status=" << OFX::StatStr(stat) << "(" << stat << ")"; } // 作用:输出 clip 的声明属性与关联 VideoParams,辅助定位格式不一致。 // Purpose: Log clip declared properties and VideoParams for debugging. -static void LogClipState(const char *label, +static void log_clip_state(const char *label, const OFX::Host::ImageEffect::ClipInstance *clip, const olive::VideoParams *params) { @@ -1312,7 +1312,7 @@ static void LogClipState(const char *label, // 作用:输出 OFX Image 的属性(深度/组件/行跨度/边界)。 // Purpose: Log OFX image properties (depth/components/stride/bounds). -static void LogImageProps(const char *label, +static void log_image_props(const char *label, OFX::Host::ImageEffect::Image *image) { if (!image) { @@ -1339,20 +1339,20 @@ static void LogImageProps(const char *label, // 作用:渲染失败时标记目标画面(紫色)提示错误。 // Purpose: Mark render failure on destination (magenta). -static void MarkRenderFailure(olive::TexturePtr destination) +static void mark_render_failure(olive::TexturePtr destination) { if (destination && destination->renderer()) { - destination->renderer()->ClearDestination(destination.get(), 1.0, 0.0, + destination->renderer()->clear_destination(destination.get(), 1.0, 0.0, 1.0, 1.0); } } /// Show an error dialog and undo the last operation. Must be called from the GUI thread. -static void ShowErrorDialogAndUndo(const QString &message) +static void show_error_dialog_and_undo(const QString &message) { if (auto *core = olive::Core::instance()) { if (auto *stack = core->undo_stack()) { - if (stack->CanUndo()) { + if (stack->can_undo()) { stack->undo(); } } @@ -1361,25 +1361,25 @@ static void ShowErrorDialogAndUndo(const QString &message) } /// Schedule an error dialog + undo on the GUI thread from a render thread. -static void ScheduleErrorDialogAndUndo(const QString &message) +static void schedule_error_dialog_and_undo(const QString &message) { if (auto *app = QCoreApplication::instance()) { QMetaObject::invokeMethod( - app, [message]() { ShowErrorDialogAndUndo(message); }, + app, [message]() { show_error_dialog_and_undo(message); }, Qt::QueuedConnection); } } -static olive::AVFramePtr DownloadTextureToFrame(const olive::TexturePtr &tex) +static olive::AVFramePtr download_texture_to_frame(const olive::TexturePtr &tex) { - if (!tex || tex->IsDummy() || !tex->renderer()) { + if (!tex || tex->is_dummy() || !tex->renderer()) { return nullptr; } const olive::VideoParams ¶ms = tex->params(); - return ReadbackTextureToFrame(tex, params); + return readback_texture_to_frame(tex, params); } inline std::vector -GetPluginSupportedDepths(const OFX::Host::ImageEffect::Descriptor &desc) +get_plugin_supported_depths(const OFX::Host::ImageEffect::Descriptor &desc) { std::vector depths; const OFX::Host::Property::Set &props = desc.getProps(); @@ -1399,7 +1399,7 @@ GetPluginSupportedDepths(const OFX::Host::ImageEffect::Descriptor &desc) // 查询插件/宿主是否支持「各 clip 不同深度」 inline bool -SupportsMultipleClipDepths(const OFX::Host::ImageEffect::Descriptor &desc) +supports_multiple_clip_depths(const OFX::Host::ImageEffect::Descriptor &desc) { const OFX::Host::Property::Set &props = desc.getProps(); // 这是单值 int 属性(0 或 1),n = 0 @@ -1414,7 +1414,7 @@ SupportsMultipleClipDepths(const OFX::Host::ImageEffect::Descriptor &desc) // Purpose: Select best input pixel format from plugin descriptor's supported // depth list. Priority: F32 > U16 > U8 > F16. static PixelFormat -SelectBestPluginInputFormat(const OFX::Host::ImageEffect::Descriptor &desc) +select_best_plugin_input_format(const OFX::Host::ImageEffect::Descriptor &desc) { const OFX::Host::Property::Set &props = desc.getProps(); int dim = props.getDimension(kOfxImageEffectPropSupportedPixelDepths); @@ -1440,23 +1440,23 @@ SelectBestPluginInputFormat(const OFX::Host::ImageEffect::Descriptor &desc) // 优先级:F32 > U16 > U8 > F16 if (supports_f32) - return PixelFormat::F32; + return PixelFormat::f32; if (supports_u16) - return PixelFormat::U16; + return PixelFormat::u16; if (supports_u8) - return PixelFormat::U8; + return PixelFormat::u8; if (supports_f16) - return PixelFormat::F16; - return PixelFormat::INVALID; + return PixelFormat::f16; + return PixelFormat::invalid; } // 作用:执行 OFX 插件渲染全流程(准备输入、调用动作、处理输出)。 // Purpose: Run full OFX plugin render flow (inputs, actions, outputs). -void olive::plugin::PluginRenderer::RenderPlugin( +void olive::plugin::PluginRenderer::render_plugin( TexturePtr src, olive::plugin::PluginJob &job, olive::TexturePtr destination, olive::VideoParams destination_params, bool clear_destination, bool interactive) { - auto instance = job.pluginInstance(); + auto instance = job.plugin_instance(); if (!instance) { return; } @@ -1486,7 +1486,7 @@ void olive::plugin::PluginRenderer::RenderPlugin( auto *olive_instance = dynamic_cast(instance); const bool use_opengl = - supports_opengl && renderer_ && renderer_->IsOpenGL() && destination && + supports_opengl && renderer_ && renderer_->is_open_gl() && destination && destination->renderer() == renderer_ && destination->id().isValid(); if (olive_instance) { olive_instance->setOpenGLEnabled(use_opengl); @@ -1504,10 +1504,10 @@ void olive::plugin::PluginRenderer::RenderPlugin( } // current render scale of 1 - OfxPointD renderScale; - renderScale.x = renderScale.y = 1.0; + OfxPointD render_scale; + render_scale.x = render_scale.y = 1.0; - int numFramesToRender = 1; + int num_frames_to_render = 1; // Output Clip OliveClipInstance *output_clip = @@ -1521,8 +1521,8 @@ void olive::plugin::PluginRenderer::RenderPlugin( if (olive_instance && !olive_instance->isCreated()) { stat = instance->createInstanceAction(); if (stat != kOfxStatOK && stat != kOfxStatReplyDefault) { - LogOfxFailure("createInstance", stat, instance); - MarkRenderFailure(destination); + log_ofx_failure("createInstance", stat, instance); + mark_render_failure(destination); return; } } @@ -1532,13 +1532,13 @@ void olive::plugin::PluginRenderer::RenderPlugin( const auto &clips = olive_instance->getDescriptor().getClips(); QString effect_input_id; if (const auto *node = job.node()) { - effect_input_id = node->GetEffectInputID(); + effect_input_id = node->get_effect_input_id(); } auto is_usable_input = [](const TexturePtr &tex) { if (!tex) { return false; } - if (!tex->IsDummy() && tex->renderer()) { + if (!tex->is_dummy() && tex->renderer()) { return true; } AVFramePtr frame = tex->frame(); @@ -1547,7 +1547,7 @@ void olive::plugin::PluginRenderer::RenderPlugin( std::map input_textures; std::map input_clips; std::map input_params; - auto values = job.GetValues(); + auto values = job.get_values(); for (const auto &entry : clips) { if (entry.first == kOfxImageEffectOutputClipName) { continue; @@ -1563,10 +1563,10 @@ void olive::plugin::PluginRenderer::RenderPlugin( is_usable_input(src)) { input_tex = src; } else { - input_tex = values.value(clip_key).toTexture(); + input_tex = values.value(clip_key).to_texture(); if (!input_tex && entry.first == kOfxImageEffectSimpleSourceClipName) { - input_tex = values.value(kTextureInput).toTexture(); + input_tex = values.value(k_texture_input).to_texture(); } } if (!is_usable_input(input_tex) && @@ -1599,47 +1599,47 @@ void olive::plugin::PluginRenderer::RenderPlugin( } catch (const OFX::Host::Property::Exception &e) { qWarning().noquote() << "OFX getClipPreferences threw exception for plugin=" - << PluginIdForInstance(instance) << "stat=" << e.getStatus(); - MarkRenderFailure(destination); - ScheduleErrorDialogAndUndo( + << plugin_id_for_instance(instance) << "stat=" << e.getStatus(); + mark_render_failure(destination); + schedule_error_dialog_and_undo( QObject::tr( "Plugin %1 failed because connected inputs have different frame rates.\n" "The last operation has been undone.") - .arg(PluginIdForInstance(instance))); + .arg(plugin_id_for_instance(instance))); return; } catch (const std::exception &e) { qWarning().noquote() << "OFX getClipPreferences threw exception for plugin=" - << PluginIdForInstance(instance) << "what=" << e.what(); - MarkRenderFailure(destination); - ScheduleErrorDialogAndUndo( + << plugin_id_for_instance(instance) << "what=" << e.what(); + mark_render_failure(destination); + schedule_error_dialog_and_undo( QObject::tr("Plugin %1 encountered an error: %2\n" "The last operation has been undone.") - .arg(PluginIdForInstance(instance), + .arg(plugin_id_for_instance(instance), QString::fromUtf8(e.what()))); return; } if (!ok) { qWarning().noquote() << "OFX getClipPreferences failed for plugin=" - << PluginIdForInstance(instance); - MarkRenderFailure(destination); - ScheduleErrorDialogAndUndo( + << plugin_id_for_instance(instance); + mark_render_failure(destination); + schedule_error_dialog_and_undo( QObject::tr("Plugin %1 failed to get clip preferences.\n" "The last operation has been undone.") - .arg(PluginIdForInstance(instance))); + .arg(plugin_id_for_instance(instance))); return; } /// RoI is in canonical coords. - OfxRectD regionOfInterest; - regionOfInterest.x1 = 0.0; - regionOfInterest.y1 = 0.0; - regionOfInterest.x2 = destination_params.width() * - destination_params.pixel_aspect_ratio().toDouble(); - regionOfInterest.y2 = destination_params.height(); + OfxRectD region_of_interest; + region_of_interest.x1 = 0.0; + region_of_interest.y1 = 0.0; + region_of_interest.x2 = destination_params.width() * + destination_params.pixel_aspect_ratio().to_double(); + region_of_interest.y2 = destination_params.height(); - OfxRectD regionOfDefinition = regionOfInterest; + OfxRectD region_of_definition = region_of_interest; - output_clip->setRegionOfDefinition(regionOfDefinition, frame); + output_clip->setRegionOfDefinition(region_of_definition, frame); output_clip->setOutputTexture(destination, frame); // get the RoI for each input clip @@ -1657,7 +1657,7 @@ void olive::plugin::PluginRenderer::RenderPlugin( // so we must flush the renderer that actually produced the texture. for (const auto &entry : input_textures) { if (entry.second && entry.second->renderer()) { - entry.second->renderer()->Flush(); + entry.second->renderer()->flush(); } } @@ -1677,14 +1677,14 @@ void olive::plugin::PluginRenderer::RenderPlugin( // the best one according to our priority: F32 > U16 > U8 > F16. // OpenFX reference: kOfxImageEffectPropSupportedPixelDepths on // the image effect descriptor lists all depths the plugin can handle. - PixelFormat chosen_fmt = SelectBestPluginInputFormat(descriptor); + PixelFormat chosen_fmt = select_best_plugin_input_format(descriptor); VideoParams params = input_tex->params(); - if (chosen_fmt != PixelFormat::INVALID && + if (chosen_fmt != PixelFormat::invalid && params.format() != chosen_fmt) { params.set_format(chosen_fmt); TexturePtr converted_tex = - ConvertTextureForParams(input_tex, params); + convert_texture_for_params(input_tex, params); if (converted_tex && is_usable_input(converted_tex)) { input_tex = converted_tex; input_textures[entry.first] = input_tex; @@ -1695,15 +1695,15 @@ void olive::plugin::PluginRenderer::RenderPlugin( OfxRectD rod; rod.x1 = 0; rod.y1 = 0; - rod.x2 = params.width() * params.pixel_aspect_ratio().toDouble(); + rod.x2 = params.width() * params.pixel_aspect_ratio().to_double(); rod.y2 = params.height(); input_clip->setRegionOfDefinition(rod, frame); input_clips[entry.first] = input_clip; } } std::map rois; - stat = instance->getRegionOfInterestAction(frame, renderScale, - regionOfInterest, rois); + stat = instance->getRegionOfInterestAction(frame, render_scale, + region_of_interest, rois); if (stat != kOfxStatOK && stat != kOfxStatReplyDefault) { // Some plugins (e.g. CImg filters) return BadHandle from getRegionOfInterest // when internal clip/property handles are not fully initialized. @@ -1711,10 +1711,10 @@ void olive::plugin::PluginRenderer::RenderPlugin( if (stat == kOfxStatErrBadHandle) { qWarning().noquote() << "OFX getRegionOfInterest returned BadHandle for plugin=" - << PluginIdForInstance(instance) << "- using default RoI"; + << plugin_id_for_instance(instance) << "- using default RoI"; } else { - LogOfxFailure("getRegionOfInterest", stat, instance); - MarkRenderFailure(destination); + log_ofx_failure("getRegionOfInterest", stat, instance); + mark_render_failure(destination); return; } } @@ -1724,8 +1724,8 @@ void olive::plugin::PluginRenderer::RenderPlugin( // (zero conversion). If plugin only supports U8/U16 we let it render in // that format and ConvertFrameIfNeeded will convert back to F32 afterwards. VideoParams output_params = destination_params; - PixelFormat best_fmt = SelectBestPluginInputFormat(descriptor); - if (best_fmt != PixelFormat::INVALID) { + PixelFormat best_fmt = select_best_plugin_input_format(descriptor); + if (best_fmt != PixelFormat::invalid) { output_params.set_format(best_fmt); } output_clip->setParams(output_params); @@ -1738,66 +1738,66 @@ void olive::plugin::PluginRenderer::RenderPlugin( // The render window is in pixel coordinates // ie: render scale and a PAR of not 1 - OfxRectI renderWindow; - renderWindow.x1 = renderWindow.y1 = 0; - renderWindow.x2 = destination_params.width(); - renderWindow.y2 = destination_params.height(); + OfxRectI render_window; + render_window.x1 = render_window.y1 = 0; + render_window.x2 = destination_params.width(); + render_window.y2 = destination_params.height(); - stat = instance->beginRenderAction(frame, numFramesToRender, 1.0, false, - renderScale, true, interactive); + stat = instance->beginRenderAction(frame, num_frames_to_render, 1.0, false, + render_scale, true, interactive); if (stat != kOfxStatOK && stat != kOfxStatReplyDefault) { - LogOfxFailure("beginRender", stat, instance); - MarkRenderFailure(destination); + log_ofx_failure("beginRender", stat, instance); + mark_render_failure(destination); return; } #ifdef OFX_SUPPORTS_OPENGLRENDER if (use_opengl) { instance->contextAttachedAction(); - AttachOutputTexture(destination); + attach_output_texture(destination); } #endif if (!output_params.is_valid()) { qWarning().noquote() << "OFX render skipped due to invalid output params for plugin=" - << PluginIdForInstance(instance); - MarkRenderFailure(destination); - instance->endRenderAction(frame, numFramesToRender, 1.0, interactive, - renderScale, true, interactive); + << plugin_id_for_instance(instance); + mark_render_failure(destination); + instance->endRenderAction(frame, num_frames_to_render, 1.0, interactive, + render_scale, true, interactive); return; } // Inject current parameter values into the OFX instance before rendering. // Parameters are bound to PluginNode inputs, so they change every frame. - ApplyParamOverrides(*instance, job.GetValues(), frame); + apply_param_overrides(*instance, job.get_values(), frame); // render a frame - const char *render_field = GetRenderFieldForParams(output_params); - stat = instance->renderAction(frame, render_field, renderWindow, - renderScale, true, interactive, interactive); + const char *render_field = get_render_field_for_params(output_params); + stat = instance->renderAction(frame, render_field, render_window, + render_scale, true, interactive, interactive); if (stat != kOfxStatOK && stat != kOfxStatReplyDefault) { - LogOfxFailure("render", stat, instance); - LogClipState("output", output_clip, &output_params); + log_ofx_failure("render", stat, instance); + log_clip_state("output", output_clip, &output_params); for (const auto &entry : input_clips) { const auto params_it = input_params.find(entry.first); const olive::VideoParams *params = (params_it != input_params.end()) ? ¶ms_it->second : nullptr; - LogClipState("input", entry.second, params); + log_clip_state("input", entry.second, params); OFX::Host::ImageEffect::Image *image = entry.second->getImage(frame, nullptr); - LogImageProps("input", image); + log_image_props("input", image); //if (image) { //image->releaseReference(); //} } OFX::Host::ImageEffect::Image *output_image = output_clip->getOutputImage(frame); - LogImageProps("output", output_image); - MarkRenderFailure(destination); - instance->endRenderAction(frame, numFramesToRender, 1.0, interactive, - renderScale, true, interactive); + log_image_props("output", output_image); + mark_render_failure(destination); + instance->endRenderAction(frame, num_frames_to_render, 1.0, interactive, + render_scale, true, interactive); return; } @@ -1808,10 +1808,10 @@ void olive::plugin::PluginRenderer::RenderPlugin( if (!output_image) { qWarning().noquote() << "OFX getOutputImage returned null for plugin=" - << PluginIdForInstance(instance); - MarkRenderFailure(destination); - instance->endRenderAction(frame, numFramesToRender, 1.0, - interactive, renderScale, true, + << plugin_id_for_instance(instance); + mark_render_failure(destination); + instance->endRenderAction(frame, num_frames_to_render, 1.0, + interactive, render_scale, true, interactive); return; } @@ -1830,11 +1830,11 @@ void olive::plugin::PluginRenderer::RenderPlugin( } else { if (!destination || !destination->id().isValid()) { #ifdef OFX_SUPPORTS_OPENGLRENDER - DetachOutputTexture(); + detach_output_texture(); instance->contextDetachedAction(); #endif - instance->endRenderAction(frame, numFramesToRender, 1.0, - interactive, renderScale, true, + instance->endRenderAction(frame, num_frames_to_render, 1.0, + interactive, render_scale, true, interactive); return; } @@ -1846,62 +1846,62 @@ void olive::plugin::PluginRenderer::RenderPlugin( if (!frame_ptr) { qWarning().noquote() << "OFX output image conversion failed for plugin=" - << PluginIdForInstance(instance); - instance->endRenderAction(frame, numFramesToRender, 1.0, - interactive, renderScale, true, + << plugin_id_for_instance(instance); + instance->endRenderAction(frame, num_frames_to_render, 1.0, + interactive, render_scale, true, interactive); return; } AVFramePtr converted = - ConvertFrameIfNeeded(frame_ptr, destination_params, renderer_); + convert_frame_if_needed(frame_ptr, destination_params, renderer_); const int expected_fmt = - GetDestinationAVPixelFormat(destination_params); - destination->handleFrame(converted); + get_destination_av_pixel_format(destination_params); + destination->handle_frame(converted); if (destination->renderer() && converted && converted->data(0) && - (expected_fmt == FB_PIX_FMT_NONE || + (expected_fmt == fb_pix_fmt_none || converted->format() == expected_fmt)) { int linesize_pixels = - LinesizeToPixels(destination_params, converted->linesize(0)); + linesize_to_pixels(destination_params, converted->linesize(0)); if (linesize_pixels <= 0) { linesize_pixels = destination_params.effective_width(); } - destination->Upload(converted->data(0), linesize_pixels); + destination->upload(converted->data(0), linesize_pixels); } else if (destination->renderer() && converted && converted->data(0)) { qWarning().noquote() << "OFX output pixel format mismatch for plugin=" - << PluginIdForInstance(instance); + << plugin_id_for_instance(instance); } } else { // OpenGL path: plugin has already rendered directly into the destination // texture via FBO/GL. No CPU readback or conversion needed. #ifdef OFX_SUPPORTS_OPENGLRENDER - DetachOutputTexture(); + detach_output_texture(); instance->contextDetachedAction(); #endif - instance->endRenderAction(frame, numFramesToRender, 1.0, interactive, - renderScale, true, interactive); + instance->endRenderAction(frame, num_frames_to_render, 1.0, interactive, + render_scale, true, interactive); return; } - instance->endRenderAction(frame, numFramesToRender, 1.0, interactive, - renderScale, true, interactive); + instance->endRenderAction(frame, num_frames_to_render, 1.0, interactive, + render_scale, true, interactive); } // 作用:绑定输出纹理到 OFX 的 GL 输出路径。 // Purpose: Attach output texture for OFX GL rendering. -void olive::plugin::PluginRenderer::AttachOutputTexture( +void olive::plugin::PluginRenderer::attach_output_texture( olive::TexturePtr texture) { if (renderer_) { - renderer_->AttachOutputTexture(texture.get()); + renderer_->attach_output_texture(texture.get()); } } // 作用:解除 OFX 的 GL 输出绑定。 // Purpose: Detach OFX GL output binding. -void olive::plugin::PluginRenderer::DetachOutputTexture() +void olive::plugin::PluginRenderer::detach_output_texture() { if (renderer_) { - renderer_->DetachOutputTexture(); + renderer_->detach_output_texture(); } } diff --git a/app/render/plugin/pluginrenderer.h b/app/render/plugin/pluginrenderer.h index cc08b52cb..c2b501e08 100644 --- a/app/render/plugin/pluginrenderer.h +++ b/app/render/plugin/pluginrenderer.h @@ -21,8 +21,8 @@ // Created by mikesolar on 25-10-19. // -#ifndef PLUGINRENDERER_H -#define PLUGINRENDERER_H +#ifndef OAK_PLUGINRENDERER_H +#define OAK_PLUGINRENDERER_H #include @@ -37,7 +37,7 @@ namespace detail { // 作用:将字节行跨度转换为像素跨度,便于纹理读写。 // Purpose: Convert byte stride to pixel stride for texture I/O. -int BytesToPixels(int byte_linesize, const olive::VideoParams ¶ms); +int bytes_to_pixels(int byte_linesize, const olive::VideoParams ¶ms); } // 作用:OFX 插件渲染器,负责 CPU/GL 路径下的插件调用和纹理桥接。 // Purpose: OFX plugin renderer that drives CPU/GL render paths and texture bridging. @@ -65,13 +65,13 @@ public: // 作用:将目标纹理绑定为插件输出。 // Purpose: Attach destination texture as OFX output. - void AttachOutputTexture(olive::TexturePtr texture); + void attach_output_texture(olive::TexturePtr texture); // 作用:解除目标纹理绑定。 // Purpose: Detach destination texture binding. - void DetachOutputTexture(); + void detach_output_texture(); // 作用:执行插件渲染流程(参数配置、输入/输出、调用渲染动作)。 // Purpose: Execute plugin render flow (params, inputs/outputs, render actions). - void RenderPlugin(TexturePtr src, olive::plugin::PluginJob &job, + void render_plugin(TexturePtr src, olive::plugin::PluginJob &job, olive::TexturePtr destination, olive::VideoParams destination_params, bool clear_destination, bool interactive); @@ -82,4 +82,4 @@ private: } } -#endif //PLUGINRENDERER_H +#endif //OAK_PLUGINRENDERER_H diff --git a/app/render/previewaudiodevice.cpp b/app/render/previewaudiodevice.cpp index c4ea42e29..f66a62222 100644 --- a/app/render/previewaudiodevice.cpp +++ b/app/render/previewaudiodevice.cpp @@ -42,16 +42,16 @@ bool PreviewAudioDevice::isSequential() const return true; } -void PreviewAudioDevice::SetParams(const core::AudioParams ¶ms) +void PreviewAudioDevice::set_params(const core::AudioParams ¶ms) { set_bytes_per_frame(params.samples_to_bytes(1)); } -qint64 PreviewAudioDevice::readData(char *data, qint64 maxSize) +qint64 PreviewAudioDevice::readData(char *data, qint64 max_size) { QMutexLocker locker(&lock_); - qint64 copy_length = qMin(maxSize, qint64(buffer_.size())); + qint64 copy_length = qMin(max_size, qint64(buffer_.size())); if (copy_length) { qint64 new_bytes_read = bytes_read_ + copy_length; @@ -59,7 +59,7 @@ qint64 PreviewAudioDevice::readData(char *data, qint64 maxSize) if (notify_interval_ > 0) { if ((bytes_read_ / notify_interval_) != (new_bytes_read / notify_interval_)) { - emit Notify(); + emit notify(); } } diff --git a/app/render/previewaudiodevice.h b/app/render/previewaudiodevice.h index d75e67d68..06b92e83b 100644 --- a/app/render/previewaudiodevice.h +++ b/app/render/previewaudiodevice.h @@ -19,8 +19,8 @@ ***/ -#ifndef PREVIEWAUDIODEVICE_H -#define PREVIEWAUDIODEVICE_H +#ifndef OAK_PREVIEWAUDIODEVICE_H +#define OAK_PREVIEWAUDIODEVICE_H #include @@ -36,18 +36,18 @@ public: virtual ~PreviewAudioDevice() override; - void StartQueuing(); + void start_queuing(); virtual bool isSequential() const override; - virtual qint64 readData(char *data, qint64 maxSize) override; + virtual qint64 readData(char *data, qint64 max_size) override; virtual qint64 writeData(const char *data, qint64 length) override; // Derives the frame size from the audio format (bytes per sample per // channel * channel count). Until params are set, bytes_per_frame() // reports 0, i.e. "unknown". - void SetParams(const core::AudioParams ¶ms); + void set_params(const core::AudioParams ¶ms); int bytes_per_frame() const { @@ -67,7 +67,7 @@ public: void clear(); signals: - void Notify(); + void notify(); private: QMutex lock_; @@ -83,4 +83,4 @@ private: } -#endif // PREVIEWAUDIODEVICE_H +#endif // OAK_PREVIEWAUDIODEVICE_H diff --git a/app/render/previewautocacher.cpp b/app/render/previewautocacher.cpp index 8af52f35b..61a6290d4 100644 --- a/app/render/previewautocacher.cpp +++ b/app/render/previewautocacher.cpp @@ -47,66 +47,66 @@ PreviewAutoCacher::PreviewAutoCacher(QObject *parent) , ignore_cache_requests_(false) { copier_ = new ProjectCopier(this); - connect(copier_, &ProjectCopier::AddedNode, this, - &PreviewAutoCacher::ConnectToNodeCache); - connect(copier_, &ProjectCopier::RemovedNode, this, - &PreviewAutoCacher::DisconnectFromNodeCache); + connect(copier_, &ProjectCopier::added_node, this, + &PreviewAutoCacher::connect_to_node_cache); + connect(copier_, &ProjectCopier::removed_node, this, + &PreviewAutoCacher::disconnect_from_node_cache); // Set defaults - SetPlayhead(0); + set_playhead(0); // Wait a certain amount of time before requeuing when we receive an invalidate signal - delayed_requeue_timer_.setInterval(OLIVE_CONFIG("AutoCacheDelay").toInt()); + delayed_requeue_timer_.setInterval(OAK_CONFIG("AutoCacheDelay").toInt()); delayed_requeue_timer_.setSingleShot(true); connect(&delayed_requeue_timer_, &QTimer::timeout, this, - &PreviewAutoCacher::TryRender); + &PreviewAutoCacher::try_render); // Catch when a conform is ready - connect(ConformManager::instance(), &ConformManager::ConformReady, this, - &PreviewAutoCacher::ConformFinished); + connect(ConformManager::instance(), &ConformManager::conform_ready, this, + &PreviewAutoCacher::conform_finished); } PreviewAutoCacher::~PreviewAutoCacher() { // Ensure everything is cleaned up appropriately - SetProject(nullptr); + set_project(nullptr); } -RenderTicketPtr PreviewAutoCacher::GetSingleFrame(ViewerOutput *viewer, - const rational &t, bool dry) +RenderTicketPtr PreviewAutoCacher::get_single_frame(ViewerOutput *viewer, + const Rational &t, bool dry) { - return GetSingleFrame(viewer->GetConnectedTextureOutput(), viewer, t, dry); + return get_single_frame(viewer->get_connected_texture_output(), viewer, t, dry); } -RenderTicketPtr PreviewAutoCacher::GetSingleFrame(Node *n, ViewerOutput *viewer, - const rational &t, bool dry) +RenderTicketPtr PreviewAutoCacher::get_single_frame(Node *n, ViewerOutput *viewer, + const Rational &t, bool dry) { // If we have a single frame render queued (but not yet sent to the RenderManager), cancel it now - CancelQueuedSingleFrameRender(); + cancel_queued_single_frame_render(); // Create a new single frame render ticket auto sfr = std::make_shared(); - sfr->Start(); + sfr->start(); sfr->setProperty("time", QVariant::fromValue(t)); sfr->setProperty("dry", dry); - sfr->setProperty("node", QtUtils::PtrToValue(n)); - sfr->setProperty("viewer", QtUtils::PtrToValue(viewer)); + sfr->setProperty("node", QtUtils::ptr_to_value(n)); + sfr->setProperty("viewer", QtUtils::ptr_to_value(viewer)); // Queue it and try to render single_frame_render_ = sfr; - TryRender(); + try_render(); return sfr; } -RenderTicketPtr PreviewAutoCacher::GetRangeOfAudio(ViewerOutput *viewer, +RenderTicketPtr PreviewAutoCacher::get_range_of_audio(ViewerOutput *viewer, TimeRange range) { - Node *copy = copier_->GetCopy(viewer->GetConnectedSampleOutput()); - return RenderAudio(copy, viewer, range, nullptr); + Node *copy = copier_->get_copy(viewer->get_connected_sample_output()); + return render_audio(copy, viewer, range, nullptr); } -void PreviewAutoCacher::ClearSingleFrameRenders() +void PreviewAutoCacher::clear_single_frame_renders() { // Snapshot the watchers as guarded pointers before doing anything that // might synchronously delete them (emitting Finished runs VideoRendered, @@ -126,18 +126,18 @@ void PreviewAutoCacher::ClearSingleFrameRenders() // Keep already-running workers alive: cancelling an in-flight render // forces the worker process to be torn down, which defeats the process // pool. Frames that finish late are simply ignored by the viewer. - if (w->IsRunning()) { + if (w->is_running()) { continue; } - RenderTicketPtr ticket = w->GetTicket(); - w->Cancel(); - RenderManager::instance()->RemoveTicket(ticket); - emit ticket->Finished(); + RenderTicketPtr ticket = w->get_ticket(); + w->cancel(); + RenderManager::instance()->remove_ticket(ticket); + emit ticket->finished(); } } -void PreviewAutoCacher::ClearSingleFrameRendersThatArentRunning() +void PreviewAutoCacher::clear_single_frame_renders_that_arent_running() { QList> watchers; for (auto it = video_immediate_passthroughs_.cbegin(); @@ -146,38 +146,38 @@ void PreviewAutoCacher::ClearSingleFrameRendersThatArentRunning() } foreach (const QPointer &w, watchers) { - if (!w || w->IsRunning()) { + if (!w || w->is_running()) { continue; } - RenderTicketPtr ticket = w->GetTicket(); - w->Cancel(); - RenderManager::instance()->RemoveTicket(ticket); - emit ticket->Finished(); + RenderTicketPtr ticket = w->get_ticket(); + w->cancel(); + RenderManager::instance()->remove_ticket(ticket); + emit ticket->finished(); } } -void PreviewAutoCacher::VideoInvalidatedFromCache(ViewerOutput *context, +void PreviewAutoCacher::video_invalidated_from_cache(ViewerOutput *context, const TimeRange &range) { PlaybackCache *cache = static_cast(sender()); - cache->ClearRequestRange(range); + cache->clear_request_range(range); - VideoInvalidatedFromNode(context, cache, range); + video_invalidated_from_node(context, cache, range); } -void PreviewAutoCacher::AudioInvalidatedFromCache(ViewerOutput *context, +void PreviewAutoCacher::audio_invalidated_from_cache(ViewerOutput *context, const TimeRange &range) { PlaybackCache *cache = static_cast(sender()); - cache->ClearRequestRange(range); + cache->clear_request_range(range); - AudioInvalidatedFromNode(context, cache, range); + audio_invalidated_from_node(context, cache, range); } -void PreviewAutoCacher::CancelForCache() +void PreviewAutoCacher::cancel_for_cache() { PlaybackCache *cache = static_cast(sender()); @@ -204,7 +204,7 @@ void PreviewAutoCacher::CancelForCache() } } -void PreviewAutoCacher::AudioRendered() +void PreviewAutoCacher::audio_rendered() { // Receive watcher RenderTicketWatcher *watcher = static_cast(sender()); @@ -214,11 +214,11 @@ void PreviewAutoCacher::AudioRendered() if (running_audio_tasks_.removeOne(watcher)) { // Assume that a "result" is a fully completed image and a non-result is a cancelled ticket TimeRange range = watcher->property("time").value(); - Node *node = copier_->GetOriginal( - QtUtils::ValueToPtr(watcher->property("node"))); + Node *node = copier_->get_original( + QtUtils::value_to_ptr(watcher->property("node"))); - if (watcher->HasResult() && node) { - if (PlaybackCache *cache = QtUtils::ValueToPtr( + if (watcher->has_result() && node) { + if (PlaybackCache *cache = QtUtils::value_to_ptr( watcher->property("cache"))) { AudioCacheData &d = audio_cache_data_[cache]; @@ -229,33 +229,33 @@ void PreviewAutoCacher::AudioRendered() d.job_tracker.getCurrentSubRanges(range, watcher_job_time); AudioVisualWaveform waveform = - watcher->GetTicket() + watcher->get_ticket() ->property("waveform") .value(); - SampleBuffer buf = watcher->Get().value(); + SampleBuffer buf = watcher->get().value(); bool incomplete = - watcher->GetTicket()->property("incomplete").toBool(); + watcher->get_ticket()->property("incomplete").toBool(); if (AudioPlaybackCache *pcm = dynamic_cast(cache)) { // WritePCM is tolerant to its buffer being null, it will just write silence instead - pcm->SetParameters(buf.audio_params()); - pcm->WritePCM(range, valid_ranges, - watcher->Get().value()); + pcm->set_parameters(buf.audio_params()); + pcm->write_pcm(range, valid_ranges, + watcher->get().value()); } else if (AudioWaveformCache *wave = dynamic_cast(cache)) { - wave->SetParameters(buf.audio_params()); + wave->set_parameters(buf.audio_params()); if (!incomplete) { - wave->WriteWaveform(range, valid_ranges, &waveform); + wave->write_waveform(range, valid_ranges, &waveform); } } if (incomplete) { if (last_conform_task_ > watcher_job_time) { // Requeue now - cache->Invalidate(range); + cache->invalidate(range); } else { // Wait for conform d.needs_conform.insert(range); @@ -265,21 +265,21 @@ void PreviewAutoCacher::AudioRendered() } // Continue rendering - TryRender(); + try_render(); } delete watcher; } -void PreviewAutoCacher::VideoRendered() +void PreviewAutoCacher::video_rendered() { RenderTicketWatcher *watcher = static_cast(sender()); const QStringList bad_cache_names = - watcher->GetTicket()->property("badcache").toStringList(); + watcher->get_ticket()->property("badcache").toStringList(); if (!bad_cache_names.empty()) { for (const QString &fn : bad_cache_names) { - DiskManager::instance()->DeleteSpecificFile(fn); + DiskManager::instance()->delete_specific_file(fn); } } @@ -288,12 +288,12 @@ void PreviewAutoCacher::VideoRendered() QVector tickets = video_immediate_passthroughs_.take(watcher); foreach (RenderTicketPtr t, tickets) { - if (watcher->HasResult()) { + if (watcher->has_result()) { t->setProperty("multicam_output", - watcher->GetTicket()->property("multicam_output")); - t->Finish(watcher->Get()); + watcher->get_ticket()->property("multicam_output")); + t->finish(watcher->get()); } else { - t->Finish(); + t->finish(); } } @@ -301,139 +301,139 @@ void PreviewAutoCacher::VideoRendered() // viewer switch, so we'll completely ignore this watcher if (running_video_tasks_.removeOne(watcher)) { // Assume that a "result" is a fully completed image and a non-result is a cancelled ticket - if (watcher->HasResult()) { - if (watcher->GetTicket()->property("cached").toBool()) { - if (FrameHashCache *cache = QtUtils::ValueToPtr( + if (watcher->has_result()) { + if (watcher->get_ticket()->property("cached").toBool()) { + if (FrameHashCache *cache = QtUtils::value_to_ptr( watcher->property("cache"))) { - rational time = watcher->property("time").value(); + Rational time = watcher->property("time").value(); JobTime job = watcher->property("job").value(); if (video_cache_data_.value(cache).job_tracker.isCurrent( time, job)) { - cache->ValidateTime(time); + cache->validate_time(time); } } } } // Continue rendering - TryRender(); + try_render(); } delete watcher; } -void PreviewAutoCacher::ConnectToNodeCache(Node *node) +void PreviewAutoCacher::connect_to_node_cache(Node *node) { if (ignore_cache_requests_) { return; } - connect(node->video_frame_cache(), &PlaybackCache::Requested, this, - &PreviewAutoCacher::VideoInvalidatedFromCache); + connect(node->video_frame_cache(), &PlaybackCache::requested, this, + &PreviewAutoCacher::video_invalidated_from_cache); - connect(node->thumbnail_cache(), &PlaybackCache::Requested, this, - &PreviewAutoCacher::VideoInvalidatedFromCache); + connect(node->thumbnail_cache(), &PlaybackCache::requested, this, + &PreviewAutoCacher::video_invalidated_from_cache); - connect(node->audio_playback_cache(), &PlaybackCache::Requested, this, - &PreviewAutoCacher::AudioInvalidatedFromCache); + connect(node->audio_playback_cache(), &PlaybackCache::requested, this, + &PreviewAutoCacher::audio_invalidated_from_cache); - connect(node->waveform_cache(), &PlaybackCache::Requested, this, - &PreviewAutoCacher::AudioInvalidatedFromCache); + connect(node->waveform_cache(), &PlaybackCache::requested, this, + &PreviewAutoCacher::audio_invalidated_from_cache); - connect(node->video_frame_cache(), &PlaybackCache::CancelAll, this, - &PreviewAutoCacher::CancelForCache); + connect(node->video_frame_cache(), &PlaybackCache::cancel_all, this, + &PreviewAutoCacher::cancel_for_cache); - connect(node->audio_playback_cache(), &PlaybackCache::CancelAll, this, - &PreviewAutoCacher::CancelForCache); + connect(node->audio_playback_cache(), &PlaybackCache::cancel_all, this, + &PreviewAutoCacher::cancel_for_cache); - node->video_frame_cache()->ResignalRequests(); - node->thumbnail_cache()->ResignalRequests(); - node->audio_playback_cache()->ResignalRequests(); - node->waveform_cache()->ResignalRequests(); + node->video_frame_cache()->resignal_requests(); + node->thumbnail_cache()->resignal_requests(); + node->audio_playback_cache()->resignal_requests(); + node->waveform_cache()->resignal_requests(); } -void PreviewAutoCacher::DisconnectFromNodeCache(Node *node) +void PreviewAutoCacher::disconnect_from_node_cache(Node *node) { - disconnect(node->video_frame_cache(), &PlaybackCache::Requested, this, - &PreviewAutoCacher::VideoInvalidatedFromCache); + disconnect(node->video_frame_cache(), &PlaybackCache::requested, this, + &PreviewAutoCacher::video_invalidated_from_cache); - disconnect(node->thumbnail_cache(), &PlaybackCache::Requested, this, - &PreviewAutoCacher::VideoInvalidatedFromCache); + disconnect(node->thumbnail_cache(), &PlaybackCache::requested, this, + &PreviewAutoCacher::video_invalidated_from_cache); - disconnect(node->audio_playback_cache(), &PlaybackCache::Requested, this, - &PreviewAutoCacher::AudioInvalidatedFromCache); + disconnect(node->audio_playback_cache(), &PlaybackCache::requested, this, + &PreviewAutoCacher::audio_invalidated_from_cache); - disconnect(node->waveform_cache(), &PlaybackCache::Requested, this, - &PreviewAutoCacher::AudioInvalidatedFromCache); + disconnect(node->waveform_cache(), &PlaybackCache::requested, this, + &PreviewAutoCacher::audio_invalidated_from_cache); - disconnect(node->video_frame_cache(), &PlaybackCache::CancelAll, this, - &PreviewAutoCacher::CancelForCache); + disconnect(node->video_frame_cache(), &PlaybackCache::cancel_all, this, + &PreviewAutoCacher::cancel_for_cache); - disconnect(node->audio_playback_cache(), &PlaybackCache::CancelAll, this, - &PreviewAutoCacher::CancelForCache); + disconnect(node->audio_playback_cache(), &PlaybackCache::cancel_all, this, + &PreviewAutoCacher::cancel_for_cache); } -void PreviewAutoCacher::CancelQueuedSingleFrameRender() +void PreviewAutoCacher::cancel_queued_single_frame_render() { if (single_frame_render_) { // Signal that this ticket was cancelled with no value - single_frame_render_->Finish(); + single_frame_render_->finish(); single_frame_render_ = nullptr; } } -void PreviewAutoCacher::StartCachingRange(const TimeRange &range, +void PreviewAutoCacher::start_caching_range(const TimeRange &range, TimeRangeList *range_list, RenderJobTracker *tracker) { range_list->insert(range); - tracker->insert(range, copier_->GetGraphChangeTime()); + tracker->insert(range, copier_->get_graph_change_time()); } -void PreviewAutoCacher::StartCachingVideoRange(ViewerOutput *context, +void PreviewAutoCacher::start_caching_video_range(ViewerOutput *context, PlaybackCache *cache, const TimeRange &range) { Node *node = cache->parent(); - rational using_tb; + Rational using_tb; if (ThumbnailCache *thumbs = dynamic_cast(cache)) { - using_tb = thumbs->GetTimebase(); + using_tb = thumbs->get_timebase(); } else { - using_tb = context->GetVideoParams().frame_rate_as_time_base(); + using_tb = context->get_video_params().frame_rate_as_time_base(); } - cache->ClearRequestRange(range); + cache->clear_request_range(range); TimeRangeListFrameIterator iterator({ range }, using_tb); pending_video_jobs_.push_back({ node, context, cache, range, iterator }); video_cache_data_[cache].job_tracker.insert( - TimeRange(iterator.Snap(range.in()), range.out()), - copier_->GetGraphChangeTime()); - TryRender(); + TimeRange(iterator.snap(range.in()), range.out()), + copier_->get_graph_change_time()); + try_render(); } -void PreviewAutoCacher::StartCachingAudioRange(ViewerOutput *context, +void PreviewAutoCacher::start_caching_audio_range(ViewerOutput *context, PlaybackCache *cache, const TimeRange &range) { Node *node = cache->parent(); - cache->ClearRequestRange(range); + cache->clear_request_range(range); pending_audio_jobs_.push_back({ node, context, cache, range }); AudioCacheData &data = audio_cache_data_[cache]; data.context = context; - data.job_tracker.insert(range, copier_->GetGraphChangeTime()); - TryRender(); + data.job_tracker.insert(range, copier_->get_graph_change_time()); + try_render(); } -void PreviewAutoCacher::VideoInvalidatedFromNode(ViewerOutput *context, +void PreviewAutoCacher::video_invalidated_from_node(ViewerOutput *context, PlaybackCache *cache, const TimeRange &range) { // Ignore render requests if no video is present - if (!context || !context->GetVideoParams().is_valid()) { + if (!context || !context->get_video_params().is_valid()) { return; } @@ -441,20 +441,20 @@ void PreviewAutoCacher::VideoInvalidatedFromNode(ViewerOutput *context, // want to dedicate all our rendering power to realtime feedback for the user //CancelVideoTasks(node); - cache->ClearRequestRange(range); + cache->clear_request_range(range); // If auto-cache is enabled and a slider is not being dragged, queue up to hash these frames - if (!NodeInputDragger::IsInputBeingDragged()) { - StartCachingVideoRange(context, cache, range); + if (!NodeInputDragger::is_input_being_dragged()) { + start_caching_video_range(context, cache, range); } } -void PreviewAutoCacher::AudioInvalidatedFromNode(ViewerOutput *context, +void PreviewAutoCacher::audio_invalidated_from_node(ViewerOutput *context, PlaybackCache *cache, const TimeRange &range) { // Ignore render requests if no video is present - if (!context || !context->GetAudioParams().is_valid()) { + if (!context || !context->get_audio_params().is_valid()) { return; } @@ -462,54 +462,54 @@ void PreviewAutoCacher::AudioInvalidatedFromNode(ViewerOutput *context, // cancelled, so some areas may end up unrendered forever // ClearAudioQueue(); - cache->ClearRequestRange(range); + cache->clear_request_range(range); // If we're auto-caching audio or require realtime waveforms, we'll have to render this - StartCachingAudioRange(context, cache, range); + start_caching_audio_range(context, cache, range); } -void PreviewAutoCacher::SetPlayhead(const rational &playhead) +void PreviewAutoCacher::set_playhead(const Rational &playhead) { cache_range_ = - TimeRange(playhead - OLIVE_CONFIG("DiskCacheBehind").value(), - playhead + OLIVE_CONFIG("DiskCacheAhead").value()); + TimeRange(playhead - OAK_CONFIG("DiskCacheBehind").value(), + playhead + OAK_CONFIG("DiskCacheAhead").value()); - TryRender(); + try_render(); } -template void CancelTasks(const T &task_list, bool and_wait) +template void cancel_tasks(const T &task_list, bool and_wait) { for (auto it = task_list.cbegin(); it != task_list.cend(); it++) { // Signal that the ticket should not be finished - (*it)->Cancel(); + (*it)->cancel(); } if (and_wait) { // Wait for each ticket to finish for (auto it = task_list.cbegin(); it != task_list.cend(); it++) { - (*it)->WaitForFinished(); + (*it)->wait_for_finished(); } } } -void PreviewAutoCacher::CancelVideoTasks(bool and_wait_for_them_to_finish) +void PreviewAutoCacher::cancel_video_tasks(bool and_wait_for_them_to_finish) { - CancelTasks(running_video_tasks_, and_wait_for_them_to_finish); + cancel_tasks(running_video_tasks_, and_wait_for_them_to_finish); } -void PreviewAutoCacher::CancelAudioTasks(bool and_wait_for_them_to_finish) +void PreviewAutoCacher::cancel_audio_tasks(bool and_wait_for_them_to_finish) { - CancelTasks(running_audio_tasks_, and_wait_for_them_to_finish); + cancel_tasks(running_audio_tasks_, and_wait_for_them_to_finish); } -bool PreviewAutoCacher::IsRenderingCustomRange() const +bool PreviewAutoCacher::is_rendering_custom_range() const { if (!use_custom_range_) { return false; } for (const VideoJob &job : pending_video_jobs_) { - if (job.range == custom_autocache_range_ && job.iterator.HasNext()) { + if (job.range == custom_autocache_range_ && job.iterator.has_next()) { return true; } } @@ -517,27 +517,27 @@ bool PreviewAutoCacher::IsRenderingCustomRange() const return false; } -void PreviewAutoCacher::SetRendersPaused(bool e) +void PreviewAutoCacher::set_renders_paused(bool e) { pause_renders_ = e; if (!e) { - TryRender(); + try_render(); } } -void PreviewAutoCacher::SetThumbnailsPaused(bool e) +void PreviewAutoCacher::set_thumbnails_paused(bool e) { pause_thumbnails_ = e; if (!e) { - TryRender(); + try_render(); } } -void PreviewAutoCacher::TryRender() +void PreviewAutoCacher::try_render() { delayed_requeue_timer_.stop(); - if (copier_->HasUpdatesInQueue()) { + if (copier_->has_updates_in_queue()) { // Check if we have jobs running in other threads that shouldn't be interrupted right now // NOTE: We don't check for downloads because, while they run in another thread, they don't // require any access to the graph and therefore don't risk race conditions. @@ -547,7 +547,7 @@ void PreviewAutoCacher::TryRender() } // No jobs are active, we can process the update queue - copier_->ProcessUpdateQueue(); + copier_->process_update_queue(); } if (single_frame_render_) { @@ -557,13 +557,13 @@ void PreviewAutoCacher::TryRender() single_frame_render_ = nullptr; // Check if already caching this - Node *n = QtUtils::ValueToPtr(t->property("node")); - Node *copy = copier_->GetCopy(n); + Node *n = QtUtils::value_to_ptr(t->property("node")); + Node *copy = copier_->get_copy(n); if (copy) { - RenderTicketWatcher *watcher = RenderFrame( - copy, QtUtils::ValueToPtr(t->property("viewer")), - t->property("time").value(), nullptr, + RenderTicketWatcher *watcher = render_frame( + copy, QtUtils::value_to_ptr(t->property("viewer")), + t->property("time").value(), nullptr, t->property("dry").toBool()); if (watcher) { video_immediate_passthroughs_[watcher].append(t); @@ -587,19 +587,19 @@ void PreviewAutoCacher::TryRender() while (!pending_video_jobs_.empty()) { VideoJob &d = pending_video_jobs_.front(); - if (Node *copy = copier_->GetCopy(d.node)) { + if (Node *copy = copier_->get_copy(d.node)) { // Queue next frames - rational t; + Rational t; while (running_video_tasks_.size() < max_tasks && - d.iterator.GetNext(&t)) { - RenderFrame(copy, d.context, t, d.cache, false); + d.iterator.get_next(&t)) { + render_frame(copy, d.context, t, d.cache, false); - emit SignalCacheProxyTaskProgress( + emit signal_cache_proxy_task_progress( double(d.iterator.frame_index()) / double(d.iterator.size())); - if (!d.iterator.HasNext()) { - emit StopCacheProxyTasks(); + if (!d.iterator.has_next()) { + emit stop_cache_proxy_tasks(); } } } else { @@ -611,7 +611,7 @@ void PreviewAutoCacher::TryRender() break; } - if (d.iterator.HasNext()) { + if (d.iterator.has_next()) { break; } else { pending_video_jobs_.pop_front(); @@ -627,14 +627,14 @@ void PreviewAutoCacher::TryRender() bool pop = true; // Start job - if (Node *copy = copier_->GetCopy(d.node)) { + if (Node *copy = copier_->get_copy(d.node)) { TimeRange &queued_range = d.range; TimeRange use_range = queued_range; if (dynamic_cast(d.cache)) { - rational new_out = std::min( + Rational new_out = std::min( use_range.in() + - AudioVisualWaveform::kMinimumSampleRate.flipped(), + AudioVisualWaveform::k_minimum_sample_rate.flipped(), use_range.out()); if (new_out != use_range.out()) { @@ -644,7 +644,7 @@ void PreviewAutoCacher::TryRender() } } - RenderAudio(copy, d.context, use_range, d.cache); + render_audio(copy, d.context, use_range, d.cache); } else { qWarning() << "Failed to find node copy for audio job, retrying"; @@ -662,65 +662,65 @@ void PreviewAutoCacher::TryRender() } } -RenderTicketWatcher *PreviewAutoCacher::RenderFrame(Node *node, +RenderTicketWatcher *PreviewAutoCacher::render_frame(Node *node, ViewerOutput *context, - const rational &time, + const Rational &time, PlaybackCache *cache, bool dry) { RenderTicketWatcher *watcher = new RenderTicketWatcher(); watcher->setProperty("job", - QVariant::fromValue(copier_->GetLastUpdateTime())); - watcher->setProperty("cache", QtUtils::PtrToValue(cache)); + QVariant::fromValue(copier_->get_last_update_time())); + watcher->setProperty("cache", QtUtils::ptr_to_value(cache)); watcher->setProperty("time", QVariant::fromValue(time)); - connect(watcher, &RenderTicketWatcher::Finished, this, - &PreviewAutoCacher::VideoRendered); + connect(watcher, &RenderTicketWatcher::finished, this, + &PreviewAutoCacher::video_rendered); running_video_tasks_.append(watcher); - RenderManager::RenderVideoParams rvp(node, context->GetVideoParams(), - context->GetAudioParams(), time, + RenderManager::RenderVideoParams rvp(node, context->get_video_params(), + context->get_audio_params(), time, copied_color_manager_, - RenderMode::kOffline); + RenderMode::k_offline); if (FrameHashCache *frame_cache = dynamic_cast(cache)) { if (ThumbnailCache *wave_cache = dynamic_cast(cache)) { Q_UNUSED(wave_cache) rvp.video_params.set_divider( - VideoParams::GetDividerForTargetResolution( + VideoParams::get_divider_for_target_resolution( rvp.video_params.width(), rvp.video_params.height(), 160, 120)); - rvp.force_format = PixelFormat::F32; - rvp.force_channel_count = VideoParams::kRGBAChannelCount; + rvp.force_format = PixelFormat::f32; + rvp.force_channel_count = VideoParams::k_rgba_channel_count; } else { - frame_cache->SetTimebase( - context->GetVideoParams().frame_rate_as_time_base()); + frame_cache->set_timebase( + context->get_video_params().frame_rate_as_time_base()); } - rvp.AddCache(frame_cache); + rvp.add_cache(frame_cache); } else { // Preview/display frames are rendered at reduced precision to cut the // GPU->CPU readback and IPC transfer bandwidth. The internal render // pipeline stays F32/ACEScg; the final preview copy is packed 10-bit // RGBA (4 bytes/pixel) to preserve 10-bit panel precision while halving // bandwidth compared to F16. - rvp.force_format = PixelFormat::U10; - rvp.force_channel_count = VideoParams::kRGBAChannelCount; + rvp.force_format = PixelFormat::u10; + rvp.force_channel_count = VideoParams::k_rgba_channel_count; } // Video playback frames are rendered out-of-process. GPU textures cannot be // shared across worker processes (or across independent Vulkan instances), // so we always request CPU frames. - rvp.return_type = dry ? RenderManager::kNull : RenderManager::kFrame; + rvp.return_type = dry ? RenderManager::k_null : RenderManager::k_frame; // Allow using cached images for this render job rvp.use_cache = true; // Multicam - rvp.multicam = copier_->GetCopy(multicam_); + rvp.multicam = copier_->get_copy(multicam_); - watcher->SetTicket(RenderManager::instance()->RenderFrame(rvp)); + watcher->set_ticket(RenderManager::instance()->render_frame(rvp)); // If the ticket finished synchronously, VideoRendered has already deleted the // watcher. The caller must not use this pointer in that case. @@ -731,47 +731,47 @@ RenderTicketWatcher *PreviewAutoCacher::RenderFrame(Node *node, return watcher; } -RenderTicketPtr PreviewAutoCacher::RenderAudio(Node *node, +RenderTicketPtr PreviewAutoCacher::render_audio(Node *node, ViewerOutput *context, const TimeRange &r, PlaybackCache *cache) { RenderTicketWatcher *watcher = new RenderTicketWatcher(); watcher->setProperty("job", - QVariant::fromValue(copier_->GetLastUpdateTime())); - watcher->setProperty("node", QtUtils::PtrToValue(node)); - watcher->setProperty("cache", QtUtils::PtrToValue(cache)); + QVariant::fromValue(copier_->get_last_update_time())); + watcher->setProperty("node", QtUtils::ptr_to_value(node)); + watcher->setProperty("cache", QtUtils::ptr_to_value(cache)); watcher->setProperty("time", QVariant::fromValue(r)); - connect(watcher, &RenderTicketWatcher::Finished, this, - &PreviewAutoCacher::AudioRendered); + connect(watcher, &RenderTicketWatcher::finished, this, + &PreviewAutoCacher::audio_rendered); running_audio_tasks_.append(watcher); - AudioParams p = context->GetAudioParams(); + AudioParams p = context->get_audio_params(); const bool invalid_params = (p.sample_rate() <= 0 || p.channel_count() <= 0); if (invalid_params) { AudioParams fallback( - OLIVE_CONFIG("DefaultSequenceAudioFrequency").toInt(), - OLIVE_CONFIG("DefaultSequenceAudioLayout").toULongLong(), - ViewerOutput::kDefaultSampleFormat); + OAK_CONFIG("DefaultSequenceAudioFrequency").toInt(), + OAK_CONFIG("DefaultSequenceAudioLayout").toULongLong(), + ViewerOutput::k_default_sample_format); p = fallback; } - p.set_format(ViewerOutput::kDefaultSampleFormat); + p.set_format(ViewerOutput::k_default_sample_format); - RenderManager::RenderAudioParams rap(node, r, p, RenderMode::kOffline); + RenderManager::RenderAudioParams rap(node, r, p, RenderMode::k_offline); rap.generate_waveforms = dynamic_cast(cache); rap.clamp = false; - RenderTicketPtr ticket = RenderManager::instance()->RenderAudio(rap); - watcher->SetTicket(ticket); + RenderTicketPtr ticket = RenderManager::instance()->render_audio(rap); + watcher->set_ticket(ticket); return ticket; } -void PreviewAutoCacher::ConformFinished() +void PreviewAutoCacher::conform_finished() { // Got an audio conform, requeue all the audio currently needing a conform - last_conform_task_.Acquire(); + last_conform_task_.acquire(); for (auto it = audio_cache_data_.begin(); it != audio_cache_data_.end(); it++) { @@ -780,30 +780,30 @@ void PreviewAutoCacher::ConformFinished() } for (const TimeRange &range : it.value().needs_conform) { - it.key()->Request(it.value().context, range); + it.key()->request(it.value().context, range); } it.value().needs_conform.clear(); } } -void PreviewAutoCacher::CacheProxyTaskCancelled() +void PreviewAutoCacher::cache_proxy_task_cancelled() { pending_video_jobs_.clear(); - TryRender(); + try_render(); } -void PreviewAutoCacher::ForceCacheRange(ViewerOutput *context, +void PreviewAutoCacher::force_cache_range(ViewerOutput *context, const TimeRange &range) { use_custom_range_ = true; custom_autocache_range_ = range; // Re-hash these frames and start rendering - StartCachingVideoRange(context, context->video_frame_cache(), range); + start_caching_video_range(context, context->video_frame_cache(), range); } -void PreviewAutoCacher::SetProject(Project *project) +void PreviewAutoCacher::set_project(Project *project) { if (project_ == project) { return; @@ -819,31 +819,31 @@ void PreviewAutoCacher::SetProject(Project *project) // Handle video rendering tasks if (!running_video_tasks_.isEmpty()) { // Cancel any video tasks and wait for them to finish - CancelVideoTasks(true); + cancel_video_tasks(true); running_video_tasks_.clear(); } // Handle audio rendering tasks if (!running_audio_tasks_.isEmpty()) { // Cancel any audio tasks and wait for them to finish - CancelAudioTasks(true); + cancel_audio_tasks(true); running_audio_tasks_.clear(); } // Clear any single frame render that might be queued - CancelQueuedSingleFrameRender(); + cancel_queued_single_frame_render(); // Not interested in video passthroughs anymore video_immediate_passthroughs_.clear(); // Disconnect from all node cache's - for (auto it = copier_->GetNodeMap().cbegin(); - it != copier_->GetNodeMap().cend(); it++) { - DisconnectFromNodeCache(it.key()); + for (auto it = copier_->get_node_map().cbegin(); + it != copier_->get_node_map().cend(); it++) { + disconnect_from_node_cache(it.key()); } // Delete all of our copied nodes - copier_->SetProject(nullptr); + copier_->set_project(nullptr); // Ensure all cache data is cleared video_cache_data_.clear(); @@ -857,18 +857,18 @@ void PreviewAutoCacher::SetProject(Project *project) if (project_) { // Copy graph (this should always be a Project) - SetRendersPaused(true); + set_renders_paused(true); - copier_->SetProject(project_); + copier_->set_project(project_); for (int i = 0; i < project_->nodes().size(); i++) { project_->nodes().at(i)->ConnectedToPreviewEvent(); } // Find copied viewer node - copied_color_manager_ = copier_->GetCopiedProject()->color_manager(); + copied_color_manager_ = copier_->get_copied_project()->color_manager(); - SetRendersPaused(false); + set_renders_paused(false); } } diff --git a/app/render/previewautocacher.h b/app/render/previewautocacher.h index b3ebad1be..0954771c2 100644 --- a/app/render/previewautocacher.h +++ b/app/render/previewautocacher.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUTOCACHER_H -#define AUTOCACHER_H +#ifndef OAK_AUTOCACHER_H +#define OAK_AUTOCACHER_H #include @@ -49,20 +49,20 @@ public: virtual ~PreviewAutoCacher() override; - RenderTicketPtr GetSingleFrame(ViewerOutput *viewer, const rational &t, + RenderTicketPtr get_single_frame(ViewerOutput *viewer, const Rational &t, bool dry = false); - RenderTicketPtr GetSingleFrame(Node *n, ViewerOutput *viewer, - const rational &t, bool dry = false); + RenderTicketPtr get_single_frame(Node *n, ViewerOutput *viewer, + const Rational &t, bool dry = false); - RenderTicketPtr GetRangeOfAudio(ViewerOutput *viewer, TimeRange range); + RenderTicketPtr get_range_of_audio(ViewerOutput *viewer, TimeRange range); - void ClearSingleFrameRenders(); - void ClearSingleFrameRendersThatArentRunning(); + void clear_single_frame_renders(); + void clear_single_frame_renders_that_arent_running(); /** * @brief Set the viewer node to auto-cache */ - void SetProject(Project *project); + void set_project(Project *project); /** * @brief Force a certain range to be cached @@ -71,12 +71,12 @@ public: * times they may want certain non-playhead-related time ranges to be cached (i.e. entire sequence * or in/out range), so that can be set here. */ - void ForceCacheRange(ViewerOutput *context, const TimeRange &range); + void force_cache_range(ViewerOutput *context, const TimeRange &range); /** * @brief Updates the range of frames to auto-cache */ - void SetPlayhead(const rational &playhead); + void set_playhead(const Rational &playhead); /** * @brief Call cancel on all currently running video tasks @@ -86,60 +86,60 @@ public: * up finishing the task. The RenderManager will also return "no result", which can be checked * with watcher->HasResult. */ - void CancelVideoTasks(bool and_wait_for_them_to_finish = false); - void CancelAudioTasks(bool and_wait_for_them_to_finish = false); + void cancel_video_tasks(bool and_wait_for_them_to_finish = false); + void cancel_audio_tasks(bool and_wait_for_them_to_finish = false); - bool IsRenderingCustomRange() const; + bool is_rendering_custom_range() const; - void SetRendersPaused(bool e); - void SetThumbnailsPaused(bool e); + void set_renders_paused(bool e); + void set_thumbnails_paused(bool e); - void SetMulticamNode(MultiCamNode *n) + void set_multicam_node(MultiCamNode *n) { multicam_ = n; } - void SetIgnoreCacheRequests(bool e) + void set_ignore_cache_requests(bool e) { ignore_cache_requests_ = e; } public slots: - void SetDisplayColorProcessor(ColorProcessorPtr processor) + void set_display_color_processor(ColorProcessorPtr processor) { display_color_processor_ = processor; } signals: - void StopCacheProxyTasks(); + void stop_cache_proxy_tasks(); - void SignalCacheProxyTaskProgress(double d); + void signal_cache_proxy_task_progress(double d); private: - void TryRender(); + void try_render(); - RenderTicketWatcher *RenderFrame(Node *node, ViewerOutput *context, - const rational &time, PlaybackCache *cache, + RenderTicketWatcher *render_frame(Node *node, ViewerOutput *context, + const Rational &time, PlaybackCache *cache, bool dry); - RenderTicketPtr RenderAudio(Node *node, ViewerOutput *context, + RenderTicketPtr render_audio(Node *node, ViewerOutput *context, const TimeRange &range, PlaybackCache *cache); - void ConnectToNodeCache(Node *node); - void DisconnectFromNodeCache(Node *node); + void connect_to_node_cache(Node *node); + void disconnect_from_node_cache(Node *node); - void CancelQueuedSingleFrameRender(); + void cancel_queued_single_frame_render(); - void StartCachingRange(const TimeRange &range, TimeRangeList *range_list, + void start_caching_range(const TimeRange &range, TimeRangeList *range_list, RenderJobTracker *tracker); - void StartCachingVideoRange(ViewerOutput *context, PlaybackCache *cache, + void start_caching_video_range(ViewerOutput *context, PlaybackCache *cache, const TimeRange &range); - void StartCachingAudioRange(ViewerOutput *context, PlaybackCache *cache, + void start_caching_audio_range(ViewerOutput *context, PlaybackCache *cache, const TimeRange &range); - void VideoInvalidatedFromNode(ViewerOutput *context, PlaybackCache *cache, + void video_invalidated_from_node(ViewerOutput *context, PlaybackCache *cache, const olive::TimeRange &range); - void AudioInvalidatedFromNode(ViewerOutput *context, PlaybackCache *cache, + void audio_invalidated_from_node(ViewerOutput *context, PlaybackCache *cache, const olive::TimeRange &range); Project *project_; @@ -208,37 +208,37 @@ private slots: /** * @brief Handler for when the NodeGraph reports a video change over a certain time range */ - void VideoInvalidatedFromCache(ViewerOutput *context, + void video_invalidated_from_cache(ViewerOutput *context, const olive::TimeRange &range); /** * @brief Handler for when the NodeGraph reports a audio change over a certain time range */ - void AudioInvalidatedFromCache(ViewerOutput *context, + void audio_invalidated_from_cache(ViewerOutput *context, const olive::TimeRange &range); - void CancelForCache(); + void cancel_for_cache(); /** * @brief Handler for when the RenderManager has returned rendered audio */ - void AudioRendered(); + void audio_rendered(); /** * @brief Handler for when the RenderManager has returned rendered video frames */ - void VideoRendered(); + void video_rendered(); /** * @brief Generic function called whenever the frames to render need to be (re)queued */ //void RequeueFrames(); - void ConformFinished(); + void conform_finished(); - void CacheProxyTaskCancelled(); + void cache_proxy_task_cancelled(); }; } -#endif // AUTOCACHER_H +#endif // OAK_AUTOCACHER_H diff --git a/app/render/projectcopier.cpp b/app/render/projectcopier.cpp index 1219596ae..80ae2b7b5 100644 --- a/app/render/projectcopier.cpp +++ b/app/render/projectcopier.cpp @@ -35,7 +35,7 @@ ProjectCopier::ProjectCopier(QObject *parent) copy_->setParent(this); } -void ProjectCopier::SetProject(Project *project) +void ProjectCopier::set_project(Project *project) { if (original_) { // Clear current project @@ -44,20 +44,20 @@ void ProjectCopier::SetProject(Project *project) copy_map_.clear(); graph_update_queue_.clear(); - disconnect(original_, &Project::NodeAdded, this, - &ProjectCopier::QueueNodeAdd); - disconnect(original_, &Project::NodeRemoved, this, - &ProjectCopier::QueueNodeRemove); - disconnect(original_, &Project::InputConnected, this, - &ProjectCopier::QueueEdgeAdd); - disconnect(original_, &Project::InputDisconnected, this, - &ProjectCopier::QueueEdgeRemove); - disconnect(original_, &Project::ValueChanged, this, - &ProjectCopier::QueueValueChange); - disconnect(original_, &Project::InputValueHintChanged, this, - &ProjectCopier::QueueValueHintChange); - disconnect(original_, &Project::SettingChanged, this, - &ProjectCopier::QueueProjectSettingChange); + disconnect(original_, &Project::node_added, this, + &ProjectCopier::queue_node_add); + disconnect(original_, &Project::node_removed, this, + &ProjectCopier::queue_node_remove); + disconnect(original_, &Project::input_connected, this, + &ProjectCopier::queue_edge_add); + disconnect(original_, &Project::input_disconnected, this, + &ProjectCopier::queue_edge_remove); + disconnect(original_, &Project::value_changed, this, + &ProjectCopier::queue_value_change); + disconnect(original_, &Project::input_value_hint_changed, this, + &ProjectCopier::queue_value_hint_change); + disconnect(original_, &Project::setting_changed, this, + &ProjectCopier::queue_project_setting_change); } original_ = project; @@ -70,49 +70,49 @@ void ProjectCopier::SetProject(Project *project) // Add all nodes for (int i = 0; i < copy_->nodes().size(); i++) { - InsertIntoCopyMap(original_->nodes().at(i), copy_->nodes().at(i)); + insert_into_copy_map(original_->nodes().at(i), copy_->nodes().at(i)); } for (int i = copy_->nodes().size(); i < original_->nodes().size(); i++) { - DoNodeAdd(original_->nodes().at(i)); + do_node_add(original_->nodes().at(i)); } // Add all connections foreach (Node *node, original_->nodes()) { for (auto it = node->input_connections().cbegin(); it != node->input_connections().cend(); it++) { - DoEdgeAdd(it->second, it->first); + do_edge_add(it->second, it->first); } } // Copy project settings - Project::CopySettings(original_, copy_); + Project::copy_settings(original_, copy_); // Ensure graph change value is just before the sync value - UpdateGraphChangeValue(); - UpdateLastSyncedValue(); + update_graph_change_value(); + update_last_synced_value(); // Connect signals for future node additions/deletions - connect(original_, &Project::NodeAdded, this, - &ProjectCopier::QueueNodeAdd, Qt::DirectConnection); - connect(original_, &Project::NodeRemoved, this, - &ProjectCopier::QueueNodeRemove, Qt::DirectConnection); - connect(original_, &Project::InputConnected, this, - &ProjectCopier::QueueEdgeAdd, Qt::DirectConnection); - connect(original_, &Project::InputDisconnected, this, - &ProjectCopier::QueueEdgeRemove, Qt::DirectConnection); - connect(original_, &Project::ValueChanged, this, - &ProjectCopier::QueueValueChange, Qt::DirectConnection); - connect(original_, &Project::InputValueHintChanged, this, - &ProjectCopier::QueueValueHintChange, Qt::DirectConnection); - connect(original_, &Project::SettingChanged, this, - &ProjectCopier::QueueProjectSettingChange, + connect(original_, &Project::node_added, this, + &ProjectCopier::queue_node_add, Qt::DirectConnection); + connect(original_, &Project::node_removed, this, + &ProjectCopier::queue_node_remove, Qt::DirectConnection); + connect(original_, &Project::input_connected, this, + &ProjectCopier::queue_edge_add, Qt::DirectConnection); + connect(original_, &Project::input_disconnected, this, + &ProjectCopier::queue_edge_remove, Qt::DirectConnection); + connect(original_, &Project::value_changed, this, + &ProjectCopier::queue_value_change, Qt::DirectConnection); + connect(original_, &Project::input_value_hint_changed, this, + &ProjectCopier::queue_value_hint_change, Qt::DirectConnection); + connect(original_, &Project::setting_changed, this, + &ProjectCopier::queue_project_setting_change, Qt::DirectConnection); } } -void ProjectCopier::ProcessUpdateQueue() +void ProjectCopier::process_update_queue() { bool copy_changed = false; @@ -123,26 +123,26 @@ void ProjectCopier::ProcessUpdateQueue() copy_changed = true; switch (job.type) { - case QueuedJob::kNodeAdded: - DoNodeAdd(job.node); + case QueuedJob::k_node_added: + do_node_add(job.node); break; - case QueuedJob::kNodeRemoved: - DoNodeRemove(job.node); + case QueuedJob::k_node_removed: + do_node_remove(job.node); break; - case QueuedJob::kEdgeAdded: - DoEdgeAdd(job.output, job.input); + case QueuedJob::k_edge_added: + do_edge_add(job.output, job.input); break; - case QueuedJob::kEdgeRemoved: - DoEdgeRemove(job.output, job.input); + case QueuedJob::k_edge_removed: + do_edge_remove(job.output, job.input); break; - case QueuedJob::kValueChanged: - DoValueChange(job.input); + case QueuedJob::k_value_changed: + do_value_change(job.input); break; - case QueuedJob::kValueHintChanged: - DoValueHintChange(job.input); + case QueuedJob::k_value_hint_changed: + do_value_hint_change(job.input); break; - case QueuedJob::kProjectSettingChanged: - DoProjectSettingChange(job.key, job.value); + case QueuedJob::k_project_setting_changed: + do_project_setting_change(job.key, job.value); break; } } @@ -156,10 +156,10 @@ void ProjectCopier::ProcessUpdateQueue() // Indicate that we have synchronized to this point, which is compared with the graph change // time to see if our copied graph is up to date - UpdateLastSyncedValue(); + update_last_synced_value(); } -void ProjectCopier::DoNodeAdd(Node *node) +void ProjectCopier::do_node_add(Node *node) { if (dynamic_cast(node)) { // Group nodes are just dummy nodes, no need to copy them @@ -173,25 +173,25 @@ void ProjectCopier::DoNodeAdd(Node *node) copy->setParent(copy_); // Disable caches for copy - copy->SetCachesEnabled(false); + copy->set_caches_enabled(false); // Copy cache UUIDs - copy->CopyCacheUuidsFrom(node); + copy->copy_cache_uuids_from(node); // Insert into map - InsertIntoCopyMap(node, copy); + insert_into_copy_map(node, copy); // Keep track of our nodes created_nodes_.append(copy); } -void ProjectCopier::DoNodeRemove(Node *node) +void ProjectCopier::do_node_remove(Node *node) { // Find our copy and remove it Node *copy = copy_map_.take(node); // Disconnect from node's caches - emit RemovedNode(node); + emit removed_node(node); // Remove from created list created_nodes_.removeOne(copy); @@ -200,27 +200,27 @@ void ProjectCopier::DoNodeRemove(Node *node) delete copy; } -void ProjectCopier::DoEdgeAdd(Node *output, const NodeInput &input) +void ProjectCopier::do_edge_add(Node *output, const NodeInput &input) { // Create same connection with our copied graph Node *our_output = copy_map_.value(output); Node *our_input = copy_map_.value(input.node()); - Node::ConnectEdge(our_output, + Node::connect_edge(our_output, NodeInput(our_input, input.input(), input.element())); } -void ProjectCopier::DoEdgeRemove(Node *output, const NodeInput &input) +void ProjectCopier::do_edge_remove(Node *output, const NodeInput &input) { // Remove same connection with our copied graph Node *our_output = copy_map_.value(output); Node *our_input = copy_map_.value(input.node()); - Node::DisconnectEdge(our_output, + Node::disconnect_edge(our_output, NodeInput(our_input, input.input(), input.element())); } -void ProjectCopier::DoValueChange(const NodeInput &input) +void ProjectCopier::do_value_change(const NodeInput &input) { if (dynamic_cast(input.node())) { // Group nodes are just dummy nodes, no need to copy them @@ -229,11 +229,11 @@ void ProjectCopier::DoValueChange(const NodeInput &input) // Copy all values to our graph Node *our_input = copy_map_.value(input.node()); - Node::CopyValuesOfElement(input.node(), our_input, input.input(), + Node::copy_values_of_element(input.node(), our_input, input.input(), input.element()); } -void ProjectCopier::DoValueHintChange(const NodeInput &input) +void ProjectCopier::do_value_hint_change(const NodeInput &input) { if (dynamic_cast(input.node())) { // Group nodes are just dummy nodes, no need to copy them @@ -243,42 +243,42 @@ void ProjectCopier::DoValueHintChange(const NodeInput &input) // Copy value hint to our graph Node *our_input = copy_map_.value(input.node()); Node::ValueHint hint = - input.node()->GetValueHintForInput(input.input(), input.element()); - our_input->SetValueHintForInput(input.input(), hint, input.element()); + input.node()->get_value_hint_for_input(input.input(), input.element()); + our_input->set_value_hint_for_input(input.input(), hint, input.element()); } -void ProjectCopier::DoProjectSettingChange(const QString &key, +void ProjectCopier::do_project_setting_change(const QString &key, const QString &value) { - copy_->SetSetting(key, value); + copy_->set_setting(key, value); } -void ProjectCopier::InsertIntoCopyMap(Node *node, Node *copy) +void ProjectCopier::insert_into_copy_map(Node *node, Node *copy) { // Insert into map copy_map_.insert(node, copy); // Copy parameters - Node::CopyInputs(node, copy, false); + Node::copy_inputs(node, copy, false); // Sync Footage proxy state (which is not stored as a Node input) if (Footage *src_footage = dynamic_cast(node)) { if (dynamic_cast(copy)) { - connect(src_footage, &Footage::ProxySettingsChanged, this, + connect(src_footage, &Footage::proxy_settings_changed, this, [this, src_footage]() { - SyncFootageProxySettings(src_footage); + sync_footage_proxy_settings(src_footage); }); - SyncFootageProxySettings(src_footage); + sync_footage_proxy_settings(src_footage); } } // Connect to node's cache - emit AddedNode(node); + emit added_node(node); } -void ProjectCopier::SyncFootageProxySettings(Footage *source) +void ProjectCopier::sync_footage_proxy_settings(Footage *source) { - Footage *copy = GetCopy(source); + Footage *copy = get_copy(source); if (!copy) { qWarning() << "ProjectCopier::SyncFootageProxySettings: no copy for" << source->filename(); @@ -289,9 +289,9 @@ void ProjectCopier::SyncFootageProxySettings(Footage *source) << "ProjectCopier::SyncFootageProxySettings:" << source->filename() << "enabled=" << source->proxy_enabled() << "->" << copy->proxy_enabled() - << "state=" << ProxyManager::ProxyStateToString(source->proxy_state()); + << "state=" << ProxyManager::proxy_state_to_string(source->proxy_state()); - copy->SetProxy(source->proxy_path(), source->proxy_state(), + copy->set_proxy(source->proxy_path(), source->proxy_state(), source->proxy_video_stream_index(), source->proxy_preset_version(), source->proxy_enabled()); @@ -300,35 +300,35 @@ void ProjectCopier::SyncFootageProxySettings(Footage *source) } } -void ProjectCopier::QueueNodeAdd(Node *node) +void ProjectCopier::queue_node_add(Node *node) { - graph_update_queue_.push_back({ QueuedJob::kNodeAdded, node, NodeInput(), + graph_update_queue_.push_back({ QueuedJob::k_node_added, node, NodeInput(), nullptr, QString(), QString() }); - UpdateGraphChangeValue(); + update_graph_change_value(); } -void ProjectCopier::QueueNodeRemove(Node *node) +void ProjectCopier::queue_node_remove(Node *node) { - graph_update_queue_.push_back({ QueuedJob::kNodeRemoved, node, NodeInput(), + graph_update_queue_.push_back({ QueuedJob::k_node_removed, node, NodeInput(), nullptr, QString(), QString() }); - UpdateGraphChangeValue(); + update_graph_change_value(); } -void ProjectCopier::QueueEdgeAdd(Node *output, const NodeInput &input) +void ProjectCopier::queue_edge_add(Node *output, const NodeInput &input) { - graph_update_queue_.push_back({ QueuedJob::kEdgeAdded, nullptr, input, + graph_update_queue_.push_back({ QueuedJob::k_edge_added, nullptr, input, output, QString(), QString() }); - UpdateGraphChangeValue(); + update_graph_change_value(); } -void ProjectCopier::QueueEdgeRemove(Node *output, const NodeInput &input) +void ProjectCopier::queue_edge_remove(Node *output, const NodeInput &input) { - graph_update_queue_.push_back({ QueuedJob::kEdgeRemoved, nullptr, input, + graph_update_queue_.push_back({ QueuedJob::k_edge_removed, nullptr, input, output, QString(), QString() }); - UpdateGraphChangeValue(); + update_graph_change_value(); } -void ProjectCopier::QueueValueChange(const NodeInput &input) +void ProjectCopier::queue_value_change(const NodeInput &input) { /*for (auto it = graph_update_queue_.begin(); it != graph_update_queue_.end(); ) { if (it->type == QueuedJob::kValueChanged && it->input == input) { @@ -338,34 +338,34 @@ void ProjectCopier::QueueValueChange(const NodeInput &input) } }*/ - graph_update_queue_.push_back({ QueuedJob::kValueChanged, nullptr, input, + graph_update_queue_.push_back({ QueuedJob::k_value_changed, nullptr, input, nullptr, QString(), QString() }); - UpdateGraphChangeValue(); + update_graph_change_value(); } -void ProjectCopier::QueueValueHintChange(const NodeInput &input) +void ProjectCopier::queue_value_hint_change(const NodeInput &input) { - graph_update_queue_.push_back({ QueuedJob::kValueHintChanged, nullptr, + graph_update_queue_.push_back({ QueuedJob::k_value_hint_changed, nullptr, input, nullptr, QString(), QString() }); - UpdateGraphChangeValue(); + update_graph_change_value(); } -void ProjectCopier::QueueProjectSettingChange(const QString &key, +void ProjectCopier::queue_project_setting_change(const QString &key, const QString &value) { - graph_update_queue_.push_back({ QueuedJob::kProjectSettingChanged, nullptr, + graph_update_queue_.push_back({ QueuedJob::k_project_setting_changed, nullptr, NodeInput(), nullptr, key, value }); - UpdateGraphChangeValue(); + update_graph_change_value(); } -void ProjectCopier::UpdateGraphChangeValue() +void ProjectCopier::update_graph_change_value() { - graph_changed_time_.Acquire(); + graph_changed_time_.acquire(); } -void ProjectCopier::UpdateLastSyncedValue() +void ProjectCopier::update_last_synced_value() { - last_update_time_.Acquire(); + last_update_time_.acquire(); } } diff --git a/app/render/projectcopier.h b/app/render/projectcopier.h index 19801ac03..45072383e 100644 --- a/app/render/projectcopier.h +++ b/app/render/projectcopier.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTCOPIER_H -#define PROJECTCOPIER_H +#ifndef OAK_PROJECTCOPIER_H +#define OAK_PROJECTCOPIER_H #include "node/project.h" #include "node/project/footage/footage.h" @@ -33,38 +33,38 @@ class ProjectCopier : public QObject { public: ProjectCopier(QObject *parent = nullptr); - void SetProject(Project *project); + void set_project(Project *project); - template T *GetCopy(T *original) + template T *get_copy(T *original) { return static_cast(copy_map_.value(original)); } - template T *GetOriginal(T *copy) + template T *get_original(T *copy) { return static_cast(copy_map_.key(copy)); } - Project *GetCopiedProject() const + Project *get_copied_project() const { return copy_; } - const QHash &GetNodeMap() const + const QHash &get_node_map() const { return copy_map_; } - const JobTime &GetGraphChangeTime() const + const JobTime &get_graph_change_time() const { return graph_changed_time_; } - const JobTime &GetLastUpdateTime() const + const JobTime &get_last_update_time() const { return last_update_time_; } - bool HasUpdatesInQueue() const + bool has_updates_in_queue() const { return !graph_update_queue_.empty(); } @@ -75,27 +75,27 @@ public: * PreviewAutoCacher staggers updates to its internal NodeGraph copy, only applying them when the * RenderManager is not reading from it. This function is called when such an opportunity arises. */ - void ProcessUpdateQueue(); + void process_update_queue(); signals: - void AddedNode(Node *n); - void RemovedNode(Node *n); + void added_node(Node *n); + void removed_node(Node *n); private: - void DoNodeAdd(Node *node); - void DoNodeRemove(Node *node); - void DoEdgeAdd(Node *output, const NodeInput &input); - void DoEdgeRemove(Node *output, const NodeInput &input); - void DoValueChange(const NodeInput &input); - void DoValueHintChange(const NodeInput &input); - void DoProjectSettingChange(const QString &key, const QString &value); + void do_node_add(Node *node); + void do_node_remove(Node *node); + void do_edge_add(Node *output, const NodeInput &input); + void do_edge_remove(Node *output, const NodeInput &input); + void do_value_change(const NodeInput &input); + void do_value_hint_change(const NodeInput &input); + void do_project_setting_change(const QString &key, const QString &value); - void SyncFootageProxySettings(Footage *source); + void sync_footage_proxy_settings(Footage *source); - void InsertIntoCopyMap(Node *node, Node *copy); + void insert_into_copy_map(Node *node, Node *copy); - void UpdateGraphChangeValue(); - void UpdateLastSyncedValue(); + void update_graph_change_value(); + void update_last_synced_value(); Project *original_; Project *copy_; @@ -103,13 +103,13 @@ private: class QueuedJob { public: enum Type { - kNodeAdded, - kNodeRemoved, - kEdgeAdded, - kEdgeRemoved, - kValueChanged, - kValueHintChanged, - kProjectSettingChanged + k_node_added, + k_node_removed, + k_edge_added, + k_edge_removed, + k_value_changed, + k_value_hint_changed, + k_project_setting_changed }; Type type; @@ -130,21 +130,21 @@ private: JobTime last_update_time_; private slots: - void QueueNodeAdd(Node *node); + void queue_node_add(Node *node); - void QueueNodeRemove(Node *node); + void queue_node_remove(Node *node); - void QueueEdgeAdd(Node *output, const NodeInput &input); + void queue_edge_add(Node *output, const NodeInput &input); - void QueueEdgeRemove(Node *output, const NodeInput &input); + void queue_edge_remove(Node *output, const NodeInput &input); - void QueueValueChange(const NodeInput &input); + void queue_value_change(const NodeInput &input); - void QueueValueHintChange(const NodeInput &input); + void queue_value_hint_change(const NodeInput &input); - void QueueProjectSettingChange(const QString &key, const QString &value); + void queue_project_setting_change(const QString &key, const QString &value); }; } -#endif // PROJECTCOPIER_H +#endif // OAK_PROJECTCOPIER_H diff --git a/app/render/rendercache.h b/app/render/rendercache.h index 8dec354ec..55a73b430 100644 --- a/app/render/rendercache.h +++ b/app/render/rendercache.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERCACHE_H -#define RENDERCACHE_H +#ifndef OAK_RENDERCACHE_H +#define OAK_RENDERCACHE_H #include "codec/decoder.h" @@ -48,4 +48,4 @@ using ShaderCache = RenderCache; } -#endif // RENDERCACHE_H +#endif // OAK_RENDERCACHE_H diff --git a/app/render/renderer.cpp b/app/render/renderer.cpp index b471143eb..de8744750 100644 --- a/app/render/renderer.cpp +++ b/app/render/renderer.cpp @@ -43,12 +43,12 @@ Renderer::~Renderer() } } -TexturePtr Renderer::CreateTexture(const VideoParams ¶ms, const void *data, +TexturePtr Renderer::create_texture(const VideoParams ¶ms, const void *data, int linesize) { QVariant v; - if (USE_TEXTURE_CACHE) { + if (use_texture_cache) { QMutexLocker locker(&texture_cache_lock_); for (auto it = texture_cache_.begin(); it != texture_cache_.end(); it++) { @@ -65,25 +65,25 @@ TexturePtr Renderer::CreateTexture(const VideoParams ¶ms, const void *data, } if (v.isNull()) { - v = CreateNativeTexture(params.effective_width(), + v = create_native_texture(params.effective_width(), params.effective_height(), params.effective_depth(), params.format(), params.channel_count(), data, linesize); } else if (data) { - UploadToTexture(v, params, data, linesize); + upload_to_texture(v, params, data, linesize); } else { - this->Flush(); + this->flush(); } - return CreateTextureFromNativeHandle(v, params); + return create_texture_from_native_handle(v, params); } -void Renderer::DestroyTexture(Texture *texture) +void Renderer::destroy_texture(Texture *texture) { if (destroyed_) { return; } - if (USE_TEXTURE_CACHE) { + if (use_texture_cache) { // HACK: Dirty, dirty hack. OpenGL uses "contexts" to store all of its data, and each context // can only be used by the thread that created it. However there are also "shared contexts" // where assets from one context can be used in another. We use shared contexts so that @@ -109,28 +109,28 @@ void Renderer::DestroyTexture(Texture *texture) texture_cache_lock_.unlock(); if (QThread::currentThread() == this->thread()) { - ClearOldTextures(); + clear_old_textures(); } } else { - DestroyNativeTexture(texture->id()); + destroy_native_texture(texture->id()); } } -QVariant Renderer::GetDefaultShader() +QVariant Renderer::get_default_shader() { QMutexLocker locker(&color_cache_mutex_); if (default_shader_.isNull()) { - default_shader_ = CreateNativeShader(ShaderCode(QString(), QString())); + default_shader_ = create_native_shader(ShaderCode(QString(), QString())); } return default_shader_; } -void Renderer::Destroy() +void Renderer::destroy() { if (!default_shader_.isNull()) { - DestroyNativeShader(default_shader_); + destroy_native_shader(default_shader_); default_shader_.clear(); } @@ -142,19 +142,19 @@ void Renderer::Destroy() // be cleared while the renderer is still alive for those to be honored. for (auto it = color_cache_.begin(); it != color_cache_.end(); it++) { if (!it->compiled_shader.isNull()) { - DestroyNativeShader(it->compiled_shader); + destroy_native_shader(it->compiled_shader); } } color_cache_.clear(); } if (!interlace_texture_.isNull()) { - DestroyNativeShader(interlace_texture_); + destroy_native_shader(interlace_texture_); interlace_texture_.clear(); } for (auto it = texture_cache_.begin(); it != texture_cache_.end(); it++) { - DestroyNativeTexture(it->handle); + destroy_native_texture(it->handle); } texture_cache_.clear(); @@ -163,10 +163,10 @@ void Renderer::Destroy() lifetime_->alive = false; } - DestroyInternal(); + destroy_internal(); } -TexturePtr Renderer::CreateTextureFromNativeHandle(const QVariant &v, +TexturePtr Renderer::create_texture_from_native_handle(const QVariant &v, const VideoParams ¶ms) { if (v.isNull()) { @@ -176,14 +176,14 @@ TexturePtr Renderer::CreateTextureFromNativeHandle(const QVariant &v, return std::make_shared(this, v, params, lifetime_); } -void Renderer::ClearOldTextures() +void Renderer::clear_old_textures() { QMutexLocker locker(&texture_cache_lock_); for (auto it = texture_cache_.begin(); it != texture_cache_.end();) { if (it->accessed < - QDateTime::currentMSecsSinceEpoch() - MAX_TEXTURE_LIFE) { - DestroyNativeTexture(it->handle); + QDateTime::currentMSecsSinceEpoch() - max_texture_life) { + destroy_native_texture(it->handle); it = texture_cache_.erase(it); } else { it++; diff --git a/app/render/renderer.h b/app/render/renderer.h index f0e9c2cee..218176daf 100644 --- a/app/render/renderer.h +++ b/app/render/renderer.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERCONTEXT_H -#define RENDERCONTEXT_H +#ifndef OAK_RENDERCONTEXT_H +#define OAK_RENDERCONTEXT_H #include #include @@ -51,81 +51,81 @@ public: Renderer(QObject *parent = nullptr); virtual ~Renderer() override; - virtual bool Init() = 0; + virtual bool init() = 0; - TexturePtr CreateTexture(const VideoParams ¶ms, + TexturePtr create_texture(const VideoParams ¶ms, const void *data = nullptr, int linesize = 0); - void DestroyTexture(Texture *texture); + void destroy_texture(Texture *texture); - virtual void BlitToTexture(QVariant shader, olive::AcceleratedJob &job, + virtual void blit_to_texture(QVariant shader, olive::AcceleratedJob &job, olive::Texture *destination, bool clear_destination = true) { - Blit(shader, job, destination, destination->params(), + blit(shader, job, destination, destination->params(), clear_destination); } - void Blit(QVariant shader, olive::AcceleratedJob &job, + void blit(QVariant shader, olive::AcceleratedJob &job, olive::VideoParams params, bool clear_destination = true) { - Blit(shader, job, nullptr, params, clear_destination); + blit(shader, job, nullptr, params, clear_destination); } - void BlitColorManaged(const ColorTransformJob &color_job, + void blit_color_managed(const ColorTransformJob &color_job, Texture *destination, const VideoParams ¶ms); - void BlitColorManaged(const ColorTransformJob &job, Texture *destination) + void blit_color_managed(const ColorTransformJob &job, Texture *destination) { - BlitColorManaged(job, destination, destination->params()); + blit_color_managed(job, destination, destination->params()); } - void BlitColorManaged(const ColorTransformJob &job, + void blit_color_managed(const ColorTransformJob &job, const VideoParams ¶ms) { - BlitColorManaged(job, nullptr, params); + blit_color_managed(job, nullptr, params); } - TexturePtr InterlaceTexture(TexturePtr top, TexturePtr bottom, + TexturePtr interlace_texture(TexturePtr top, TexturePtr bottom, const VideoParams ¶ms); - QVariant GetDefaultShader(); + QVariant get_default_shader(); - void Destroy(); + void destroy(); - virtual void PostDestroy() = 0; + virtual void post_destroy() = 0; - virtual void PostInit() = 0; + virtual void post_init() = 0; - virtual void ClearDestination(olive::Texture *texture = nullptr, + virtual void clear_destination(olive::Texture *texture = nullptr, double r = 0.0, double g = 0.0, double b = 0.0, double a = 1.0) = 0; - virtual QVariant CreateNativeShader(olive::ShaderCode code) = 0; + virtual QVariant create_native_shader(olive::ShaderCode code) = 0; - virtual void DestroyNativeShader(QVariant shader) = 0; + virtual void destroy_native_shader(QVariant shader) = 0; - virtual void UploadToTexture(const QVariant &handle, + virtual void upload_to_texture(const QVariant &handle, const VideoParams ¶ms, const void *data, int linesize) = 0; - virtual void DownloadFromTexture(const QVariant &handle, + virtual void download_from_texture(const QVariant &handle, const VideoParams ¶ms, void *data, int linesize) = 0; - virtual void Flush() = 0; + virtual void flush() = 0; - virtual Color GetPixelFromTexture(olive::Texture *texture, + virtual Color get_pixel_from_texture(olive::Texture *texture, const QPointF &pt) = 0; - std::shared_ptr GetLifetime() const + std::shared_ptr get_lifetime() const { return lifetime_; } - virtual bool IsOpenGL() const + virtual bool is_open_gl() const { return false; } - virtual bool IsVulkan() const + virtual bool is_vulkan() const { return false; } @@ -137,7 +137,7 @@ public: * Default implementation is a no-op. OpenGL-based renderers override this * to bind the texture as a framebuffer render target. */ - virtual void AttachOutputTexture(olive::Texture *texture) + virtual void attach_output_texture(olive::Texture *texture) { (void)texture; } @@ -147,23 +147,23 @@ public: * * Default implementation is a no-op. */ - virtual void DetachOutputTexture() + virtual void detach_output_texture() { } protected: - virtual void Blit(QVariant shader, olive::AcceleratedJob &job, + virtual void blit(QVariant shader, olive::AcceleratedJob &job, olive::Texture *destination, olive::VideoParams destination_params, bool clear_destination) = 0; - virtual QVariant CreateNativeTexture(int width, int height, int depth, + virtual QVariant create_native_texture(int width, int height, int depth, PixelFormat format, int channel_count, const void *data = nullptr, int linesize = 0) = 0; - virtual void DestroyNativeTexture(QVariant texture) = 0; + virtual void destroy_native_texture(QVariant texture) = 0; - virtual void DestroyInternal() = 0; + virtual void destroy_internal() = 0; private: std::atomic destroyed_{ false }; @@ -180,12 +180,12 @@ private: QVector lut1d_textures; }; - TexturePtr CreateTextureFromNativeHandle(const QVariant &v, + TexturePtr create_texture_from_native_handle(const QVariant &v, const VideoParams ¶ms); - bool GetColorContext(const ColorTransformJob &color_job, ColorContext *ctx); + bool get_color_context(const ColorTransformJob &color_job, ColorContext *ctx); - void ClearOldTextures(); + void clear_old_textures(); QHash color_cache_; @@ -199,8 +199,8 @@ private: qint64 accessed; }; - static const int MAX_TEXTURE_LIFE = 5000; - static const bool USE_TEXTURE_CACHE = true; + static const int max_texture_life = 5000; + static const bool use_texture_cache = true; std::list texture_cache_; QMutex color_cache_mutex_; @@ -214,4 +214,4 @@ private: } -#endif // RENDERCONTEXT_H +#endif // OAK_RENDERCONTEXT_H diff --git a/app/render/renderjobtracker.cpp b/app/render/renderjobtracker.cpp index db3991d37..c5b28465d 100644 --- a/app/render/renderjobtracker.cpp +++ b/app/render/renderjobtracker.cpp @@ -46,11 +46,11 @@ void RenderJobTracker::clear() jobs_.clear(); } -bool RenderJobTracker::isCurrent(const rational &time, JobTime job_time) const +bool RenderJobTracker::isCurrent(const Rational &time, JobTime job_time) const { for (auto it = jobs_.crbegin(); it != jobs_.crend(); it++) { - if (it->Contains(time)) { - return job_time >= it->GetJobTime(); + if (it->contains(time)) { + return job_time >= it->get_job_time(); } } @@ -64,8 +64,8 @@ RenderJobTracker::getCurrentSubRanges(const TimeRange &range, TimeRangeList current_ranges; for (auto it = jobs_.crbegin(); it != jobs_.crend(); it++) { - if (job_time >= it->GetJobTime() && it->OverlapsWith(range)) { - current_ranges.insert(it->Intersected(range)); + if (job_time >= it->get_job_time() && it->overlaps_with(range)) { + current_ranges.insert(it->intersected(range)); } } diff --git a/app/render/renderjobtracker.h b/app/render/renderjobtracker.h index b909e3352..74cdf5946 100644 --- a/app/render/renderjobtracker.h +++ b/app/render/renderjobtracker.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERJOBTRACKER_H -#define RENDERJOBTRACKER_H +#ifndef OAK_RENDERJOBTRACKER_H +#define OAK_RENDERJOBTRACKER_H #include @@ -40,7 +40,7 @@ public: void clear(); - bool isCurrent(const rational &time, JobTime job_time) const; + bool isCurrent(const Rational &time, JobTime job_time) const; TimeRangeList getCurrentSubRanges(const TimeRange &range, const JobTime &job_time) const; @@ -55,11 +55,11 @@ private: job_time_ = job_time; } - JobTime GetJobTime() const + JobTime get_job_time() const { return job_time_; } - void SetJobTime(JobTime jt) + void set_job_time(JobTime jt) { job_time_ = jt; } @@ -73,4 +73,4 @@ private: } -#endif // RENDERJOBTRACKER_H +#endif // OAK_RENDERJOBTRACKER_H diff --git a/app/render/rendermanager.cpp b/app/render/rendermanager.cpp index 168bff95c..f2d8cdea6 100644 --- a/app/render/rendermanager.cpp +++ b/app/render/rendermanager.cpp @@ -41,36 +41,36 @@ namespace olive { RenderManager *RenderManager::instance_ = nullptr; -const rational RenderManager::kDryRunInterval = rational(10); +const Rational RenderManager::k_dry_run_interval = Rational(10); -RenderManager::Backend RenderManager::BackendFromString(const QString &backend) +RenderManager::Backend RenderManager::backend_from_string(const QString &backend) { const QString lower = backend.toLower(); if (lower == QStringLiteral("vulkan")) { - return kVulkan; + return k_vulkan; } if (lower == QStringLiteral("multiprocess")) { - return kMultiProcess; + return k_multi_process; } if (lower == QStringLiteral("dummy")) { - return kDummy; + return k_dummy; } - return kOpenGL; + return k_open_gl; } -QString RenderManager::BackendToString(Backend backend) +QString RenderManager::backend_to_string(Backend backend) { switch (backend) { - case kOpenGL: + case k_open_gl: return QStringLiteral("opengl"); - case kVulkan: + case k_vulkan: return QStringLiteral("vulkan"); - case kMultiProcess: + case k_multi_process: return QStringLiteral("multiprocess"); - case kDummy: + case k_dummy: return QStringLiteral("dummy"); } @@ -78,12 +78,12 @@ QString RenderManager::BackendToString(Backend backend) } RenderManager::RenderManager(QObject *parent) - : backend_(BackendFromString(OLIVE_CONFIG("GraphicsBackend").toString())) + : backend_(backend_from_string(OAK_CONFIG("GraphicsBackend").toString())) , requested_backend_(backend_) , aggressive_gc_(0) , worker_pool_(nullptr) { - if (backend_ == kVulkan) { + if (backend_ == k_vulkan) { #ifndef OAK_ENABLE_DYNAMIC_RENDER_BACKEND qWarning() << "Vulkan backend requested but dynamic render backend is not enabled. Falling back to OpenGL."; @@ -91,27 +91,27 @@ RenderManager::RenderManager(QObject *parent) #endif } - if (backend_ == kOpenGL || backend_ == kVulkan) { + if (backend_ == k_open_gl || backend_ == k_vulkan) { #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND auto *dynamic_renderer = - new DynamicRenderer(BackendToString(requested_backend_)); - if (!dynamic_renderer->Load()) { + new DynamicRenderer(backend_to_string(requested_backend_)); + if (!dynamic_renderer->load()) { qWarning() << "Failed to load dynamic render backend" - << BackendToString(requested_backend_) + << backend_to_string(requested_backend_) << ", falling back to OpenGL"; delete dynamic_renderer; - backend_ = kOpenGL; + backend_ = k_open_gl; context_ = new OpenGLRenderer(); } else { context_ = dynamic_renderer; // DynamicRenderer may internally fall back (e.g. Vulkan -> OpenGL). // Synchronize RenderManager's view of the actual runtime backend. Backend actual_backend = - BackendFromString(dynamic_renderer->backend_name()); + backend_from_string(dynamic_renderer->backend_name()); if (actual_backend != backend_) { qWarning() << "Dynamic render backend fell back from" - << BackendToString(backend_) << "to" - << BackendToString(actual_backend); + << backend_to_string(backend_) << "to" + << backend_to_string(actual_backend); backend_ = actual_backend; } } @@ -127,26 +127,26 @@ RenderManager::RenderManager(QObject *parent) } if (context_) { - dry_run_thread_ = CreateThread(); - audio_thread_ = CreateThread(); + dry_run_thread_ = create_thread(); + audio_thread_ = create_thread(); waveform_threads_.resize(QThread::idealThreadCount()); for (size_t i = 0; i < waveform_threads_.size(); i++) { - waveform_threads_[i] = CreateThread(); + waveform_threads_[i] = create_thread(); } auto_cacher_ = new PreviewAutoCacher(this); worker_pool_ = new RenderWorkerPool( - decoder_cache_, BackendToString(requested_backend_), this); + decoder_cache_, backend_to_string(requested_backend_), this); worker_pool_->start(QThread::NormalPriority); - backend_ = kMultiProcess; + backend_ = k_multi_process; } decoder_clear_timer_ = new QTimer(this); - decoder_clear_timer_->setInterval(kDecoderMaximumInactivity); + decoder_clear_timer_->setInterval(k_decoder_maximum_inactivity); connect(decoder_clear_timer_, &QTimer::timeout, this, - &RenderManager::ClearOldDecoders); + &RenderManager::clear_old_decoders); decoder_clear_timer_->start(); } @@ -154,7 +154,7 @@ RenderManager::~RenderManager() { if (context_) { if (worker_pool_) { - worker_pool_->Shutdown(); + worker_pool_->shutdown(); delete worker_pool_; worker_pool_ = nullptr; } @@ -167,12 +167,12 @@ RenderManager::~RenderManager() rt->wait(); } - context_->PostDestroy(); + context_->post_destroy(); delete context_; } } -RenderThread *RenderManager::CreateThread(Renderer *renderer) +RenderThread *RenderManager::create_thread(Renderer *renderer) { auto t = new RenderThread(renderer, decoder_cache_, shader_cache_, this); render_threads_.push_back(t); @@ -180,12 +180,12 @@ RenderThread *RenderManager::CreateThread(Renderer *renderer) return t; } -RenderTicketPtr RenderManager::RenderFrame(const RenderVideoParams ¶ms) +RenderTicketPtr RenderManager::render_frame(const RenderVideoParams ¶ms) { // Create ticket RenderTicketPtr ticket = std::make_shared(); - ticket->setProperty("node", QtUtils::PtrToValue(params.node)); + ticket->setProperty("node", QtUtils::ptr_to_value(params.node)); ticket->setProperty("time", QVariant::fromValue(params.time)); ticket->setProperty("size", params.force_size); ticket->setProperty("matrix", params.force_matrix); @@ -194,9 +194,9 @@ RenderTicketPtr RenderManager::RenderFrame(const RenderVideoParams ¶ms) ticket->setProperty("usecache", params.use_cache); ticket->setProperty("channelcount", params.force_channel_count); ticket->setProperty("mode", params.mode); - ticket->setProperty("type", kTypeVideo); + ticket->setProperty("type", k_type_video); ticket->setProperty("colormanager", - QtUtils::PtrToValue(params.color_manager)); + QtUtils::ptr_to_value(params.color_manager)); ticket->setProperty("coloroutput", QVariant::fromValue(params.force_color_output)); ticket->setProperty("colortransform", @@ -209,44 +209,44 @@ RenderTicketPtr RenderManager::RenderFrame(const RenderVideoParams ¶ms) ticket->setProperty("cachetimebase", QVariant::fromValue(params.cache_timebase)); ticket->setProperty("cacheid", QVariant::fromValue(params.cache_id)); - ticket->setProperty("multicam", QtUtils::PtrToValue(params.multicam)); + ticket->setProperty("multicam", QtUtils::ptr_to_value(params.multicam)); // Video frames are always rendered by the worker pool. GPU textures cannot // be shared across the process boundary (or across independent Vulkan // instances), so texture-return requests are downgraded to CPU frames. RenderVideoParams worker_params = params; - if (worker_params.return_type == ReturnType::kTexture) { - worker_params.return_type = ReturnType::kFrame; + if (worker_params.return_type == ReturnType::k_texture) { + worker_params.return_type = ReturnType::k_frame; } - if (worker_params.return_type == ReturnType::kNull) { + if (worker_params.return_type == ReturnType::k_null) { if (dry_run_thread_) { - dry_run_thread_->AddTicket(ticket); + dry_run_thread_->add_ticket(ticket); } else { // No render threads (e.g. dummy backend), finish without a result - ticket->Finish(); + ticket->finish(); } } else if (worker_pool_ && - worker_pool_->SubmitFrame(ticket, worker_params)) { + worker_pool_->submit_frame(ticket, worker_params)) { return ticket; } else { qWarning() << "RenderManager: worker pool unavailable, finishing ticket " "without result"; - ticket->Finish(); + ticket->finish(); } return ticket; } -RenderTicketPtr RenderManager::RenderAudio(const RenderAudioParams ¶ms) +RenderTicketPtr RenderManager::render_audio(const RenderAudioParams ¶ms) { // Create ticket RenderTicketPtr ticket = std::make_shared(); - ticket->setProperty("node", QtUtils::PtrToValue(params.node)); + ticket->setProperty("node", QtUtils::ptr_to_value(params.node)); ticket->setProperty("time", QVariant::fromValue(params.range)); - ticket->setProperty("type", kTypeAudio); + ticket->setProperty("type", k_type_audio); ticket->setProperty("enablewaveforms", params.generate_waveforms); ticket->setProperty("clamp", params.clamp); ticket->setProperty("aparam", QVariant::fromValue(params.audio_params)); @@ -255,26 +255,26 @@ RenderTicketPtr RenderManager::RenderAudio(const RenderAudioParams ¶ms) if (params.generate_waveforms && !waveform_threads_.empty()) { size_t thread_index = last_waveform_thread_ % waveform_threads_.size(); RenderThread *thread = waveform_threads_[thread_index]; - thread->AddTicket(ticket); + thread->add_ticket(ticket); last_waveform_thread_++; } else if (audio_thread_) { - audio_thread_->AddTicket(ticket); + audio_thread_->add_ticket(ticket); } else { // No render threads (e.g. dummy backend), finish without a result - ticket->Finish(); + ticket->finish(); } return ticket; } -bool RenderManager::RemoveTicket(RenderTicketPtr ticket) +bool RenderManager::remove_ticket(RenderTicketPtr ticket) { - if (worker_pool_ && worker_pool_->RemoveTicket(ticket)) { + if (worker_pool_ && worker_pool_->remove_ticket(ticket)) { return true; } for (RenderThread *rt : render_threads_) { - if (rt->RemoveTicket(ticket)) { + if (rt->remove_ticket(ticket)) { return true; } } @@ -282,7 +282,7 @@ bool RenderManager::RemoveTicket(RenderTicketPtr ticket) return false; } -void RenderManager::SetAggressiveGarbageCollection(bool enabled) +void RenderManager::set_aggressive_garbage_collection(bool enabled) { aggressive_gc_ += enabled ? 1 : -1; @@ -292,13 +292,13 @@ void RenderManager::SetAggressiveGarbageCollection(bool enabled) } if (aggressive_gc_ > 0) { - decoder_clear_timer_->setInterval(kDecoderMaximumInactivityAggressive); + decoder_clear_timer_->setInterval(k_decoder_maximum_inactivity_aggressive); } else { - decoder_clear_timer_->setInterval(kDecoderMaximumInactivity); + decoder_clear_timer_->setInterval(k_decoder_maximum_inactivity); } } -void RenderManager::ClearOldDecoders() +void RenderManager::clear_old_decoders() { if (!decoder_cache_) { // No decoder cache exists on backends without a renderer (e.g. dummy) @@ -308,13 +308,13 @@ void RenderManager::ClearOldDecoders() QMutexLocker locker(decoder_cache_->mutex()); qint64 min_age = - QDateTime::currentMSecsSinceEpoch() - kDecoderMaximumInactivity; + QDateTime::currentMSecsSinceEpoch() - k_decoder_maximum_inactivity; for (auto it = decoder_cache_->begin(); it != decoder_cache_->end();) { DecoderPair decoder = it.value(); - if (decoder.decoder->GetLastAccessedTime() < min_age) { - decoder.decoder->Close(); + if (decoder.decoder->get_last_accessed_time() < min_age) { + decoder.decoder->close(); it = decoder_cache_->erase(it); } else { it++; @@ -331,12 +331,12 @@ RenderThread::RenderThread(Renderer *renderer, DecoderCache *decoder_cache, , shader_cache_(shader_cache) { if (context_) { - context_->Init(); + context_->init(); context_->moveToThread(this); } } -void RenderThread::AddTicket(RenderTicketPtr ticket) +void RenderThread::add_ticket(RenderTicketPtr ticket) { QMutexLocker locker(&mutex_); ticket->moveToThread(this); @@ -344,7 +344,7 @@ void RenderThread::AddTicket(RenderTicketPtr ticket) wait_.wakeOne(); } -bool RenderThread::RemoveTicket(RenderTicketPtr ticket) +bool RenderThread::remove_ticket(RenderTicketPtr ticket) { QMutexLocker locker(&mutex_); @@ -367,7 +367,7 @@ void RenderThread::quit() void RenderThread::run() { if (context_) { - context_->PostInit(); + context_->post_init(); } QMutexLocker locker(&mutex_); @@ -388,12 +388,12 @@ void RenderThread::run() locker.unlock(); // Setup the ticket for ::Process - ticket->Start(); + ticket->start(); - if (ticket->IsCancelled()) { - ticket->Finish(); + if (ticket->is_cancelled()) { + ticket->finish(); } else { - RenderProcessor::Process(ticket, context_, decoder_cache_, + RenderProcessor::process(ticket, context_, decoder_cache_, shader_cache_); } @@ -402,7 +402,7 @@ void RenderThread::run() } if (context_) { - context_->Destroy(); + context_->destroy(); context_->moveToThread(this->thread()); } } diff --git a/app/render/rendermanager.h b/app/render/rendermanager.h index 39e01b01c..2d1530e56 100644 --- a/app/render/rendermanager.h +++ b/app/render/rendermanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERBACKEND_H -#define RENDERBACKEND_H +#ifndef OAK_RENDERBACKEND_H +#define OAK_RENDERBACKEND_H #include @@ -45,9 +45,9 @@ public: RenderThread(Renderer *renderer, DecoderCache *decoder_cache, ShaderCache *shader_cache, QObject *parent = nullptr); - void AddTicket(RenderTicketPtr ticket); + void add_ticket(RenderTicketPtr ticket); - bool RemoveTicket(RenderTicketPtr ticket); + bool remove_ticket(RenderTicketPtr ticket); void quit(); @@ -77,24 +77,24 @@ class RenderManager : public QObject { public: enum Backend { /// Graphics acceleration provided by OpenGL - kOpenGL, + k_open_gl, /// Vulkan requested by the user. Falls back to OpenGL until VulkanRenderer is implemented. - kVulkan, + k_vulkan, /// Video frames are rendered by an external oak-render-worker process. - kMultiProcess, + k_multi_process, /// No graphics rendering - used to test core threading logic - kDummy + k_dummy }; - static void CreateInstance() + static void create_instance() { instance_ = new RenderManager(); } - static void DestroyInstance() + static void destroy_instance() { delete instance_; instance_ = nullptr; @@ -105,11 +105,11 @@ public: return instance_; } - enum ReturnType { kTexture, kFrame, kNull }; + enum ReturnType { k_texture, k_frame, k_null }; struct RenderVideoParams { RenderVideoParams(Node *n, const VideoParams &vparam, - const AudioParams &aparam, const rational &t, + const AudioParams &aparam, const Rational &t, ColorManager *colorman, RenderMode::Mode m) { node = n; @@ -118,8 +118,8 @@ public: time = t; color_manager = colorman; use_cache = false; - return_type = kFrame; - force_format = PixelFormat::INVALID; + return_type = k_frame; + force_format = PixelFormat::invalid; force_color_output = nullptr; force_color_transform = ColorTransform(); force_size = QSize(0, 0); @@ -128,17 +128,17 @@ public: multicam = nullptr; } - void AddCache(FrameHashCache *cache) + void add_cache(FrameHashCache *cache) { - cache_dir = cache->GetCacheDirectory(); - cache_timebase = cache->GetTimebase(); - cache_id = cache->GetUuid().toString(); + cache_dir = cache->get_cache_directory(); + cache_timebase = cache->get_timebase(); + cache_id = cache->get_uuid().toString(); } Node *node; VideoParams video_params; AudioParams audio_params; - rational time; + Rational time; ColorManager *color_manager; bool use_cache; ReturnType return_type; @@ -146,7 +146,7 @@ public: MultiCamNode *multicam; QString cache_dir; - rational cache_timebase; + Rational cache_timebase; QString cache_id; QSize force_size; @@ -157,7 +157,7 @@ public: ColorTransform force_color_transform; }; - static const rational kDryRunInterval; + static const Rational k_dry_run_interval; /** * @brief Asynchronously generate a frame at a given time @@ -167,7 +167,7 @@ public: * * This function is thread-safe. */ - RenderTicketPtr RenderFrame(const RenderVideoParams ¶ms); + RenderTicketPtr render_frame(const RenderVideoParams ¶ms); struct RenderAudioParams { RenderAudioParams(Node *n, const TimeRange &time, @@ -196,11 +196,11 @@ public: * * This function is thread-safe. */ - RenderTicketPtr RenderAudio(const RenderAudioParams ¶ms); + RenderTicketPtr render_audio(const RenderAudioParams ¶ms); - bool RemoveTicket(RenderTicketPtr ticket); + bool remove_ticket(RenderTicketPtr ticket); - enum TicketType { kTypeVideo, kTypeAudio }; + enum TicketType { k_type_video, k_type_audio }; Backend backend() const { @@ -212,21 +212,21 @@ public: return requested_backend_; } - static Backend BackendFromString(const QString &backend); - static QString BackendToString(Backend backend); + static Backend backend_from_string(const QString &backend); + static QString backend_to_string(Backend backend); - PreviewAutoCacher *GetCacher() const + PreviewAutoCacher *get_cacher() const { return auto_cacher_; } - void SetProject(Project *p) + void set_project(Project *p) { - auto_cacher_->SetProject(p); + auto_cacher_->set_project(p); } public slots: - void SetAggressiveGarbageCollection(bool enabled); + void set_aggressive_garbage_collection(bool enabled); signals: @@ -235,7 +235,7 @@ private: virtual ~RenderManager() override; - RenderThread *CreateThread(Renderer *renderer = nullptr); + RenderThread *create_thread(Renderer *renderer = nullptr); static RenderManager *instance_; @@ -248,8 +248,8 @@ private: ShaderCache *shader_cache_ = nullptr; - static constexpr auto kDecoderMaximumInactivityAggressive = 1000; - static constexpr auto kDecoderMaximumInactivity = 5000; + static constexpr auto k_decoder_maximum_inactivity_aggressive = 1000; + static constexpr auto k_decoder_maximum_inactivity = 5000; int aggressive_gc_ = 0; @@ -268,11 +268,11 @@ private: RenderWorkerPool *worker_pool_ = nullptr; private slots: - void ClearOldDecoders(); + void clear_old_decoders(); }; } Q_DECLARE_METATYPE(olive::RenderManager::TicketType) -#endif // RENDERBACKEND_H +#endif // OAK_RENDERBACKEND_H diff --git a/app/render/rendermodes.h b/app/render/rendermodes.h index 9ccbdfa9e..1dabbf72a 100644 --- a/app/render/rendermodes.h +++ b/app/render/rendermodes.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERMODE_H -#define RENDERMODE_H +#ifndef OAK_RENDERMODE_H +#define OAK_RENDERMODE_H #include "common/define.h" @@ -37,16 +37,16 @@ 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. */ - kOffline, + k_offline, /** * 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 + k_online }; }; } -#endif // RENDERMODE_H +#endif // OAK_RENDERMODE_H diff --git a/app/render/renderprocessor.cpp b/app/render/renderprocessor.cpp index c6b840670..4a6451d72 100644 --- a/app/render/renderprocessor.cpp +++ b/app/render/renderprocessor.cpp @@ -34,8 +34,8 @@ #include "node/project.h" #include "rendermanager.h" #include "render/plugin/pluginrenderer.h" -#include "pluginSupport/OliveClip.h" -#include "pluginSupport/OliveHost.h" +#include "pluginSupport/oliveclip.h" +#include "pluginSupport/olivehost.h" #include "render/ipc/frameslotpool.h" namespace olive @@ -53,28 +53,28 @@ RenderProcessor::RenderProcessor(RenderTicketPtr ticket, Renderer *render_ctx, { } -TexturePtr RenderProcessor::GenerateTexture(const rational &time, - const rational &frame_length) +TexturePtr RenderProcessor::generate_texture(const Rational &time, + const Rational &frame_length) { TimeRange range = TimeRange(time, time + frame_length); NodeValueTable table; - if (Node *node = QtUtils::ValueToPtr(ticket_->property("node"))) { - table = GenerateTable(node, range); + if (Node *node = QtUtils::value_to_ptr(ticket_->property("node"))) { + table = generate_table(node, range); } - NodeValue tex_val = table.Get(NodeValue::kTexture); + NodeValue tex_val = table.get(NodeValue::k_texture); - ResolveJobs(tex_val); + resolve_jobs(tex_val); - return tex_val.toTexture(); + return tex_val.to_texture(); } -FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, - const rational &time) +FramePtr RenderProcessor::generate_frame(TexturePtr texture, + const Rational &time) { // Set up output frame parameters - VideoParams frame_params = GetCacheVideoParams(); + VideoParams frame_params = get_cache_video_params(); QSize frame_size = ticket_->property("size").value(); if (!frame_size.isNull()) { @@ -84,7 +84,7 @@ FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, PixelFormat frame_format = static_cast(ticket_->property("format").toInt()); - if (frame_format != PixelFormat::INVALID) { + if (frame_format != PixelFormat::invalid) { frame_params.set_format(frame_format); } @@ -94,10 +94,10 @@ FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, } else { frame_params.set_channel_count(texture ? texture->channel_count() : - VideoParams::kRGBAChannelCount); + VideoParams::k_rgba_channel_count); } - FramePtr frame = Frame::Create(); + FramePtr frame = Frame::create(); frame->set_timestamp(time); frame->set_video_params(frame_params); frame->allocate(); @@ -112,16 +112,16 @@ FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, const VideoParams &tex_params = texture->params(); if (output_color_transform) { - TexturePtr transform_tex = render_ctx_->CreateTexture(tex_params); + TexturePtr transform_tex = render_ctx_->create_texture(tex_params); ColorTransformJob job; - job.SetColorProcessor(output_color_transform); - job.SetInputTexture(texture); - job.SetInputAlphaAssociation( - OLIVE_CONFIG("ReassocLinToNonLin").toBool() ? kAlphaAssociated : - kAlphaNone); + job.set_color_processor(output_color_transform); + job.set_input_texture(texture); + job.set_input_alpha_association( + OAK_CONFIG("ReassocLinToNonLin").toBool() ? k_alpha_associated : + k_alpha_none); - render_ctx_->BlitColorManaged(job, transform_tex.get()); + render_ctx_->blit_color_managed(job, transform_tex.get()); texture = transform_tex; } @@ -129,26 +129,26 @@ FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, if (tex_params.effective_width() != frame_params.effective_width() || tex_params.effective_height() != frame_params.effective_height() || tex_params.format() != frame_params.format()) { - TexturePtr blit_tex = render_ctx_->CreateTexture(frame_params); + TexturePtr blit_tex = render_ctx_->create_texture(frame_params); QMatrix4x4 matrix = ticket_->property("matrix").value(); // No color transform, just blit ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), - NodeValue(NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(texture))); - job.Insert(QStringLiteral("ove_mvpmat"), - NodeValue(NodeValue::kMatrix, matrix)); + job.insert(QStringLiteral("ove_mvpmat"), + NodeValue(NodeValue::k_matrix, matrix)); - render_ctx_->BlitToTexture(render_ctx_->GetDefaultShader(), job, + render_ctx_->blit_to_texture(render_ctx_->get_default_shader(), job, blit_tex.get()); // Replace texture that we're going to download in the next step texture = blit_tex; } - render_ctx_->DownloadFromTexture(texture->id(), texture->params(), + render_ctx_->download_from_texture(texture->id(), texture->params(), frame->data(), frame->linesize_pixels()); if (output_color_transform) { @@ -163,21 +163,21 @@ FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, return frame; } -void RenderProcessor::Run() +void RenderProcessor::run() { // Depending on the render ticket type, start a job RenderManager::TicketType type = ticket_->property("type").value(); - SetCancelPointer(ticket_->GetCancelAtom()); + set_cancel_pointer(ticket_->get_cancel_atom()); VideoParams params = ticket_->property("vparam").value(); - params.set_format(PixelFormat::F32); - SetCacheVideoParams(params); - SetCacheAudioParams(ticket_->property("aparam").value()); + params.set_format(PixelFormat::f32); + set_cache_video_params(params); + set_cache_audio_params(ticket_->property("aparam").value()); - if (IsCancelled()) { - ticket_->Finish(); + if (is_cancelled()) { + ticket_->finish(); return; } @@ -193,40 +193,40 @@ void RenderProcessor::Run() */ switch (type) { - case RenderManager::kTypeVideo: { - rational time = ticket_->property("time").value(); + case RenderManager::k_type_video: { + Rational time = ticket_->property("time").value(); - rational frame_length = GetCacheVideoParams().frame_rate_as_time_base(); - if (GetCacheVideoParams().interlacing() != - VideoParams::kInterlaceNone) { + Rational frame_length = get_cache_video_params().frame_rate_as_time_base(); + if (get_cache_video_params().interlacing() != + VideoParams::k_interlace_none) { frame_length /= 2; } - TexturePtr texture = GenerateTexture(time, frame_length); + TexturePtr texture = generate_texture(time, frame_length); if (!render_ctx_) { - ticket_->Finish(); + ticket_->finish(); } else { - if (GetCacheVideoParams().interlacing() != - VideoParams::kInterlaceNone) { + if (get_cache_video_params().interlacing() != + VideoParams::k_interlace_none) { // Get next between frame and interlace it TexturePtr top = texture; TexturePtr bottom = - GenerateTexture(time + frame_length, frame_length); + generate_texture(time + frame_length, frame_length); - if (GetCacheVideoParams().interlacing() == - VideoParams::kInterlacedBottomFirst) { + if (get_cache_video_params().interlacing() == + VideoParams::k_interlaced_bottom_first) { std::swap(top, bottom); } - texture = render_ctx_->InterlaceTexture(top, bottom, - GetCacheVideoParams()); + texture = render_ctx_->interlace_texture(top, bottom, + get_cache_video_params()); } - if (HeardCancel()) { + if (heard_cancel()) { // Finish cancelled ticket with nothing since we can't guarantee the frame we generated // is actually "complete - ticket_->Finish(); + ticket_->finish(); } else { FramePtr frame; QString cache = ticket_->property("cache").toString(); @@ -234,85 +234,85 @@ void RenderProcessor::Run() RenderManager::ReturnType( ticket_->property("return").toInt()); - if (return_type == RenderManager::kFrame || !cache.isEmpty()) { + if (return_type == RenderManager::k_frame || !cache.isEmpty()) { // Convert to CPU frame - frame = GenerateFrame(texture, time); + frame = generate_frame(texture, time); // Save to cache if requested if (!cache.isEmpty()) { - rational timebase = - ticket_->property("cachetimebase").value(); + Rational timebase = + ticket_->property("cachetimebase").value(); QUuid uuid = ticket_->property("cacheid").value(); - bool cache_result = FrameHashCache::SaveCacheFrame( + bool cache_result = FrameHashCache::save_cache_frame( cache, uuid, time, timebase, frame); ticket_->setProperty("cached", cache_result); } } - if (return_type == RenderManager::kTexture) { + if (return_type == RenderManager::k_texture) { // Return GPU texture if (!texture) { texture = - render_ctx_->CreateTexture(GetCacheVideoParams()); - render_ctx_->ClearDestination(texture.get()); + render_ctx_->create_texture(get_cache_video_params()); + render_ctx_->clear_destination(texture.get()); } - render_ctx_->Flush(); - ticket_->Finish(QVariant::fromValue(texture)); + render_ctx_->flush(); + ticket_->finish(QVariant::fromValue(texture)); } else { - ticket_->Finish(QVariant::fromValue(frame)); + ticket_->finish(QVariant::fromValue(frame)); } } } break; } - case RenderManager::kTypeAudio: { + case RenderManager::k_type_audio: { TimeRange time = ticket_->property("time").value(); NodeValueTable table; - if (Node *node = QtUtils::ValueToPtr(ticket_->property("node"))) { - table = GenerateTable(node, time); + if (Node *node = QtUtils::value_to_ptr(ticket_->property("node"))) { + table = generate_table(node, time); } - NodeValue sample_val = table.Get(NodeValue::kSamples); + NodeValue sample_val = table.get(NodeValue::k_samples); - ResolveJobs(sample_val); + resolve_jobs(sample_val); - SampleBuffer samples = sample_val.toSamples(); + SampleBuffer samples = sample_val.to_samples(); if (samples.is_allocated()) { - if (ticket_->property("clamp").toBool() && !IsCancelled()) { + if (ticket_->property("clamp").toBool() && !is_cancelled()) { samples.clamp(); } if (ticket_->property("enablewaveforms").toBool() && - !IsCancelled()) { + !is_cancelled()) { AudioVisualWaveform vis; vis.set_channel_count(samples.audio_params().channel_count()); - vis.OverwriteSamples(samples, + vis.overwrite_samples(samples, samples.audio_params().sample_rate()); ticket_->setProperty("waveform", QVariant::fromValue(vis)); } } - if (HeardCancel()) { - ticket_->Finish(); + if (heard_cancel()) { + ticket_->finish(); } else { - ticket_->Finish(QVariant::fromValue(samples)); + ticket_->finish(QVariant::fromValue(samples)); } break; } default: // Fail - ticket_->Finish(); + ticket_->finish(); } } DecoderPtr -RenderProcessor::ResolveDecoderFromInput(const QString &decoder_id, +RenderProcessor::resolve_decoder_from_input(const QString &decoder_id, const Decoder::CodecStream &stream) { - if (!stream.IsValid()) { + if (!stream.is_valid()) { qWarning() << "Attempted to resolve the decoder of a null stream"; return nullptr; } @@ -336,12 +336,12 @@ RenderProcessor::ResolveDecoderFromInput(const QString &decoder_id, dec = decoder.decoder; } else { // No decoder - decoder.decoder = dec = Decoder::CreateFromID(decoder_id); + decoder.decoder = dec = Decoder::create_from_id(decoder_id); decoder.last_modified = file_last_modified; decoder_cache_->insert(stream, decoder); locker.unlock(); - if (!dec->Open(stream)) { + if (!dec->open(stream)) { qWarning() << "Failed to open decoder for" << stream.filename() << "::" << stream.stream(); return nullptr; @@ -349,35 +349,35 @@ RenderProcessor::ResolveDecoderFromInput(const QString &decoder_id, if (!render_ctx_) { // Assume dry run and increment access time - decoder.decoder->IncrementAccessTime( - RenderManager::kDryRunInterval.toDouble() * 1000); + decoder.decoder->increment_access_time( + RenderManager::k_dry_run_interval.to_double() * 1000); } } return dec; } -NodeValueDatabase RenderProcessor::GenerateDatabase(const Node *node, +NodeValueDatabase RenderProcessor::generate_database(const Node *node, const TimeRange &range) { - NodeValueDatabase db = super::GenerateDatabase(node, range); + NodeValueDatabase db = super::generate_database(node, range); if (const MultiCamNode *multicam = dynamic_cast(node)) { - if (QtUtils::ValueToPtr(ticket_->property("multicam")) == + if (QtUtils::value_to_ptr(ticket_->property("multicam")) == multicam) { - int sz = multicam->GetSourceCount(); + int sz = multicam->get_source_count(); QVector multicam_tex(sz); for (int i = 0; i < sz; i++) { NodeValueTable t = - GenerateTable(multicam->GetConnectedRenderOutput( - multicam->kSourcesInput, i), + generate_table(multicam->get_connected_render_output( + multicam->k_sources_input, i), range, multicam); - NodeValue val = GenerateRowValueElement( - multicam, multicam->kSourcesInput, i, &t, range); - ResolveJobs(val); + NodeValue val = generate_row_value_element( + multicam, multicam->k_sources_input, i, &t, range); + resolve_jobs(val); - multicam_tex[i] = val.toTexture(); + multicam_tex[i] = val.to_texture(); } ticket_->setProperty("multicam_output", QVariant::fromValue(multicam_tex)); @@ -387,20 +387,20 @@ NodeValueDatabase RenderProcessor::GenerateDatabase(const Node *node, return db; } -void RenderProcessor::Process(RenderTicketPtr ticket, Renderer *render_ctx, +void RenderProcessor::process(RenderTicketPtr ticket, Renderer *render_ctx, DecoderCache *decoder_cache, ShaderCache *shader_cache) { RenderProcessor p(ticket, render_ctx, decoder_cache, shader_cache); - p.Run(); + p.run(); } -void RenderProcessor::ProcessVideoFootage(TexturePtr destination, +void RenderProcessor::process_video_footage(TexturePtr destination, const FootageJob *stream, - const rational &input_time) + const Rational &input_time) { if (ticket_->property("type").value() != - RenderManager::kTypeVideo) { + RenderManager::k_type_video) { // Video cannot contribute to audio, so we do nothing here return; } @@ -411,12 +411,12 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, VideoParams stream_data = stream->video_params(); ColorManager *color_manager = - QtUtils::ValueToPtr(ticket_->property("colormanager")); + QtUtils::value_to_ptr(ticket_->property("colormanager")); QString using_colorspace = stream_data.colorspace(); if (using_colorspace.isEmpty() && color_manager) { - using_colorspace = color_manager->GetDefaultInputColorSpace(); + using_colorspace = color_manager->get_default_input_color_space(); } if (using_colorspace.isEmpty()) { @@ -426,37 +426,37 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, auto blit_color_managed = [&](const TexturePtr &unmanaged_texture, const VideoParams &texture_params) { - if (!render_ctx_ || !unmanaged_texture || IsCancelled()) { + if (!render_ctx_ || !unmanaged_texture || is_cancelled()) { return; } // We convert to our rendering pixel format, since that will always be float-based which // is necessary for correct color conversion ColorProcessorPtr processor = - ColorProcessor::Create(color_manager, using_colorspace, - color_manager->GetReferenceColorSpace()); + ColorProcessor::create(color_manager, using_colorspace, + color_manager->get_reference_color_space()); ColorTransformJob job; - job.SetColorProcessor(processor); - job.SetInputTexture(unmanaged_texture); + job.set_color_processor(processor); + job.set_input_texture(unmanaged_texture); - if (texture_params.channel_count() != VideoParams::kRGBAChannelCount || + if (texture_params.channel_count() != VideoParams::k_rgba_channel_count || texture_params.colorspace() == - color_manager->GetReferenceColorSpace()) { - job.SetInputAlphaAssociation(kAlphaNone); + color_manager->get_reference_color_space()) { + job.set_input_alpha_association(k_alpha_none); } else if (texture_params.premultiplied_alpha()) { - job.SetInputAlphaAssociation(kAlphaAssociated); + job.set_input_alpha_association(k_alpha_associated); } else { - job.SetInputAlphaAssociation(kAlphaUnassociated); + job.set_input_alpha_association(k_alpha_unassociated); } - render_ctx_->BlitColorManaged(job, destination.get()); + render_ctx_->blit_color_managed(job, destination.get()); // macOS TBDR: ensure tile writeback completes before the texture // is read back in a potentially different shared OpenGL context. - render_ctx_->Flush(); + render_ctx_->flush(); }; - auto *input_pool = QtUtils::ValueToPtr( + auto *input_pool = QtUtils::value_to_ptr( ticket_->property("ipc_input_pool")); int input_slot = -1; const QVariantList input_slots = @@ -481,7 +481,7 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, return; } - const ipc::FrameSlotMeta *meta = input_pool->Meta(uint32_t(input_slot)); + const ipc::FrameSlotMeta *meta = input_pool->meta(uint32_t(input_slot)); if (meta && meta->width > 0 && meta->height > 0 && meta->data_size > 0 && meta->data_size <= int(input_pool->slot_data_bytes())) { @@ -506,13 +506,13 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, using_colorspace = ipc_colorspace; } - const int bytes_per_pixel = input_params.GetBytesPerPixel(); + const int bytes_per_pixel = input_params.get_bytes_per_pixel(); const int linesize_pixels = bytes_per_pixel > 0 ? meta->linesize / bytes_per_pixel : input_params.effective_width(); - const void *slot_data = input_pool->SlotData(uint32_t(input_slot)); - TexturePtr unmanaged_texture = render_ctx_->CreateTexture( + const void *slot_data = input_pool->slot_data(uint32_t(input_slot)); + TexturePtr unmanaged_texture = render_ctx_->create_texture( input_params, slot_data, linesize_pixels); blit_color_managed(unmanaged_texture, input_params); @@ -532,7 +532,7 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, const bool use_proxy = static_cast(ticket_->property("mode").toInt()) == - RenderMode::kOffline && + RenderMode::k_offline && stream->has_proxy() && QFileInfo::exists(stream->proxy_filename()); const QString decode_filename = use_proxy ? stream->proxy_filename() : stream->filename(); @@ -542,30 +542,30 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, stream_data.stream_index(); Decoder::CodecStream default_codec_stream(decode_filename, stream_index, - GetCurrentBlock()); + get_current_block()); DecoderPtr decoder = nullptr; switch (stream_data.video_type()) { - case VideoParams::kVideoTypeVideo: - case VideoParams::kVideoTypeStill: - decoder = ResolveDecoderFromInput(decoder_id, default_codec_stream); + case VideoParams::k_video_type_video: + case VideoParams::k_video_type_still: + decoder = resolve_decoder_from_input(decoder_id, default_codec_stream); break; - case VideoParams::kVideoTypeImageSequence: { + case VideoParams::k_video_type_image_sequence: { if (render_ctx_) { // Since image sequences involve multiple files, we don't engage the decoder cache - decoder = Decoder::CreateFromID(decoder_id); + decoder = Decoder::create_from_id(decoder_id); QString frame_filename; int64_t frame_number = stream_data.get_time_in_timebase_units(input_time); - frame_filename = Decoder::TransformImageSequenceFileName( + frame_filename = Decoder::transform_image_sequence_file_name( decode_filename, frame_number); // Decoder will close automatically since it's a stream_ptr - decoder->Open(Decoder::CodecStream(frame_filename, stream_index, - GetCurrentBlock())); + decoder->open(Decoder::CodecStream(frame_filename, stream_index, + get_current_block())); } break; } @@ -576,7 +576,7 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, p.divider = stream->video_params().divider(); p.maximum_format = destination->format(); - if (!IsCancelled()) { + if (!is_cancelled()) { VideoParams tex_params = stream->video_params(); if (tex_params.is_valid()) { @@ -584,16 +584,16 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, p.renderer = render_ctx_; p.time = - (stream_data.video_type() == VideoParams::kVideoTypeVideo) ? + (stream_data.video_type() == VideoParams::k_video_type_video) ? input_time : - Decoder::kAnyTimecode; - p.cancelled = GetCancelPointer(); + Decoder::k_any_timecode; + p.cancelled = get_cancel_pointer(); p.force_range = stream_data.color_range(); p.src_interlacing = stream_data.interlacing(); - unmanaged_texture = decoder->RetrieveVideo(p); + unmanaged_texture = decoder->retrieve_video(p); - if (!IsCancelled() && unmanaged_texture) { + if (!is_cancelled() && unmanaged_texture) { blit_color_managed(unmanaged_texture, stream_data); } } @@ -601,7 +601,7 @@ void RenderProcessor::ProcessVideoFootage(TexturePtr destination, } } -void RenderProcessor::ProcessAudioFootage(SampleBuffer &destination, +void RenderProcessor::process_audio_footage(SampleBuffer &destination, const FootageJob *stream, const TimeRange &input_time) { @@ -615,7 +615,7 @@ void RenderProcessor::ProcessAudioFootage(SampleBuffer &destination, // audio) for offline renders only, never for export const bool use_proxy = static_cast(ticket_->property("mode").toInt()) == - RenderMode::kOffline && + RenderMode::k_offline && stream->has_proxy() && QFileInfo::exists(stream->proxy_filename()); const QString decode_filename = use_proxy ? stream->proxy_filename() : stream->filename(); @@ -625,25 +625,25 @@ void RenderProcessor::ProcessAudioFootage(SampleBuffer &destination, stream->proxy_stream_index() : stream->audio_params().stream_index(); - DecoderPtr decoder = ResolveDecoderFromInput( + DecoderPtr decoder = resolve_decoder_from_input( decoder_id, Decoder::CodecStream(decode_filename, stream_index, nullptr)); if (decoder) { - const AudioParams &audio_params = GetCacheAudioParams(); + const AudioParams &audio_params = get_cache_audio_params(); - Decoder::RetrieveAudioStatus status = decoder->RetrieveAudio( + Decoder::RetrieveAudioStatus status = decoder->retrieve_audio( destination, input_time, audio_params, stream->cache_path(), loop_mode(), static_cast(ticket_->property("mode").toInt())); - if (status == Decoder::kWaitingForConform) { + if (status == Decoder::k_waiting_for_conform) { ticket_->setProperty("incomplete", true); } } } -void RenderProcessor::ProcessShader(TexturePtr destination, const Node *node, +void RenderProcessor::process_shader(TexturePtr destination, const Node *node, const ShaderJob *job) { if (!render_ctx_) { @@ -651,7 +651,7 @@ void RenderProcessor::ProcessShader(TexturePtr destination, const Node *node, } QString full_shader_id = - QStringLiteral("%1:%2").arg(node->id(), job->GetShaderID()); + QStringLiteral("%1:%2").arg(node->id(), job->get_shader_id()); QMutexLocker locker(shader_cache_->mutex()); @@ -659,8 +659,8 @@ void RenderProcessor::ProcessShader(TexturePtr destination, const Node *node, if (shader.isNull()) { // Since we have shader code, compile it now - shader = render_ctx_->CreateNativeShader( - node->GetShaderCode(job->GetShaderID())); + shader = render_ctx_->create_native_shader( + node->get_shader_code(job->get_shader_id())); if (shader.isNull()) { // Couldn't find or build the shader required @@ -673,11 +673,11 @@ void RenderProcessor::ProcessShader(TexturePtr destination, const Node *node, locker.unlock(); // Run shader - render_ctx_->BlitToTexture(shader, const_cast(*job), + render_ctx_->blit_to_texture(shader, const_cast(*job), destination.get()); } -void RenderProcessor::ProcessSamples(SampleBuffer &destination, +void RenderProcessor::process_samples(SampleBuffer &destination, const Node *node, const TimeRange &range, const SampleJob &job) { @@ -687,32 +687,32 @@ void RenderProcessor::ProcessSamples(SampleBuffer &destination, NodeValueRow value_db; - const AudioParams &audio_params = GetCacheAudioParams(); + const AudioParams &audio_params = get_cache_audio_params(); for (size_t i = 0; i < job.samples().sample_count(); i++) { - // Calculate the exact rational time at this sample + // Calculate the exact Rational time at this sample double sample_to_second = static_cast(i) / static_cast(audio_params.sample_rate()); - rational this_sample_time = - rational::fromDouble(range.in().toDouble() + sample_to_second); + Rational this_sample_time = + Rational::from_double(range.in().to_double() + sample_to_second); // Update all non-sample and non-footage inputs - for (auto j = job.GetValues().constBegin(); - j != job.GetValues().constEnd(); j++) { + for (auto j = job.get_values().constBegin(); + j != job.get_values().constEnd(); j++) { TimeRange r = TimeRange(this_sample_time, this_sample_time); - NodeValueTable value = ProcessInput(node, j.key(), r); + NodeValueTable value = process_input(node, j.key(), r); value_db.insert(j.key(), - GenerateRowValue(node, j.key(), &value, r)); + generate_row_value(node, j.key(), &value, r)); } - node->ProcessSamples(value_db, job.samples(), destination, i); + node->process_samples(value_db, job.samples(), destination, i); } } -void RenderProcessor::ProcessColorTransform(TexturePtr destination, +void RenderProcessor::process_color_transform(TexturePtr destination, const Node *node, const ColorTransformJob *job) { @@ -720,10 +720,10 @@ void RenderProcessor::ProcessColorTransform(TexturePtr destination, return; } - render_ctx_->BlitColorManaged(*job, destination.get()); + render_ctx_->blit_color_managed(*job, destination.get()); } -void RenderProcessor::ProcessFrameGeneration(TexturePtr destination, +void RenderProcessor::process_frame_generation(TexturePtr destination, const Node *node, const GenerateJob *job) { @@ -731,17 +731,17 @@ void RenderProcessor::ProcessFrameGeneration(TexturePtr destination, return; } - FramePtr frame = Frame::Create(); + FramePtr frame = Frame::create(); frame->set_video_params(destination->params()); frame->allocate(); - node->GenerateFrame(frame, *job); + node->generate_frame(frame, *job); - destination->Upload(frame->data(), frame->linesize_pixels()); + destination->upload(frame->data(), frame->linesize_pixels()); } -TexturePtr RenderProcessor::ProcessPluginJob(TexturePtr texture, +TexturePtr RenderProcessor::process_plugin_job(TexturePtr texture, TexturePtr destination, const Node *node) { @@ -761,13 +761,13 @@ TexturePtr RenderProcessor::ProcessPluginJob(TexturePtr texture, return destination; } - NodeValueRow &values = plugin_job->GetValues(); + NodeValueRow &values = plugin_job->get_values(); auto is_usable_texture = [](const TexturePtr &tex) { if (!tex) { return false; } - if (!tex->IsDummy() && tex->renderer()) { + if (!tex->is_dummy() && tex->renderer()) { return true; } AVFramePtr frame = tex->frame(); @@ -777,10 +777,10 @@ TexturePtr RenderProcessor::ProcessPluginJob(TexturePtr texture, TexturePtr src = nullptr; QString effect_input_id; if (plugin_job->node()) { - effect_input_id = plugin_job->node()->GetEffectInputID(); + effect_input_id = plugin_job->node()->get_effect_input_id(); } if (!effect_input_id.isEmpty()) { - if (TexturePtr effect_tex = values.value(effect_input_id).toTexture(); + if (TexturePtr effect_tex = values.value(effect_input_id).to_texture(); is_usable_texture(effect_tex)) { src = effect_tex; } @@ -788,19 +788,19 @@ TexturePtr RenderProcessor::ProcessPluginJob(TexturePtr texture, if (!src) { const QString source_key = QString::fromUtf8(kOfxImageEffectSimpleSourceClipName); - if (TexturePtr source_tex = values.value(source_key).toTexture(); + if (TexturePtr source_tex = values.value(source_key).to_texture(); is_usable_texture(source_tex)) { src = source_tex; } else if (TexturePtr effect_tex = - values.value(plugin::kTextureInput).toTexture(); + values.value(plugin::k_texture_input).to_texture(); is_usable_texture(effect_tex)) { src = effect_tex; } } if (!src) { for (auto it = values.cbegin(); it != values.cend(); ++it) { - if (it.value().type() == NodeValue::kTexture) { - if (TexturePtr any_tex = it.value().toTexture(); + if (it.value().type() == NodeValue::k_texture) { + if (TexturePtr any_tex = it.value().to_texture(); is_usable_texture(any_tex)) { src = any_tex; break; @@ -809,15 +809,15 @@ TexturePtr RenderProcessor::ProcessPluginJob(TexturePtr texture, } } - plugin_renderer.RenderPlugin(src, *plugin_job, destination, + plugin_renderer.render_plugin(src, *plugin_job, destination, destination->params(), true, false); return destination; } -TexturePtr RenderProcessor::ProcessVideoCacheJob(const CacheJob *val) +TexturePtr RenderProcessor::process_video_cache_job(const CacheJob *val) { - FramePtr frame = FrameHashCache::LoadCacheFrame(val->GetFilename()); + FramePtr frame = FrameHashCache::load_cache_frame(val->get_filename()); if (frame) { // Auto-detect and discard black/empty cached frames (macOS TBDR artifact) bool all_black = true; @@ -835,37 +835,37 @@ TexturePtr RenderProcessor::ProcessVideoCacheJob(const CacheJob *val) } if (all_black) { qWarning() << "[CACHE] Discarding black cached frame:" - << val->GetFilename() - << "time=" << frame->timestamp().toDouble() + << val->get_filename() + << "time=" << frame->timestamp().to_double() << "size=" << frame->allocated_size(); - QFile::remove(val->GetFilename()); + QFile::remove(val->get_filename()); return nullptr; } - TexturePtr tex = CreateTexture(frame->video_params()); + TexturePtr tex = create_texture(frame->video_params()); if (tex) { - tex->Upload(frame->data(), frame->linesize_pixels()); + tex->upload(frame->data(), frame->linesize_pixels()); return tex; } } else { QStringList s = ticket_->property("badcache").toStringList(); - s.append(val->GetFilename()); + s.append(val->get_filename()); ticket_->setProperty("badcache", s); } return nullptr; } -TexturePtr RenderProcessor::CreateTexture(const VideoParams &p) +TexturePtr RenderProcessor::create_texture(const VideoParams &p) { if (render_ctx_) { - return render_ctx_->CreateTexture(p); + return render_ctx_->create_texture(p); } else { - return super::CreateTexture(p); + return super::create_texture(p); } } -void RenderProcessor::ConvertToReferenceSpace(TexturePtr destination, +void RenderProcessor::convert_to_reference_space(TexturePtr destination, TexturePtr source, const QString &input_cs) { @@ -874,23 +874,23 @@ void RenderProcessor::ConvertToReferenceSpace(TexturePtr destination, } ColorManager *color_manager = - QtUtils::ValueToPtr(ticket_->property("colormanager")); - ColorProcessorPtr cp = ColorProcessor::Create( - color_manager, input_cs, color_manager->GetReferenceColorSpace()); + QtUtils::value_to_ptr(ticket_->property("colormanager")); + ColorProcessorPtr cp = ColorProcessor::create( + color_manager, input_cs, color_manager->get_reference_color_space()); ColorTransformJob ctj; - ctj.SetColorProcessor(cp); - ctj.SetInputTexture(source); - ctj.SetInputAlphaAssociation(kAlphaAssociated); + ctj.set_color_processor(cp); + ctj.set_input_texture(source); + ctj.set_input_alpha_association(k_alpha_associated); - render_ctx_->BlitColorManaged(ctj, destination.get()); + render_ctx_->blit_color_managed(ctj, destination.get()); } -bool RenderProcessor::UseCache() const +bool RenderProcessor::use_cache() const { return static_cast(ticket_->property("mode").toInt()) == - RenderMode::kOffline; + RenderMode::k_offline; } } diff --git a/app/render/renderprocessor.h b/app/render/renderprocessor.h index 2a58c690f..750f72b1b 100644 --- a/app/render/renderprocessor.h +++ b/app/render/renderprocessor.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERPROCESSOR_H -#define RENDERPROCESSOR_H +#ifndef OAK_RENDERPROCESSOR_H +#define OAK_RENDERPROCESSOR_H #include "node/block/clip/clip.h" #include @@ -39,10 +39,10 @@ class PluginRenderer; class RenderProcessor : public NodeTraverser { public: - virtual NodeValueDatabase GenerateDatabase(const Node *node, + virtual NodeValueDatabase generate_database(const Node *node, const TimeRange &range) override; - static void Process(RenderTicketPtr ticket, Renderer *render_ctx, + static void process(RenderTicketPtr ticket, Renderer *render_ctx, DecoderCache *decoder_cache, ShaderCache *shader_cache); struct RenderedWaveform { @@ -53,60 +53,60 @@ public: }; protected: - virtual void ProcessVideoFootage(TexturePtr destination, + virtual void process_video_footage(TexturePtr destination, const FootageJob *stream, - const rational &input_time) override; + const Rational &input_time) override; - virtual void ProcessAudioFootage(SampleBuffer &destination, + virtual void process_audio_footage(SampleBuffer &destination, const FootageJob *stream, const TimeRange &input_time) override; - virtual void ProcessShader(TexturePtr destination, const Node *node, + virtual void process_shader(TexturePtr destination, const Node *node, const ShaderJob *job) override; - virtual void ProcessSamples(SampleBuffer &destination, const Node *node, + virtual void process_samples(SampleBuffer &destination, const Node *node, const TimeRange &range, const SampleJob &job) override; - virtual void ProcessColorTransform(TexturePtr destination, const Node *node, + virtual void process_color_transform(TexturePtr destination, const Node *node, const ColorTransformJob *job) override; - virtual void ProcessFrameGeneration(TexturePtr destination, + virtual void process_frame_generation(TexturePtr destination, const Node *node, const GenerateJob *job) override; - virtual TexturePtr ProcessPluginJob(TexturePtr texture, + virtual TexturePtr process_plugin_job(TexturePtr texture, TexturePtr destination, const Node *node) override; - virtual TexturePtr ProcessVideoCacheJob(const CacheJob *val) override; + virtual TexturePtr process_video_cache_job(const CacheJob *val) override; - virtual TexturePtr CreateTexture(const VideoParams &p) override; + virtual TexturePtr create_texture(const VideoParams &p) override; - virtual SampleBuffer CreateSampleBuffer(const AudioParams ¶ms, + virtual SampleBuffer create_sample_buffer(const AudioParams ¶ms, int sample_count) override { return SampleBuffer(params, sample_count); } - virtual void ConvertToReferenceSpace(TexturePtr destination, + virtual void convert_to_reference_space(TexturePtr destination, TexturePtr source, const QString &input_cs) override; - virtual bool UseCache() const override; + virtual bool use_cache() const override; private: RenderProcessor(RenderTicketPtr ticket, Renderer *render_ctx, DecoderCache *decoder_cache, ShaderCache *shader_cache); - TexturePtr GenerateTexture(const rational &time, - const rational &frame_length); + TexturePtr generate_texture(const Rational &time, + const Rational &frame_length); - FramePtr GenerateFrame(TexturePtr texture, const rational &time); + FramePtr generate_frame(TexturePtr texture, const Rational &time); - void Run(); + void run(); - DecoderPtr ResolveDecoderFromInput(const QString &decoder_id, + DecoderPtr resolve_decoder_from_input(const QString &decoder_id, const Decoder::CodecStream &stream); RenderTicketPtr ticket_; @@ -124,4 +124,4 @@ private: Q_DECLARE_METATYPE(olive::RenderProcessor::RenderedWaveform) -#endif // RENDERPROCESSOR_H +#endif // OAK_RENDERPROCESSOR_H diff --git a/app/render/renderticket.cpp b/app/render/renderticket.cpp index 991ba0168..a6a16331c 100644 --- a/app/render/renderticket.cpp +++ b/app/render/renderticket.cpp @@ -31,14 +31,14 @@ RenderTicket::RenderTicket() { } -void RenderTicket::WaitForFinished(QMutex *mutex) +void RenderTicket::wait_for_finished(QMutex *mutex) { if (is_running_) { wait_.wait(mutex); } } -void RenderTicket::Start() +void RenderTicket::start() { QMutexLocker locker(&lock_); @@ -47,33 +47,33 @@ void RenderTicket::Start() result_.clear(); } -void RenderTicket::Finish() +void RenderTicket::finish() { - FinishInternal(false, QVariant()); + finish_internal(false, QVariant()); } -void RenderTicket::Finish(QVariant result) +void RenderTicket::finish(QVariant result) { - FinishInternal(true, result); + finish_internal(true, result); } -QVariant RenderTicket::Get() +QVariant RenderTicket::get() { - WaitForFinished(); + wait_for_finished(); // We don't have to mutex around this because there is no way to write to `result_` after // the ticket has finished and the above function blocks the calling thread until it is finished return result_; } -void RenderTicket::WaitForFinished() +void RenderTicket::wait_for_finished() { QMutexLocker locker(&lock_); - WaitForFinished(&lock_); + wait_for_finished(&lock_); } -bool RenderTicket::IsRunning(bool lock) +bool RenderTicket::is_running(bool lock) { if (lock) { lock_.lock(); @@ -88,7 +88,7 @@ bool RenderTicket::IsRunning(bool lock) return running; } -int RenderTicket::GetFinishCount(bool lock) +int RenderTicket::get_finish_count(bool lock) { if (lock) { lock_.lock(); @@ -103,14 +103,14 @@ int RenderTicket::GetFinishCount(bool lock) return count; } -bool RenderTicket::HasResult() +bool RenderTicket::has_result() { QMutexLocker locker(&lock_); return has_result_; } -void RenderTicket::FinishInternal(bool has_result, QVariant result) +void RenderTicket::finish_internal(bool has_result, QVariant result) { QMutexLocker locker(&lock_); @@ -126,7 +126,7 @@ void RenderTicket::FinishInternal(bool has_result, QVariant result) locker.unlock(); - emit Finished(); + emit finished(); } } @@ -136,7 +136,7 @@ RenderTicketWatcher::RenderTicketWatcher(QObject *parent) { } -void RenderTicketWatcher::SetTicket(RenderTicketPtr ticket) +void RenderTicketWatcher::set_ticket(RenderTicketPtr ticket) { if (ticket_) { qCritical() << "Tried to set a ticket on a RenderTicketWatcher twice"; @@ -153,62 +153,62 @@ void RenderTicketWatcher::SetTicket(RenderTicketPtr ticket) // Lock ticket so we can query if it's already finished by the time this code runs QMutexLocker locker(ticket->lock()); - connect(ticket_.get(), &RenderTicket::Finished, this, - &RenderTicketWatcher::TicketFinished); + connect(ticket_.get(), &RenderTicket::finished, this, + &RenderTicketWatcher::ticket_finished); - if (!ticket_->IsRunning(false) && ticket_->GetFinishCount(false) > 0) { + if (!ticket_->is_running(false) && ticket_->get_finish_count(false) > 0) { // Ticket has already finished before, so we emit a signal asynchronously // to avoid deleting this watcher before the caller has a chance to use // the returned pointer. - QMetaObject::invokeMethod(this, &RenderTicketWatcher::TicketFinished, + QMetaObject::invokeMethod(this, &RenderTicketWatcher::ticket_finished, Qt::QueuedConnection); } } -bool RenderTicketWatcher::IsRunning() +bool RenderTicketWatcher::is_running() { if (ticket_) { - return ticket_->IsRunning(); + return ticket_->is_running(); } else { return false; } } -void RenderTicketWatcher::WaitForFinished() +void RenderTicketWatcher::wait_for_finished() { if (ticket_) { - ticket_->WaitForFinished(); + ticket_->wait_for_finished(); } } -QVariant RenderTicketWatcher::Get() +QVariant RenderTicketWatcher::get() { if (ticket_) { - return ticket_->Get(); + return ticket_->get(); } else { return QVariant(); } } -bool RenderTicketWatcher::HasResult() +bool RenderTicketWatcher::has_result() { if (ticket_) { - return ticket_->HasResult(); + return ticket_->has_result(); } else { return false; } } -void RenderTicketWatcher::Cancel() +void RenderTicketWatcher::cancel() { if (ticket_) { - ticket_->Cancel(); + ticket_->cancel(); } } -void RenderTicketWatcher::TicketFinished() +void RenderTicketWatcher::ticket_finished() { - emit Finished(this); + emit finished(this); } } diff --git a/app/render/renderticket.h b/app/render/renderticket.h index be1af260d..6c3b95f2d 100644 --- a/app/render/renderticket.h +++ b/app/render/renderticket.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERTICKET_H -#define RENDERTICKET_H +#ifndef OAK_RENDERTICKET_H +#define OAK_RENDERTICKET_H #include #include @@ -44,7 +44,7 @@ public: * This function is thread safe, unless `lock` is set to false. Then the caller has responsibility * of locking the mutex before and unlocking after this function is called. */ - bool IsRunning(bool lock = true); + bool is_running(bool lock = true); /** * @brief Determine how many times ticket has been finished @@ -52,27 +52,27 @@ public: * This function is thread safe, unless `lock` is set to false. Then the caller has responsibility * of locking the mutex before and unlocking after this function is called. */ - int GetFinishCount(bool lock = true); + int get_finish_count(bool lock = true); /** * @brief Check if this ticket has a result * * If this ticket is running, this will always return false. */ - bool HasResult(); + bool has_result(); /** * @brief Get value, if any */ - QVariant Get(); + QVariant get(); /** * @brief Wait for ticket to be finished * * If this ticket is not running, this function returns immediately. */ - void WaitForFinished(); - void WaitForFinished(QMutex *mutex); + void wait_for_finished(); + void wait_for_finished(QMutex *mutex); /** * @brief Access this ticket's mutex @@ -90,30 +90,30 @@ public: * * If any value is set, it is cleared. */ - void Start(); + void start(); /** * @brief Finish ticket with no value * * Sets ticket to no longer running and assume it has received no result. */ - void Finish(); + void finish(); /** * @brief Finish ticket with value * * Sets ticket to no longer running and provide a value generated by the operation requested. */ - void Finish(QVariant result); + void finish(QVariant result); signals: /** * @brief Emitted when finish has been called by any means (either cancelled or with a result) */ - void Finished(); + void finished(); private: - void FinishInternal(bool has_result, QVariant result); + void finish_internal(bool has_result, QVariant result); bool is_running_; @@ -135,35 +135,35 @@ class RenderTicketWatcher : public QObject { public: RenderTicketWatcher(QObject *parent = nullptr); - RenderTicketPtr GetTicket() const + RenderTicketPtr get_ticket() const { return ticket_; } - void SetTicket(RenderTicketPtr ticket); + void set_ticket(RenderTicketPtr ticket); - bool IsRunning(); + bool is_running(); - void WaitForFinished(); + void wait_for_finished(); - QVariant Get(); + QVariant get(); - bool HasResult(); + bool has_result(); - void Cancel(); + void cancel(); signals: - void Finished(RenderTicketWatcher *watcher); + void finished(RenderTicketWatcher *watcher); private: RenderTicketPtr ticket_; private slots: - void TicketFinished(); + void ticket_finished(); }; } Q_DECLARE_METATYPE(olive::RenderTicketPtr) -#endif // RENDERTICKET_H +#endif // OAK_RENDERTICKET_H diff --git a/app/render/renderworkerpool.cpp b/app/render/renderworkerpool.cpp index d537b3d79..00b39b26a 100644 --- a/app/render/renderworkerpool.cpp +++ b/app/render/renderworkerpool.cpp @@ -53,47 +53,47 @@ namespace olive namespace { -constexpr int kProtocolVersion = 1; +constexpr int k_protocol_version = 1; struct FootageInput { FootageJob job; - rational time; + Rational time; }; class FootageInputCollector : public NodeTraverser { public: QVector - Collect(const RenderManager::RenderVideoParams ¶ms, CancelAtom *cancel) + collect(const RenderManager::RenderVideoParams ¶ms, CancelAtom *cancel) { - SetCancelPointer(cancel); + set_cancel_pointer(cancel); VideoParams cache_params = params.video_params; - cache_params.set_format(PixelFormat::F32); - SetCacheVideoParams(cache_params); - SetCacheAudioParams(params.audio_params); + cache_params.set_format(PixelFormat::f32); + set_cache_video_params(cache_params); + set_cache_audio_params(params.audio_params); - rational frame_length = cache_params.frame_rate_as_time_base(); - if (cache_params.interlacing() != VideoParams::kInterlaceNone) { + Rational frame_length = cache_params.frame_rate_as_time_base(); + if (cache_params.interlacing() != VideoParams::k_interlace_none) { frame_length /= 2; } - NodeValueTable table = GenerateTable( + NodeValueTable table = generate_table( params.node, TimeRange(params.time, params.time + frame_length)); - NodeValue texture = table.Get(NodeValue::kTexture); - ResolveJobs(texture); + NodeValue texture = table.get(NodeValue::k_texture); + resolve_jobs(texture); - if (cache_params.interlacing() != VideoParams::kInterlaceNone) { - NodeValueTable second_table = GenerateTable( + if (cache_params.interlacing() != VideoParams::k_interlace_none) { + NodeValueTable second_table = generate_table( params.node, TimeRange(params.time + frame_length, params.time + frame_length * 2)); - NodeValue second_texture = second_table.Get(NodeValue::kTexture); - ResolveJobs(second_texture); + NodeValue second_texture = second_table.get(NodeValue::k_texture); + resolve_jobs(second_texture); } return inputs_; } protected: - void ProcessVideoFootage(TexturePtr destination, const FootageJob *stream, - const rational &input_time) override + void process_video_footage(TexturePtr destination, const FootageJob *stream, + const Rational &input_time) override { Q_UNUSED(destination) if (stream) { @@ -105,11 +105,11 @@ private: QVector inputs_; }; -DecoderPtr ResolveDecoderFromCache(DecoderCache *decoder_cache, +DecoderPtr resolve_decoder_from_cache(DecoderCache *decoder_cache, const QString &decoder_id, const Decoder::CodecStream &stream) { - if (!decoder_cache || !stream.IsValid()) { + if (!decoder_cache || !stream.is_valid()) { return nullptr; } @@ -122,12 +122,12 @@ DecoderPtr ResolveDecoderFromCache(DecoderCache *decoder_cache, return decoder.decoder; } - decoder.decoder = Decoder::CreateFromID(decoder_id); + decoder.decoder = Decoder::create_from_id(decoder_id); decoder.last_modified = file_last_modified; decoder_cache->insert(stream, decoder); locker.unlock(); - if (!decoder.decoder || !decoder.decoder->Open(stream)) { + if (!decoder.decoder || !decoder.decoder->open(stream)) { qWarning() << "RenderWorkerPool failed to open decoder for" << stream.filename() << "::" << stream.stream(); return nullptr; @@ -136,7 +136,7 @@ DecoderPtr ResolveDecoderFromCache(DecoderCache *decoder_cache, return decoder.decoder; } -FramePtr DecodeInputFrame(DecoderCache *decoder_cache, +FramePtr decode_input_frame(DecoderCache *decoder_cache, const FootageInput &input, CancelAtom *cancel) { VideoParams stream_data = input.job.video_params(); @@ -155,19 +155,19 @@ FramePtr DecodeInputFrame(DecoderCache *decoder_cache, DecoderPtr decoder; switch (stream_data.video_type()) { - case VideoParams::kVideoTypeVideo: - case VideoParams::kVideoTypeStill: - decoder = ResolveDecoderFromCache( + case VideoParams::k_video_type_video: + case VideoParams::k_video_type_still: + decoder = resolve_decoder_from_cache( decoder_cache, decoder_id, Decoder::CodecStream(filename, stream_index, nullptr)); break; - case VideoParams::kVideoTypeImageSequence: { + case VideoParams::k_video_type_image_sequence: { const int64_t frame_number = stream_data.get_time_in_timebase_units(input.time); filename = - Decoder::TransformImageSequenceFileName(filename, frame_number); - decoder = Decoder::CreateFromID(decoder_id); - if (decoder && !decoder->Open(Decoder::CodecStream( + Decoder::transform_image_sequence_file_name(filename, frame_number); + decoder = Decoder::create_from_id(decoder_id); + if (decoder && !decoder->open(Decoder::CodecStream( filename, stream_index, nullptr))) { decoder = nullptr; } @@ -181,14 +181,14 @@ FramePtr DecodeInputFrame(DecoderCache *decoder_cache, Decoder::RetrieveVideoParams retrieve; retrieve.divider = stream_data.divider(); - retrieve.maximum_format = PixelFormat::U16; - retrieve.time = stream_data.video_type() == VideoParams::kVideoTypeVideo ? + retrieve.maximum_format = PixelFormat::u16; + retrieve.time = stream_data.video_type() == VideoParams::k_video_type_video ? input.time : - Decoder::kAnyTimecode; + Decoder::k_any_timecode; retrieve.cancelled = cancel; retrieve.force_range = stream_data.color_range(); retrieve.src_interlacing = stream_data.interlacing(); - FramePtr frame = decoder->RetrieveVideoFrame(retrieve); + FramePtr frame = decoder->retrieve_video_frame(retrieve); if (frame) { frame->set_timestamp(input.time); @@ -205,21 +205,21 @@ FramePtr DecodeInputFrame(DecoderCache *decoder_cache, return frame; } -bool DecodeInputFrames(DecoderCache *decoder_cache, +bool decode_input_frames(DecoderCache *decoder_cache, const RenderManager::RenderVideoParams ¶ms, CancelAtom *cancel, QVector *frames) { frames->clear(); FootageInputCollector collector; - const QVector inputs = collector.Collect(params, cancel); + const QVector inputs = collector.collect(params, cancel); frames->reserve(inputs.size()); for (const FootageInput &input : inputs) { - if (cancel && cancel->IsCancelled()) { + if (cancel && cancel->is_cancelled()) { return false; } - FramePtr frame = DecodeInputFrame(decoder_cache, input, cancel); + FramePtr frame = decode_input_frame(decoder_cache, input, cancel); if (!frame || !frame->is_allocated()) { frames->clear(); return false; @@ -230,7 +230,7 @@ bool DecodeInputFrames(DecoderCache *decoder_cache, return true; } -QString WorkerProgramPath() +QString worker_program_path() { #if defined(Q_OS_WIN) const QString file = QStringLiteral("oak-render-worker.exe"); @@ -257,7 +257,7 @@ QString WorkerProgramPath() return candidates.first(); } -bool WriteControlMessage(QProcess *process, const QJsonObject &obj) +bool write_control_message(QProcess *process, const QJsonObject &obj) { if (!process || process->state() != QProcess::Running) { return false; @@ -272,7 +272,7 @@ bool WriteControlMessage(QProcess *process, const QJsonObject &obj) return process->waitForBytesWritten(5000); } -void TryWriteControlMessage(QProcess *process, const QJsonObject &obj) +void try_write_control_message(QProcess *process, const QJsonObject &obj) { if (!process || process->state() != QProcess::Running) { return; @@ -283,7 +283,7 @@ void TryWriteControlMessage(QProcess *process, const QJsonObject &obj) process->write(line); } -bool KillProcessById(qint64 process_id) +bool kill_process_by_id(qint64 process_id) { if (process_id <= 0) { return false; @@ -302,7 +302,7 @@ bool KillProcessById(qint64 process_id) #endif } -bool IsProcessAlive(qint64 process_id) +bool is_process_alive(qint64 process_id) { if (process_id <= 0) { return false; @@ -324,7 +324,7 @@ bool IsProcessAlive(qint64 process_id) #endif } -QString WorkerProcessDetails(const QProcess *process) +QString worker_process_details(const QProcess *process) { if (!process) { return QStringLiteral("worker process unavailable"); @@ -342,18 +342,18 @@ QString WorkerProcessDetails(const QProcess *process) .arg(process->errorString()); } -bool ReadControlMessage(QProcess *process, QJsonObject *out, QString *error, +bool read_control_message(QProcess *process, QJsonObject *out, QString *error, int timeout_ms = 10000) { if (!process->waitForReadyRead(timeout_ms)) { if (error) { if (process->state() == QProcess::NotRunning) { *error = QStringLiteral("worker exited before response: %1") - .arg(WorkerProcessDetails(process)); + .arg(worker_process_details(process)); } else { *error = QStringLiteral("timeout waiting for worker response: %1") - .arg(WorkerProcessDetails(process)); + .arg(worker_process_details(process)); } } return false; @@ -377,7 +377,7 @@ bool ReadControlMessage(QProcess *process, QJsonObject *out, QString *error, *out = doc.object(); if (out->value(QStringLiteral("type")).toString() == - QLatin1String(ipc::msgtype::kError)) { + QLatin1String(ipc::msgtype::k_error)) { if (error) { *error = out->value(QStringLiteral("message")).toString(); } @@ -404,14 +404,14 @@ RenderWorkerPool::RenderWorkerPool(DecoderCache *decoder_cache, RenderWorkerPool::~RenderWorkerPool() { - Shutdown(); + shutdown(); } -bool RenderWorkerPool::SubmitFrame( +bool RenderWorkerPool::submit_frame( RenderTicketPtr ticket, const RenderManager::RenderVideoParams ¶ms) { Job job(ticket, params); - if (!PrepareJob(ticket, params, &job)) { + if (!prepare_job(ticket, params, &job)) { return false; } @@ -423,7 +423,7 @@ bool RenderWorkerPool::SubmitFrame( return true; } -bool RenderWorkerPool::RemoveTicket(RenderTicketPtr ticket) +bool RenderWorkerPool::remove_ticket(RenderTicketPtr ticket) { if (!ticket) { return false; @@ -444,8 +444,8 @@ bool RenderWorkerPool::RemoveTicket(RenderTicketPtr ticket) } else { for (const ActiveJob &active : active_jobs_) { if (active.ticket == ticket) { - ticket->Cancel(); - CancelActiveProcess(active.process_id); + ticket->cancel(); + cancel_active_process(active.process_id); matched_active = true; break; } @@ -457,33 +457,33 @@ bool RenderWorkerPool::RemoveTicket(RenderTicketPtr ticket) } if (!queued_graph_path.isEmpty()) { - ReleaseGraphPathRef(queued_graph_path); + release_graph_path_ref(queued_graph_path); return true; } return true; } -void RenderWorkerPool::Shutdown() +void RenderWorkerPool::shutdown() { { QMutexLocker locker(&mutex_); stopping_ = true; for (Job &job : queue_) { if (job.ticket) { - job.ticket->Cancel(); + job.ticket->cancel(); } - ReleaseGraphPathRefLocked(job.graph_path); + release_graph_path_ref_locked(job.graph_path); } queue_.clear(); for (ActiveJob &active : active_jobs_) { if (active.ticket) { - active.ticket->Cancel(); - CancelActiveProcess(active.process_id); + active.ticket->cancel(); + cancel_active_process(active.process_id); } } for (auto it = graph_cache_.begin(); it != graph_cache_.end(); ++it) { - SetGraphPathCachedLocked(it->path, false); + set_graph_path_cached_locked(it->path, false); } graph_cache_.clear(); wait_.wakeAll(); @@ -496,19 +496,18 @@ void RenderWorkerPool::Shutdown() void RenderWorkerPool::run() { - const int worker_count = WorkerCount(); + const int count = worker_count(); { QMutexLocker locker(&mutex_); - active_jobs_.resize(worker_count); + active_jobs_.resize(count); } - std::vector>> local_pools( - worker_count); + std::vector>> local_pools(count); std::vector workers; - workers.reserve(size_t(worker_count)); - for (int i = 0; i < worker_count; i++) { + workers.reserve(size_t(count)); + for (int i = 0; i < count; i++) { workers.emplace_back( - [this, i, &local_pools]() { WorkerLoop(i, &local_pools[i]); }); + [this, i, &local_pools]() { worker_loop(i, &local_pools[i]); }); } for (std::thread &worker : workers) { @@ -516,16 +515,16 @@ void RenderWorkerPool::run() } for (auto &local_pool : local_pools) { - ShutdownLocalPool(&local_pool); + shutdown_local_pool(&local_pool); } - ClearGraphCache(); + clear_graph_cache(); QMutexLocker locker(&mutex_); active_jobs_.clear(); } -void RenderWorkerPool::WorkerLoop( +void RenderWorkerPool::worker_loop( int worker_index, std::vector> *local_pool) { while (true) { @@ -542,20 +541,20 @@ void RenderWorkerPool::WorkerLoop( queue_.pop_front(); mutex_.unlock(); - ProcessJob(job, worker_index, local_pool); - ReleaseGraphPathRef(job.graph_path); + process_job(job, worker_index, local_pool); + release_graph_path_ref(job.graph_path); } } -bool RenderWorkerPool::PrepareJob(RenderTicketPtr ticket, +bool RenderWorkerPool::prepare_job(RenderTicketPtr ticket, const RenderManager::RenderVideoParams ¶ms, Job *job) { - if (!IsSupported(params)) { + if (!is_supported(params)) { return false; } - Project *project = Project::GetProjectFromObject(params.node); + Project *project = Project::get_project_from_object(params.node); if (!project) { qWarning() << "RenderWorkerPool could not resolve project for render node"; @@ -563,7 +562,7 @@ bool RenderWorkerPool::PrepareJob(RenderTicketPtr ticket, } QVector input_frames; - if (!DecodeInputFrames(decoder_cache_, params, ticket->GetCancelAtom(), + if (!decode_input_frames(decoder_cache_, params, ticket->get_cancel_atom(), &input_frames)) { qWarning() << "RenderWorkerPool could not predecode footage inputs;" << "falling back to in-process render"; @@ -573,19 +572,19 @@ bool RenderWorkerPool::PrepareJob(RenderTicketPtr ticket, QString graph_path; bool wrote_new_snapshot = false; { - const QUuid project_uuid = project->GetUuid(); + const QUuid project_uuid = project->get_uuid(); QMutexLocker locker(&mutex_); auto it = graph_cache_.find(project_uuid); if (it != graph_cache_.end() && !project->is_modified()) { graph_path = it->path; - AddGraphPathRefLocked(graph_path); + add_graph_path_ref_locked(graph_path); } else { if (it != graph_cache_.end()) { - SetGraphPathCachedLocked(it->path, false); + set_graph_path_cached_locked(it->path, false); graph_cache_.erase(it); } locker.unlock(); - if (!WriteGraphSnapshot(project, &graph_path)) { + if (!write_graph_snapshot(project, &graph_path)) { return false; } wrote_new_snapshot = true; @@ -597,8 +596,8 @@ bool RenderWorkerPool::PrepareJob(RenderTicketPtr ticket, } locker.relock(); graph_cache_.insert(project_uuid, { graph_path }); - SetGraphPathCachedLocked(graph_path, true); - AddGraphPathRefLocked(graph_path); + set_graph_path_cached_locked(graph_path, true); + add_graph_path_ref_locked(graph_path); } } @@ -611,7 +610,7 @@ bool RenderWorkerPool::PrepareJob(RenderTicketPtr ticket, return true; } -bool RenderWorkerPool::WriteGraphSnapshot(Project *project, QString *path) +bool RenderWorkerPool::write_graph_snapshot(Project *project, QString *path) { // Keep snapshots in the system temp directory. The previous bug was not the // temp location itself, but stale snapshots being deleted while queued jobs @@ -629,15 +628,15 @@ bool RenderWorkerPool::WriteGraphSnapshot(Project *project, QString *path) } QXmlStreamWriter writer(&file); - ProjectSerializer::SaveData data(ProjectSerializer::kProject, project, + ProjectSerializer::SaveData data(ProjectSerializer::k_project, project, file.fileName()); const ProjectSerializer::Result result = - ProjectSerializer::Save(&writer, data); + ProjectSerializer::save(&writer, data); file.close(); - if (result.code() != ProjectSerializer::kSuccess || writer.hasError()) { + if (result.code() != ProjectSerializer::k_success || writer.hasError()) { qWarning() << "RenderWorkerPool failed to serialize graph snapshot" - << result.GetDetails(); + << result.get_details(); QFile::remove(file.fileName()); return false; } @@ -646,41 +645,41 @@ bool RenderWorkerPool::WriteGraphSnapshot(Project *project, QString *path) return true; } -bool RenderWorkerPool::IsSupported( +bool RenderWorkerPool::is_supported( const RenderManager::RenderVideoParams ¶ms) const { - return params.node && params.return_type == RenderManager::kFrame && + return params.node && params.return_type == RenderManager::k_frame && params.video_params.is_valid(); } -void RenderWorkerPool::ProcessJob( +void RenderWorkerPool::process_job( const Job &job, int worker_index, std::vector> *local_pool) { const qint64 ticket_id = qint64(reinterpret_cast(job.ticket.get())); - SetActiveWorker(worker_index, job.ticket, nullptr, ticket_id); + set_active_worker(worker_index, job.ticket, nullptr, ticket_id); - job.ticket->Start(); - if (job.ticket->IsCancelled()) { - job.ticket->Finish(); - ClearActiveWorker(worker_index, 0); + job.ticket->start(); + if (job.ticket->is_cancelled()) { + job.ticket->finish(); + clear_active_worker(worker_index, 0); return; } std::unique_ptr worker = - AcquireWorker(local_pool, job.graph_path); + acquire_worker(local_pool, job.graph_path); if (!worker) { qWarning() << "RenderWorkerPool failed to acquire worker for ticket" << ticket_id; - job.ticket->Finish(); - ClearActiveWorker(worker_index, 0); + job.ticket->finish(); + clear_active_worker(worker_index, 0); return; } - for (int attempt = 0; attempt < kMaxAttempts; attempt++) { + for (int attempt = 0; attempt < k_max_attempts; attempt++) { if (attempt > 0) { - worker = AcquireWorker(local_pool, job.graph_path); + worker = acquire_worker(local_pool, job.graph_path); if (!worker) { qWarning() << "RenderWorkerPool failed to acquire worker for retry" @@ -690,60 +689,60 @@ void RenderWorkerPool::ProcessJob( } const JobResult result = - ProcessJobAttempt(job, worker_index, attempt, worker.get()); + process_job_attempt(job, worker_index, attempt, worker.get()); const qint64 worker_pid = worker && worker->process ? worker->process->processId() : 0; const bool process_state_running = worker && worker->process && worker->process->state() == QProcess::Running; - const bool os_alive = worker_pid > 0 && IsProcessAlive(worker_pid); + const bool os_alive = worker_pid > 0 && is_process_alive(worker_pid); const bool worker_healthy = process_state_running || os_alive; - const bool keep_alive = (result == JobResult::kFinished) && + const bool keep_alive = (result == JobResult::k_finished) && worker_healthy; - ReturnWorker(local_pool, std::move(worker), keep_alive); + return_worker(local_pool, std::move(worker), keep_alive); worker.reset(); - if (result == JobResult::kFinished) { - ClearActiveWorker(worker_index, 0); + if (result == JobResult::k_finished) { + clear_active_worker(worker_index, 0); return; } - if (result == JobResult::kCancelled) { - job.ticket->Finish(); - ClearActiveWorker(worker_index, 0); + if (result == JobResult::k_cancelled) { + job.ticket->finish(); + clear_active_worker(worker_index, 0); return; } - if (result == JobResult::kFatalFailure) { + if (result == JobResult::k_fatal_failure) { break; } - if (attempt + 1 < kMaxAttempts && !job.ticket->IsCancelled()) { + if (attempt + 1 < k_max_attempts && !job.ticket->is_cancelled()) { qWarning() << "RenderWorkerPool retrying render worker for ticket" << ticket_id << "after worker failure"; } } - if (job.ticket->IsCancelled()) { - job.ticket->Finish(); + if (job.ticket->is_cancelled()) { + job.ticket->finish(); } else { qWarning() << "RenderWorkerPool exhausted worker retries for ticket" << ticket_id; - job.ticket->Finish(); + job.ticket->finish(); } - ClearActiveWorker(worker_index, 0); + clear_active_worker(worker_index, 0); } RenderWorkerPool::JobResult -RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, +RenderWorkerPool::process_job_attempt(const Job &job, int worker_index, int attempt_index, PooledWorker *worker) { const qint64 ticket_id = qint64(reinterpret_cast(job.ticket.get())); - if (job.ticket->IsCancelled()) { - return JobResult::kCancelled; + if (job.ticket->is_cancelled()) { + return JobResult::k_cancelled; } if (!worker || !worker->process) { - return JobResult::kRetryableFailure; + return JobResult::k_retryable_failure; } const qint64 worker_process_id = worker->process->processId(); @@ -755,18 +754,18 @@ RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, job.params.force_size.height() : job.params.video_params.effective_height(); const PixelFormat::Format output_format = - job.params.force_format != PixelFormat::INVALID ? + job.params.force_format != PixelFormat::invalid ? PixelFormat::Format(job.params.force_format) : - PixelFormat::F32; + PixelFormat::f32; const int output_channels = job.params.force_channel_count > 0 ? job.params.force_channel_count : - VideoParams::kRGBAChannelCount; + VideoParams::k_rgba_channel_count; const int output_linesize = Frame::generate_linesize_bytes( output_width, output_format, output_channels); const size_t estimated_output_slot_bytes = size_t(output_linesize) * size_t(output_height); const int f32_rgba_linesize = Frame::generate_linesize_bytes( - output_width, PixelFormat::F32, VideoParams::kRGBAChannelCount); + output_width, PixelFormat::f32, VideoParams::k_rgba_channel_count); const size_t f32_rgba_slot_bytes = size_t(f32_rgba_linesize) * size_t(output_height); const size_t output_slot_bytes = @@ -779,29 +778,29 @@ RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, } } const size_t output_region_bytes = - ipc::FrameSlotPool::BytesNeeded(kOutputSlots, output_slot_bytes); + ipc::FrameSlotPool::bytes_needed(k_output_slots, output_slot_bytes); - if (!worker->output_region.IsValid() || + if (!worker->output_region.is_valid() || worker->output_slot_bytes < output_slot_bytes) { - if (worker->output_region.IsValid()) { - worker->output_region.Close(); + if (worker->output_region.is_valid()) { + worker->output_region.close(); worker->output_pool = ipc::FrameSlotPool(); } if (worker->output_shm_key.isEmpty()) { worker->output_shm_key = - ipc::SharedMemoryRegion::MakeKey(worker_process_id, 0) + + ipc::SharedMemoryRegion::make_key(worker_process_id, 0) + QStringLiteral("-out"); } - if (!worker->output_region.Open(worker->output_shm_key, + if (!worker->output_region.open(worker->output_shm_key, output_region_bytes, - ipc::SharedMemoryRegion::kCreate)) { + ipc::SharedMemoryRegion::k_create)) { qWarning() << "RenderWorkerPool failed to create output shared memory" << worker->output_region.error(); - return JobResult::kFatalFailure; + return JobResult::k_fatal_failure; } - worker->output_pool = ipc::FrameSlotPool::Create( - worker->output_region.data(), kOutputSlots, output_slot_bytes); + worker->output_pool = ipc::FrameSlotPool::create( + worker->output_region.data(), k_output_slots, output_slot_bytes); worker->output_slot_bytes = output_slot_bytes; } const QString shm_key = worker->output_shm_key; @@ -810,30 +809,30 @@ RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, const uint32_t input_slot_count = job.input_frames.isEmpty() ? 0 : uint32_t(job.input_frames.size()); if (input_slot_count > 0) { - if (!worker->input_region.IsValid() || + if (!worker->input_region.is_valid() || worker->input_slot_bytes < input_slot_bytes || worker->input_pool.slot_count() < input_slot_count) { - if (worker->input_region.IsValid()) { - worker->input_region.Close(); + if (worker->input_region.is_valid()) { + worker->input_region.close(); worker->input_pool = ipc::FrameSlotPool(); } if (worker->input_shm_key.isEmpty()) { worker->input_shm_key = - ipc::SharedMemoryRegion::MakeKey(worker_process_id, 1) + + ipc::SharedMemoryRegion::make_key(worker_process_id, 1) + QStringLiteral("-in"); } - const size_t input_region_bytes = ipc::FrameSlotPool::BytesNeeded( + const size_t input_region_bytes = ipc::FrameSlotPool::bytes_needed( input_slot_count, input_slot_bytes); - if (!worker->input_region.Open(worker->input_shm_key, + if (!worker->input_region.open(worker->input_shm_key, input_region_bytes, - ipc::SharedMemoryRegion::kCreate)) { + ipc::SharedMemoryRegion::k_create)) { qWarning() << "RenderWorkerPool failed to create input shared memory" << worker->input_region.error(); - return JobResult::kFatalFailure; + return JobResult::k_fatal_failure; } worker->input_pool = - ipc::FrameSlotPool::Create(worker->input_region.data(), + ipc::FrameSlotPool::create(worker->input_region.data(), input_slot_count, input_slot_bytes); worker->input_slot_bytes = input_slot_bytes; } @@ -846,18 +845,18 @@ RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, if (frame->allocated_size() > int(worker->input_slot_bytes)) { qWarning() << "RenderWorkerPool decoded input frame exceeds slot size"; - return JobResult::kFatalFailure; + return JobResult::k_fatal_failure; } uint32_t slot = 0; - if (!input_pool.Acquire(&slot)) { + if (!input_pool.acquire(&slot)) { qWarning() << "RenderWorkerPool input pool had no free slot"; - return JobResult::kFatalFailure; + return JobResult::k_fatal_failure; } - memcpy(input_pool.SlotData(slot), frame->const_data(), + memcpy(input_pool.slot_data(slot), frame->const_data(), size_t(frame->allocated_size())); - ipc::FrameSlotMeta *meta = input_pool.Meta(slot); + ipc::FrameSlotMeta *meta = input_pool.meta(slot); meta->id = qint64(input_slots.size()); meta->time_num = frame->timestamp().numerator(); meta->time_den = frame->timestamp().denominator(); @@ -877,9 +876,9 @@ RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, memcpy(meta->colorspace, cs_utf8.constData(), copy_len); meta->colorspace[copy_len] = '\0'; } - if (!input_pool.Publish(slot)) { + if (!input_pool.publish(slot)) { qWarning() << "RenderWorkerPool failed to publish input slot"; - return JobResult::kFatalFailure; + return JobResult::k_fatal_failure; } input_slots.append(int(slot)); } @@ -887,36 +886,36 @@ RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, if (input_slots.size() != job.input_frames.size()) { qWarning() << "RenderWorkerPool failed to publish all input frames;" << "aborting worker render"; - return JobResult::kFatalFailure; + return JobResult::k_fatal_failure; } } - SetActiveWorker(worker_index, job.ticket, worker->process, ticket_id); - if (job.ticket->IsCancelled()) { + set_active_worker(worker_index, job.ticket, worker->process, ticket_id); + if (job.ticket->is_cancelled()) { ipc::CancelMsg cancel; cancel.ticket_id = ticket_id; - TryWriteControlMessage(worker->process, cancel.ToJson()); - ClearActiveWorker(worker_index, worker_process_id); - return JobResult::kCancelled; + try_write_control_message(worker->process, cancel.to_json()); + clear_active_worker(worker_index, worker_process_id); + return JobResult::k_cancelled; } ipc::HandshakeMsg handshake; - handshake.protocol_version = kProtocolVersion; + handshake.protocol_version = k_protocol_version; handshake.shm_key = shm_key; handshake.input_shm_key = input_slots.isEmpty() ? QString() : input_shm_key; handshake.input_slots = input_slots.size(); - handshake.output_slots = int(kOutputSlots); + handshake.output_slots = int(k_output_slots); handshake.slot_data_bytes = qint64(output_slot_bytes); handshake.input_slot_data_bytes = input_slots.isEmpty() ? 0 : qint64(input_slot_bytes); - if (!WriteControlMessage(worker->process, handshake.ToJson())) { - if (!job.ticket->IsCancelled()) { + if (!write_control_message(worker->process, handshake.to_json())) { + if (!job.ticket->is_cancelled()) { qWarning() << "RenderWorkerPool failed to send shared-memory handshake"; } - ClearActiveWorker(worker_index, worker_process_id); - return job.ticket->IsCancelled() ? JobResult::kCancelled : - JobResult::kRetryableFailure; + clear_active_worker(worker_index, worker_process_id); + return job.ticket->is_cancelled() ? JobResult::k_cancelled : + JobResult::k_retryable_failure; } if (worker->loaded_graph_path != job.graph_path) { @@ -924,15 +923,15 @@ RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, load.path = job.graph_path; QString error; QJsonObject response; - if (!WriteControlMessage(worker->process, load.ToJson()) || - !ReadControlMessage(worker->process, &response, &error)) { - if (!job.ticket->IsCancelled()) { + if (!write_control_message(worker->process, load.to_json()) || + !read_control_message(worker->process, &response, &error)) { + if (!job.ticket->is_cancelled()) { qWarning() << "RenderWorkerPool failed to load graph in worker" << error << worker->process->readAllStandardError(); } - ClearActiveWorker(worker_index, worker_process_id); - return job.ticket->IsCancelled() ? JobResult::kCancelled : - JobResult::kRetryableFailure; + clear_active_worker(worker_index, worker_process_id); + return job.ticket->is_cancelled() ? JobResult::k_cancelled : + JobResult::k_retryable_failure; } worker->loaded_graph_path = job.graph_path; } @@ -956,62 +955,62 @@ RenderWorkerPool::ProcessJobAttempt(const Job &job, int worker_index, render.color_view = ct.view(); render.color_look = ct.look(); - if (!WriteControlMessage(worker->process, render.ToJson())) { - if (!job.ticket->IsCancelled()) { + if (!write_control_message(worker->process, render.to_json())) { + if (!job.ticket->is_cancelled()) { qWarning() << "RenderWorkerPool failed to send render_frame"; } - ClearActiveWorker(worker_index, worker_process_id); - return job.ticket->IsCancelled() ? JobResult::kCancelled : - JobResult::kRetryableFailure; + clear_active_worker(worker_index, worker_process_id); + return job.ticket->is_cancelled() ? JobResult::k_cancelled : + JobResult::k_retryable_failure; } QString error; QJsonObject response; ipc::FrameReadyMsg ready; while (true) { - if (!ReadControlMessage(worker->process, &response, &error, 30000)) { - if (!job.ticket->IsCancelled()) { + if (!read_control_message(worker->process, &response, &error, 30000)) { + if (!job.ticket->is_cancelled()) { qWarning() << "RenderWorkerPool failed waiting for frame_ready" << error << worker->process->readAllStandardError(); } - ClearActiveWorker(worker_index, worker_process_id); - return job.ticket->IsCancelled() ? JobResult::kCancelled : - JobResult::kRetryableFailure; + clear_active_worker(worker_index, worker_process_id); + return job.ticket->is_cancelled() ? JobResult::k_cancelled : + JobResult::k_retryable_failure; } - if (ipc::FrameReadyMsg::FromJson(response, &ready)) { + if (ipc::FrameReadyMsg::from_json(response, &ready)) { break; } } - if (job.ticket->IsCancelled()) { - ClearActiveWorker(worker_index, worker_process_id); - return JobResult::kCancelled; + if (job.ticket->is_cancelled()) { + clear_active_worker(worker_index, worker_process_id); + return JobResult::k_cancelled; } uint32_t consumed_slot = 0; - if (!output_pool.Consume(&consumed_slot)) { + if (!output_pool.consume(&consumed_slot)) { qWarning() << "RenderWorkerPool failed to consume output slot"; - ClearActiveWorker(worker_index, worker_process_id); - return JobResult::kRetryableFailure; + clear_active_worker(worker_index, worker_process_id); + return JobResult::k_retryable_failure; } if (int(consumed_slot) != ready.output_slot) { qWarning() << "RenderWorkerPool output slot mismatch: consumed" << consumed_slot << "expected" << ready.output_slot; } - FinishWithFrame(job.ticket, output_pool, consumed_slot); - output_pool.Release(consumed_slot); - ClearActiveWorker(worker_index, worker_process_id); + finish_with_frame(job.ticket, output_pool, consumed_slot); + output_pool.release(consumed_slot); + clear_active_worker(worker_index, worker_process_id); - return JobResult::kFinished; + return JobResult::k_finished; } -void RenderWorkerPool::CancelActiveProcess(qint64 process_id) +void RenderWorkerPool::cancel_active_process(qint64 process_id) { - KillProcessById(process_id); + kill_process_by_id(process_id); } -void RenderWorkerPool::SetActiveWorker(int worker_index, RenderTicketPtr ticket, +void RenderWorkerPool::set_active_worker(int worker_index, RenderTicketPtr ticket, QProcess *worker, qint64 ticket_id) { QMutexLocker locker(&mutex_); @@ -1025,7 +1024,7 @@ void RenderWorkerPool::SetActiveWorker(int worker_index, RenderTicketPtr ticket, active.ticket_id = ticket_id; } -void RenderWorkerPool::ClearActiveWorker(int worker_index, qint64 process_id) +void RenderWorkerPool::clear_active_worker(int worker_index, qint64 process_id) { QMutexLocker locker(&mutex_); if (worker_index < 0 || worker_index >= active_jobs_.size()) { @@ -1042,7 +1041,7 @@ void RenderWorkerPool::ClearActiveWorker(int worker_index, qint64 process_id) } } -int RenderWorkerPool::WorkerCount() const +int RenderWorkerPool::worker_count() const { // GPU rendering is the bottleneck for video frames; too many workers just // multiply first-frame warmup (shader/OCIO cache creation) and compete for @@ -1051,7 +1050,7 @@ int RenderWorkerPool::WorkerCount() const return std::max(1, std::min(ideal - 2, 4)); } -std::unique_ptr RenderWorkerPool::AcquireWorker( +std::unique_ptr RenderWorkerPool::acquire_worker( std::vector> *local_pool, const QString &graph_path) { @@ -1072,14 +1071,14 @@ std::unique_ptr RenderWorkerPool::AcquireWorker( const bool candidate_state_running = candidate->process->state() == QProcess::Running; const bool candidate_os_alive = - IsProcessAlive(candidate->process->processId()); + is_process_alive(candidate->process->processId()); if (!candidate_state_running && !candidate_os_alive) { - ShutdownWorker(candidate); + shutdown_worker(candidate); local_pool->erase(local_pool->begin() + i); continue; } - if (now - candidate->last_used_ms > kWorkerIdleTimeoutMs) { - ShutdownWorker(candidate); + if (now - candidate->last_used_ms > k_worker_idle_timeout_ms) { + shutdown_worker(candidate); local_pool->erase(local_pool->begin() + i); continue; } @@ -1104,7 +1103,7 @@ std::unique_ptr RenderWorkerPool::AcquireWorker( // No idle worker available: start a new one. auto *process = new QProcess(); - process->setProgram(WorkerProgramPath()); + process->setProgram(worker_program_path()); process->setArguments({ QStringLiteral("--backend"), gpu_backend_ }); const QString worker_stderr_path = @@ -1124,7 +1123,7 @@ std::unique_ptr RenderWorkerPool::AcquireWorker( QString error; QJsonObject response; - if (!ReadControlMessage(process, &response, &error)) { + if (!read_control_message(process, &response, &error)) { qWarning() << "RenderWorkerPool did not receive startup handshake" << error << process->readAllStandardError(); process->kill(); @@ -1140,7 +1139,7 @@ std::unique_ptr RenderWorkerPool::AcquireWorker( return worker; } -void RenderWorkerPool::ReturnWorker( +void RenderWorkerPool::return_worker( std::vector> *local_pool, std::unique_ptr worker, bool keep_alive) { @@ -1148,9 +1147,9 @@ void RenderWorkerPool::ReturnWorker( return; } - const bool pool_full = worker->use_count >= kWorkerMaxUses; + const bool pool_full = worker->use_count >= k_worker_max_uses; if (!keep_alive || stopping_ || pool_full) { - ShutdownWorker(worker.get()); + shutdown_worker(worker.get()); return; } @@ -1158,7 +1157,7 @@ void RenderWorkerPool::ReturnWorker( local_pool->push_back(std::move(worker)); } -void RenderWorkerPool::ShutdownWorker(PooledWorker *worker) +void RenderWorkerPool::shutdown_worker(PooledWorker *worker) { if (!worker || !worker->process) { return; @@ -1171,8 +1170,8 @@ void RenderWorkerPool::ShutdownWorker(PooledWorker *worker) if (process->state() == QProcess::Running) { QJsonObject shutdown; - shutdown[QStringLiteral("type")] = ipc::msgtype::kShutdown; - TryWriteControlMessage(process, shutdown); + shutdown[QStringLiteral("type")] = ipc::msgtype::k_shutdown; + try_write_control_message(process, shutdown); process->closeWriteChannel(); if (!process->waitForFinished(5000)) { process->kill(); @@ -1182,68 +1181,68 @@ void RenderWorkerPool::ShutdownWorker(PooledWorker *worker) delete process; } -void RenderWorkerPool::ShutdownLocalPool( +void RenderWorkerPool::shutdown_local_pool( std::vector> *local_pool) { if (!local_pool) { return; } for (std::unique_ptr &worker : *local_pool) { - ShutdownWorker(worker.get()); + shutdown_worker(worker.get()); } local_pool->clear(); } -void RenderWorkerPool::ClearGraphCache() +void RenderWorkerPool::clear_graph_cache() { QMutexLocker locker(&mutex_); for (auto it = graph_cache_.begin(); it != graph_cache_.end(); ++it) { - SetGraphPathCachedLocked(it->path, false); + set_graph_path_cached_locked(it->path, false); } graph_cache_.clear(); graph_path_ref_count_.clear(); cached_graph_paths_.clear(); } -void RenderWorkerPool::FinishWithFrame(RenderTicketPtr ticket, +void RenderWorkerPool::finish_with_frame(RenderTicketPtr ticket, const ipc::FrameSlotPool &pool, uint32_t slot) { - const ipc::FrameSlotMeta *meta = pool.Meta(slot); + const ipc::FrameSlotMeta *meta = pool.meta(slot); if (!meta || meta->data_size <= 0 || meta->data_size > int(pool.slot_data_bytes())) { - ticket->Finish(); + ticket->finish(); return; } VideoParams params(meta->width, meta->height, PixelFormat::Format(meta->format), meta->channel_count); - FramePtr frame = Frame::Create(); - frame->set_timestamp(rational(int(meta->time_num), int(meta->time_den))); + FramePtr frame = Frame::create(); + frame->set_timestamp(Rational(int(meta->time_num), int(meta->time_den))); frame->set_video_params(params); if (!frame->allocate() || frame->allocated_size() < meta->data_size) { - ticket->Finish(); + ticket->finish(); return; } - memcpy(frame->data(), pool.SlotData(slot), size_t(meta->data_size)); - ticket->Finish(QVariant::fromValue(frame)); + memcpy(frame->data(), pool.slot_data(slot), size_t(meta->data_size)); + ticket->finish(QVariant::fromValue(frame)); } -void RenderWorkerPool::CleanupGraphFile(const QString &path) +void RenderWorkerPool::cleanup_graph_file(const QString &path) { if (!path.isEmpty()) { QFile::remove(path); } } -void RenderWorkerPool::AddGraphPathRef(const QString &path) +void RenderWorkerPool::add_graph_path_ref(const QString &path) { QMutexLocker locker(&mutex_); - AddGraphPathRefLocked(path); + add_graph_path_ref_locked(path); } -void RenderWorkerPool::AddGraphPathRefLocked(const QString &path) +void RenderWorkerPool::add_graph_path_ref_locked(const QString &path) { if (path.isEmpty()) { return; @@ -1251,13 +1250,13 @@ void RenderWorkerPool::AddGraphPathRefLocked(const QString &path) ++graph_path_ref_count_[path]; } -void RenderWorkerPool::ReleaseGraphPathRef(const QString &path) +void RenderWorkerPool::release_graph_path_ref(const QString &path) { QMutexLocker locker(&mutex_); - ReleaseGraphPathRefLocked(path); + release_graph_path_ref_locked(path); } -void RenderWorkerPool::ReleaseGraphPathRefLocked(const QString &path) +void RenderWorkerPool::release_graph_path_ref_locked(const QString &path) { if (path.isEmpty()) { return; @@ -1269,18 +1268,18 @@ void RenderWorkerPool::ReleaseGraphPathRefLocked(const QString &path) if (--(*it) <= 0) { graph_path_ref_count_.erase(it); if (!cached_graph_paths_.contains(path)) { - CleanupGraphFile(path); + cleanup_graph_file(path); } } } -void RenderWorkerPool::SetGraphPathCached(const QString &path, bool cached) +void RenderWorkerPool::set_graph_path_cached(const QString &path, bool cached) { QMutexLocker locker(&mutex_); - SetGraphPathCachedLocked(path, cached); + set_graph_path_cached_locked(path, cached); } -void RenderWorkerPool::SetGraphPathCachedLocked(const QString &path, +void RenderWorkerPool::set_graph_path_cached_locked(const QString &path, bool cached) { if (path.isEmpty()) { @@ -1291,7 +1290,7 @@ void RenderWorkerPool::SetGraphPathCachedLocked(const QString &path, } else { cached_graph_paths_.remove(path); if (!graph_path_ref_count_.contains(path)) { - CleanupGraphFile(path); + cleanup_graph_file(path); } } } diff --git a/app/render/renderworkerpool.h b/app/render/renderworkerpool.h index fa5be97a7..f50815ce2 100644 --- a/app/render/renderworkerpool.h +++ b/app/render/renderworkerpool.h @@ -18,8 +18,8 @@ ***/ -#ifndef RENDERWORKERPOOL_H -#define RENDERWORKERPOOL_H +#ifndef OAK_RENDERWORKERPOOL_H +#define OAK_RENDERWORKERPOOL_H #include #include @@ -52,12 +52,12 @@ public: QObject *parent = nullptr); ~RenderWorkerPool() override; - bool SubmitFrame(RenderTicketPtr ticket, + bool submit_frame(RenderTicketPtr ticket, const RenderManager::RenderVideoParams ¶ms); - bool RemoveTicket(RenderTicketPtr ticket); + bool remove_ticket(RenderTicketPtr ticket); - void Shutdown(); + void shutdown(); protected: void run() override; @@ -78,10 +78,10 @@ private: }; enum class JobResult { - kFinished, - kRetryableFailure, - kFatalFailure, - kCancelled + k_finished, + k_retryable_failure, + k_fatal_failure, + k_cancelled }; struct ActiveJob { @@ -113,41 +113,41 @@ private: QString path; }; - bool PrepareJob(RenderTicketPtr ticket, + bool prepare_job(RenderTicketPtr ticket, const RenderManager::RenderVideoParams ¶ms, Job *job); - bool WriteGraphSnapshot(Project *project, QString *path); - bool IsSupported(const RenderManager::RenderVideoParams ¶ms) const; + bool write_graph_snapshot(Project *project, QString *path); + bool is_supported(const RenderManager::RenderVideoParams ¶ms) const; - void WorkerLoop(int worker_index, + void worker_loop(int worker_index, std::vector> *local_pool); - void ProcessJob(const Job &job, int worker_index, + void process_job(const Job &job, int worker_index, std::vector> *local_pool); - JobResult ProcessJobAttempt(const Job &job, int worker_index, + JobResult process_job_attempt(const Job &job, int worker_index, int attempt_index, PooledWorker *worker); - void FinishWithFrame(RenderTicketPtr ticket, const ipc::FrameSlotPool &pool, + void finish_with_frame(RenderTicketPtr ticket, const ipc::FrameSlotPool &pool, uint32_t slot); - void CleanupGraphFile(const QString &path); - void AddGraphPathRef(const QString &path); - void AddGraphPathRefLocked(const QString &path); - void ReleaseGraphPathRef(const QString &path); - void ReleaseGraphPathRefLocked(const QString &path); - void SetGraphPathCached(const QString &path, bool cached); - void SetGraphPathCachedLocked(const QString &path, bool cached); - void CancelActiveProcess(qint64 process_id); - void SetActiveWorker(int worker_index, RenderTicketPtr ticket, + void cleanup_graph_file(const QString &path); + void add_graph_path_ref(const QString &path); + void add_graph_path_ref_locked(const QString &path); + void release_graph_path_ref(const QString &path); + void release_graph_path_ref_locked(const QString &path); + void set_graph_path_cached(const QString &path, bool cached); + void set_graph_path_cached_locked(const QString &path, bool cached); + void cancel_active_process(qint64 process_id); + void set_active_worker(int worker_index, RenderTicketPtr ticket, QProcess *worker, qint64 ticket_id); - void ClearActiveWorker(int worker_index, qint64 process_id); - int WorkerCount() const; + void clear_active_worker(int worker_index, qint64 process_id); + int worker_count() const; std::unique_ptr - AcquireWorker(std::vector> *local_pool, + acquire_worker(std::vector> *local_pool, const QString &graph_path); - void ReturnWorker(std::vector> *local_pool, + void return_worker(std::vector> *local_pool, std::unique_ptr worker, bool keep_alive); - void ShutdownWorker(PooledWorker *worker); + void shutdown_worker(PooledWorker *worker); void - ShutdownLocalPool(std::vector> *local_pool); - void ClearGraphCache(); + shutdown_local_pool(std::vector> *local_pool); + void clear_graph_cache(); DecoderCache *decoder_cache_; QString gpu_backend_; @@ -160,14 +160,14 @@ private: QHash graph_path_ref_count_; QSet cached_graph_paths_; - static constexpr uint32_t kOutputSlots = 2; - static constexpr int kMaxAttempts = 2; - static constexpr int kMaxWidth = 4096; - static constexpr int kMaxHeight = 2160; - static constexpr int kWorkerIdleTimeoutMs = 30000; - static constexpr int kWorkerMaxUses = 100; + static constexpr uint32_t k_output_slots = 2; + static constexpr int k_max_attempts = 2; + static constexpr int k_max_width = 4096; + static constexpr int k_max_height = 2160; + static constexpr int k_worker_idle_timeout_ms = 30000; + static constexpr int k_worker_max_uses = 100; }; } -#endif // RENDERWORKERPOOL_H +#endif // OAK_RENDERWORKERPOOL_H diff --git a/app/render/shadercode.h b/app/render/shadercode.h index 9feab9f47..e2209d753 100644 --- a/app/render/shadercode.h +++ b/app/render/shadercode.h @@ -19,8 +19,8 @@ ***/ -#ifndef SHADERCODE_H -#define SHADERCODE_H +#ifndef OAK_SHADERCODE_H +#define OAK_SHADERCODE_H #include "common/filefunctions.h" @@ -62,4 +62,4 @@ private: } -#endif // SHADERCODE_H +#endif // OAK_SHADERCODE_H diff --git a/app/render/subtitleparams.cpp b/app/render/subtitleparams.cpp index 70ef9e096..660112159 100644 --- a/app/render/subtitleparams.cpp +++ b/app/render/subtitleparams.cpp @@ -28,24 +28,24 @@ namespace olive { -QString SubtitleParams::GenerateASSHeader() +QString SubtitleParams::generate_ass_header() { // NOTE: We'll probably implement more customization as we support ASS better. Right now, we only // natively support SRT and only make this header because FFmpeg requires it. - static const int kAssDefaultPlayResX = 384; - static const int kAssDefaultPlayResY = 288; - static const QString kAssDefaultFont = QStringLiteral("Arial"); - static const int kAssDefaultFontSize = 16; - static const int kAssDefaultPrimaryColor = 0xFFFFFF; // White - static const int kAssDefaultSecondaryColor = 0xFFFFFF; // White - static const int kAssDefaultOutlineColor = 0x000000; // Black - static const int kAssDefaultBackColor = 0x000000; // Black - static const int kAssBold = 0; - static const int kAssItalic = 0; - static const int kAssUnderline = 0; - static const int kAssStrike = 0; - static const int kAssBorderStyle = 1; - static const int kAssAlignment = 2; + static const int k_ass_default_play_res_x = 384; + static const int k_ass_default_play_res_y = 288; + static const QString k_ass_default_font = QStringLiteral("Arial"); + static const int k_ass_default_font_size = 16; + static const int k_ass_default_primary_color = 0xFFFFFF; // White + static const int k_ass_default_secondary_color = 0xFFFFFF; // White + static const int k_ass_default_outline_color = 0x000000; // Black + static const int k_ass_default_back_color = 0x000000; // Black + static const int k_ass_bold = 0; + static const int k_ass_italic = 0; + static const int k_ass_underline = 0; + static const int k_ass_strike = 0; + static const int k_ass_border_style = 1; + static const int k_ass_alignment = 2; QString ass_code; @@ -56,9 +56,9 @@ QString SubtitleParams::GenerateASSHeader() QCoreApplication::applicationVersion())); ass_code.append(QStringLiteral("ScriptType: v4.00+\r\n")); ass_code.append(QStringLiteral("PlayResX: %1\r\n") - .arg(QString::number(kAssDefaultPlayResX))); + .arg(QString::number(k_ass_default_play_res_x))); ass_code.append(QStringLiteral("PlayResY: %1\r\n") - .arg(QString::number(kAssDefaultPlayResY))); + .arg(QString::number(k_ass_default_play_res_y))); ass_code.append(QStringLiteral("ScaledBorderAndShadow: yes\r\n")); ass_code.append(QStringLiteral("\r\n")); @@ -81,20 +81,20 @@ QString SubtitleParams::GenerateASSHeader() // Font{name,size} ass_code.append(QStringLiteral("%1,%2,").arg( - kAssDefaultFont, QString::number(kAssDefaultFontSize))); + k_ass_default_font, QString::number(k_ass_default_font_size))); // {Primary,Secondary,Outline,Back}Colour ass_code.append(QStringLiteral("&H%1,&H%2,&H%3,&H%4,") - .arg(QString::number(kAssDefaultPrimaryColor, 16), - QString::number(kAssDefaultSecondaryColor, 16), - QString::number(kAssDefaultOutlineColor, 16), - QString::number(kAssDefaultBackColor, 16))); + .arg(QString::number(k_ass_default_primary_color, 16), + QString::number(k_ass_default_secondary_color, 16), + QString::number(k_ass_default_outline_color, 16), + QString::number(k_ass_default_back_color, 16))); // Bold, Italic, Underline, StrikeOut ass_code.append( QStringLiteral("%1,%2,%3,%4,") - .arg(QString::number(kAssBold), QString::number(kAssItalic), - QString::number(kAssUnderline), QString::number(kAssStrike))); + .arg(QString::number(k_ass_bold), QString::number(k_ass_italic), + QString::number(k_ass_underline), QString::number(k_ass_strike))); // Scale{X,Y} ass_code.append(QStringLiteral("100,100,")); @@ -104,11 +104,11 @@ QString SubtitleParams::GenerateASSHeader() // BorderStyle, Outline, Shadow ass_code.append( - QStringLiteral("%1,1,0,").arg(QString::number(kAssBorderStyle))); + QStringLiteral("%1,1,0,").arg(QString::number(k_ass_border_style))); // Alignment, Margin[LRV] ass_code.append( - QStringLiteral("%1,10,10,10,").arg(QString::number(kAssAlignment))); + QStringLiteral("%1,10,10,10,").arg(QString::number(k_ass_alignment))); // Encoding ass_code.append(QStringLiteral("0\r\n")); @@ -120,28 +120,28 @@ QString SubtitleParams::GenerateASSHeader() return ass_code; } -void SubtitleParams::Load(QXmlStreamReader *reader) +void SubtitleParams::load(QXmlStreamReader *reader) { this->clear(); - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("streamindex")) { set_stream_index(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("enabled")) { set_enabled(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("subtitles")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("subtitle")) { - rational in, out; + Rational in, out; QString text; XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("in")) { - in = rational::fromString( + in = Rational::from_string( attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { - out = rational::fromString( + out = Rational::from_string( attr.value().toString().toStdString()); } } @@ -159,7 +159,7 @@ void SubtitleParams::Load(QXmlStreamReader *reader) } } -void SubtitleParams::Save(QXmlStreamWriter *writer) const +void SubtitleParams::save(QXmlStreamWriter *writer) const { writer->writeTextElement(QStringLiteral("streamindex"), QString::number(stream_index_)); @@ -171,10 +171,10 @@ void SubtitleParams::Save(QXmlStreamWriter *writer) const writer->writeStartElement(QStringLiteral("subtitle")); writer->writeAttribute( QStringLiteral("in"), - QString::fromStdString(it->time().in().toString())); + QString::fromStdString(it->time().in().to_string())); writer->writeAttribute( QStringLiteral("out"), - QString::fromStdString(it->time().out().toString())); + QString::fromStdString(it->time().out().to_string())); writer->writeCharacters(it->text()); writer->writeEndElement(); // subtitle } diff --git a/app/render/subtitleparams.h b/app/render/subtitleparams.h index 4d9c4dbad..c3dca2bf1 100644 --- a/app/render/subtitleparams.h +++ b/app/render/subtitleparams.h @@ -19,8 +19,8 @@ ***/ -#ifndef SUBTITLEPARAMS_H -#define SUBTITLEPARAMS_H +#ifndef OAK_SUBTITLEPARAMS_H +#define OAK_SUBTITLEPARAMS_H #include #include @@ -75,18 +75,18 @@ public: enabled_ = true; } - static QString GenerateASSHeader(); + static QString generate_ass_header(); - void Load(QXmlStreamReader *reader); + void load(QXmlStreamReader *reader); - void Save(QXmlStreamWriter *writer) const; + void save(QXmlStreamWriter *writer) const; bool is_valid() const { return !this->empty(); } - rational duration() const + Rational duration() const { if (this->empty()) { return 0; @@ -124,4 +124,4 @@ private: Q_DECLARE_METATYPE(olive::Subtitle) Q_DECLARE_METATYPE(olive::SubtitleParams) -#endif // SUBTITLEPARAMS_H +#endif // OAK_SUBTITLEPARAMS_H diff --git a/app/render/texture.cpp b/app/render/texture.cpp index 6e687dd46..00425c537 100644 --- a/app/render/texture.cpp +++ b/app/render/texture.cpp @@ -27,13 +27,13 @@ namespace olive { -const Texture::Interpolation Texture::kDefaultInterpolation = - Texture::kMipmappedLinear; +const Texture::Interpolation Texture::k_default_interpolation = + Texture::k_mipmapped_linear; Texture::~Texture() { - if (IsRendererAlive()) { - renderer_->DestroyTexture(this); + if (is_renderer_alive()) { + renderer_->destroy_texture(this); } if (job_) { @@ -41,17 +41,17 @@ Texture::~Texture() } } -void Texture::Upload(void *data, int linesize) +void Texture::upload(void *data, int linesize) { - if (IsRendererAlive()) { - renderer_->UploadToTexture(this->id(), this->params(), data, linesize); + if (is_renderer_alive()) { + renderer_->upload_to_texture(this->id(), this->params(), data, linesize); } } -void Texture::Download(void *data, int linesize) +void Texture::download(void *data, int linesize) { - if (IsRendererAlive()) { - renderer_->DownloadFromTexture(this->id(), this->params(), data, + if (is_renderer_alive()) { + renderer_->download_from_texture(this->id(), this->params(), data, linesize); } } diff --git a/app/render/texture.h b/app/render/texture.h index 38522eccc..f188a77bb 100644 --- a/app/render/texture.h +++ b/app/render/texture.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERTEXTURE_H -#define RENDERTEXTURE_H +#ifndef OAK_RENDERTEXTURE_H +#define OAK_RENDERTEXTURE_H #include "common/avframeptr.h" @@ -44,9 +44,9 @@ using TexturePtr = std::shared_ptr; class Texture { public: - enum Interpolation { kNearest, kLinear, kMipmappedLinear }; + enum Interpolation { k_nearest, k_linear, k_mipmapped_linear }; - static const Interpolation kDefaultInterpolation; + static const Interpolation k_default_interpolation; /** * @brief Construct a dummy texture with no renderer backend @@ -93,21 +93,21 @@ public: } template - static TexturePtr Job(const VideoParams &p, const T &j) + static TexturePtr job(const VideoParams &p, const T &j) { return std::make_shared(p, j); } - template TexturePtr toJob(const T &job) + template TexturePtr to_job(const T &job) { - return Texture::Job(params_, job); + return Texture::job(params_, job); } - void Upload(void *data, int linesize); + void upload(void *data, int linesize); - void Download(void *data, int linesize); + void download(void *data, int linesize); - bool IsDummy() const + bool is_dummy() const { return !renderer_; } @@ -142,7 +142,7 @@ public: return params_.divider(); } - const rational &pixel_aspect_ratio() const + const Rational &pixel_aspect_ratio() const { return params_.pixel_aspect_ratio(); } @@ -152,7 +152,7 @@ public: return renderer_; } - bool IsJob() const + bool is_job() const { return job_; } @@ -160,7 +160,7 @@ public: { return job_; } - void handleFrame(AVFramePtr ptr) + void handle_frame(AVFramePtr ptr) { frame_ = ptr; } @@ -170,7 +170,7 @@ public: } private: - bool IsRendererAlive() const + bool is_renderer_alive() const { return renderer_ && (!renderer_lifetime_ || renderer_lifetime_->alive.load()); @@ -192,4 +192,4 @@ private: Q_DECLARE_METATYPE(olive::TexturePtr) -#endif // RENDERTEXTURE_H +#endif // OAK_RENDERTEXTURE_H diff --git a/app/render/videoparams.cpp b/app/render/videoparams.cpp index d50e498e7..1e5553522 100644 --- a/app/render/videoparams.cpp +++ b/app/render/videoparams.cpp @@ -32,41 +32,41 @@ namespace olive { -const int VideoParams::kInternalChannelCount = kRGBAChannelCount; +const int VideoParams::k_internal_channel_count = k_rgba_channel_count; -const rational VideoParams::kPixelAspectSquare(1); -const rational VideoParams::kPixelAspectNTSCStandard(8, 9); -const rational VideoParams::kPixelAspectNTSCWidescreen(32, 27); -const rational VideoParams::kPixelAspectPALStandard(16, 15); -const rational VideoParams::kPixelAspectPALWidescreen(64, 45); -const rational VideoParams::kPixelAspect1080Anamorphic(4, 3); +const Rational VideoParams::k_pixel_aspect_square(1); +const Rational VideoParams::k_pixel_aspect_ntsc_standard(8, 9); +const Rational VideoParams::k_pixel_aspect_ntsc_widescreen(32, 27); +const Rational VideoParams::k_pixel_aspect_pal_standard(16, 15); +const Rational VideoParams::k_pixel_aspect_pal_widescreen(64, 45); +const Rational VideoParams::k_pixel_aspect1080_anamorphic(4, 3); -const QVector VideoParams::kSupportedFrameRates = { - rational(10, 1), // 10 FPS - rational(15, 1), // 15 FPS - rational(24000, 1001), // 23.976 FPS - rational(24, 1), // 24 FPS - rational(25, 1), // 25 FPS - rational(30000, 1001), // 29.97 FPS - rational(30, 1), // 30 FPS - rational(48000, 1001), // 47.952 FPS - rational(48, 1), // 48 FPS - rational(50, 1), // 50 FPS - rational(60000, 1001), // 59.94 FPS - rational(60, 1) // 60 FPS +const QVector VideoParams::k_supported_frame_rates = { + Rational(10, 1), // 10 FPS + Rational(15, 1), // 15 FPS + Rational(24000, 1001), // 23.976 FPS + Rational(24, 1), // 24 FPS + Rational(25, 1), // 25 FPS + Rational(30000, 1001), // 29.97 FPS + Rational(30, 1), // 30 FPS + Rational(48000, 1001), // 47.952 FPS + Rational(48, 1), // 48 FPS + Rational(50, 1), // 50 FPS + Rational(60000, 1001), // 59.94 FPS + Rational(60, 1) // 60 FPS }; -const QVector VideoParams::kSupportedDividers = { +const QVector VideoParams::k_supported_dividers = { 1, 2, 3, 4, 6, 8, 12, 16 }; -const QVector VideoParams::kStandardPixelAspects = { - VideoParams::kPixelAspectSquare, - VideoParams::kPixelAspectNTSCStandard, - VideoParams::kPixelAspectNTSCWidescreen, - VideoParams::kPixelAspectPALStandard, - VideoParams::kPixelAspectPALWidescreen, - VideoParams::kPixelAspect1080Anamorphic +const QVector VideoParams::k_standard_pixel_aspects = { + VideoParams::k_pixel_aspect_square, + VideoParams::k_pixel_aspect_ntsc_standard, + VideoParams::k_pixel_aspect_ntsc_widescreen, + VideoParams::k_pixel_aspect_pal_standard, + VideoParams::k_pixel_aspect_pal_widescreen, + VideoParams::k_pixel_aspect1080_anamorphic }; VideoParams::VideoParams() @@ -74,10 +74,10 @@ VideoParams::VideoParams() , height_(0) , depth_(0) , time_base_(0) - , format_(PixelFormat::INVALID) + , format_(PixelFormat::invalid) , channel_count_(0) , pixel_aspect_ratio_(1) - , interlacing_(Interlacing::kInterlaceNone) + , interlacing_(Interlacing::k_interlace_none) , divider_(1) { calculate_effective_size(); @@ -86,7 +86,7 @@ VideoParams::VideoParams() } VideoParams::VideoParams(int width, int height, PixelFormat format, - int nb_channels, const rational &pixel_aspect_ratio, + int nb_channels, const Rational &pixel_aspect_ratio, Interlacing interlacing, int divider) : width_(width) , height_(height) @@ -103,7 +103,7 @@ VideoParams::VideoParams(int width, int height, PixelFormat format, } VideoParams::VideoParams(int width, int height, int depth, PixelFormat format, - int nb_channels, const rational &pixel_aspect_ratio, + int nb_channels, const Rational &pixel_aspect_ratio, VideoParams::Interlacing interlacing, int divider) : width_(width) , height_(height) @@ -119,20 +119,20 @@ VideoParams::VideoParams(int width, int height, int depth, PixelFormat format, set_defaults_for_footage(); } -void VideoParams::set_channel_count(const std::string &ofxComponent) +void VideoParams::set_channel_count(const std::string &ofx_component) { - if (ofxComponent == kOfxImageComponentAlpha) { + if (ofx_component == kOfxImageComponentAlpha) { channel_count_ = 1; - } else if (ofxComponent == kOfxImageComponentRGB) { - channel_count_ = kRGBChannelCount; - } else if (ofxComponent == kOfxImageComponentRGBA) { - channel_count_ = kRGBAChannelCount; + } else if (ofx_component == kOfxImageComponentRGB) { + channel_count_ = k_rgb_channel_count; + } else if (ofx_component == kOfxImageComponentRGBA) { + channel_count_ = k_rgba_channel_count; } } -VideoParams::VideoParams(int width, int height, const rational &time_base, +VideoParams::VideoParams(int width, int height, const Rational &time_base, PixelFormat format, int nb_channels, - const rational &pixel_aspect_ratio, + const Rational &pixel_aspect_ratio, Interlacing interlacing, int divider) : width_(width) , height_(height) @@ -159,14 +159,14 @@ int VideoParams::generate_auto_divider(qint64 width, qint64 height) double squared_divider = double(megapixels) / double(target_res); double divider = qSqrt(squared_divider); - if (divider <= kSupportedDividers.first()) { - return kSupportedDividers.first(); - } else if (divider >= kSupportedDividers.last()) { - return kSupportedDividers.last(); + if (divider <= k_supported_dividers.first()) { + return k_supported_dividers.first(); + } else if (divider >= k_supported_dividers.last()) { + return k_supported_dividers.last(); } else { - for (int i = 1; i < kSupportedDividers.size(); i++) { - int prev_divider = kSupportedDividers.at(i - 1); - int next_divider = kSupportedDividers.at(i); + for (int i = 1; i < k_supported_dividers.size(); i++) { + int prev_divider = k_supported_dividers.at(i - 1); + int next_divider = k_supported_dividers.at(i); if (divider >= prev_divider && divider <= next_divider) { double prev_diff = qAbs(prev_divider - divider); @@ -199,36 +199,36 @@ bool VideoParams::operator!=(const VideoParams &rhs) const return !(*this == rhs); } -int VideoParams::GetBytesPerChannel(PixelFormat format) +int VideoParams::get_bytes_per_channel(PixelFormat format) { switch (format) { - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; - case PixelFormat::U8: + case PixelFormat::u8: return 1; - case PixelFormat::U10: + case PixelFormat::u10: return 0; // packed format, use GetBytesPerPixel instead - case PixelFormat::U16: - case PixelFormat::F16: + case PixelFormat::u16: + case PixelFormat::f16: return 2; - case PixelFormat::F32: + case PixelFormat::f32: return 4; } return 0; } -int VideoParams::GetBytesPerPixel(PixelFormat format, int channels) +int VideoParams::get_bytes_per_pixel(PixelFormat format, int channels) { - if (format == PixelFormat::U10) { + if (format == PixelFormat::u10) { // Packed 10-bit RGBA10A2: 4 bytes per RGBA pixel regardless of channel count - return channels == VideoParams::kRGBAChannelCount ? 4 : 0; + return channels == VideoParams::k_rgba_channel_count ? 4 : 0; } - return GetBytesPerChannel(format) * channels; + return get_bytes_per_channel(format) * channels; } -QString VideoParams::GetNameForDivider(int div) +QString VideoParams::get_name_for_divider(int div) { if (div == 1) { return QCoreApplication::translate("VideoParams", "Full"); @@ -237,23 +237,23 @@ QString VideoParams::GetNameForDivider(int div) } } -QString VideoParams::GetFormatName(PixelFormat format) +QString VideoParams::get_format_name(PixelFormat format) { switch (format) { - case PixelFormat::U8: + case PixelFormat::u8: return QCoreApplication::translate("VideoParams", "8-bit"); - case PixelFormat::U10: + case PixelFormat::u10: return QCoreApplication::translate("VideoParams", "10-bit Packed"); - case PixelFormat::U16: + case PixelFormat::u16: return QCoreApplication::translate("VideoParams", "16-bit Integer"); - case PixelFormat::F16: + case PixelFormat::f16: return QCoreApplication::translate("VideoParams", "Half-Float (16-bit)"); - case PixelFormat::F32: + case PixelFormat::f32: return QCoreApplication::translate("VideoParams", "Full-Float (32-bit)"); - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; } @@ -261,7 +261,7 @@ QString VideoParams::GetFormatName(PixelFormat format) .arg(static_cast(format), 0, 16); } -int VideoParams::GetDividerForTargetResolution(int src_width, int src_height, +int VideoParams::get_divider_for_target_resolution(int src_width, int src_height, int dst_width, int dst_height) { int divider = 0; @@ -270,8 +270,8 @@ int VideoParams::GetDividerForTargetResolution(int src_width, int src_height, do { divider++; - test_width = VideoParams::GetScaledDimension(src_width, divider); - test_height = VideoParams::GetScaledDimension(src_height, divider); + test_width = VideoParams::get_scaled_dimension(src_width, divider); + test_height = VideoParams::get_scaled_dimension(src_height, divider); } while (test_width > dst_width || test_height > dst_height); return divider; @@ -279,10 +279,10 @@ int VideoParams::GetDividerForTargetResolution(int src_width, int src_height, void VideoParams::calculate_effective_size() { - effective_width_ = GetScaledDimension(width(), divider_); - effective_height_ = GetScaledDimension(height(), divider_); + effective_width_ = get_scaled_dimension(width(), divider_); + effective_height_ = get_scaled_dimension(height(), divider_); effective_depth_ = (depth() == 1) ? depth() : - GetScaledDimension(depth(), divider_); + get_scaled_dimension(depth(), divider_); calculate_square_pixel_width(); } @@ -298,19 +298,19 @@ void VideoParams::set_defaults_for_footage() { enabled_ = true; stream_index_ = 0; - video_type_ = kVideoTypeVideo; + video_type_ = k_video_type_video; start_time_ = 0; duration_ = 0; premultiplied_alpha_ = false; x_ = 0; y_ = 0; - color_range_ = kColorRangeDefault; + color_range_ = k_color_range_default; } void VideoParams::calculate_square_pixel_width() { if (pixel_aspect_ratio_.denominator() != 0) { - par_width_ = qRound(width_ * pixel_aspect_ratio_.toDouble()); + par_width_ = qRound(width_ * pixel_aspect_ratio_.to_double()); } else { par_width_ = width_; } @@ -319,17 +319,17 @@ void VideoParams::calculate_square_pixel_width() bool VideoParams::is_valid() const { return (width() > 0 && height() > 0 && !pixel_aspect_ratio_.isNull() && - format_ > PixelFormat::INVALID && format_ < PixelFormat::COUNT && + format_ > PixelFormat::invalid && format_ < PixelFormat::count && channel_count_ > 0); } -QString VideoParams::FrameRateToString(const rational &frame_rate) +QString VideoParams::frame_rate_to_string(const Rational &frame_rate) { return QCoreApplication::translate("VideoParams", "%1 FPS") - .arg(frame_rate.toDouble()); + .arg(frame_rate.to_double()); } -QStringList VideoParams::GetStandardPixelAspectRatioNames() +QStringList VideoParams::get_standard_pixel_aspect_ratio_names() { QStringList strings = { QCoreApplication::translate("VideoParams", "Square Pixels (%1)"), @@ -342,25 +342,25 @@ QStringList VideoParams::GetStandardPixelAspectRatioNames() // Format each for (int i = 0; i < strings.size(); i++) { - strings.replace(i, FormatPixelAspectRatioString( - strings.at(i), kStandardPixelAspects.at(i))); + strings.replace(i, format_pixel_aspect_ratio_string( + strings.at(i), k_standard_pixel_aspects.at(i))); } return strings; } -QString VideoParams::FormatPixelAspectRatioString(const QString &format, - const rational &ratio) +QString VideoParams::format_pixel_aspect_ratio_string(const QString &format, + const Rational &ratio) { - return format.arg(QString::number(ratio.toDouble(), 'f', 4)); + return format.arg(QString::number(ratio.to_double(), 'f', 4)); } -int VideoParams::GetScaledDimension(int dim, int divider) +int VideoParams::get_scaled_dimension(int dim, int divider) { return dim / divider; } -int64_t VideoParams::get_time_in_timebase_units(const rational &time) const +int64_t VideoParams::get_time_in_timebase_units(const Rational &time) const { if (time_base_.isNull()) { return INT64_MIN; // AV_NOPTS_VALUE @@ -369,9 +369,9 @@ int64_t VideoParams::get_time_in_timebase_units(const rational &time) const return Timecode::time_to_timestamp(time, time_base_) + start_time_; } -void VideoParams::Load(QXmlStreamReader *reader) +void VideoParams::load(QXmlStreamReader *reader) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("width")) { set_width(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("height")) { @@ -380,7 +380,7 @@ void VideoParams::Load(QXmlStreamReader *reader) set_depth(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("timebase")) { set_time_base( - rational::fromString(reader->readElementText().toStdString())); + Rational::from_string(reader->readElementText().toStdString())); } else if (reader->name() == QStringLiteral("format")) { set_format(static_cast( reader->readElementText().toInt())); @@ -388,7 +388,7 @@ void VideoParams::Load(QXmlStreamReader *reader) set_channel_count(reader->readElementText().toInt()); } else if (reader->name() == QStringLiteral("pixelaspectratio")) { set_pixel_aspect_ratio( - rational::fromString(reader->readElementText().toStdString())); + Rational::from_string(reader->readElementText().toStdString())); } else if (reader->name() == QStringLiteral("interlacing")) { set_interlacing(static_cast( reader->readElementText().toInt())); @@ -407,7 +407,7 @@ void VideoParams::Load(QXmlStreamReader *reader) reader->readElementText().toInt())); } else if (reader->name() == QStringLiteral("framerate")) { set_frame_rate( - rational::fromString(reader->readElementText().toStdString())); + Rational::from_string(reader->readElementText().toStdString())); } else if (reader->name() == QStringLiteral("starttime")) { set_start_time(reader->readElementText().toLongLong()); } else if (reader->name() == QStringLiteral("duration")) { @@ -425,21 +425,21 @@ void VideoParams::Load(QXmlStreamReader *reader) } } -void VideoParams::Save(QXmlStreamWriter *writer) const +void VideoParams::save(QXmlStreamWriter *writer) const { writer->writeTextElement(QStringLiteral("width"), QString::number(width_)); writer->writeTextElement(QStringLiteral("height"), QString::number(height_)); writer->writeTextElement(QStringLiteral("depth"), QString::number(depth_)); writer->writeTextElement(QStringLiteral("timebase"), - QString::fromStdString(time_base_.toString())); + QString::fromStdString(time_base_.to_string())); writer->writeTextElement(QStringLiteral("format"), QString::number(format_)); writer->writeTextElement(QStringLiteral("channelcount"), QString::number(channel_count_)); writer->writeTextElement( QStringLiteral("pixelaspectratio"), - QString::fromStdString(pixel_aspect_ratio_.toString())); + QString::fromStdString(pixel_aspect_ratio_.to_string())); writer->writeTextElement(QStringLiteral("interlacing"), QString::number(interlacing_)); writer->writeTextElement(QStringLiteral("divider"), @@ -453,7 +453,7 @@ void VideoParams::Save(QXmlStreamWriter *writer) const writer->writeTextElement(QStringLiteral("videotype"), QString::number(video_type_)); writer->writeTextElement(QStringLiteral("framerate"), - QString::fromStdString(frame_rate_.toString())); + QString::fromStdString(frame_rate_.to_string())); writer->writeTextElement(QStringLiteral("starttime"), QString::number(start_time_)); writer->writeTextElement(QStringLiteral("duration"), diff --git a/app/render/videoparams.h b/app/render/videoparams.h index f7138b100..277cf2032 100644 --- a/app/render/videoparams.h +++ b/app/render/videoparams.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIDEOPARAMS_H -#define VIDEOPARAMS_H +#ifndef OAK_VIDEOPARAMS_H +#define OAK_VIDEOPARAMS_H #include #include @@ -36,30 +36,30 @@ using namespace core; class VideoParams { public: enum Interlacing { - kInterlaceNone, - kInterlacedTopFirst, - kInterlacedBottomFirst + k_interlace_none, + k_interlaced_top_first, + k_interlaced_bottom_first }; - enum Type { kVideoTypeVideo, kVideoTypeStill, kVideoTypeImageSequence }; + enum Type { k_video_type_video, k_video_type_still, k_video_type_image_sequence }; enum ColorRange { - kColorRangeLimited, // 16_235 - kColorRangeFull, // 0-255 + k_color_range_limited, // 16_235 + k_color_range_full, // 0-255 - kColorRangeDefault = kColorRangeLimited + k_color_range_default = k_color_range_limited }; VideoParams(); VideoParams(int width, int height, PixelFormat format, int nb_channels, - const rational &pixel_aspect_ratio = 1, - Interlacing interlacing = kInterlaceNone, int divider = 1); + const Rational &pixel_aspect_ratio = 1, + Interlacing interlacing = k_interlace_none, int divider = 1); VideoParams(int width, int height, int depth, PixelFormat format, - int nb_channels, const rational &pixel_aspect_ratio = 1, - Interlacing interlacing = kInterlaceNone, int divider = 1); - VideoParams(int width, int height, const rational &time_base, + int nb_channels, const Rational &pixel_aspect_ratio = 1, + Interlacing interlacing = k_interlace_none, int divider = 1); + VideoParams(int width, int height, const Rational &time_base, PixelFormat format, int nb_channels, - const rational &pixel_aspect_ratio = 1, - Interlacing interlacing = kInterlaceNone, int divider = 1); + const Rational &pixel_aspect_ratio = 1, + Interlacing interlacing = k_interlace_none, int divider = 1); int width() const { @@ -117,17 +117,17 @@ public: return depth_ > 1; } - const rational &time_base() const + const Rational &time_base() const { return time_base_; } - void set_time_base(const rational &r) + void set_time_base(const Rational &r) { time_base_ = r; } - rational frame_rate_as_time_base() const + Rational frame_rate_as_time_base() const { return frame_rate_.flipped(); } @@ -177,13 +177,13 @@ public: { channel_count_ = c; } - void set_channel_count(const std::string &ofxComponent); - const rational &pixel_aspect_ratio() const + void set_channel_count(const std::string &ofx_component); + const Rational &pixel_aspect_ratio() const { return pixel_aspect_ratio_; } - void set_pixel_aspect_ratio(const rational &r) + void set_pixel_aspect_ratio(const Rational &r) { pixel_aspect_ratio_ = r; validate_pixel_aspect_ratio(); @@ -206,67 +206,67 @@ public: bool operator==(const VideoParams &rhs) const; bool operator!=(const VideoParams &rhs) const; - static int GetBytesPerChannel(PixelFormat format); - int GetBytesPerChannel() const + static int get_bytes_per_channel(PixelFormat format); + int get_bytes_per_channel() const { - return GetBytesPerChannel(format_); + return get_bytes_per_channel(format_); } - static int GetBytesPerPixel(PixelFormat format, int channels); - int GetBytesPerPixel() const + static int get_bytes_per_pixel(PixelFormat format, int channels); + int get_bytes_per_pixel() const { - return GetBytesPerPixel(format_, channel_count_); + return get_bytes_per_pixel(format_, channel_count_); } - static int GetBufferSize(int width, int height, PixelFormat format, + static int get_buffer_size(int width, int height, PixelFormat format, int channels) { - return width * height * GetBytesPerPixel(format, channels); + return width * height * get_bytes_per_pixel(format, channels); } - int GetBufferSize() const + int get_buffer_size() const { - return GetBufferSize(width_, height_, format_, channel_count_); + return get_buffer_size(width_, height_, format_, channel_count_); } - static QString GetNameForDivider(int div); + static QString get_name_for_divider(int div); - static bool FormatIsFloat(PixelFormat format) + static bool format_is_float(PixelFormat format) { return format.is_float(); } - static QString GetFormatName(PixelFormat format); + static QString get_format_name(PixelFormat format); - static int GetDividerForTargetResolution(int src_width, int src_height, + static int get_divider_for_target_resolution(int src_width, int src_height, int dst_width, int dst_height); - static const int kInternalChannelCount; + static const int k_internal_channel_count; - static const rational kPixelAspectSquare; - static const rational kPixelAspectNTSCStandard; - static const rational kPixelAspectNTSCWidescreen; - static const rational kPixelAspectPALStandard; - static const rational kPixelAspectPALWidescreen; - static const rational kPixelAspect1080Anamorphic; + static const Rational k_pixel_aspect_square; + static const Rational k_pixel_aspect_ntsc_standard; + static const Rational k_pixel_aspect_ntsc_widescreen; + static const Rational k_pixel_aspect_pal_standard; + static const Rational k_pixel_aspect_pal_widescreen; + static const Rational k_pixel_aspect1080_anamorphic; - static const QVector kSupportedFrameRates; - static const QVector kStandardPixelAspects; - static const QVector kSupportedDividers; + static const QVector k_supported_frame_rates; + static const QVector k_standard_pixel_aspects; + static const QVector k_supported_dividers; - static const int kHSVChannelCount = 3; - static const int kRGBChannelCount = 3; - static const int kRGBAChannelCount = 4; + static const int k_hsv_channel_count = 3; + static const int k_rgb_channel_count = 3; + static const int k_rgba_channel_count = 4; /** - * @brief Convert rational frame rate (i.e. flipped timebase) to a user-friendly string + * @brief Convert Rational frame rate (i.e. flipped timebase) to a user-friendly string */ - static QString FrameRateToString(const rational &frame_rate); + static QString frame_rate_to_string(const Rational &frame_rate); - static QStringList GetStandardPixelAspectRatioNames(); - static QString FormatPixelAspectRatioString(const QString &format, - const rational &ratio); + static QStringList get_standard_pixel_aspect_ratio_names(); + static QString format_pixel_aspect_ratio_string(const QString &format, + const Rational &ratio); - static int GetScaledDimension(int dim, int divider); + static int get_scaled_dimension(int dim, int divider); bool enabled() const { @@ -319,12 +319,12 @@ public: video_type_ = t; } - const rational &frame_rate() const + const Rational &frame_rate() const { return frame_rate_; } - void set_frame_rate(const rational &frame_rate) + void set_frame_rate(const Rational &frame_rate) { frame_rate_ = frame_rate; } @@ -378,11 +378,11 @@ public: color_range_ = color_range; } - int64_t get_time_in_timebase_units(const rational &time) const; + int64_t get_time_in_timebase_units(const Rational &time) const; - void Load(QXmlStreamReader *reader); + void load(QXmlStreamReader *reader); - void Save(QXmlStreamWriter *writer) const; + void save(QXmlStreamWriter *writer) const; private: void calculate_effective_size(); @@ -396,13 +396,13 @@ private: int width_; int height_; int depth_; - rational time_base_; + Rational time_base_; PixelFormat format_; int channel_count_; - rational pixel_aspect_ratio_; + Rational pixel_aspect_ratio_; Interlacing interlacing_; @@ -417,7 +417,7 @@ private: bool enabled_; int stream_index_; Type video_type_; - rational frame_rate_; + Rational frame_rate_; int64_t start_time_; int64_t duration_; bool premultiplied_alpha_; @@ -432,4 +432,4 @@ private: Q_DECLARE_METATYPE(olive::VideoParams) Q_DECLARE_METATYPE(olive::VideoParams::Interlacing) -#endif // VIDEOPARAMS_H +#endif // OAK_VIDEOPARAMS_H diff --git a/app/render/vulkan/vulkanbackend_c.cpp b/app/render/vulkan/vulkanbackend_c.cpp index 135c54984..f6b5617b9 100644 --- a/app/render/vulkan/vulkanbackend_c.cpp +++ b/app/render/vulkan/vulkanbackend_c.cpp @@ -17,21 +17,21 @@ namespace class BackendVulkanRenderer : public olive::VulkanRenderer { public: using olive::VulkanRenderer::VulkanRenderer; - using olive::VulkanRenderer::Blit; - using olive::VulkanRenderer::CreateNativeTexture; - using olive::VulkanRenderer::DestroyInternal; - using olive::VulkanRenderer::DestroyNativeTexture; + using olive::VulkanRenderer::blit; + using olive::VulkanRenderer::create_native_texture; + using olive::VulkanRenderer::destroy_internal; + using olive::VulkanRenderer::destroy_native_texture; }; // Converts the opaque C ABI handle back to the C++ Vulkan renderer. -BackendVulkanRenderer *Renderer(OakRenderBackendHandle handle) +BackendVulkanRenderer *renderer(OakRenderBackendHandle handle) { return static_cast(handle); } // Interprets ABI QVariant payloads without copying; this ABI version assumes // the host and backend are built with the same Qt/C++ ABI. -const QVariant &VariantRef(const void *variant) +const QVariant &variant_ref(const void *variant) { return *static_cast(variant); } @@ -49,7 +49,7 @@ oak_renderer_create(void *parent) OAK_RENDER_BACKEND_EXPORT void oak_renderer_destroy(OakRenderBackendHandle handle) { - delete Renderer(handle); + delete renderer(handle); } // Reports Vulkan backend capabilities and runtime availability status. @@ -61,12 +61,12 @@ oak_renderer_get_info(OakRenderBackendHandle handle, return false; } out_info->abi_version = 1; - out_info->kind = OAK_RENDER_BACKEND_VULKAN; + out_info->kind = oak_render_backend_vulkan; out_info->capabilities = - OAK_RENDER_BACKEND_CAP_TEXTURES | OAK_RENDER_BACKEND_CAP_SHADERS | - OAK_RENDER_BACKEND_CAP_BLIT | OAK_RENDER_BACKEND_CAP_READBACK; + oak_render_backend_cap_textures | oak_render_backend_cap_shaders | + oak_render_backend_cap_blit | oak_render_backend_cap_readback; out_info->name = "vulkan"; - out_info->status = Renderer(handle)->IsAvailable() ? "available" : + out_info->status = renderer(handle)->is_available() ? "available" : "unavailable"; return true; } @@ -76,21 +76,21 @@ oak_renderer_get_info(OakRenderBackendHandle handle, OAK_RENDER_BACKEND_EXPORT bool oak_renderer_is_available(OakRenderBackendHandle handle) { - auto *r = Renderer(handle); - if (!r || r->IsAvailable()) { - return r && r->IsAvailable(); + auto *r = renderer(handle); + if (!r || r->is_available()) { + return r && r->is_available(); } // Try to initialize if not already available - if (r->Init()) { - r->PostInit(); + if (r->init()) { + r->post_init(); } - return r->IsAvailable(); + return r->is_available(); } // Initializes the Vulkan device path. OAK_RENDER_BACKEND_EXPORT bool oak_renderer_init(OakRenderBackendHandle handle) { - return Renderer(handle)->Init(); + return renderer(handle)->init(); } // Vulkan does not use a QOpenGLContext; the argument is accepted for ABI parity. @@ -98,28 +98,28 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_init_with_context(OakRenderBackendHandle handle, void *context) { Q_UNUSED(context) - Renderer(handle)->Init(); + renderer(handle)->init(); } // Creates reusable Vulkan resources after device initialization. OAK_RENDER_BACKEND_EXPORT void oak_renderer_post_init(OakRenderBackendHandle handle) { - Renderer(handle)->PostInit(); + renderer(handle)->post_init(); } // Reserved for API symmetry; Vulkan cleanup is handled by destroy_internal. OAK_RENDER_BACKEND_EXPORT void oak_renderer_post_destroy(OakRenderBackendHandle handle) { - Renderer(handle)->PostDestroy(); + renderer(handle)->post_destroy(); } // Releases all Vulkan resources owned by the renderer. OAK_RENDER_BACKEND_EXPORT void oak_renderer_destroy_internal(OakRenderBackendHandle handle) { - Renderer(handle)->DestroyInternal(); + renderer(handle)->destroy_internal(); } // Clears a Vulkan texture destination. @@ -127,7 +127,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_clear_destination(OakRenderBackendHandle handle, void *texture, double r, double g, double b, double a) { - Renderer(handle)->ClearDestination(static_cast(texture), + renderer(handle)->clear_destination(static_cast(texture), r, g, b, a); } @@ -137,7 +137,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_create_native_texture( int channel_count, const void *data, int linesize, void *out_variant) { *static_cast(out_variant) = - Renderer(handle)->CreateNativeTexture( + renderer(handle)->create_native_texture( width, height, depth, static_cast(format), channel_count, data, linesize); @@ -148,7 +148,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_destroy_native_texture(OakRenderBackendHandle handle, const void *variant) { - Renderer(handle)->DestroyNativeTexture(VariantRef(variant)); + renderer(handle)->destroy_native_texture(variant_ref(variant)); } // Compiles a Vulkan shader and returns its QVariant handle. @@ -157,7 +157,7 @@ oak_renderer_create_native_shader(OakRenderBackendHandle handle, const void *shader_code, void *out_variant) { *static_cast(out_variant) = - Renderer(handle)->CreateNativeShader( + renderer(handle)->create_native_shader( *static_cast(shader_code)); } @@ -166,7 +166,7 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_destroy_native_shader(OakRenderBackendHandle handle, const void *variant) { - Renderer(handle)->DestroyNativeShader(VariantRef(variant)); + renderer(handle)->destroy_native_shader(variant_ref(variant)); } // Uploads CPU pixel data into a Vulkan texture. @@ -175,8 +175,8 @@ oak_renderer_upload_to_texture(OakRenderBackendHandle handle, const void *variant, const void *video_params, const void *data, int linesize) { - Renderer(handle)->UploadToTexture( - VariantRef(variant), + renderer(handle)->upload_to_texture( + variant_ref(variant), *static_cast(video_params), data, linesize); } @@ -185,15 +185,15 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_download_from_texture( OakRenderBackendHandle handle, const void *variant, const void *video_params, void *data, int linesize) { - Renderer(handle)->DownloadFromTexture( - VariantRef(variant), + renderer(handle)->download_from_texture( + variant_ref(variant), *static_cast(video_params), data, linesize); } // Waits for all queued Vulkan work to finish. OAK_RENDER_BACKEND_EXPORT void oak_renderer_flush(OakRenderBackendHandle handle) { - Renderer(handle)->Flush(); + renderer(handle)->flush(); } // Reads one pixel from a Vulkan texture. @@ -203,7 +203,7 @@ oak_renderer_get_pixel_from_texture(OakRenderBackendHandle handle, void *out_color) { *static_cast(out_color) = - Renderer(handle)->GetPixelFromTexture( + renderer(handle)->get_pixel_from_texture( static_cast(texture), *static_cast(point)); } @@ -215,8 +215,8 @@ OAK_RENDER_BACKEND_EXPORT void oak_renderer_blit(OakRenderBackendHandle handle, const void *destination_params, bool clear_destination) { - Renderer(handle)->Blit( - VariantRef(shader), *static_cast(job), + renderer(handle)->blit( + variant_ref(shader), *static_cast(job), static_cast(destination), *static_cast(destination_params), clear_destination); diff --git a/app/render/vulkan/vulkanrenderer.cpp b/app/render/vulkan/vulkanrenderer.cpp index 3211e4b51..104b6b255 100644 --- a/app/render/vulkan/vulkanrenderer.cpp +++ b/app/render/vulkan/vulkanrenderer.cpp @@ -26,7 +26,7 @@ struct VulkanRenderer::VulkanTexture { int width = 0; int height = 0; int depth = 0; - PixelFormat format = PixelFormat::INVALID; + PixelFormat format = PixelFormat::invalid; int channel_count = 0; VkFormat vk_format = VK_FORMAT_UNDEFINED; VkImageLayout current_layout = VK_IMAGE_LAYOUT_UNDEFINED; @@ -62,7 +62,7 @@ struct VulkanRenderer::StagingBuffer { VkDeviceSize size = 0; }; -static const float kBlitVertices[] = { +static const float k_blit_vertices[] = { -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, @@ -78,42 +78,42 @@ VulkanRenderer::VulkanRenderer(QObject *parent) // Ensures Vulkan resources are destroyed before the QObject hierarchy goes away. VulkanRenderer::~VulkanRenderer() { - Destroy(); - PostDestroy(); + destroy(); + post_destroy(); } // Initializes the Vulkan instance/device path once. Repeated calls are accepted // because backend availability probes may call Init() before normal rendering. -bool VulkanRenderer::Init() +bool VulkanRenderer::init() { if (instance_ != VK_NULL_HANDLE) { return true; } - return CreateInstance() && CreateDevice() && CreateCommandPool() && - CreateDescriptorPool(); + return create_instance() && create_device() && create_command_pool() && + create_descriptor_pool(); } // Creates reusable draw resources after Init() has a valid logical device. -void VulkanRenderer::PostInit() +void VulkanRenderer::post_init() { if (vertex_buffer_ != VK_NULL_HANDLE) { return; } - CreateVertexBuffer(); - CreateLinearSampler(); - CreateNearestSampler(); + create_vertex_buffer(); + create_linear_sampler(); + create_nearest_sampler(); } // Reserved for Renderer API symmetry; Vulkan teardown is centralized in // DestroyInternal() so object destruction and explicit Destroy() share a path. -void VulkanRenderer::PostDestroy() +void VulkanRenderer::post_destroy() { } // Destroys all Vulkan objects in dependency order. The device is idled first so // cached textures, pipelines, descriptor pools, and command pools are no longer // referenced by in-flight work. -void VulkanRenderer::DestroyInternal() +void VulkanRenderer::destroy_internal() { if (device_ != VK_NULL_HANDLE) { vkDeviceWaitIdle(device_); @@ -226,14 +226,14 @@ void VulkanRenderer::DestroyInternal() device_lost_ = false; if (instance_ != VK_NULL_HANDLE) { - DestroyDebugMessenger(); + destroy_debug_messenger(); vkDestroyInstance(instance_, nullptr); instance_ = VK_NULL_HANDLE; } } // Creates the minimal Vulkan instance needed for offscreen rendering. -bool VulkanRenderer::CreateInstance() +bool VulkanRenderer::create_instance() { VkApplicationInfo app_info = {}; app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; @@ -295,7 +295,7 @@ bool VulkanRenderer::CreateInstance() } if (has_validation && has_debug_extension) { - CreateDebugMessenger(); + create_debug_messenger(); } qDebug() << "Vulkan instance created successfully"; @@ -305,31 +305,31 @@ bool VulkanRenderer::CreateInstance() // Logs validation errors/warnings from the Vulkan validation layers. These are // the first signal of missing barriers or invalid usage that would otherwise // become a GPU hang. -VKAPI_ATTR VkBool32 VKAPI_CALL VulkanRenderer::DebugCallback( - VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, - VkDebugUtilsMessageTypeFlagsEXT messageType, - const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData) +VKAPI_ATTR VkBool32 VKAPI_CALL VulkanRenderer::debug_callback( + VkDebugUtilsMessageSeverityFlagBitsEXT message_severity, + VkDebugUtilsMessageTypeFlagsEXT message_type, + const VkDebugUtilsMessengerCallbackDataEXT *p_callback_data, void *p_user_data) { - Q_UNUSED(messageType) - Q_UNUSED(pUserData) + Q_UNUSED(message_type) + Q_UNUSED(p_user_data) - if (!pCallbackData || !pCallbackData->pMessage) { + if (!p_callback_data || !p_callback_data->pMessage) { return VK_FALSE; } // Only emit errors/warnings. Verbose validation messages are useful during // bring-up but flood the log and degrade playback performance. - if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { - qWarning() << "Vulkan validation error:" << pCallbackData->pMessage; - } else if (messageSeverity & + if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { + qWarning() << "Vulkan validation error:" << p_callback_data->pMessage; + } else if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { - qWarning() << "Vulkan validation warning:" << pCallbackData->pMessage; + qWarning() << "Vulkan validation warning:" << p_callback_data->pMessage; } return VK_FALSE; } -bool VulkanRenderer::CreateDebugMessenger() +bool VulkanRenderer::create_debug_messenger() { auto create_fn = reinterpret_cast( vkGetInstanceProcAddr(instance_, "vkCreateDebugUtilsMessengerEXT")); @@ -345,7 +345,7 @@ bool VulkanRenderer::CreateDebugMessenger() VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT; create_info.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT; - create_info.pfnUserCallback = DebugCallback; + create_info.pfnUserCallback = debug_callback; VkResult result = create_fn(instance_, &create_info, nullptr, &debug_messenger_); @@ -356,7 +356,7 @@ bool VulkanRenderer::CreateDebugMessenger() return true; } -void VulkanRenderer::DestroyDebugMessenger() +void VulkanRenderer::destroy_debug_messenger() { if (debug_messenger_ == VK_NULL_HANDLE || instance_ == VK_NULL_HANDLE) { return; @@ -371,7 +371,7 @@ void VulkanRenderer::DestroyDebugMessenger() // Selects the first physical device with a graphics queue and creates a logical // device without swapchain extensions because viewer output is CPU readback. -bool VulkanRenderer::CreateDevice() +bool VulkanRenderer::create_device() { VkResult result = vkEnumeratePhysicalDevices(instance_, &physical_device_count_, nullptr); @@ -454,7 +454,7 @@ bool VulkanRenderer::CreateDevice() // Creates the command pool used for short-lived transfer and draw command // buffers. -bool VulkanRenderer::CreateCommandPool() +bool VulkanRenderer::create_command_pool() { VkCommandPoolCreateInfo pool_info = {}; pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; @@ -472,19 +472,19 @@ bool VulkanRenderer::CreateCommandPool() // Creates a pool large enough for transient per-blit descriptor sets. Descriptor // sets are freed after each pass, so this is capacity rather than lifetime count. -bool VulkanRenderer::CreateDescriptorPool() +bool VulkanRenderer::create_descriptor_pool() { VkDescriptorPoolSize pool_sizes[2] = {}; pool_sizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - pool_sizes[0].descriptorCount = kMaxDescriptorSets; + pool_sizes[0].descriptorCount = k_max_descriptor_sets; pool_sizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - pool_sizes[1].descriptorCount = kMaxDescriptorSets * 8; + pool_sizes[1].descriptorCount = k_max_descriptor_sets * 8; VkDescriptorPoolCreateInfo pool_info = {}; pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; pool_info.poolSizeCount = 2; pool_info.pPoolSizes = pool_sizes; - pool_info.maxSets = kMaxDescriptorSets; + pool_info.maxSets = k_max_descriptor_sets; pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; VkResult result = @@ -497,7 +497,7 @@ bool VulkanRenderer::CreateDescriptorPool() } // Returns a cached render pass keyed by color format and load operation. -VkRenderPass VulkanRenderer::GetOrCreateRenderPass(VkFormat format, bool clear) +VkRenderPass VulkanRenderer::get_or_create_render_pass(VkFormat format, bool clear) { const quint64 key = (static_cast(format) << 1) | (clear ? 1ULL : 0ULL); @@ -584,9 +584,9 @@ VkRenderPass VulkanRenderer::GetOrCreateRenderPass(VkFormat format, bool clear) } // Uploads a fullscreen quad to device-local memory through a staging buffer. -bool VulkanRenderer::CreateVertexBuffer() +bool VulkanRenderer::create_vertex_buffer() { - VkDeviceSize buffer_size = sizeof(kBlitVertices); + VkDeviceSize buffer_size = sizeof(k_blit_vertices); VkBufferCreateInfo buffer_info = {}; buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; @@ -607,7 +607,7 @@ bool VulkanRenderer::CreateVertexBuffer() VkMemoryAllocateInfo alloc_info = {}; alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; alloc_info.allocationSize = mem_req.size; - alloc_info.memoryTypeIndex = FindMemoryType( + alloc_info.memoryTypeIndex = find_memory_type( mem_req.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); if (alloc_info.memoryTypeIndex == UINT32_MAX) { @@ -631,7 +631,7 @@ bool VulkanRenderer::CreateVertexBuffer() void *data; vkMapMemory(device_, staging_memory, 0, buffer_size, 0, &data); - memcpy(data, kBlitVertices, (size_t)buffer_size); + memcpy(data, k_blit_vertices, (size_t)buffer_size); vkUnmapMemory(device_, staging_memory); buffer_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | @@ -646,7 +646,7 @@ bool VulkanRenderer::CreateVertexBuffer() vkGetBufferMemoryRequirements(device_, vertex_buffer_, &mem_req); alloc_info.allocationSize = mem_req.size; - alloc_info.memoryTypeIndex = FindMemoryType( + alloc_info.memoryTypeIndex = find_memory_type( mem_req.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); if (alloc_info.memoryTypeIndex == UINT32_MAX) { vkDestroyBuffer(device_, vertex_buffer_, nullptr); @@ -675,14 +675,14 @@ bool VulkanRenderer::CreateVertexBuffer() } // Copy from staging to device local - VkCommandBuffer cmd = BeginOneTimeCommands(); + VkCommandBuffer cmd = begin_one_time_commands(); if (cmd == VK_NULL_HANDLE) { return false; } VkBufferCopy copy_region = {}; copy_region.size = buffer_size; vkCmdCopyBuffer(cmd, staging_buffer, vertex_buffer_, 1, ©_region); - EndOneTimeCommands(cmd); + end_one_time_commands(cmd); vkFreeMemory(device_, staging_memory, nullptr); vkDestroyBuffer(device_, staging_buffer, nullptr); @@ -691,7 +691,7 @@ bool VulkanRenderer::CreateVertexBuffer() } // Creates the persistent linear sampler shared by all texture bindings. -bool VulkanRenderer::CreateLinearSampler() +bool VulkanRenderer::create_linear_sampler() { VkSamplerCreateInfo sampler_info = {}; sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; @@ -719,7 +719,7 @@ bool VulkanRenderer::CreateLinearSampler() } // Creates the persistent nearest sampler shared by all texture bindings. -bool VulkanRenderer::CreateNearestSampler() +bool VulkanRenderer::create_nearest_sampler() { VkSamplerCreateInfo sampler_info = {}; sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; @@ -747,14 +747,14 @@ bool VulkanRenderer::CreateNearestSampler() } // Maps Oak interpolation settings to persistent Vulkan sampler objects. -VkSampler VulkanRenderer::GetSampler(Texture::Interpolation interpolation) const +VkSampler VulkanRenderer::get_sampler(Texture::Interpolation interpolation) const { switch (interpolation) { - case Texture::kNearest: + case Texture::k_nearest: return nearest_sampler_ != VK_NULL_HANDLE ? nearest_sampler_ : linear_sampler_; - case Texture::kLinear: - case Texture::kMipmappedLinear: + case Texture::k_linear: + case Texture::k_mipmapped_linear: default: return linear_sampler_; } @@ -764,7 +764,7 @@ VkSampler VulkanRenderer::GetSampler(Texture::Interpolation interpolation) const // Vulkan allocations are expensive and some drivers fragment host-visible heaps // under repeated 4K/F32 readback. Reusing one submit-and-wait staging buffer // keeps peak allocation count low while the renderer mutex serializes callers. -bool VulkanRenderer::CreateStagingBuffer(VkDeviceSize size, +bool VulkanRenderer::create_staging_buffer(VkDeviceSize size, VkBuffer *out_buffer, VkDeviceMemory *out_memory) { @@ -812,7 +812,7 @@ bool VulkanRenderer::CreateStagingBuffer(VkDeviceSize size, VkMemoryAllocateInfo alloc_info = {}; alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; alloc_info.allocationSize = mem_req.size; - alloc_info.memoryTypeIndex = FindMemoryType( + alloc_info.memoryTypeIndex = find_memory_type( mem_req.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); if (alloc_info.memoryTypeIndex == UINT32_MAX) { @@ -852,7 +852,7 @@ bool VulkanRenderer::CreateStagingBuffer(VkDeviceSize size, // Kept for existing call sites; runtime staging buffers are renderer-owned and // released in DestroyInternal() or when a larger staging allocation is required. -void VulkanRenderer::DestroyStagingBuffer(VkBuffer buffer, +void VulkanRenderer::destroy_staging_buffer(VkBuffer buffer, VkDeviceMemory memory) { if (staging_buffer_ && buffer == staging_buffer_->buffer && @@ -868,7 +868,7 @@ void VulkanRenderer::DestroyStagingBuffer(VkBuffer buffer, } // Starts a primary command buffer intended for immediate submit-and-wait use. -VkCommandBuffer VulkanRenderer::BeginOneTimeCommands() +VkCommandBuffer VulkanRenderer::begin_one_time_commands() { if (reusable_command_buffer_ == VK_NULL_HANDLE) { VkCommandBufferAllocateInfo alloc_info = {}; @@ -904,7 +904,7 @@ VkCommandBuffer VulkanRenderer::BeginOneTimeCommands() // Submits a one-time command buffer and waits with a timeout. Using a fence // instead of vkQueueWaitIdle prevents the CPU thread from blocking forever if // a bad barrier/shader causes the GPU to hang. -void VulkanRenderer::EndOneTimeCommands(VkCommandBuffer cmd) +void VulkanRenderer::end_one_time_commands(VkCommandBuffer cmd) { if (cmd == VK_NULL_HANDLE) { return; @@ -954,8 +954,8 @@ void VulkanRenderer::EndOneTimeCommands(VkCommandBuffer cmd) // 10 second timeout. If the GPU is hung, the process can report it instead // of blocking forever. Note: a true GPU hang may still freeze the display // before this timeout is reached, but the CPU-side wait will not deadlock. - constexpr uint64_t kTimeoutNs = 10ULL * 1000ULL * 1000ULL * 1000ULL; - result = vkWaitForFences(device_, 1, &reusable_fence_, VK_TRUE, kTimeoutNs); + constexpr uint64_t k_timeout_ns = 10ULL * 1000ULL * 1000ULL * 1000ULL; + result = vkWaitForFences(device_, 1, &reusable_fence_, VK_TRUE, k_timeout_ns); if (result == VK_TIMEOUT) { qCritical() << "Vulkan GPU wait timed out; the GPU may be hung"; } else if (result != VK_SUCCESS) { @@ -965,7 +965,7 @@ void VulkanRenderer::EndOneTimeCommands(VkCommandBuffer cmd) // Emits a conservative barrier for the image layout transitions used by this // renderer: upload, shader read, color attachment, clear, and readback. -void VulkanRenderer::TransitionImageLayout(VkCommandBuffer cmd, VkImage image, +void VulkanRenderer::transition_image_layout(VkCommandBuffer cmd, VkImage image, VkImageLayout old_layout, VkImageLayout new_layout) { @@ -1102,7 +1102,7 @@ void VulkanRenderer::TransitionImageLayout(VkCommandBuffer cmd, VkImage image, } // Records a buffer-to-image copy for tightly packed texture uploads. -void VulkanRenderer::CopyBufferToImage(VkCommandBuffer cmd, VkBuffer buffer, +void VulkanRenderer::copy_buffer_to_image(VkCommandBuffer cmd, VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, uint32_t depth) { @@ -1122,7 +1122,7 @@ void VulkanRenderer::CopyBufferToImage(VkCommandBuffer cmd, VkBuffer buffer, } // Records an image-to-buffer copy for full texture downloads or one-pixel reads. -void VulkanRenderer::CopyImageToBuffer(VkCommandBuffer cmd, VkImage image, +void VulkanRenderer::copy_image_to_buffer(VkCommandBuffer cmd, VkImage image, VkBuffer buffer, uint32_t width, uint32_t height, uint32_t offset_x, uint32_t offset_y) @@ -1144,11 +1144,11 @@ void VulkanRenderer::CopyImageToBuffer(VkCommandBuffer cmd, VkImage image, } // Converts Oak's pixel format/channel count pair to the closest Vulkan format. -VkFormat VulkanRenderer::PixelFormatToVkFormat(PixelFormat format, +VkFormat VulkanRenderer::pixel_format_to_vk_format(PixelFormat format, int channel_count) const { switch (format) { - case PixelFormat::U8: + case PixelFormat::u8: switch (channel_count) { case 1: return VK_FORMAT_R8_UNORM; @@ -1160,12 +1160,12 @@ VkFormat VulkanRenderer::PixelFormatToVkFormat(PixelFormat format, return VK_FORMAT_R8G8B8A8_UNORM; } break; - case PixelFormat::U10: + case PixelFormat::u10: if (channel_count == 4) { return VK_FORMAT_A2B10G10R10_UNORM_PACK32; } break; - case PixelFormat::U16: + case PixelFormat::u16: switch (channel_count) { case 1: return VK_FORMAT_R16_UNORM; @@ -1177,7 +1177,7 @@ VkFormat VulkanRenderer::PixelFormatToVkFormat(PixelFormat format, return VK_FORMAT_R16G16B16A16_UNORM; } break; - case PixelFormat::F16: + case PixelFormat::f16: switch (channel_count) { case 1: return VK_FORMAT_R16_SFLOAT; @@ -1189,7 +1189,7 @@ VkFormat VulkanRenderer::PixelFormatToVkFormat(PixelFormat format, return VK_FORMAT_R16G16B16A16_SFLOAT; } break; - case PixelFormat::F32: + case PixelFormat::f32: switch (channel_count) { case 1: return VK_FORMAT_R32_SFLOAT; @@ -1201,15 +1201,15 @@ VkFormat VulkanRenderer::PixelFormatToVkFormat(PixelFormat format, return VK_FORMAT_R32G32B32A32_SFLOAT; } break; - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; } return VK_FORMAT_UNDEFINED; } // Checks color-attachment support before selecting renderable image formats. -bool VulkanRenderer::IsColorAttachmentSupported(VkFormat format) const +bool VulkanRenderer::is_color_attachment_supported(VkFormat format) const { VkFormatProperties props; vkGetPhysicalDeviceFormatProperties(physical_device_, format, &props); @@ -1219,20 +1219,20 @@ bool VulkanRenderer::IsColorAttachmentSupported(VkFormat format) const // Chooses a renderable Vulkan format and falls back from RGB to RGBA when a // driver does not expose 3-channel color attachment support. -VkFormat VulkanRenderer::PickRenderableFormat(PixelFormat format, +VkFormat VulkanRenderer::pick_renderable_format(PixelFormat format, int channel_count) const { - VkFormat candidate = PixelFormatToVkFormat(format, channel_count); + VkFormat candidate = pixel_format_to_vk_format(format, channel_count); if (candidate != VK_FORMAT_UNDEFINED && - IsColorAttachmentSupported(candidate)) { + is_color_attachment_supported(candidate)) { return candidate; } // 3-channel formats are often unsupported as color attachments; fallback // to the 4-channel equivalent. if (channel_count == 3) { - VkFormat rgba = PixelFormatToVkFormat(format, 4); - if (rgba != VK_FORMAT_UNDEFINED && IsColorAttachmentSupported(rgba)) { + VkFormat rgba = pixel_format_to_vk_format(format, 4); + if (rgba != VK_FORMAT_UNDEFINED && is_color_attachment_supported(rgba)) { return rgba; } } @@ -1241,7 +1241,7 @@ VkFormat VulkanRenderer::PickRenderableFormat(PixelFormat format, } // Returns the packed texel size for the VkFormat values generated above. -int VulkanRenderer::GetVkFormatBytesPerPixel(VkFormat format) const +int VulkanRenderer::get_vk_format_bytes_per_pixel(VkFormat format) const { switch (format) { case VK_FORMAT_R8_UNORM: @@ -1284,11 +1284,11 @@ int VulkanRenderer::GetVkFormatBytesPerPixel(VkFormat format) const } // Returns the alpha fill value used when expanding formats without alpha. -float VulkanRenderer::GetFormatMaxAlpha(PixelFormat format) const +float VulkanRenderer::get_format_max_alpha(PixelFormat format) const { - if (format == PixelFormat::U8) { + if (format == PixelFormat::u8) { return 255.0f; - } else if (format == PixelFormat::U16) { + } else if (format == PixelFormat::u16) { return 65535.0f; } return 1.0f; @@ -1296,13 +1296,13 @@ float VulkanRenderer::GetFormatMaxAlpha(PixelFormat format) const // Copies tightly-packed pixels while changing channel count. This handles the // common Vulkan fallback where requested RGB data is stored as RGBA on the GPU. -void VulkanRenderer::CopyPixelsWithChannelConversion( +void VulkanRenderer::copy_pixels_with_channel_conversion( const void *src, void *dst, int width, int height, int depth, int src_channels, int dst_channels, PixelFormat format) const { - int src_bpc = VideoParams::GetBytesPerChannel(format); + int src_bpc = VideoParams::get_bytes_per_channel(format); int dst_bpc = src_bpc; - float alpha = GetFormatMaxAlpha(format); + float alpha = get_format_max_alpha(format); int plane_pixels = width * height; int total_pixels = plane_pixels * depth; @@ -1318,15 +1318,15 @@ void VulkanRenderer::CopyPixelsWithChannelConversion( } else { // Fill missing channels with 0 (color) or max alpha. if (c == 3) { - if (format == PixelFormat::U8) { + if (format == PixelFormat::u8) { *reinterpret_cast( dst_ptr + (i * dst_channels + c) * dst_bpc) = static_cast(alpha); - } else if (format == PixelFormat::U16) { + } else if (format == PixelFormat::u16) { *reinterpret_cast( dst_ptr + (i * dst_channels + c) * dst_bpc) = static_cast(alpha); - } else if (format == PixelFormat::F16) { + } else if (format == PixelFormat::f16) { // Half-float 1.0: 0x3C00 *reinterpret_cast( dst_ptr + (i * dst_channels + c) * dst_bpc) = @@ -1345,14 +1345,14 @@ void VulkanRenderer::CopyPixelsWithChannelConversion( } // Rounds size up to the next multiple of alignment. -VkDeviceSize VulkanRenderer::AlignSize(VkDeviceSize size, +VkDeviceSize VulkanRenderer::align_size(VkDeviceSize size, VkDeviceSize alignment) const { return (size + alignment - 1) & ~(alignment - 1); } // Finds a compatible memory type satisfying Vulkan's bitmask and property flags. -uint32_t VulkanRenderer::FindMemoryType(uint32_t type_filter, +uint32_t VulkanRenderer::find_memory_type(uint32_t type_filter, VkMemoryPropertyFlags properties) const { for (uint32_t i = 0; i < mem_properties_.memoryTypeCount; i++) { @@ -1366,14 +1366,14 @@ uint32_t VulkanRenderer::FindMemoryType(uint32_t type_filter, } // Creates a Vulkan image, memory allocation, and image view for an Oak texture. -QVariant VulkanRenderer::CreateNativeTexture(int width, int height, int depth, +QVariant VulkanRenderer::create_native_texture(int width, int height, int depth, PixelFormat format, int channel_count, const void *data, int linesize) { QMutexLocker lock(&mutex_); - VkFormat vk_format = PickRenderableFormat(format, channel_count); + VkFormat vk_format = pick_renderable_format(format, channel_count); if (vk_format == VK_FORMAT_UNDEFINED) { qWarning() << "Unsupported pixel format for Vulkan texture"; return QVariant(); @@ -1420,7 +1420,7 @@ QVariant VulkanRenderer::CreateNativeTexture(int width, int height, int depth, VkMemoryAllocateInfo alloc_info = {}; alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; alloc_info.allocationSize = mem_req.size; - alloc_info.memoryTypeIndex = FindMemoryType( + alloc_info.memoryTypeIndex = find_memory_type( mem_req.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); if (alloc_info.memoryTypeIndex == UINT32_MAX) { qWarning() @@ -1480,8 +1480,8 @@ QVariant VulkanRenderer::CreateNativeTexture(int width, int height, int depth, // Upload initial data if provided if (data) { int cpu_bytes_per_pixel = - VideoParams::GetBytesPerPixel(format, channel_count); - int gpu_bytes_per_pixel = GetVkFormatBytesPerPixel(vk_format); + VideoParams::get_bytes_per_pixel(format, channel_count); + int gpu_bytes_per_pixel = get_vk_format_bytes_per_pixel(vk_format); if (gpu_bytes_per_pixel == 0) { gpu_bytes_per_pixel = cpu_bytes_per_pixel; } @@ -1494,7 +1494,7 @@ QVariant VulkanRenderer::CreateNativeTexture(int width, int height, int depth, VkBuffer staging_buffer; VkDeviceMemory staging_memory; - if (CreateStagingBuffer(image_size, &staging_buffer, &staging_memory)) { + if (create_staging_buffer(image_size, &staging_buffer, &staging_memory)) { void *mapped; vkMapMemory(device_, staging_memory, 0, image_size, 0, &mapped); if (cpu_bytes_per_pixel == gpu_bytes_per_pixel) { @@ -1529,40 +1529,40 @@ QVariant VulkanRenderer::CreateNativeTexture(int width, int height, int depth, } } int gpu_channels = gpu_bytes_per_pixel / - VideoParams::GetBytesPerChannel(format); - CopyPixelsWithChannelConversion(tmp.constData(), mapped, width, + VideoParams::get_bytes_per_channel(format); + copy_pixels_with_channel_conversion(tmp.constData(), mapped, width, height, depth, channel_count, gpu_channels, format); } vkUnmapMemory(device_, staging_memory); - VkCommandBuffer cmd = BeginOneTimeCommands(); + VkCommandBuffer cmd = begin_one_time_commands(); if (cmd == VK_NULL_HANDLE) { return QVariant(); } - TransitionImageLayout(cmd, tex->image, VK_IMAGE_LAYOUT_UNDEFINED, + transition_image_layout(cmd, tex->image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - CopyBufferToImage(cmd, staging_buffer, tex->image, + copy_buffer_to_image(cmd, staging_buffer, tex->image, static_cast(width), static_cast(height), static_cast(depth)); - TransitionImageLayout(cmd, tex->image, + transition_image_layout(cmd, tex->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - EndOneTimeCommands(cmd); + end_one_time_commands(cmd); - DestroyStagingBuffer(staging_buffer, staging_memory); + destroy_staging_buffer(staging_buffer, staging_memory); tex->current_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } } else { - VkCommandBuffer cmd = BeginOneTimeCommands(); + VkCommandBuffer cmd = begin_one_time_commands(); if (cmd == VK_NULL_HANDLE) { return QVariant(); } - TransitionImageLayout(cmd, tex->image, VK_IMAGE_LAYOUT_UNDEFINED, + transition_image_layout(cmd, tex->image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - EndOneTimeCommands(cmd); + end_one_time_commands(cmd); tex->current_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; } @@ -1571,7 +1571,7 @@ QVariant VulkanRenderer::CreateNativeTexture(int width, int height, int depth, } // Destroys a texture handle and all Vulkan objects owned by that texture. -void VulkanRenderer::DestroyNativeTexture(QVariant texture) +void VulkanRenderer::destroy_native_texture(QVariant texture) { QMutexLocker lock(&mutex_); quint64 id = texture.value(); @@ -1596,7 +1596,7 @@ void VulkanRenderer::DestroyNativeTexture(QVariant texture) // Uploads CPU pixels to an existing image. The staging layout is based on the // selected GPU VkFormat, then CPU data is repacked when channel counts differ. -void VulkanRenderer::UploadToTexture(const QVariant &handle, +void VulkanRenderer::upload_to_texture(const QVariant &handle, const VideoParams ¶ms, const void *data, int linesize) { @@ -1611,8 +1611,8 @@ void VulkanRenderer::UploadToTexture(const QVariant &handle, int height = params.effective_height(); int depth = params.effective_depth(); int cpu_bytes_per_pixel = - VideoParams::GetBytesPerPixel(params.format(), params.channel_count()); - int gpu_bytes_per_pixel = GetVkFormatBytesPerPixel(tex->vk_format); + VideoParams::get_bytes_per_pixel(params.format(), params.channel_count()); + int gpu_bytes_per_pixel = get_vk_format_bytes_per_pixel(tex->vk_format); if (gpu_bytes_per_pixel == 0) { gpu_bytes_per_pixel = cpu_bytes_per_pixel; } @@ -1625,7 +1625,7 @@ void VulkanRenderer::UploadToTexture(const QVariant &handle, VkBuffer staging_buffer; VkDeviceMemory staging_memory; - if (!CreateStagingBuffer(image_size, &staging_buffer, &staging_memory)) { + if (!create_staging_buffer(image_size, &staging_buffer, &staging_memory)) { return; } @@ -1658,37 +1658,37 @@ void VulkanRenderer::UploadToTexture(const QVariant &handle, } } int gpu_channels = gpu_bytes_per_pixel / - VideoParams::GetBytesPerChannel(params.format()); - CopyPixelsWithChannelConversion(tmp.constData(), mapped, width, height, + VideoParams::get_bytes_per_channel(params.format()); + copy_pixels_with_channel_conversion(tmp.constData(), mapped, width, height, depth, params.channel_count(), gpu_channels, params.format()); } vkUnmapMemory(device_, staging_memory); - VkCommandBuffer cmd = BeginOneTimeCommands(); + VkCommandBuffer cmd = begin_one_time_commands(); if (cmd == VK_NULL_HANDLE) { return; } if (tex->current_layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) { - TransitionImageLayout(cmd, tex->image, tex->current_layout, + transition_image_layout(cmd, tex->image, tex->current_layout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); } - CopyBufferToImage(cmd, staging_buffer, tex->image, + copy_buffer_to_image(cmd, staging_buffer, tex->image, static_cast(width), static_cast(height), static_cast(depth)); - TransitionImageLayout(cmd, tex->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + transition_image_layout(cmd, tex->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - EndOneTimeCommands(cmd); + end_one_time_commands(cmd); - DestroyStagingBuffer(staging_buffer, staging_memory); + destroy_staging_buffer(staging_buffer, staging_memory); tex->current_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } // Downloads an image to CPU memory. When the GPU format is wider than the // requested CPU format, the staging data is compacted back to the caller layout. -void VulkanRenderer::DownloadFromTexture(const QVariant &handle, +void VulkanRenderer::download_from_texture(const QVariant &handle, const VideoParams ¶ms, void *data, int linesize) { @@ -1702,8 +1702,8 @@ void VulkanRenderer::DownloadFromTexture(const QVariant &handle, int width = params.effective_width(); int height = params.effective_height(); int cpu_bytes_per_pixel = - VideoParams::GetBytesPerPixel(params.format(), params.channel_count()); - int gpu_bytes_per_pixel = GetVkFormatBytesPerPixel(tex->vk_format); + VideoParams::get_bytes_per_pixel(params.format(), params.channel_count()); + int gpu_bytes_per_pixel = get_vk_format_bytes_per_pixel(tex->vk_format); if (gpu_bytes_per_pixel == 0) { gpu_bytes_per_pixel = cpu_bytes_per_pixel; } @@ -1716,23 +1716,23 @@ void VulkanRenderer::DownloadFromTexture(const QVariant &handle, VkBuffer staging_buffer; VkDeviceMemory staging_memory; - if (!CreateStagingBuffer(image_size, &staging_buffer, &staging_memory)) { + if (!create_staging_buffer(image_size, &staging_buffer, &staging_memory)) { return; } - VkCommandBuffer cmd = BeginOneTimeCommands(); + VkCommandBuffer cmd = begin_one_time_commands(); if (cmd == VK_NULL_HANDLE) { return; } if (tex->current_layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { - TransitionImageLayout(cmd, tex->image, tex->current_layout, + transition_image_layout(cmd, tex->image, tex->current_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); } - CopyImageToBuffer(cmd, tex->image, staging_buffer, + copy_image_to_buffer(cmd, tex->image, staging_buffer, static_cast(width), static_cast(height)); - EndOneTimeCommands(cmd); + end_one_time_commands(cmd); void *mapped; vkMapMemory(device_, staging_memory, 0, image_size, 0, &mapped); @@ -1750,10 +1750,10 @@ void VulkanRenderer::DownloadFromTexture(const QVariant &handle, } } else { int gpu_channels = gpu_bytes_per_pixel / - VideoParams::GetBytesPerChannel(params.format()); + VideoParams::get_bytes_per_channel(params.format()); QByteArray tmp(width * height * gpu_bytes_per_pixel, Qt::Uninitialized); memcpy(tmp.data(), mapped, static_cast(tmp.size())); - CopyPixelsWithChannelConversion(tmp.constData(), data, width, height, 1, + copy_pixels_with_channel_conversion(tmp.constData(), data, width, height, 1, gpu_channels, params.channel_count(), params.format()); if (linesize != width) { @@ -1770,12 +1770,12 @@ void VulkanRenderer::DownloadFromTexture(const QVariant &handle, } vkUnmapMemory(device_, staging_memory); - DestroyStagingBuffer(staging_buffer, staging_memory); + destroy_staging_buffer(staging_buffer, staging_memory); tex->current_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; } // Blocks until the device is idle so later CPU readback or teardown is safe. -void VulkanRenderer::Flush() +void VulkanRenderer::flush() { if (device_ != VK_NULL_HANDLE) { vkDeviceWaitIdle(device_); @@ -1784,12 +1784,12 @@ void VulkanRenderer::Flush() // Clears a texture with vkCmdClearColorImage; null destinations are ignored // because this backend has no implicit swapchain framebuffer. -void VulkanRenderer::ClearDestination(olive::Texture *texture, double r, +void VulkanRenderer::clear_destination(olive::Texture *texture, double r, double g, double b, double a) { QMutexLocker lock(&mutex_); - VkCommandBuffer cmd = BeginOneTimeCommands(); + VkCommandBuffer cmd = begin_one_time_commands(); if (cmd == VK_NULL_HANDLE) { return; @@ -1798,11 +1798,11 @@ void VulkanRenderer::ClearDestination(olive::Texture *texture, double r, quint64 id = texture->id().value(); VulkanTexture *tex = textures_.value(id); if (!tex) { - EndOneTimeCommands(cmd); + end_one_time_commands(cmd); return; } if (tex->current_layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) { - TransitionImageLayout(cmd, tex->image, tex->current_layout, + transition_image_layout(cmd, tex->image, tex->current_layout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); } VkClearColorValue clear_color = {}; @@ -1819,22 +1819,22 @@ void VulkanRenderer::ClearDestination(olive::Texture *texture, double r, vkCmdClearColorImage(cmd, tex->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_color, 1, &range); - TransitionImageLayout(cmd, tex->image, + transition_image_layout(cmd, tex->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); tex->current_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; } - EndOneTimeCommands(cmd); + end_one_time_commands(cmd); } // Reads one pixel by copying a 1x1 image region into a staging buffer. -Color VulkanRenderer::GetPixelFromTexture(olive::Texture *texture, +Color VulkanRenderer::get_pixel_from_texture(olive::Texture *texture, const QPointF &pt) { if (!texture) { return Color(); } - int cpu_bytes_per_pixel = VideoParams::GetBytesPerPixel( + int cpu_bytes_per_pixel = VideoParams::get_bytes_per_pixel( texture->format(), texture->channel_count()); QByteArray data(cpu_bytes_per_pixel, Qt::Uninitialized); @@ -1850,29 +1850,29 @@ Color VulkanRenderer::GetPixelFromTexture(olive::Texture *texture, uint32_t py = static_cast(qBound(0.0, pt.y(), double(tex->height - 1))); - int gpu_bytes_per_pixel = GetVkFormatBytesPerPixel(tex->vk_format); + int gpu_bytes_per_pixel = get_vk_format_bytes_per_pixel(tex->vk_format); if (gpu_bytes_per_pixel == 0) { gpu_bytes_per_pixel = cpu_bytes_per_pixel; } VkBuffer staging_buffer; VkDeviceMemory staging_memory; - if (!CreateStagingBuffer(gpu_bytes_per_pixel, &staging_buffer, + if (!create_staging_buffer(gpu_bytes_per_pixel, &staging_buffer, &staging_memory)) { return Color(); } - VkCommandBuffer cmd = BeginOneTimeCommands(); + VkCommandBuffer cmd = begin_one_time_commands(); if (cmd == VK_NULL_HANDLE) { return Color(); } if (tex->current_layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { - TransitionImageLayout(cmd, tex->image, tex->current_layout, + transition_image_layout(cmd, tex->image, tex->current_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); } - CopyImageToBuffer(cmd, tex->image, staging_buffer, 1, 1, px, py); - EndOneTimeCommands(cmd); + copy_image_to_buffer(cmd, tex->image, staging_buffer, 1, 1, px, py); + end_one_time_commands(cmd); void *mapped; vkMapMemory(device_, staging_memory, 0, gpu_bytes_per_pixel, 0, &mapped); @@ -1880,21 +1880,21 @@ Color VulkanRenderer::GetPixelFromTexture(olive::Texture *texture, memcpy(data.data(), mapped, static_cast(cpu_bytes_per_pixel)); } else { int gpu_channels = gpu_bytes_per_pixel / - VideoParams::GetBytesPerChannel(texture->format()); + VideoParams::get_bytes_per_channel(texture->format()); QByteArray gpu_pixel(gpu_bytes_per_pixel, Qt::Uninitialized); memcpy(gpu_pixel.data(), mapped, static_cast(gpu_bytes_per_pixel)); - CopyPixelsWithChannelConversion(gpu_pixel.constData(), data.data(), 1, + copy_pixels_with_channel_conversion(gpu_pixel.constData(), data.data(), 1, 1, 1, gpu_channels, texture->channel_count(), texture->format()); } vkUnmapMemory(device_, staging_memory); - DestroyStagingBuffer(staging_buffer, staging_memory); + destroy_staging_buffer(staging_buffer, staging_memory); tex->current_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; - return Color::fromData(data.data(), texture->format(), + return Color::from_data(data.data(), texture->format(), texture->channel_count()); } @@ -1903,7 +1903,7 @@ Color VulkanRenderer::GetPixelFromTexture(olive::Texture *texture, // ------------------------------------------------------------------ // Returns true for GLSL sampler uniforms that must become explicit descriptors. -static bool IsSamplerType(const QString &type) +static bool is_sampler_type(const QString &type) { static const QRegularExpression sampler_re( QStringLiteral(R"(sampler\d*D|samplerCube|sampler2DArray|sampler3D)")); @@ -1912,7 +1912,7 @@ static bool IsSamplerType(const QString &type) // Ensures GLSL has a Vulkan-compatible version directive before shaderc compiles // it as GLSL 450. -QString VulkanRenderer::EnsureGlslVersion450(const QString &glsl) const +QString VulkanRenderer::ensure_glsl_version450(const QString &glsl) const { QString result = glsl.trimmed(); if (result.startsWith(QStringLiteral("#version"))) { @@ -1926,7 +1926,7 @@ QString VulkanRenderer::EnsureGlslVersion450(const QString &glsl) const // Converts legacy Oak/OpenGL GLSL into Vulkan GLSL. The conversion keeps shader // semantics but replaces implicit attributes/varyings and texture sampling with // explicit layouts that Vulkan requires. -QString VulkanRenderer::ConvertGlslToVulkan(const QString &glsl, +QString VulkanRenderer::convert_glsl_to_vulkan(const QString &glsl, VkShaderStageFlagBits stage) { QString result = glsl; @@ -1962,7 +1962,7 @@ QString VulkanRenderer::ConvertGlslToVulkan(const QString &glsl, } // Returns the std140 storage size for scalar, vector, color, and matrix values. -VkDeviceSize VulkanRenderer::GetStd140Size(const QString &type) const +VkDeviceSize VulkanRenderer::get_std140_size(const QString &type) const { if (type == QStringLiteral("float")) return 4; @@ -1980,7 +1980,7 @@ VkDeviceSize VulkanRenderer::GetStd140Size(const QString &type) const } // Returns std140 base alignment so generated UBO offsets match GPU layout rules. -VkDeviceSize VulkanRenderer::GetStd140Alignment(const QString &type) const +VkDeviceSize VulkanRenderer::get_std140_alignment(const QString &type) const { if (type == QStringLiteral("float")) return 4; @@ -1999,7 +1999,7 @@ VkDeviceSize VulkanRenderer::GetStd140Alignment(const QString &type) const // Scans GLSL uniform declarations and splits them into samplers and values. This // is intentionally narrow and targets the shader style generated by Oak nodes. -void VulkanRenderer::ExtractUniforms(const QString &glsl, +void VulkanRenderer::extract_uniforms(const QString &glsl, QVector *out_uniforms, QVector *out_samplers) const { @@ -2013,7 +2013,7 @@ void VulkanRenderer::ExtractUniforms(const QString &glsl, QString type = m.captured(1); QString name = m.captured(2); - if (IsSamplerType(type)) { + if (is_sampler_type(type)) { if (out_samplers && !out_samplers->contains(name)) { out_samplers->append(name); } @@ -2038,21 +2038,21 @@ void VulkanRenderer::ExtractUniforms(const QString &glsl, } // Computes std140 offsets in declaration order and records the total UBO size. -void VulkanRenderer::ComputeUniformLayout(QVector *uniforms) const +void VulkanRenderer::compute_uniform_layout(QVector *uniforms) const { VkDeviceSize offset = 0; for (UniformInfo &info : *uniforms) { - VkDeviceSize align = GetStd140Alignment(info.type); - offset = AlignSize(offset, align); + VkDeviceSize align = get_std140_alignment(info.type); + offset = align_size(offset, align); info.offset = offset; - info.size = GetStd140Size(info.type); + info.size = get_std140_size(info.type); offset += info.size; } } // Generates the uniform block source inserted into rewritten shaders. QString -VulkanRenderer::BuildUboBlock(const QVector &uniforms) const +VulkanRenderer::build_ubo_block(const QVector &uniforms) const { if (uniforms.isEmpty()) { return QString(); @@ -2069,7 +2069,7 @@ VulkanRenderer::BuildUboBlock(const QVector &uniforms) const // Rewrites GLSL so non-sampler uniforms live in set=0,binding=0 and sampler // uniforms get deterministic explicit bindings after the UBO. -QString VulkanRenderer::RewriteShaderWithUbo( +QString VulkanRenderer::rewrite_shader_with_ubo( const QString &glsl, const QVector &all_uniforms, const QHash &sampler_bindings) const { @@ -2091,7 +2091,7 @@ QString VulkanRenderer::RewriteShaderWithUbo( QString type = m.captured(1); QString name = m.captured(2); - if (IsSamplerType(type)) { + if (is_sampler_type(type)) { int binding = sampler_bindings.value(name, -1); if (binding >= 0) { QString new_decl = @@ -2116,7 +2116,7 @@ QString VulkanRenderer::RewriteShaderWithUbo( // Third pass: insert the shared UBO block after the #version line. if (!all_uniforms.isEmpty()) { - QString ubo = BuildUboBlock(all_uniforms); + QString ubo = build_ubo_block(all_uniforms); int version_end = result.indexOf(QChar('\n')); if (version_end >= 0 && result.startsWith(QStringLiteral("#version"))) { result.insert(version_end + 1, ubo); @@ -2130,7 +2130,7 @@ QString VulkanRenderer::RewriteShaderWithUbo( // Compiles Vulkan GLSL into SPIR-V using shaderc. Without shaderc this backend // can initialize but cannot create shaders. -bool VulkanRenderer::CompileGlslToSpv(const QString &glsl, +bool VulkanRenderer::compile_glsl_to_spv(const QString &glsl, VkShaderStageFlagBits stage, QByteArray *out_spv) { @@ -2161,7 +2161,7 @@ bool VulkanRenderer::CompileGlslToSpv(const QString &glsl, return false; } - QString converted = ConvertGlslToVulkan(glsl, stage); + QString converted = convert_glsl_to_vulkan(glsl, stage); QByteArray source_utf8 = converted.toUtf8(); shaderc_compilation_result_t compile_result = shaderc_compile_into_spv( @@ -2197,7 +2197,7 @@ bool VulkanRenderer::CompileGlslToSpv(const QString &glsl, } // Converts, compiles, and stores a shader pair plus descriptor metadata. -QVariant VulkanRenderer::CreateNativeShader(olive::ShaderCode code) +QVariant VulkanRenderer::create_native_shader(olive::ShaderCode code) { QMutexLocker lock(&mutex_); @@ -2209,17 +2209,17 @@ QVariant VulkanRenderer::CreateNativeShader(olive::ShaderCode code) // Use default shaders if empty if (vert_code.isEmpty()) { - vert_code = FileFunctions::ReadFileAsString( + vert_code = FileFunctions::read_file_as_string( QStringLiteral(":/shaders/default.vert")); } if (frag_code.isEmpty()) { - frag_code = FileFunctions::ReadFileAsString( + frag_code = FileFunctions::read_file_as_string( QStringLiteral(":/shaders/default.frag")); } // Make sure both stages declare a Vulkan-compatible version. - vert_code = EnsureGlslVersion450(vert_code); - frag_code = EnsureGlslVersion450(frag_code); + vert_code = ensure_glsl_version450(vert_code); + frag_code = ensure_glsl_version450(frag_code); // Extract uniforms and samplers from both stages. We build a single shared // UBO layout and a single sampler binding table so both vertex and fragment @@ -2228,8 +2228,8 @@ QVariant VulkanRenderer::CreateNativeShader(olive::ShaderCode code) QVector frag_uniforms; QVector vert_samplers; QVector frag_samplers; - ExtractUniforms(vert_code, &vert_uniforms, &vert_samplers); - ExtractUniforms(frag_code, &frag_uniforms, &frag_samplers); + extract_uniforms(vert_code, &vert_uniforms, &vert_samplers); + extract_uniforms(frag_code, &frag_uniforms, &frag_samplers); QVector all_uniforms = vert_uniforms; for (const UniformInfo &fu : frag_uniforms) { @@ -2244,7 +2244,7 @@ QVariant VulkanRenderer::CreateNativeShader(olive::ShaderCode code) all_uniforms.append(fu); } } - ComputeUniformLayout(&all_uniforms); + compute_uniform_layout(&all_uniforms); QVector all_samplers = vert_samplers; for (const QString &name : frag_samplers) { @@ -2258,22 +2258,22 @@ QVariant VulkanRenderer::CreateNativeShader(olive::ShaderCode code) } QString converted_vert = - RewriteShaderWithUbo(vert_code, all_uniforms, sampler_bindings); + rewrite_shader_with_ubo(vert_code, all_uniforms, sampler_bindings); QString converted_frag = - RewriteShaderWithUbo(frag_code, all_uniforms, sampler_bindings); + rewrite_shader_with_ubo(frag_code, all_uniforms, sampler_bindings); converted_vert = - ConvertGlslToVulkan(converted_vert, VK_SHADER_STAGE_VERTEX_BIT); + convert_glsl_to_vulkan(converted_vert, VK_SHADER_STAGE_VERTEX_BIT); converted_frag = - ConvertGlslToVulkan(converted_frag, VK_SHADER_STAGE_FRAGMENT_BIT); + convert_glsl_to_vulkan(converted_frag, VK_SHADER_STAGE_FRAGMENT_BIT); - if (!CompileGlslToSpv(converted_vert, VK_SHADER_STAGE_VERTEX_BIT, + if (!compile_glsl_to_spv(converted_vert, VK_SHADER_STAGE_VERTEX_BIT, &vert_spv)) { fprintf(stderr, "Failed to compile Vulkan vertex shader:\n%s\n", converted_vert.toUtf8().constData()); return QVariant(); } - if (!CompileGlslToSpv(converted_frag, VK_SHADER_STAGE_FRAGMENT_BIT, + if (!compile_glsl_to_spv(converted_frag, VK_SHADER_STAGE_FRAGMENT_BIT, &frag_spv)) { fprintf(stderr, "Failed to compile Vulkan fragment shader:\n%s\n", converted_frag.toUtf8().constData()); @@ -2374,7 +2374,7 @@ QVariant VulkanRenderer::CreateNativeShader(olive::ShaderCode code) } // Releases shader modules, descriptor layout, pipeline layout, and pipelines. -void VulkanRenderer::DestroyNativeShader(QVariant shader) +void VulkanRenderer::destroy_native_shader(QVariant shader) { QMutexLocker lock(&mutex_); quint64 id = shader.value(); @@ -2406,7 +2406,7 @@ void VulkanRenderer::DestroyNativeShader(QVariant shader) // Creates a graphics pipeline for the destination render format. Viewport and // scissor are dynamic so one pipeline can handle multiple target sizes. -bool VulkanRenderer::CreatePipelineForShader(VulkanShader *shader, +bool VulkanRenderer::create_pipeline_for_shader(VulkanShader *shader, const VideoParams &dest_params, VkFormat render_pass_format) @@ -2521,7 +2521,7 @@ bool VulkanRenderer::CreatePipelineForShader(VulkanShader *shader, pipeline_info.pColorBlendState = &color_blending; pipeline_info.pDynamicState = &dynamic_state; pipeline_info.layout = shader->pipeline_layout; - pipeline_info.renderPass = GetOrCreateRenderPass(render_pass_format, false); + pipeline_info.renderPass = get_or_create_render_pass(render_pass_format, false); pipeline_info.subpass = 0; VkPipeline new_pipeline = VK_NULL_HANDLE; @@ -2538,7 +2538,7 @@ bool VulkanRenderer::CreatePipelineForShader(VulkanShader *shader, // Executes one fullscreen draw pass. Texture descriptors and a transient UBO are // allocated per pass so iterative shaders can update bindings cheaply. -void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, +void VulkanRenderer::blit_pass(VulkanShader *shader, VulkanTexture *dest_tex, const QVector &bindings, const QByteArray &ubo_data, const VideoParams &destination_params, @@ -2552,12 +2552,12 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, VkFormat render_pass_format = dest_tex->vk_format; VkRenderPass render_pass = - GetOrCreateRenderPass(render_pass_format, clear_destination); + get_or_create_render_pass(render_pass_format, clear_destination); if (render_pass == VK_NULL_HANDLE) { return; } - if (!CreatePipelineForShader(shader, destination_params, + if (!create_pipeline_for_shader(shader, destination_params, render_pass_format)) { return; } @@ -2570,7 +2570,7 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, if (dest_tex->framebuffer == VK_NULL_HANDLE) { VkFramebufferCreateInfo fb_info = {}; fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - fb_info.renderPass = GetOrCreateRenderPass(render_pass_format, false); + fb_info.renderPass = get_or_create_render_pass(render_pass_format, false); fb_info.attachmentCount = 1; fb_info.pAttachments = &dest_tex->view; fb_info.width = static_cast(dest_tex->width); @@ -2589,7 +2589,7 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, VkBuffer ubo_buffer = VK_NULL_HANDLE; VkDeviceMemory ubo_memory = VK_NULL_HANDLE; if (shader->ubo_size > 0 && !ubo_data.isEmpty()) { - if (CreateStagingBuffer(shader->ubo_size, &ubo_buffer, &ubo_memory)) { + if (create_staging_buffer(shader->ubo_size, &ubo_buffer, &ubo_memory)) { void *mapped; vkMapMemory(device_, ubo_memory, 0, shader->ubo_size, 0, &mapped); memcpy(mapped, ubo_data.constData(), @@ -2605,7 +2605,7 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, QVector image_infos; bool descriptors_needed = (shader->ubo_size > 0 || !bindings.isEmpty()); if (descriptors_needed) { - if (descriptor_sets_since_reset_ >= kMaxDescriptorSets - 16) { + if (descriptor_sets_since_reset_ >= k_max_descriptor_sets - 16) { vkResetDescriptorPool(device_, descriptor_pool_, 0); descriptor_sets_since_reset_ = 0; } @@ -2621,7 +2621,7 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, if (result != VK_SUCCESS) { qWarning() << "Failed to allocate Vulkan descriptor set:" << result; if (ubo_buffer != VK_NULL_HANDLE) { - DestroyStagingBuffer(ubo_buffer, ubo_memory); + destroy_staging_buffer(ubo_buffer, ubo_memory); } return; } @@ -2652,7 +2652,7 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, for (int i = 0; i < bindings.size() && i < 16; i++) { const TextureBinding &tb = bindings.at(i); VkDescriptorImageInfo img_info = {}; - img_info.sampler = GetSampler(tb.interp); + img_info.sampler = get_sampler(tb.interp); img_info.imageView = tb.tex ? tb.tex->view : VK_NULL_HANDLE; img_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; image_infos.append(img_info); @@ -2685,14 +2685,14 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, } } - VkCommandBuffer cmd = BeginOneTimeCommands(); + VkCommandBuffer cmd = begin_one_time_commands(); if (cmd == VK_NULL_HANDLE) { return; } if (dest_tex->current_layout != VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) { - TransitionImageLayout(cmd, dest_tex->image, dest_tex->current_layout, + transition_image_layout(cmd, dest_tex->image, dest_tex->current_layout, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); dest_tex->current_layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; } @@ -2700,7 +2700,7 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, for (const TextureBinding &tb : bindings) { if (tb.tex && tb.tex->current_layout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) { - TransitionImageLayout(cmd, tb.tex->image, tb.tex->current_layout, + transition_image_layout(cmd, tb.tex->image, tb.tex->current_layout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); tb.tex->current_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } @@ -2760,21 +2760,21 @@ void VulkanRenderer::BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, // Leave the destination in a shader-readable state so it can be sampled or // downloaded without an extra layout transition on the caller side. - TransitionImageLayout(cmd, dest_tex->image, + transition_image_layout(cmd, dest_tex->image, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); dest_tex->current_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - EndOneTimeCommands(cmd); + end_one_time_commands(cmd); if (ubo_buffer != VK_NULL_HANDLE) { - DestroyStagingBuffer(ubo_buffer, ubo_memory); + destroy_staging_buffer(ubo_buffer, ubo_memory); } } // Runs a shader job. Multi-iteration jobs ping-pong between temporary textures // and replace the configured iterative input with the previous pass output. -void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, +void VulkanRenderer::blit(QVariant shader_variant, olive::AcceleratedJob &a_job, olive::Texture *destination, VideoParams destination_params, bool clear_destination) @@ -2790,8 +2790,8 @@ void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, // Iterative shaders require ping-pong textures. Create them before locking // the renderer mutex because CreateTexture also locks it. int real_iteration_count = 1; - if (job.GetIterationCount() > 1 && !job.GetIterativeInput().isEmpty()) { - real_iteration_count = job.GetIterationCount(); + if (job.get_iteration_count() > 1 && !job.get_iterative_input().isEmpty()) { + real_iteration_count = job.get_iteration_count(); } struct PingPongTexture { @@ -2801,14 +2801,14 @@ void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, PingPongTexture output_tex, input_tex, final_tex; if (real_iteration_count > 1) { - output_tex.texture = CreateTexture(destination_params); + output_tex.texture = create_texture(destination_params); if (real_iteration_count > 2) { - input_tex.texture = CreateTexture(destination_params); + input_tex.texture = create_texture(destination_params); } } if (!destination) { - final_tex.texture = CreateTexture(destination_params); + final_tex.texture = create_texture(destination_params); } QMutexLocker lock(&mutex_); @@ -2853,18 +2853,18 @@ void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, base_ubo_data.fill(0); } - for (auto it = job.GetValues().constBegin(); - it != job.GetValues().constEnd(); ++it) { + for (auto it = job.get_values().constBegin(); + it != job.get_values().constEnd(); ++it) { const NodeValue &value = it.value(); - if (value.type() == NodeValue::kTexture) { - TexturePtr texture = value.toTexture(); + if (value.type() == NodeValue::k_texture) { + TexturePtr texture = value.to_texture(); VulkanTexture *vtex = nullptr; if (texture) { quint64 tid = texture->id().value(); vtex = textures_.value(tid); } base_bindings.append( - { it.key(), vtex, job.GetInterpolation(it.key()) }); + { it.key(), vtex, job.get_interpolation(it.key()) }); } else if (!shader->uniforms.isEmpty() && shader->ubo_size > 0) { // Find matching uniform for (const UniformInfo &u : shader->uniforms) { @@ -2872,39 +2872,39 @@ void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, continue; char *dst = base_ubo_data.data() + static_cast(u.offset); switch (value.type()) { - case NodeValue::kFloat: + case NodeValue::k_float: *reinterpret_cast(dst) = - static_cast(value.toDouble()); + static_cast(value.to_double()); break; - case NodeValue::kInt: + case NodeValue::k_int: *reinterpret_cast(dst) = - static_cast(value.toInt()); + static_cast(value.to_int()); break; - case NodeValue::kBoolean: - *reinterpret_cast(dst) = value.toBool() ? 1 : 0; + case NodeValue::k_boolean: + *reinterpret_cast(dst) = value.to_bool() ? 1 : 0; break; - case NodeValue::kVec2: { - QVector2D v = value.toVec2(); + case NodeValue::k_vec2: { + QVector2D v = value.to_vec2(); memcpy(dst, &v, sizeof(float) * 2); break; } - case NodeValue::kVec3: { - QVector3D v = value.toVec3(); + case NodeValue::k_vec3: { + QVector3D v = value.to_vec3(); memcpy(dst, &v, sizeof(float) * 3); break; } - case NodeValue::kVec4: { - QVector4D v = value.toVec4(); + case NodeValue::k_vec4: { + QVector4D v = value.to_vec4(); memcpy(dst, &v, sizeof(float) * 4); break; } - case NodeValue::kMatrix: { - QMatrix4x4 m = value.toMatrix(); + case NodeValue::k_matrix: { + QMatrix4x4 m = value.to_matrix(); memcpy(dst, m.constData(), sizeof(float) * 16); break; } - case NodeValue::kColor: { - Color c = value.toColor(); + case NodeValue::k_color: { + Color c = value.to_color(); float col[4] = { static_cast(c.red()), static_cast(c.green()), static_cast(c.blue()), @@ -2912,8 +2912,8 @@ void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, memcpy(dst, col, sizeof(float) * 4); break; } - case NodeValue::kCombo: - *reinterpret_cast(dst) = value.toInt(); + case NodeValue::k_combo: + *reinterpret_cast(dst) = value.to_int(); break; default: break; @@ -2928,18 +2928,18 @@ void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, for (const UniformInfo &u : shader->uniforms) { char *dst = base_ubo_data.data() + static_cast(u.offset); if (u.name == QStringLiteral("ove_mvpmat")) { - QMatrix4x4 m = job.Get(QStringLiteral("ove_mvpmat")).toMatrix(); + QMatrix4x4 m = job.get(QStringLiteral("ove_mvpmat")).to_matrix(); memcpy(dst, m.constData(), sizeof(float) * 16); } else if (u.name == QStringLiteral("ove_cropmatrix")) { QMatrix4x4 m = - job.Get(QStringLiteral("ove_cropmatrix")).toMatrix(); + job.get(QStringLiteral("ove_cropmatrix")).to_matrix(); memcpy(dst, m.constData(), sizeof(float) * 16); } else if (u.name == QStringLiteral("ove_maintex_alpha")) { *reinterpret_cast(dst) = - job.Get(QStringLiteral("ove_maintex_alpha")).toInt(); + job.get(QStringLiteral("ove_maintex_alpha")).to_int(); } else if (u.name == QStringLiteral("ove_force_opaque")) { *reinterpret_cast(dst) = - job.Get(QStringLiteral("ove_force_opaque")).toBool() ? 1 : + job.get(QStringLiteral("ove_force_opaque")).to_bool() ? 1 : 0; } } @@ -2985,7 +2985,7 @@ void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, } if (iteration > 0) { - const QString &iterative_input = job.GetIterativeInput(); + const QString &iterative_input = job.get_iterative_input(); for (TextureBinding &tb : pass_bindings) { if (tb.name == iterative_input) { tb.tex = input_tex.native; @@ -2994,7 +2994,7 @@ void VulkanRenderer::Blit(QVariant shader_variant, olive::AcceleratedJob &a_job, } } - BlitPass(shader, pass_dest, pass_bindings, pass_ubo_data, + blit_pass(shader, pass_dest, pass_bindings, pass_ubo_data, destination_params, pass_clear, iteration); if (iteration != real_iteration_count - 1) { diff --git a/app/render/vulkan/vulkanrenderer.h b/app/render/vulkan/vulkanrenderer.h index 48687b8f9..12f21fcfd 100644 --- a/app/render/vulkan/vulkanrenderer.h +++ b/app/render/vulkan/vulkanrenderer.h @@ -18,8 +18,8 @@ ***************************************************************************/ -#ifndef VULKANRENDERER_H -#define VULKANRENDERER_H +#ifndef OAK_VULKANRENDERER_H +#define OAK_VULKANRENDERER_H #include @@ -42,67 +42,67 @@ public: // Creates the Vulkan instance, logical device, command pool, and descriptor // pool required for offscreen rendering. - virtual bool Init() override; + virtual bool init() override; // Creates reusable GPU resources that require a fully initialized device. - virtual void PostInit() override; + virtual void post_init() override; // Reserved for symmetry with OpenGLRenderer; Vulkan cleanup is handled by // DestroyInternal(). - virtual void PostDestroy() override; + virtual void post_destroy() override; // Clears either a texture render target or the currently bound output target. - virtual void ClearDestination(olive::Texture *texture = nullptr, + virtual void clear_destination(olive::Texture *texture = nullptr, double r = 0.0, double g = 0.0, double b = 0.0, double a = 0.0) override; // Compiles GLSL to SPIR-V, creates shader modules, and prepares descriptor // metadata for later blits. - virtual QVariant CreateNativeShader(olive::ShaderCode code) override; + virtual QVariant create_native_shader(olive::ShaderCode code) override; // Destroys shader modules, descriptor layout, pipeline layout, and cached // pipelines associated with a shader handle. - virtual void DestroyNativeShader(QVariant shader) override; + virtual void destroy_native_shader(QVariant shader) override; // Uploads CPU pixel data to a Vulkan image via a staging buffer. - virtual void UploadToTexture(const QVariant &handle, + virtual void upload_to_texture(const QVariant &handle, const VideoParams ¶ms, const void *data, int linesize) override; // Downloads a Vulkan image to CPU memory via a staging buffer. - virtual void DownloadFromTexture(const QVariant &handle, + virtual void download_from_texture(const QVariant &handle, const VideoParams ¶ms, void *data, int linesize) override; // Waits for outstanding device work to complete. - virtual void Flush() override; + virtual void flush() override; - virtual bool IsVulkan() const override + virtual bool is_vulkan() const override { return true; } // Reads a single texture pixel using a one-pixel transfer readback. - virtual Color GetPixelFromTexture(olive::Texture *texture, + virtual Color get_pixel_from_texture(olive::Texture *texture, const QPointF &pt) override; - bool IsAvailable() const + bool is_available() const { return device_ != VK_NULL_HANDLE; } protected: // Runs one or more fullscreen shader passes into the destination texture. - virtual void Blit(QVariant shader, olive::AcceleratedJob &job, + virtual void blit(QVariant shader, olive::AcceleratedJob &job, olive::Texture *destination, VideoParams destination_params, bool clear_destination) override; // Creates a Vulkan image/view/memory bundle and optionally uploads initial // pixel data. - virtual QVariant CreateNativeTexture(int width, int height, int depth, + virtual QVariant create_native_texture(int width, int height, int depth, PixelFormat format, int channel_count, const void *data = nullptr, int linesize = 0) override; // Releases a Vulkan texture bundle. - virtual void DestroyNativeTexture(QVariant texture) override; + virtual void destroy_native_texture(QVariant texture) override; // Releases all Vulkan device resources owned by this renderer. - virtual void DestroyInternal() override; + virtual void destroy_internal() override; private: struct VulkanTexture; @@ -111,113 +111,113 @@ private: struct StagingBuffer; // Creates the Vulkan instance used for all offscreen work. - bool CreateInstance(); + bool create_instance(); // Creates the debug messenger when validation layers are available. - bool CreateDebugMessenger(); + bool create_debug_messenger(); // Destroys the debug messenger before the instance is destroyed. - void DestroyDebugMessenger(); + void destroy_debug_messenger(); // Validation layer callback; logs errors/warnings so synchronization issues // are visible before they become GPU hangs. static VKAPI_ATTR VkBool32 VKAPI_CALL - DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, - VkDebugUtilsMessageTypeFlagsEXT messageType, - const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, - void *pUserData); + debug_callback(VkDebugUtilsMessageSeverityFlagBitsEXT message_severity, + VkDebugUtilsMessageTypeFlagsEXT message_type, + const VkDebugUtilsMessengerCallbackDataEXT *p_callback_data, + void *p_user_data); // Chooses a graphics-capable physical device and creates the logical device. - bool CreateDevice(); + bool create_device(); // Creates a command pool for short-lived command buffers. - bool CreateCommandPool(); + bool create_command_pool(); // Creates the descriptor pool used for per-blit UBO/sampler sets. - bool CreateDescriptorPool(); + bool create_descriptor_pool(); // Uploads the fullscreen quad vertex buffer used by BlitPass(). - bool CreateVertexBuffer(); + bool create_vertex_buffer(); // Creates the persistent linear sampler. - bool CreateLinearSampler(); + bool create_linear_sampler(); // Creates the persistent nearest-neighbor sampler. - bool CreateNearestSampler(); + bool create_nearest_sampler(); // Returns the persistent sampler matching the requested interpolation mode. - VkSampler GetSampler(Texture::Interpolation interpolation) const; + VkSampler get_sampler(Texture::Interpolation interpolation) const; // Allocates a host-visible staging buffer for upload/download transfers. - bool CreateStagingBuffer(VkDeviceSize size, VkBuffer *out_buffer, + bool create_staging_buffer(VkDeviceSize size, VkBuffer *out_buffer, VkDeviceMemory *out_memory); // Destroys a staging buffer pair allocated by CreateStagingBuffer(). - void DestroyStagingBuffer(VkBuffer buffer, VkDeviceMemory memory); + void destroy_staging_buffer(VkBuffer buffer, VkDeviceMemory memory); // Begins a one-shot command buffer and records it immediately. - VkCommandBuffer BeginOneTimeCommands(); + VkCommandBuffer begin_one_time_commands(); // Submits and waits for a one-shot command buffer. - void EndOneTimeCommands(VkCommandBuffer cmd); + void end_one_time_commands(VkCommandBuffer cmd); // Emits an image memory barrier for the subset of layouts this renderer uses. - void TransitionImageLayout(VkCommandBuffer cmd, VkImage image, + void transition_image_layout(VkCommandBuffer cmd, VkImage image, VkImageLayout old_layout, VkImageLayout new_layout); // Records a tightly packed buffer-to-image copy. - void CopyBufferToImage(VkCommandBuffer cmd, VkBuffer buffer, VkImage image, + void copy_buffer_to_image(VkCommandBuffer cmd, VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, uint32_t depth); // Records an image-to-buffer copy, optionally reading one pixel offset. - void CopyImageToBuffer(VkCommandBuffer cmd, VkImage image, VkBuffer buffer, + void copy_image_to_buffer(VkCommandBuffer cmd, VkImage image, VkBuffer buffer, uint32_t width, uint32_t height, uint32_t offset_x = 0, uint32_t offset_y = 0); // Converts Oak pixel format/channel metadata to a preferred Vulkan format. - VkFormat PixelFormatToVkFormat(PixelFormat format, int channel_count) const; + VkFormat pixel_format_to_vk_format(PixelFormat format, int channel_count) const; // Picks a color-attachment-capable format, falling back from RGB to RGBA // where drivers do not support 3-channel render targets. - VkFormat PickRenderableFormat(PixelFormat format, int channel_count) const; + VkFormat pick_renderable_format(PixelFormat format, int channel_count) const; // Checks whether a format can be used as a render target. - bool IsColorAttachmentSupported(VkFormat format) const; + bool is_color_attachment_supported(VkFormat format) const; // Returns the packed byte size for supported VkFormat values. - int GetVkFormatBytesPerPixel(VkFormat format) const; + int get_vk_format_bytes_per_pixel(VkFormat format) const; // Returns the alpha fill value used when expanding RGB data to RGBA. - float GetFormatMaxAlpha(PixelFormat format) const; + float get_format_max_alpha(PixelFormat format) const; // Repackages tightly packed pixels when the requested CPU channel count // differs from the selected GPU format channel count. - void CopyPixelsWithChannelConversion(const void *src, void *dst, int width, + void copy_pixels_with_channel_conversion(const void *src, void *dst, int width, int height, int depth, int src_channels, int dst_channels, PixelFormat format) const; // Rounds a size up to the requested alignment. - VkDeviceSize AlignSize(VkDeviceSize size, VkDeviceSize alignment) const; + VkDeviceSize align_size(VkDeviceSize size, VkDeviceSize alignment) const; // Finds a Vulkan memory type matching the requested properties. - uint32_t FindMemoryType(uint32_t type_filter, + uint32_t find_memory_type(uint32_t type_filter, VkMemoryPropertyFlags properties) const; // Compiles GLSL source into SPIR-V using shaderc when available. - bool CompileGlslToSpv(const QString &glsl, VkShaderStageFlagBits stage, + bool compile_glsl_to_spv(const QString &glsl, VkShaderStageFlagBits stage, QByteArray *out_spv); // Rewrites an Oak GLSL shader into Vulkan-compatible GLSL. - QString ConvertGlslToVulkan(const QString &glsl, + QString convert_glsl_to_vulkan(const QString &glsl, VkShaderStageFlagBits stage); // Ensures a shader declares a Vulkan-compatible GLSL version. - QString EnsureGlslVersion450(const QString &glsl) const; + QString ensure_glsl_version450(const QString &glsl) const; // Extracts uniforms and sampler names from GLSL declarations. - void ExtractUniforms(const QString &glsl, + void extract_uniforms(const QString &glsl, QVector *out_uniforms, QVector *out_samplers) const; // Computes std140 offsets and total UBO size for extracted uniforms. - void ComputeUniformLayout(QVector *uniforms) const; + void compute_uniform_layout(QVector *uniforms) const; // Builds the generated uniform block used by rewritten shaders. - QString BuildUboBlock(const QVector &uniforms) const; + QString build_ubo_block(const QVector &uniforms) const; // Rewrites standalone uniforms and samplers into explicit UBO/sampler // bindings accepted by Vulkan GLSL. QString - RewriteShaderWithUbo(const QString &glsl, + rewrite_shader_with_ubo(const QString &glsl, const QVector &all_uniforms, const QHash &sampler_bindings) const; // Returns std140 storage size for a supported GLSL type. - VkDeviceSize GetStd140Size(const QString &type) const; + VkDeviceSize get_std140_size(const QString &type) const; // Returns std140 alignment for a supported GLSL type. - VkDeviceSize GetStd140Alignment(const QString &type) const; + VkDeviceSize get_std140_alignment(const QString &type) const; // Creates or retrieves the graphics pipeline for a shader/render format pair. - bool CreatePipelineForShader(VulkanShader *shader, + bool create_pipeline_for_shader(VulkanShader *shader, const VideoParams &dest_params, VkFormat render_pass_format); // Caches simple single-color-attachment render passes by format/clear mode. - VkRenderPass GetOrCreateRenderPass(VkFormat format, bool clear); + VkRenderPass get_or_create_render_pass(VkFormat format, bool clear); struct TextureBinding { QString name; @@ -226,7 +226,7 @@ private: }; // Executes one fullscreen pass with the provided texture bindings and UBO. - void BlitPass(VulkanShader *shader, VulkanTexture *dest_tex, + void blit_pass(VulkanShader *shader, VulkanTexture *dest_tex, const QVector &bindings, const QByteArray &ubo_data, const VideoParams &destination_params, bool clear_destination, @@ -269,9 +269,9 @@ private: quint64 next_shader_id_ = 1; QHash shaders_; - static const int kMaxDescriptorSets = 1024; + static const int k_max_descriptor_sets = 1024; }; } -#endif // VULKANRENDERER_H +#endif // OAK_VULKANRENDERER_H diff --git a/app/render/worker/workermain.cpp b/app/render/worker/workermain.cpp index c01fa5e9c..37c9679fe 100644 --- a/app/render/worker/workermain.cpp +++ b/app/render/worker/workermain.cpp @@ -66,7 +66,7 @@ namespace { #ifdef Q_OS_LINUX -void PrintBacktrace(int sig) +void print_backtrace(int sig) { void *array[50]; size_t size = backtrace(array, 50); @@ -77,12 +77,12 @@ void PrintBacktrace(int sig) } #endif -constexpr int kProtocolVersion = 1; -constexpr int kDefaultWidth = 1920; -constexpr int kDefaultHeight = 1080; -constexpr int kDefaultFrameRate = 24; +constexpr int k_protocol_version = 1; +constexpr int k_default_width = 1920; +constexpr int k_default_height = 1080; +constexpr int k_default_frame_rate = 24; -void InstallSurfaceFormat() +void install_surface_format() { QSurfaceFormat format; format.setVersion(3, 2); @@ -91,17 +91,17 @@ void InstallSurfaceFormat() QSurfaceFormat::setDefaultFormat(format); } -void LogError(const QString &message) +void log_error(const QString &message) { const QByteArray line = QByteArray("worker: ") + message.toUtf8() + '\n'; fwrite(line.constData(), 1, size_t(line.size()), stderr); fflush(stderr); } -QJsonObject ErrorMessage(const QString &message, qint64 ticket_id = 0) +QJsonObject error_message(const QString &message, qint64 ticket_id = 0) { QJsonObject o; - o["type"] = olive::ipc::msgtype::kError; + o["type"] = olive::ipc::msgtype::k_error; o["message"] = message; if (ticket_id) { o["ticket"] = double(ticket_id); @@ -120,13 +120,13 @@ public: ~RenderWorker() { project_.reset(); - olive::ProjectSerializer::Destroy(); - olive::DiskManager::DestroyInstance(); - olive::FrameManager::DestroyInstance(); - olive::NodeFactory::Destroy(); + olive::ProjectSerializer::destroy(); + olive::DiskManager::destroy_instance(); + olive::FrameManager::destroy_instance(); + olive::NodeFactory::destroy(); } - bool InitializeRuntime() + bool initialize_runtime() { // Create a minimal Core instance so that code paths calling Core::instance() // (e.g. ViewerOutput::data for timecode display) do not dereference null. @@ -135,19 +135,19 @@ public: new olive::Core(olive::Core::CoreParams()); } - olive::Config::Load(); - olive::NodeFactory::Initialize(); - olive::ColorManager::SetUpDefaultConfig(); - olive::FrameManager::CreateInstance(); - olive::DiskManager::CreateInstance(); - olive::ProjectSerializer::Initialize(); + olive::Config::load(); + olive::NodeFactory::initialize(); + olive::ColorManager::set_up_default_config(); + olive::FrameManager::create_instance(); + olive::DiskManager::create_instance(); + olive::ProjectSerializer::initialize(); return true; } - bool SendStartupHandshake() + bool send_startup_handshake() { olive::ipc::HandshakeMsg hs; - hs.protocol_version = kProtocolVersion; + hs.protocol_version = k_protocol_version; hs.shm_key = QString(); hs.input_shm_key = QString(); hs.input_slots = 0; @@ -155,12 +155,12 @@ public: hs.slot_data_bytes = 0; hs.input_slot_data_bytes = 0; - QJsonObject handshake = hs.ToJson(); + QJsonObject handshake = hs.to_json(); QOpenGLContext *ctx = nullptr; #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND if (auto *dynamic_renderer = dynamic_cast(renderer_)) { - ctx = dynamic_renderer->OpenGLContext(); + ctx = dynamic_renderer->open_gl_context(); } else #endif { @@ -172,52 +172,52 @@ public: handshake["gl_minor"] = fmt.minorVersion(); } - return Write(handshake); + return write(handshake); } - bool Handle(const QJsonObject &message) + bool handle(const QJsonObject &message) { const QString type = message["type"].toString(); - if (type == QLatin1String(olive::ipc::msgtype::kHandshake)) { + if (type == QLatin1String(olive::ipc::msgtype::k_handshake)) { olive::ipc::HandshakeMsg hs; - if (!olive::ipc::HandshakeMsg::FromJson(message, &hs)) { - return Write( - ErrorMessage(QStringLiteral("invalid handshake message"))); + if (!olive::ipc::HandshakeMsg::from_json(message, &hs)) { + return write( + error_message(QStringLiteral("invalid handshake message"))); } - return AttachOutputPool(hs); + return attach_output_pool(hs); } - if (type == QLatin1String(olive::ipc::msgtype::kLoadGraph)) { + if (type == QLatin1String(olive::ipc::msgtype::k_load_graph)) { olive::ipc::LoadGraphMsg load; - if (!olive::ipc::LoadGraphMsg::FromJson(message, &load)) { - return Write( - ErrorMessage(QStringLiteral("invalid load_graph message"))); + if (!olive::ipc::LoadGraphMsg::from_json(message, &load)) { + return write( + error_message(QStringLiteral("invalid load_graph message"))); } - return LoadGraph(load.path); + return load_graph(load.path); } - if (type == QLatin1String(olive::ipc::msgtype::kRenderFrame)) { + if (type == QLatin1String(olive::ipc::msgtype::k_render_frame)) { olive::ipc::RenderFrameMsg render; - if (!olive::ipc::RenderFrameMsg::FromJson(message, &render)) { - return Write(ErrorMessage( + if (!olive::ipc::RenderFrameMsg::from_json(message, &render)) { + return write(error_message( QStringLiteral("invalid render_frame message"))); } - return RenderFrame(render); + return render_frame(render); } - if (type == QLatin1String(olive::ipc::msgtype::kCancel)) { + if (type == QLatin1String(olive::ipc::msgtype::k_cancel)) { // Stage 5 wires cancellation into in-flight jobs. Stage 2 has only synchronous single-frame work. return true; } - if (type == QLatin1String(olive::ipc::msgtype::kShutdown)) { + if (type == QLatin1String(olive::ipc::msgtype::k_shutdown)) { shutdown_requested_ = true; return true; } - return Write( - ErrorMessage(QStringLiteral("unknown message type: %1").arg(type))); + return write( + error_message(QStringLiteral("unknown message type: %1").arg(type))); } bool shutdown_requested() const @@ -226,67 +226,67 @@ public: } private: - bool Write(const QJsonObject &message) + bool write(const QJsonObject &message) { - const bool ok = olive::ipc::WriteMessage(out_, message); + const bool ok = olive::ipc::write_message(out_, message); out_->flush(); return ok; } - bool AttachOutputPool(const olive::ipc::HandshakeMsg &hs) + bool attach_output_pool(const olive::ipc::HandshakeMsg &hs) { - if (hs.protocol_version != kProtocolVersion) { - return Write( - ErrorMessage(QStringLiteral("unsupported protocol version %1") + if (hs.protocol_version != k_protocol_version) { + return write( + error_message(QStringLiteral("unsupported protocol version %1") .arg(hs.protocol_version))); } if (hs.shm_key.isEmpty() || hs.output_slots <= 0 || hs.slot_data_bytes <= 0) { - return Write(ErrorMessage(QStringLiteral( + return write(error_message(QStringLiteral( "handshake missing output shared-memory geometry"))); } - const size_t bytes = olive::ipc::FrameSlotPool::BytesNeeded( + const size_t bytes = olive::ipc::FrameSlotPool::bytes_needed( uint32_t(hs.output_slots), size_t(hs.slot_data_bytes)); - if (!output_region_.Open(hs.shm_key, bytes, - olive::ipc::SharedMemoryRegion::kAttach)) { - return Write(ErrorMessage( + if (!output_region_.open(hs.shm_key, bytes, + olive::ipc::SharedMemoryRegion::k_attach)) { + return write(error_message( QStringLiteral("failed to attach shared memory: %1") .arg(output_region_.error()))); } - output_pool_ = olive::ipc::FrameSlotPool::Attach(output_region_.data()); - if (!output_pool_->IsValid()) { - output_region_.Close(); + output_pool_ = olive::ipc::FrameSlotPool::attach(output_region_.data()); + if (!output_pool_->is_valid()) { + output_region_.close(); output_pool_.reset(); - return Write(ErrorMessage(QStringLiteral( + return write(error_message(QStringLiteral( "shared memory does not contain a frame slot pool"))); } input_pool_.reset(); - input_region_.Close(); + input_region_.close(); if (hs.input_slots > 0) { if (hs.input_shm_key.isEmpty() || hs.input_slot_data_bytes <= 0) { - return Write(ErrorMessage(QStringLiteral( + return write(error_message(QStringLiteral( "handshake missing input shared-memory geometry"))); } - const size_t input_bytes = olive::ipc::FrameSlotPool::BytesNeeded( + const size_t input_bytes = olive::ipc::FrameSlotPool::bytes_needed( uint32_t(hs.input_slots), size_t(hs.input_slot_data_bytes)); - if (!input_region_.Open(hs.input_shm_key, input_bytes, - olive::ipc::SharedMemoryRegion::kAttach)) { - return Write(ErrorMessage( + if (!input_region_.open(hs.input_shm_key, input_bytes, + olive::ipc::SharedMemoryRegion::k_attach)) { + return write(error_message( QStringLiteral("failed to attach input shared memory: %1") .arg(input_region_.error()))); } input_pool_ = - olive::ipc::FrameSlotPool::Attach(input_region_.data()); - if (!input_pool_->IsValid()) { - input_region_.Close(); + olive::ipc::FrameSlotPool::attach(input_region_.data()); + if (!input_pool_->is_valid()) { + input_region_.close(); input_pool_.reset(); - return Write(ErrorMessage(QStringLiteral( + return write(error_message(QStringLiteral( "input shared memory does not contain a frame slot pool"))); } } @@ -294,24 +294,24 @@ private: return true; } - bool LoadGraph(const QString &path) + bool load_graph(const QString &path) { { QFileInfo fi(path); if (!fi.exists()) { - LogError( + log_error( QStringLiteral("LoadGraph: graph file does not exist: %1") .arg(path)); - return Write(ErrorMessage( + return write(error_message( QStringLiteral("graph file does not exist: %1").arg(path))); } if (fi.size() == 0) { - LogError(QStringLiteral("LoadGraph: graph file is empty: %1") + log_error(QStringLiteral("LoadGraph: graph file is empty: %1") .arg(path)); - return Write(ErrorMessage( + return write(error_message( QStringLiteral("graph file is empty: %1").arg(path))); } - LogError( + log_error( QStringLiteral("LoadGraph: loading %1 (%2 bytes, readable=%3)") .arg(path) .arg(fi.size()) @@ -324,19 +324,19 @@ private: // Initialize() first triggers Q_ASSERT(!root_) in Project::Load. olive::ProjectSerializer::Result result = - olive::ProjectSerializer::Load(loaded.get(), path, - olive::ProjectSerializer::kProject); - if (result != olive::ProjectSerializer::kSuccess) { - return Write( - ErrorMessage(QStringLiteral("failed to load graph %1: %2") - .arg(path, result.GetDetails()))); + olive::ProjectSerializer::load(loaded.get(), path, + olive::ProjectSerializer::k_project); + if (result != olive::ProjectSerializer::k_success) { + return write( + error_message(QStringLiteral("failed to load graph %1: %2") + .arg(path, result.get_details()))); } project_ = std::move(loaded); node_by_token_.clear(); color_processor_cache_.clear(); - const auto &data = result.GetLoadData(); + const auto &data = result.get_load_data(); for (auto it = data.node_ptrs.cbegin(); it != data.node_ptrs.cend(); ++it) { node_by_token_.insert(QString::number(it.key()), it.value()); @@ -351,10 +351,10 @@ private: QJsonObject ack; ack["type"] = QStringLiteral("graph_loaded"); ack["nodes"] = node_by_token_.size(); - return Write(ack); + return write(ack); } - olive::Node *FindNode(const QString &token) const + olive::Node *find_node(const QString &token) const { if (olive::Node *node = node_by_token_.value(token, nullptr)) { return node; @@ -369,24 +369,24 @@ private: return nullptr; } - bool RenderFrame(const olive::ipc::RenderFrameMsg &message) + bool render_frame(const olive::ipc::RenderFrameMsg &message) { if (!project_) { - return Write(ErrorMessage( + return write(error_message( QStringLiteral("render_frame received before load_graph"), message.ticket_id)); } - if (!output_pool_ || !output_pool_->IsValid()) { - return Write(ErrorMessage( + if (!output_pool_ || !output_pool_->is_valid()) { + return write(error_message( QStringLiteral( "render_frame received before output shm handshake"), message.ticket_id)); } - olive::Node *node = FindNode(message.node_uuid); + olive::Node *node = find_node(message.node_uuid); if (!node) { - return Write( - ErrorMessage(QStringLiteral("render node not found: %1") + return write( + error_message(QStringLiteral("render node not found: %1") .arg(message.node_uuid), message.ticket_id)); } @@ -397,8 +397,8 @@ private: QVector{ message.input_slot } : message.input_slots; if (!requested_input_slots.isEmpty()) { - if (!input_pool_ || !input_pool_->IsValid()) { - return Write(ErrorMessage( + if (!input_pool_ || !input_pool_->is_valid()) { + return write(error_message( QStringLiteral( "render_frame referenced input slot without input pool"), message.ticket_id)); @@ -408,65 +408,65 @@ private: if (requested_slot < 0 || requested_slot >= int(input_pool_->slot_count())) { for (int slot : input_slots) { - input_pool_->Release(uint32_t(slot)); + input_pool_->release(uint32_t(slot)); } - return Write(ErrorMessage( + return write(error_message( QStringLiteral("input slot index out of range"), message.ticket_id)); } uint32_t consumed_slot = 0; - if (!input_pool_->Consume(&consumed_slot)) { + if (!input_pool_->consume(&consumed_slot)) { for (int slot : input_slots) { - input_pool_->Release(uint32_t(slot)); + input_pool_->release(uint32_t(slot)); } - return Write( - ErrorMessage(QStringLiteral("input slot was not ready"), + return write( + error_message(QStringLiteral("input slot was not ready"), message.ticket_id)); } if (int(consumed_slot) != requested_slot) { - input_pool_->Release(consumed_slot); + input_pool_->release(consumed_slot); for (int slot : input_slots) { - input_pool_->Release(uint32_t(slot)); + input_pool_->release(uint32_t(slot)); } - return Write(ErrorMessage( + return write(error_message( QStringLiteral("input slot order mismatch"), message.ticket_id)); } input_slots.append(int(consumed_slot)); const olive::ipc::FrameSlotMeta *meta = - input_pool_->Meta(consumed_slot); + input_pool_->meta(consumed_slot); if (meta) { } } } olive::VideoParams vparams( - message.width > 0 ? message.width : kDefaultWidth, - message.height > 0 ? message.height : kDefaultHeight, - olive::rational(1, kDefaultFrameRate), + message.width > 0 ? message.width : k_default_width, + message.height > 0 ? message.height : k_default_height, + olive::Rational(1, k_default_frame_rate), message.format >= 0 ? olive::PixelFormat::Format(message.format) : - olive::PixelFormat::F32, + olive::PixelFormat::f32, message.channel_count > 0 ? message.channel_count : - olive::VideoParams::kRGBAChannelCount); + olive::VideoParams::k_rgba_channel_count); olive::RenderTicketPtr ticket = std::make_shared(); - ticket->setProperty("node", olive::QtUtils::PtrToValue(node)); + ticket->setProperty("node", olive::QtUtils::ptr_to_value(node)); ticket->setProperty("time", - QVariant::fromValue(olive::rational( + QVariant::fromValue(olive::Rational( int(message.time_num), int(message.time_den)))); ticket->setProperty("size", QSize(message.width, message.height)); ticket->setProperty("matrix", QMatrix4x4()); ticket->setProperty("format", message.format >= 0 ? olive::PixelFormat::Format(message.format) : - olive::PixelFormat::INVALID); + olive::PixelFormat::invalid); ticket->setProperty("usecache", false); ticket->setProperty("channelcount", message.channel_count); ticket->setProperty("mode", olive::RenderMode::Mode(message.mode)); - ticket->setProperty("type", olive::RenderManager::kTypeVideo); - ticket->setProperty("colormanager", olive::QtUtils::PtrToValue( + ticket->setProperty("type", olive::RenderManager::k_type_video); + ticket->setProperty("colormanager", olive::QtUtils::ptr_to_value( project_->color_manager())); { @@ -489,9 +489,9 @@ private: } else { transform = olive::ColorTransform(message.color_output); } - color_output = olive::ColorProcessor::Create( + color_output = olive::ColorProcessor::create( project_->color_manager(), - project_->color_manager()->GetReferenceColorSpace(), + project_->color_manager()->get_reference_color_space(), transform); if (color_output) { color_processor_cache_.insert(cache_key, color_output); @@ -504,16 +504,16 @@ private: ticket->setProperty("vparam", QVariant::fromValue(vparams)); ticket->setProperty("aparam", QVariant::fromValue(olive::AudioParams())); - ticket->setProperty("return", olive::RenderManager::kFrame); + ticket->setProperty("return", olive::RenderManager::k_frame); ticket->setProperty("cache", QString()); ticket->setProperty("cachetimebase", - QVariant::fromValue(olive::rational(1))); + QVariant::fromValue(olive::Rational(1))); ticket->setProperty("cacheid", QVariant::fromValue(QUuid())); - ticket->setProperty("multicam", olive::QtUtils::PtrToValue( + ticket->setProperty("multicam", olive::QtUtils::ptr_to_value( static_cast(nullptr))); ticket->setProperty( "ipc_input_pool", - olive::QtUtils::PtrToValue(input_pool_ ? + olive::QtUtils::ptr_to_value(input_pool_ ? static_cast(&*input_pool_) : static_cast(nullptr))); QVariantList input_slot_values; @@ -525,44 +525,44 @@ private: ticket->setProperty("ipc_input_slot", input_slots.isEmpty() ? -1 : input_slots.front()); - ticket->Start(); - olive::RenderProcessor::Process(ticket, renderer_, nullptr, + ticket->start(); + olive::RenderProcessor::process(ticket, renderer_, nullptr, &shader_cache_); for (int slot : input_slots) { - input_pool_->Release(uint32_t(slot)); + input_pool_->release(uint32_t(slot)); } - if (!ticket->HasResult()) { - return Write(ErrorMessage( + if (!ticket->has_result()) { + return write(error_message( QStringLiteral("render produced no frame"), message.ticket_id)); } - olive::FramePtr frame = ticket->Get().value(); + olive::FramePtr frame = ticket->get().value(); if (!frame || !frame->is_allocated()) { - return Write(ErrorMessage(QStringLiteral("render result was empty"), + return write(error_message(QStringLiteral("render result was empty"), message.ticket_id)); } uint32_t slot = 0; - if (!output_pool_->Acquire(&slot)) { - return Write( - ErrorMessage(QStringLiteral("no free output frame slot"), + if (!output_pool_->acquire(&slot)) { + return write( + error_message(QStringLiteral("no free output frame slot"), message.ticket_id)); } const int data_size = frame->linesize_bytes() * frame->height(); if (data_size > int(output_pool_->slot_data_bytes())) { - output_pool_->Release(slot); - LogError(QString("Output frame size") + QString::number(data_size)); - LogError(QString("Slot size") + + output_pool_->release(slot); + log_error(QString("Output frame size") + QString::number(data_size)); + log_error(QString("Slot size") + QString::number(output_pool_->slot_data_bytes())); - return Write(ErrorMessage( + return write(error_message( QStringLiteral("rendered frame does not fit output slot "), message.ticket_id)); } - std::memcpy(output_pool_->SlotData(slot), frame->const_data(), + std::memcpy(output_pool_->slot_data(slot), frame->const_data(), size_t(data_size)); - olive::ipc::FrameSlotMeta *meta = output_pool_->Meta(slot); + olive::ipc::FrameSlotMeta *meta = output_pool_->meta(slot); meta->id = message.ticket_id; meta->time_num = frame->timestamp().numerator(); meta->time_den = frame->timestamp().denominator(); @@ -573,16 +573,16 @@ private: meta->linesize = frame->linesize_bytes(); meta->data_size = data_size; - if (!output_pool_->Publish(slot)) { - output_pool_->Release(slot); - return Write(ErrorMessage( + if (!output_pool_->publish(slot)) { + output_pool_->release(slot); + return write(error_message( QStringLiteral("failed to publish output frame slot"), message.ticket_id)); } olive::ipc::FrameReadyMsg ready; ready.ticket_id = message.ticket_id; ready.output_slot = int(slot); - return Write(ready.ToJson()); + return write(ready.to_json()); } olive::Renderer *renderer_; @@ -604,7 +604,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - InstallSurfaceFormat(); + install_surface_format(); QGuiApplication app(argc, argv); @@ -625,36 +625,36 @@ int main(int argc, char *argv[]) } #ifdef Q_OS_LINUX - std::signal(SIGSEGV, PrintBacktrace); - std::signal(SIGABRT, PrintBacktrace); - std::signal(SIGFPE, PrintBacktrace); + std::signal(SIGSEGV, print_backtrace); + std::signal(SIGABRT, print_backtrace); + std::signal(SIGFPE, print_backtrace); #endif QFile in; QFile out; if (!in.open(stdin, QIODevice::ReadOnly | QIODevice::Unbuffered) || !out.open(stdout, QIODevice::WriteOnly | QIODevice::Unbuffered)) { - LogError(QStringLiteral("failed to open stdio control pipes")); + log_error(QStringLiteral("failed to open stdio control pipes")); return 1; } olive::Renderer *renderer; #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND auto *dynamic_renderer = new olive::DynamicRenderer(backend); - if (dynamic_renderer->Init()) { - dynamic_renderer->PostInit(); + if (dynamic_renderer->init()) { + dynamic_renderer->post_init(); renderer = dynamic_renderer; } else { delete dynamic_renderer; qWarning() << "Failed to initialize dynamic" << backend << "backend, falling back to direct OpenGL renderer"; renderer = new olive::OpenGLRenderer(); - if (!renderer->Init()) { - LogError(QStringLiteral("failed to initialize OpenGL renderer")); + if (!renderer->init()) { + log_error(QStringLiteral("failed to initialize OpenGL renderer")); delete renderer; return 1; } - renderer->PostInit(); + renderer->post_init(); } #else renderer = new olive::OpenGLRenderer(); @@ -674,7 +674,7 @@ int main(int argc, char *argv[]) #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND if (auto *loaded_renderer = dynamic_cast(renderer)) { - ctx = loaded_renderer->OpenGLContext(); + ctx = loaded_renderer->open_gl_context(); } else #endif { @@ -685,9 +685,9 @@ int main(int argc, char *argv[]) } } if (!renderer_valid) { - LogError(QStringLiteral("OpenGL context is not valid after init")); - renderer->Destroy(); - renderer->PostDestroy(); + log_error(QStringLiteral("OpenGL context is not valid after init")); + renderer->destroy(); + renderer->post_destroy(); delete renderer; return 1; } @@ -695,7 +695,7 @@ int main(int argc, char *argv[]) int exit_code = 0; { RenderWorker worker(renderer, &out); - if (!worker.InitializeRuntime() || !worker.SendStartupHandshake()) { + if (!worker.initialize_runtime() || !worker.send_startup_handshake()) { exit_code = 1; } else { QByteArray buffer; @@ -709,10 +709,10 @@ int main(int argc, char *argv[]) while (true) { QJsonObject message; bool ok = true; - if (!olive::ipc::ReadMessage(&buffer, &message, &ok)) { + if (!olive::ipc::read_message(&buffer, &message, &ok)) { if (!ok) { - olive::ipc::WriteMessage( - &out, ErrorMessage(QStringLiteral( + olive::ipc::write_message( + &out, error_message(QStringLiteral( "malformed control message"))); out.flush(); continue; @@ -720,7 +720,7 @@ int main(int argc, char *argv[]) break; } - if (!worker.Handle(message)) { + if (!worker.handle(message)) { exit_code = 1; break; } @@ -729,8 +729,8 @@ int main(int argc, char *argv[]) } } - renderer->Destroy(); - renderer->PostDestroy(); + renderer->destroy(); + renderer->post_destroy(); delete renderer; return exit_code; diff --git a/app/task/conform/conform.cpp b/app/task/conform/conform.cpp index 8b035a7c3..7502226c8 100644 --- a/app/task/conform/conform.cpp +++ b/app/task/conform/conform.cpp @@ -33,28 +33,28 @@ ConformTask::ConformTask(const QString &decoder_id, , params_(params) , output_filenames_(output_filenames) { - SetTitle(tr("Conforming Audio %1:%2") + set_title(tr("Conforming Audio %1:%2") .arg(stream.filename(), QString::number(stream.stream()))); } -bool ConformTask::Run() +bool ConformTask::run() { - DecoderPtr decoder = Decoder::CreateFromID(decoder_id_); + DecoderPtr decoder = Decoder::create_from_id(decoder_id_); - if (!decoder->Open(stream_)) { - SetError(tr("Failed to open decoder for audio conform")); + if (!decoder->open(stream_)) { + set_error(tr("Failed to open decoder for audio conform")); return false; } - connect(decoder.get(), &Decoder::IndexProgress, this, - &ConformTask::ProgressChanged); + connect(decoder.get(), &Decoder::index_progress, this, + &ConformTask::progress_changed); qDebug() << "Starting conform of" << stream_.filename() << stream_.stream(); bool ret = - decoder->ConformAudio(output_filenames_, params_, GetCancelAtom()); + decoder->conform_audio(output_filenames_, params_, get_cancel_atom()); - decoder->Close(); + decoder->close(); return ret; } diff --git a/app/task/conform/conform.h b/app/task/conform/conform.h index 3ca179049..354b88323 100644 --- a/app/task/conform/conform.h +++ b/app/task/conform/conform.h @@ -19,8 +19,8 @@ ***/ -#ifndef CONFORMTASK_H -#define CONFORMTASK_H +#ifndef OAK_CONFORMTASK_H +#define OAK_CONFORMTASK_H #include "codec/decoder.h" #include "node/project/footage/footage.h" @@ -37,7 +37,7 @@ public: const QVector &output_filenames); protected: - virtual bool Run() override; + virtual bool run() override; private: QString decoder_id_; @@ -51,4 +51,4 @@ private: } -#endif // CONFORMTASK_H +#endif // OAK_CONFORMTASK_H diff --git a/app/task/customcache/customcachetask.cpp b/app/task/customcache/customcachetask.cpp index 28e04f4f7..1ab92c75a 100644 --- a/app/task/customcache/customcachetask.cpp +++ b/app/task/customcache/customcachetask.cpp @@ -27,10 +27,10 @@ namespace olive CustomCacheTask::CustomCacheTask(const QString &sequence_name) : cancelled_through_finish_(false) { - SetTitle(tr("Caching custom range for \"%1\"").arg(sequence_name)); + set_title(tr("Caching custom range for \"%1\"").arg(sequence_name)); } -void CustomCacheTask::Finish() +void CustomCacheTask::finish() { mutex_.lock(); @@ -40,11 +40,11 @@ void CustomCacheTask::Finish() mutex_.unlock(); } -bool CustomCacheTask::Run() +bool CustomCacheTask::run() { mutex_.lock(); - while (!IsCancelled()) { + while (!is_cancelled()) { wait_cond_.wait(&mutex_); } @@ -56,7 +56,7 @@ bool CustomCacheTask::Run() void CustomCacheTask::CancelEvent() { if (!cancelled_through_finish_) { - emit Cancelled(); + emit cancelled(); } wait_cond_.wakeOne(); } diff --git a/app/task/customcache/customcachetask.h b/app/task/customcache/customcachetask.h index 8675d3dcb..7f4d9fceb 100644 --- a/app/task/customcache/customcachetask.h +++ b/app/task/customcache/customcachetask.h @@ -19,8 +19,8 @@ ***/ -#ifndef CUSTOMCACHETASK_H -#define CUSTOMCACHETASK_H +#ifndef OAK_CUSTOMCACHETASK_H +#define OAK_CUSTOMCACHETASK_H #include #include @@ -35,13 +35,13 @@ class CustomCacheTask : public Task { public: CustomCacheTask(const QString &sequence_name); - void Finish(); + void finish(); signals: - void Cancelled(); + void cancelled(); protected: - virtual bool Run() override; + virtual bool run() override; virtual void CancelEvent() override; @@ -55,4 +55,4 @@ private: } -#endif // CUSTOMCACHETASK_H +#endif // OAK_CUSTOMCACHETASK_H diff --git a/app/task/export/export.cpp b/app/task/export/export.cpp index e499e93ab..ffaa19532 100644 --- a/app/task/export/export.cpp +++ b/app/task/export/export.cpp @@ -32,79 +32,79 @@ ExportTask::ExportTask(ViewerOutput *viewer_node, ColorManager *color_manager, { // Create a copy of the project copier_ = new ProjectCopier(this); - copier_->SetProject(viewer_node->project()); + copier_->set_project(viewer_node->project()); - set_viewer(copier_->GetCopy(viewer_node)); - color_manager_ = copier_->GetCopiedProject()->color_manager(); + set_viewer(copier_->get_copy(viewer_node)); + color_manager_ = copier_->get_copied_project()->color_manager(); // Adjust video params to have no divider - VideoParams vp = viewer_node->GetVideoParams(); + VideoParams vp = viewer_node->get_video_params(); vp.set_divider(1); vp.set_time_base(params.video_params().time_base()); vp.set_frame_rate(params.video_params().frame_rate()); set_video_params(vp); - set_audio_params(viewer_node->GetAudioParams()); + set_audio_params(viewer_node->get_audio_params()); - SetTitle(tr("Exporting \"%1\"").arg(viewer_node->GetLabel())); - SetNativeProgressSignallingEnabled(false); + set_title(tr("Exporting \"%1\"").arg(viewer_node->get_label())); + set_native_progress_signalling_enabled(false); } -bool ExportTask::Run() +bool ExportTask::run() { // For safety, if we're overwriting, we save to a temporary filename and then only overwrite it // at the end QString real_filename = params_.filename(); if (QFileInfo::exists(params_.filename())) { // Generate a filename that definitely doesn't exist - params_.SetFilename( - FileFunctions::GetSafeTemporaryFilename(real_filename)); + params_.set_filename( + FileFunctions::get_safe_temporary_filename(real_filename)); } // If we're exporting to a sidecar subtitle file, disable the subtitles in the main encoder bool subtitles_enabled = params_.subtitles_enabled(); EncodingParams sidecar_params = params_; if (subtitles_enabled && params_.subtitles_are_sidecar()) { - params_.DisableSubtitles(); + params_.disable_subtitles(); } - encoder_ = std::shared_ptr(Encoder::CreateFromParams(params_)); + encoder_ = std::shared_ptr(Encoder::create_from_params(params_)); if (!encoder_) { - SetError(tr("Failed to create encoder")); + set_error(tr("Failed to create encoder")); return false; } - if (!encoder_->Open()) { - SetError(tr("Failed to open file: %1").arg(encoder_->GetError())); + if (!encoder_->open()) { + set_error(tr("Failed to open file: %1").arg(encoder_->get_error())); return false; } if (subtitles_enabled && params_.subtitles_are_sidecar()) { // Construct sidecar params - sidecar_params.DisableVideo(); - sidecar_params.DisableAudio(); + sidecar_params.disable_video(); + sidecar_params.disable_audio(); QString sidecar_filename; { QFileInfo fi(real_filename); sidecar_filename = fi.completeBaseName(); sidecar_filename.append('.'); - sidecar_filename.append(ExportFormat::GetExtension( + sidecar_filename.append(ExportFormat::get_extension( sidecar_params.subtitle_sidecar_fmt())); sidecar_filename = fi.dir().filePath(sidecar_filename); } - sidecar_params.SetFilename(sidecar_filename); + sidecar_params.set_filename(sidecar_filename); - subtitle_encoder_ = std::shared_ptr(Encoder::CreateFromFormat( + subtitle_encoder_ = std::shared_ptr(Encoder::create_from_format( sidecar_params.subtitle_sidecar_fmt(), sidecar_params)); if (!subtitle_encoder_) { - SetError(tr("Failed to create subtitle encoder")); + set_error(tr("Failed to create subtitle encoder")); return false; } - if (!subtitle_encoder_->Open()) { - SetError(tr("Failed to open subtitle sidecar file: %1") + if (!subtitle_encoder_->open()) { + set_error(tr("Failed to open subtitle sidecar file: %1") .arg(sidecar_filename)); return false; } @@ -117,7 +117,7 @@ bool ExportTask::Run() export_range_ = params_.custom_range(); } else { // Render entire sequence - export_range_ = TimeRange(0, viewer()->GetLength()); + export_range_ = TimeRange(0, viewer()->get_length()); } frame_time_ = 0; @@ -132,8 +132,8 @@ bool ExportTask::Run() video_force_size = QSize(params_.video_params().width(), params_.video_params().height()); - if (params_.video_scaling_method() != EncodingParams::kStretch) { - video_force_matrix = EncodingParams::GenerateMatrix( + if (params_.video_scaling_method() != EncodingParams::k_stretch) { + video_force_matrix = EncodingParams::generate_matrix( params_.video_scaling_method(), video_params().width(), video_params().height(), params_.video_params().width(), params_.video_params().height()); @@ -144,8 +144,8 @@ bool ExportTask::Run() } // Create color processor - color_processor_ = ColorProcessor::Create( - color_manager_, color_manager_->GetReferenceColorSpace(), + color_processor_ = ColorProcessor::create( + color_manager_, color_manager_->get_reference_color_space(), params_.color_transform()); } @@ -170,36 +170,36 @@ bool ExportTask::Run() subtitle_range = export_range_; } - Render(color_manager_, video_range, audio_range, subtitle_range, - RenderMode::kOnline, nullptr, video_force_size, video_force_matrix, - encoder_->GetDesiredPixelFormat(), VideoParams::kRGBAChannelCount, + render(color_manager_, video_range, audio_range, subtitle_range, + RenderMode::k_online, nullptr, video_force_size, video_force_matrix, + encoder_->get_desired_pixel_format(), VideoParams::k_rgba_channel_count, color_processor_, params_.color_transform()); bool success = true; - encoder_->Close(); - if (!encoder_->GetError().isEmpty()) { - SetError(encoder_->GetError()); + encoder_->close(); + if (!encoder_->get_error().isEmpty()) { + set_error(encoder_->get_error()); success = false; } if (subtitle_encoder_ != encoder_) { - subtitle_encoder_->Close(); - if (!subtitle_encoder_->GetError().isEmpty()) { - SetError(subtitle_encoder_->GetError()); + subtitle_encoder_->close(); + if (!subtitle_encoder_->get_error().isEmpty()) { + set_error(subtitle_encoder_->get_error()); success = false; } } // If cancelled, delete the file we made, which is always a file we created since we write to a // temp file during the actual encoding process - if (IsCancelled()) { + if (is_cancelled()) { QFile::remove(params_.filename()); } else if (params_.filename() != real_filename) { // If we were writing to a temp file, overwrite now - if (!FileFunctions::RenameFileAllowOverwrite(params_.filename(), + if (!FileFunctions::rename_file_allow_overwrite(params_.filename(), real_filename)) { - SetError( + set_error( tr("Failed to overwrite \"%1\". Export has been saved as \"%2\" instead.") .arg(real_filename, params_.filename())); success = false; @@ -209,14 +209,14 @@ bool ExportTask::Run() return success; } -bool ExportTask::FrameDownloaded(FramePtr f, const rational &time) +bool ExportTask::frame_downloaded(FramePtr f, const Rational &time) { - rational actual_time = time - export_range_.in(); + Rational actual_time = time - export_range_.in(); time_map_.insert(actual_time, f); - while (!IsCancelled()) { - rational real_time = Timecode::timestamp_to_time( + while (!is_cancelled()) { + Rational real_time = Timecode::timestamp_to_time( frame_time_, video_params().frame_rate_as_time_base()); if (!time_map_.contains(real_time)) { @@ -225,26 +225,26 @@ bool ExportTask::FrameDownloaded(FramePtr f, const rational &time) // Unfortunately this can't be done in another thread since the frames need to be sent // one after the other chronologically. - if (!encoder_->WriteFrame(time_map_.take(real_time), real_time)) { - SetError(encoder_->GetError()); + if (!encoder_->write_frame(time_map_.take(real_time), real_time)) { + set_error(encoder_->get_error()); return false; } frame_time_++; - emit ProgressChanged(double(frame_time_) / - double(GetTotalNumberOfFrames())); + emit progress_changed(double(frame_time_) / + double(get_total_number_of_frames())); } return true; } -bool ExportTask::AudioDownloaded(const TimeRange &range, +bool ExportTask::audio_downloaded(const TimeRange &range, const SampleBuffer &samples) { TimeRange adjusted_range = range - export_range_.in(); if (adjusted_range.in() == audio_time_) { - if (!WriteAudioLoop(adjusted_range, samples)) { + if (!write_audio_loop(adjusted_range, samples)) { return false; } } else { @@ -254,21 +254,21 @@ bool ExportTask::AudioDownloaded(const TimeRange &range, return true; } -bool ExportTask::EncodeSubtitle(const SubtitleBlock *sub) +bool ExportTask::encode_subtitle(const SubtitleBlock *sub) { - if (!subtitle_encoder_->WriteSubtitle(sub)) { - SetError(subtitle_encoder_->GetError()); + if (!subtitle_encoder_->write_subtitle(sub)) { + set_error(subtitle_encoder_->get_error()); return false; } else { return true; } } -bool ExportTask::WriteAudioLoop(const TimeRange &time, +bool ExportTask::write_audio_loop(const TimeRange &time, const SampleBuffer &samples) { - if (!encoder_->WriteAudio(samples)) { - SetError(encoder_->GetError()); + if (!encoder_->write_audio(samples)) { + set_error(encoder_->get_error()); return false; } @@ -283,7 +283,7 @@ bool ExportTask::WriteAudioLoop(const TimeRange &time, audio_map_.erase(it); // Call recursively to write the next sample buffer - if (!WriteAudioLoop(t, s)) { + if (!write_audio_loop(t, s)) { return false; } diff --git a/app/task/export/export.h b/app/task/export/export.h index e860bbabf..20111b98d 100644 --- a/app/task/export/export.h +++ b/app/task/export/export.h @@ -19,8 +19,8 @@ ***/ -#ifndef EXPORTTASK_H -#define EXPORTTASK_H +#ifndef OAK_EXPORTTASK_H +#define OAK_EXPORTTASK_H #include "codec/encoder.h" #include "node/output/viewer/viewer.h" @@ -39,26 +39,26 @@ public: const EncodingParams ¶ms); protected: - virtual bool Run() override; + virtual bool run() override; - virtual bool FrameDownloaded(FramePtr frame, const rational &time) override; + virtual bool frame_downloaded(FramePtr frame, const Rational &time) override; - virtual bool AudioDownloaded(const TimeRange &range, + virtual bool audio_downloaded(const TimeRange &range, const SampleBuffer &samples) override; - virtual bool EncodeSubtitle(const SubtitleBlock *sub) override; + virtual bool encode_subtitle(const SubtitleBlock *sub) override; - virtual bool TwoStepFrameRendering() const override + virtual bool two_step_frame_rendering() const override { return false; } private: - bool WriteAudioLoop(const TimeRange &time, const SampleBuffer &samples); + bool write_audio_loop(const TimeRange &time, const SampleBuffer &samples); ProjectCopier *copier_; - QHash time_map_; + QHash time_map_; QHash audio_map_; @@ -74,11 +74,11 @@ private: int64_t frame_time_; - rational audio_time_; + Rational audio_time_; TimeRange export_range_; }; } -#endif // EXPORTTASK_H +#endif // OAK_EXPORTTASK_H diff --git a/app/task/precache/precachetask.cpp b/app/task/precache/precachetask.cpp index 27dc1c55e..42241e432 100644 --- a/app/task/precache/precachetask.cpp +++ b/app/task/precache/precachetask.cpp @@ -29,8 +29,8 @@ namespace olive PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence *sequence) { // Set video and audio params - set_video_params(sequence->GetVideoParams()); - set_audio_params(sequence->GetAudioParams()); + set_video_params(sequence->get_video_params()); + set_audio_params(sequence->get_audio_params()); // Create new project project_ = new Project(); @@ -38,25 +38,25 @@ PreCacheTask::PreCacheTask(Footage *footage, int index, Sequence *sequence) // Create viewer with same parameters as the sequence set_viewer(new ViewerOutput()); viewer()->setParent(project_); - viewer()->SetVideoParams(sequence->GetVideoParams()); - viewer()->SetAudioParams(sequence->GetAudioParams()); + viewer()->set_video_params(sequence->get_video_params()); + viewer()->set_audio_params(sequence->get_audio_params()); // Copy project config nodes - Project::CopySettings(footage->project(), project_); + Project::copy_settings(footage->project(), project_); // Copy footage node so it can precache without any modifications from the user screwing it up footage_ = static_cast(footage->copy()); footage_->setParent(project_); - Node::CopyInputs(footage, footage_, false); + Node::copy_inputs(footage, footage_, false); - Node::ConnectEdge(footage_, - NodeInput(viewer(), ViewerOutput::kTextureInput)); - viewer()->SetValueHintForInput( - ViewerOutput::kTextureInput, - Node::ValueHint({ NodeValue::kTexture }, - Track::Reference(Track::kVideo, index).ToString())); + Node::connect_edge(footage_, + NodeInput(viewer(), ViewerOutput::k_texture_input)); + viewer()->set_value_hint_for_input( + ViewerOutput::k_texture_input, + Node::ValueHint({ NodeValue::k_texture }, + Track::Reference(Track::k_video, index).to_string())); - SetTitle(tr("Pre-caching %1:%2") + set_title(tr("Pre-caching %1:%2") .arg(footage_->filename(), QString::number(index))); } @@ -66,29 +66,29 @@ PreCacheTask::~PreCacheTask() delete project_; } -bool PreCacheTask::Run() +bool PreCacheTask::run() { // Get list of invalidated ranges TimeRange intersection; - if (footage_->GetWorkArea()->enabled()) { + if (footage_->get_work_area()->enabled()) { // If we're caching only in-out, limit the range to that - intersection = footage_->GetWorkArea()->range(); + intersection = footage_->get_work_area()->range(); } else { // Otherwise use full length - intersection = TimeRange(0, footage_->GetVideoLength()); + intersection = TimeRange(0, footage_->get_video_length()); } TimeRangeList video_range = - viewer()->video_frame_cache()->GetInvalidatedRanges(intersection); + viewer()->video_frame_cache()->get_invalidated_ranges(intersection); - Render(project_->color_manager(), video_range, TimeRangeList(), TimeRange(), - RenderMode::kOnline, viewer()->video_frame_cache()); + render(project_->color_manager(), video_range, TimeRangeList(), TimeRange(), + RenderMode::k_online, viewer()->video_frame_cache()); return true; } -bool PreCacheTask::FrameDownloaded(FramePtr frame, const rational &time) +bool PreCacheTask::frame_downloaded(FramePtr frame, const Rational &time) { // Do nothing. Pre-cache essentially just creates more frames in the cache, it doesn't need to do // anything else. @@ -99,7 +99,7 @@ bool PreCacheTask::FrameDownloaded(FramePtr frame, const rational &time) return true; } -bool PreCacheTask::AudioDownloaded(const TimeRange &range, +bool PreCacheTask::audio_downloaded(const TimeRange &range, const SampleBuffer &samples) { // Pre-cache doesn't cache any audio diff --git a/app/task/precache/precachetask.h b/app/task/precache/precachetask.h index da31b9fe1..d082e20bf 100644 --- a/app/task/precache/precachetask.h +++ b/app/task/precache/precachetask.h @@ -19,8 +19,8 @@ ***/ -#ifndef PRECACHETASK_H -#define PRECACHETASK_H +#ifndef OAK_PRECACHETASK_H +#define OAK_PRECACHETASK_H #include "node/project/footage/footage.h" #include "node/project/sequence/sequence.h" @@ -37,12 +37,12 @@ public: virtual ~PreCacheTask() override; protected: - virtual bool Run() override; + virtual bool run() override; - virtual bool FrameDownloaded(FramePtr frame, - const rational ×) override; + virtual bool frame_downloaded(FramePtr frame, + const Rational ×) override; - virtual bool AudioDownloaded(const TimeRange &range, + virtual bool audio_downloaded(const TimeRange &range, const SampleBuffer &samples) override; private: @@ -53,4 +53,4 @@ private: } -#endif // PRECACHETASK_H +#endif // OAK_PRECACHETASK_H diff --git a/app/task/project/import/import.cpp b/app/task/project/import/import.cpp index 6189dec97..ba03b3167 100644 --- a/app/task/project/import/import.cpp +++ b/app/task/project/import/import.cpp @@ -41,25 +41,25 @@ ProjectImportTask::ProjectImportTask(Folder *folder, filenames_.append(QFileInfo(f)); } - file_count_ = Core::CountFilesInFileList(filenames_); + file_count_ = Core::count_files_in_file_list(filenames_); - SetTitle(tr("Importing %n file(s)", nullptr, file_count_)); + set_title(tr("Importing %n file(s)", nullptr, file_count_)); } -const int &ProjectImportTask::GetFileCount() const +const int &ProjectImportTask::get_file_count() const { return file_count_; } -bool ProjectImportTask::Run() +bool ProjectImportTask::run() { command_ = new MultiUndoCommand(); int imported = 0; - Import(folder_, filenames_, imported, command_); + import(folder_, filenames_, imported, command_); - if (IsCancelled()) { + if (is_cancelled()) { delete command_; command_ = nullptr; return false; @@ -68,15 +68,15 @@ bool ProjectImportTask::Run() } } -void ProjectImportTask::Import(Folder *folder, QFileInfoList import, +void ProjectImportTask::import(Folder *folder, QFileInfoList entries, int &counter, MultiUndoCommand *parent_command) { - for (int i = 0; i < import.size(); i++) { - if (IsCancelled()) { + for (int i = 0; i < entries.size(); i++) { + if (is_cancelled()) { break; } - const QFileInfo &file_info = import.at(i); + const QFileInfo &file_info = entries.at(i); // Check if this file is a directory if (file_info.isDir()) { @@ -99,31 +99,31 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, // Create a folder corresponding to the directory Folder *f = new Folder(); - f->SetLabel(file_info.fileName()); + f->set_label(file_info.fileName()); // Create undoable command that adds the items to the model - AddItemToFolder(folder, f, parent_command); + add_item_to_folder(folder, f, parent_command); // Recursively follow this path - Import(f, entry_list, counter, parent_command); + import(f, entry_list, counter, parent_command); } } else { Footage *footage = new Footage(); - footage->SetCancelPointer(this->GetCancelAtom()); + footage->set_cancel_pointer(this->get_cancel_atom()); footage->set_filename(file_info.absoluteFilePath()); - footage->SetLabel(file_info.fileName()); + footage->set_label(file_info.fileName()); - footage->SetCancelPointer(nullptr); + footage->set_cancel_pointer(nullptr); - if (footage->IsValid()) { + if (footage->is_valid()) { // See if this footage is an image sequence - ValidateImageSequence(footage, import, i); + validate_image_sequence(footage, entries, i); // Create undoable command that adds the items to the model - AddItemToFolder(folder, footage, parent_command); + add_item_to_folder(folder, footage, parent_command); // Add to vector imported_footage_.push_back(footage); @@ -136,13 +136,13 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, counter++; - emit ProgressChanged(static_cast(counter) / + emit progress_changed(static_cast(counter) / static_cast(file_count_)); } } } -void ProjectImportTask::ValidateImageSequence(Footage *footage, +void ProjectImportTask::validate_image_sequence(Footage *footage, QFileInfoList &info_list, int index) { @@ -150,51 +150,51 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage, // // By this point we've established that video contains a single still image stream. Now we'll // see if it ends with numbers. - if (Decoder::GetImageSequenceDigitCount(footage->filename()) > 0 && + if (Decoder::get_image_sequence_digit_count(footage->filename()) > 0 && !image_sequence_ignore_files_.contains(footage->filename()) && - footage->InputArraySize(Footage::kVideoParamsInput)) { - VideoParams video_stream = footage->GetVideoParams(0); + footage->input_array_size(Footage::k_video_params_input)) { + VideoParams video_stream = footage->get_video_params(0); QSize dim(video_stream.width(), video_stream.height()); - int64_t ind = Decoder::GetImageSequenceIndex(footage->filename()); + int64_t ind = Decoder::get_image_sequence_index(footage->filename()); // Check if files around exist around it with that follow a sequence - QString previous_img_fn = Decoder::TransformImageSequenceFileName( + QString previous_img_fn = Decoder::transform_image_sequence_file_name( footage->filename(), ind - 1); - QString next_img_fn = Decoder::TransformImageSequenceFileName( + QString next_img_fn = Decoder::transform_image_sequence_file_name( footage->filename(), ind + 1); Footage *previous_file = new Footage(previous_img_fn); Footage *next_file = new Footage(next_img_fn); // Finally see if these files have the same dimensions - if ((previous_file->IsValid() && - CompareStillImageSize(previous_file, dim)) || - (next_file->IsValid() && CompareStillImageSize(next_file, dim))) { + if ((previous_file->is_valid() && + compare_still_image_size(previous_file, dim)) || + (next_file->is_valid() && compare_still_image_size(next_file, dim))) { // By this point, we've established this file is a still image with a number at the end of // the filename surrounded by adjacent numbers. It could be a still image! But let's ask the // user just in case... bool is_sequence; - QMetaObject::invokeMethod(Core::instance(), "ConfirmImageSequence", + QMetaObject::invokeMethod(Core::instance(), "confirm_image_sequence", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, is_sequence), Q_ARG(QString, footage->filename())); int64_t seq_index = - Decoder::GetImageSequenceIndex(footage->filename()); + Decoder::get_image_sequence_index(footage->filename()); // Heuristic to find the first and last images (users can always override this later in // FootagePropertiesDialog) int64_t start_index = - GetImageSequenceLimit(footage->filename(), seq_index, false); + get_image_sequence_limit(footage->filename(), seq_index, false); int64_t end_index = - GetImageSequenceLimit(footage->filename(), seq_index, true); + get_image_sequence_limit(footage->filename(), seq_index, true); // Depending on the user's choice, either remove them from the list or don't ask for the // remainders for (int64_t j = start_index; j <= end_index; j++) { - QString entry_fn = Decoder::TransformImageSequenceFileName( + QString entry_fn = Decoder::transform_image_sequence_file_name( footage->filename(), j); if (is_sequence) { @@ -215,17 +215,17 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage, if (is_sequence) { // User has confirmed it is a still image, let's set it accordingly. video_stream.set_video_type( - VideoParams::kVideoTypeImageSequence); + VideoParams::k_video_type_image_sequence); - rational default_timebase = - OLIVE_CONFIG("DefaultSequenceFrameRate").value(); + Rational default_timebase = + OAK_CONFIG("DefaultSequenceFrameRate").value(); video_stream.set_time_base(default_timebase); video_stream.set_frame_rate(default_timebase.flipped()); video_stream.set_start_time(start_index); video_stream.set_duration(end_index - start_index + 1); - footage->SetVideoParams(video_stream, 0); + footage->set_video_params(video_stream, 0); } } @@ -234,44 +234,44 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage, } } -void ProjectImportTask::AddItemToFolder(Folder *folder, Node *item, +void ProjectImportTask::add_item_to_folder(Folder *folder, Node *item, MultiUndoCommand *command) { // Create undoable command that adds the items to the model Project *project = folder_->project(); NodeAddCommand *nac = new NodeAddCommand(project, item); - nac->PushToThread(project->thread()); + nac->push_to_thread(project->thread()); command->add_child(nac); command->add_child(new FolderAddChild(folder, item)); } -bool ProjectImportTask::ItemIsStillImageFootageOnly(Footage *footage) +bool ProjectImportTask::item_is_still_image_footage_only(Footage *footage) { - if (footage->GetTotalStreamCount() != 1) { + if (footage->get_total_stream_count() != 1) { // Footage with more than one stream (usually video+audio) most likely isn't an image sequence return false; } - VideoParams vp = footage->GetVideoParams(0); + VideoParams vp = footage->get_video_params(0); // Footage must be valid and video stream must be a still image to be an image sequence - return vp.is_valid() && vp.video_type() == VideoParams::kVideoTypeStill; + return vp.is_valid() && vp.video_type() == VideoParams::k_video_type_still; } -bool ProjectImportTask::CompareStillImageSize(Footage *footage, const QSize &sz) +bool ProjectImportTask::compare_still_image_size(Footage *footage, const QSize &sz) { - if (!ItemIsStillImageFootageOnly(footage)) { + if (!item_is_still_image_footage_only(footage)) { return false; } - VideoParams stream = footage->GetVideoParams(0); + VideoParams stream = footage->get_video_params(0); return stream.width() == sz.width() && stream.height() == sz.height(); } -int64_t ProjectImportTask::GetImageSequenceLimit(const QString &start_fn, +int64_t ProjectImportTask::get_image_sequence_limit(const QString &start_fn, int64_t start, bool up) { QString test_filename; @@ -286,7 +286,7 @@ int64_t ProjectImportTask::GetImageSequenceLimit(const QString &start_fn, } test_filename = - Decoder::TransformImageSequenceFileName(start_fn, test_index); + Decoder::transform_image_sequence_file_name(start_fn, test_index); if (!QFileInfo::exists(test_filename)) { // Reached end of index diff --git a/app/task/project/import/import.h b/app/task/project/import/import.h index 9a51fc336..e665760b4 100644 --- a/app/task/project/import/import.h +++ b/app/task/project/import/import.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTIMPORTMANAGER_H -#define PROJECTIMPORTMANAGER_H +#ifndef OAK_PROJECTIMPORTMANAGER_H +#define OAK_PROJECTIMPORTMANAGER_H #include #include @@ -37,45 +37,45 @@ class ProjectImportTask : public Task { public: ProjectImportTask(Folder *folder, const QStringList &filenames); - const int &GetFileCount() const; + const int &get_file_count() const; - MultiUndoCommand *GetCommand() const + MultiUndoCommand *get_command() const { return command_; } - const QStringList &GetInvalidFiles() const + const QStringList &get_invalid_files() const { return invalid_files_; } - bool HasInvalidFiles() const + bool has_invalid_files() const { return !invalid_files_.isEmpty(); } - const QVector &GetImportedFootage() const + const QVector &get_imported_footage() const { return imported_footage_; } protected: - virtual bool Run() override; + virtual bool run() override; private: - void Import(Folder *folder, QFileInfoList import, int &counter, + void import(Folder *folder, QFileInfoList entries, int &counter, MultiUndoCommand *parent_command); - void ValidateImageSequence(Footage *footage, QFileInfoList &info_list, + void validate_image_sequence(Footage *footage, QFileInfoList &info_list, int index); - void AddItemToFolder(Folder *folder, Node *item, MultiUndoCommand *command); + void add_item_to_folder(Folder *folder, Node *item, MultiUndoCommand *command); - static bool ItemIsStillImageFootageOnly(Footage *footage); + static bool item_is_still_image_footage_only(Footage *footage); - static bool CompareStillImageSize(Footage *footage, const QSize &sz); + static bool compare_still_image_size(Footage *footage, const QSize &sz); - static int64_t GetImageSequenceLimit(const QString &start_fn, int64_t start, + static int64_t get_image_sequence_limit(const QString &start_fn, int64_t start, bool up); MultiUndoCommand *command_; @@ -95,4 +95,4 @@ private: } -#endif // PROJECTIMPORTMANAGER_H +#endif // OAK_PROJECTIMPORTMANAGER_H diff --git a/app/task/project/import/importerrordialog.h b/app/task/project/import/importerrordialog.h index 04f7c702f..2c447ee17 100644 --- a/app/task/project/import/importerrordialog.h +++ b/app/task/project/import/importerrordialog.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTIMPORTERRORDIALOG_H -#define PROJECTIMPORTERRORDIALOG_H +#ifndef OAK_PROJECTIMPORTERRORDIALOG_H +#define OAK_PROJECTIMPORTERRORDIALOG_H #include @@ -38,4 +38,4 @@ public: } -#endif // PROJECTIMPORTERRORDIALOG_H +#endif // OAK_PROJECTIMPORTERRORDIALOG_H diff --git a/app/task/project/load/load.cpp b/app/task/project/load/load.cpp index ddec65094..922707f1b 100644 --- a/app/task/project/load/load.cpp +++ b/app/task/project/load/load.cpp @@ -33,51 +33,51 @@ ProjectLoadTask::ProjectLoadTask(const QString &filename) { } -bool ProjectLoadTask::Run() +bool ProjectLoadTask::run() { project_ = new Project(); - project_->set_filename(GetFilename()); + project_->set_filename(get_filename()); - ProjectSerializer::Result result = ProjectSerializer::Load( - project_, GetFilename(), ProjectSerializer::kProject); + ProjectSerializer::Result result = ProjectSerializer::load( + project_, get_filename(), ProjectSerializer::k_project); - layout_ = result.GetLoadData().layout; + layout_ = result.get_load_data().layout; switch (result.code()) { - case ProjectSerializer::kSuccess: + case ProjectSerializer::k_success: break; - case ProjectSerializer::kProjectTooOld: - SetError(tr( + case ProjectSerializer::k_project_too_old: + set_error(tr( "This project is from a version of Oak Video Editor that is no longer supported in this version.")); break; - case ProjectSerializer::kProjectTooNew: - SetError(tr( + case ProjectSerializer::k_project_too_new: + set_error(tr( "This project is from a newer version of Oak Video Editor and cannot be opened in this version.")); break; - case ProjectSerializer::kUnknownVersion: - SetError(tr("Failed to determine project version.")); + case ProjectSerializer::k_unknown_version: + set_error(tr("Failed to determine project version.")); break; - case ProjectSerializer::kFileError: - SetError( - tr("Failed to read file \"%1\" for reading.").arg(GetFilename())); + case ProjectSerializer::k_file_error: + set_error( + tr("Failed to read file \"%1\" for reading.").arg(get_filename())); break; - case ProjectSerializer::kXmlError: - SetError( + case ProjectSerializer::k_xml_error: + set_error( tr("Failed to read XML document. File may be corrupt. Error was: %1") - .arg(result.GetDetails())); + .arg(result.get_details())); break; - case ProjectSerializer::kNoData: - SetError(tr("Failed to find any data to parse.")); + case ProjectSerializer::k_no_data: + set_error(tr("Failed to find any data to parse.")); break; // Errors that should never be thrown by a load - case ProjectSerializer::kOverwriteError: - SetError(tr("Unknown error.")); + case ProjectSerializer::k_overwrite_error: + set_error(tr("Unknown error.")); break; } - if (result == ProjectSerializer::kSuccess) { + if (result == ProjectSerializer::k_success) { project_->moveToThread(qApp->thread()); return true; } else { diff --git a/app/task/project/load/load.h b/app/task/project/load/load.h index 11c9a1c54..495301714 100644 --- a/app/task/project/load/load.h +++ b/app/task/project/load/load.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTLOADMANAGER_H -#define PROJECTLOADMANAGER_H +#ifndef OAK_PROJECTLOADMANAGER_H +#define OAK_PROJECTLOADMANAGER_H #include "loadbasetask.h" #include "window/mainwindow/mainwindowlayoutinfo.h" @@ -34,9 +34,9 @@ public: ProjectLoadTask(const QString &filename); protected: - virtual bool Run() override; + virtual bool run() override; }; } -#endif // PROJECTLOADMANAGER_H +#endif // OAK_PROJECTLOADMANAGER_H diff --git a/app/task/project/load/loadbasetask.cpp b/app/task/project/load/loadbasetask.cpp index d61d2e4b4..c8a54b3b5 100644 --- a/app/task/project/load/loadbasetask.cpp +++ b/app/task/project/load/loadbasetask.cpp @@ -28,7 +28,7 @@ ProjectLoadBaseTask::ProjectLoadBaseTask(const QString &filename) : project_(nullptr) , filename_(filename) { - SetTitle(tr("Loading '%1'").arg(filename)); + set_title(tr("Loading '%1'").arg(filename)); } } diff --git a/app/task/project/load/loadbasetask.h b/app/task/project/load/loadbasetask.h index 653562d80..0f2e5afec 100644 --- a/app/task/project/load/loadbasetask.h +++ b/app/task/project/load/loadbasetask.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTLOADBASETASK_H -#define PROJECTLOADBASETASK_H +#ifndef OAK_PROJECTLOADBASETASK_H +#define OAK_PROJECTLOADBASETASK_H #include "node/project.h" #include "task/task.h" @@ -33,17 +33,17 @@ class ProjectLoadBaseTask : public Task { public: ProjectLoadBaseTask(const QString &filename); - Project *GetLoadedProject() const + Project *get_loaded_project() const { return project_; } - const QString &GetFilename() const + const QString &get_filename() const { return filename_; } - const MainWindowLayoutInfo &GetLoadedLayout() const + const MainWindowLayoutInfo &get_loaded_layout() const { return layout_; } diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index 1246b4439..c61fedde5 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -221,17 +221,17 @@ bool LoadOTIOTask::Run() track->AppendBlock(block); - rational start_time; - rational duration; + Rational start_time; + Rational duration; if (otio_block->schema_name() == "Clip" || otio_block->schema_name() == "Gap") { - start_time = rational::fromDouble( + start_time = Rational::fromDouble( static_cast(otio_block) ->source_range() ->start_time() .to_seconds()); - duration = rational::fromDouble( + duration = Rational::fromDouble( static_cast(otio_block) ->source_range() ->duration() @@ -262,9 +262,9 @@ bool LoadOTIOTask::Run() // Set how far the transition eats into the previous clip transition_block->set_offsets_and_length( - rational::fromRationalTime( + Rational::fromRationalTime( otio_block_transition->in_offset()), - rational::fromRationalTime( + Rational::fromRationalTime( otio_block_transition->out_offset())); if (previous_block) { diff --git a/app/task/project/loadotio/loadotio.h b/app/task/project/loadotio/loadotio.h index 58d5a3497..d11246264 100644 --- a/app/task/project/loadotio/loadotio.h +++ b/app/task/project/loadotio/loadotio.h @@ -19,8 +19,8 @@ ***/ -#ifndef OTIODECODER_H -#define OTIODECODER_H +#ifndef OAK_OTIODECODER_H +#define OAK_OTIODECODER_H #ifdef USE_OTIO @@ -44,4 +44,4 @@ protected: #endif -#endif // OTIODECODER_H +#endif // OAK_OTIODECODER_H diff --git a/app/task/project/save/save.cpp b/app/task/project/save/save.cpp index c1a757d4a..cdf749c43 100644 --- a/app/task/project/save/save.cpp +++ b/app/task/project/save/save.cpp @@ -36,50 +36,50 @@ ProjectSaveTask::ProjectSaveTask(Project *project, bool use_compression) : project_(project) , use_compression_(use_compression) { - SetTitle(tr("Saving '%1'").arg(project->filename())); + set_title(tr("Saving '%1'").arg(project->filename())); } -bool ProjectSaveTask::Run() +bool ProjectSaveTask::run() { QString using_filename = override_filename_.isEmpty() ? project_->filename() : override_filename_; - ProjectSerializer::SaveData data(ProjectSerializer::kProject); + ProjectSerializer::SaveData data(ProjectSerializer::k_project); - data.SetFilename(using_filename); - data.SetProject(project_); - data.SetLayout(layout_); + data.set_filename(using_filename); + data.set_project(project_); + data.set_layout(layout_); ProjectSerializer::Result result = - ProjectSerializer::Save(data, use_compression_); + ProjectSerializer::save(data, use_compression_); bool success = false; switch (result.code()) { - case ProjectSerializer::kSuccess: + case ProjectSerializer::k_success: success = true; break; - case ProjectSerializer::kXmlError: - SetError(tr("Failed to write XML data.")); + case ProjectSerializer::k_xml_error: + set_error(tr("Failed to write XML data.")); break; - case ProjectSerializer::kFileError: - SetError(tr("Failed to open file \"%1\" for writing.") - .arg(result.GetDetails())); + case ProjectSerializer::k_file_error: + set_error(tr("Failed to open file \"%1\" for writing.") + .arg(result.get_details())); break; - case ProjectSerializer::kOverwriteError: - SetError( + case ProjectSerializer::k_overwrite_error: + set_error( tr("Failed to overwrite \"%1\". Project has been saved as \"%2\" instead.") - .arg(using_filename, result.GetDetails())); + .arg(using_filename, result.get_details())); success = true; break; // Errors that should never be thrown by a save - case ProjectSerializer::kProjectTooNew: - case ProjectSerializer::kProjectTooOld: - case ProjectSerializer::kUnknownVersion: - case ProjectSerializer::kNoData: - SetError(tr("Unknown error.")); + case ProjectSerializer::k_project_too_new: + case ProjectSerializer::k_project_too_old: + case ProjectSerializer::k_unknown_version: + case ProjectSerializer::k_no_data: + set_error(tr("Unknown error.")); break; } diff --git a/app/task/project/save/save.h b/app/task/project/save/save.h index 2b4d7479f..06b1c4909 100644 --- a/app/task/project/save/save.h +++ b/app/task/project/save/save.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTSAVEMANAGER_H -#define PROJECTSAVEMANAGER_H +#ifndef OAK_PROJECTSAVEMANAGER_H +#define OAK_PROJECTSAVEMANAGER_H #include "node/project.h" #include "task/task.h" @@ -33,23 +33,23 @@ class ProjectSaveTask : public Task { public: ProjectSaveTask(Project *project, bool use_compression); - Project *GetProject() const + Project *get_project() const { return project_; } - void SetOverrideFilename(const QString &filename) + void set_override_filename(const QString &filename) { override_filename_ = filename; } - void SetLayout(const MainWindowLayoutInfo &layout) + void set_layout(const MainWindowLayoutInfo &layout) { layout_ = layout; } protected: - virtual bool Run() override; + virtual bool run() override; private: Project *project_; @@ -63,4 +63,4 @@ private: } -#endif // PROJECTSAVEMANAGER_H +#endif // OAK_PROJECTSAVEMANAGER_H diff --git a/app/task/project/saveotio/saveotio.cpp b/app/task/project/saveotio/saveotio.cpp index b411d6e83..81762c059 100644 --- a/app/task/project/saveotio/saveotio.cpp +++ b/app/task/project/saveotio/saveotio.cpp @@ -125,7 +125,7 @@ OTIO::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence) } OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track, double sequence_rate, - rational max_track_length) + Rational max_track_length) { auto otio_track = new OTIO::Track(); @@ -246,7 +246,7 @@ bool SaveOTIOTask::SerializeTrackList(TrackList *list, { OTIO::ErrorStatus es; - rational max_track_length = RATIONAL_MIN; + Rational max_track_length = RATIONAL_MIN; foreach (Track *track, list->GetTracks()) { if (track->track_length() > max_track_length) { diff --git a/app/task/project/saveotio/saveotio.h b/app/task/project/saveotio/saveotio.h index 1d0a26953..6a29da1d2 100644 --- a/app/task/project/saveotio/saveotio.h +++ b/app/task/project/saveotio/saveotio.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTSAVEASOTIOTASK_H -#define PROJECTSAVEASOTIOTASK_H +#ifndef OAK_PROJECTSAVEASOTIOTASK_H +#define OAK_PROJECTSAVEASOTIOTASK_H #ifdef USE_OTIO @@ -46,7 +46,7 @@ private: OTIO::Timeline *SerializeTimeline(Sequence *sequence); OTIO::Track *SerializeTrack(Track *track, double sequence_rate, - rational max_track_length); + Rational max_track_length); bool SerializeTrackList(TrackList *list, OTIO::Timeline *otio_timeline, double sequence_rate); @@ -58,4 +58,4 @@ private: #endif -#endif // PROJECTSAVEASOTIOTASK_H +#endif // OAK_PROJECTSAVEASOTIOTASK_H diff --git a/app/task/proxy/proxy.cpp b/app/task/proxy/proxy.cpp index d0c88f368..6b3eeb669 100644 --- a/app/task/proxy/proxy.cpp +++ b/app/task/proxy/proxy.cpp @@ -39,11 +39,11 @@ ProxyTask::ProxyTask(const QString &source_filename, int stream_index, , params_(params) , output_filename_(output_filename) { - SetTitle(tr("Generating Proxy %1:%2") + set_title(tr("Generating Proxy %1:%2") .arg(source_filename_, QString::number(stream_index_))); } -QStringList ProxyTask::BuildArguments(const QString &source_filename, +QStringList ProxyTask::build_arguments(const QString &source_filename, int stream_index, const ProxyManager::ProxyParams ¶ms, const QString &output_filename) @@ -82,12 +82,12 @@ QStringList ProxyTask::BuildArguments(const QString &source_filename, return args; } -bool ProxyTask::Run() +bool ProxyTask::run() { - const QString ffmpeg = ProxyManager::FindFFmpegExecutable( - OLIVE_CONFIG("FFmpegPath").toString()); + const QString ffmpeg = ProxyManager::find_f_fmpeg_executable( + OAK_CONFIG("FFmpegPath").toString()); if (ffmpeg.isEmpty()) { - SetError( + set_error( tr("Failed to generate proxy: ffmpeg executable was not found. Set " "the ffmpeg path in Preferences > Disk > Proxy Settings.")); qWarning() << "ProxyTask: ffmpeg executable not found"; @@ -96,7 +96,7 @@ bool ProxyTask::Run() QDir output_dir = QFileInfo(output_filename_).dir(); if (!output_dir.exists() && !output_dir.mkpath(QStringLiteral("."))) { - SetError(tr("Failed to create proxy output directory")); + set_error(tr("Failed to create proxy output directory")); qWarning() << "ProxyTask: failed to create output directory" << output_dir.absolutePath(); return false; @@ -108,7 +108,7 @@ bool ProxyTask::Run() QFile::remove(output_filename_); - const QStringList args = BuildArguments(source_filename_, stream_index_, + const QStringList args = build_arguments(source_filename_, stream_index_, params_, output_filename_); QProcess process; @@ -118,18 +118,18 @@ bool ProxyTask::Run() process.start(); if (!process.waitForStarted()) { - SetError(tr("Failed to start ffmpeg for proxy generation")); + set_error(tr("Failed to start ffmpeg for proxy generation")); qWarning() << "ProxyTask: failed to start ffmpeg" << process.errorString(); return false; } while (!process.waitForFinished(100)) { - if (IsCancelled()) { + if (is_cancelled()) { process.kill(); process.waitForFinished(); QFile::remove(output_filename_); - SetError(tr("Proxy generation was cancelled")); + set_error(tr("Proxy generation was cancelled")); return false; } } @@ -138,21 +138,21 @@ bool ProxyTask::Run() process.exitCode() != 0) { const QString output = QString::fromUtf8(process.readAll()).trimmed(); QFile::remove(output_filename_); - SetError(tr("ffmpeg failed to generate proxy: %1").arg(output)); + set_error(tr("ffmpeg failed to generate proxy: %1").arg(output)); qWarning() << "ProxyTask: ffmpeg failed with exit code" << process.exitCode() << "output:" << output; return false; } if (!QFileInfo::exists(output_filename_)) { - SetError(tr("ffmpeg finished but proxy file was not created")); + set_error(tr("ffmpeg finished but proxy file was not created")); qWarning() << "ProxyTask: ffmpeg finished but output file missing" << output_filename_; return false; } qDebug() << "ProxyTask: proxy generation succeeded:" << output_filename_; - emit ProgressChanged(1.0); + emit progress_changed(1.0); return true; } diff --git a/app/task/proxy/proxy.h b/app/task/proxy/proxy.h index 7d5632639..a48b83d4a 100644 --- a/app/task/proxy/proxy.h +++ b/app/task/proxy/proxy.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef PROXYTASK_H -#define PROXYTASK_H +#ifndef OAK_PROXYTASK_H +#define OAK_PROXYTASK_H #include "codec/proxymanager.h" #include "task/task.h" @@ -39,13 +39,13 @@ public: * that it is stream 0 in the proxy file; audio streams (when enabled) * follow in source order. */ - static QStringList BuildArguments(const QString &source_filename, + static QStringList build_arguments(const QString &source_filename, int stream_index, const ProxyManager::ProxyParams ¶ms, const QString &output_filename); protected: - virtual bool Run() override; + virtual bool run() override; private: QString source_filename_; @@ -56,4 +56,4 @@ private: } -#endif // PROXYTASK_H +#endif // OAK_PROXYTASK_H diff --git a/app/task/render/render.cpp b/app/task/render/render.cpp index 0642007d8..c9944210a 100644 --- a/app/task/render/render.cpp +++ b/app/task/render/render.cpp @@ -37,7 +37,7 @@ RenderTask::~RenderTask() { } -bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, +bool RenderTask::render(ColorManager *manager, const TimeRangeList &video_range, const TimeRangeList &audio_range, const TimeRange &subtitle_range, RenderMode::Mode mode, FrameHashCache *cache, const QSize &force_size, @@ -65,14 +65,14 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, //total_length += r.length().toDouble(); RenderManager::RenderAudioParams rap( - viewer_->GetConnectedSampleOutput(), range, audio_params_, - RenderMode::kOnline); + viewer_->get_connected_sample_output(), range, audio_params_, + RenderMode::k_online); RenderTicketWatcher *watcher = new RenderTicketWatcher(); watcher->setProperty("range", QVariant::fromValue(range)); - PrepareWatcher(watcher, &watcher_thread); - IncrementRunningTickets(); - watcher->SetTicket(RenderManager::instance()->RenderAudio(rap)); + prepare_watcher(watcher, &watcher_thread); + increment_running_tickets(); + watcher->set_ticket(RenderManager::instance()->render_audio(rap)); } // Look up hashes @@ -87,10 +87,10 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, // each of the system's threads are utilized as memory allows. const int maximum_rendered_frames = QThread::idealThreadCount(); - rational next_frame; + Rational next_frame; for (int i = 0; - i < maximum_rendered_frames && iterator.GetNext(&next_frame); i++) { - StartTicket(&watcher_thread, manager, next_frame, mode, cache, + i < maximum_rendered_frames && iterator.get_next(&next_frame); i++) { + start_ticket(&watcher_thread, manager, next_frame, mode, cache, force_size, force_matrix, force_format, force_channel_count, force_color_output, force_color_transform); } @@ -100,37 +100,37 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, // Subtitle loop, loops over all blocks in sequence on all tracks if (!subtitle_range.length().isNull()) { if (Sequence *sequence = dynamic_cast(viewer_)) { - TrackList *list = sequence->track_list(Track::kSubtitle); - QVector block_indexes(list->GetTrackCount(), 0); + TrackList *list = sequence->track_list(Track::k_subtitle); + QVector block_indexes(list->get_track_count(), 0); QVector tracks_to_push; do { tracks_to_push.clear(); for (int i = 0; i < block_indexes.size(); i++) { - Track *this_track = list->GetTrackAt(i); - if (this_track->IsMuted()) { + Track *this_track = list->get_track_at(i); + if (this_track->is_muted()) { continue; } int &this_block_index = block_indexes[i]; - if (this_block_index >= this_track->Blocks().size()) { + if (this_block_index >= this_track->blocks().size()) { continue; } Block *this_block = - this_track->Blocks().at(this_block_index); + this_track->blocks().at(this_block_index); Track *compare_track = tracks_to_push.isEmpty() ? nullptr : - list->GetTrackAt(tracks_to_push.first()); + list->get_track_at(tracks_to_push.first()); const int &compare_block_index = tracks_to_push.isEmpty() ? -1 : block_indexes.at(tracks_to_push.first()); Block *compare_block = compare_track ? - compare_track->Blocks().at(compare_block_index) : + compare_track->blocks().at(compare_block_index) : nullptr; if (!compare_track || compare_block->in() >= this_block->in()) { @@ -143,14 +143,14 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, } for (int i = 0; i < tracks_to_push.size(); i++) { - Track *this_track = list->GetTrackAt(tracks_to_push.at(i)); - Block *this_block = this_track->Blocks().at( + Track *this_track = list->get_track_at(tracks_to_push.at(i)); + Block *this_block = this_track->blocks().at( block_indexes.at(tracks_to_push.at(i))); if (const SubtitleBlock *sub = dynamic_cast(this_block)) { if (sub->is_enabled()) { - if (!EncodeSubtitle(sub)) { + if (!encode_subtitle(sub)) { result = false; break; } @@ -165,8 +165,8 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, finished_watcher_mutex_.lock(); - while (result && !IsCancelled()) { - while (!finished_watchers_.empty() && !IsCancelled() && result) { + while (result && !is_cancelled()) { + while (!finished_watchers_.empty() && !is_cancelled() && result) { RenderTicketWatcher *watcher = finished_watchers_.front(); finished_watchers_.pop_front(); @@ -174,15 +174,15 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, // Analyze watcher here RenderManager::TicketType ticket_type = - watcher->GetTicket() + watcher->get_ticket() ->property("type") .value(); - if (ticket_type == RenderManager::kTypeAudio) { + if (ticket_type == RenderManager::k_type_audio) { TimeRange range = watcher->property("range").value(); - if (!AudioDownloaded(range, - watcher->Get().value())) { + if (!audio_downloaded(range, + watcher->get().value())) { result = false; } @@ -191,39 +191,39 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, //progress_counter += range.length().toDouble(); //emit ProgressChanged(progress_counter / total_length); - } else if (ticket_type == RenderManager::kTypeVideo && - TwoStepFrameRendering()) { - if (!DownloadFrame( - &watcher_thread, watcher->Get().value(), - watcher->property("time").value())) { + } else if (ticket_type == RenderManager::k_type_video && + two_step_frame_rendering()) { + if (!download_frame( + &watcher_thread, watcher->get().value(), + watcher->property("time").value())) { result = false; } if (native_progress_signalling_) { progress_counter += 0.5; - emit ProgressChanged(progress_counter / total_length); + emit progress_changed(progress_counter / total_length); } } else { // Assume single-step video or video download ticket - if (!FrameDownloaded( - watcher->Get().value(), - watcher->property("time").value())) { + if (!frame_downloaded( + watcher->get().value(), + watcher->property("time").value())) { result = false; } if (native_progress_signalling_) { double progress_to_add = 1.0; - if (TwoStepFrameRendering()) { + if (two_step_frame_rendering()) { progress_to_add *= 0.5; } progress_counter += progress_to_add; - emit ProgressChanged(progress_counter / total_length); + emit progress_changed(progress_counter / total_length); } - if (iterator.GetNext(&next_frame)) { - StartTicket(&watcher_thread, manager, next_frame, mode, + if (iterator.get_next(&next_frame)) { + start_ticket(&watcher_thread, manager, next_frame, mode, cache, force_size, force_matrix, force_format, force_channel_count, force_color_output, force_color_transform); @@ -236,7 +236,7 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, finished_watcher_mutex_.lock(); } - if (IsCancelled() || !result) { + if (is_cancelled() || !result) { break; } @@ -251,17 +251,17 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, finished_watcher_mutex_.unlock(); - if (IsCancelled() || !result) { + if (is_cancelled() || !result) { // Cancel every watcher we created foreach (RenderTicketWatcher *watcher, running_watchers_) { - watcher->Cancel(); - disconnect(watcher, &RenderTicketWatcher::Finished, this, - &RenderTask::TicketDone); - RenderManager::instance()->RemoveTicket(watcher->GetTicket()); + watcher->cancel(); + disconnect(watcher, &RenderTicketWatcher::finished, this, + &RenderTask::ticket_done); + RenderManager::instance()->remove_ticket(watcher->get_ticket()); } foreach (RenderTicketWatcher *watcher, running_watchers_) { - watcher->WaitForFinished(); + watcher->wait_for_finished(); } } @@ -275,8 +275,8 @@ bool RenderTask::Render(ColorManager *manager, const TimeRangeList &video_range, return result; } -bool RenderTask::DownloadFrame(QThread *thread, FramePtr frame, - const rational &time) +bool RenderTask::download_frame(QThread *thread, FramePtr frame, + const Rational &time) { //RenderTicketWatcher* watcher = new RenderTicketWatcher(); //PrepareWatcher(watcher, thread); @@ -289,36 +289,36 @@ bool RenderTask::DownloadFrame(QThread *thread, FramePtr frame, return true; } -bool RenderTask::EncodeSubtitle(const SubtitleBlock *subtitle) +bool RenderTask::encode_subtitle(const SubtitleBlock *subtitle) { Q_UNUSED(subtitle) return true; } -void RenderTask::PrepareWatcher(RenderTicketWatcher *watcher, QThread *thread) +void RenderTask::prepare_watcher(RenderTicketWatcher *watcher, QThread *thread) { watcher->moveToThread(thread); - connect(watcher, &RenderTicketWatcher::Finished, this, - &RenderTask::TicketDone, Qt::DirectConnection); + connect(watcher, &RenderTicketWatcher::finished, this, + &RenderTask::ticket_done, Qt::DirectConnection); running_watchers_.append(watcher); } -void RenderTask::IncrementRunningTickets() +void RenderTask::increment_running_tickets() { finished_watcher_mutex_.lock(); running_tickets_++; finished_watcher_mutex_.unlock(); } -void RenderTask::StartTicket(QThread *watcher_thread, ColorManager *manager, - const rational &time, RenderMode::Mode mode, +void RenderTask::start_ticket(QThread *watcher_thread, ColorManager *manager, + const Rational &time, RenderMode::Mode mode, FrameHashCache *cache, const QSize &force_size, const QMatrix4x4 &force_matrix, PixelFormat force_format, int force_channel_count, ColorProcessorPtr force_color_output, const ColorTransform &force_color_transform) { - RenderManager::RenderVideoParams rvp(viewer_->GetConnectedTextureOutput(), + RenderManager::RenderVideoParams rvp(viewer_->get_connected_texture_output(), video_params_, audio_params_, time, manager, mode); @@ -330,17 +330,17 @@ void RenderTask::StartTicket(QThread *watcher_thread, ColorManager *manager, rvp.force_channel_count = force_channel_count; if (cache) { - rvp.AddCache(cache); + rvp.add_cache(cache); } RenderTicketWatcher *watcher = new RenderTicketWatcher(); watcher->setProperty("time", QVariant::fromValue(time)); - PrepareWatcher(watcher, watcher_thread); - IncrementRunningTickets(); - watcher->SetTicket(RenderManager::instance()->RenderFrame(rvp)); + prepare_watcher(watcher, watcher_thread); + increment_running_tickets(); + watcher->set_ticket(RenderManager::instance()->render_frame(rvp)); } -void RenderTask::TicketDone(RenderTicketWatcher *watcher) +void RenderTask::ticket_done(RenderTicketWatcher *watcher) { finished_watcher_mutex_.lock(); finished_watchers_.push_back(watcher); diff --git a/app/task/render/render.h b/app/task/render/render.h index 344937f2a..f16204eec 100644 --- a/app/task/render/render.h +++ b/app/task/render/render.h @@ -19,8 +19,8 @@ ***/ -#ifndef RENDERTASK_H -#define RENDERTASK_H +#ifndef OAK_RENDERTASK_H +#define OAK_RENDERTASK_H #include @@ -41,25 +41,25 @@ public: virtual ~RenderTask() override; protected: - bool Render(ColorManager *manager, const TimeRangeList &video_range, + bool render(ColorManager *manager, const TimeRangeList &video_range, const TimeRangeList &audio_range, const TimeRange &subtitle_range, RenderMode::Mode mode, FrameHashCache *cache, const QSize &force_size = QSize(0, 0), const QMatrix4x4 &force_matrix = QMatrix4x4(), - PixelFormat force_format = PixelFormat::INVALID, + PixelFormat force_format = PixelFormat::invalid, int force_channel_count = 0, ColorProcessorPtr force_color_output = nullptr, const ColorTransform &force_color_transform = ColorTransform()); - virtual bool DownloadFrame(QThread *thread, FramePtr frame, - const rational &time); + virtual bool download_frame(QThread *thread, FramePtr frame, + const Rational &time); - virtual bool FrameDownloaded(FramePtr frame, const rational &time) = 0; + virtual bool frame_downloaded(FramePtr frame, const Rational &time) = 0; - virtual bool AudioDownloaded(const TimeRange &range, + virtual bool audio_downloaded(const TimeRange &range, const SampleBuffer &samples) = 0; - virtual bool EncodeSubtitle(const SubtitleBlock *subtitle); + virtual bool encode_subtitle(const SubtitleBlock *subtitle); ViewerOutput *viewer() const { @@ -98,12 +98,12 @@ protected: finished_watcher_mutex_.unlock(); } - virtual bool TwoStepFrameRendering() const + virtual bool two_step_frame_rendering() const { return true; } - void SetNativeProgressSignallingEnabled(bool e) + void set_native_progress_signalling_enabled(bool e) { native_progress_signalling_ = e; } @@ -111,18 +111,18 @@ protected: /** * @brief Only valid after Render() is called */ - int64_t GetTotalNumberOfFrames() const + int64_t get_total_number_of_frames() const { return total_number_of_frames_; } private: - void PrepareWatcher(RenderTicketWatcher *watcher, QThread *thread); + void prepare_watcher(RenderTicketWatcher *watcher, QThread *thread); - void IncrementRunningTickets(); + void increment_running_tickets(); - void StartTicket(QThread *watcher_thread, ColorManager *manager, - const rational &time, RenderMode::Mode mode, + void start_ticket(QThread *watcher_thread, ColorManager *manager, + const Rational &time, RenderMode::Mode mode, FrameHashCache *cache, const QSize &force_size, const QMatrix4x4 &force_matrix, PixelFormat force_format, int force_channel_count, @@ -146,9 +146,9 @@ private: int64_t total_number_of_frames_; private slots: - void TicketDone(RenderTicketWatcher *watcher); + void ticket_done(RenderTicketWatcher *watcher); }; } -#endif // RENDERTASK_H +#endif // OAK_RENDERTASK_H diff --git a/app/task/task.h b/app/task/task.h index 47c5ec70b..253c3c2f1 100644 --- a/app/task/task.h +++ b/app/task/task.h @@ -19,8 +19,8 @@ ***/ -#ifndef TASK_H -#define TASK_H +#ifndef OAK_TASK_H +#define OAK_TASK_H #include #include @@ -65,7 +65,7 @@ public: /** * @brief Retrieve the current title of this Task */ - const QString &GetTitle() const + const QString &get_title() const { return title_; } @@ -73,12 +73,12 @@ public: /** * @brief Returns the error that occurred if Run() returns false */ - const QString &GetError() const + const QString &get_error() const { return error_; } - const qint64 &GetStartTime() const + const qint64 &get_start_time() const { return start_time_; } @@ -91,18 +91,18 @@ public slots: * * \see GetError() if this returns false. */ - bool Start() + bool start() { start_time_ = QDateTime::currentMSecsSinceEpoch(); - emit Started(start_time_); + emit started(start_time_); - bool ret = Run(); + bool ret = run(); // Print how long this task took for debugging purposes qDebug() << this << "took" << (QDateTime::currentMSecsSinceEpoch() - start_time_); - emit Finished(this, ret); + emit finished(this, ret); return ret; } @@ -113,7 +113,7 @@ public slots: * Override this if your class holds any persistent state that should be cleared/modified before * it's safe for Run() to run again. */ - virtual void Reset() + virtual void reset() { } @@ -125,11 +125,11 @@ public slots: */ void Cancel() { - CancelableObject::Cancel(); + CancelableObject::cancel(); } protected: - virtual bool Run() = 0; + virtual bool run() = 0; /** * @brief Set the error message @@ -137,7 +137,7 @@ protected: * It is recommended to use this if your Action() function ever returns FALSE to tell the user why the failure * occurred. */ - void SetError(const QString &s) + void set_error(const QString &s) { error_ = s; } @@ -149,13 +149,13 @@ protected: * and shouldn't need to change during the life of the Task. To show an error message, it's recommended to use * set_error() instead. */ - void SetTitle(const QString &s) + void set_title(const QString &s) { title_ = s; } signals: - void Started(qint64 start_time); + void started(qint64 start_time); /** * @brief Signal emitted whenever progress is made @@ -166,14 +166,14 @@ signals: * * A progress value between 0.0 and 1.0. */ - void ProgressChanged(double d); + void progress_changed(double d); /** * @brief Emitted when task is finished * * Do NOT delete immediately after this signal, call deleteLater() instead. */ - void Finished(Task *task, bool succeeded); + void finished(Task *task, bool succeeded); private: QString title_; @@ -185,4 +185,4 @@ private: } -#endif // TASK_H +#endif // OAK_TASK_H diff --git a/app/task/taskmanager.cpp b/app/task/taskmanager.cpp index 0417c3f24..af6899bee 100644 --- a/app/task/taskmanager.cpp +++ b/app/task/taskmanager.cpp @@ -49,12 +49,12 @@ TaskManager::~TaskManager() } } -void TaskManager::CreateInstance() +void TaskManager::create_instance() { instance_ = new TaskManager(); } -void TaskManager::DestroyInstance() +void TaskManager::destroy_instance() { delete instance_; instance_ = nullptr; @@ -65,17 +65,17 @@ TaskManager *TaskManager::instance() return instance_; } -int TaskManager::GetTaskCount() const +int TaskManager::get_task_count() const { return tasks_.size(); } -Task *TaskManager::GetFirstTask() const +Task *TaskManager::get_first_task() const { return tasks_.begin().value(); } -void TaskManager::CancelTaskAndWait(Task *t) +void TaskManager::cancel_task_and_wait(Task *t) { t->Cancel(); @@ -86,12 +86,12 @@ void TaskManager::CancelTaskAndWait(Task *t) } } -void TaskManager::AddTask(Task *t) +void TaskManager::add_task(Task *t) { // Create a watcher for signalling QFutureWatcher *watcher = new QFutureWatcher(); connect(watcher, &QFutureWatcher::finished, this, - &TaskManager::TaskFinished); + &TaskManager::task_finished); // Add the Task to the queue tasks_.insert(watcher, t); @@ -99,30 +99,30 @@ void TaskManager::AddTask(Task *t) // Run task concurrently watcher->setFuture( #if QT_VERSION_MAJOR >= 6 - QtConcurrent::run(&thread_pool_, &Task::Start, t) + QtConcurrent::run(&thread_pool_, &Task::start, t) #else QtConcurrent::run(&thread_pool_, t, &Task::Start) #endif ); // Emit signal that a Task was added - emit TaskAdded(t); - emit TaskListChanged(); + emit task_added(t); + emit task_list_changed(); } -void TaskManager::CancelTask(Task *t) +void TaskManager::cancel_task(Task *t) { if (std::find(failed_tasks_.begin(), failed_tasks_.end(), t) != failed_tasks_.end()) { failed_tasks_.remove(t); - emit TaskRemoved(t); + emit task_removed(t); t->deleteLater(); } else { t->Cancel(); } } -void TaskManager::TaskFinished() +void TaskManager::task_finished() { QFutureWatcher *watcher = static_cast *>(sender()); @@ -132,17 +132,17 @@ void TaskManager::TaskFinished() if (watcher->result()) { // Task completed successfully - emit TaskRemoved(t); + emit task_removed(t); t->deleteLater(); } else { // Task failed, keep it so the user can see the error message - emit TaskFailed(t); + emit task_failed(t); failed_tasks_.push_back(t); } watcher->deleteLater(); - emit TaskListChanged(); + emit task_list_changed(); } } diff --git a/app/task/taskmanager.h b/app/task/taskmanager.h index aaae46be8..02ff313eb 100644 --- a/app/task/taskmanager.h +++ b/app/task/taskmanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef TASKMANAGER_H -#define TASKMANAGER_H +#ifndef OAK_TASKMANAGER_H +#define OAK_TASKMANAGER_H #include #include @@ -54,17 +54,17 @@ public: */ virtual ~TaskManager(); - static void CreateInstance(); + static void create_instance(); - static void DestroyInstance(); + static void destroy_instance(); static TaskManager *instance(); - int GetTaskCount() const; + int get_task_count() const; - Task *GetFirstTask() const; + Task *get_first_task() const; - void CancelTaskAndWait(Task *t); + void cancel_task_and_wait(Task *t); public slots: /** @@ -82,9 +82,9 @@ public slots: * * The task to add and run. TaskManager takes ownership of this Task and will be responsible for freeing it. */ - void AddTask(Task *t); + void add_task(Task *t); - void CancelTask(Task *t); + void cancel_task(Task *t); signals: /** @@ -94,22 +94,22 @@ signals: * * Task that was added */ - void TaskAdded(Task *t); + void task_added(Task *t); /** * @brief Signal emitted when any change to the running task list has been made */ - void TaskListChanged(); + void task_list_changed(); /** * @brief Signal emitted when a task is deleted */ - void TaskRemoved(Task *t); + void task_removed(Task *t); /** * @brief Signal emitted when a task fails */ - void TaskFailed(Task *t); + void task_failed(Task *t); private: /** @@ -128,14 +128,14 @@ private: QThreadPool thread_pool_; /** - * @brief TaskManager singleton instance + * @brief TaskManager singleton instance_ */ static TaskManager *instance_; private slots: - void TaskFinished(); + void task_finished(); }; } -#endif // TASKMANAGER_H +#endif // OAK_TASKMANAGER_H diff --git a/app/timeline/timelinecommon.h b/app/timeline/timelinecommon.h index bfebf66e4..f80571776 100644 --- a/app/timeline/timelinecommon.h +++ b/app/timeline/timelinecommon.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINECOMMON_H -#define TIMELINECOMMON_H +#ifndef OAK_TIMELINECOMMON_H +#define OAK_TIMELINECOMMON_H #include @@ -36,20 +36,20 @@ class Track; class Timeline { public: - enum MovementMode { kNone, kMove, kTrimIn, kTrimOut }; + enum MovementMode { k_none, k_move, k_trim_in, k_trim_out }; - enum ThumbnailMode { kThumbnailOff, kThumbnailInOut, kThumbnailOn }; + enum ThumbnailMode { k_thumbnail_off, k_thumbnail_in_out, k_thumbnail_on }; - enum WaveformMode { kWaveformsDisabled, kWaveformsEnabled }; + enum WaveformMode { k_waveforms_disabled, k_waveforms_enabled }; - static bool IsATrimMode(MovementMode mode) + static bool is_a_trim_mode(MovementMode mode) { - return mode == kTrimIn || mode == kTrimOut; + return mode == k_trim_in || mode == k_trim_out; } struct EditToInfo { Track *track; - rational nearest_time; + Rational nearest_time; Block *nearest_block; }; }; @@ -58,4 +58,4 @@ public: } -#endif // TIMELINECOMMON_H +#endif // OAK_TIMELINECOMMON_H diff --git a/app/timeline/timelinecoordinate.cpp b/app/timeline/timelinecoordinate.cpp index f7059c4ab..90cc2c11d 100644 --- a/app/timeline/timelinecoordinate.cpp +++ b/app/timeline/timelinecoordinate.cpp @@ -25,18 +25,18 @@ namespace olive { TimelineCoordinate::TimelineCoordinate() - : track_(Track::kNone, 0) + : track_(Track::k_none, 0) { } -TimelineCoordinate::TimelineCoordinate(const rational &frame, +TimelineCoordinate::TimelineCoordinate(const Rational &frame, const Track::Reference &track) : frame_(frame) , track_(track) { } -TimelineCoordinate::TimelineCoordinate(const rational &frame, +TimelineCoordinate::TimelineCoordinate(const Rational &frame, const Track::Type &track_type, const int &track_index) : frame_(frame) @@ -44,22 +44,22 @@ TimelineCoordinate::TimelineCoordinate(const rational &frame, { } -const rational &TimelineCoordinate::GetFrame() const +const Rational &TimelineCoordinate::get_frame() const { return frame_; } -const Track::Reference &TimelineCoordinate::GetTrack() const +const Track::Reference &TimelineCoordinate::get_track() const { return track_; } -void TimelineCoordinate::SetFrame(const rational &frame) +void TimelineCoordinate::set_frame(const Rational &frame) { frame_ = frame; } -void TimelineCoordinate::SetTrack(const Track::Reference &track) +void TimelineCoordinate::set_track(const Track::Reference &track) { track_ = track; } diff --git a/app/timeline/timelinecoordinate.h b/app/timeline/timelinecoordinate.h index d6bbe3a2e..08d1a5d01 100644 --- a/app/timeline/timelinecoordinate.h +++ b/app/timeline/timelinecoordinate.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINECOORDINATE_H -#define TIMELINECOORDINATE_H +#ifndef OAK_TIMELINECOORDINATE_H +#define OAK_TIMELINECOORDINATE_H #include "node/output/track/track.h" @@ -30,22 +30,22 @@ namespace olive class TimelineCoordinate { public: TimelineCoordinate(); - TimelineCoordinate(const rational &frame, const Track::Reference &track); - TimelineCoordinate(const rational &frame, const Track::Type &track_type, + TimelineCoordinate(const Rational &frame, const Track::Reference &track); + TimelineCoordinate(const Rational &frame, const Track::Type &track_type, const int &track_index); - const rational &GetFrame() const; - const Track::Reference &GetTrack() const; + const Rational &get_frame() const; + const Track::Reference &get_track() const; - void SetFrame(const rational &frame); - void SetTrack(const Track::Reference &track); + void set_frame(const Rational &frame); + void set_track(const Track::Reference &track); private: - rational frame_; + Rational frame_; Track::Reference track_; }; } -#endif // TIMELINECOORDINATE_H +#endif // OAK_TIMELINECOORDINATE_H diff --git a/app/timeline/timelinemarker.cpp b/app/timeline/timelinemarker.cpp index 50411135b..048f42f68 100644 --- a/app/timeline/timelinemarker.cpp +++ b/app/timeline/timelinemarker.cpp @@ -33,7 +33,7 @@ namespace olive { TimelineMarker::TimelineMarker(QObject *parent) - : color_(OLIVE_CONFIG("MarkerColor").toInt()) + : color_(OAK_CONFIG("MarkerColor").toInt()) { setParent(parent); } @@ -50,49 +50,49 @@ TimelineMarker::TimelineMarker(int color, const TimeRange &time, void TimelineMarker::set_time(const TimeRange &time) { time_ = time; - emit TimeChanged(time_); + emit time_changed(time_); } -void TimelineMarker::set_time(const rational &time) +void TimelineMarker::set_time(const Rational &time) { set_time(TimeRange(time, time + time_.length())); } -bool TimelineMarker::has_sibling_at_time(const rational &t) const +bool TimelineMarker::has_sibling_at_time(const Rational &t) const { TimelineMarker *m = - static_cast(parent())->GetMarkerAtTime(t); + static_cast(parent())->get_marker_at_time(t); return m && m != this; } void TimelineMarker::set_name(const QString &name) { name_ = name; - emit NameChanged(name_); + emit name_changed(name_); } void TimelineMarker::set_color(int c) { color_ = c; - emit ColorChanged(color_); + emit color_changed(color_); } -int TimelineMarker::GetMarkerHeight(const QFontMetrics &fm) +int TimelineMarker::get_marker_height(const QFontMetrics &fm) { return fm.height(); } -QRect TimelineMarker::Draw(QPainter *p, const QPoint &pt, int max_right, +QRect TimelineMarker::draw(QPainter *p, const QPoint &pt, int max_right, double scale, bool selected) { QFontMetrics fm = p->fontMetrics(); - int marker_height = GetMarkerHeight(fm); - int marker_width = QtUtils::QFontMetricsWidth(fm, QStringLiteral("H")); + int marker_height = get_marker_height(fm); + int marker_width = QtUtils::q_font_metrics_width(fm, QStringLiteral("H")); int half_width = marker_width / 2; - QColor c = QtUtils::toQColor(ColorCoding::GetColor(color())); + QColor c = QtUtils::to_q_color(ColorCoding::get_color(color())); if (selected) { p->setPen(Qt::white); p->setBrush(c.lighter()); @@ -107,14 +107,14 @@ QRect TimelineMarker::Draw(QPainter *p, const QPoint &pt, int max_right, op.setWrapMode(QTextOption::NoWrap); if (time_.out() != time_.in()) { - QRect marker_rect(pt.x(), top, time_.length().toDouble() * scale, + QRect marker_rect(pt.x(), top, time_.length().to_double() * scale, marker_height); p->drawRect(marker_rect); if (!name_.isEmpty()) { p->setPen( - ColorCoding::GetUISelectorColor(ColorCoding::GetColor(color_))); + ColorCoding::get_ui_selector_color(ColorCoding::get_color(color_))); p->drawText(marker_rect.adjusted(marker_width / 4, 0, 0, 0), name_, op); } @@ -141,7 +141,7 @@ QRect TimelineMarker::Draw(QPainter *p, const QPoint &pt, int max_right, if (!name_.isEmpty() && max_right != -1) { QRect text_rect(right, top, max_right - right, marker_height); - int padding = QtUtils::QFontMetricsWidth(p->fontMetrics(), + int padding = QtUtils::q_font_metrics_width(p->fontMetrics(), QStringLiteral(" ")); text_rect.adjust(padding, 0, -padding - half_width, 0); @@ -155,16 +155,16 @@ QRect TimelineMarker::Draw(QPainter *p, const QPoint &pt, int max_right, bool TimelineMarker::load(QXmlStreamReader *reader) { - rational in, out; + Rational in, out; XMLAttributeLoop(reader, attr) { if (attr.name() == QStringLiteral("name")) { this->set_name(attr.value().toString()); } else if (attr.name() == QStringLiteral("in")) { - in = rational::fromString(attr.value().toString().toStdString()); + in = Rational::from_string(attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("out")) { - out = rational::fromString(attr.value().toString().toStdString()); + out = Rational::from_string(attr.value().toString().toStdString()); } else if (attr.name() == QStringLiteral("color")) { this->set_color(attr.value().toInt()); } @@ -183,17 +183,17 @@ void TimelineMarker::save(QXmlStreamWriter *writer) const writer->writeAttribute(QStringLiteral("name"), this->name()); writer->writeAttribute( QStringLiteral("in"), - QString::fromStdString(this->time().in().toString())); + QString::fromStdString(this->time().in().to_string())); writer->writeAttribute( QStringLiteral("out"), - QString::fromStdString(this->time().out().toString())); + QString::fromStdString(this->time().out().to_string())); writer->writeAttribute(QStringLiteral("color"), QString::number(this->color())); } bool TimelineMarkerList::load(QXmlStreamReader *reader) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("marker")) { TimelineMarker *marker = new TimelineMarker(this); if (!marker->load(reader)) { @@ -226,37 +226,37 @@ void TimelineMarkerList::childEvent(QChildEvent *e) if (TimelineMarker *marker = dynamic_cast(e->child())) { if (e->type() == QChildEvent::ChildAdded) { - connect(marker, &TimelineMarker::TimeChanged, this, - &TimelineMarkerList::HandleMarkerTimeChange); - connect(marker, &TimelineMarker::TimeChanged, this, - &TimelineMarkerList::HandleMarkerModification); - connect(marker, &TimelineMarker::NameChanged, this, - &TimelineMarkerList::HandleMarkerModification); - connect(marker, &TimelineMarker::ColorChanged, this, - &TimelineMarkerList::HandleMarkerModification); + connect(marker, &TimelineMarker::time_changed, this, + &TimelineMarkerList::handle_marker_time_change); + connect(marker, &TimelineMarker::time_changed, this, + &TimelineMarkerList::handle_marker_modification); + connect(marker, &TimelineMarker::name_changed, this, + &TimelineMarkerList::handle_marker_modification); + connect(marker, &TimelineMarker::color_changed, this, + &TimelineMarkerList::handle_marker_modification); - InsertIntoList(marker); + insert_into_list(marker); - emit MarkerAdded(marker); + emit marker_added(marker); } else if (e->type() == QChildEvent::ChildRemoved) { - RemoveFromList(marker); + remove_from_list(marker); - disconnect(marker, &TimelineMarker::TimeChanged, this, - &TimelineMarkerList::HandleMarkerTimeChange); - disconnect(marker, &TimelineMarker::TimeChanged, this, - &TimelineMarkerList::HandleMarkerModification); - disconnect(marker, &TimelineMarker::NameChanged, this, - &TimelineMarkerList::HandleMarkerModification); - disconnect(marker, &TimelineMarker::ColorChanged, this, - &TimelineMarkerList::HandleMarkerModification); + disconnect(marker, &TimelineMarker::time_changed, this, + &TimelineMarkerList::handle_marker_time_change); + disconnect(marker, &TimelineMarker::time_changed, this, + &TimelineMarkerList::handle_marker_modification); + disconnect(marker, &TimelineMarker::name_changed, this, + &TimelineMarkerList::handle_marker_modification); + disconnect(marker, &TimelineMarker::color_changed, this, + &TimelineMarkerList::handle_marker_modification); - emit MarkerRemoved(marker); + emit marker_removed(marker); } } } -void TimelineMarkerList::InsertIntoList(TimelineMarker *marker) +void TimelineMarkerList::insert_into_list(TimelineMarker *marker) { // Insertion sort by time to allow some loop optimizations bool found = false; @@ -277,7 +277,7 @@ void TimelineMarkerList::InsertIntoList(TimelineMarker *marker) } } -bool TimelineMarkerList::RemoveFromList(TimelineMarker *marker) +bool TimelineMarkerList::remove_from_list(TimelineMarker *marker) { auto it = std::find(markers_.begin(), markers_.end(), marker); @@ -289,12 +289,12 @@ bool TimelineMarkerList::RemoveFromList(TimelineMarker *marker) return false; } -void TimelineMarkerList::HandleMarkerModification() +void TimelineMarkerList::handle_marker_modification() { - emit MarkerModified(static_cast(sender())); + emit marker_modified(static_cast(sender())); } -void TimelineMarkerList::HandleMarkerTimeChange() +void TimelineMarkerList::handle_marker_time_change() { TimelineMarker *m = static_cast(sender()); @@ -302,7 +302,7 @@ void TimelineMarkerList::HandleMarkerTimeChange() if (it != markers_.end()) { markers_.erase(it); - InsertIntoList(m); + insert_into_list(m); } } @@ -324,9 +324,9 @@ MarkerAddCommand::MarkerAddCommand(TimelineMarkerList *marker_list, added_marker_->setParent(&memory_manager_); } -Project *MarkerAddCommand::GetRelevantProject() const +Project *MarkerAddCommand::get_relevant_project() const { - return Project::GetProjectFromObject(marker_list_); + return Project::get_project_from_object(marker_list_); } void MarkerAddCommand::redo() @@ -344,9 +344,9 @@ MarkerRemoveCommand::MarkerRemoveCommand(TimelineMarker *marker) { } -Project *MarkerRemoveCommand::GetRelevantProject() const +Project *MarkerRemoveCommand::get_relevant_project() const { - return Project::GetProjectFromObject(marker_); + return Project::get_project_from_object(marker_); } void MarkerRemoveCommand::redo() @@ -367,9 +367,9 @@ MarkerChangeColorCommand::MarkerChangeColorCommand(TimelineMarker *marker, { } -Project *MarkerChangeColorCommand::GetRelevantProject() const +Project *MarkerChangeColorCommand::get_relevant_project() const { - return Project::GetProjectFromObject(marker_); + return Project::get_project_from_object(marker_); } void MarkerChangeColorCommand::redo() @@ -390,9 +390,9 @@ MarkerChangeNameCommand::MarkerChangeNameCommand(TimelineMarker *marker, { } -Project *MarkerChangeNameCommand::GetRelevantProject() const +Project *MarkerChangeNameCommand::get_relevant_project() const { - return Project::GetProjectFromObject(marker_); + return Project::get_project_from_object(marker_); } void MarkerChangeNameCommand::redo() @@ -415,9 +415,9 @@ MarkerChangeTimeCommand::MarkerChangeTimeCommand(TimelineMarker *marker, { } -Project *MarkerChangeTimeCommand::GetRelevantProject() const +Project *MarkerChangeTimeCommand::get_relevant_project() const { - return Project::GetProjectFromObject(marker_); + return Project::get_project_from_object(marker_); } void MarkerChangeTimeCommand::redo() diff --git a/app/timeline/timelinemarker.h b/app/timeline/timelinemarker.h index 0709947f1..7532e91c7 100644 --- a/app/timeline/timelinemarker.h +++ b/app/timeline/timelinemarker.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEMARKER_H -#define TIMELINEMARKER_H +#ifndef OAK_TIMELINEMARKER_H +#define OAK_TIMELINEMARKER_H #include #include @@ -47,9 +47,9 @@ public: return time_; } void set_time(const TimeRange &time); - void set_time(const rational &time); + void set_time(const Rational &time); - bool has_sibling_at_time(const rational &t) const; + bool has_sibling_at_time(const Rational &t) const; const QString &name() const { @@ -63,19 +63,19 @@ public: } void set_color(int c); - static int GetMarkerHeight(const QFontMetrics &fm); - QRect Draw(QPainter *p, const QPoint &pt, int max_right, double scale, + static int get_marker_height(const QFontMetrics &fm); + QRect draw(QPainter *p, const QPoint &pt, int max_right, double scale, bool selected); bool load(QXmlStreamReader *reader); void save(QXmlStreamWriter *writer) const; signals: - void TimeChanged(const TimeRange &time); + void time_changed(const TimeRange &time); - void NameChanged(const QString &name); + void name_changed(const QString &name); - void ColorChanged(int c); + void color_changed(int c); private: TimeRange time_; @@ -129,7 +129,7 @@ public: bool load(QXmlStreamReader *reader); void save(QXmlStreamWriter *writer) const; - TimelineMarker *GetMarkerAtTime(const rational &t) const + TimelineMarker *get_marker_at_time(const Rational &t) const { for (auto it = markers_.cbegin(); it != markers_.cend(); it++) { TimelineMarker *m = *it; @@ -141,17 +141,17 @@ public: return nullptr; } - TimelineMarker *GetClosestMarkerToTime(const rational &t) const + TimelineMarker *get_closest_marker_to_time(const Rational &t) const { TimelineMarker *closest = nullptr; for (auto it = markers_.cbegin(); it != markers_.cend(); it++) { TimelineMarker *m = *it; - rational this_diff = qAbs(m->time().in() - t); + Rational this_diff = qAbs(m->time().in() - t); if (closest) { - rational stored_diff = qAbs(closest->time().in() - t); + Rational stored_diff = qAbs(closest->time().in() - t); if (this_diff > stored_diff) { // Since the list is organized by time, if the diff increases, assume we are only going @@ -167,25 +167,25 @@ public: } signals: - void MarkerAdded(TimelineMarker *marker); + void marker_added(TimelineMarker *marker); - void MarkerRemoved(TimelineMarker *marker); + void marker_removed(TimelineMarker *marker); - void MarkerModified(TimelineMarker *marker); + void marker_modified(TimelineMarker *marker); protected: virtual void childEvent(QChildEvent *e) override; private: - void InsertIntoList(TimelineMarker *m); - bool RemoveFromList(TimelineMarker *m); + void insert_into_list(TimelineMarker *m); + bool remove_from_list(TimelineMarker *m); std::vector markers_; private slots: - void HandleMarkerModification(); + void handle_marker_modification(); - void HandleMarkerTimeChange(); + void handle_marker_time_change(); }; class MarkerAddCommand : public UndoCommand { @@ -194,7 +194,7 @@ public: const QString &name, int color); MarkerAddCommand(TimelineMarkerList *marker_list, TimelineMarker *marker); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -211,7 +211,7 @@ class MarkerRemoveCommand : public UndoCommand { public: MarkerRemoveCommand(TimelineMarker *marker); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -228,7 +228,7 @@ class MarkerChangeColorCommand : public UndoCommand { public: MarkerChangeColorCommand(TimelineMarker *marker, int new_color); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -244,7 +244,7 @@ class MarkerChangeNameCommand : public UndoCommand { public: MarkerChangeNameCommand(TimelineMarker *marker, QString name); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -265,7 +265,7 @@ public: { } - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -279,4 +279,4 @@ private: } -#endif // TIMELINEMARKER_H +#endif // OAK_TIMELINEMARKER_H diff --git a/app/timeline/timelineundocommon.h b/app/timeline/timelineundocommon.h index bae3136e1..0b193bd9b 100644 --- a/app/timeline/timelineundocommon.h +++ b/app/timeline/timelineundocommon.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEUNDOCOMMON_H -#define TIMELINEUNDOCOMMON_H +#ifndef OAK_TIMELINEUNDOCOMMON_H +#define OAK_TIMELINEUNDOCOMMON_H #include "node/node.h" #include "node/nodeundo.h" @@ -28,23 +28,23 @@ namespace olive { -inline bool NodeCanBeRemoved(Node *n) +inline bool node_can_be_removed(Node *n) { return n->output_connections().empty(); } -inline UndoCommand *CreateRemoveCommand(Node *n) +inline UndoCommand *create_remove_command(Node *n) { return new NodeRemoveWithExclusiveDependenciesAndDisconnect(n); } -inline UndoCommand *CreateAndRunRemoveCommand(Node *n) +inline UndoCommand *create_and_run_remove_command(Node *n) { - UndoCommand *command = CreateRemoveCommand(n); + UndoCommand *command = create_remove_command(n); command->redo_now(); return command; } } -#endif // TIMELINEUNDOCOMMON_H +#endif // OAK_TIMELINEUNDOCOMMON_H diff --git a/app/timeline/timelineundogeneral.cpp b/app/timeline/timelineundogeneral.cpp index 0032cac0e..98454b59b 100644 --- a/app/timeline/timelineundogeneral.cpp +++ b/app/timeline/timelineundogeneral.cpp @@ -90,10 +90,10 @@ TimelineAddTrackCommand::TimelineAddTrackCommand(TrackList *timeline, // Determine what input to connect it to QString relevant_input; - if (timeline_->type() == Track::kVideo) { - relevant_input = Sequence::kTextureInput; - } else if (timeline_->type() == Track::kAudio) { - relevant_input = Sequence::kSamplesInput; + if (timeline_->type() == Track::k_video) { + relevant_input = Sequence::k_texture_input; + } else if (timeline_->type() == Track::k_audio) { + relevant_input = Sequence::k_samples_input; } // If we have an input to connect to, set it as our `direct` connection @@ -101,17 +101,17 @@ TimelineAddTrackCommand::TimelineAddTrackCommand(TrackList *timeline, direct_ = NodeInput(timeline_->parent(), relevant_input); // If we're automerging and something is already connected, determine if/how to merge it - if (automerge_tracks && direct_.IsConnected()) { - if (timeline_->type() == Track::kVideo) { + if (automerge_tracks && direct_.is_connected()) { + if (timeline_->type() == Track::k_video) { // Use merge for video merge_ = new MergeNode(); - base_ = NodeInput(merge_, MergeNode::kBaseIn); - blend_ = NodeInput(merge_, MergeNode::kBlendIn); - } else if (timeline_->type() == Track::kAudio) { + base_ = NodeInput(merge_, MergeNode::k_base_in); + blend_ = NodeInput(merge_, MergeNode::k_blend_in); + } else if (timeline_->type() == Track::k_audio) { // Use math (add) for audio merge_ = new MathNode(); - base_ = NodeInput(merge_, MathNode::kParamAIn); - blend_ = NodeInput(merge_, MathNode::kParamBIn); + base_ = NodeInput(merge_, MathNode::k_param_a_in); + blend_ = NodeInput(merge_, MathNode::k_param_b_in); } if (merge_) { @@ -128,23 +128,23 @@ void TimelineAddTrackCommand::redo() Sequence *sequence = timeline_->parent(); // Add track to sequence - track_->setParent(timeline_->GetParentGraph()); - if (timeline_->GetTrackCount() > 0) { - track_->SetTrackHeight( - timeline_->GetTrackAt(timeline_->GetTrackCount() - 1) - ->GetTrackHeight()); + track_->setParent(timeline_->get_parent_graph()); + if (timeline_->get_track_count() > 0) { + track_->set_track_height( + timeline_->get_track_at(timeline_->get_track_count() - 1) + ->get_track_height()); } - timeline_->ArrayAppend(); - Node::ConnectEdge(track_, - timeline_->track_input(timeline_->ArraySize() - 1)); + timeline_->array_append(); + Node::connect_edge(track_, + timeline_->track_input(timeline_->array_size() - 1)); qreal position_factor = 0.5; - if (timeline_->type() == Track::kVideo) { + if (timeline_->type() == Track::k_video) { position_factor = -position_factor; } bool create_pos_command = - (!position_command_ && (timeline_->type() == Track::kVideo || - timeline_->type() == Track::kAudio)); + (!position_command_ && (timeline_->type() == Track::k_video || + timeline_->type() == Track::k_audio)); if (create_pos_command) { position_command_ = new MultiUndoCommand(); } @@ -152,41 +152,41 @@ void TimelineAddTrackCommand::redo() // Add merge if applicable if (merge_) { // Determine what was previously connected - Node *previous_connection = direct_.GetConnectedOutput(); + Node *previous_connection = direct_.get_connected_output(); // Add merge to graph - merge_->setParent(timeline_->GetParentGraph()); + merge_->setParent(timeline_->get_parent_graph()); // Connect merge between what used to be here - Node::DisconnectEdge(previous_connection, direct_); - Node::ConnectEdge(merge_, direct_); - Node::ConnectEdge(previous_connection, base_); - Node::ConnectEdge(track_, blend_); + Node::disconnect_edge(previous_connection, direct_); + Node::connect_edge(merge_, direct_); + Node::connect_edge(previous_connection, base_); + Node::connect_edge(track_, blend_); if (create_pos_command) { position_command_->add_child(new NodeSetPositionCommand( track_, sequence, - sequence->GetNodePositionInContext(sequence) + + sequence->get_node_position_in_context(sequence) + QPointF(-1, -position_factor))); position_command_->add_child(new NodeSetPositionCommand( merge_, sequence, - sequence->GetNodePositionInContext(sequence))); + sequence->get_node_position_in_context(sequence))); position_command_->add_child( new NodeSetPositionAndDependenciesRecursivelyCommand( merge_, sequence, - sequence->GetNodePositionInContext(sequence) + + sequence->get_node_position_in_context(sequence) + QPointF(-1, - position_factor * timeline_->GetTrackCount()))); + position_factor * timeline_->get_track_count()))); } - } else if (direct_.IsValid() && !direct_.IsConnected()) { + } else if (direct_.is_valid() && !direct_.is_connected()) { // If no merge, we have a direct connection, and nothing else is connected, connect this - Node::ConnectEdge(track_, direct_); + Node::connect_edge(track_, direct_); if (create_pos_command) { // Just position directly next to the context node position_command_->add_child(new NodeSetPositionCommand( track_, sequence, - sequence->GetNodePositionInContext(sequence) + + sequence->get_node_position_in_context(sequence) + QPointF(-1, position_factor))); } } @@ -205,22 +205,22 @@ void TimelineAddTrackCommand::undo() // Remove merge if applicable if (merge_) { - Node *previous_connection = base_.GetConnectedOutput(); + Node *previous_connection = base_.get_connected_output(); - Node::DisconnectEdge(track_, blend_); - Node::DisconnectEdge(previous_connection, base_); - Node::DisconnectEdge(merge_, direct_); - Node::ConnectEdge(previous_connection, direct_); + Node::disconnect_edge(track_, blend_); + Node::disconnect_edge(previous_connection, base_); + Node::disconnect_edge(merge_, direct_); + Node::connect_edge(previous_connection, direct_); merge_->setParent(&memory_manager_); - } else if (direct_.IsValid() && direct_.GetConnectedOutput() == track_) { - Node::DisconnectEdge(track_, direct_); + } else if (direct_.is_valid() && direct_.get_connected_output() == track_) { + Node::disconnect_edge(track_, direct_); } // Remove track - Node::DisconnectEdge(track_, - timeline_->track_input(timeline_->ArraySize() - 1)); - timeline_->ArrayRemoveLast(); + Node::disconnect_edge(track_, + timeline_->track_input(timeline_->array_size() - 1)); + timeline_->array_remove_last(); track_->setParent(&memory_manager_); } @@ -248,20 +248,20 @@ void TransitionRemoveCommand::redo() } if (in_block_) { - Node::DisconnectEdge(in_block_, - NodeInput(block_, TransitionBlock::kInBlockInput)); + Node::disconnect_edge(in_block_, + NodeInput(block_, TransitionBlock::k_in_block_input)); } if (out_block_) { - Node::DisconnectEdge( - out_block_, NodeInput(block_, TransitionBlock::kOutBlockInput)); + Node::disconnect_edge( + out_block_, NodeInput(block_, TransitionBlock::k_out_block_input)); } - track_->RippleRemoveBlock(block_); + track_->ripple_remove_block(block_); if (remove_from_graph_) { if (!remove_command_) { - remove_command_ = CreateRemoveCommand(block_); + remove_command_ = create_remove_command(block_); } remove_command_->redo_now(); @@ -275,19 +275,19 @@ void TransitionRemoveCommand::undo() } if (in_block_) { - track_->InsertBlockBefore(block_, in_block_); + track_->insert_block_before(block_, in_block_); } else { - track_->InsertBlockAfter(block_, out_block_); + track_->insert_block_after(block_, out_block_); } if (in_block_) { - Node::ConnectEdge(in_block_, - NodeInput(block_, TransitionBlock::kInBlockInput)); + Node::connect_edge(in_block_, + NodeInput(block_, TransitionBlock::k_in_block_input)); } if (out_block_) { - Node::ConnectEdge(out_block_, - NodeInput(block_, TransitionBlock::kOutBlockInput)); + Node::connect_edge(out_block_, + NodeInput(block_, TransitionBlock::k_out_block_input)); } // These if statements must be separated because in_offset and out_offset report different things @@ -310,8 +310,8 @@ void TransitionRemoveCommand::undo() void TrackListInsertGaps::prepare() { // Determine if all tracks will be affected, which will allow us to make some optimizations - foreach (Track *track, track_list_->GetTracks()) { - if (track->IsLocked()) { + foreach (Track *track, track_list_->get_tracks()) { + if (track->is_locked()) { continue; } @@ -323,7 +323,7 @@ void TrackListInsertGaps::prepare() QVector tracks_to_append_gap_to; for (Track *track : qAsConst(working_tracks_)) { - for (Block *b : track->Blocks()) { + for (Block *b : track->blocks()) { if (dynamic_cast(b) && b->in() <= point_ && b->out() >= point_) { // Found a gap at the location @@ -379,7 +379,7 @@ void TrackListInsertGaps::redo() foreach (auto add_gap, gaps_added_) { add_gap.gap->setParent(add_gap.track->parent()); - add_gap.track->InsertBlockAfter(add_gap.gap, add_gap.before); + add_gap.track->insert_block_after(add_gap.gap, add_gap.before); } } @@ -387,7 +387,7 @@ void TrackListInsertGaps::undo() { // Remove added gaps foreach (auto add_gap, gaps_added_) { - add_gap.gap->track()->RippleRemoveBlock(add_gap.gap); + add_gap.gap->track()->ripple_remove_block(add_gap.gap); add_gap.gap->setParent(&memory_manager_); } @@ -409,8 +409,8 @@ void TrackReplaceBlockWithGapCommand::redo() { // Determine if this block is connected to any transitions that should also be removed by this operation if (handle_transitions_ && transition_remove_commands_.isEmpty()) { - CreateRemoveTransitionCommandIfNecessary(false); - CreateRemoveTransitionCommandIfNecessary(true); + create_remove_transition_command_if_necessary(false); + create_remove_transition_command_if_necessary(true); } for (auto it = transition_remove_commands_.cbegin(); it != transition_remove_commands_.cend(); it++) { @@ -422,7 +422,7 @@ void TrackReplaceBlockWithGapCommand::redo() TimeRange invalidate_range(block_->in(), block_->out()); // Block has a next, which means it's NOT at the end of the sequence and thus requires a gap - rational new_gap_length = block_->length(); + Rational new_gap_length = block_->length(); Block *previous = block_->previous(); Block *next = block_->next(); @@ -436,7 +436,7 @@ void TrackReplaceBlockWithGapCommand::redo() existing_merged_gap_ = static_cast(next); new_gap_length += existing_merged_gap_->length(); - track_->RippleRemoveBlock(existing_merged_gap_); + track_->ripple_remove_block(existing_merged_gap_); existing_merged_gap_->setParent(&memory_manager_); } else if (previous_is_a_gap) { // Extend this gap to fill space left by block @@ -450,7 +450,7 @@ void TrackReplaceBlockWithGapCommand::redo() // Extend an existing gap new_gap_length += existing_gap_->length(); existing_gap_->set_length_and_media_out(new_gap_length); - track_->RippleRemoveBlock(block_); + track_->ripple_remove_block(block_); existing_gap_precedes_ = (existing_gap_ == previous); } else { @@ -461,17 +461,17 @@ void TrackReplaceBlockWithGapCommand::redo() } our_gap_->setParent(track_->parent()); - track_->ReplaceBlock(block_, our_gap_); + track_->replace_block(block_, our_gap_); } } else { // Block is at the end of the track, simply remove it Block *preceding = block_->previous(); - track_->RippleRemoveBlock(block_); + track_->ripple_remove_block(block_); // Determine if it's preceded by a gap, and remove that gap if so if (dynamic_cast(preceding)) { - track_->RippleRemoveBlock(preceding); + track_->ripple_remove_block(preceding); preceding->setParent(&memory_manager_); existing_merged_gap_ = static_cast(preceding); @@ -484,27 +484,27 @@ void TrackReplaceBlockWithGapCommand::undo() if (our_gap_ || existing_gap_) { if (our_gap_) { // We made this gap, simply swap our gap back - track_->ReplaceBlock(our_gap_, block_); + track_->replace_block(our_gap_, block_); our_gap_->setParent(&memory_manager_); } else { // If we're here, assume that we extended an existing gap - rational original_gap_length = + Rational original_gap_length = existing_gap_->length() - block_->length(); // If we merged two gaps together, restore the second one now if (existing_merged_gap_) { original_gap_length -= existing_merged_gap_->length(); existing_merged_gap_->setParent(track_->parent()); - track_->InsertBlockAfter(existing_merged_gap_, existing_gap_); + track_->insert_block_after(existing_merged_gap_, existing_gap_); existing_merged_gap_ = nullptr; } // Restore original block if (existing_gap_precedes_) { - track_->InsertBlockAfter(block_, existing_gap_); + track_->insert_block_after(block_, existing_gap_); } else { - track_->InsertBlockBefore(block_, existing_gap_); + track_->insert_block_before(block_, existing_gap_); } // Restore gap's original length @@ -520,12 +520,12 @@ void TrackReplaceBlockWithGapCommand::undo() // However, we may have removed an unnecessary gap that preceded it if (existing_merged_gap_) { existing_merged_gap_->setParent(track_->parent()); - track_->AppendBlock(existing_merged_gap_); + track_->append_block(existing_merged_gap_); existing_merged_gap_ = nullptr; } // Restore block - track_->AppendBlock(block_); + track_->append_block(block_); } for (auto it = transition_remove_commands_.crbegin(); @@ -534,7 +534,7 @@ void TrackReplaceBlockWithGapCommand::undo() } } -void TrackReplaceBlockWithGapCommand::CreateRemoveTransitionCommandIfNecessary( +void TrackReplaceBlockWithGapCommand::create_remove_transition_command_if_necessary( bool next) { Block *relevant_block; @@ -564,7 +564,7 @@ void TimelineRemoveTrackCommand::prepare() { list_ = track_->sequence()->track_list(track_->type()); - index_ = list_->GetArrayIndexFromCacheIndex(track_->Index()); + index_ = list_->get_array_index_from_cache_index(track_->index()); remove_command_ = new NodeRemoveWithExclusiveDependenciesAndDisconnect(track_); @@ -574,12 +574,12 @@ void TimelineRemoveTrackCommand::redo() { remove_command_->redo_now(); - list_->parent()->InputArrayRemove(list_->track_input(), index_); + list_->parent()->input_array_remove(list_->track_input(), index_); } void TimelineRemoveTrackCommand::undo() { - list_->parent()->InputArrayInsert(list_->track_input(), index_); + list_->parent()->input_array_insert(list_->track_input(), index_); remove_command_->undo_now(); } @@ -594,64 +594,64 @@ void TimelineAddDefaultTransitionCommand::prepare() // Do nothing, assume this will be handled by a dual transition from that clip } else if (dynamic_cast(c->previous()) || !c->previous()) { // Create in transition - AddTransition(c, kIn); + add_transition(c, k_in); } // Handle out transition if (clips_.contains(static_cast(c->next()))) { - AddTransition(c, kOutDual); + add_transition(c, k_out_dual); } else if (dynamic_cast(c->next()) || !c->next()) { // Create out transition - AddTransition(c, kOut); + add_transition(c, k_out); } } } -void TimelineAddDefaultTransitionCommand::AddTransition( +void TimelineAddDefaultTransitionCommand::add_transition( ClipBlock *c, CreateTransitionMode mode) { if (Track *t = c->track()) { Node *p = nullptr; - if (t->type() == Track::kVideo) { - p = NodeFactory::CreateFromID( - OLIVE_CONFIG("DefaultVideoTransition").toString()); - } else if (t->type() == Track::kAudio) { - p = NodeFactory::CreateFromID( - OLIVE_CONFIG("DefaultAudioTransition").toString()); + if (t->type() == Track::k_video) { + p = NodeFactory::create_from_id( + OAK_CONFIG("DefaultVideoTransition").toString()); + } else if (t->type() == Track::k_audio) { + p = NodeFactory::create_from_id( + OAK_CONFIG("DefaultAudioTransition").toString()); } - rational transition_length = - OLIVE_CONFIG("DefaultTransitionLength").value(); + Rational transition_length = + OAK_CONFIG("DefaultTransitionLength").value(); // Resize original clip switch (mode) { - case kIn: - ValidateTransitionLength(c, transition_length); + case k_in: + validate_transition_length(c, transition_length); if (transition_length > 0) { - AdjustClipLength(c, transition_length, false); + adjust_clip_length(c, transition_length, false); } break; - case kOut: - ValidateTransitionLength(c, transition_length); + case k_out: + validate_transition_length(c, transition_length); if (transition_length > 0) { - AdjustClipLength(c, transition_length, true); + adjust_clip_length(c, transition_length, true); } break; - case kOutDual: { - rational half_length = transition_length / 2; + case k_out_dual: { + Rational half_length = transition_length / 2; - ValidateTransitionLength(static_cast(c->next()), + validate_transition_length(static_cast(c->next()), half_length); - ValidateTransitionLength(c, half_length); + validate_transition_length(c, half_length); transition_length = half_length * 2; if (transition_length > 0) { - AdjustClipLength(static_cast(c->next()), + adjust_clip_length(static_cast(c->next()), half_length, false); - AdjustClipLength(c, half_length, true); + adjust_clip_length(c, half_length, true); } break; } @@ -666,26 +666,26 @@ void TimelineAddDefaultTransitionCommand::AddTransition( commands_.append(new NodeAddCommand(c->parent(), transition)); // Insert block - Block *insert_after = (mode == kIn) ? c->previous() : c; + Block *insert_after = (mode == k_in) ? c->previous() : c; commands_.append(new TrackInsertBlockAfterCommand( c->track(), transition, insert_after)); // Connect switch (mode) { - case kIn: + case k_in: commands_.append(new NodeEdgeAddCommand( c, - NodeInput(transition, TransitionBlock::kInBlockInput))); + NodeInput(transition, TransitionBlock::k_in_block_input))); break; - case kOutDual: + case k_out_dual: commands_.append(new NodeEdgeAddCommand( c->next(), - NodeInput(transition, TransitionBlock::kInBlockInput))); + NodeInput(transition, TransitionBlock::k_in_block_input))); /* fall through */ - case kOut: + case k_out: commands_.append(new NodeEdgeAddCommand( c, NodeInput(transition, - TransitionBlock::kOutBlockInput))); + TransitionBlock::k_out_block_input))); break; } } @@ -693,11 +693,11 @@ void TimelineAddDefaultTransitionCommand::AddTransition( } } -void TimelineAddDefaultTransitionCommand::AdjustClipLength( - ClipBlock *c, const rational &transition_length, bool out) +void TimelineAddDefaultTransitionCommand::adjust_clip_length( + ClipBlock *c, const Rational &transition_length, bool out) { - rational cur_len = lengths_.value(c, c->length()); - rational new_len = cur_len - transition_length; + Rational cur_len = lengths_.value(c, c->length()); + Rational new_len = cur_len - transition_length; if (out) { commands_.append(new BlockResizeCommand(c, new_len)); } else { @@ -706,11 +706,11 @@ void TimelineAddDefaultTransitionCommand::AdjustClipLength( lengths_.insert(c, new_len); } -void TimelineAddDefaultTransitionCommand::ValidateTransitionLength( - ClipBlock *c, rational &transition_length) +void TimelineAddDefaultTransitionCommand::validate_transition_length( + ClipBlock *c, Rational &transition_length) { - rational cur_len = lengths_.value(c, c->length()); - rational half_cur_len = cur_len / 2; + Rational cur_len = lengths_.value(c, c->length()); + Rational half_cur_len = cur_len / 2; if (transition_length >= half_cur_len) { transition_length = half_cur_len - timebase_; } diff --git a/app/timeline/timelineundogeneral.h b/app/timeline/timelineundogeneral.h index c6fa73714..02eb7364c 100644 --- a/app/timeline/timelineundogeneral.h +++ b/app/timeline/timelineundogeneral.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEUNDOGENERAL_H -#define TIMELINEUNDOGENERAL_H +#ifndef OAK_TIMELINEUNDOGENERAL_H +#define OAK_TIMELINEUNDOGENERAL_H #include "config/config.h" #include "node/block/clip/clip.h" @@ -37,13 +37,13 @@ namespace olive class BlockResizeCommand : public UndoCommand { public: - BlockResizeCommand(Block *block, rational new_length) + BlockResizeCommand(Block *block, Rational new_length) : block_(block) , new_length_(new_length) { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return block_->project(); } @@ -54,19 +54,19 @@ protected: private: Block *block_; - rational old_length_; - rational new_length_; + Rational old_length_; + Rational new_length_; }; class BlockResizeWithMediaInCommand : public UndoCommand { public: - BlockResizeWithMediaInCommand(Block *block, rational new_length) + BlockResizeWithMediaInCommand(Block *block, Rational new_length) : block_(block) , new_length_(new_length) { } - virtual Project *GetRelevantProject() const + virtual Project *get_relevant_project() const { return block_->project(); } @@ -77,19 +77,19 @@ protected: private: Block *block_; - rational old_length_; - rational new_length_; + Rational old_length_; + Rational new_length_; }; class BlockSetMediaInCommand : public UndoCommand { public: - BlockSetMediaInCommand(ClipBlock *block, rational new_media_in) + BlockSetMediaInCommand(ClipBlock *block, Rational new_media_in) : block_(block) , new_media_in_(new_media_in) { } - virtual Project *GetRelevantProject() const + virtual Project *get_relevant_project() const { return block_->project(); } @@ -100,28 +100,28 @@ protected: private: ClipBlock *block_; - rational old_media_in_; - rational new_media_in_; + Rational old_media_in_; + Rational new_media_in_; }; class TimelineAddTrackCommand : public UndoCommand { public: TimelineAddTrackCommand(TrackList *timeline) : TimelineAddTrackCommand(timeline, - OLIVE_CONFIG("AutoMergeTracks").toBool()) + OAK_CONFIG("AutoMergeTracks").toBool()) { } TimelineAddTrackCommand(TrackList *timeline, bool automerge_tracks); - static Track *RunImmediately(TrackList *timeline) + static Track *run_immediately(TrackList *timeline) { TimelineAddTrackCommand c(timeline); c.redo(); return c.track(); } - static Track *RunImmediately(TrackList *timeline, bool automerge) + static Track *run_immediately(TrackList *timeline, bool automerge) { TimelineAddTrackCommand c(timeline, automerge); c.redo(); @@ -138,7 +138,7 @@ public: return track_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return timeline_->parent()->project(); } @@ -176,7 +176,7 @@ public: delete remove_command_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -208,7 +208,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -243,7 +243,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return block_->project(); } @@ -254,7 +254,7 @@ protected: virtual void undo() override; private: - void CreateRemoveTransitionCommandIfNecessary(bool next); + void create_remove_transition_command_if_necessary(bool next); Track *track_; Block *block_; @@ -280,7 +280,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return block_->project(); } @@ -306,8 +306,8 @@ private: class TrackListInsertGaps : public UndoCommand { public: - TrackListInsertGaps(TrackList *track_list, const rational &point, - const rational &length) + TrackListInsertGaps(TrackList *track_list, const Rational &point, + const Rational &length) : track_list_(track_list) , point_(point) , length_(length) @@ -320,7 +320,7 @@ public: delete split_command_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_list_->parent()->project(); } @@ -335,9 +335,9 @@ protected: private: TrackList *track_list_; - rational point_; + Rational point_; - rational length_; + Rational length_; QVector working_tracks_; @@ -359,7 +359,7 @@ private: class TimelineAddDefaultTransitionCommand : public UndoCommand { public: TimelineAddDefaultTransitionCommand(const QVector &clips, - const rational &timebase) + const Rational &timebase) : clips_(clips) , timebase_(timebase) { @@ -370,7 +370,7 @@ public: qDeleteAll(commands_); } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return clips_.empty() ? nullptr : clips_.first()->project(); } @@ -393,20 +393,20 @@ protected: } private: - enum CreateTransitionMode { kIn, kOut, kOutDual }; + enum CreateTransitionMode { k_in, k_out, k_out_dual }; - void AddTransition(ClipBlock *c, CreateTransitionMode mode); - void AdjustClipLength(ClipBlock *c, const rational &transition_length, + void add_transition(ClipBlock *c, CreateTransitionMode mode); + void adjust_clip_length(ClipBlock *c, const Rational &transition_length, bool out); - void ValidateTransitionLength(ClipBlock *c, rational &transition_length); + void validate_transition_length(ClipBlock *c, Rational &transition_length); QVector clips_; - rational timebase_; + Rational timebase_; QVector commands_; - QHash lengths_; + QHash lengths_; }; } -#endif // TIMELINEUNDOGENERAL_H +#endif // OAK_TIMELINEUNDOGENERAL_H diff --git a/app/timeline/timelineundopointer.cpp b/app/timeline/timelineundopointer.cpp index 9d2ba467a..8a5113e0f 100644 --- a/app/timeline/timelineundopointer.cpp +++ b/app/timeline/timelineundopointer.cpp @@ -41,7 +41,7 @@ void BlockTrimCommand::redo() // Determine how much time to invalidate TimeRange invalidate_range; - if (mode_ == Timeline::kTrimIn) { + if (mode_ == Timeline::k_trim_in) { invalidate_range = TimeRange(block_->in(), block_->in() + trim_diff_); block_->set_length_and_media_in(new_length_); } else { @@ -54,27 +54,27 @@ void BlockTrimCommand::redo() // Add adjacent and insert it adjacent_->setParent(track_->parent()); - if (mode_ == Timeline::kTrimIn) { - track_->InsertBlockBefore(adjacent_, block_); + if (mode_ == Timeline::k_trim_in) { + track_->insert_block_before(adjacent_, block_); } else { - track_->InsertBlockAfter(adjacent_, block_); + track_->insert_block_after(adjacent_, block_); } } else if (we_removed_adjacent_) { - track_->RippleRemoveBlock(adjacent_); + track_->ripple_remove_block(adjacent_); // It no longer inputs/outputs anything, remove it - if (remove_block_from_graph_ && NodeCanBeRemoved(adjacent_)) { + if (remove_block_from_graph_ && node_can_be_removed(adjacent_)) { if (!deleted_adjacent_command_) { deleted_adjacent_command_ = - CreateAndRunRemoveCommand(adjacent_); + create_and_run_remove_command(adjacent_); } else { deleted_adjacent_command_->redo_now(); } } } else { - rational adjacent_length = adjacent_->length() + trim_diff_; + Rational adjacent_length = adjacent_->length() + trim_diff_; - if (mode_ == Timeline::kTrimIn) { + if (mode_ == Timeline::k_trim_in) { adjacent_->set_length_and_media_out(adjacent_length); } else { adjacent_->set_length_and_media_in(adjacent_length); @@ -98,7 +98,7 @@ void BlockTrimCommand::undo() if (needs_adjacent_) { if (we_created_adjacent_) { // Adjacent is ours, just delete it - track_->RippleRemoveBlock(adjacent_); + track_->ripple_remove_block(adjacent_); adjacent_->setParent(&memory_manager_); } else { if (we_removed_adjacent_) { @@ -107,15 +107,15 @@ void BlockTrimCommand::undo() deleted_adjacent_command_->undo_now(); } - if (mode_ == Timeline::kTrimIn) { - track_->InsertBlockBefore(adjacent_, block_); + if (mode_ == Timeline::k_trim_in) { + track_->insert_block_before(adjacent_, block_); } else { - track_->InsertBlockAfter(adjacent_, block_); + track_->insert_block_after(adjacent_, block_); } } else { - rational adjacent_length = adjacent_->length() - trim_diff_; + Rational adjacent_length = adjacent_->length() - trim_diff_; - if (mode_ == Timeline::kTrimIn) { + if (mode_ == Timeline::k_trim_in) { adjacent_->set_length_and_media_out(adjacent_length); } else { adjacent_->set_length_and_media_in(adjacent_length); @@ -126,7 +126,7 @@ void BlockTrimCommand::undo() TimeRange invalidate_range; - if (mode_ == Timeline::kTrimIn) { + if (mode_ == Timeline::k_trim_in) { block_->set_length_and_media_in(old_length_); invalidate_range = TimeRange(block_->in(), block_->in() + trim_diff_); @@ -156,7 +156,7 @@ void BlockTrimCommand::prepare() trim_diff_ = old_length_ - new_length_; // Retrieve our adjacent block (or nullptr if none) - if (mode_ == Timeline::kTrimIn) { + if (mode_ == Timeline::k_trim_in) { adjacent_ = block_->previous(); } else { adjacent_ = block_->next(); @@ -164,7 +164,7 @@ void BlockTrimCommand::prepare() // Ignore when trimming the out with no adjacent, because the user must have trimmed the end // of the last block in the track, so we don't need to do anything elses - needs_adjacent_ = (mode_ == Timeline::kTrimIn || adjacent_); + needs_adjacent_ = (mode_ == Timeline::k_trim_in || adjacent_); if (needs_adjacent_) { // If we're trimming shorter, we need an adjacent, so check if we have a viable one. @@ -179,7 +179,7 @@ void BlockTrimCommand::prepare() adjacent_->set_length_and_media_out(trim_diff_); } else { // Determine if we're removing the adjacent - rational adjacent_length = adjacent_->length() + trim_diff_; + Rational adjacent_length = adjacent_->length() + trim_diff_; we_removed_adjacent_ = adjacent_length.isNull(); } } @@ -197,14 +197,14 @@ void TrackSlideCommand::redo() if (we_created_in_adjacent_) { // We created in adjacent, so all we have to do is insert it in_adjacent_->setParent(track_->parent()); - track_->InsertBlockBefore(in_adjacent_, blocks_.first()); + track_->insert_block_before(in_adjacent_, blocks_.first()); } else if (-movement_ == in_adjacent_->length()) { // Movement will remove in adjacent - track_->RippleRemoveBlock(in_adjacent_); + track_->ripple_remove_block(in_adjacent_); - if (NodeCanBeRemoved(in_adjacent_)) { + if (node_can_be_removed(in_adjacent_)) { if (!in_adjacent_remove_command_) { - in_adjacent_remove_command_ = CreateRemoveCommand(in_adjacent_); + in_adjacent_remove_command_ = create_remove_command(in_adjacent_); } in_adjacent_remove_command_->redo_now(); @@ -222,15 +222,15 @@ void TrackSlideCommand::redo() if (we_created_out_adjacent_) { // We created out adjacent, so we just have to insert it out_adjacent_->setParent(track_->parent()); - track_->InsertBlockAfter(out_adjacent_, blocks_.last()); + track_->insert_block_after(out_adjacent_, blocks_.last()); } else if (movement_ == out_adjacent_->length()) { // Movement will remove out adjacent - track_->RippleRemoveBlock(out_adjacent_); + track_->ripple_remove_block(out_adjacent_); - if (NodeCanBeRemoved(out_adjacent_)) { + if (node_can_be_removed(out_adjacent_)) { if (!out_adjacent_remove_command_) { out_adjacent_remove_command_ = - CreateRemoveCommand(out_adjacent_); + create_remove_command(out_adjacent_); } out_adjacent_remove_command_->redo_now(); @@ -257,7 +257,7 @@ void TrackSlideCommand::undo() if (we_created_in_adjacent_) { // We created this, so we can remove it now - track_->RippleRemoveBlock(in_adjacent_); + track_->ripple_remove_block(in_adjacent_); in_adjacent_->setParent(&memory_manager_); } else if (we_removed_in_adjacent_) { if (in_adjacent_remove_command_) { @@ -265,7 +265,7 @@ void TrackSlideCommand::undo() in_adjacent_remove_command_->undo_now(); } - track_->InsertBlockBefore(in_adjacent_, blocks_.first()); + track_->insert_block_before(in_adjacent_, blocks_.first()); } else { // Simply resize adjacent in_adjacent_->set_length_and_media_out(in_adjacent_->length() - @@ -275,14 +275,14 @@ void TrackSlideCommand::undo() if (out_adjacent_) { if (we_created_out_adjacent_) { // We created this, so we can remove it now - track_->RippleRemoveBlock(out_adjacent_); + track_->ripple_remove_block(out_adjacent_); out_adjacent_->setParent(&memory_manager_); } else if (we_removed_out_adjacent_) { if (out_adjacent_remove_command_) { out_adjacent_remove_command_->undo_now(); } - track_->InsertBlockAfter(out_adjacent_, blocks_.last()); + track_->insert_block_after(out_adjacent_, blocks_.last()); } else { out_adjacent_->set_length_and_media_in(out_adjacent_->length() + movement_); @@ -328,11 +328,11 @@ TrackPlaceBlockCommand::~TrackPlaceBlockCommand() void TrackPlaceBlockCommand::redo() { // Determine if we need to add tracks - if (track_index_ >= timeline_->GetTracks().size()) { + if (track_index_ >= timeline_->get_tracks().size()) { if (add_track_commands_.isEmpty()) { // First redo, create tracks now add_track_commands_.resize(track_index_ - - timeline_->GetTracks().size() + 1); + timeline_->get_tracks().size() + 1); for (int i = 0; i < add_track_commands_.size(); i++) { add_track_commands_[i] = new TimelineAddTrackCommand(timeline_); @@ -344,7 +344,7 @@ void TrackPlaceBlockCommand::redo() } } - Track *track = timeline_->GetTrackAt(track_index_); + Track *track = timeline_->get_track_at(track_index_); bool append = (in_ >= track->track_length()); @@ -357,38 +357,38 @@ void TrackPlaceBlockCommand::redo() gap_->set_length_and_media_out(in_ - track->track_length()); } gap_->setParent(track->parent()); - track->AppendBlock(gap_); + track->append_block(gap_); } - track->AppendBlock(insert_); + track->append_block(insert_); } else { // Place the Block at this point if (!ripple_remove_command_) { ripple_remove_command_ = new TrackRippleRemoveAreaCommand( track, TimeRange(in_, in_ + insert_->length())); - ripple_remove_command_->SetAllowSplittingGaps(true); + ripple_remove_command_->set_allow_splitting_gaps(true); } ripple_remove_command_->redo_now(); - track->InsertBlockAfter(insert_, - ripple_remove_command_->GetInsertionIndex()); + track->insert_block_after(insert_, + ripple_remove_command_->get_insertion_index()); } } void TrackPlaceBlockCommand::undo() { - Track *t = timeline_->GetTrackAt(track_index_); + Track *t = timeline_->get_track_at(track_index_); TimeRange insert_range(insert_->in(), insert_->out()); // Firstly, remove our insert - t->RippleRemoveBlock(insert_); + t->ripple_remove_block(insert_); if (ripple_remove_command_) { // If we ripple removed, just undo that ripple_remove_command_->undo_now(); } else if (gap_) { - t->RippleRemoveBlock(gap_); + t->ripple_remove_block(gap_); gap_->setParent(&memory_manager_); } diff --git a/app/timeline/timelineundopointer.h b/app/timeline/timelineundopointer.h index 9dbd78183..c65721524 100644 --- a/app/timeline/timelineundopointer.h +++ b/app/timeline/timelineundopointer.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEUNDOPOINTER_H -#define TIMELINEUNDOPOINTER_H +#ifndef OAK_TIMELINEUNDOPOINTER_H +#define OAK_TIMELINEUNDOPOINTER_H #include "node/block/gap/gap.h" #include "node/output/track/track.h" @@ -44,7 +44,7 @@ namespace olive */ class BlockTrimCommand : public UndoCommand { public: - BlockTrimCommand(Track *track, Block *block, rational new_length, + BlockTrimCommand(Track *track, Block *block, Rational new_length, Timeline::MovementMode mode) : track_(track) , block_(block) @@ -61,7 +61,7 @@ public: delete deleted_adjacent_command_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -69,7 +69,7 @@ public: /** * @brief Set this if the trim should always affect the adjacent clip and not create a gap */ - void SetTrimIsARollEdit(bool e) + void set_trim_is_a_roll_edit(bool e) { trim_is_a_roll_edit_ = e; } @@ -81,7 +81,7 @@ public: * default it also gets removed from the whole graph. Set this to FALSE to disable that * functionality. */ - void SetRemoveZeroLengthFromGraph(bool e) + void set_remove_zero_length_from_graph(bool e) { remove_block_from_graph_ = e; } @@ -93,12 +93,12 @@ protected: private: bool doing_nothing_; - rational trim_diff_; + Rational trim_diff_; Track *track_; Block *block_; - rational old_length_; - rational new_length_; + Rational old_length_; + Rational new_length_; Timeline::MovementMode mode_; Block *adjacent_; @@ -117,7 +117,7 @@ class TrackSlideCommand : public UndoCommand { public: TrackSlideCommand(Track *track, const QList &moving_blocks, Block *in_adjacent, Block *out_adjacent, - const rational &movement) + const Rational &movement) : track_(track) , blocks_(moving_blocks) , movement_(movement) @@ -137,7 +137,7 @@ public: delete out_adjacent_remove_command_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -152,7 +152,7 @@ protected: private: Track *track_; QList blocks_; - rational movement_; + Rational movement_; bool we_created_in_adjacent_; bool we_removed_in_adjacent_; @@ -176,7 +176,7 @@ private: class TrackPlaceBlockCommand : public UndoCommand { public: TrackPlaceBlockCommand(TrackList *timeline, int track, Block *block, - rational in) + Rational in) : timeline_(timeline) , track_index_(track) , in_(in) @@ -188,7 +188,7 @@ public: virtual ~TrackPlaceBlockCommand() override; - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return timeline_->parent()->project(); } @@ -201,7 +201,7 @@ protected: private: TrackList *timeline_; int track_index_; - rational in_; + Rational in_; GapBlock *gap_; Block *insert_; QVector add_track_commands_; @@ -211,4 +211,4 @@ private: } -#endif // TIMELINEUNDOPOINTER_H +#endif // OAK_TIMELINEUNDOPOINTER_H diff --git a/app/timeline/timelineundoripple.cpp b/app/timeline/timelineundoripple.cpp index f0fe73077..ad730b59a 100644 --- a/app/timeline/timelineundoripple.cpp +++ b/app/timeline/timelineundoripple.cpp @@ -49,7 +49,7 @@ TrackRippleRemoveAreaCommand::~TrackRippleRemoveAreaCommand() void TrackRippleRemoveAreaCommand::prepare() { // Determine precisely what will be happening to these tracks - Block *first_block = track_->NearestBlockBeforeOrAt(range_.in()); + Block *first_block = track_->nearest_block_before_or_at(range_.in()); if (!first_block) { // No blocks at this time, nothing to be done on this track @@ -140,15 +140,15 @@ void TrackRippleRemoveAreaCommand::redo() if (!removals_.isEmpty()) { foreach (auto op, removals_) { // Ripple remove them all first - track_->RippleRemoveBlock(op.block); + track_->ripple_remove_block(op.block); } // Create undo commands for node removals where possible if (remove_block_commands_.isEmpty()) { foreach (auto op, removals_) { - if (NodeCanBeRemoved(op.block)) { + if (node_can_be_removed(op.block)) { remove_block_commands_.append( - CreateRemoveCommand(op.block)); + create_remove_command(op.block)); } } } @@ -179,7 +179,7 @@ void TrackRippleRemoveAreaCommand::undo() } foreach (auto op, removals_) { - track_->InsertBlockAfter(op.block, op.before); + track_->insert_block_after(op.block, op.before); } } } @@ -189,8 +189,8 @@ void TrackRippleRemoveAreaCommand::undo() // void TrackListRippleRemoveAreaCommand::prepare() { - foreach (Track *track, list_->GetTracks()) { - if (track->IsLocked()) { + foreach (Track *track, list_->get_tracks()) { + if (track->is_locked()) { continue; } @@ -219,10 +219,10 @@ void TrackListRippleRemoveAreaCommand::undo() // TimelineRippleRemoveAreaCommand // TimelineRippleRemoveAreaCommand::TimelineRippleRemoveAreaCommand( - Sequence *timeline, rational in, rational out) + Sequence *timeline, Rational in, Rational out) : timeline_(timeline) { - for (int i = 0; i < Track::kCount; i++) { + for (int i = 0; i < Track::k_count; i++) { add_child(new TrackListRippleRemoveAreaCommand( timeline->track_list(static_cast(i)), in, out)); } @@ -233,7 +233,7 @@ TimelineRippleRemoveAreaCommand::TimelineRippleRemoveAreaCommand( // TrackListRippleToolCommand::TrackListRippleToolCommand( TrackList *track_list, const QHash &info, - const rational &ripple_movement, + const Rational &ripple_movement, const Timeline::MovementMode &movement_mode) : track_list_(track_list) , info_(info) @@ -252,8 +252,8 @@ void TrackListRippleToolCommand::ripple(bool redo) // If we can shift, we will shift from the latest out before the ripple to the latest out after, // since those sections will be unchanged by this ripple - rational pre_latest_out = RATIONAL_MIN; - rational post_latest_out = RATIONAL_MIN; + Rational pre_latest_out = RATIONAL_MIN; + Rational post_latest_out = RATIONAL_MIN; // Make timeline changes for (auto it = info_.cbegin(); it != info_.cend(); it++) { @@ -263,10 +263,10 @@ void TrackListRippleToolCommand::ripple(bool redo) Block *b = info.block; // Generate block length - rational new_block_length; - rational operation_movement = ripple_movement_; + Rational new_block_length; + Rational operation_movement = ripple_movement_; - if (movement_mode_ == Timeline::kTrimIn) { + if (movement_mode_ == Timeline::k_trim_in) { operation_movement = -operation_movement; } @@ -278,8 +278,8 @@ void TrackListRippleToolCommand::ripple(bool redo) new_block_length = b->length() + operation_movement; } - rational pre_shift; - rational post_shift; + Rational pre_shift; + Rational post_shift; if (info.append_gap) { // Rather than rippling the referenced block, we'll insert a gap and ripple with that @@ -293,7 +293,7 @@ void TrackListRippleToolCommand::ripple(bool redo) } gap->setParent(track->parent()); - track->InsertBlockBefore(gap, b); + track->insert_block_before(gap, b); // As an insertion, we will shift from the gap's in to the gap's out pre_shift = gap->in(); @@ -304,7 +304,7 @@ void TrackListRippleToolCommand::ripple(bool redo) pre_shift = gap->out(); post_shift = gap->in(); - track->RippleRemoveBlock(gap); + track->ripple_remove_block(gap); gap->setParent(&memory_manager_); } @@ -323,12 +323,12 @@ void TrackListRippleToolCommand::ripple(bool redo) // Remove gap from track and from graph working_data.removed_gap_after = b->previous(); - track->RippleRemoveBlock(b); + track->ripple_remove_block(b); b->setParent(&memory_manager_); } else { // Restore gap to graph and track b->setParent(track->parent()); - track->InsertBlockAfter(b, working_data.removed_gap_after); + track->insert_block_after(b, working_data.removed_gap_after); // The earliest point changes will happen is at the start of this block working_data.earliest_point_of_change = b->in(); @@ -342,13 +342,13 @@ void TrackListRippleToolCommand::ripple(bool redo) // Store old length working_data.old_length = b->length(); - if (movement_mode_ == Timeline::kTrimIn) { + if (movement_mode_ == Timeline::k_trim_in) { // The earliest point changes will occur is in point of this bloc working_data.earliest_point_of_change = b->in(); // Undo the trim in inversion we do above, this will still be inverted accurately for // undoing where appropriate - rational inverted = -operation_movement; + Rational inverted = -operation_movement; if (inverted > 0) { pre_shift = b->in() + inverted; post_shift = b->in(); @@ -396,7 +396,7 @@ void TimelineRippleDeleteGapsAtRegionsCommand::prepare() const TimeRange &range = region.second; GapBlock *gap = - dynamic_cast(track->NearestBlockBeforeOrAt(range.in())); + dynamic_cast(track->nearest_block_before_or_at(range.in())); if (gap) { QVector &gaps_on_track = requested_gaps[track]; @@ -424,11 +424,11 @@ void TimelineRippleDeleteGapsAtRegionsCommand::prepare() // For each gap on each track, find a corresponding gap on every other track (which may include // a requested gap) to ripple in order to keep everything synchronized - QHash gap_lengths; + QHash gap_lengths; for (int gap_index = 0; gap_index < max_gaps; gap_index++) { - rational earliest_point = RATIONAL_MAX; - rational ripple_length = RATIONAL_MAX; - rational latest_point = RATIONAL_MIN; + Rational earliest_point = RATIONAL_MAX; + Rational ripple_length = RATIONAL_MAX; + Rational latest_point = RATIONAL_MIN; foreach (const QVector &gaps_on_track, requested_gaps) { if (gap_index < gaps_on_track.size()) { @@ -442,8 +442,8 @@ void TimelineRippleDeleteGapsAtRegionsCommand::prepare() // Determine which gaps will be involved in this operation QVector gaps; - foreach (Track *track, timeline_->GetTracks()) { - if (track->IsLocked()) { + foreach (Track *track, timeline_->get_tracks()) { + if (track->is_locked()) { continue; } @@ -455,7 +455,7 @@ void TimelineRippleDeleteGapsAtRegionsCommand::prepare() gap = requested_gaps_on_track.at(gap_index).gap; } else { // No requested gap was at this index, find one - Block *block = track->NearestBlockAfterOrAt(earliest_point); + Block *block = track->nearest_block_after_or_at(earliest_point); if (block) { // Found a block, test if it's a gap diff --git a/app/timeline/timelineundoripple.h b/app/timeline/timelineundoripple.h index 5e3d720d5..125e259eb 100644 --- a/app/timeline/timelineundoripple.h +++ b/app/timeline/timelineundoripple.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEUNDORIPPLE_H -#define TIMELINEUNDORIPPLE_H +#ifndef OAK_TIMELINEUNDORIPPLE_H +#define OAK_TIMELINEUNDORIPPLE_H #include "node/block/gap/gap.h" #include "node/output/track/track.h" @@ -46,7 +46,7 @@ public: virtual ~TrackRippleRemoveAreaCommand() override; - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -54,12 +54,12 @@ public: /** * @brief Block to insert after if you want to insert something between this ripple */ - Block *GetInsertionIndex() const + Block *get_insertion_index() const { return insert_previous_; } - Block *GetSplicedBlock() const + Block *get_spliced_block() const { if (splice_split_command_) { return splice_split_command_->new_block(); @@ -68,7 +68,7 @@ public: return nullptr; } - void SetAllowSplittingGaps(bool e) + void set_allow_splitting_gaps(bool e) { allow_splitting_gaps_ = e; } @@ -83,8 +83,8 @@ protected: private: struct TrimOperation { Block *block; - rational old_length; - rational new_length; + Rational old_length; + Rational new_length; }; struct RemoveOperation { @@ -107,7 +107,7 @@ private: class TrackListRippleRemoveAreaCommand : public UndoCommand { public: - TrackListRippleRemoveAreaCommand(TrackList *list, rational in, rational out) + TrackListRippleRemoveAreaCommand(TrackList *list, Rational in, Rational out) : list_(list) , range_(in, out) { @@ -118,7 +118,7 @@ public: qDeleteAll(commands_); } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return list_->parent()->project(); } @@ -142,10 +142,10 @@ private: class TimelineRippleRemoveAreaCommand : public MultiUndoCommand { public: - TimelineRippleRemoveAreaCommand(Sequence *timeline, rational in, - rational out); + TimelineRippleRemoveAreaCommand(Sequence *timeline, Rational in, + Rational out); - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return timeline_->project(); } @@ -163,10 +163,10 @@ public: TrackListRippleToolCommand(TrackList *track_list, const QHash &info, - const rational &ripple_movement, + const Rational &ripple_movement, const Timeline::MovementMode &movement_mode); - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_list_->parent()->project(); } @@ -188,14 +188,14 @@ private: TrackList *track_list_; QHash info_; - rational ripple_movement_; + Rational ripple_movement_; Timeline::MovementMode movement_mode_; struct WorkingData { GapBlock *created_gap = nullptr; Block *removed_gap_after; - rational old_length; - rational earliest_point_of_change; + Rational old_length; + Rational earliest_point_of_change; }; QHash working_data_; @@ -219,12 +219,12 @@ public: qDeleteAll(commands_); } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return timeline_->project(); } - bool HasCommands() const + bool has_commands() const { return !commands_.isEmpty(); } @@ -250,4 +250,4 @@ private: } -#endif // TIMELINEUNDORIPPLE_H +#endif // OAK_TIMELINEUNDORIPPLE_H diff --git a/app/timeline/timelineundosplit.cpp b/app/timeline/timelineundosplit.cpp index 3309f5a77..f91adba56 100644 --- a/app/timeline/timelineundosplit.cpp +++ b/app/timeline/timelineundosplit.cpp @@ -35,7 +35,7 @@ void BlockSplitCommand::prepare() { reconnect_tree_command_ = new MultiUndoCommand(); new_block_ = static_cast( - Node::CopyNodeInGraph(block_, reconnect_tree_command_)); + Node::copy_node_in_graph(block_, reconnect_tree_command_)); } void BlockSplitCommand::redo() @@ -47,8 +47,8 @@ void BlockSplitCommand::redo() reconnect_tree_command_->redo_now(); // Determine our new lengths - rational new_length = point_ - block_->in(); - rational new_part_length = block_->out() - point_; + Rational new_length = point_ - block_->in(); + Rational new_part_length = block_->out() - point_; // Begin an operation Track *track = block_->track(); @@ -58,11 +58,11 @@ void BlockSplitCommand::redo() new_block()->set_length_and_media_in(new_part_length); // Insert new block - track->InsertBlockAfter(new_block(), block_); + track->insert_block_after(new_block(), block_); if (ClipBlock *new_clip = dynamic_cast(new_block_)) { ClipBlock *old_clip = static_cast(block_); - new_clip->AddCachePassthroughFrom(old_clip); + new_clip->add_cache_passthrough_from(old_clip); } // If the block had an out transition, we move it to the new block @@ -75,9 +75,9 @@ void BlockSplitCommand::redo() block_->output_connections()) { if (output.second.node() == potential_transition) { moved_transition_ = NodeInput(potential_transition, - TransitionBlock::kOutBlockInput); - Node::DisconnectEdge(block_, moved_transition_); - Node::ConnectEdge(new_block(), moved_transition_); + TransitionBlock::k_out_block_input); + Node::disconnect_edge(block_, moved_transition_); + Node::connect_edge(new_block(), moved_transition_); break; } } @@ -88,13 +88,13 @@ void BlockSplitCommand::undo() { Track *track = block_->track(); - if (moved_transition_.IsValid()) { - Node::DisconnectEdge(new_block(), moved_transition_); - Node::ConnectEdge(block_, moved_transition_); + if (moved_transition_.is_valid()) { + Node::disconnect_edge(new_block(), moved_transition_); + Node::connect_edge(block_, moved_transition_); } block_->set_length_and_media_out(old_length_); - track->RippleRemoveBlock(new_block()); + track->ripple_remove_block(new_block()); // If we ran a reconnect command, disconnect now reconnect_tree_command_->undo_now(); @@ -103,7 +103,7 @@ void BlockSplitCommand::undo() // // BlockSplitPreservingLinksCommand // -Block *BlockSplitPreservingLinksCommand::GetSplit(Block *original, +Block *BlockSplitPreservingLinksCommand::get_split(Block *original, int time_index) const { if (time_index >= 0 && time_index < times_.size()) { @@ -121,7 +121,7 @@ void BlockSplitPreservingLinksCommand::prepare() splits_.resize(times_.size()); for (int i = 0; i < times_.size(); i++) { - const rational &time = times_.at(i); + const Rational &time = times_.at(i); // FIXME: I realize this isn't going to work if the times aren't ordered. I'm lazy so rather // than writing in a sorting algorithm here, I'll just put an assert as a reminder @@ -158,7 +158,7 @@ void BlockSplitPreservingLinksCommand::prepare() Block *b = blocks_.at(j); - if (Block::AreLinked(a, b)) { + if (Block::are_linked(a, b)) { // These blocks are linked, ensure all the splits are linked too foreach (const QVector &split_list, splits_) { @@ -178,7 +178,7 @@ void BlockSplitPreservingLinksCommand::prepare() void TrackSplitAtTimeCommand::prepare() { // Find Block that contains this time - Block *b = track_->BlockContainingTime(point_); + Block *b = track_->block_containing_time(point_); if (b) { command_ = new BlockSplitCommand(b, point_); diff --git a/app/timeline/timelineundosplit.h b/app/timeline/timelineundosplit.h index 3b1687f23..ec43b4093 100644 --- a/app/timeline/timelineundosplit.h +++ b/app/timeline/timelineundosplit.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEUNDOSPLIT_H -#define TIMELINEUNDOSPLIT_H +#ifndef OAK_TIMELINEUNDOSPLIT_H +#define OAK_TIMELINEUNDOSPLIT_H #include "node/output/track/track.h" @@ -29,7 +29,7 @@ namespace olive class BlockSplitCommand : public UndoCommand { public: - BlockSplitCommand(Block *block, rational point) + BlockSplitCommand(Block *block, Rational point) : block_(block) , new_block_(nullptr) , point_(point) @@ -42,7 +42,7 @@ public: delete reconnect_tree_command_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return block_->project(); } @@ -66,8 +66,8 @@ private: Block *block_; Block *new_block_; - rational old_length_; - rational point_; + Rational old_length_; + Rational point_; MultiUndoCommand *reconnect_tree_command_; @@ -77,7 +77,7 @@ private: class BlockSplitPreservingLinksCommand : public UndoCommand { public: BlockSplitPreservingLinksCommand(const QVector &blocks, - const QList ×) + const QList ×) : blocks_(blocks) , times_(times) { @@ -88,12 +88,12 @@ public: qDeleteAll(commands_); } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return blocks_.first()->project(); } - Block *GetSplit(Block *original, int time_index) const; + Block *get_split(Block *original, int time_index) const; protected: virtual void prepare() override; @@ -115,7 +115,7 @@ protected: private: QVector blocks_; - QList times_; + QList times_; QVector commands_; @@ -124,7 +124,7 @@ private: class TrackSplitAtTimeCommand : public UndoCommand { public: - TrackSplitAtTimeCommand(Track *track, rational point) + TrackSplitAtTimeCommand(Track *track, Rational point) : track_(track) , point_(point) , command_(nullptr) @@ -136,7 +136,7 @@ public: delete command_; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -161,11 +161,11 @@ protected: private: Track *track_; - rational point_; + Rational point_; UndoCommand *command_; }; } -#endif // TIMELINEUNDOSPLIT_H +#endif // OAK_TIMELINEUNDOSPLIT_H diff --git a/app/timeline/timelineundotrack.h b/app/timeline/timelineundotrack.h index 2488a4b89..64f96229e 100644 --- a/app/timeline/timelineundotrack.h +++ b/app/timeline/timelineundotrack.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEUNDOTRACK_H -#define TIMELINEUNDOTRACK_H +#ifndef OAK_TIMELINEUNDOTRACK_H +#define OAK_TIMELINEUNDOTRACK_H #include "node/output/track/track.h" @@ -35,7 +35,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -44,12 +44,12 @@ protected: virtual void redo() override { before_ = block_->previous(); - track_->RippleRemoveBlock(block_); + track_->ripple_remove_block(block_); } virtual void undo() override { - track_->InsertBlockAfter(block_, before_); + track_->insert_block_after(block_, before_); } private: @@ -68,7 +68,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -76,12 +76,12 @@ public: protected: virtual void redo() override { - track_->PrependBlock(block_); + track_->prepend_block(block_); } virtual void undo() override { - track_->RippleRemoveBlock(block_); + track_->ripple_remove_block(block_); } private: @@ -98,7 +98,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return block_->project(); } @@ -106,12 +106,12 @@ public: protected: virtual void redo() override { - track_->InsertBlockAfter(block_, before_); + track_->insert_block_after(block_, before_); } virtual void undo() override { - track_->RippleRemoveBlock(block_); + track_->ripple_remove_block(block_); } private: @@ -136,7 +136,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return track_->project(); } @@ -144,12 +144,12 @@ public: protected: virtual void redo() override { - track_->ReplaceBlock(old_, replace_); + track_->replace_block(old_, replace_); } virtual void undo() override { - track_->ReplaceBlock(replace_, old_); + track_->replace_block(replace_, old_); } private: @@ -160,4 +160,4 @@ private: } -#endif // TIMELINEUNDOTRACK_H +#endif // OAK_TIMELINEUNDOTRACK_H diff --git a/app/timeline/timelineundoworkarea.h b/app/timeline/timelineundoworkarea.h index 69f0319f4..0ec37677a 100644 --- a/app/timeline/timelineundoworkarea.h +++ b/app/timeline/timelineundoworkarea.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEUNDOWORKAREA_H -#define TIMELINEUNDOWORKAREA_H +#ifndef OAK_TIMELINEUNDOWORKAREA_H +#define OAK_TIMELINEUNDOWORKAREA_H #include "node/project.h" @@ -38,7 +38,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return project_; } @@ -79,9 +79,9 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { - return Project::GetProjectFromObject(workarea_); + return Project::get_project_from_object(workarea_); } protected: @@ -105,4 +105,4 @@ private: } -#endif // TIMELINEUNDOWORKAREA_H +#endif // OAK_TIMELINEUNDOWORKAREA_H diff --git a/app/timeline/timelineworkarea.cpp b/app/timeline/timelineworkarea.cpp index c185391a5..0b2a5db90 100644 --- a/app/timeline/timelineworkarea.cpp +++ b/app/timeline/timelineworkarea.cpp @@ -26,8 +26,8 @@ namespace olive { -const rational TimelineWorkArea::kResetIn = 0; -const rational TimelineWorkArea::kResetOut = RATIONAL_MAX; +const Rational TimelineWorkArea::k_reset_in = 0; +const Rational TimelineWorkArea::k_reset_out = RATIONAL_MAX; TimelineWorkArea::TimelineWorkArea(QObject *parent) : QObject(parent) @@ -43,7 +43,7 @@ bool TimelineWorkArea::enabled() const void TimelineWorkArea::set_enabled(bool e) { workarea_enabled_ = e; - emit EnabledChanged(workarea_enabled_); + emit enabled_changed(workarea_enabled_); } const TimeRange &TimelineWorkArea::range() const @@ -54,13 +54,13 @@ const TimeRange &TimelineWorkArea::range() const void TimelineWorkArea::set_range(const TimeRange &range) { workarea_range_ = range; - emit RangeChanged(workarea_range_); + emit range_changed(workarea_range_); } bool TimelineWorkArea::load(QXmlStreamReader *reader) { - rational range_in = this->in(); - rational range_out = this->out(); + Rational range_in = this->in(); + Rational range_out = this->out(); uint version = 0; XMLAttributeLoop(reader, attr) @@ -71,15 +71,15 @@ bool TimelineWorkArea::load(QXmlStreamReader *reader) } Q_UNUSED(version) - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("enabled")) { this->set_enabled(reader->readElementText() != QStringLiteral("0")); } else if (reader->name() == QStringLiteral("in")) { range_in = - rational::fromString(reader->readElementText().toStdString()); + Rational::from_string(reader->readElementText().toStdString()); } else if (reader->name() == QStringLiteral("out")) { range_out = - rational::fromString(reader->readElementText().toStdString()); + Rational::from_string(reader->readElementText().toStdString()); } else { reader->skipCurrentElement(); } @@ -101,22 +101,22 @@ void TimelineWorkArea::save(QXmlStreamWriter *writer) const writer->writeTextElement(QStringLiteral("enabled"), QString::number(this->enabled())); writer->writeTextElement(QStringLiteral("in"), - QString::fromStdString(this->in().toString())); + QString::fromStdString(this->in().to_string())); writer->writeTextElement(QStringLiteral("out"), - QString::fromStdString(this->out().toString())); + QString::fromStdString(this->out().to_string())); } -const rational &TimelineWorkArea::in() const +const Rational &TimelineWorkArea::in() const { return workarea_range_.in(); } -const rational &TimelineWorkArea::out() const +const Rational &TimelineWorkArea::out() const { return workarea_range_.out(); } -const rational &TimelineWorkArea::length() const +const Rational &TimelineWorkArea::length() const { return workarea_range_.length(); } diff --git a/app/timeline/timelineworkarea.h b/app/timeline/timelineworkarea.h index cce9492a6..17a16816a 100644 --- a/app/timeline/timelineworkarea.h +++ b/app/timeline/timelineworkarea.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEWORKAREA_H -#define TIMELINEWORKAREA_H +#ifndef OAK_TIMELINEWORKAREA_H +#define OAK_TIMELINEWORKAREA_H #include #include @@ -40,22 +40,22 @@ public: bool enabled() const; void set_enabled(bool e); - const rational &in() const; - const rational &out() const; - const rational &length() const; + const Rational &in() const; + const Rational &out() const; + const Rational &length() const; const TimeRange &range() const; void set_range(const TimeRange &range); bool load(QXmlStreamReader *reader); void save(QXmlStreamWriter *writer) const; - static const rational kResetIn; - static const rational kResetOut; + static const Rational k_reset_in; + static const Rational k_reset_out; signals: - void EnabledChanged(bool e); + void enabled_changed(bool e); - void RangeChanged(const TimeRange &r); + void range_changed(const TimeRange &r); private: bool workarea_enabled_; @@ -65,4 +65,4 @@ private: } -#endif // TIMELINEWORKAREA_H +#endif // OAK_TIMELINEWORKAREA_H diff --git a/app/tool/tool.h b/app/tool/tool.h index 28375d4bb..2cd54a576 100644 --- a/app/tool/tool.h +++ b/app/tool/tool.h @@ -19,8 +19,8 @@ ***/ -#ifndef TOOL_H -#define TOOL_H +#ifndef OAK_TOOL_H +#define OAK_TOOL_H #include #include @@ -38,48 +38,48 @@ public: enum Item { /// No tool. This should never be set as the application tool, its only real purpose is to indicate the lack of /// a tool somewhere similar to nullptr. - kNone, + k_none, /// Pointer tool - kPointer, + k_pointer, /// Edit tool - kEdit, + k_edit, /// Ripple tool - kRipple, + k_ripple, /// Rolling tool - kRolling, + k_rolling, /// Razor tool - kRazor, + k_razor, /// Slip tool - kSlip, + k_slip, /// Slide tool - kSlide, + k_slide, /// Hand tool - kHand, + k_hand, /// Zoom tool - kZoom, + k_zoom, /// Transition tool - kTransition, + k_transition, /// Record tool - kRecord, + k_record, /// Add tool - kAdd, + k_add, /// Track select tool - kTrackSelect, + k_track_select, - kCount + k_count }; /** @@ -87,71 +87,71 @@ public: */ enum AddableObject { /// An empty clip - kAddableEmpty, + k_addable_empty, /// A video clip showing a generic video placeholder - kAddableBars, + k_addable_bars, /// A video clip showing a primitive shape - kAddableShape, + k_addable_shape, /// A video clip with a solid connected - kAddableSolid, + k_addable_solid, /// A video clip with a title connected - kAddableTitle, + k_addable_title, /// An audio clip with a sine connected to it - kAddableTone, + k_addable_tone, /// A subtitle clip - kAddableSubtitle, + k_addable_subtitle, - kAddableCount + k_addable_count }; - static QString GetAddableObjectName(const AddableObject &a) + static QString get_addable_object_name(const AddableObject &a) { switch (a) { - case kAddableEmpty: + case k_addable_empty: return QCoreApplication::translate("Tool", "Empty"); - case kAddableBars: + case k_addable_bars: return QCoreApplication::translate("Tool", "Bars"); - case kAddableShape: + case k_addable_shape: return QCoreApplication::translate("Tool", "Shape"); - case kAddableSolid: + case k_addable_solid: return QCoreApplication::translate("Tool", "Solid"); - case kAddableTitle: + case k_addable_title: return QCoreApplication::translate("Tool", "Title"); - case kAddableTone: + case k_addable_tone: return QCoreApplication::translate("Tool", "Tone"); - case kAddableSubtitle: + case k_addable_subtitle: return QCoreApplication::translate("Tool", "Subtitle"); - case kAddableCount: + case k_addable_count: break; } return QCoreApplication::translate("Tool", "Unknown"); } - static QString GetAddableObjectID(const AddableObject &a) + static QString get_addable_object_id(const AddableObject &a) { switch (a) { - case kAddableEmpty: + case k_addable_empty: return QStringLiteral("empty"); - case kAddableBars: + case k_addable_bars: return QStringLiteral("bars"); - case kAddableShape: + case k_addable_shape: return QStringLiteral("shape"); - case kAddableSolid: + case k_addable_solid: return QStringLiteral("solid"); - case kAddableTitle: + case k_addable_title: return QStringLiteral("title"); - case kAddableTone: + case k_addable_tone: return QStringLiteral("tone"); - case kAddableSubtitle: + case k_addable_subtitle: return QStringLiteral("subtitle"); - case kAddableCount: + case k_addable_count: break; } @@ -161,4 +161,4 @@ public: } -#endif // TOOL_H +#endif // OAK_TOOL_H diff --git a/app/ui/colorcoding.cpp b/app/ui/colorcoding.cpp index da7af49bf..7d0bdc67b 100644 --- a/app/ui/colorcoding.cpp +++ b/app/ui/colorcoding.cpp @@ -24,7 +24,7 @@ namespace olive { -QVector ColorCoding::colors_ = { +QVector ColorCoding::colors = { Color(0.545f, 0.255f, 0.255f), Color(0.412f, 0.188f, 0.259f), Color(0.561f, 0.427f, 0.239f), Color(0.486f, 0.306f, 0.235f), Color(0.631f, 0.612f, 0.212f), Color(0.404f, 0.478f, 0.243f), @@ -35,55 +35,55 @@ QVector ColorCoding::colors_ = { Color(0.800f, 0.800f, 0.800f), Color(0.502f, 0.502f, 0.502f) }; -QString ColorCoding::GetColorName(int c) +QString ColorCoding::get_color_name(int c) { // FIXME: I'm sure we could come up with more creative names for these colors switch (c) { - case kRed: + case k_red: return tr("Red"); - case kMaroon: + case k_maroon: return tr("Maroon"); - case kOrange: + case k_orange: return tr("Orange"); - case kBrown: + case k_brown: return tr("Brown"); - case kYellow: + case k_yellow: return tr("Yellow"); - case kOlive: + case k_olive: return tr("Oak"); - case kLime: + case k_lime: return tr("Lime"); - case kGreen: + case k_green: return tr("Green"); - case kCyan: + case k_cyan: return tr("Cyan"); - case kTeal: + case k_teal: return tr("Teal"); - case kBlue: + case k_blue: return tr("Blue"); - case kNavy: + case k_navy: return tr("Navy"); - case kPink: + case k_pink: return tr("Pink"); - case kPurple: + case k_purple: return tr("Purple"); - case kSilver: + case k_silver: return tr("Silver"); - case kGray: + case k_gray: return tr("Gray"); } return QString(); } -Color ColorCoding::GetColor(int c) +Color ColorCoding::get_color(int c) { - return colors_.at(c); + return colors.at(c); } -Qt::GlobalColor ColorCoding::GetUISelectorColor(const Color &c) +Qt::GlobalColor ColorCoding::get_ui_selector_color(const Color &c) { - if (c.GetRoughLuminance() > 0.40f) { + if (c.get_rough_luminance() > 0.40f) { return Qt::black; } else { return Qt::white; diff --git a/app/ui/colorcoding.h b/app/ui/colorcoding.h index 3e876622f..613370e56 100644 --- a/app/ui/colorcoding.h +++ b/app/ui/colorcoding.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORCODING_H -#define COLORCODING_H +#ifndef OAK_COLORCODING_H +#define OAK_COLORCODING_H #include #include @@ -34,39 +34,39 @@ class ColorCoding : public QObject { Q_OBJECT public: enum Code { - kRed, - kMaroon, - kOrange, - kBrown, - kYellow, - kOlive, - kLime, - kGreen, - kCyan, - kTeal, - kBlue, - kNavy, - kPink, - kPurple, - kSilver, - kGray + k_red, + k_maroon, + k_orange, + k_brown, + k_yellow, + k_olive, + k_lime, + k_green, + k_cyan, + k_teal, + k_blue, + k_navy, + k_pink, + k_purple, + k_silver, + k_gray }; - static QString GetColorName(int c); + static QString get_color_name(int c); - static Color GetColor(int c); + static Color get_color(int c); - static Qt::GlobalColor GetUISelectorColor(const Color &c); + static Qt::GlobalColor get_ui_selector_color(const Color &c); static const QVector &standard_colors() { - return colors_; + return colors; } private: - static QVector colors_; + static QVector colors; }; } -#endif // COLORCODING_H +#endif // OAK_COLORCODING_H diff --git a/app/ui/humanstrings.cpp b/app/ui/humanstrings.cpp index a4d095558..3c6a611e7 100644 --- a/app/ui/humanstrings.cpp +++ b/app/ui/humanstrings.cpp @@ -23,23 +23,23 @@ namespace olive { -QString HumanStrings::SampleRateToString(const int &sample_rate) +QString HumanStrings::sample_rate_to_string(const int &sample_rate) { return QCoreApplication::translate("AudioParams", "%1 Hz").arg(sample_rate); } -QString HumanStrings::ChannelLayoutToString(const uint64_t &layout) +QString HumanStrings::channel_layout_to_string(const uint64_t &layout) { switch (layout) { - case kChannelLayoutMono: + case k_channel_layout_mono: return QCoreApplication::translate("AudioParams", "Mono"); - case kChannelLayoutStereo: + case k_channel_layout_stereo: return QCoreApplication::translate("AudioParams", "Stereo"); - case kChannelLayout2_1: + case k_channel_layout2_1: return QCoreApplication::translate("AudioParams", "2.1"); - case kChannelLayout5Point1: + case k_channel_layout5_point1: return QCoreApplication::translate("AudioParams", "5.1"); - case kChannelLayout7Point1: + case k_channel_layout7_point1: return QCoreApplication::translate("AudioParams", "7.1"); default: return QCoreApplication::translate("AudioParams", "Unknown (0x%1)") @@ -47,48 +47,48 @@ QString HumanStrings::ChannelLayoutToString(const uint64_t &layout) } } -QString HumanStrings::FormatToString(const SampleFormat &f) +QString HumanStrings::format_to_string(const SampleFormat &f) { switch (f) { - case SampleFormat::U8: + case SampleFormat::u8: return QCoreApplication::translate("AudioParams", "Unsigned 8-bit (Packed)"); - case SampleFormat::S16: + case SampleFormat::s16: return QCoreApplication::translate("AudioParams", "Signed 16-bit (Packed)"); - case SampleFormat::S32: + case SampleFormat::s32: return QCoreApplication::translate("AudioParams", "Signed 32-bit (Packed)"); - case SampleFormat::S64: + case SampleFormat::s64: return QCoreApplication::translate("AudioParams", "Signed 64-bit (Packed)"); - case SampleFormat::F32: + case SampleFormat::f32: return QCoreApplication::translate("AudioParams", "Float 32-bit (Packed)"); - case SampleFormat::F64: + case SampleFormat::f64: return QCoreApplication::translate("AudioParams", "Float 64-bit (Packed)"); - case SampleFormat::U8P: + case SampleFormat::u8_p: return QCoreApplication::translate("AudioParams", "Unsigned 8-bit (Planar)"); - case SampleFormat::S16P: + case SampleFormat::s16_p: return QCoreApplication::translate("AudioParams", "Signed 16-bit (Planar)"); - case SampleFormat::S32P: + case SampleFormat::s32_p: return QCoreApplication::translate("AudioParams", "Signed 32-bit (Planar)"); - case SampleFormat::S64P: + case SampleFormat::s64_p: return QCoreApplication::translate("AudioParams", "Signed 64-bit (Planar)"); - case SampleFormat::F32P: + case SampleFormat::f32_p: return QCoreApplication::translate("AudioParams", "Float 32-bit (Planar)"); - case SampleFormat::F64P: + case SampleFormat::f64_p: return QCoreApplication::translate("AudioParams", "Float 64-bit (Planar)"); - case SampleFormat::INVALID: - case SampleFormat::COUNT: + case SampleFormat::invalid: + case SampleFormat::count: break; } diff --git a/app/ui/humanstrings.h b/app/ui/humanstrings.h index d9b7d45f1..a8941017b 100644 --- a/app/ui/humanstrings.h +++ b/app/ui/humanstrings.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef HUMANSTRINGS_H -#define HUMANSTRINGS_H +#ifndef OAK_HUMANSTRINGS_H +#define OAK_HUMANSTRINGS_H #include #include @@ -32,13 +32,13 @@ class HumanStrings : public QObject { public: HumanStrings() = default; - static QString SampleRateToString(const int &sample_rate); + static QString sample_rate_to_string(const int &sample_rate); - static QString ChannelLayoutToString(const uint64_t &layout); + static QString channel_layout_to_string(const uint64_t &layout); - static QString FormatToString(const SampleFormat &f); + static QString format_to_string(const SampleFormat &f); }; } -#endif // HUMANSTRINGS_H +#endif // OAK_HUMANSTRINGS_H diff --git a/app/ui/icons/icons.cpp b/app/ui/icons/icons.cpp index 45bfb6447..cadcf6e11 100644 --- a/app/ui/icons/icons.cpp +++ b/app/ui/icons/icons.cpp @@ -25,165 +25,165 @@ namespace olive { /// Works in conjunction with `genicons.sh` to generate and utilize icons of specific sizes -const int ICON_SIZE_COUNT = 4; -const int ICON_SIZES[] = { 16, 32, 64, 128 }; +const int icon_size_count = 4; +const int icon_sizes[] = { 16, 32, 64, 128 }; /// Internal icon library for use throughout Olive without having to regenerate constantly -QIcon icon::GoToStart; -QIcon icon::PrevFrame; -QIcon icon::Play; -QIcon icon::Pause; -QIcon icon::NextFrame; -QIcon icon::GoToEnd; +QIcon icon::go_to_start; +QIcon icon::prev_frame; +QIcon icon::play; +QIcon icon::pause; +QIcon icon::next_frame; +QIcon icon::go_to_end; QIcon icon::New; -QIcon icon::Open; -QIcon icon::Save; -QIcon icon::Undo; -QIcon icon::Redo; -QIcon icon::TreeView; -QIcon icon::ListView; -QIcon icon::IconView; -QIcon icon::ToolPointer; -QIcon icon::ToolEdit; -QIcon icon::ToolRipple; -QIcon icon::ToolRolling; -QIcon icon::ToolRazor; -QIcon icon::ToolSlip; -QIcon icon::ToolSlide; -QIcon icon::ToolHand; -QIcon icon::ToolTransition; -QIcon icon::ToolTrackSelect; -QIcon icon::Folder; -QIcon icon::Sequence; -QIcon icon::Video; -QIcon icon::Audio; -QIcon icon::Image; -QIcon icon::MiniMap; -QIcon icon::TriUp; -QIcon icon::TriLeft; -QIcon icon::TriDown; -QIcon icon::TriRight; -QIcon icon::TextBold; -QIcon icon::TextItalic; -QIcon icon::TextUnderline; -QIcon icon::TextStrikethrough; -QIcon icon::TextSmallCaps; -QIcon icon::TextAlignLeft; -QIcon icon::TextAlignRight; -QIcon icon::TextAlignCenter; -QIcon icon::TextAlignJustify; -QIcon icon::TextAlignTop; -QIcon icon::TextAlignBottom; -QIcon icon::TextAlignMiddle; -QIcon icon::Snapping; -QIcon icon::ZoomIn; -QIcon icon::ZoomOut; -QIcon icon::Record; -QIcon icon::Add; -QIcon icon::Error; -QIcon icon::DirUp; -QIcon icon::Clock; -QIcon icon::Diamond; -QIcon icon::Plus; -QIcon icon::Minus; -QIcon icon::AddEffect; -QIcon icon::EyeOpened; -QIcon icon::EyeClosed; -QIcon icon::LockOpened; -QIcon icon::LockClosed; -QIcon icon::Pencil; -QIcon icon::Subtitles; -QIcon icon::ColorPicker; +QIcon icon::open; +QIcon icon::save; +QIcon icon::undo; +QIcon icon::redo; +QIcon icon::tree_view; +QIcon icon::list_view; +QIcon icon::icon_view; +QIcon icon::tool_pointer; +QIcon icon::tool_edit; +QIcon icon::tool_ripple; +QIcon icon::tool_rolling; +QIcon icon::tool_razor; +QIcon icon::tool_slip; +QIcon icon::tool_slide; +QIcon icon::tool_hand; +QIcon icon::tool_transition; +QIcon icon::tool_track_select; +QIcon icon::folder; +QIcon icon::sequence; +QIcon icon::video; +QIcon icon::audio; +QIcon icon::image; +QIcon icon::mini_map; +QIcon icon::tri_up; +QIcon icon::tri_left; +QIcon icon::tri_down; +QIcon icon::tri_right; +QIcon icon::text_bold; +QIcon icon::text_italic; +QIcon icon::text_underline; +QIcon icon::text_strikethrough; +QIcon icon::text_small_caps; +QIcon icon::text_align_left; +QIcon icon::text_align_right; +QIcon icon::text_align_center; +QIcon icon::text_align_justify; +QIcon icon::text_align_top; +QIcon icon::text_align_bottom; +QIcon icon::text_align_middle; +QIcon icon::snapping; +QIcon icon::zoom_in; +QIcon icon::zoom_out; +QIcon icon::record; +QIcon icon::add; +QIcon icon::error; +QIcon icon::dir_up; +QIcon icon::clock; +QIcon icon::diamond; +QIcon icon::plus; +QIcon icon::minus; +QIcon icon::add_effect; +QIcon icon::eye_opened; +QIcon icon::eye_closed; +QIcon icon::lock_opened; +QIcon icon::lock_closed; +QIcon icon::pencil; +QIcon icon::subtitles; +QIcon icon::color_picker; -void icon::LoadAll(const QString &theme) +void icon::load_all(const QString &theme) { - GoToStart = Create(theme, "prev"); - PrevFrame = Create(theme, "rew"); - Play = Create(theme, "play"); - Pause = Create(theme, "pause"); - NextFrame = Create(theme, "ff"); - GoToEnd = Create(theme, "next"); + go_to_start = create(theme, "prev"); + prev_frame = create(theme, "rew"); + play = create(theme, "play"); + pause = create(theme, "pause"); + next_frame = create(theme, "ff"); + go_to_end = create(theme, "next"); - New = Create(theme, "new"); - Open = Create(theme, "open"); - Save = Create(theme, "save"); - Undo = Create(theme, "undo"); - Redo = Create(theme, "redo"); - TreeView = Create(theme, "treeview"); - ListView = Create(theme, "listview"); - IconView = Create(theme, "iconview"); + New = create(theme, "new"); + open = create(theme, "open"); + save = create(theme, "save"); + undo = create(theme, "undo"); + redo = create(theme, "redo"); + tree_view = create(theme, "treeview"); + list_view = create(theme, "listview"); + icon_view = create(theme, "iconview"); - ToolPointer = Create(theme, "arrow"); - ToolEdit = Create(theme, "beam"); - ToolRipple = Create(theme, "ripple"); - ToolRolling = Create(theme, "rolling"); - ToolRazor = Create(theme, "razor"); - ToolSlip = Create(theme, "slip"); - ToolSlide = Create(theme, "slide"); - ToolHand = Create(theme, "hand"); - ToolTransition = Create(theme, "transition-tool"); - ToolTrackSelect = Create(theme, "track-tool"); + tool_pointer = create(theme, "arrow"); + tool_edit = create(theme, "beam"); + tool_ripple = create(theme, "ripple"); + tool_rolling = create(theme, "rolling"); + tool_razor = create(theme, "razor"); + tool_slip = create(theme, "slip"); + tool_slide = create(theme, "slide"); + tool_hand = create(theme, "hand"); + tool_transition = create(theme, "transition-tool"); + tool_track_select = create(theme, "track-tool"); - Folder = Create(theme, "folder"); - Sequence = Create(theme, "sequence"); - Video = Create(theme, "videosource"); - Audio = Create(theme, "audiosource"); - Image = Create(theme, "imagesource"); + folder = create(theme, "folder"); + sequence = create(theme, "sequence"); + video = create(theme, "videosource"); + audio = create(theme, "audiosource"); + image = create(theme, "imagesource"); - MiniMap = Create(theme, "map"); + mini_map = create(theme, "map"); - TriUp = Create(theme, "tri-up"); - TriLeft = Create(theme, "tri-left"); - TriDown = Create(theme, "tri-down"); - TriRight = Create(theme, "tri-right"); + tri_up = create(theme, "tri-up"); + tri_left = create(theme, "tri-left"); + tri_down = create(theme, "tri-down"); + tri_right = create(theme, "tri-right"); - TextBold = Create(theme, "text-bold"); - TextItalic = Create(theme, "text-italic"); - TextUnderline = Create(theme, "text-underline"); - TextStrikethrough = Create(theme, "text-strikethrough"); - TextSmallCaps = Create(theme, "text-small-caps"); - TextAlignLeft = Create(theme, "align-left"); - TextAlignRight = Create(theme, "align-right"); - TextAlignCenter = Create(theme, "align-center"); - TextAlignJustify = Create(theme, "align-justify-all"); - TextAlignTop = Create(theme, "align-v-top"); - TextAlignBottom = Create(theme, "align-v-bottom"); - TextAlignMiddle = Create(theme, "align-v-middle"); + text_bold = create(theme, "text-bold"); + text_italic = create(theme, "text-italic"); + text_underline = create(theme, "text-underline"); + text_strikethrough = create(theme, "text-strikethrough"); + text_small_caps = create(theme, "text-small-caps"); + text_align_left = create(theme, "align-left"); + text_align_right = create(theme, "align-right"); + text_align_center = create(theme, "align-center"); + text_align_justify = create(theme, "align-justify-all"); + text_align_top = create(theme, "align-v-top"); + text_align_bottom = create(theme, "align-v-bottom"); + text_align_middle = create(theme, "align-v-middle"); - Snapping = Create(theme, "magnet"); - ZoomIn = Create(theme, "zoomin"); - ZoomOut = Create(theme, "zoomout"); - Record = Create(theme, "record"); - Add = Create(theme, "add-button"); - Error = Create(theme, "error"); - DirUp = Create(theme, "dirup"); - Clock = Create(theme, "clock"); - Diamond = Create(theme, "diamond"); - Plus = Create(theme, "plus"); - Minus = Create(theme, "minus"); - AddEffect = Create(theme, "add-effect"); - ColorPicker = Create(theme, "color-picker"); + snapping = create(theme, "magnet"); + zoom_in = create(theme, "zoomin"); + zoom_out = create(theme, "zoomout"); + record = create(theme, "record"); + add = create(theme, "add-button"); + error = create(theme, "error"); + dir_up = create(theme, "dirup"); + clock = create(theme, "clock"); + diamond = create(theme, "diamond"); + plus = create(theme, "plus"); + minus = create(theme, "minus"); + add_effect = create(theme, "add-effect"); + color_picker = create(theme, "color-picker"); - EyeOpened = Create(theme, "eye-opened"); - EyeClosed = Create(theme, "eye-closed"); - LockOpened = Create(theme, "lock-opened"); - LockClosed = Create(theme, "lock-closed"); + eye_opened = create(theme, "eye-opened"); + eye_closed = create(theme, "eye-closed"); + lock_opened = create(theme, "lock-opened"); + lock_closed = create(theme, "lock-closed"); - Pencil = Create(theme, "text-edit"); - Subtitles = Create(theme, "subtitles"); + pencil = create(theme, "text-edit"); + subtitles = create(theme, "subtitles"); } -QIcon icon::Create(const QString &theme, const QString &name) +QIcon icon::create(const QString &theme, const QString &name) { QIcon icon; - for (int i = 0; i < ICON_SIZE_COUNT; i++) { + for (int i = 0; i < icon_size_count; i++) { icon.addFile(QStringLiteral("%1/png/%2.%3.png") - .arg(theme, name, QString::number(ICON_SIZES[i])), - QSize(ICON_SIZES[i], ICON_SIZES[i]), QIcon::Normal); + .arg(theme, name, QString::number(icon_sizes[i])), + QSize(icon_sizes[i], icon_sizes[i]), QIcon::Normal); icon.addFile(QStringLiteral("%1/png/%2.%3.disabled.png") - .arg(theme, name, QString::number(ICON_SIZES[i])), - QSize(ICON_SIZES[i], ICON_SIZES[i]), QIcon::Disabled); + .arg(theme, name, QString::number(icon_sizes[i])), + QSize(icon_sizes[i], icon_sizes[i]), QIcon::Disabled); } return icon; diff --git a/app/ui/icons/icons.h b/app/ui/icons/icons.h index 9bdfd485e..bc8581823 100644 --- a/app/ui/icons/icons.h +++ b/app/ui/icons/icons.h @@ -19,8 +19,8 @@ ***/ -#ifndef ICONS_H -#define ICONS_H +#ifndef OAK_ICONS_H +#define OAK_ICONS_H #include @@ -33,85 +33,85 @@ namespace icon { // Playback Icons -extern QIcon GoToStart; -extern QIcon PrevFrame; -extern QIcon Play; -extern QIcon Pause; -extern QIcon NextFrame; -extern QIcon GoToEnd; +extern QIcon go_to_start; +extern QIcon prev_frame; +extern QIcon play; +extern QIcon pause; +extern QIcon next_frame; +extern QIcon go_to_end; // Project Management Toolbar Icons extern QIcon New; -extern QIcon Open; -extern QIcon Save; -extern QIcon Undo; -extern QIcon Redo; -extern QIcon TreeView; -extern QIcon ListView; -extern QIcon IconView; +extern QIcon open; +extern QIcon save; +extern QIcon undo; +extern QIcon redo; +extern QIcon tree_view; +extern QIcon list_view; +extern QIcon icon_view; // Tool Icons -extern QIcon ToolPointer; -extern QIcon ToolEdit; -extern QIcon ToolRipple; -extern QIcon ToolRolling; -extern QIcon ToolRazor; -extern QIcon ToolSlip; -extern QIcon ToolSlide; -extern QIcon ToolHand; -extern QIcon ToolTransition; -extern QIcon ToolTrackSelect; +extern QIcon tool_pointer; +extern QIcon tool_edit; +extern QIcon tool_ripple; +extern QIcon tool_rolling; +extern QIcon tool_razor; +extern QIcon tool_slip; +extern QIcon tool_slide; +extern QIcon tool_hand; +extern QIcon tool_transition; +extern QIcon tool_track_select; // Project Icons -extern QIcon Folder; -extern QIcon Sequence; -extern QIcon Video; -extern QIcon Audio; -extern QIcon Image; +extern QIcon folder; +extern QIcon sequence; +extern QIcon video; +extern QIcon audio; +extern QIcon image; // Node Icons -extern QIcon MiniMap; +extern QIcon mini_map; // Triangle Arrows -extern QIcon TriUp; -extern QIcon TriLeft; -extern QIcon TriDown; -extern QIcon TriRight; +extern QIcon tri_up; +extern QIcon tri_left; +extern QIcon tri_down; +extern QIcon tri_right; // Text -extern QIcon TextBold; -extern QIcon TextItalic; -extern QIcon TextUnderline; -extern QIcon TextStrikethrough; -extern QIcon TextSmallCaps; -extern QIcon TextAlignLeft; -extern QIcon TextAlignRight; -extern QIcon TextAlignCenter; -extern QIcon TextAlignJustify; -extern QIcon TextAlignTop; -extern QIcon TextAlignBottom; -extern QIcon TextAlignMiddle; +extern QIcon text_bold; +extern QIcon text_italic; +extern QIcon text_underline; +extern QIcon text_strikethrough; +extern QIcon text_small_caps; +extern QIcon text_align_left; +extern QIcon text_align_right; +extern QIcon text_align_center; +extern QIcon text_align_justify; +extern QIcon text_align_top; +extern QIcon text_align_bottom; +extern QIcon text_align_middle; // Miscellaneous Icons -extern QIcon Snapping; -extern QIcon ZoomIn; -extern QIcon ZoomOut; -extern QIcon Record; -extern QIcon Add; -extern QIcon Error; -extern QIcon DirUp; -extern QIcon Clock; -extern QIcon Diamond; -extern QIcon Plus; -extern QIcon Minus; -extern QIcon AddEffect; -extern QIcon EyeOpened; -extern QIcon EyeClosed; -extern QIcon LockOpened; -extern QIcon LockClosed; -extern QIcon Pencil; -extern QIcon Subtitles; -extern QIcon ColorPicker; +extern QIcon snapping; +extern QIcon zoom_in; +extern QIcon zoom_out; +extern QIcon record; +extern QIcon add; +extern QIcon error; +extern QIcon dir_up; +extern QIcon clock; +extern QIcon diamond; +extern QIcon plus; +extern QIcon minus; +extern QIcon add_effect; +extern QIcon eye_opened; +extern QIcon eye_closed; +extern QIcon lock_opened; +extern QIcon lock_closed; +extern QIcon pencil; +extern QIcon subtitles; +extern QIcon color_picker; /** * @brief Create an icon object loaded from file @@ -142,7 +142,7 @@ extern QIcon ColorPicker; * * A QIcon object containing the various icon sizes loaded from resource */ -QIcon Create(const QString &theme, const QString &name); +QIcon create(const QString &theme, const QString &name); /** * @brief Methodically load all Olive icons into global variables that can be accessed throughout the application @@ -150,10 +150,10 @@ QIcon Create(const QString &theme, const QString &name); * It's recommended to load any UI icons here so they're ready at startup and don't need to be re-loaded upon each * use. */ -void LoadAll(const QString &theme); +void load_all(const QString &theme); } } -#endif // ICONS_H +#endif // OAK_ICONS_H diff --git a/app/ui/style/style.cpp b/app/ui/style/style.cpp index f57764fb8..6728d4c94 100644 --- a/app/ui/style/style.cpp +++ b/app/ui/style/style.cpp @@ -35,23 +35,23 @@ namespace olive { -QString StyleManager::current_style_; +QString StyleManager::current_style; QMap StyleManager::available_themes_; -QPalette StyleManager::ParsePalette(const QString &ini_path) +QPalette StyleManager::parse_palette(const QString &ini_path) { QSettings ini(ini_path, QSettings::IniFormat); QPalette palette; - ParsePaletteGroup(&ini, &palette, QPalette::All); - ParsePaletteGroup(&ini, &palette, QPalette::Active); - ParsePaletteGroup(&ini, &palette, QPalette::Inactive); - ParsePaletteGroup(&ini, &palette, QPalette::Disabled); + parse_palette_group(&ini, &palette, QPalette::All); + parse_palette_group(&ini, &palette, QPalette::Active); + parse_palette_group(&ini, &palette, QPalette::Inactive); + parse_palette_group(&ini, &palette, QPalette::Disabled); return palette; } -void StyleManager::ParsePaletteGroup(QSettings *ini, QPalette *palette, +void StyleManager::parse_palette_group(QSettings *ini, QPalette *palette, QPalette::ColorGroup group) { QString group_name; @@ -77,13 +77,13 @@ void StyleManager::ParsePaletteGroup(QSettings *ini, QPalette *palette, QStringList keys = ini->childKeys(); foreach (QString k, keys) { - ParsePaletteColor(ini, palette, group, k); + parse_palette_color(ini, palette, group, k); } ini->endGroup(); } -void StyleManager::ParsePaletteColor(QSettings *ini, QPalette *palette, +void StyleManager::parse_palette_color(QSettings *ini, QPalette *palette, QPalette::ColorGroup group, const QString &role_name) { @@ -137,7 +137,7 @@ void StyleManager::ParsePaletteColor(QSettings *ini, QPalette *palette, palette->setColor(group, role, QColor(ini->value(role_name).toString())); } -void StyleManager::Init() +void StyleManager::init() { qApp->setStyle(QStyleFactory::create("Fusion")); @@ -146,33 +146,33 @@ void StyleManager::Init() available_themes_.insert(QStringLiteral("olive-light"), QStringLiteral("Oak Light")); - QString config_style = OLIVE_CONFIG("Style").toString(); + QString config_style = OAK_CONFIG("Style").toString(); if (config_style.isEmpty() || !available_themes_.contains(config_style)) { - SetStyle(kDefaultStyle); + set_style(k_default_style); } else { - SetStyle(config_style); + set_style(config_style); } } -const QString &StyleManager::GetStyle() +const QString &StyleManager::get_style() { - return current_style_; + return current_style; } -void StyleManager::SetStyle(const QString &style_path) +void StyleManager::set_style(const QString &style_path) { - current_style_ = style_path; + current_style = style_path; QString abs_style_path = QStringLiteral(":/style/%1").arg(style_path); // Load all icons for this style (icons must be loaded first because the style change below triggers the icon change) - icon::LoadAll(abs_style_path); + icon::load_all(abs_style_path); // Set palette for this QString palette_file = QStringLiteral("%1/palette.ini").arg(abs_style_path); if (QFileInfo::exists(palette_file)) { - qApp->setPalette(ParsePalette(palette_file)); + qApp->setPalette(parse_palette(palette_file)); } else { qApp->setPalette(qApp->style()->standardPalette()); } diff --git a/app/ui/style/style.h b/app/ui/style/style.h index ebd776c79..745849b7a 100644 --- a/app/ui/style/style.h +++ b/app/ui/style/style.h @@ -19,8 +19,8 @@ ***/ -#ifndef STYLEMANAGER_H -#define STYLEMANAGER_H +#ifndef OAK_STYLEMANAGER_H +#define OAK_STYLEMANAGER_H #include #include @@ -32,13 +32,13 @@ namespace olive class StyleManager : public QObject { public: - static void Init(); + static void init(); - static const QString &GetStyle(); + static const QString &get_style(); - static void SetStyle(const QString &style_path); + static void set_style(const QString &style_path); - inline static const char *kDefaultStyle = "olive-dark"; + inline static const char *k_default_style = "olive-dark"; static const QMap &available_themes() { @@ -46,20 +46,20 @@ public: } private: - static QPalette ParsePalette(const QString &ini_path); + static QPalette parse_palette(const QString &ini_path); - static void ParsePaletteGroup(QSettings *ini, QPalette *palette, + static void parse_palette_group(QSettings *ini, QPalette *palette, QPalette::ColorGroup group); - static void ParsePaletteColor(QSettings *ini, QPalette *palette, + static void parse_palette_color(QSettings *ini, QPalette *palette, QPalette::ColorGroup group, const QString &role_name); - static QString current_style_; + static QString current_style; static QMap available_themes_; }; } -#endif // STYLEMANAGER_H +#endif // OAK_STYLEMANAGER_H diff --git a/app/undo/undocommand.cpp b/app/undo/undocommand.cpp index d5bacd660..0782d3385 100644 --- a/app/undo/undocommand.cpp +++ b/app/undo/undocommand.cpp @@ -48,7 +48,7 @@ UndoCommand::UndoCommand() void UndoCommand::redo_and_set_modified() { - project_ = GetRelevantProject(); + project_ = get_relevant_project(); redo_now(); diff --git a/app/undo/undocommand.h b/app/undo/undocommand.h index 66733f183..db85ebeb1 100644 --- a/app/undo/undocommand.h +++ b/app/undo/undocommand.h @@ -19,8 +19,8 @@ ***/ -#ifndef UNDOCOMMAND_H -#define UNDOCOMMAND_H +#ifndef OAK_UNDOCOMMAND_H +#define OAK_UNDOCOMMAND_H #include #include @@ -58,7 +58,7 @@ public: void redo_and_set_modified(); void undo_and_set_modified(); - virtual Project *GetRelevantProject() const = 0; + virtual Project *get_relevant_project() const = 0; protected: virtual void prepare() @@ -81,7 +81,7 @@ class MultiUndoCommand : public UndoCommand { public: MultiUndoCommand() = default; - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nullptr; } @@ -111,4 +111,4 @@ private: } -#endif // UNDOCOMMAND_H +#endif // OAK_UNDOCOMMAND_H diff --git a/app/undo/undostack.cpp b/app/undo/undostack.cpp index fc0c4374c..80744287b 100644 --- a/app/undo/undostack.cpp +++ b/app/undo/undostack.cpp @@ -26,7 +26,7 @@ namespace olive { -const int UndoStack::kMaxUndoCommands = 200; +const int UndoStack::k_max_undo_commands = 200; class EmptyCommand : public UndoCommand { public: @@ -34,7 +34,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nullptr; } @@ -57,7 +57,7 @@ UndoStack::UndoStack() connect(redo_action_, &QAction::triggered, this, &UndoStack::redo); clear(); - UpdateActions(); + update_actions(); } UndoStack::~UndoStack() @@ -79,7 +79,7 @@ void UndoStack::push(UndoCommand *command, const QString &name) // Clear any redoable commands this->beginRemoveRows(QModelIndex(), commands_.size(), commands_.size() + undone_commands_.size()); - if (CanRedo()) { + if (can_redo()) { for (auto it = undone_commands_.cbegin(); it != undone_commands_.cend(); it++) { delete (*it).command; @@ -95,14 +95,14 @@ void UndoStack::push(UndoCommand *command, const QString &name) this->endInsertRows(); // Delete oldest - if (commands_.size() > kMaxUndoCommands) { + if (commands_.size() > k_max_undo_commands) { this->beginRemoveRows(QModelIndex(), 0, 0); delete commands_.front().command; commands_.pop_front(); this->endRemoveRows(); } - UpdateActions(); + update_actions(); } void UndoStack::jump(size_t index) @@ -117,7 +117,7 @@ void UndoStack::jump(size_t index) void UndoStack::undo() { - if (CanUndo()) { + if (can_undo()) { // Undo most recently done command commands_.back().command->undo_and_set_modified(); @@ -128,13 +128,13 @@ void UndoStack::undo() commands_.pop_back(); // Update actions - UpdateActions(); + update_actions(); } } void UndoStack::redo() { - if (CanRedo()) { + if (can_redo()) { // Redo most recently undone command undone_commands_.front().command->redo_and_set_modified(); @@ -145,7 +145,7 @@ void UndoStack::redo() undone_commands_.pop_front(); // Update actions - UpdateActions(); + update_actions(); } } @@ -168,25 +168,25 @@ void UndoStack::clear() push(new EmptyCommand(), tr("New/Open Project")); } -bool UndoStack::CanUndo() const +bool UndoStack::can_undo() const { return !commands_.empty() && !dynamic_cast(commands_.back().command); } -void UndoStack::UpdateActions() +void UndoStack::update_actions() { - undo_action_->setEnabled(CanUndo()); - redo_action_->setEnabled(CanRedo()); + undo_action_->setEnabled(can_undo()); + redo_action_->setEnabled(can_redo()); undo_action_->setText( QCoreApplication::translate("UndoStack", "Undo %1") - .arg(CanUndo() ? commands_.back().name : QString())); + .arg(can_undo() ? commands_.back().name : QString())); redo_action_->setText( QCoreApplication::translate("UndoStack", "Redo %1") - .arg(CanRedo() ? undone_commands_.front().name : QString())); + .arg(can_redo() ? undone_commands_.front().name : QString())); - emit indexChanged(commands_.size()); + emit index_changed(commands_.size()); } int UndoStack::columnCount(const QModelIndex &parent) const diff --git a/app/undo/undostack.h b/app/undo/undostack.h index b51aaa4f1..8684989d9 100644 --- a/app/undo/undostack.h +++ b/app/undo/undostack.h @@ -19,8 +19,8 @@ ***/ -#ifndef UNDOSTACK_H -#define UNDOSTACK_H +#ifndef OAK_UNDOSTACK_H +#define OAK_UNDOSTACK_H #include #include @@ -44,14 +44,14 @@ public: void clear(); - bool CanUndo() const; + bool can_undo() const; - bool CanRedo() const + bool can_redo() const { return !undone_commands_.empty(); } - void UpdateActions(); + void update_actions(); QAction *GetUndoAction() { @@ -79,7 +79,7 @@ public: hasChildren(const QModelIndex &parent = QModelIndex()) const override; signals: - void indexChanged(int i); + void index_changed(int i); public slots: void undo(); @@ -87,7 +87,7 @@ public slots: void redo(); private: - static const int kMaxUndoCommands; + static const int k_max_undo_commands; struct CommandEntry { UndoCommand *command; @@ -105,4 +105,4 @@ private: } -#endif // UNDOSTACK_H +#endif // OAK_UNDOSTACK_H diff --git a/app/version.cpp b/app/version.cpp index e8b0626c8..82acaf39f 100644 --- a/app/version.cpp +++ b/app/version.cpp @@ -24,7 +24,7 @@ namespace olive { -QString kAppVersion = QStringLiteral(APPVERSION); -QString kAppVersionLong = QStringLiteral(APPVERSIONLONG); +QString k_app_version = QStringLiteral(APPVERSION); +QString k_app_version_long = QStringLiteral(APPVERSIONLONG); } diff --git a/app/version.h b/app/version.h index 176feec09..f83203f88 100644 --- a/app/version.h +++ b/app/version.h @@ -19,17 +19,17 @@ ***/ -#ifndef GITHASH_H -#define GITHASH_H +#ifndef OAK_GITHASH_H +#define OAK_GITHASH_H #include namespace olive { -extern QString kAppVersion; -extern QString kAppVersionLong; +extern QString k_app_version; +extern QString k_app_version_long; } -#endif // GITHASH_H +#endif // OAK_GITHASH_H diff --git a/app/widget/audiomonitor/audiomonitor.cpp b/app/widget/audiomonitor/audiomonitor.cpp index 8f01c060c..eb58d36d9 100644 --- a/app/widget/audiomonitor/audiomonitor.cpp +++ b/app/widget/audiomonitor/audiomonitor.cpp @@ -33,31 +33,31 @@ namespace olive { -const int kDecibelStep = 6; -const int kDecibelMinimum = +const int k_decibel_step = 6; +const int k_decibel_minimum = -198; // Must be divisible by kDecibelStep for infinity to appear -const int kMaximumSmoothness = 8; +const int k_maximum_smoothness = 8; -QVector AudioMonitor::instances_; +QVector AudioMonitor::instances; AudioMonitor::AudioMonitor(QWidget *parent) : QOpenGLWidget(parent) , waveform_(nullptr) , cached_channels_(0) { - instances_.append(this); + instances.append(this); - values_.resize(kMaximumSmoothness); + values_.resize(k_maximum_smoothness); this->setMinimumWidth(this->fontMetrics().height()); } AudioMonitor::~AudioMonitor() { - instances_.removeOne(this); + instances.removeOne(this); } -void AudioMonitor::SetParams(const AudioParams ¶ms) +void AudioMonitor::set_params(const AudioParams ¶ms) { if (params_ != params) { params_ = params; @@ -74,7 +74,7 @@ void AudioMonitor::SetParams(const AudioParams ¶ms) } } -void AudioMonitor::Stop() +void AudioMonitor::stop() { waveform_ = nullptr; @@ -82,7 +82,7 @@ void AudioMonitor::Stop() // loop will stop itself since file_ and waveform_ are null. } -void AudioMonitor::PushSampleBuffer(const SampleBuffer &d) +void AudioMonitor::push_sample_buffer(const SampleBuffer &d) { if (!params_.channel_count()) { return; @@ -91,7 +91,7 @@ void AudioMonitor::PushSampleBuffer(const SampleBuffer &d) QVector v(params_.channel_count(), 0); const AudioLevelMeter::Stats stats = - AudioLevelMeter::AnalyzeSampleBuffer(d); + AudioLevelMeter::analyze_sample_buffer(d); for (int i = 0; i < v.size() && i < stats.channels.size(); i++) { v[i] = stats.channels.at(i).peak_linear; } @@ -99,13 +99,13 @@ void AudioMonitor::PushSampleBuffer(const SampleBuffer &d) // Fill values because they get averaged out for smoothing values_.fill(v); - SetUpdateLoop(true); + set_update_loop(true); } -void AudioMonitor::StartWaveform(const AudioWaveformCache *waveform, - const rational &start, int playback_speed) +void AudioMonitor::start_waveform(const AudioWaveformCache *waveform, + const Rational &start, int playback_speed) { - Stop(); + stop(); waveform_length_ = waveform->length(); if (start >= waveform_length_) { @@ -119,10 +119,10 @@ void AudioMonitor::StartWaveform(const AudioWaveformCache *waveform, last_time_ = QDateTime::currentMSecsSinceEpoch(); - SetUpdateLoop(true); + set_update_loop(true); } -void AudioMonitor::SetUpdateLoop(bool e) +void AudioMonitor::set_update_loop(bool e) { if (e) { connect(this, &AudioMonitor::frameSwapped, this, @@ -171,7 +171,7 @@ void AudioMonitor::paintGL() int peaks_pos; int channel_size; int db_line_length = fm.horizontalAdvance(QStringLiteral("-")); - int db_width = QtUtils::QFontMetricsWidth(p.fontMetrics(), "-00 "); + int db_width = QtUtils::q_font_metrics_width(p.fontMetrics(), "-00 "); if (horizontal) { // Insert peaks area full_meter_rect.adjust(0, 0, -font_height, 0); @@ -236,16 +236,16 @@ void AudioMonitor::paintGL() cached_painter.setPen(palette.text().color()); - for (int i = 0; i >= kDecibelMinimum; i -= kDecibelStep) { + for (int i = 0; i >= k_decibel_minimum; i -= k_decibel_step) { QString db_label; qreal log_val; - if (i == kDecibelMinimum) { + if (i == k_decibel_minimum) { db_label = QStringLiteral("-∞ "); log_val = 0; } else { db_label = QStringLiteral("%1 ").arg(i); - log_val = Decibel::toLogarithmic(i); + log_val = Decibel::to_logarithmic(i); } QLine db_line; @@ -278,7 +278,7 @@ void AudioMonitor::paintGL() db_labels_rect.bottom() - font_height; } - if (overlaps_infinity && i == kDecibelMinimum) { + if (overlaps_infinity && i == k_decibel_minimum) { overlaps_infinity = false; } @@ -351,7 +351,7 @@ void AudioMonitor::paintGL() QVector v(params_.channel_count(), 0); - if (IsPlaying()) { + if (is_playing()) { // Determines how many milliseconds have passed since last update qint64 current_time = QDateTime::currentMSecsSinceEpoch(); qint64 delta_time = current_time - last_time_; @@ -363,19 +363,19 @@ void AudioMonitor::paintGL() } if (waveform_) { - UpdateValuesFromWaveform(v, delta_time); + update_values_from_waveform(v, delta_time); if (waveform_time_ >= waveform_length_) { - Stop(); + stop(); } } last_time_ = current_time; } - PushValue(v); + push_value(v); - QVector vals = GetAverages(); + QVector vals = get_averages(); p.setBrush(QColor(0, 0, 0, 128)); p.setPen(Qt::NoPen); @@ -394,7 +394,7 @@ void AudioMonitor::paintGL() } // Convert val to logarithmic scale - vol = Decibel::LinearToLogarithmic(vol); + vol = Decibel::linear_to_logarithmic(vol); QRect peaks_rect, meter_rect; @@ -424,9 +424,9 @@ void AudioMonitor::paintGL() } } - if (all_zeroes && !IsPlaying()) { + if (all_zeroes && !is_playing()) { // Optimize by disabling the update loop - SetUpdateLoop(false); + set_update_loop(false); } } @@ -436,21 +436,21 @@ void AudioMonitor::mousePressEvent(QMouseEvent *) update(); } -void AudioMonitor::UpdateValuesFromWaveform(QVector &v, +void AudioMonitor::update_values_from_waveform(QVector &v, qint64 delta_time) { - // Delta time is provided in milliseconds, so we convert to seconds in rational - rational length(delta_time, 1000); + // Delta time is provided in milliseconds, so we convert to seconds in Rational + Rational length(delta_time, 1000); AudioVisualWaveform::Sample sum = - waveform_->GetSummaryFromTime(waveform_time_, length); + waveform_->get_summary_from_time(waveform_time_, length); - AudioVisualWaveformSampleToInternalValues(sum, v); + audio_visual_waveform_sample_to_internal_values(sum, v); waveform_time_ += length; } -void AudioMonitor::AudioVisualWaveformSampleToInternalValues( +void AudioMonitor::audio_visual_waveform_sample_to_internal_values( const AudioVisualWaveform::Sample &in, QVector &out) { for (size_t i = 0; i < in.size(); i++) { @@ -463,7 +463,7 @@ void AudioMonitor::AudioVisualWaveformSampleToInternalValues( } } -void AudioMonitor::PushValue(const QVector &v) +void AudioMonitor::push_value(const QVector &v) { int lim = values_.size() - 1; for (int i = 0; i < lim; i++) { @@ -472,7 +472,7 @@ void AudioMonitor::PushValue(const QVector &v) values_[lim] = v; } -void AudioMonitor::BytesToSampleSummary(const QByteArray &b, QVector &v) +void AudioMonitor::bytes_to_sample_summary(const QByteArray &b, QVector &v) { const float *samples = reinterpret_cast(b.constData()); int nb_samples = b.size() / sizeof(float); @@ -488,7 +488,7 @@ void AudioMonitor::BytesToSampleSummary(const QByteArray &b, QVector &v) } } -QVector AudioMonitor::GetAverages() const +QVector AudioMonitor::get_averages() const { QVector v(params_.channel_count(), 0); diff --git a/app/widget/audiomonitor/audiomonitor.h b/app/widget/audiomonitor/audiomonitor.h index c1888ab08..c51e9ae56 100644 --- a/app/widget/audiomonitor/audiomonitor.h +++ b/app/widget/audiomonitor/audiomonitor.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUDIOMONITORWIDGET_H -#define AUDIOMONITORWIDGET_H +#ifndef OAK_AUDIOMONITORWIDGET_H +#define OAK_AUDIOMONITORWIDGET_H #include #include @@ -40,42 +40,42 @@ public: virtual ~AudioMonitor() override; - bool IsPlaying() const + bool is_playing() const { return waveform_; } - static void StartWaveformOnAll(const AudioWaveformCache *waveform, - const rational &start, int playback_speed) + static void start_waveform_on_all(const AudioWaveformCache *waveform, + const Rational &start, int playback_speed) { - foreach (AudioMonitor *m, instances_) { - m->StartWaveform(waveform, start, playback_speed); + foreach (AudioMonitor *m, instances) { + m->start_waveform(waveform, start, playback_speed); } } - static void StopOnAll() + static void stop_on_all() { - foreach (AudioMonitor *m, instances_) { - m->Stop(); + foreach (AudioMonitor *m, instances) { + m->stop(); } } - static void PushSampleBufferOnAll(const SampleBuffer &d) + static void push_sample_buffer_on_all(const SampleBuffer &d) { - foreach (AudioMonitor *m, instances_) { - m->PushSampleBuffer(d); + foreach (AudioMonitor *m, instances) { + m->push_sample_buffer(d); } } public slots: - void SetParams(const AudioParams ¶ms); + void set_params(const AudioParams ¶ms); - void Stop(); + void stop(); - void PushSampleBuffer(const SampleBuffer &samples); + void push_sample_buffer(const SampleBuffer &samples); - void StartWaveform(const AudioWaveformCache *waveform, - const rational &start, int playback_speed); + void start_waveform(const AudioWaveformCache *waveform, + const Rational &start, int playback_speed); protected: virtual void paintGL() override; @@ -83,26 +83,26 @@ protected: virtual void mousePressEvent(QMouseEvent *event) override; private: - void SetUpdateLoop(bool e); + void set_update_loop(bool e); - void UpdateValuesFromWaveform(QVector &v, qint64 delta_time); + void update_values_from_waveform(QVector &v, qint64 delta_time); - void AudioVisualWaveformSampleToInternalValues( + void audio_visual_waveform_sample_to_internal_values( const AudioVisualWaveform::Sample &in, QVector &out); - void PushValue(const QVector &v); + void push_value(const QVector &v); - void BytesToSampleSummary(const QByteArray &bytes, QVector &v); + void bytes_to_sample_summary(const QByteArray &bytes, QVector &v); - QVector GetAverages() const; + QVector get_averages() const; AudioParams params_; qint64 last_time_; const AudioWaveformCache *waveform_; - rational waveform_time_; - rational waveform_length_; + Rational waveform_time_; + Rational waveform_length_; int playback_speed_; @@ -112,9 +112,9 @@ private: QPixmap cached_background_; int cached_channels_; - static QVector instances_; + static QVector instances; }; } -#endif // AUDIOMONITORWIDGET_H +#endif // OAK_AUDIOMONITORWIDGET_H diff --git a/app/widget/bezier/bezierwidget.cpp b/app/widget/bezier/bezierwidget.cpp index 8a4ef0b8d..ba50d02b0 100644 --- a/app/widget/bezier/bezierwidget.cpp +++ b/app/widget/bezier/bezierwidget.cpp @@ -37,13 +37,13 @@ BezierWidget::BezierWidget(QWidget *parent) layout->addWidget(new QLabel(tr("Center:")), row, 0); x_slider_ = new FloatSlider(); - connect(x_slider_, &FloatSlider::ValueChanged, this, - &BezierWidget::ValueChanged); + connect(x_slider_, &FloatSlider::value_changed, this, + &BezierWidget::value_changed); layout->addWidget(x_slider_, row, 1); y_slider_ = new FloatSlider(); - connect(y_slider_, &FloatSlider::ValueChanged, this, - &BezierWidget::ValueChanged); + connect(y_slider_, &FloatSlider::value_changed, this, + &BezierWidget::value_changed); layout->addWidget(y_slider_, row, 2); row++; @@ -58,13 +58,13 @@ BezierWidget::BezierWidget(QWidget *parent) bezier_layout->addWidget(new QLabel(tr("In:")), row, 0); cp1_x_slider_ = new FloatSlider(); - connect(cp1_x_slider_, &FloatSlider::ValueChanged, this, - &BezierWidget::ValueChanged); + connect(cp1_x_slider_, &FloatSlider::value_changed, this, + &BezierWidget::value_changed); bezier_layout->addWidget(cp1_x_slider_, row, 1); cp1_y_slider_ = new FloatSlider(); - connect(cp1_y_slider_, &FloatSlider::ValueChanged, this, - &BezierWidget::ValueChanged); + connect(cp1_y_slider_, &FloatSlider::value_changed, this, + &BezierWidget::value_changed); bezier_layout->addWidget(cp1_y_slider_, row, 2); row++; @@ -72,38 +72,38 @@ BezierWidget::BezierWidget(QWidget *parent) bezier_layout->addWidget(new QLabel(tr("Out:")), row, 0); cp2_x_slider_ = new FloatSlider(); - connect(cp2_x_slider_, &FloatSlider::ValueChanged, this, - &BezierWidget::ValueChanged); + connect(cp2_x_slider_, &FloatSlider::value_changed, this, + &BezierWidget::value_changed); bezier_layout->addWidget(cp2_x_slider_, row, 1); cp2_y_slider_ = new FloatSlider(); - connect(cp2_y_slider_, &FloatSlider::ValueChanged, this, - &BezierWidget::ValueChanged); + connect(cp2_y_slider_, &FloatSlider::value_changed, this, + &BezierWidget::value_changed); bezier_layout->addWidget(cp2_y_slider_, row, 2); } -Bezier BezierWidget::GetValue() const +Bezier BezierWidget::get_value() const { Bezier b; - b.set_x(x_slider_->GetValue()); - b.set_y(y_slider_->GetValue()); - b.set_cp1_x(cp1_x_slider_->GetValue()); - b.set_cp1_y(cp1_y_slider_->GetValue()); - b.set_cp2_x(cp2_x_slider_->GetValue()); - b.set_cp2_y(cp2_y_slider_->GetValue()); + b.set_x(x_slider_->get_value()); + b.set_y(y_slider_->get_value()); + b.set_cp1_x(cp1_x_slider_->get_value()); + b.set_cp1_y(cp1_y_slider_->get_value()); + b.set_cp2_x(cp2_x_slider_->get_value()); + b.set_cp2_y(cp2_y_slider_->get_value()); return b; } -void BezierWidget::SetValue(const Bezier &b) +void BezierWidget::set_value(const Bezier &b) { - x_slider_->SetValue(b.x()); - y_slider_->SetValue(b.y()); - cp1_x_slider_->SetValue(b.cp1_x()); - cp1_y_slider_->SetValue(b.cp1_y()); - cp2_x_slider_->SetValue(b.cp2_x()); - cp2_y_slider_->SetValue(b.cp2_y()); + x_slider_->set_value(b.x()); + y_slider_->set_value(b.y()); + cp1_x_slider_->set_value(b.cp1_x()); + cp1_y_slider_->set_value(b.cp1_y()); + cp2_x_slider_->set_value(b.cp2_x()); + cp2_y_slider_->set_value(b.cp2_y()); } } diff --git a/app/widget/bezier/bezierwidget.h b/app/widget/bezier/bezierwidget.h index 1a13da1f5..8314f10c9 100644 --- a/app/widget/bezier/bezierwidget.h +++ b/app/widget/bezier/bezierwidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef BEZIERWIDGET_H -#define BEZIERWIDGET_H +#ifndef OAK_BEZIERWIDGET_H +#define OAK_BEZIERWIDGET_H #include #include @@ -38,9 +38,9 @@ class BezierWidget : public QWidget { public: explicit BezierWidget(QWidget *parent = nullptr); - Bezier GetValue() const; + Bezier get_value() const; - void SetValue(const Bezier &b); + void set_value(const Bezier &b); FloatSlider *x_slider() const { @@ -73,7 +73,7 @@ public: } signals: - void ValueChanged(); + void value_changed(); private: FloatSlider *x_slider_; @@ -91,4 +91,4 @@ private: } -#endif // BEZIERWIDGET_H +#endif // OAK_BEZIERWIDGET_H diff --git a/app/widget/clickablelabel/clickablelabel.cpp b/app/widget/clickablelabel/clickablelabel.cpp index c97880f63..80bd9e713 100644 --- a/app/widget/clickablelabel/clickablelabel.cpp +++ b/app/widget/clickablelabel/clickablelabel.cpp @@ -39,14 +39,14 @@ ClickableLabel::ClickableLabel(QWidget *parent) void ClickableLabel::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton && underMouse()) { - emit MouseClicked(); + emit mouse_clicked(); } } void ClickableLabel::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit MouseDoubleClicked(); + emit mouse_double_clicked(); } } diff --git a/app/widget/clickablelabel/clickablelabel.h b/app/widget/clickablelabel/clickablelabel.h index 3c54bc938..87e0d41bd 100644 --- a/app/widget/clickablelabel/clickablelabel.h +++ b/app/widget/clickablelabel/clickablelabel.h @@ -19,8 +19,8 @@ ***/ -#ifndef CLICKABLELABEL_H -#define CLICKABLELABEL_H +#ifndef OAK_CLICKABLELABEL_H +#define OAK_CLICKABLELABEL_H #include @@ -40,10 +40,10 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent *event) override; signals: - void MouseClicked(); - void MouseDoubleClicked(); + void mouse_clicked(); + void mouse_double_clicked(); }; } -#endif // CLICKABLELABEL_H +#endif // OAK_CLICKABLELABEL_H diff --git a/app/widget/collapsebutton/collapsebutton.cpp b/app/widget/collapsebutton/collapsebutton.cpp index 4e39f58eb..84500611a 100644 --- a/app/widget/collapsebutton/collapsebutton.cpp +++ b/app/widget/collapsebutton/collapsebutton.cpp @@ -35,17 +35,17 @@ CollapseButton::CollapseButton(QWidget *parent) setChecked(true); setIconSize(QSize(fontMetrics().height() / 2, fontMetrics().height() / 2)); - connect(this, &CollapseButton::toggled, this, &CollapseButton::UpdateIcon); + connect(this, &CollapseButton::toggled, this, &CollapseButton::update_icon); - UpdateIcon(isChecked()); + update_icon(isChecked()); } -void CollapseButton::UpdateIcon(bool e) +void CollapseButton::update_icon(bool e) { if (e) { - setIcon(icon::TriDown); + setIcon(icon::tri_down); } else { - setIcon(icon::TriRight); + setIcon(icon::tri_right); } } diff --git a/app/widget/collapsebutton/collapsebutton.h b/app/widget/collapsebutton/collapsebutton.h index 62e052184..7959a4fd6 100644 --- a/app/widget/collapsebutton/collapsebutton.h +++ b/app/widget/collapsebutton/collapsebutton.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLLAPSEBUTTON_H -#define COLLAPSEBUTTON_H +#ifndef OAK_COLLAPSEBUTTON_H +#define OAK_COLLAPSEBUTTON_H #include @@ -35,9 +35,9 @@ public: CollapseButton(QWidget *parent = nullptr); private slots: - void UpdateIcon(bool e); + void update_icon(bool e); }; } -#endif // COLLAPSEBUTTON_H +#endif // OAK_COLLAPSEBUTTON_H diff --git a/app/widget/colorbutton/colorbutton.cpp b/app/widget/colorbutton/colorbutton.cpp index 9e86c9aef..bbac6e2d4 100644 --- a/app/widget/colorbutton/colorbutton.cpp +++ b/app/widget/colorbutton/colorbutton.cpp @@ -37,52 +37,52 @@ ColorButton::ColorButton(ColorManager *color_manager, bool show_dialog_on_click, if (show_dialog_on_click) { connect(this, &ColorButton::clicked, this, - &ColorButton::ShowColorDialog); + &ColorButton::show_color_dialog); } - SetColor(Color(1.0f, 1.0f, 1.0f)); + set_color(Color(1.0f, 1.0f, 1.0f)); } -const ManagedColor &ColorButton::GetColor() const +const ManagedColor &ColorButton::get_color() const { return color_; } -void ColorButton::SetColor(const ManagedColor &c) +void ColorButton::set_color(const ManagedColor &c) { color_ = c; color_.set_color_input( - color_manager_->GetCompliantColorSpace(color_.color_input())); + color_manager_->get_compliant_color_space(color_.color_input())); color_.set_color_output( - color_manager_->GetCompliantColorSpace(color_.color_output())); + color_manager_->get_compliant_color_space(color_.color_output())); - UpdateColor(); + update_color(); } -void ColorButton::ShowColorDialog() +void ColorButton::show_color_dialog() { if (!dialog_open_) { dialog_open_ = true; ColorDialog *cd = new ColorDialog(color_manager_, color_, this); connect(cd, &ColorDialog::finished, this, - &ColorButton::ColorDialogFinished); + &ColorButton::color_dialog_finished); cd->show(); } } -void ColorButton::ColorDialogFinished(int e) +void ColorButton::color_dialog_finished(int e) { ColorDialog *cd = static_cast(sender()); if (e == QDialog::Accepted) { - color_ = cd->GetSelectedColor(); + color_ = cd->get_selected_color(); - UpdateColor(); + update_color(); - emit ColorChanged(color_); + emit color_changed(color_); } cd->deleteLater(); @@ -90,12 +90,12 @@ void ColorButton::ColorDialogFinished(int e) dialog_open_ = false; } -void ColorButton::UpdateColor() +void ColorButton::update_color() { - color_processor_ = ColorProcessor::Create( + color_processor_ = ColorProcessor::create( color_manager_, color_.color_input(), color_.color_output()); - QColor managed = QtUtils::toQColor(color_processor_->ConvertColor(color_)); + QColor managed = QtUtils::to_q_color(color_processor_->convert_color(color_)); setStyleSheet(QStringLiteral("%1--ColorButton {background: %2;}") .arg(MACRO_VAL_AS_STR(olive), managed.name())); diff --git a/app/widget/colorbutton/colorbutton.h b/app/widget/colorbutton/colorbutton.h index 4ce4aa385..34e0df117 100644 --- a/app/widget/colorbutton/colorbutton.h +++ b/app/widget/colorbutton/colorbutton.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORBUTTON_H -#define COLORBUTTON_H +#ifndef OAK_COLORBUTTON_H +#define OAK_COLORBUTTON_H #include @@ -40,21 +40,21 @@ public: { } - const ManagedColor &GetColor() const; + const ManagedColor &get_color() const; public slots: - void SetColor(const ManagedColor &c); + void set_color(const ManagedColor &c); signals: - void ColorChanged(const ManagedColor &c); + void color_changed(const ManagedColor &c); private slots: - void ShowColorDialog(); + void show_color_dialog(); - void ColorDialogFinished(int e); + void color_dialog_finished(int e); private: - void UpdateColor(); + void update_color(); ColorManager *color_manager_; @@ -67,4 +67,4 @@ private: } -#endif // COLORBUTTON_H +#endif // OAK_COLORBUTTON_H diff --git a/app/widget/colorlabelmenu/colorcodingcombobox.cpp b/app/widget/colorlabelmenu/colorcodingcombobox.cpp index f5ef88af9..ced256d2a 100644 --- a/app/widget/colorlabelmenu/colorcodingcombobox.cpp +++ b/app/widget/colorlabelmenu/colorcodingcombobox.cpp @@ -29,7 +29,7 @@ namespace olive ColorCodingComboBox::ColorCodingComboBox(QWidget *parent) : QComboBox(parent) { - SetColor(0); + set_color(0); } void ColorCodingComboBox::showPopup() @@ -41,14 +41,14 @@ void ColorCodingComboBox::showPopup() QAction *a = menu.exec(parentWidget()->mapToGlobal(pos())); if (a) { - SetColor(a->data().toInt()); + set_color(a->data().toInt()); } } -void ColorCodingComboBox::SetColor(int index) +void ColorCodingComboBox::set_color(int index) { clear(); - addItem(ColorCoding::GetColorName(index)); + addItem(ColorCoding::get_color_name(index)); index_ = index; } diff --git a/app/widget/colorlabelmenu/colorcodingcombobox.h b/app/widget/colorlabelmenu/colorcodingcombobox.h index 7fad58698..2de848563 100644 --- a/app/widget/colorlabelmenu/colorcodingcombobox.h +++ b/app/widget/colorlabelmenu/colorcodingcombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORCODINGCOMBOBOX_H -#define COLORCODINGCOMBOBOX_H +#ifndef OAK_COLORCODINGCOMBOBOX_H +#define OAK_COLORCODINGCOMBOBOX_H #include @@ -36,9 +36,9 @@ public: virtual void showPopup() override; - void SetColor(int index); + void set_color(int index); - int GetSelectedColor() const + int get_selected_color() const { return index_; } @@ -49,4 +49,4 @@ private: } -#endif // COLORCODINGCOMBOBOX_H +#endif // OAK_COLORCODINGCOMBOBOX_H diff --git a/app/widget/colorlabelmenu/colorlabelmenu.cpp b/app/widget/colorlabelmenu/colorlabelmenu.cpp index 2034b3188..26a190e16 100644 --- a/app/widget/colorlabelmenu/colorlabelmenu.cpp +++ b/app/widget/colorlabelmenu/colorlabelmenu.cpp @@ -44,41 +44,41 @@ ColorLabelMenu::ColorLabelMenu(QWidget *parent) QPainter painter(&p); painter.setPen(Qt::black); painter.setBrush( - QtUtils::toQColor(ColorCoding::standard_colors().at(i))); + QtUtils::to_q_color(ColorCoding::standard_colors().at(i))); painter.drawRect(p.rect().adjusted(0, 0, -1, -1)); - QAction *a = AddItem(QStringLiteral("colorlabel%1").arg(i), this, - &ColorLabelMenu::ActionTriggered); + QAction *a = add_item(QStringLiteral("colorlabel%1").arg(i), this, + &ColorLabelMenu::action_triggered); a->setIcon(p); a->setData(i); color_items_.replace(i, a); } - Retranslate(); + retranslate(); } void ColorLabelMenu::changeEvent(QEvent *event) { if (event->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } Menu::changeEvent(event); } -void ColorLabelMenu::Retranslate() +void ColorLabelMenu::retranslate() { this->setTitle(tr("Color")); for (int i = 0; i < color_items_.size(); i++) { - color_items_.at(i)->setText(ColorCoding::GetColorName(i)); + color_items_.at(i)->setText(ColorCoding::get_color_name(i)); } } -void ColorLabelMenu::ActionTriggered() +void ColorLabelMenu::action_triggered() { QAction *a = static_cast(sender()); - emit ColorSelected(a->data().toInt()); + emit color_selected(a->data().toInt()); } } diff --git a/app/widget/colorlabelmenu/colorlabelmenu.h b/app/widget/colorlabelmenu/colorlabelmenu.h index 328e9dc7a..df83aefbe 100644 --- a/app/widget/colorlabelmenu/colorlabelmenu.h +++ b/app/widget/colorlabelmenu/colorlabelmenu.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORLABELMENU_H -#define COLORLABELMENU_H +#ifndef OAK_COLORLABELMENU_H +#define OAK_COLORLABELMENU_H #include "widget/menu/menu.h" @@ -35,17 +35,17 @@ public: virtual void changeEvent(QEvent *event) override; signals: - void ColorSelected(int i); + void color_selected(int i); private: - void Retranslate(); + void retranslate(); QVector color_items_; private slots: - void ActionTriggered(); + void action_triggered(); }; } -#endif // COLORLABELMENU_H +#endif // OAK_COLORLABELMENU_H diff --git a/app/widget/colorwheel/colorgradientwidget.cpp b/app/widget/colorwheel/colorgradientwidget.cpp index 34cdf0aae..f8ac0dc14 100644 --- a/app/widget/colorwheel/colorgradientwidget.cpp +++ b/app/widget/colorwheel/colorgradientwidget.cpp @@ -37,12 +37,12 @@ ColorGradientWidget::ColorGradientWidget(Qt::Orientation orientation, { } -Color ColorGradientWidget::GetColorFromScreenPos(const QPoint &p) const +Color ColorGradientWidget::get_color_from_screen_pos(const QPoint &p) const { if (orientation_ == Qt::Horizontal) { - return LerpColor(start_, end_, p.x(), width()); + return lerp_color(start_, end_, p.x(), width()); } else { - return LerpColor(start_, end_, p.y(), height()); + return lerp_color(start_, end_, p.y(), height()); } } @@ -64,8 +64,8 @@ void ColorGradientWidget::paintEvent(QPaintEvent *e) } for (int i = 0; i < max; i++) { - p.setPen(QtUtils::toQColor( - GetManagedColor(LerpColor(start_, end_, i, max)))); + p.setPen(QtUtils::to_q_color( + get_managed_color(lerp_color(start_, end_, i, max)))); if (orientation_ == Qt::Horizontal) { p.drawLine(i, 0, i, height()); @@ -76,7 +76,7 @@ void ColorGradientWidget::paintEvent(QPaintEvent *e) // Draw selector int selector_radius = qMax(2, min / 8); - p.setPen(QPen(GetUISelectorColor(), qMax(1, selector_radius / 2))); + p.setPen(QPen(get_ui_selector_color(), qMax(1, selector_radius / 2))); p.setBrush(Qt::NoBrush); float clamped_val = std::clamp(val_, 0.0f, 1.0f); @@ -95,15 +95,15 @@ void ColorGradientWidget::SelectedColorChangedEvent(const Color &c, { float hue, sat; - c.toHsv(&hue, &sat, &val_); + c.to_hsv(&hue, &sat, &val_); if (external) { - start_ = Color::fromHsv(hue, sat, 1.0); - end_ = Color::fromHsv(hue, sat, 0.0); + start_ = Color::from_hsv(hue, sat, 1.0); + end_ = Color::from_hsv(hue, sat, 0.0); } } -Color ColorGradientWidget::LerpColor(const Color &a, const Color &b, int i, +Color ColorGradientWidget::lerp_color(const Color &a, const Color &b, int i, int max) { float t = diff --git a/app/widget/colorwheel/colorgradientwidget.h b/app/widget/colorwheel/colorgradientwidget.h index c1ff1dd63..e25ac4726 100644 --- a/app/widget/colorwheel/colorgradientwidget.h +++ b/app/widget/colorwheel/colorgradientwidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORGRADIENTGLWIDGET_H -#define COLORGRADIENTGLWIDGET_H +#ifndef OAK_COLORGRADIENTGLWIDGET_H +#define OAK_COLORGRADIENTGLWIDGET_H #include "colorswatchwidget.h" @@ -33,7 +33,7 @@ public: ColorGradientWidget(Qt::Orientation orientation, QWidget *parent = nullptr); protected: - virtual Color GetColorFromScreenPos(const QPoint &p) const override; + virtual Color get_color_from_screen_pos(const QPoint &p) const override; virtual void paintEvent(QPaintEvent *e) override; @@ -41,7 +41,7 @@ protected: bool external) override; private: - static Color LerpColor(const Color &a, const Color &b, int i, int max); + static Color lerp_color(const Color &a, const Color &b, int i, int max); QPixmap cached_gradient_; @@ -56,4 +56,4 @@ private: } -#endif // COLORGRADIENTGLWIDGET_H +#endif // OAK_COLORGRADIENTGLWIDGET_H diff --git a/app/widget/colorwheel/colorpreviewbox.cpp b/app/widget/colorwheel/colorpreviewbox.cpp index fbf5e3a00..c4459b701 100644 --- a/app/widget/colorwheel/colorpreviewbox.cpp +++ b/app/widget/colorwheel/colorpreviewbox.cpp @@ -35,7 +35,7 @@ ColorPreviewBox::ColorPreviewBox(QWidget *parent) { } -void ColorPreviewBox::SetColorProcessor(ColorProcessorPtr to_ref, +void ColorPreviewBox::set_color_processor(ColorProcessorPtr to_ref, ColorProcessorPtr to_display) { to_ref_processor_ = to_ref; @@ -44,7 +44,7 @@ void ColorPreviewBox::SetColorProcessor(ColorProcessorPtr to_ref, update(); } -void ColorPreviewBox::SetColor(const Color &c) +void ColorPreviewBox::set_color(const Color &c) { color_ = c; update(); @@ -58,10 +58,10 @@ void ColorPreviewBox::paintEvent(QPaintEvent *e) // Color management if (to_ref_processor_ && to_display_processor_) { - c = QtUtils::toQColor(to_display_processor_->ConvertColor( - to_ref_processor_->ConvertColor(color_))); + c = QtUtils::to_q_color(to_display_processor_->convert_color( + to_ref_processor_->convert_color(color_))); } else { - c = QtUtils::toQColor(color_); + c = QtUtils::to_q_color(color_); } QPainter p(this); diff --git a/app/widget/colorwheel/colorpreviewbox.h b/app/widget/colorwheel/colorpreviewbox.h index ce57d12d3..89c3c5ed4 100644 --- a/app/widget/colorwheel/colorpreviewbox.h +++ b/app/widget/colorwheel/colorpreviewbox.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORPREVIEWBOX_H -#define COLORPREVIEWBOX_H +#ifndef OAK_COLORPREVIEWBOX_H +#define OAK_COLORPREVIEWBOX_H #include @@ -34,11 +34,11 @@ class ColorPreviewBox : public QWidget { public: ColorPreviewBox(QWidget *parent = nullptr); - void SetColorProcessor(ColorProcessorPtr to_ref, + void set_color_processor(ColorProcessorPtr to_ref, ColorProcessorPtr to_display); public slots: - void SetColor(const Color &c); + void set_color(const Color &c); protected: virtual void paintEvent(QPaintEvent *e) override; @@ -53,4 +53,4 @@ private: } -#endif // COLORPREVIEWBOX_H +#endif // OAK_COLORPREVIEWBOX_H diff --git a/app/widget/colorwheel/colorspacechooser.cpp b/app/widget/colorwheel/colorspacechooser.cpp index ac0ec14ee..2a1bcc477 100644 --- a/app/widget/colorwheel/colorspacechooser.cpp +++ b/app/widget/colorwheel/colorspacechooser.cpp @@ -56,19 +56,19 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager, input_combobox_ = new QComboBox(); layout->addWidget(input_combobox_, row, 1); - QStringList input_spaces = color_manager->ListAvailableColorspaces(); + QStringList input_spaces = color_manager->list_available_colorspaces(); foreach (const QString &s, input_spaces) { input_combobox_->addItem(s); } - if (!color_manager_->GetDefaultInputColorSpace().isEmpty()) { + if (!color_manager_->get_default_input_color_space().isEmpty()) { input_combobox_->setCurrentText( - color_manager_->GetDefaultInputColorSpace()); + color_manager_->get_default_input_color_space()); } connect(input_combobox_, &QComboBox::currentTextChanged, this, - &ColorSpaceChooser::ComboBoxChanged); + &ColorSpaceChooser::combo_box_changed); row++; } else { @@ -82,17 +82,17 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager, display_combobox_ = new QComboBox(); layout->addWidget(display_combobox_, row, 1); - QStringList display_spaces = color_manager->ListAvailableDisplays(); + QStringList display_spaces = color_manager->list_available_displays(); foreach (const QString &s, display_spaces) { display_combobox_->addItem(s); } display_combobox_->setCurrentText( - color_manager_->GetDefaultDisplay()); + color_manager_->get_default_display()); connect(display_combobox_, &QComboBox::currentTextChanged, this, - &ColorSpaceChooser::ComboBoxChanged); + &ColorSpaceChooser::combo_box_changed); } row++; @@ -103,10 +103,10 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager, view_combobox_ = new QComboBox(); layout->addWidget(view_combobox_, row, 1); - UpdateViews(display_combobox_->currentText()); + update_views(display_combobox_->currentText()); connect(view_combobox_, &QComboBox::currentTextChanged, this, - &ColorSpaceChooser::ComboBoxChanged); + &ColorSpaceChooser::combo_box_changed); } row++; @@ -117,7 +117,7 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager, look_combobox_ = new QComboBox(); layout->addWidget(look_combobox_, row, 1); - QStringList looks = color_manager->ListAvailableLooks(); + QStringList looks = color_manager->list_available_looks(); look_combobox_->addItem(tr("(None)"), QString()); @@ -126,7 +126,7 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager, } connect(look_combobox_, &QComboBox::currentTextChanged, this, - &ColorSpaceChooser::ComboBoxChanged); + &ColorSpaceChooser::combo_box_changed); } } else { display_combobox_ = nullptr; @@ -155,12 +155,12 @@ ColorTransform ColorSpaceChooser::output() const void ColorSpaceChooser::set_input(const QString &s) { - input_combobox_->setCurrentText(color_manager_->GetCompliantColorSpace(s)); + input_combobox_->setCurrentText(color_manager_->get_compliant_color_space(s)); } void ColorSpaceChooser::set_output(const ColorTransform &out) { - ColorTransform compliant = color_manager_->GetCompliantColorSpace(out); + ColorTransform compliant = color_manager_->get_compliant_color_space(out); display_combobox_->setCurrentText(compliant.display()); view_combobox_->setCurrentText(compliant.view()); @@ -172,13 +172,13 @@ void ColorSpaceChooser::set_output(const ColorTransform &out) } } -void ColorSpaceChooser::UpdateViews(const QString &display) +void ColorSpaceChooser::update_views(const QString &display) { QString v = view_combobox_->currentText(); view_combobox_->clear(); - QStringList views = color_manager_->ListAvailableViews(display); + QStringList views = color_manager_->list_available_views(display); foreach (const QString &s, views) { view_combobox_->addItem(s); @@ -189,26 +189,26 @@ void ColorSpaceChooser::UpdateViews(const QString &display) view_combobox_->setCurrentText(v); } else { // Otherwise reset to default view for this display - view_combobox_->setCurrentText(color_manager_->GetDefaultView(display)); + view_combobox_->setCurrentText(color_manager_->get_default_view(display)); } } -void ColorSpaceChooser::ComboBoxChanged() +void ColorSpaceChooser::combo_box_changed() { if (sender() == display_combobox_) { - UpdateViews(display_combobox_->currentText()); + update_views(display_combobox_->currentText()); } if (input_combobox_) { - emit InputColorSpaceChanged(input()); + emit input_color_space_changed(input()); } if (display_combobox_) { - emit OutputColorSpaceChanged(output()); + emit output_color_space_changed(output()); } if (input_combobox_ && display_combobox_) { - emit ColorSpaceChanged(input(), output()); + emit color_space_changed(input(), output()); } } diff --git a/app/widget/colorwheel/colorspacechooser.h b/app/widget/colorwheel/colorspacechooser.h index f8034bc05..a8108356c 100644 --- a/app/widget/colorwheel/colorspacechooser.h +++ b/app/widget/colorwheel/colorspacechooser.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORSPACECHOOSER_H -#define COLORSPACECHOOSER_H +#ifndef OAK_COLORSPACECHOOSER_H +#define OAK_COLORSPACECHOOSER_H #include #include @@ -45,14 +45,14 @@ public: void set_output(const ColorTransform &out); signals: - void InputColorSpaceChanged(const QString &input); + void input_color_space_changed(const QString &input); - void OutputColorSpaceChanged(const ColorTransform &out); + void output_color_space_changed(const ColorTransform &out); - void ColorSpaceChanged(const QString &input, const ColorTransform &out); + void color_space_changed(const QString &input, const ColorTransform &out); private slots: - void UpdateViews(const QString &display); + void update_views(const QString &display); private: ColorManager *color_manager_; @@ -66,9 +66,9 @@ private: QComboBox *look_combobox_; private slots: - void ComboBoxChanged(); + void combo_box_changed(); }; } -#endif // COLORSPACECHOOSER_H +#endif // OAK_COLORSPACECHOOSER_H diff --git a/app/widget/colorwheel/colorswatchchooser.cpp b/app/widget/colorwheel/colorswatchchooser.cpp index 02cfac961..c609f1819 100644 --- a/app/widget/colorwheel/colorswatchchooser.cpp +++ b/app/widget/colorwheel/colorswatchchooser.cpp @@ -29,8 +29,8 @@ namespace olive { -const int kDefaultColorCount = 16; -const Color kDefaultColors[kDefaultColorCount] = { +const int k_default_color_count = 16; +const Color k_default_colors[k_default_color_count] = { Color(1.0, 1.0, 1.0), Color(1.0, 1.0, 0.0), Color(1.0, 0.5, 0.0), Color(1.0, 0.0, 0.0), Color(1.0, 0.0, 1.0), Color(0.5, 0.0, 1.0), Color(0.0, 0.0, 1.0), Color(0.0, 0.5, 1.0), Color(0.0, 1.0, 0.0), @@ -44,8 +44,8 @@ ColorSwatchChooser::ColorSwatchChooser(ColorManager *manager, QWidget *parent) { auto layout = new QGridLayout(this); - for (int x = 0; x < kColCount; x++) { - for (int y = 0; y < kRowCount; y++) { + for (int x = 0; x < k_col_count; x++) { + for (int y = 0; y < k_row_count; y++) { // Create button auto b = new ColorButton(manager, false); b->setFixedWidth(b->sizeHint().height() / 2 * 3); @@ -53,85 +53,85 @@ ColorSwatchChooser::ColorSwatchChooser(ColorManager *manager, QWidget *parent) layout->addWidget(b, y, x); // Save button in buttons array - int btn_index = x + kColCount * y; + int btn_index = x + k_col_count * y; buttons_[btn_index] = b; // Set default color - SetDefaultColor(btn_index); + set_default_color(btn_index); // Connect clicks connect(b, &ColorButton::clicked, this, - &ColorSwatchChooser::HandleButtonClick); + &ColorSwatchChooser::handle_button_click); connect(b, &ColorButton::customContextMenuRequested, this, - &ColorSwatchChooser::HandleContextMenu); + &ColorSwatchChooser::handle_context_menu); } } - LoadSwatches(); + load_swatches(); } -void ColorSwatchChooser::SetDefaultColor(int index) +void ColorSwatchChooser::set_default_color(int index) { - if (index < kDefaultColorCount) { - buttons_[index]->SetColor(kDefaultColors[index]); + if (index < k_default_color_count) { + buttons_[index]->set_color(k_default_colors[index]); } else { - buttons_[index]->SetColor(Color(1.0, 1.0, 1.0)); + buttons_[index]->set_color(Color(1.0, 1.0, 1.0)); } } -void ColorSwatchChooser::HandleButtonClick() +void ColorSwatchChooser::handle_button_click() { auto b = static_cast(sender()); - emit ColorClicked(b->GetColor()); - SetCurrentColor(b->GetColor()); + emit color_clicked(b->get_color()); + set_current_color(b->get_color()); } -void ColorSwatchChooser::HandleContextMenu() +void ColorSwatchChooser::handle_context_menu() { Menu m(this); auto save_action = m.addAction(tr("Save Color Here")); connect(save_action, &QAction::triggered, this, - &ColorSwatchChooser::SaveCurrentColor); + &ColorSwatchChooser::save_current_color); m.addSeparator(); auto reset_action = m.addAction(tr("Reset To Default")); connect(reset_action, &QAction::triggered, this, - &ColorSwatchChooser::ResetMenuButton); + &ColorSwatchChooser::reset_menu_button); menu_btn_ = static_cast(sender()); m.exec(QCursor::pos()); } -void ColorSwatchChooser::SaveCurrentColor() +void ColorSwatchChooser::save_current_color() { - menu_btn_->SetColor(current_); + menu_btn_->set_color(current_); - SaveSwatches(); + save_swatches(); } -void ColorSwatchChooser::ResetMenuButton() +void ColorSwatchChooser::reset_menu_button() { - for (int i = 0; i < kBtnCount; i++) { + for (int i = 0; i < k_btn_count; i++) { if (buttons_[i] == menu_btn_) { - SetDefaultColor(i); + set_default_color(i); break; } } } -QString ColorSwatchChooser::GetSwatchFilename() +QString ColorSwatchChooser::get_swatch_filename() { - return QDir(FileFunctions::GetConfigurationLocation()) + return QDir(FileFunctions::get_configuration_location()) .filePath(QStringLiteral("swatch")); } -void ColorSwatchChooser::LoadSwatches() +void ColorSwatchChooser::load_swatches() { - QFile f(GetSwatchFilename()); + QFile f(get_swatch_filename()); if (f.open(QFile::ReadOnly)) { QDataStream d(&f); @@ -140,7 +140,7 @@ void ColorSwatchChooser::LoadSwatches() if (version == 1) { int index = 0; - while (index < kBtnCount && !d.atEnd()) { + while (index < k_btn_count && !d.atEnd()) { Color::DataType r; QString s; ManagedColor c; @@ -173,7 +173,7 @@ void ColorSwatchChooser::LoadSwatches() c.set_color_output(ColorTransform(s)); } - buttons_[index]->SetColor(c); + buttons_[index]->set_color(c); index++; } @@ -183,9 +183,9 @@ void ColorSwatchChooser::LoadSwatches() } } -void ColorSwatchChooser::SaveSwatches() +void ColorSwatchChooser::save_swatches() { - QString fn = GetSwatchFilename(); + QString fn = get_swatch_filename(); QFile f(fn); if (f.open(QFile::WriteOnly)) { @@ -194,8 +194,8 @@ void ColorSwatchChooser::SaveSwatches() const uint version = 1; d << version; - for (int i = 0; i < kBtnCount; i++) { - const ManagedColor &c = buttons_[i]->GetColor(); + for (int i = 0; i < k_btn_count; i++) { + const ManagedColor &c = buttons_[i]->get_color(); d << c.red(); d << c.green(); d << c.blue(); diff --git a/app/widget/colorwheel/colorswatchchooser.h b/app/widget/colorwheel/colorswatchchooser.h index a9e05fd6b..e748f2df8 100644 --- a/app/widget/colorwheel/colorswatchchooser.h +++ b/app/widget/colorwheel/colorswatchchooser.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORSWATCHCHOOSER_H -#define COLORSWATCHCHOOSER_H +#ifndef OAK_COLORSWATCHCHOOSER_H +#define OAK_COLORSWATCHCHOOSER_H #include "node/color/colormanager/colormanager.h" #include "widget/colorbutton/colorbutton.h" @@ -34,40 +34,40 @@ public: ColorSwatchChooser(ColorManager *manager, QWidget *parent = nullptr); public slots: - void SetCurrentColor(const ManagedColor &c) + void set_current_color(const ManagedColor &c) { current_ = c; } signals: - void ColorClicked(const ManagedColor &c); + void color_clicked(const ManagedColor &c); private: - void SetDefaultColor(int index); + void set_default_color(int index); - static QString GetSwatchFilename(); + static QString get_swatch_filename(); - void LoadSwatches(); - void SaveSwatches(); + void load_swatches(); + void save_swatches(); - static const int kRowCount = 4; - static const int kColCount = 8; - static const int kBtnCount = kRowCount * kColCount; - ColorButton *buttons_[kBtnCount]; + static const int k_row_count = 4; + static const int k_col_count = 8; + static const int k_btn_count = k_row_count * k_col_count; + ColorButton *buttons_[k_btn_count]; ManagedColor current_; ColorButton *menu_btn_; private slots: - void HandleButtonClick(); + void handle_button_click(); - void HandleContextMenu(); + void handle_context_menu(); - void SaveCurrentColor(); + void save_current_color(); - void ResetMenuButton(); + void reset_menu_button(); }; } -#endif // COLORSWATCHCHOOSER_H +#endif // OAK_COLORSWATCHCHOOSER_H diff --git a/app/widget/colorwheel/colorswatchwidget.cpp b/app/widget/colorwheel/colorswatchwidget.cpp index fd8802858..ab29aa445 100644 --- a/app/widget/colorwheel/colorswatchwidget.cpp +++ b/app/widget/colorwheel/colorswatchwidget.cpp @@ -35,33 +35,33 @@ ColorSwatchWidget::ColorSwatchWidget(QWidget *parent) { } -const Color &ColorSwatchWidget::GetSelectedColor() const +const Color &ColorSwatchWidget::get_selected_color() const { return selected_color_; } -void ColorSwatchWidget::SetColorProcessor(ColorProcessorPtr to_linear, +void ColorSwatchWidget::set_color_processor(ColorProcessorPtr to_linear, ColorProcessorPtr to_display) { to_linear_processor_ = to_linear; to_display_processor_ = to_display; // Force full update - SelectedColorChangedEvent(GetSelectedColor(), true); + SelectedColorChangedEvent(get_selected_color(), true); update(); } -void ColorSwatchWidget::SetSelectedColor(const Color &c) +void ColorSwatchWidget::set_selected_color(const Color &c) { - SetSelectedColorInternal(c, true); + set_selected_color_internal(c, true); } void ColorSwatchWidget::mousePressEvent(QMouseEvent *e) { QWidget::mousePressEvent(e); - SetSelectedColorInternal(GetColorFromScreenPos(e->pos()), false); - emit SelectedColorChanged(GetSelectedColor()); + set_selected_color_internal(get_color_from_screen_pos(e->pos()), false); + emit selected_color_changed(get_selected_color()); } void ColorSwatchWidget::mouseMoveEvent(QMouseEvent *e) @@ -69,8 +69,8 @@ void ColorSwatchWidget::mouseMoveEvent(QMouseEvent *e) QWidget::mouseMoveEvent(e); if (e->buttons() & Qt::LeftButton) { - SetSelectedColorInternal(GetColorFromScreenPos(e->pos()), false); - emit SelectedColorChanged(GetSelectedColor()); + set_selected_color_internal(get_color_from_screen_pos(e->pos()), false); + emit selected_color_changed(get_selected_color()); } } @@ -78,22 +78,22 @@ void ColorSwatchWidget::SelectedColorChangedEvent(const Color &, bool) { } -Qt::GlobalColor ColorSwatchWidget::GetUISelectorColor() const +Qt::GlobalColor ColorSwatchWidget::get_ui_selector_color() const { - return ColorCoding::GetUISelectorColor(GetSelectedColor()); + return ColorCoding::get_ui_selector_color(get_selected_color()); } -Color ColorSwatchWidget::GetManagedColor(const Color &input) const +Color ColorSwatchWidget::get_managed_color(const Color &input) const { if (to_linear_processor_ && to_display_processor_) { - return to_display_processor_->ConvertColor( - to_linear_processor_->ConvertColor(input)); + return to_display_processor_->convert_color( + to_linear_processor_->convert_color(input)); } return input; } -void ColorSwatchWidget::SetSelectedColorInternal(const Color &c, bool external) +void ColorSwatchWidget::set_selected_color_internal(const Color &c, bool external) { selected_color_ = c; SelectedColorChangedEvent(c, external); diff --git a/app/widget/colorwheel/colorswatchwidget.h b/app/widget/colorwheel/colorswatchwidget.h index 0f4cccf67..9fbeba4a7 100644 --- a/app/widget/colorwheel/colorswatchwidget.h +++ b/app/widget/colorwheel/colorswatchwidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORSWATCHWIDGET_H -#define COLORSWATCHWIDGET_H +#ifndef OAK_COLORSWATCHWIDGET_H +#define OAK_COLORSWATCHWIDGET_H #include @@ -34,32 +34,32 @@ class ColorSwatchWidget : public QWidget { public: ColorSwatchWidget(QWidget *parent = nullptr); - const Color &GetSelectedColor() const; + const Color &get_selected_color() const; - void SetColorProcessor(ColorProcessorPtr to_linear, + void set_color_processor(ColorProcessorPtr to_linear, ColorProcessorPtr to_display); public slots: - void SetSelectedColor(const Color &c); + void set_selected_color(const Color &c); signals: - void SelectedColorChanged(const Color &c); + void selected_color_changed(const Color &c); protected: virtual void mousePressEvent(QMouseEvent *e) override; virtual void mouseMoveEvent(QMouseEvent *e) override; - virtual Color GetColorFromScreenPos(const QPoint &p) const = 0; + virtual Color get_color_from_screen_pos(const QPoint &p) const = 0; virtual void SelectedColorChangedEvent(const Color &c, bool external); - Qt::GlobalColor GetUISelectorColor() const; + Qt::GlobalColor get_ui_selector_color() const; - Color GetManagedColor(const Color &input) const; + Color get_managed_color(const Color &input) const; private: - void SetSelectedColorInternal(const Color &c, bool external); + void set_selected_color_internal(const Color &c, bool external); Color selected_color_; @@ -70,4 +70,4 @@ private: } -#endif // COLORSWATCHWIDGET_H +#endif // OAK_COLORSWATCHWIDGET_H diff --git a/app/widget/colorwheel/colorvalueswidget.cpp b/app/widget/colorwheel/colorvalueswidget.cpp index 6f835c59f..0c5bf295c 100644 --- a/app/widget/colorwheel/colorvalueswidget.cpp +++ b/app/widget/colorwheel/colorvalueswidget.cpp @@ -55,14 +55,14 @@ ColorValuesWidget::ColorValuesWidget(ColorManager *manager, QWidget *parent) preview_layout->addWidget(preview_); color_picker_btn_ = new QPushButton(); - color_picker_btn_->setIcon(icon::ColorPicker); + color_picker_btn_->setIcon(icon::color_picker); color_picker_btn_->setFixedWidth( color_picker_btn_->sizeHint().height()); color_picker_btn_->setCheckable(true); connect(color_picker_btn_, &QPushButton::toggled, this, - &ColorValuesWidget::ColorPickedBtnToggled); - connect(Core::instance(), &Core::ColorPickerColorEmitted, this, - &ColorValuesWidget::SetReferenceColor); + &ColorValuesWidget::color_picked_btn_toggled); + connect(Core::instance(), &Core::color_picker_color_emitted, this, + &ColorValuesWidget::set_reference_color); preview_layout->addWidget(color_picker_btn_); layout->addLayout(preview_layout); @@ -74,33 +74,33 @@ ColorValuesWidget::ColorValuesWidget(ColorManager *manager, QWidget *parent) input_tab_ = new ColorValuesTab(true); tabs->addTab(input_tab_, tr("Input")); - connect(input_tab_, &ColorValuesTab::ColorChanged, this, - &ColorValuesWidget::UpdateValuesFromInput); - connect(input_tab_, &ColorValuesTab::ColorChanged, this, - &ColorValuesWidget::ColorChanged); - connect(input_tab_, &ColorValuesTab::ColorChanged, preview_, - &ColorPreviewBox::SetColor); + connect(input_tab_, &ColorValuesTab::color_changed, this, + &ColorValuesWidget::update_values_from_input); + connect(input_tab_, &ColorValuesTab::color_changed, this, + &ColorValuesWidget::color_changed); + connect(input_tab_, &ColorValuesTab::color_changed, preview_, + &ColorPreviewBox::set_color); reference_tab_ = new ColorValuesTab(); tabs->addTab(reference_tab_, tr("Reference")); - connect(reference_tab_, &ColorValuesTab::ColorChanged, this, - &ColorValuesWidget::UpdateValuesFromRef); + connect(reference_tab_, &ColorValuesTab::color_changed, this, + &ColorValuesWidget::update_values_from_ref); display_tab_ = new ColorValuesTab(); tabs->addTab(display_tab_, tr("Display")); - connect(display_tab_, &ColorValuesTab::ColorChanged, this, - &ColorValuesWidget::UpdateValuesFromDisplay); + connect(display_tab_, &ColorValuesTab::color_changed, this, + &ColorValuesWidget::update_values_from_display); layout->addWidget(tabs); } } -Color ColorValuesWidget::GetColor() const +Color ColorValuesWidget::get_color() const { - return reference_tab_->GetColor(); + return reference_tab_->get_color(); } -void ColorValuesWidget::SetColorProcessor(ColorProcessorPtr input_to_ref, +void ColorValuesWidget::set_color_processor(ColorProcessorPtr input_to_ref, ColorProcessorPtr ref_to_display, ColorProcessorPtr display_to_ref, ColorProcessorPtr ref_to_input) @@ -110,9 +110,9 @@ void ColorValuesWidget::SetColorProcessor(ColorProcessorPtr input_to_ref, display_to_ref_ = display_to_ref; ref_to_input_ = ref_to_input; - UpdateValuesFromInput(); + update_values_from_input(); - preview_->SetColorProcessor(input_to_ref_, ref_to_display_); + preview_->set_color_processor(input_to_ref_, ref_to_display_); } bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event) @@ -129,7 +129,7 @@ bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event) } if (use_this_color) { - picker_end_color_ = GetColor(); + picker_end_color_ = get_color(); } color_picker_btn_->setChecked(false); return true; @@ -145,101 +145,101 @@ bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event) return QWidget::eventFilter(watcher, event); } -void ColorValuesWidget::SetColor(const Color &c) +void ColorValuesWidget::set_color(const Color &c) { - input_tab_->SetColor(c); - preview_->SetColor(c); + input_tab_->set_color(c); + preview_->set_color(c); - UpdateValuesFromInput(); + update_values_from_input(); } -void ColorValuesWidget::SetReferenceColor(const Color &c) +void ColorValuesWidget::set_reference_color(const Color &c) { - reference_tab_->SetColor(c); + reference_tab_->set_color(c); - UpdateValuesFromRef(); + update_values_from_ref(); } -void ColorValuesWidget::UpdateValuesFromInput() +void ColorValuesWidget::update_values_from_input() { - UpdateRefFromInput(); - UpdateDisplayFromRef(); + update_ref_from_input(); + update_display_from_ref(); } -void ColorValuesWidget::UpdateValuesFromRef() +void ColorValuesWidget::update_values_from_ref() { - UpdateInputFromRef(); - UpdateDisplayFromRef(); + update_input_from_ref(); + update_display_from_ref(); } -void ColorValuesWidget::UpdateValuesFromDisplay() +void ColorValuesWidget::update_values_from_display() { - UpdateRefFromDisplay(); - UpdateInputFromRef(); + update_ref_from_display(); + update_input_from_ref(); } -void ColorValuesWidget::ColorPickedBtnToggled(bool e) +void ColorValuesWidget::color_picked_btn_toggled(bool e) { - Core::instance()->RequestPixelSamplingInViewers(e); + Core::instance()->request_pixel_sampling_in_viewers(e); if (e) { qApp->installEventFilter(this); // Store current color in case it needs to be restored - picker_end_color_ = GetColor(); + picker_end_color_ = get_color(); } else { qApp->removeEventFilter(this); // Restore original color (or use overridden color from eventFilter) - SetReferenceColor(picker_end_color_); - emit ColorChanged(input_tab_->GetColor()); + set_reference_color(picker_end_color_); + emit color_changed(input_tab_->get_color()); } } -void ColorValuesWidget::UpdateInputFromRef() +void ColorValuesWidget::update_input_from_ref() { if (ref_to_input_) { - input_tab_->SetColor( - ref_to_input_->ConvertColor(reference_tab_->GetColor())); + input_tab_->set_color( + ref_to_input_->convert_color(reference_tab_->get_color())); } else { - input_tab_->SetColor(reference_tab_->GetColor()); + input_tab_->set_color(reference_tab_->get_color()); } - preview_->SetColor(input_tab_->GetColor()); - emit ColorChanged(input_tab_->GetColor()); + preview_->set_color(input_tab_->get_color()); + emit color_changed(input_tab_->get_color()); } -void ColorValuesWidget::UpdateDisplayFromRef() +void ColorValuesWidget::update_display_from_ref() { if (ref_to_display_) { - display_tab_->SetColor( - ref_to_display_->ConvertColor(reference_tab_->GetColor())); + display_tab_->set_color( + ref_to_display_->convert_color(reference_tab_->get_color())); } else { - display_tab_->SetColor(reference_tab_->GetColor()); + display_tab_->set_color(reference_tab_->get_color()); } } -void ColorValuesWidget::UpdateRefFromInput() +void ColorValuesWidget::update_ref_from_input() { if (input_to_ref_) { - reference_tab_->SetColor( - input_to_ref_->ConvertColor(input_tab_->GetColor())); + reference_tab_->set_color( + input_to_ref_->convert_color(input_tab_->get_color())); } else { - reference_tab_->SetColor(input_tab_->GetColor()); + reference_tab_->set_color(input_tab_->get_color()); } } -void ColorValuesWidget::UpdateRefFromDisplay() +void ColorValuesWidget::update_ref_from_display() { if (display_to_ref_) { - reference_tab_->SetColor( - display_to_ref_->ConvertColor(display_tab_->GetColor())); + reference_tab_->set_color( + display_to_ref_->convert_color(display_tab_->get_color())); } else { - reference_tab_->SetColor(display_tab_->GetColor()); + reference_tab_->set_color(display_tab_->get_color()); } } -const double ColorValuesTab::kLegacyMultiplier = 255.0; +const double ColorValuesTab::k_legacy_multiplier = 255.0; ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent) : QWidget(parent) @@ -251,9 +251,9 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent) if (with_legacy_option) { legacy_box_ = new QCheckBox(tr("Use legacy (8-bit) values")); legacy_box_->setChecked( - OLIVE_CONFIG("UseLegacyColorInInputTab").toBool()); + OAK_CONFIG("UseLegacyColorInInputTab").toBool()); connect(legacy_box_, &QCheckBox::clicked, this, - &ColorValuesTab::LegacyChanged); + &ColorValuesTab::legacy_changed); layout->addWidget(legacy_box_, row, 0, 1, 2); row++; } else { @@ -264,7 +264,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent) layout->addWidget(new QLabel(tr("Red")), row, 0); - red_slider_ = CreateColorSlider(); + red_slider_ = create_color_slider(); sliders_[0] = red_slider_; layout->addWidget(red_slider_, row, 1); @@ -272,7 +272,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent) layout->addWidget(new QLabel(tr("Green")), row, 0); - green_slider_ = CreateColorSlider(); + green_slider_ = create_color_slider(); sliders_[1] = green_slider_; layout->addWidget(green_slider_, row, 1); @@ -280,7 +280,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent) layout->addWidget(new QLabel(tr("Blue")), row, 0); - blue_slider_ = CreateColorSlider(); + blue_slider_ = create_color_slider(); sliders_[2] = blue_slider_; layout->addWidget(blue_slider_, row, 1); @@ -290,112 +290,112 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent) layout->addWidget(hex_lbl_, row, 0); hex_slider_ = new StringSlider(); - connect(hex_slider_, &StringSlider::ValueChanged, this, - &ColorValuesTab::HexChanged); + connect(hex_slider_, &StringSlider::value_changed, this, + &ColorValuesTab::hex_changed); layout->addWidget(hex_slider_, row, 1); if (legacy_box_) { - LegacyChanged(AreSlidersLegacyValues()); + legacy_changed(are_sliders_legacy_values()); } } -Color ColorValuesTab::GetColor() const +Color ColorValuesTab::get_color() const { - return Color(GetRed(), GetGreen(), GetBlue()); + return Color(get_red(), get_green(), get_blue()); } -void ColorValuesTab::SetColor(const Color &c) +void ColorValuesTab::set_color(const Color &c) { - SetRed(c.red()); - SetGreen(c.green()); - SetBlue(c.blue()); + set_red(c.red()); + set_green(c.green()); + set_blue(c.blue()); } -double ColorValuesTab::GetRed() const +double ColorValuesTab::get_red() const { - return GetValueInternal(red_slider_); + return get_value_internal(red_slider_); } -double ColorValuesTab::GetGreen() const +double ColorValuesTab::get_green() const { - return GetValueInternal(green_slider_); + return get_value_internal(green_slider_); } -double ColorValuesTab::GetBlue() const +double ColorValuesTab::get_blue() const { - return GetValueInternal(blue_slider_); + return get_value_internal(blue_slider_); } -void ColorValuesTab::SetRed(double r) +void ColorValuesTab::set_red(double r) { - SetValueInternal(red_slider_, r); + set_value_internal(red_slider_, r); } -void ColorValuesTab::SetGreen(double g) +void ColorValuesTab::set_green(double g) { - SetValueInternal(green_slider_, g); + set_value_internal(green_slider_, g); } -void ColorValuesTab::SetBlue(double b) +void ColorValuesTab::set_blue(double b) { - SetValueInternal(blue_slider_, b); + set_value_internal(blue_slider_, b); } -double ColorValuesTab::GetValueInternal(FloatSlider *slider) const +double ColorValuesTab::get_value_internal(FloatSlider *slider) const { - double d = slider->GetValue(); + double d = slider->get_value(); - if (AreSlidersLegacyValues()) { - d /= kLegacyMultiplier; + if (are_sliders_legacy_values()) { + d /= k_legacy_multiplier; } return d; } -void ColorValuesTab::SetValueInternal(FloatSlider *slider, double v) +void ColorValuesTab::set_value_internal(FloatSlider *slider, double v) { - if (AreSlidersLegacyValues()) { - v *= kLegacyMultiplier; + if (are_sliders_legacy_values()) { + v *= k_legacy_multiplier; } - slider->SetValue(v); - UpdateHex(); + slider->set_value(v); + update_hex(); } -FloatSlider *ColorValuesTab::CreateColorSlider() +FloatSlider *ColorValuesTab::create_color_slider() { FloatSlider *fs = new FloatSlider(); - fs->SetLadderElementCount(1); - connect(fs, &FloatSlider::ValueChanged, this, - &ColorValuesTab::SliderChanged); + fs->set_ladder_element_count(1); + connect(fs, &FloatSlider::value_changed, this, + &ColorValuesTab::slider_changed); return fs; } -void ColorValuesTab::SliderChanged() +void ColorValuesTab::slider_changed() { - emit ColorChanged(GetColor()); - UpdateHex(); + emit color_changed(get_color()); + update_hex(); } -void ColorValuesTab::LegacyChanged(bool legacy) +void ColorValuesTab::legacy_changed(bool legacy) { - OLIVE_CONFIG("UseLegacyColorInInputTab") = legacy; + OAK_CONFIG("UseLegacyColorInInputTab") = legacy; - double legacy_multiplier = legacy ? kLegacyMultiplier : - 1.0 / kLegacyMultiplier; + double legacy_multiplier = legacy ? k_legacy_multiplier : + 1.0 / k_legacy_multiplier; int decimal_places = legacy ? 0 : 5; double drag_multiplier = legacy ? 1.0 : 0.01; foreach (FloatSlider *s, sliders_) { - s->SetValue(s->GetValue() * legacy_multiplier); - s->SetDecimalPlaces(decimal_places); - s->SetDragMultiplier(drag_multiplier); + s->set_value(s->get_value() * legacy_multiplier); + s->set_decimal_places(decimal_places); + s->set_drag_multiplier(drag_multiplier); } - UpdateHex(); + update_hex(); } -QString RGBValToString(double d) +QString rgb_val_to_string(double d) { QString s = QString::number(d); @@ -406,33 +406,33 @@ QString RGBValToString(double d) return s; } -void ColorValuesTab::UpdateHex() +void ColorValuesTab::update_hex() { - if (AreSlidersLegacyValues()) { - double r = red_slider_->GetValue(); - double g = green_slider_->GetValue(); - double b = blue_slider_->GetValue(); + if (are_sliders_legacy_values()) { + double r = red_slider_->get_value(); + double g = green_slider_->get_value(); + double b = blue_slider_->get_value(); - if (r > kLegacyMultiplier || g > kLegacyMultiplier || - b > kLegacyMultiplier) { - hex_slider_->SetValue(tr("(Invalid)")); + if (r > k_legacy_multiplier || g > k_legacy_multiplier || + b > k_legacy_multiplier) { + hex_slider_->set_value(tr("(Invalid)")); } else { uint32_t rgb = (uint8_t(r) << 16) | (uint8_t(g) << 8) | uint8_t(b); - hex_slider_->SetValue(QStringLiteral("%1") + hex_slider_->set_value(QStringLiteral("%1") .arg(rgb, 6, 16, QLatin1Char('0')) .toUpper()); } } else { - hex_slider_->SetValue( + hex_slider_->set_value( QStringLiteral("rgb(%1, %2, %3)") - .arg(RGBValToString(red_slider_->GetValue()), - RGBValToString(green_slider_->GetValue()), - RGBValToString(blue_slider_->GetValue()))); + .arg(rgb_val_to_string(red_slider_->get_value()), + rgb_val_to_string(green_slider_->get_value()), + rgb_val_to_string(blue_slider_->get_value()))); } } -bool ParseRGBString(QString s, double *r, double *g, double *b) +bool parse_rgb_string(QString s, double *r, double *g, double *b) { // Trim whitespace s = s.trimmed(); @@ -463,7 +463,7 @@ bool ParseRGBString(QString s, double *r, double *g, double *b) return true; } -void ColorValuesTab::HexChanged(const QString &s) +void ColorValuesTab::hex_changed(const QString &s) { bool ok; uint32_t hex = s.toULong(&ok, 16); @@ -477,40 +477,40 @@ void ColorValuesTab::HexChanged(const QString &s) uint32_t g = (hex & 0x00FF00) >> 8; uint32_t b = (hex & 0x0000FF); - if (AreSlidersLegacyValues()) { - red_slider_->SetValue(r); - green_slider_->SetValue(g); - blue_slider_->SetValue(b); + if (are_sliders_legacy_values()) { + red_slider_->set_value(r); + green_slider_->set_value(g); + blue_slider_->set_value(b); } else { - red_slider_->SetValue(double(r) / kLegacyMultiplier); - green_slider_->SetValue(double(g) / kLegacyMultiplier); - blue_slider_->SetValue(double(b) / kLegacyMultiplier); + red_slider_->set_value(double(r) / k_legacy_multiplier); + green_slider_->set_value(double(g) / k_legacy_multiplier); + blue_slider_->set_value(double(b) / k_legacy_multiplier); } - emit ColorChanged(GetColor()); + emit color_changed(get_color()); } else { // Attempt to parse rgb/rgba double r, g, b; - if (ParseRGBString(s, &r, &g, &b)) { - if (AreSlidersLegacyValues()) { - red_slider_->SetValue(r * kLegacyMultiplier); - green_slider_->SetValue(g * kLegacyMultiplier); - blue_slider_->SetValue(b * kLegacyMultiplier); + if (parse_rgb_string(s, &r, &g, &b)) { + if (are_sliders_legacy_values()) { + red_slider_->set_value(r * k_legacy_multiplier); + green_slider_->set_value(g * k_legacy_multiplier); + blue_slider_->set_value(b * k_legacy_multiplier); } else { - red_slider_->SetValue(r); - green_slider_->SetValue(g); - blue_slider_->SetValue(b); + red_slider_->set_value(r); + green_slider_->set_value(g); + blue_slider_->set_value(b); } - emit ColorChanged(GetColor()); + emit color_changed(get_color()); } } // Conform string to our formatting - UpdateHex(); + update_hex(); } -bool ColorValuesTab::AreSlidersLegacyValues() const +bool ColorValuesTab::are_sliders_legacy_values() const { return legacy_box_ && legacy_box_->isChecked(); } diff --git a/app/widget/colorwheel/colorvalueswidget.h b/app/widget/colorwheel/colorvalueswidget.h index 924492834..1e659f9f3 100644 --- a/app/widget/colorwheel/colorvalueswidget.h +++ b/app/widget/colorwheel/colorvalueswidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORVALUESWIDGET_H -#define COLORVALUESWIDGET_H +#ifndef OAK_COLORVALUESWIDGET_H +#define OAK_COLORVALUESWIDGET_H #include #include @@ -39,29 +39,29 @@ class ColorValuesTab : public QWidget { public: ColorValuesTab(bool with_legacy_option = false, QWidget *parent = nullptr); - Color GetColor() const; + Color get_color() const; - void SetColor(const Color &c); + void set_color(const Color &c); - double GetRed() const; - double GetGreen() const; - double GetBlue() const; - void SetRed(double r); - void SetGreen(double g); - void SetBlue(double b); + double get_red() const; + double get_green() const; + double get_blue() const; + void set_red(double r); + void set_green(double g); + void set_blue(double b); signals: - void ColorChanged(const Color &c); + void color_changed(const Color &c); private: - static const double kLegacyMultiplier; + static const double k_legacy_multiplier; - double GetValueInternal(FloatSlider *slider) const; - void SetValueInternal(FloatSlider *slider, double v); + double get_value_internal(FloatSlider *slider) const; + void set_value_internal(FloatSlider *slider, double v); - bool AreSlidersLegacyValues() const; + bool are_sliders_legacy_values() const; - FloatSlider *CreateColorSlider(); + FloatSlider *create_color_slider(); FloatSlider *red_slider_; FloatSlider *green_slider_; @@ -75,13 +75,13 @@ private: QCheckBox *legacy_box_; private slots: - void SliderChanged(); + void slider_changed(); - void LegacyChanged(bool e); + void legacy_changed(bool e); - void UpdateHex(); + void update_hex(); - void HexChanged(const QString &s); + void hex_changed(const QString &s); }; class ColorValuesWidget : public QWidget { @@ -89,36 +89,36 @@ class ColorValuesWidget : public QWidget { public: ColorValuesWidget(ColorManager *manager, QWidget *parent = nullptr); - Color GetColor() const; + Color get_color() const; - void SetColorProcessor(ColorProcessorPtr input_to_ref, + void set_color_processor(ColorProcessorPtr input_to_ref, ColorProcessorPtr ref_to_display, ColorProcessorPtr display_to_ref, ColorProcessorPtr ref_to_input); virtual bool eventFilter(QObject *watcher, QEvent *event) override; - void IgnorePickFrom(QWidget *w) + void ignore_pick_from(QWidget *w) { ignore_pick_from_.append(w); } public slots: - void SetColor(const Color &c); + void set_color(const Color &c); - void SetReferenceColor(const Color &c); + void set_reference_color(const Color &c); signals: - void ColorChanged(const Color &c); + void color_changed(const Color &c); private: - void UpdateInputFromRef(); + void update_input_from_ref(); - void UpdateDisplayFromRef(); + void update_display_from_ref(); - void UpdateRefFromInput(); + void update_ref_from_input(); - void UpdateRefFromDisplay(); + void update_ref_from_display(); ColorManager *manager_; @@ -145,15 +145,15 @@ private: QVector ignore_pick_from_; private slots: - void UpdateValuesFromInput(); + void update_values_from_input(); - void UpdateValuesFromRef(); + void update_values_from_ref(); - void UpdateValuesFromDisplay(); + void update_values_from_display(); - void ColorPickedBtnToggled(bool e); + void color_picked_btn_toggled(bool e); }; } -#endif // COLORVALUESWIDGET_H +#endif // OAK_COLORVALUESWIDGET_H diff --git a/app/widget/colorwheel/colorwheelwidget.cpp b/app/widget/colorwheel/colorwheelwidget.cpp index 6ae16f8d2..50668ecdf 100644 --- a/app/widget/colorwheel/colorwheelwidget.cpp +++ b/app/widget/colorwheel/colorwheelwidget.cpp @@ -39,23 +39,23 @@ ColorWheelWidget::ColorWheelWidget(QWidget *parent) { } -Color ColorWheelWidget::GetColorFromScreenPos(const QPoint &p) const +Color ColorWheelWidget::get_color_from_screen_pos(const QPoint &p) const { - return GetColorFromTriangle(GetTriangleFromCoords(rect().center(), p)); + return get_color_from_triangle(get_triangle_from_coords(rect().center(), p)); } void ColorWheelWidget::resizeEvent(QResizeEvent *e) { ColorSwatchWidget::resizeEvent(e); - emit DiameterChanged(GetDiameter()); + emit diameter_changed(get_diameter()); } void ColorWheelWidget::paintEvent(QPaintEvent *e) { ColorSwatchWidget::paintEvent(e); - int diameter = GetDiameter(); + int diameter = get_diameter(); // Half diameter int radius = diameter / 2; @@ -70,11 +70,11 @@ void ColorWheelWidget::paintEvent(QPaintEvent *e) for (int i = 0; i < diameter; i++) { for (int j = 0; j < diameter; j++) { - Triangle tri = GetTriangleFromCoords(center, j, i); + Triangle tri = get_triangle_from_coords(center, j, i); if (tri.hypotenuse <= radius) { - Color managed = GetManagedColor(GetColorFromTriangle(tri)); - QColor c = QtUtils::toQColor(managed); + Color managed = get_managed_color(get_color_from_triangle(tri)); + QColor c = QtUtils::to_q_color(managed); // Very basic antialiasing around the edges of the wheel qreal alpha = qMin(1.0, radius - tri.hypotenuse); @@ -110,10 +110,10 @@ void ColorWheelWidget::paintEvent(QPaintEvent *e) // Really rough algorithm for determining whether the selector UI should be white or black int selector_radius = qMax(1, radius / 32); - p.setPen(QPen(GetUISelectorColor(), qMax(1, selector_radius / 4))); + p.setPen(QPen(get_ui_selector_color(), qMax(1, selector_radius / 4))); p.setBrush(Qt::NoBrush); - p.drawEllipse(GetCoordsFromColor(GetSelectedColor()), selector_radius, + p.drawEllipse(get_coords_from_color(get_selected_color()), selector_radius, selector_radius); } @@ -125,25 +125,25 @@ void ColorWheelWidget::SelectedColorChangedEvent(const Color &c, bool external) } } -int ColorWheelWidget::GetDiameter() const +int ColorWheelWidget::get_diameter() const { return qMin(width(), height()); } -qreal ColorWheelWidget::GetRadius() const +qreal ColorWheelWidget::get_radius() const { - return GetDiameter() * 0.5; + return get_diameter() * 0.5; } ColorWheelWidget::Triangle -ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er, +ColorWheelWidget::get_triangle_from_coords(const QPoint ¢er, const QPoint &p) const { - return GetTriangleFromCoords(center, p.y(), p.x()); + return get_triangle_from_coords(center, p.y(), p.x()); } ColorWheelWidget::Triangle -ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er, qreal y, +ColorWheelWidget::get_triangle_from_coords(const QPoint ¢er, qreal y, qreal x) const { qreal opposite = y - center.y(); @@ -153,21 +153,21 @@ ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er, qreal y, return { opposite, adjacent, hypotenuse }; } -Color ColorWheelWidget::GetColorFromTriangle( +Color ColorWheelWidget::get_color_from_triangle( const ColorWheelWidget::Triangle &tri) const { qreal hue = qAtan2(tri.opposite, tri.adjacent) * M_180_OVER_PI + 180.0; - qreal sat = qMin(1.0, (tri.hypotenuse / GetRadius())); + qreal sat = qMin(1.0, (tri.hypotenuse / get_radius())); - return Color::fromHsv(hue, sat, val_); + return Color::from_hsv(hue, sat, val_); } -QPoint ColorWheelWidget::GetCoordsFromColor(const Color &c) const +QPoint ColorWheelWidget::get_coords_from_color(const Color &c) const { float hue, sat, val; - c.toHsv(&hue, &sat, &val); + c.to_hsv(&hue, &sat, &val); - qreal hypotenuse = sat * GetRadius(); + qreal hypotenuse = sat * get_radius(); qreal radian_angle = (hue - 180.0) / M_180_OVER_PI; diff --git a/app/widget/colorwheel/colorwheelwidget.h b/app/widget/colorwheel/colorwheelwidget.h index c5966dce8..8eca05aef 100644 --- a/app/widget/colorwheel/colorwheelwidget.h +++ b/app/widget/colorwheel/colorwheelwidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLORWHEELWIDGET_H -#define COLORWHEELWIDGET_H +#ifndef OAK_COLORWHEELWIDGET_H +#define OAK_COLORWHEELWIDGET_H #include @@ -35,10 +35,10 @@ public: ColorWheelWidget(QWidget *parent = nullptr); signals: - void DiameterChanged(int radius); + void diameter_changed(int radius); protected: - virtual Color GetColorFromScreenPos(const QPoint &p) const override; + virtual Color get_color_from_screen_pos(const QPoint &p) const override; virtual void resizeEvent(QResizeEvent *e) override; @@ -48,9 +48,9 @@ protected: bool external) override; private: - int GetDiameter() const; + int get_diameter() const; - qreal GetRadius() const; + qreal get_radius() const; struct Triangle { qreal opposite; @@ -58,12 +58,12 @@ private: qreal hypotenuse; }; - Triangle GetTriangleFromCoords(const QPoint ¢er, const QPoint &p) const; - Triangle GetTriangleFromCoords(const QPoint ¢er, qreal y, + Triangle get_triangle_from_coords(const QPoint ¢er, const QPoint &p) const; + Triangle get_triangle_from_coords(const QPoint ¢er, qreal y, qreal x) const; - Color GetColorFromTriangle(const Triangle &tri) const; - QPoint GetCoordsFromColor(const Color &c) const; + Color get_color_from_triangle(const Triangle &tri) const; + QPoint get_coords_from_color(const Color &c) const; QPixmap cached_wheel_; @@ -74,4 +74,4 @@ private: } -#endif // COLORWHEELWIDGET_H +#endif // OAK_COLORWHEELWIDGET_H diff --git a/app/widget/columnedgridlayout/columnedgridlayout.cpp b/app/widget/columnedgridlayout/columnedgridlayout.cpp index d14671c85..dd64519cc 100644 --- a/app/widget/columnedgridlayout/columnedgridlayout.cpp +++ b/app/widget/columnedgridlayout/columnedgridlayout.cpp @@ -30,7 +30,7 @@ ColumnedGridLayout::ColumnedGridLayout(QWidget *parent, int maximum_columns) { } -void ColumnedGridLayout::Add(QWidget *widget) +void ColumnedGridLayout::add(QWidget *widget) { if (maximum_columns_ > 0) { int row = count() / maximum_columns_; @@ -43,12 +43,12 @@ void ColumnedGridLayout::Add(QWidget *widget) } } -int ColumnedGridLayout::MaximumColumns() const +int ColumnedGridLayout::maximum_columns() const { return maximum_columns_; } -void ColumnedGridLayout::SetMaximumColumns(int maximum_columns) +void ColumnedGridLayout::set_maximum_columns(int maximum_columns) { maximum_columns_ = maximum_columns; } diff --git a/app/widget/columnedgridlayout/columnedgridlayout.h b/app/widget/columnedgridlayout/columnedgridlayout.h index d13945cf0..a8522181a 100644 --- a/app/widget/columnedgridlayout/columnedgridlayout.h +++ b/app/widget/columnedgridlayout/columnedgridlayout.h @@ -19,8 +19,8 @@ ***/ -#ifndef COLUMNEDGRIDLAYOUT_H -#define COLUMNEDGRIDLAYOUT_H +#ifndef OAK_COLUMNEDGRIDLAYOUT_H +#define OAK_COLUMNEDGRIDLAYOUT_H #include @@ -40,9 +40,9 @@ class ColumnedGridLayout : public QGridLayout { public: ColumnedGridLayout(QWidget *parent = nullptr, int maximum_columns = 0); - void Add(QWidget *widget); - int MaximumColumns() const; - void SetMaximumColumns(int maximum_columns); + void add(QWidget *widget); + int maximum_columns() const; + void set_maximum_columns(int maximum_columns); private: int maximum_columns_; @@ -50,4 +50,4 @@ private: } -#endif // COLUMNEDGRIDLAYOUT_H +#endif // OAK_COLUMNEDGRIDLAYOUT_H diff --git a/app/widget/curvewidget/curveview.cpp b/app/widget/curvewidget/curveview.cpp index cc044ae91..f599a0120 100644 --- a/app/widget/curvewidget/curveview.cpp +++ b/app/widget/curvewidget/curveview.cpp @@ -43,17 +43,17 @@ CurveView::CurveView(QWidget *parent) , dragging_bezier_pt_(nullptr) { setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - SetYAxisEnabled(true); - SetAutoSelectSiblings(false); + set_y_axis_enabled(true); + set_auto_select_siblings(false); text_padding_ = - QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("i")); + QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("i")); minimum_grid_space_ = - QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("00000")); + QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("00000")); } -void CurveView::ConnectInput(const NodeKeyframeTrackReference &ref) +void CurveView::connect_input(const NodeKeyframeTrackReference &ref) { if (connected_inputs_.contains(ref)) { // Input wasn't connected, do nothing @@ -61,19 +61,19 @@ void CurveView::ConnectInput(const NodeKeyframeTrackReference &ref) } // Add keyframes from track - KeyframeViewInputConnection *track_con = AddKeyframesOfTrack(ref); - track_con->SetBrush(keyframe_colors_.value(ref)); + KeyframeViewInputConnection *track_con = add_keyframes_of_track(ref); + track_con->set_brush(keyframe_colors_.value(ref)); track_connections_.insert(ref, track_con); // Signal to CurveWidget to update its bezier/linear/hold buttons if a key type changes - connect(track_con, &KeyframeViewInputConnection::TypeChanged, this, - &CurveView::SelectionChanged); + connect(track_con, &KeyframeViewInputConnection::type_changed, this, + &CurveView::selection_changed); // Append to the list connected_inputs_.append(ref); } -void CurveView::DisconnectInput(const NodeKeyframeTrackReference &ref) +void CurveView::disconnect_input(const NodeKeyframeTrackReference &ref) { if (!connected_inputs_.contains(ref)) { // Input wasn't connected, do nothing @@ -81,24 +81,24 @@ void CurveView::DisconnectInput(const NodeKeyframeTrackReference &ref) } // Remove keyframes belonging to this element and track - RemoveKeyframesOfTrack(track_connections_.take(ref)); + remove_keyframes_of_track(track_connections_.take(ref)); // Remove from the list connected_inputs_.removeOne(ref); } -void CurveView::SelectKeyframesOfInput(const NodeKeyframeTrackReference &ref) +void CurveView::select_keyframes_of_input(const NodeKeyframeTrackReference &ref) { - DeselectAll(); + deselect_all(); if (KeyframeViewInputConnection *con = track_connections_.value(ref)) { - foreach (NodeKeyframe *key, con->GetKeyframes()) { - SelectKeyframe(key); + foreach (NodeKeyframe *key, con->get_keyframes()) { + select_keyframe(key); } } } -void CurveView::SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref, +void CurveView::set_keyframe_track_color(const NodeKeyframeTrackReference &ref, const QColor &color) { // Insert color into hashmap @@ -106,7 +106,7 @@ void CurveView::SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref, if (KeyframeViewInputConnection *con = track_connections_.value(ref)) { // Update all keyframes - con->SetBrush(color); + con->set_brush(color); } } @@ -120,7 +120,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) QVector lines; - double x_interval = timebase().flipped().toDouble(); + double x_interval = timebase().flipped().to_double(); double y_interval = 100.0; int x_grid_interval, y_grid_interval; @@ -128,12 +128,12 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) painter->setPen(QPen(palette().window().color(), 1)); do { - x_grid_interval = qRound(x_interval * GetScale() * timebase_dbl()); + x_grid_interval = qRound(x_interval * get_scale() * timebase_dbl()); x_interval *= 2.0; } while (x_grid_interval < minimum_grid_space_); do { - y_grid_interval = qRound(y_interval * GetYScale()); + y_grid_interval = qRound(y_interval * get_y_scale()); y_interval *= 2.0; } while (y_grid_interval < minimum_grid_space_); @@ -146,7 +146,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) // Add vertical lines for (int i = x_start; i < rect.right(); i += x_grid_interval) { int value = - qRound(static_cast(i) / GetScale() / timebase_dbl()); + qRound(static_cast(i) / get_scale() / timebase_dbl()); painter->drawText(i + text_padding_, qRound(scene_bottom_left.y()) - text_padding_, QString::number(value)); @@ -155,7 +155,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) // Add horizontal lines for (int i = y_start; i < rect.bottom(); i += y_grid_interval) { - int value = qRound(static_cast(i) / GetYScale()); + int value = qRound(static_cast(i) / get_y_scale()); painter->drawText(qRound(scene_bottom_left.x()) + text_padding_, i - text_padding_, QString::number(-value)); lines.append(QLine(qRound(rect.left()), i, qRound(rect.right()), i)); @@ -169,9 +169,9 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) Node *node = ref.input().node(); const QString &input = ref.input().input(); - if (node->IsInputKeyframing(input, ref.input().element())) { + if (node->is_input_keyframing(input, ref.input().element())) { const QVector &tracks = - node->GetKeyframeTracks(ref.input()); + node->get_keyframe_tracks(ref.input()); const NodeKeyframeTrack &track = tracks.at(ref.track()); @@ -183,7 +183,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) QPainterPath path; // Draw straight line leading to first keyframe - QPointF first_key_pos = GetKeyframePosition(track.first()); + QPointF first_key_pos = get_keyframe_position(track.first()); path.moveTo(QPointF(scene_bottom_left.x(), first_key_pos.y())); path.lineTo(first_key_pos); @@ -192,16 +192,16 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) NodeKeyframe *before = track.at(i - 1); NodeKeyframe *after = track.at(i); - QPointF before_pos = GetKeyframePosition(before); - QPointF after_pos = GetKeyframePosition(after); + QPointF before_pos = get_keyframe_position(before); + QPointF after_pos = get_keyframe_position(after); - if (before->type() == NodeKeyframe::kHold) { + if (before->type() == NodeKeyframe::k_hold) { // Draw a hold keyframe (basically a right angle) path.lineTo(after_pos.x(), before_pos.y()); path.lineTo(after_pos.x(), after_pos.y()); - } else if (before->type() == NodeKeyframe::kBezier && - after->type() == NodeKeyframe::kBezier) { + } else if (before->type() == NodeKeyframe::k_bezier && + after->type() == NodeKeyframe::k_bezier) { // Draw a cubic bezier // Cubic beziers have two control points, so we can just use both @@ -215,15 +215,15 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) path.cubicTo(before_control_point, after_control_point, after_pos); - } else if (before->type() == NodeKeyframe::kBezier || - after->type() == NodeKeyframe::kBezier) { + } else if (before->type() == NodeKeyframe::k_bezier || + after->type() == NodeKeyframe::k_bezier) { // Draw a quadratic bezier // Quadratic beziers have a single control point, we just have to determine which it is QPointF key_anchor; QPointF control_point; - if (before->type() == NodeKeyframe::kBezier) { + if (before->type() == NodeKeyframe::k_bezier) { key_anchor = before_pos; control_point = before->valid_bezier_control_out(); } else { @@ -244,7 +244,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect) } // Draw straight line leading from end keyframe - QPointF last_key_pos = GetKeyframePosition(track.last()); + QPointF last_key_pos = get_keyframe_position(track.last()); path.lineTo(QPointF(scene_top_right.x(), last_key_pos.y())); painter->drawPath(path); @@ -264,15 +264,15 @@ void CurveView::ContextMenuEvent(Menu &m) { // View settings QAction *zoom_fit_action = m.addAction(tr("Zoom to Fit")); - connect(zoom_fit_action, &QAction::triggered, this, &CurveView::ZoomToFit); + connect(zoom_fit_action, &QAction::triggered, this, &CurveView::zoom_to_fit); QAction *zoom_fit_selected_action = m.addAction(tr("Zoom to Fit Selected")); connect(zoom_fit_selected_action, &QAction::triggered, this, - &CurveView::ZoomToFitSelected); + &CurveView::zoom_to_fit_selected); QAction *reset_zoom_action = m.addAction(tr("Reset Zoom")); connect(reset_zoom_action, &QAction::triggered, this, - &CurveView::ResetZoom); + &CurveView::reset_zoom); } void CurveView::SceneRectUpdateEvent(QRectF &r) @@ -281,8 +281,8 @@ void CurveView::SceneRectUpdateEvent(QRectF &r) bool got_val = false; foreach (KeyframeViewInputConnection *con, track_connections_) { - foreach (NodeKeyframe *key, con->GetKeyframes()) { - qreal key_y = GetItemYFromKeyframeValue(key); + foreach (NodeKeyframe *key, con->get_keyframes()) { + qreal key_y = get_item_y_from_keyframe_value(key); if (got_val) { min_val = qMin(key_y, min_val); @@ -301,19 +301,19 @@ void CurveView::SceneRectUpdateEvent(QRectF &r) } } -qreal CurveView::GetKeyframeSceneY(KeyframeViewInputConnection *track, +qreal CurveView::get_keyframe_scene_y(KeyframeViewInputConnection *track, NodeKeyframe *key) { - return GetItemYFromKeyframeValue(key); + return get_item_y_from_keyframe_value(key); } -void CurveView::DrawKeyframe(QPainter *painter, NodeKeyframe *key, +void CurveView::draw_keyframe(QPainter *painter, NodeKeyframe *key, KeyframeViewInputConnection *track, const QRectF &key_rect) { - if (IsKeyframeSelected(key) && key->type() == NodeKeyframe::kBezier) { + if (is_keyframe_selected(key) && key->type() == NodeKeyframe::k_bezier) { // Draw bezier control points if keyframe is selected - int control_point_size = QtUtils::QFontMetricsWidth(fontMetrics(), "o"); + int control_point_size = QtUtils::q_font_metrics_width(fontMetrics(), "o"); int half_sz = control_point_size / 2; QRectF control_point_rect(-half_sz, -half_sz, control_point_size, control_point_size); @@ -332,14 +332,14 @@ void CurveView::DrawKeyframe(QPainter *painter, NodeKeyframe *key, painter->drawEllipse(cp_in); painter->drawEllipse(cp_out); - bezier_pts_.append({ cp_in, key, NodeKeyframe::kInHandle }); - bezier_pts_.append({ cp_out, key, NodeKeyframe::kOutHandle }); + bezier_pts_.append({ cp_in, key, NodeKeyframe::k_in_handle }); + bezier_pts_.append({ cp_out, key, NodeKeyframe::k_out_handle }); } - super::DrawKeyframe(painter, key, track, key_rect); + super::draw_keyframe(painter, key, track, key_rect); } -bool CurveView::FirstChanceMousePress(QMouseEvent *event) +bool CurveView::first_chance_mouse_press(QMouseEvent *event) { dragging_bezier_pt_ = nullptr; QPointF scene_pt = mapToScene(event->pos()); @@ -353,11 +353,11 @@ bool CurveView::FirstChanceMousePress(QMouseEvent *event) if (dragging_bezier_pt_) { NodeKeyframe *key = dragging_bezier_pt_->keyframe; dragging_bezier_point_start_ = - (dragging_bezier_pt_->type == NodeKeyframe::kInHandle) ? + (dragging_bezier_pt_->type == NodeKeyframe::k_in_handle) ? key->bezier_control_in() : key->bezier_control_out(); dragging_bezier_point_opposing_start_ = - (dragging_bezier_pt_->type == NodeKeyframe::kInHandle) ? + (dragging_bezier_pt_->type == NodeKeyframe::k_in_handle) ? key->bezier_control_out() : key->bezier_control_in(); @@ -368,11 +368,11 @@ bool CurveView::FirstChanceMousePress(QMouseEvent *event) } } -void CurveView::FirstChanceMouseMove(QMouseEvent *event) +void CurveView::first_chance_mouse_move(QMouseEvent *event) { // Calculate cursor difference and scale it QPointF scene_pos = mapToScene(event->pos()); - QPointF mouse_diff_scaled = GetScaledCursorPos(scene_pos - drag_start_); + QPointF mouse_diff_scaled = get_scaled_cursor_pos(scene_pos - drag_start_); if (event->modifiers() & Qt::ShiftModifier) { // If holding shift, only move one axis @@ -382,7 +382,7 @@ void CurveView::FirstChanceMouseMove(QMouseEvent *event) // Flip the mouse Y because bezier control points are drawn bottom to top, not top to bottom mouse_diff_scaled.setY(-mouse_diff_scaled.y()); - QPointF new_bezier_pos = GenerateBezierControlPosition( + QPointF new_bezier_pos = generate_bezier_control_position( dragging_bezier_pt_->type, dragging_bezier_point_start_, mouse_diff_scaled); @@ -392,7 +392,7 @@ void CurveView::FirstChanceMouseMove(QMouseEvent *event) NodeKeyframe::get_opposing_bezier_type(dragging_bezier_pt_->type); if (!(event->modifiers() & Qt::ControlModifier)) { - new_opposing_pos = GenerateBezierControlPosition( + new_opposing_pos = generate_bezier_control_position( opposing_type, dragging_bezier_point_opposing_start_, -mouse_diff_scaled); } else { @@ -405,10 +405,10 @@ void CurveView::FirstChanceMouseMove(QMouseEvent *event) dragging_bezier_pt_->keyframe->set_bezier_control(opposing_type, new_opposing_pos); - Redraw(); + redraw(); } -void CurveView::FirstChanceMouseRelease(QMouseEvent *event) +void CurveView::first_chance_mouse_release(QMouseEvent *event) { MultiUndoCommand *command = new MultiUndoCommand(); @@ -434,23 +434,23 @@ void CurveView::FirstChanceMouseRelease(QMouseEvent *event) command, tr("Moved Keyframe Bezier Control Point")); } -void CurveView::KeyframeDragStart(QMouseEvent *event) +void CurveView::keyframe_drag_start(QMouseEvent *event) { - drag_keyframe_values_.resize(GetSelectedKeyframes().size()); - for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) { - NodeKeyframe *key = GetSelectedKeyframes().at(i); + drag_keyframe_values_.resize(get_selected_keyframes().size()); + for (size_t i = 0; i < get_selected_keyframes().size(); i++) { + NodeKeyframe *key = get_selected_keyframes().at(i); drag_keyframe_values_[i] = key->value(); } drag_start_ = mapToScene(event->pos()); } -void CurveView::KeyframeDragMove(QMouseEvent *event, QString &tip) +void CurveView::keyframe_drag_move(QMouseEvent *event, QString &tip) { if (event->modifiers() & Qt::ShiftModifier) { // Lock to X axis only and set original values on all keys - for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) { - NodeKeyframe *key = GetSelectedKeyframes().at(i); + for (size_t i = 0; i < get_selected_keyframes().size(); i++) { + NodeKeyframe *key = get_selected_keyframes().at(i); key->set_value(drag_keyframe_values_.at(i)); } return; @@ -458,31 +458,31 @@ void CurveView::KeyframeDragMove(QMouseEvent *event, QString &tip) // Calculate cursor difference double scaled_diff = - (mapToScene(event->pos()).y() - drag_start_.y()) / GetYScale(); + (mapToScene(event->pos()).y() - drag_start_.y()) / get_y_scale(); // Validate movement - ensure no keyframe goes above its max point or below its min point - for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) { - NodeKeyframe *key = GetSelectedKeyframes().at(i); + for (size_t i = 0; i < get_selected_keyframes().size(); i++) { + NodeKeyframe *key = get_selected_keyframes().at(i); - FloatSlider::DisplayType display = GetFloatDisplayTypeFromKeyframe(key); + FloatSlider::DisplayType display = get_float_display_type_from_keyframe(key); Node *node = key->parent(); - double original_val = FloatSlider::TransformValueToDisplay( + double original_val = FloatSlider::transform_value_to_display( drag_keyframe_values_.at(i).toDouble(), display); const QString &input = key->input(); - double new_val = FloatSlider::TransformDisplayToValue( + double new_val = FloatSlider::transform_display_to_value( original_val - scaled_diff, display); double limited = new_val; - if (node->HasInputProperty(input, QStringLiteral("min"))) { + if (node->has_input_property(input, QStringLiteral("min"))) { limited = qMax( limited, - node->GetInputProperty(input, QStringLiteral("min")).toDouble()); + node->get_input_property(input, QStringLiteral("min")).toDouble()); } - if (node->HasInputProperty(input, QStringLiteral("max"))) { + if (node->has_input_property(input, QStringLiteral("max"))) { limited = qMin( limited, - node->GetInputProperty(input, QStringLiteral("max")).toDouble()); + node->get_input_property(input, QStringLiteral("max")).toDouble()); } if (limited != new_val) { @@ -491,34 +491,34 @@ void CurveView::KeyframeDragMove(QMouseEvent *event, QString &tip) } // Set values - for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) { - NodeKeyframe *key = GetSelectedKeyframes().at(i); - FloatSlider::DisplayType display = GetFloatDisplayTypeFromKeyframe(key); - key->set_value(FloatSlider::TransformDisplayToValue( - FloatSlider::TransformValueToDisplay( + for (size_t i = 0; i < get_selected_keyframes().size(); i++) { + NodeKeyframe *key = get_selected_keyframes().at(i); + FloatSlider::DisplayType display = get_float_display_type_from_keyframe(key); + key->set_value(FloatSlider::transform_display_to_value( + FloatSlider::transform_value_to_display( drag_keyframe_values_.at(i).toDouble(), display) - scaled_diff, display)); } - NodeKeyframe *tip_item = GetSelectedKeyframes().front(); + NodeKeyframe *tip_item = get_selected_keyframes().front(); bool ok; double num_value = tip_item->value().toDouble(&ok); if (ok) { tip = QStringLiteral("%1\n"); - tip.append(FloatSlider::ValueToString( - num_value + GetOffsetFromKeyframe(tip_item), - GetFloatDisplayTypeFromKeyframe(tip_item), 2, true)); + tip.append(FloatSlider::value_to_string( + num_value + get_offset_from_keyframe(tip_item), + get_float_display_type_from_keyframe(tip_item), 2, true)); } } -void CurveView::KeyframeDragRelease(QMouseEvent *event, +void CurveView::keyframe_drag_release(QMouseEvent *event, MultiUndoCommand *command) { - for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) { - NodeKeyframe *k = GetSelectedKeyframes().at(i); + for (size_t i = 0; i < get_selected_keyframes().size(); i++) { + NodeKeyframe *k = get_selected_keyframes().at(i); if (!qFuzzyCompare(k->value().toDouble(), drag_keyframe_values_.at(i).toDouble())) { command->add_child(new NodeParamSetKeyframeValueCommand( @@ -528,7 +528,7 @@ void CurveView::KeyframeDragRelease(QMouseEvent *event, } QPointF -CurveView::GenerateBezierControlPosition(const NodeKeyframe::BezierType mode, +CurveView::generate_bezier_control_position(const NodeKeyframe::BezierType mode, const QPointF &start_point, const QPointF &scaled_cursor_diff) { @@ -537,7 +537,7 @@ CurveView::GenerateBezierControlPosition(const NodeKeyframe::BezierType mode, new_bezier_pos += scaled_cursor_diff; // LIMIT bezier handles from overlapping each other - if (mode == NodeKeyframe::kInHandle) { + if (mode == NodeKeyframe::k_in_handle) { if (new_bezier_pos.x() > 0) { new_bezier_pos.setX(0); } @@ -550,26 +550,26 @@ CurveView::GenerateBezierControlPosition(const NodeKeyframe::BezierType mode, return new_bezier_pos; } -QPointF CurveView::GetScaledCursorPos(const QPointF &cursor_pos) +QPointF CurveView::get_scaled_cursor_pos(const QPointF &cursor_pos) { - return QPointF(cursor_pos.x() / GetScale(), cursor_pos.y() / GetYScale()); + return QPointF(cursor_pos.x() / get_scale(), cursor_pos.y() / get_y_scale()); } -void CurveView::ZoomToFitInternal(bool selected_only) +void CurveView::zoom_to_fit_internal(bool selected_only) { bool got_val = false; - rational min_time, max_time; + Rational min_time, max_time; double min_val, max_val; foreach (KeyframeViewInputConnection *con, track_connections_) { - foreach (NodeKeyframe *key, con->GetKeyframes()) { - if (!selected_only || IsKeyframeSelected(key)) { - rational transformed_time = - GetAdjustedTime(key->parent(), GetTimeTarget(), key->time(), - Node::kTransformTowardsOutput); + foreach (NodeKeyframe *key, con->get_keyframes()) { + if (!selected_only || is_keyframe_selected(key)) { + Rational transformed_time = + get_adjusted_time(key->parent(), get_time_target(), key->time(), + Node::k_transform_towards_output); - qreal key_y = GetUnscaledItemYFromKeyframeValue(key); + qreal key_y = get_unscaled_item_y_from_keyframe_value(key); if (got_val) { min_time = qMin(transformed_time, min_time); @@ -592,8 +592,8 @@ void CurveView::ZoomToFitInternal(bool selected_only) // Prevent scaling if no keyframes were found if (got_val) { - QRectF desired(QPointF(min_time.toDouble(), min_val), - QPointF(max_time.toDouble(), max_val)); + QRectF desired(QPointF(min_time.to_double(), min_val), + QPointF(max_time.to_double(), max_val)); const double scale_divider = 0.5; double scale_half_divider = scale_divider * 0.5; @@ -612,10 +612,10 @@ void CurveView::ZoomToFitInternal(bool selected_only) viewport()->height() / desired.height() * scale_divider; } - emit ScaleChanged(new_x_scale); - SetYScale(new_y_scale); + emit scale_changed(new_x_scale); + set_y_scale(new_y_scale); - UpdateSceneRect(); + update_scene_rect(); int sb_x = desired.left() * new_x_scale - viewport()->width() * scale_half_divider; @@ -629,19 +629,19 @@ void CurveView::ZoomToFitInternal(bool selected_only) } } -qreal CurveView::GetItemYFromKeyframeValue(NodeKeyframe *key) +qreal CurveView::get_item_y_from_keyframe_value(NodeKeyframe *key) { - return GetUnscaledItemYFromKeyframeValue(key) * GetYScale(); + return get_unscaled_item_y_from_keyframe_value(key) * get_y_scale(); } -qreal CurveView::GetUnscaledItemYFromKeyframeValue(NodeKeyframe *key) +qreal CurveView::get_unscaled_item_y_from_keyframe_value(NodeKeyframe *key) { double val = key->value().toDouble(); - val = FloatSlider::TransformValueToDisplay( - val, GetFloatDisplayTypeFromKeyframe(key)); + val = FloatSlider::transform_value_to_display( + val, get_float_display_type_from_keyframe(key)); - val += GetOffsetFromKeyframe(key); + val += get_offset_from_keyframe(key); return -val; } @@ -649,35 +649,35 @@ qreal CurveView::GetUnscaledItemYFromKeyframeValue(NodeKeyframe *key) QPointF CurveView::ScalePoint(const QPointF &point) { // Flips Y coordinate because curves are drawn bottom to top - return QPointF(point.x() * GetScale(), -point.y() * GetYScale()); + return QPointF(point.x() * get_scale(), -point.y() * get_y_scale()); } FloatSlider::DisplayType -CurveView::GetFloatDisplayTypeFromKeyframe(NodeKeyframe *key) +CurveView::get_float_display_type_from_keyframe(NodeKeyframe *key) { Node *node = key->parent(); const QString &input = key->input(); - if (node->HasInputProperty(input, QStringLiteral("view"))) { + if (node->has_input_property(input, QStringLiteral("view"))) { // Try to get view from input (which will be normal if unset) return static_cast( - node->GetInputProperty(input, QStringLiteral("view")).toInt()); + node->get_input_property(input, QStringLiteral("view")).toInt()); } // Fallback to normal - return FloatSlider::kNormal; + return FloatSlider::k_normal; } -double CurveView::GetOffsetFromKeyframe(NodeKeyframe *key) +double CurveView::get_offset_from_keyframe(NodeKeyframe *key) { Node *node = key->parent(); const QString &input = key->input(); - if (node->HasInputProperty(input, QStringLiteral("offset"))) { - QVariant v = node->GetInputProperty(input, QStringLiteral("offset")); + if (node->has_input_property(input, QStringLiteral("offset"))) { + QVariant v = node->get_input_property(input, QStringLiteral("offset")); // NOTE: Implement getting correct offset for the track based on the data type QVector track_vals = NodeValue::split_normal_value_into_track_values( - node->GetInputDataType(input), v); + node->get_input_data_type(input), v); return track_vals.at(key->track()).toDouble(); } @@ -685,25 +685,25 @@ double CurveView::GetOffsetFromKeyframe(NodeKeyframe *key) return 0; } -QPointF CurveView::GetKeyframePosition(NodeKeyframe *key) +QPointF CurveView::get_keyframe_position(NodeKeyframe *key) { - return QPointF(GetKeyframeSceneX(key), GetItemYFromKeyframeValue(key)); + return QPointF(get_keyframe_scene_x(key), get_item_y_from_keyframe_value(key)); } -void CurveView::ZoomToFit() +void CurveView::zoom_to_fit() { - ZoomToFitInternal(false); + zoom_to_fit_internal(false); } -void CurveView::ZoomToFitSelected() +void CurveView::zoom_to_fit_selected() { - ZoomToFitInternal(true); + zoom_to_fit_internal(true); } -void CurveView::ResetZoom() +void CurveView::reset_zoom() { - emit ScaleChanged(1.0); - SetYScale(1.0); + emit scale_changed(1.0); + set_y_scale(1.0); } } diff --git a/app/widget/curvewidget/curveview.h b/app/widget/curvewidget/curveview.h index e1e4f6b09..71e4f17bb 100644 --- a/app/widget/curvewidget/curveview.h +++ b/app/widget/curvewidget/curveview.h @@ -19,8 +19,8 @@ ***/ -#ifndef CURVEVIEW_H -#define CURVEVIEW_H +#ifndef OAK_CURVEVIEW_H +#define OAK_CURVEVIEW_H #include "node/keyframe.h" #include "widget/keyframeview/keyframeview.h" @@ -34,27 +34,27 @@ class CurveView : public KeyframeView { public: CurveView(QWidget *parent = nullptr); - void ConnectInput(const NodeKeyframeTrackReference &ref); + void connect_input(const NodeKeyframeTrackReference &ref); - void DisconnectInput(const NodeKeyframeTrackReference &ref); + void disconnect_input(const NodeKeyframeTrackReference &ref); - void SelectKeyframesOfInput(const NodeKeyframeTrackReference &ref); + void select_keyframes_of_input(const NodeKeyframeTrackReference &ref); - void SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref, + void set_keyframe_track_color(const NodeKeyframeTrackReference &ref, const QColor &color); const QHash & - GetConnections() const + get_connections() const { return track_connections_; } public slots: - void ZoomToFit(); + void zoom_to_fit(); - void ZoomToFitSelected(); + void zoom_to_fit_selected(); - void ResetZoom(); + void reset_zoom(); protected: virtual void drawBackground(QPainter *painter, const QRectF &rect) override; @@ -64,45 +64,45 @@ protected: virtual void SceneRectUpdateEvent(QRectF &r) override; - virtual qreal GetKeyframeSceneY(KeyframeViewInputConnection *track, + virtual qreal get_keyframe_scene_y(KeyframeViewInputConnection *track, NodeKeyframe *key) override; - virtual void DrawKeyframe(QPainter *painter, NodeKeyframe *key, + virtual void draw_keyframe(QPainter *painter, NodeKeyframe *key, KeyframeViewInputConnection *track, const QRectF &key_rect) override; - virtual bool FirstChanceMousePress(QMouseEvent *event) override; - virtual void FirstChanceMouseMove(QMouseEvent *event) override; - virtual void FirstChanceMouseRelease(QMouseEvent *event) override; + virtual bool first_chance_mouse_press(QMouseEvent *event) override; + virtual void first_chance_mouse_move(QMouseEvent *event) override; + virtual void first_chance_mouse_release(QMouseEvent *event) override; - virtual void KeyframeDragStart(QMouseEvent *event) override; - virtual void KeyframeDragMove(QMouseEvent *event, QString &tip) override; - virtual void KeyframeDragRelease(QMouseEvent *event, + virtual void keyframe_drag_start(QMouseEvent *event) override; + virtual void keyframe_drag_move(QMouseEvent *event, QString &tip) override; + virtual void keyframe_drag_release(QMouseEvent *event, MultiUndoCommand *command) override; private: - void ZoomToFitInternal(bool selected_only); + void zoom_to_fit_internal(bool selected_only); - qreal GetItemYFromKeyframeValue(NodeKeyframe *key); - qreal GetUnscaledItemYFromKeyframeValue(NodeKeyframe *key); + qreal get_item_y_from_keyframe_value(NodeKeyframe *key); + qreal get_unscaled_item_y_from_keyframe_value(NodeKeyframe *key); QPointF ScalePoint(const QPointF &point); static FloatSlider::DisplayType - GetFloatDisplayTypeFromKeyframe(NodeKeyframe *key); + get_float_display_type_from_keyframe(NodeKeyframe *key); - static double GetOffsetFromKeyframe(NodeKeyframe *key); + static double get_offset_from_keyframe(NodeKeyframe *key); - void AdjustLines(); + void adjust_lines(); - QPointF GetKeyframePosition(NodeKeyframe *key); + QPointF get_keyframe_position(NodeKeyframe *key); static QPointF - GenerateBezierControlPosition(const NodeKeyframe::BezierType mode, + generate_bezier_control_position(const NodeKeyframe::BezierType mode, const QPointF &start_point, const QPointF &scaled_cursor_diff); - QPointF GetScaledCursorPos(const QPointF &cursor_pos); + QPointF get_scaled_cursor_pos(const QPointF &cursor_pos); QHash keyframe_colors_; QHash @@ -132,4 +132,4 @@ private: } -#endif // CURVEVIEW_H +#endif // OAK_CURVEVIEW_H diff --git a/app/widget/curvewidget/curvewidget.cpp b/app/widget/curvewidget/curvewidget.cpp index e576f8314..a714917ae 100644 --- a/app/widget/curvewidget/curvewidget.cpp +++ b/app/widget/curvewidget/curvewidget.cpp @@ -47,10 +47,10 @@ CurveWidget::CurveWidget(QWidget *parent) outer_layout->addWidget(splitter); tree_view_ = new NodeTreeView(); - tree_view_->SetOnlyShowKeyframable(true); - tree_view_->SetShowKeyframeTracksAsRows(true); - connect(tree_view_, &NodeTreeView::InputSelectionChanged, this, - &CurveWidget::InputSelectionChanged); + tree_view_->set_only_show_keyframable(true); + tree_view_->set_show_keyframe_tracks_as_rows(true); + connect(tree_view_, &NodeTreeView::input_selection_changed, this, + &CurveWidget::input_selection_changed); splitter->addWidget(tree_view_); QWidget *workarea = new QWidget(); @@ -70,21 +70,21 @@ CurveWidget::CurveWidget(QWidget *parent) linear_button_->setEnabled(false); top_controls->addWidget(linear_button_); connect(linear_button_, &QPushButton::clicked, this, - &CurveWidget::KeyframeTypeButtonTriggered); + &CurveWidget::keyframe_type_button_triggered); bezier_button_ = new QPushButton(tr("Bezier")); bezier_button_->setCheckable(true); bezier_button_->setEnabled(false); top_controls->addWidget(bezier_button_); connect(bezier_button_, &QPushButton::clicked, this, - &CurveWidget::KeyframeTypeButtonTriggered); + &CurveWidget::keyframe_type_button_triggered); hold_button_ = new QPushButton(tr("Hold")); hold_button_->setCheckable(true); hold_button_->setEnabled(false); top_controls->addWidget(hold_button_); connect(hold_button_, &QPushButton::clicked, this, - &CurveWidget::KeyframeTypeButtonTriggered); + &CurveWidget::keyframe_type_button_triggered); layout->addLayout(top_controls); @@ -96,19 +96,19 @@ CurveWidget::CurveWidget(QWidget *parent) ruler_view_layout->addWidget(ruler()); view_ = new CurveView(); - ConnectTimelineView(view_); - view_->SetSnapService(this); + connect_timeline_view(view_); + view_->set_snap_service(this); ruler_view_layout->addWidget(view_); layout->addLayout(ruler_view_layout); // Connect ruler and view together - connect(view_, &CurveView::SelectionChanged, this, - &CurveWidget::SelectionChanged); - connect(view_, &CurveView::Dragged, this, - &CurveWidget::KeyframeViewDragged); - connect(view_, &CurveView::Released, this, - &CurveWidget::KeyframeViewReleased); + connect(view_, &CurveView::selection_changed, this, + &CurveWidget::selection_changed); + connect(view_, &CurveView::dragged, this, + &CurveWidget::keyframe_view_dragged); + connect(view_, &CurveView::released, this, + &CurveWidget::keyframe_view_released); // TimeBasedWidget's scrollbar has extra functionality that we can take advantage of view_->setHorizontalScrollBar(scrollbar()); @@ -119,25 +119,25 @@ CurveWidget::CurveWidget(QWidget *parent) SetScale(120.0); } -const double &CurveWidget::GetVerticalScale() +const double &CurveWidget::get_vertical_scale() { - return view_->GetYScale(); + return view_->get_y_scale(); } -void CurveWidget::SetVerticalScale(const double &vscale) +void CurveWidget::set_vertical_scale(const double &vscale) { - view_->SetYScale(vscale); + view_->set_y_scale(vscale); } void CurveWidget::DeleteSelected() { - view_->DeleteSelected(); + view_->delete_selected(); } -Node *CurveWidget::GetSelectedNodeWithID(const QString &id) +Node *CurveWidget::get_selected_node_with_id(const QString &id) { - for (auto it = view_->GetConnections().cbegin(); - it != view_->GetConnections().cend(); it++) { + for (auto it = view_->get_connections().cbegin(); + it != view_->get_connections().cend(); it++) { Node *n = it.key().input().node(); if (n->id() == id) { return n; @@ -147,28 +147,28 @@ Node *CurveWidget::GetSelectedNodeWithID(const QString &id) return nullptr; } -bool CurveWidget::CopySelected(bool cut) +bool CurveWidget::copy_selected(bool cut) { - if (super::CopySelected(cut)) { + if (super::copy_selected(cut)) { return true; } - return view_->CopySelected(cut); + return view_->copy_selected(cut); } -bool CurveWidget::Paste() +bool CurveWidget::paste() { - if (super::Paste()) { + if (super::paste()) { return true; } - return view_->Paste(std::bind(&CurveWidget::GetSelectedNodeWithID, this, + return view_->paste(std::bind(&CurveWidget::get_selected_node_with_id, this, std::placeholders::_1)); } -void CurveWidget::SetNodes(const QVector &nodes) +void CurveWidget::set_nodes(const QVector &nodes) { - tree_view_->SetNodes(nodes); + tree_view_->set_nodes(nodes); // Save new node list nodes_ = nodes; @@ -176,13 +176,13 @@ void CurveWidget::SetNodes(const QVector &nodes) // Generate colors foreach (Node *node, nodes_) { foreach (const QString &input, node->inputs()) { - if (node->IsInputKeyframable(input) && - !node->IsInputHidden(input)) { - int arr_sz = node->InputArraySize(input); + if (node->is_input_keyframable(input) && + !node->is_input_hidden(input)) { + int arr_sz = node->input_array_size(input); for (int i = -1; i < arr_sz; i++) { // Generate a random color for this input const QVector &tracks = - node->GetKeyframeTracks(input, i); + node->get_keyframe_tracks(input, i); for (int j = 0; j < tracks.size(); j++) { NodeKeyframeTrackReference ref( @@ -193,8 +193,8 @@ void CurveWidget::SetNodes(const QVector &nodes) QColor::fromHsl(std::rand() % 360, 255, 160); keyframe_colors_.insert(ref, c); - tree_view_->SetKeyframeTrackColor(ref, c); - view_->SetKeyframeTrackColor(ref, c); + tree_view_->set_keyframe_track_color(ref, c); + view_->set_keyframe_track_color(ref, c); } } } @@ -203,92 +203,92 @@ void CurveWidget::SetNodes(const QVector &nodes) } } -void CurveWidget::TimebaseChangedEvent(const rational &timebase) +void CurveWidget::TimebaseChangedEvent(const Rational &timebase) { super::TimebaseChangedEvent(timebase); - view_->SetTimebase(timebase); + view_->set_timebase(timebase); } void CurveWidget::ScaleChangedEvent(const double &scale) { super::ScaleChangedEvent(scale); - view_->SetScale(scale); + view_->set_scale(scale); } void CurveWidget::TimeTargetChangedEvent(ViewerOutput *target) { TimeTargetObject::TimeTargetChangedEvent(target); - key_control_->SetTimeTarget(target); + key_control_->set_time_target(target); - view_->SetTimeTarget(target); + view_->set_time_target(target); } void CurveWidget::ConnectedNodeChangeEvent(ViewerOutput *n) { super::ConnectedNodeChangeEvent(n); - key_control_->SetTimeTarget(n); + key_control_->set_time_target(n); - SetTimeTarget(n); + set_time_target(n); } -void CurveWidget::SetKeyframeButtonEnabled(bool enable) +void CurveWidget::set_keyframe_button_enabled(bool enable) { linear_button_->setEnabled(enable); bezier_button_->setEnabled(enable); hold_button_->setEnabled(enable); } -void CurveWidget::SetKeyframeButtonChecked(bool checked) +void CurveWidget::set_keyframe_button_checked(bool checked) { linear_button_->setChecked(checked); bezier_button_->setChecked(checked); hold_button_->setChecked(checked); } -void CurveWidget::SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type) +void CurveWidget::set_keyframe_button_checked_from_type(NodeKeyframe::Type type) { - linear_button_->setChecked(type == NodeKeyframe::kLinear); - bezier_button_->setChecked(type == NodeKeyframe::kBezier); - hold_button_->setChecked(type == NodeKeyframe::kHold); + linear_button_->setChecked(type == NodeKeyframe::k_linear); + bezier_button_->setChecked(type == NodeKeyframe::k_bezier); + hold_button_->setChecked(type == NodeKeyframe::k_hold); } -void CurveWidget::ConnectInput(Node *node, const QString &input, int element) +void CurveWidget::connect_input(Node *node, const QString &input, int element) { - if (element == -1 && node->InputIsArray(input)) { + if (element == -1 && node->input_is_array(input)) { // This is the root element, connect all elements (if applicable) - int arr_sz = node->InputArraySize(input); + int arr_sz = node->input_array_size(input); for (int i = -1; i < arr_sz; i++) { - ConnectInputInternal(node, input, i); + connect_input_internal(node, input, i); } } else { // This is a single element, just connect it as-is - ConnectInputInternal(node, input, element); + connect_input_internal(node, input, element); } } -void CurveWidget::ConnectInputInternal(Node *node, const QString &input, +void CurveWidget::connect_input_internal(Node *node, const QString &input, int element) { NodeInput input_ref(node, input, element); int track_count = - NodeValue::get_number_of_keyframe_tracks(input_ref.GetDataType()); + NodeValue::get_number_of_keyframe_tracks(input_ref.get_data_type()); for (int i = 0; i < track_count; i++) { NodeKeyframeTrackReference track_ref(input_ref, i); - view_->ConnectInput(track_ref); + view_->connect_input(track_ref); selected_tracks_.append(track_ref); } } -void CurveWidget::SelectionChanged() +void CurveWidget::selection_changed() { - const std::vector &selected = view_->GetSelectedKeyframes(); + const std::vector &selected = view_->get_selected_keyframes(); - SetKeyframeButtonChecked(false); - SetKeyframeButtonEnabled(!selected.empty()); + set_keyframe_button_checked(false); + set_keyframe_button_enabled(!selected.empty()); if (!selected.empty()) { bool all_same_type = true; @@ -305,12 +305,12 @@ void CurveWidget::SelectionChanged() } if (all_same_type) { - SetKeyframeButtonCheckedFromType(type); + set_keyframe_button_checked_from_type(type); } } } -void CurveWidget::KeyframeTypeButtonTriggered(bool checked) +void CurveWidget::keyframe_type_button_triggered(bool checked) { QPushButton *key_btn = static_cast(sender()); @@ -321,7 +321,7 @@ void CurveWidget::KeyframeTypeButtonTriggered(bool checked) } // Get selected items and do nothing if there are none - const std::vector &selected = view_->GetSelectedKeyframes(); + const std::vector &selected = view_->get_selected_keyframes(); if (selected.empty()) { return; } @@ -331,15 +331,15 @@ void CurveWidget::KeyframeTypeButtonTriggered(bool checked) // Determine which type to set if (key_btn == bezier_button_) { - new_type = NodeKeyframe::kBezier; + new_type = NodeKeyframe::k_bezier; } else if (key_btn == hold_button_) { - new_type = NodeKeyframe::kHold; + new_type = NodeKeyframe::k_hold; } else { - new_type = NodeKeyframe::kLinear; + new_type = NodeKeyframe::k_linear; } // Ensure only the appropriate button is checked - SetKeyframeButtonCheckedFromType(new_type); + set_keyframe_button_checked_from_type(new_type); MultiUndoCommand *command = new MultiUndoCommand(); @@ -351,47 +351,47 @@ void CurveWidget::KeyframeTypeButtonTriggered(bool checked) command, tr("Changed Type of %1 Keyframe(s) to %2")); } -void CurveWidget::InputSelectionChanged(const NodeKeyframeTrackReference &ref) +void CurveWidget::input_selection_changed(const NodeKeyframeTrackReference &ref) { - key_control_->SetInput(ref.input()); + key_control_->set_input(ref.input()); foreach (const NodeKeyframeTrackReference &c, selected_tracks_) { - view_->DisconnectInput(c); + view_->disconnect_input(c); } selected_tracks_.clear(); - if (ref.IsValid() && !ref.input().IsArray()) { + if (ref.is_valid() && !ref.input().is_array()) { // This reference is a track, connect it only - view_->ConnectInput(ref); + view_->connect_input(ref); selected_tracks_.append(ref); - } else if (ref.input().IsValid()) { + } else if (ref.input().is_valid()) { // This reference is a input, connect all tracks - ConnectInput(ref.input().node(), ref.input().input(), + connect_input(ref.input().node(), ref.input().input(), ref.input().element()); } else if (Node *node = ref.input().node()) { // This is a node, add all inputs foreach (const QString &input, node->inputs()) { - if (node->IsInputKeyframable(input) && - !node->IsInputHidden(input)) { - ConnectInput(node, input, -1); + if (node->is_input_keyframable(input) && + !node->is_input_hidden(input)) { + connect_input(node, input, -1); } } } - view_->ZoomToFit(); + view_->zoom_to_fit(); } -void CurveWidget::KeyframeViewDragged(int x, int y) +void CurveWidget::keyframe_view_dragged(int x, int y) { - SetCatchUpScrollValue(x); - SetCatchUpScrollValue(view_->verticalScrollBar(), y, view_->height()); + set_catch_up_scroll_value(x); + set_catch_up_scroll_value(view_->verticalScrollBar(), y, view_->height()); } -void CurveWidget::KeyframeViewReleased() +void CurveWidget::keyframe_view_released() { - StopCatchUpScrollTimer(); - StopCatchUpScrollTimer(view_->verticalScrollBar()); + stop_catch_up_scroll_timer(); + stop_catch_up_scroll_timer(view_->verticalScrollBar()); } } diff --git a/app/widget/curvewidget/curvewidget.h b/app/widget/curvewidget/curvewidget.h index 54c512fe6..ca80b67b3 100644 --- a/app/widget/curvewidget/curvewidget.h +++ b/app/widget/curvewidget/curvewidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef CURVEWIDGET_H -#define CURVEWIDGET_H +#ifndef OAK_CURVEWIDGET_H +#define OAK_CURVEWIDGET_H #include #include @@ -41,32 +41,32 @@ class CurveWidget : public TimeBasedWidget, public TimeTargetObject { public: CurveWidget(QWidget *parent = nullptr); - const double &GetVerticalScale(); - void SetVerticalScale(const double &vscale); + const double &get_vertical_scale(); + void set_vertical_scale(const double &vscale); void DeleteSelected(); - void SelectAll() + void select_all() { - view_->SelectAll(); + view_->select_all(); } - void DeselectAll() + void deselect_all() { - view_->DeselectAll(); + view_->deselect_all(); } - Node *GetSelectedNodeWithID(const QString &id); + Node *get_selected_node_with_id(const QString &id); - virtual bool CopySelected(bool cut) override; + virtual bool copy_selected(bool cut) override; - virtual bool Paste() override; + virtual bool paste() override; public slots: - void SetNodes(const QVector &nodes); + void set_nodes(const QVector &nodes); protected: - virtual void TimebaseChangedEvent(const rational &) override; + virtual void TimebaseChangedEvent(const Rational &) override; virtual void ScaleChangedEvent(const double &) override; virtual void TimeTargetChangedEvent(ViewerOutput *target) override; @@ -74,32 +74,32 @@ protected: virtual void ConnectedNodeChangeEvent(ViewerOutput *n) override; virtual const QVector * - GetSnapKeyframes() const override + get_snap_keyframes() const override { - return &view_->GetKeyframeTracks(); + return &view_->get_keyframe_tracks(); } - virtual const TimeTargetObject *GetKeyframeTimeTarget() const override + virtual const TimeTargetObject *get_keyframe_time_target() const override { return view_; } virtual const std::vector * - GetSnapIgnoreKeyframes() const override + get_snap_ignore_keyframes() const override { - return &view_->GetSelectedKeyframes(); + return &view_->get_selected_keyframes(); } private: - void SetKeyframeButtonEnabled(bool enable); + void set_keyframe_button_enabled(bool enable); - void SetKeyframeButtonChecked(bool checked); + void set_keyframe_button_checked(bool checked); - void SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type); + void set_keyframe_button_checked_from_type(NodeKeyframe::Type type); - void ConnectInput(Node *node, const QString &input, int element); + void connect_input(Node *node, const QString &input, int element); - void ConnectInputInternal(Node *node, const QString &input, int element); + void connect_input_internal(Node *node, const QString &input, int element); QHash keyframe_colors_; @@ -120,16 +120,16 @@ private: QVector selected_tracks_; private slots: - void SelectionChanged(); + void selection_changed(); - void KeyframeTypeButtonTriggered(bool checked); + void keyframe_type_button_triggered(bool checked); - void InputSelectionChanged(const NodeKeyframeTrackReference &ref); + void input_selection_changed(const NodeKeyframeTrackReference &ref); - void KeyframeViewDragged(int x, int y); - void KeyframeViewReleased(); + void keyframe_view_dragged(int x, int y); + void keyframe_view_released(); }; } -#endif // CURVEWIDGET_H +#endif // OAK_CURVEWIDGET_H diff --git a/app/widget/filefield/filefield.cpp b/app/widget/filefield/filefield.cpp index 9a66f980a..9741a613f 100644 --- a/app/widget/filefield/filefield.cpp +++ b/app/widget/filefield/filefield.cpp @@ -41,19 +41,19 @@ FileField::FileField(QWidget *parent) line_edit_ = new QLineEdit(); connect(line_edit_, &QLineEdit::textChanged, this, - &FileField::LineEditChanged); + &FileField::line_edit_changed); connect(line_edit_, &QLineEdit::textEdited, this, - &FileField::FilenameChanged); + &FileField::filename_changed); layout->addWidget(line_edit_); browse_btn_ = new QPushButton(); - browse_btn_->setIcon(icon::Open); + browse_btn_->setIcon(icon::open); connect(browse_btn_, &QPushButton::clicked, this, - &FileField::BrowseBtnClicked); + &FileField::browse_btn_clicked); layout->addWidget(browse_btn_); } -void FileField::BrowseBtnClicked() +void FileField::browse_btn_clicked() { QString s; @@ -85,11 +85,11 @@ void FileField::BrowseBtnClicked() if (!s.isEmpty()) { line_edit_->setText(s); - emit FilenameChanged(s); + emit filename_changed(s); } } -void FileField::LineEditChanged(const QString &text) +void FileField::line_edit_changed(const QString &text) { if (QFileInfo::exists(text) || text.isEmpty()) { line_edit_->setStyleSheet(QString()); diff --git a/app/widget/filefield/filefield.h b/app/widget/filefield/filefield.h index cf1b1e248..bf44ac551 100644 --- a/app/widget/filefield/filefield.h +++ b/app/widget/filefield/filefield.h @@ -19,8 +19,8 @@ ***/ -#ifndef FILEFIELD_H -#define FILEFIELD_H +#ifndef OAK_FILEFIELD_H +#define OAK_FILEFIELD_H #include #include @@ -33,27 +33,27 @@ class FileField : public QWidget { public: FileField(QWidget *parent = nullptr); - QString GetFilename() const + QString get_filename() const { return line_edit_->text(); } - virtual void SetFilename(const QString &s) + virtual void set_filename(const QString &s) { line_edit_->setText(s); } - void SetPlaceholder(const QString &s) + void set_placeholder(const QString &s) { line_edit_->setPlaceholderText(s); } - void SetDirectoryMode(bool e) + void set_directory_mode(bool e) { directory_mode_ = e; } - void SetNameFilter(const QString &filter) + void set_name_filter(const QString &filter) { name_filter_ = filter; } @@ -64,13 +64,13 @@ public: * * Note: setting sidebar URLs requires Qt's non-native file dialog. */ - void SetSidebarUrls(const QList &urls) + void set_sidebar_urls(const QList &urls) { sidebar_urls_ = urls; } signals: - void FilenameChanged(const QString &filename); + void filename_changed(const QString &filename); private: QLineEdit *line_edit_; @@ -84,11 +84,11 @@ private: QList sidebar_urls_; private slots: - void BrowseBtnClicked(); + void browse_btn_clicked(); - void LineEditChanged(const QString &text); + void line_edit_changed(const QString &text); }; } -#endif // FILEFIELD_H +#endif // OAK_FILEFIELD_H diff --git a/app/widget/filefield/lutfilefield.cpp b/app/widget/filefield/lutfilefield.cpp index 126e24843..c7923d0e7 100644 --- a/app/widget/filefield/lutfilefield.cpp +++ b/app/widget/filefield/lutfilefield.cpp @@ -35,7 +35,7 @@ LutFileField::LutFileField(QWidget *parent) : FileField(parent) library_combo_->setMinimumContentsLength(12); static_cast(layout())->insertWidget(0, library_combo_, 1); - RefreshLibraryEntries(); + refresh_library_entries(); connect(library_combo_, static_cast(&QComboBox::activated), this, @@ -43,33 +43,33 @@ LutFileField::LutFileField(QWidget *parent) : FileField(parent) const QString path = library_combo_->itemData(index).toString(); if (!path.isEmpty()) { - SetFilename(path); - emit FilenameChanged(path); + set_filename(path); + emit filename_changed(path); } }); // Keep the combo in sync when the path is edited directly - connect(this, &FileField::FilenameChanged, this, [this](const QString &) { - RefreshLibraryEntries(); + connect(this, &FileField::filename_changed, this, [this](const QString &) { + refresh_library_entries(); }); } -void LutFileField::SetFilename(const QString &s) +void LutFileField::set_filename(const QString &s) { - FileField::SetFilename(s); - RefreshLibraryEntries(); + FileField::set_filename(s); + refresh_library_entries(); } -void LutFileField::RefreshLibraryEntries() +void LutFileField::refresh_library_entries() { - const QString current = GetFilename(); + const QString current = get_filename(); const QSignalBlocker blocker(library_combo_); library_combo_->clear(); library_combo_->addItem(tr("Other (Custom File)..."), QString()); - const QStringList library_dirs = LUTLibrary::GetDirectories(); - const QStringList luts = LUTLibrary::GetLutFiles(); + const QStringList library_dirs = LUTLibrary::get_directories(); + const QStringList luts = LUTLibrary::get_lut_files(); for (const QString &lut : luts) { // Show the path relative to the library directory that contains it QString display = lut; diff --git a/app/widget/filefield/lutfilefield.h b/app/widget/filefield/lutfilefield.h index c37384cc4..213fd113b 100644 --- a/app/widget/filefield/lutfilefield.h +++ b/app/widget/filefield/lutfilefield.h @@ -18,8 +18,8 @@ ***/ -#ifndef LUTFILEFIELD_H -#define LUTFILEFIELD_H +#ifndef OAK_LUTFILEFIELD_H +#define OAK_LUTFILEFIELD_H #include @@ -43,7 +43,7 @@ class LutFileField : public FileField { public: LutFileField(QWidget *parent = nullptr); - virtual void SetFilename(const QString &s) override; + virtual void set_filename(const QString &s) override; /** * @brief The combo box listing the LUT library entries @@ -61,11 +61,11 @@ private: * @brief Repopulates the combo from the LUT library and syncs the * selection with the current filename */ - void RefreshLibraryEntries(); + void refresh_library_entries(); QComboBox *library_combo_; }; } -#endif // LUTFILEFIELD_H +#endif // OAK_LUTFILEFIELD_H diff --git a/app/widget/flowlayout/flowlayout.cpp b/app/widget/flowlayout/flowlayout.cpp index cffa9ad34..270f440a1 100644 --- a/app/widget/flowlayout/flowlayout.cpp +++ b/app/widget/flowlayout/flowlayout.cpp @@ -52,17 +52,17 @@ #include #include "flowlayout.h" -FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) +FlowLayout::FlowLayout(QWidget *parent, int margin, int h_spacing, int v_spacing) : QLayout(parent) - , m_hSpace(hSpacing) - , m_vSpace(vSpacing) + , m_hSpace_(h_spacing) + , m_vSpace_(v_spacing) { setContentsMargins(margin, margin, margin, margin); } -FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) - : m_hSpace(hSpacing) - , m_vSpace(vSpacing) +FlowLayout::FlowLayout(int margin, int h_spacing, int v_spacing) + : m_hSpace_(h_spacing) + , m_vSpace_(v_spacing) { setContentsMargins(margin, margin, margin, margin); } @@ -76,41 +76,41 @@ FlowLayout::~FlowLayout() void FlowLayout::addItem(QLayoutItem *item) { - itemList.append(item); + itemList_.append(item); } -int FlowLayout::horizontalSpacing() const +int FlowLayout::horizontal_spacing() const { - if (m_hSpace >= 0) { - return m_hSpace; + if (m_hSpace_ >= 0) { + return m_hSpace_; } else { - return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); + return smart_spacing(QStyle::PM_LayoutHorizontalSpacing); } } -int FlowLayout::verticalSpacing() const +int FlowLayout::vertical_spacing() const { - if (m_vSpace >= 0) { - return m_vSpace; + if (m_vSpace_ >= 0) { + return m_vSpace_; } else { - return smartSpacing(QStyle::PM_LayoutVerticalSpacing); + return smart_spacing(QStyle::PM_LayoutVerticalSpacing); } } int FlowLayout::count() const { - return itemList.size(); + return itemList_.size(); } QLayoutItem *FlowLayout::itemAt(int index) const { - return itemList.value(index); + return itemList_.value(index); } QLayoutItem *FlowLayout::takeAt(int index) { - if (index >= 0 && index < itemList.size()) - return itemList.takeAt(index); + if (index >= 0 && index < itemList_.size()) + return itemList_.takeAt(index); else return 0; } @@ -127,14 +127,14 @@ bool FlowLayout::hasHeightForWidth() const int FlowLayout::heightForWidth(int width) const { - int height = doLayout(QRect(0, 0, width, 0), true); + int height = do_layout(QRect(0, 0, width, 0), true); return height; } void FlowLayout::setGeometry(const QRect &rect) { QLayout::setGeometry(rect); - doLayout(rect, false); + do_layout(rect, false); } QSize FlowLayout::sizeHint() const @@ -146,51 +146,51 @@ QSize FlowLayout::minimumSize() const { QSize size; QLayoutItem *item; - foreach (item, itemList) + foreach (item, itemList_) size = size.expandedTo(item->minimumSize()); size += QSize(2 * contentsMargins().left(), 2 * contentsMargins().top()); return size; } -int FlowLayout::doLayout(const QRect &rect, bool testOnly) const +int FlowLayout::do_layout(const QRect &rect, bool test_only) const { int left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); - QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom); - int x = effectiveRect.x(); - int y = effectiveRect.y(); - int lineHeight = 0; + QRect effective_rect = rect.adjusted(+left, +top, -right, -bottom); + int x = effective_rect.x(); + int y = effective_rect.y(); + int line_height = 0; QLayoutItem *item; - foreach (item, itemList) { + foreach (item, itemList_) { QWidget *wid = item->widget(); - int spaceX = horizontalSpacing(); - if (spaceX == -1) - spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton, + int space_x = horizontal_spacing(); + if (space_x == -1) + space_x = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); - int spaceY = verticalSpacing(); - if (spaceY == -1) - spaceY = wid->style()->layoutSpacing( + int space_y = vertical_spacing(); + if (space_y == -1) + space_y = wid->style()->layoutSpacing( QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); - int nextX = x + item->sizeHint().width() + spaceX; - if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { - x = effectiveRect.x(); - y = y + lineHeight + spaceY; - nextX = x + item->sizeHint().width() + spaceX; - lineHeight = 0; + int next_x = x + item->sizeHint().width() + space_x; + if (next_x - space_x > effective_rect.right() && line_height > 0) { + x = effective_rect.x(); + y = y + line_height + space_y; + next_x = x + item->sizeHint().width() + space_x; + line_height = 0; } - if (!testOnly) + if (!test_only) item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); - x = nextX; - lineHeight = qMax(lineHeight, item->sizeHint().height()); + x = next_x; + line_height = qMax(line_height, item->sizeHint().height()); } - return y + lineHeight - rect.y() + bottom; + return y + line_height - rect.y() + bottom; } -int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const +int FlowLayout::smart_spacing(QStyle::PixelMetric pm) const { QObject *parent = this->parent(); if (!parent) { diff --git a/app/widget/flowlayout/flowlayout.h b/app/widget/flowlayout/flowlayout.h index a6846623b..08bae8f45 100644 --- a/app/widget/flowlayout/flowlayout.h +++ b/app/widget/flowlayout/flowlayout.h @@ -49,22 +49,22 @@ ** ****************************************************************************/ -#ifndef FLOWLAYOUT_H -#define FLOWLAYOUT_H +#ifndef OAK_FLOWLAYOUT_H +#define OAK_FLOWLAYOUT_H #include #include #include class FlowLayout : public QLayout { public: - explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, - int vSpacing = -1); - explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); + explicit FlowLayout(QWidget *parent, int margin = -1, int h_spacing = -1, + int v_spacing = -1); + explicit FlowLayout(int margin = -1, int h_spacing = -1, int v_spacing = -1); ~FlowLayout(); void addItem(QLayoutItem *item) override; - int horizontalSpacing() const; - int verticalSpacing() const; + int horizontal_spacing() const; + int vertical_spacing() const; Qt::Orientations expandingDirections() const override; bool hasHeightForWidth() const override; int heightForWidth(int) const override; @@ -76,12 +76,12 @@ public: QLayoutItem *takeAt(int index) override; private: - int doLayout(const QRect &rect, bool testOnly) const; - int smartSpacing(QStyle::PixelMetric pm) const; + int do_layout(const QRect &rect, bool test_only) const; + int smart_spacing(QStyle::PixelMetric pm) const; - QList itemList; - int m_hSpace; - int m_vSpace; + QList itemList_; + int m_hSpace_; + int m_vSpace_; }; -#endif // FLOWLAYOUT_H +#endif // OAK_FLOWLAYOUT_H diff --git a/app/widget/focusablelineedit/focusablelineedit.cpp b/app/widget/focusablelineedit/focusablelineedit.cpp index 348b86bf9..e112daa71 100644 --- a/app/widget/focusablelineedit/focusablelineedit.cpp +++ b/app/widget/focusablelineedit/focusablelineedit.cpp @@ -36,10 +36,10 @@ void FocusableLineEdit::keyPressEvent(QKeyEvent *e) switch (e->key()) { case Qt::Key_Return: case Qt::Key_Enter: - emit Confirmed(); + emit confirmed(); break; case Qt::Key_Escape: - emit Cancelled(); + emit cancelled(); break; default: QLineEdit::keyPressEvent(e); @@ -50,7 +50,7 @@ void FocusableLineEdit::focusOutEvent(QFocusEvent *e) { QLineEdit::focusOutEvent(e); - emit Confirmed(); + emit confirmed(); } } diff --git a/app/widget/focusablelineedit/focusablelineedit.h b/app/widget/focusablelineedit/focusablelineedit.h index b748171a1..54b2ed891 100644 --- a/app/widget/focusablelineedit/focusablelineedit.h +++ b/app/widget/focusablelineedit/focusablelineedit.h @@ -19,8 +19,8 @@ ***/ -#ifndef SLIDERLINEEDIT_H -#define SLIDERLINEEDIT_H +#ifndef OAK_SLIDERLINEEDIT_H +#define OAK_SLIDERLINEEDIT_H #include @@ -35,9 +35,9 @@ public: FocusableLineEdit(QWidget *parent = nullptr); signals: - void Confirmed(); + void confirmed(); - void Cancelled(); + void cancelled(); protected: void keyPressEvent(QKeyEvent *) override; @@ -47,4 +47,4 @@ protected: } -#endif // SLIDERLINEEDIT_H +#endif // OAK_SLIDERLINEEDIT_H diff --git a/app/widget/handmovableview/handmovableview.cpp b/app/widget/handmovableview/handmovableview.cpp index dfcf6fbad..afe2b39e1 100644 --- a/app/widget/handmovableview/handmovableview.cpp +++ b/app/widget/handmovableview/handmovableview.cpp @@ -37,13 +37,13 @@ HandMovableView::HandMovableView(QWidget *parent) , default_drag_mode_(NoDrag) , is_timeline_axes_(false) { - connect(Core::instance(), &Core::ToolChanged, this, - &HandMovableView::ApplicationToolChanged); + connect(Core::instance(), &Core::tool_changed, this, + &HandMovableView::application_tool_changed); } -void HandMovableView::ApplicationToolChanged(Tool::Item tool) +void HandMovableView::application_tool_changed(Tool::Item tool) { - if (tool == Tool::kHand) { + if (tool == Tool::k_hand) { setDragMode(ScrollHandDrag); setInteractive(false); } else { @@ -54,7 +54,7 @@ void HandMovableView::ApplicationToolChanged(Tool::Item tool) ToolChangedEvent(tool); } -bool HandMovableView::HandPress(QMouseEvent *event) +bool HandMovableView::hand_press(QMouseEvent *event) { if (event->button() == Qt::MiddleButton) { pre_hand_drag_mode_ = dragMode(); @@ -77,7 +77,7 @@ bool HandMovableView::HandPress(QMouseEvent *event) return false; } -bool HandMovableView::HandMove(QMouseEvent *event) +bool HandMovableView::hand_move(QMouseEvent *event) { if (dragging_hand_) { // Transform mouse event to act like the left button is pressed @@ -112,7 +112,7 @@ bool HandMovableView::HandMove(QMouseEvent *event) return dragging_hand_; } -bool HandMovableView::HandRelease(QMouseEvent *event) +bool HandMovableView::hand_release(QMouseEvent *event) { if (dragging_hand_) { // Transform mouse event to act like the left button is pressed @@ -134,13 +134,13 @@ bool HandMovableView::HandRelease(QMouseEvent *event) return false; } -void HandMovableView::SetDefaultDragMode(HandMovableView::DragMode mode) +void HandMovableView::set_default_drag_mode(HandMovableView::DragMode mode) { default_drag_mode_ = mode; setDragMode(default_drag_mode_); } -const HandMovableView::DragMode &HandMovableView::GetDefaultDragMode() const +const HandMovableView::DragMode &HandMovableView::get_default_drag_mode() const { return default_drag_mode_; } @@ -148,10 +148,10 @@ const HandMovableView::DragMode &HandMovableView::GetDefaultDragMode() const bool HandMovableView::WheelEventIsAZoomEvent(QWheelEvent *event) { return (static_cast(event->modifiers() & Qt::ControlModifier) == - !OLIVE_CONFIG("ScrollZooms").toBool()); + !OAK_CONFIG("ScrollZooms").toBool()); } -qreal HandMovableView::GetScrollZoomMultiplier(QWheelEvent *event) +qreal HandMovableView::get_scroll_zoom_multiplier(QWheelEvent *event) { qreal v = (static_cast(event->angleDelta().x() + event->angleDelta().y()) * @@ -166,7 +166,7 @@ void HandMovableView::wheelEvent(QWheelEvent *event) { if (WheelEventIsAZoomEvent(event)) { if (!event->angleDelta().isNull()) { - qreal multiplier = GetScrollZoomMultiplier(event); + qreal multiplier = get_scroll_zoom_multiplier(event); QPointF cursor_pos; #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) @@ -175,14 +175,14 @@ void HandMovableView::wheelEvent(QWheelEvent *event) cursor_pos = event->posF(); #endif - ZoomIntoCursorPosition(event, multiplier, cursor_pos); + zoom_into_cursor_position(event, multiplier, cursor_pos); } } else if (is_timeline_axes_) { #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) QPoint angle_delta = event->angleDelta(); - if (OLIVE_CONFIG("InvertTimelineScrollAxes") + if (OAK_CONFIG("InvertTimelineScrollAxes") .toBool() // Check if config is set to invert timeline axes && event->source() != @@ -204,7 +204,7 @@ void HandMovableView::wheelEvent(QWheelEvent *event) Qt::Orientation orientation = event->orientation(); - if (OLIVE_CONFIG("InvertTimelineScrollAxes").toBool()) { + if (OAK_CONFIG("InvertTimelineScrollAxes").toBool()) { orientation = (orientation == Qt::Horizontal) ? Qt::Vertical : Qt::Horizontal; } @@ -220,7 +220,7 @@ void HandMovableView::wheelEvent(QWheelEvent *event) } } -void HandMovableView::ZoomIntoCursorPosition(QWheelEvent *event, +void HandMovableView::zoom_into_cursor_position(QWheelEvent *event, double multiplier, const QPointF &cursor_pos) { diff --git a/app/widget/handmovableview/handmovableview.h b/app/widget/handmovableview/handmovableview.h index 97ee32e5f..2d6cb314e 100644 --- a/app/widget/handmovableview/handmovableview.h +++ b/app/widget/handmovableview/handmovableview.h @@ -19,8 +19,8 @@ ***/ -#ifndef HANDMOVABLEVIEW_H -#define HANDMOVABLEVIEW_H +#ifndef OAK_HANDMOVABLEVIEW_H +#define OAK_HANDMOVABLEVIEW_H #include #include @@ -37,7 +37,7 @@ public: static bool WheelEventIsAZoomEvent(QWheelEvent *event); - static qreal GetScrollZoomMultiplier(QWheelEvent *event); + static qreal get_scroll_zoom_multiplier(QWheelEvent *event); virtual void CatchUpScrollEvent() { @@ -49,19 +49,19 @@ protected: Q_UNUSED(tool) } - bool HandPress(QMouseEvent *event); - bool HandMove(QMouseEvent *event); - bool HandRelease(QMouseEvent *event); + bool hand_press(QMouseEvent *event); + bool hand_move(QMouseEvent *event); + bool hand_release(QMouseEvent *event); - void SetDefaultDragMode(DragMode mode); - const DragMode &GetDefaultDragMode() const; + void set_default_drag_mode(DragMode mode); + const DragMode &get_default_drag_mode() const; virtual void wheelEvent(QWheelEvent *event) override; - virtual void ZoomIntoCursorPosition(QWheelEvent *event, double multiplier, + virtual void zoom_into_cursor_position(QWheelEvent *event, double multiplier, const QPointF &cursor_pos); - void SetIsTimelineAxes(bool e) + void set_is_timeline_axes(bool e) { is_timeline_axes_ = e; } @@ -77,9 +77,9 @@ private: bool is_timeline_axes_; private slots: - void ApplicationToolChanged(Tool::Item tool); + void application_tool_changed(Tool::Item tool); }; } -#endif // HANDMOVABLEVIEW_H +#endif // OAK_HANDMOVABLEVIEW_H diff --git a/app/widget/history/historywidget.cpp b/app/widget/history/historywidget.cpp index 0e7d54520..c0ef4d567 100644 --- a/app/widget/history/historywidget.cpp +++ b/app/widget/history/historywidget.cpp @@ -33,20 +33,20 @@ HistoryWidget::HistoryWidget(QWidget *parent) this->setModel(stack_); this->setRootIsDecorated(false); - connect(stack_, &UndoStack::indexChanged, this, - &HistoryWidget::indexChanged); + connect(stack_, &UndoStack::index_changed, this, + &HistoryWidget::index_changed); connect(this->selectionModel(), &QItemSelectionModel::currentRowChanged, - this, &HistoryWidget::currentRowChanged); + this, &HistoryWidget::current_row_changed); } -void HistoryWidget::indexChanged(int i) +void HistoryWidget::index_changed(int i) { this->selectionModel()->select(this->model()->index(i - 1, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } -void HistoryWidget::currentRowChanged(const QModelIndex ¤t, +void HistoryWidget::current_row_changed(const QModelIndex ¤t, const QModelIndex &previous) { size_t jump_to = (current.row() + 1); diff --git a/app/widget/history/historywidget.h b/app/widget/history/historywidget.h index 105dd6cea..7d4d0349c 100644 --- a/app/widget/history/historywidget.h +++ b/app/widget/history/historywidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef HISTORYWIDGET_H -#define HISTORYWIDGET_H +#ifndef OAK_HISTORYWIDGET_H +#define OAK_HISTORYWIDGET_H #include @@ -40,12 +40,12 @@ private: size_t current_row_; private slots: - void indexChanged(int i); + void index_changed(int i); - void currentRowChanged(const QModelIndex ¤t, + void current_row_changed(const QModelIndex ¤t, const QModelIndex &previous); }; } -#endif // HISTORYWIDGET_H +#endif // OAK_HISTORYWIDGET_H diff --git a/app/widget/keyframeview/keyframeview.cpp b/app/widget/keyframeview/keyframeview.cpp index 35403eabd..7a3fcb3e4 100644 --- a/app/widget/keyframeview/keyframeview.cpp +++ b/app/widget/keyframeview/keyframeview.cpp @@ -48,53 +48,53 @@ KeyframeView::KeyframeView(QWidget *parent) , first_chance_mouse_event_(false) { setAlignment(Qt::AlignLeft | Qt::AlignTop); - SetDefaultDragMode(RubberBandDrag); + set_default_drag_mode(RubberBandDrag); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &KeyframeView::customContextMenuRequested, this, - &KeyframeView::ShowContextMenu); + &KeyframeView::show_context_menu); } -void KeyframeView::DeleteSelected() +void KeyframeView::delete_selected() { - if (!selection_manager_.IsDragging()) { + if (!selection_manager_.is_dragging()) { MultiUndoCommand *command = new MultiUndoCommand(); - foreach (NodeKeyframe *key, GetSelectedKeyframes()) { + foreach (NodeKeyframe *key, get_selected_keyframes()) { command->add_child(new NodeParamRemoveKeyframeCommand(key)); } Core::instance()->undo_stack()->push( command, - tr("Deleted %1 Keyframe(s)").arg(GetSelectedKeyframes().size())); + tr("Deleted %1 Keyframe(s)").arg(get_selected_keyframes().size())); } } -KeyframeView::NodeConnections KeyframeView::AddKeyframesOfNode(Node *n) +KeyframeView::NodeConnections KeyframeView::add_keyframes_of_node(Node *n) { NodeConnections map; foreach (const QString &i, n->inputs()) { - map.insert(i, AddKeyframesOfInput(n, i)); + map.insert(i, add_keyframes_of_input(n, i)); } return map; } KeyframeView::InputConnections -KeyframeView::AddKeyframesOfInput(Node *on, const QString &oinput) +KeyframeView::add_keyframes_of_input(Node *on, const QString &oinput) { InputConnections vec; - NodeInput resolved = NodeGroup::ResolveInput(NodeInput(on, oinput)); + NodeInput resolved = NodeGroup::resolve_input(NodeInput(on, oinput)); Node *n = resolved.node(); const QString &input = resolved.input(); - if (n->IsInputKeyframable(input)) { - int arr_sz = n->InputArraySize(input); + if (n->is_input_keyframable(input)) { + int arr_sz = n->input_array_size(input); vec.resize(arr_sz + 1); for (int i = -1; i < arr_sz; i++) { - vec[i + 1] = AddKeyframesOfElement(NodeInput(n, input, i)); + vec[i + 1] = add_keyframes_of_element(NodeInput(n, input, i)); } } @@ -102,114 +102,114 @@ KeyframeView::AddKeyframesOfInput(Node *on, const QString &oinput) } KeyframeView::ElementConnections -KeyframeView::AddKeyframesOfElement(const NodeInput &input) +KeyframeView::add_keyframes_of_element(const NodeInput &input) { const QVector &tracks = - input.node()->GetKeyframeTracks(input); + input.node()->get_keyframe_tracks(input); ElementConnections vec(tracks.size()); for (int i = 0; i < tracks.size(); i++) { - vec[i] = AddKeyframesOfTrack(NodeKeyframeTrackReference(input, i)); + vec[i] = add_keyframes_of_track(NodeKeyframeTrackReference(input, i)); } return vec; } KeyframeViewInputConnection * -KeyframeView::AddKeyframesOfTrack(const NodeKeyframeTrackReference &ref) +KeyframeView::add_keyframes_of_track(const NodeKeyframeTrackReference &ref) { KeyframeViewInputConnection *track = new KeyframeViewInputConnection(ref, this); - connect(track, &KeyframeViewInputConnection::RequireUpdate, this, - &KeyframeView::Redraw); + connect(track, &KeyframeViewInputConnection::require_update, this, + &KeyframeView::redraw); tracks_.append(track); - Redraw(); + redraw(); return track; } -void KeyframeView::RemoveKeyframesOfTrack( +void KeyframeView::remove_keyframes_of_track( KeyframeViewInputConnection *connection) { if (tracks_.removeOne(connection)) { - foreach (NodeKeyframe *key, connection->GetKeyframes()) { - selection_manager_.Deselect(key); + foreach (NodeKeyframe *key, connection->get_keyframes()) { + selection_manager_.deselect(key); } delete connection; - Redraw(); - emit SelectionChanged(); + redraw(); + emit selection_changed(); } } -void KeyframeView::SelectAll() +void KeyframeView::select_all() { foreach (KeyframeViewInputConnection *track, tracks_) { - foreach (NodeKeyframe *key, track->GetKeyframes()) { - SelectKeyframe(key); + foreach (NodeKeyframe *key, track->get_keyframes()) { + select_keyframe(key); } } } -void KeyframeView::DeselectAll() +void KeyframeView::deselect_all() { - selection_manager_.ClearSelection(); + selection_manager_.clear_selection(); - Redraw(); + redraw(); } -void KeyframeView::Clear() +void KeyframeView::clear() { if (!tracks_.isEmpty()) { qDeleteAll(tracks_); tracks_.clear(); - Redraw(); + redraw(); } - selection_manager_.ClearSelection(); + selection_manager_.clear_selection(); } void KeyframeView::SelectionManagerSelectEvent(void *obj) { if (autoselect_siblings_) { NodeKeyframe *key = static_cast(obj); - QVector keys = key->parent()->GetKeyframesAtTime( + QVector keys = key->parent()->get_keyframes_at_time( key->input(), key->time(), key->element()); foreach (NodeKeyframe *k, keys) { if (k != key) { - SelectKeyframe(k); + select_keyframe(k); } } } - emit SelectionChanged(); + emit selection_changed(); } void KeyframeView::SelectionManagerDeselectEvent(void *obj) { if (autoselect_siblings_) { NodeKeyframe *key = static_cast(obj); - QVector keys = key->parent()->GetKeyframesAtTime( + QVector keys = key->parent()->get_keyframes_at_time( key->input(), key->time(), key->element()); foreach (NodeKeyframe *k, keys) { if (k != key) { - DeselectKeyframe(k); + deselect_keyframe(k); } } } - emit SelectionChanged(); + emit selection_changed(); } -bool KeyframeView::CopySelected(bool cut) +bool KeyframeView::copy_selected(bool cut) { - if (!selection_manager_.GetSelectedObjects().empty()) { - ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyKeyframes); - sdata.SetOnlySerializeKeyframes( - selection_manager_.GetSelectedObjects()); + if (!selection_manager_.get_selected_objects().empty()) { + ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_keyframes); + sdata.set_only_serialize_keyframes( + selection_manager_.get_selected_objects()); - ProjectSerializer::Copy(sdata); + ProjectSerializer::copy(sdata); if (cut) { - DeleteSelected(); + delete_selected(); } return true; @@ -218,28 +218,28 @@ bool KeyframeView::CopySelected(bool cut) return false; } -bool KeyframeView::Paste( +bool KeyframeView::paste( std::function find_node_function) { - if (!GetViewerNode()) { + if (!get_viewer_node()) { return false; } ProjectSerializer::Result res = - ProjectSerializer::Paste(ProjectSerializer::kOnlyKeyframes); - if (res == ProjectSerializer::kSuccess) { + ProjectSerializer::paste(ProjectSerializer::k_only_keyframes); + if (res == ProjectSerializer::k_success) { const ProjectSerializer::SerializedKeyframes &keys = - res.GetLoadData().keyframes; + res.get_load_data().keyframes; MultiUndoCommand *command = new MultiUndoCommand(); - rational min = RATIONAL_MAX; + Rational min = RATIONAL_MAX; for (auto it = keys.cbegin(); it != keys.cend(); it++) { for (NodeKeyframe *key : it.value()) { min = std::min(min, key->time()); } } - min -= GetViewerNode()->GetPlayhead(); + min -= get_viewer_node()->get_playhead(); for (auto it = keys.cbegin(); it != keys.cend(); it++) { const QString &paste_id = it.key(); @@ -250,13 +250,13 @@ bool KeyframeView::Paste( if (node_with_id) { for (NodeKeyframe *key : it.value()) { // Adjust sequence time to node's time - rational t = key->time() - min; - t = GetAdjustedTime(GetTimeTarget(), node_with_id, t, - Node::kTransformTowardsInput); + Rational t = key->time() - min; + t = get_adjusted_time(get_time_target(), node_with_id, t, + Node::k_transform_towards_input); key->set_time(t); if (NodeKeyframe *existing = - node_with_id->GetKeyframeAtTimeOnTrack( + node_with_id->get_keyframe_at_time_on_track( key->input(), key->time(), key->track(), key->element())) { command->add_child( @@ -283,83 +283,83 @@ void KeyframeView::CatchUpScrollEvent() { super::CatchUpScrollEvent(); - this->selection_manager_.ForceDragUpdate(); + this->selection_manager_.force_drag_update(); } void KeyframeView::mousePressEvent(QMouseEvent *event) { NodeKeyframe *key_under_cursor = - selection_manager_.GetObjectAtPoint(event->pos()); + selection_manager_.get_object_at_point(event->pos()); - if (HandPress(event) || (!key_under_cursor && PlayheadPress(event))) { + if (hand_press(event) || (!key_under_cursor && playhead_press(event))) { return; } // Do mouse press things - if (FirstChanceMousePress(event)) { + if (first_chance_mouse_press(event)) { first_chance_mouse_event_ = true; } else if (NodeKeyframe *initial_key = - selection_manager_.MousePress(event)) { - selection_manager_.DragStart(initial_key, event, this); - KeyframeDragStart(event); + selection_manager_.mouse_press(event)) { + selection_manager_.drag_start(initial_key, event, this); + keyframe_drag_start(event); } else { - selection_manager_.RubberBandStart(event); + selection_manager_.rubber_band_start(event); } // Update view - Redraw(); + redraw(); } void KeyframeView::mouseMoveEvent(QMouseEvent *event) { - if (HandMove(event) || PlayheadMove(event)) { + if (hand_move(event) || playhead_move(event)) { return; } if (first_chance_mouse_event_) { - FirstChanceMouseMove(event); - } else if (selection_manager_.IsDragging()) { + first_chance_mouse_move(event); + } else if (selection_manager_.is_dragging()) { QString tip; - KeyframeDragMove(event, tip); - selection_manager_.DragMove(event->pos(), tip); - } else if (selection_manager_.IsRubberBanding()) { - selection_manager_.RubberBandMove(event->pos()); - Redraw(); + keyframe_drag_move(event, tip); + selection_manager_.drag_move(event->pos(), tip); + } else if (selection_manager_.is_rubber_banding()) { + selection_manager_.rubber_band_move(event->pos()); + redraw(); } if (event->buttons()) { // Signal cursor pos in case we should scroll to catch up to it - emit Dragged(event->pos().x(), event->pos().y()); + emit dragged(event->pos().x(), event->pos().y()); } } void KeyframeView::mouseReleaseEvent(QMouseEvent *event) { - if (HandRelease(event) || PlayheadRelease(event)) { + if (hand_release(event) || playhead_release(event)) { return; } if (first_chance_mouse_event_) { - FirstChanceMouseRelease(event); + first_chance_mouse_release(event); first_chance_mouse_event_ = false; - } else if (selection_manager_.IsDragging()) { + } else if (selection_manager_.is_dragging()) { MultiUndoCommand *command = new MultiUndoCommand(); - selection_manager_.DragStop(command); - KeyframeDragRelease(event, command); + selection_manager_.drag_stop(command); + keyframe_drag_release(event, command); Core::instance()->undo_stack()->push( command, tr("Moved %1 Keyframe(s)") - .arg(selection_manager_.GetSelectedObjects().size())); - } else if (selection_manager_.IsRubberBanding()) { - selection_manager_.RubberBandStop(); - Redraw(); - emit SelectionChanged(); + .arg(selection_manager_.get_selected_objects().size())); + } else if (selection_manager_.is_rubber_banding()) { + selection_manager_.rubber_band_stop(); + redraw(); + emit selection_changed(); } - emit Released(); + emit released(); } -int BinarySearchFirstKeyframeAfterOrAt(const QVector &keys, - const rational &time) +int binary_search_first_keyframe_after_or_at(const QVector &keys, + const Rational &time) { int low = 0; int high = keys.size() - 1; @@ -384,35 +384,35 @@ int BinarySearchFirstKeyframeAfterOrAt(const QVector &keys, void KeyframeView::drawForeground(QPainter *painter, const QRectF &rect) { - int key_sz = QtUtils::QFontMetricsWidth(fontMetrics(), "Oi"); + int key_sz = QtUtils::q_font_metrics_width(fontMetrics(), "Oi"); int key_rad = key_sz / 2; - selection_manager_.ClearDrawnObjects(); + selection_manager_.clear_drawn_objects(); painter->setRenderHint(QPainter::Antialiasing); foreach (KeyframeViewInputConnection *track, tracks_) { - const QVector &keys = track->GetKeyframes(); + const QVector &keys = track->get_keyframes(); if (keys.isEmpty()) { continue; } - if (!IsYAxisEnabled()) { + if (!is_y_axis_enabled()) { // Filter out if the keyframes are offscreen Y - qreal y = GetKeyframeSceneY(track, keys.first()); + qreal y = get_keyframe_scene_y(track, keys.first()); if (y + key_rad < rect.top() || y - key_rad >= rect.bottom()) { continue; } } // Find first keyframe to show with binary search - rational left_time = GetUnadjustedKeyframeTime( - keys.first(), SceneToTime(rect.left() - key_sz)); - int using_index = BinarySearchFirstKeyframeAfterOrAt(keys, left_time); + Rational left_time = get_unadjusted_keyframe_time( + keys.first(), scene_to_time(rect.left() - key_sz)); + int using_index = binary_search_first_keyframe_after_or_at(keys, left_time); - rational next_key = RATIONAL_MIN; - NodeKeyframe::Type last_type = NodeKeyframe::kInvalid; + Rational next_key = RATIONAL_MIN; + NodeKeyframe::Type last_type = NodeKeyframe::k_invalid; for (int i = using_index; i < keys.size(); i++) { NodeKeyframe *key = keys.at(i); @@ -428,7 +428,7 @@ void KeyframeView::drawForeground(QPainter *painter, const QRectF &rect) if (key->time() < next_key) { // Next key still won't be drawn, so we'll switch to a binary search - i = BinarySearchFirstKeyframeAfterOrAt(keys, next_key); + i = binary_search_first_keyframe_after_or_at(keys, next_key); if (i == keys.size()) { break; @@ -439,17 +439,17 @@ void KeyframeView::drawForeground(QPainter *painter, const QRectF &rect) } QRectF key_rect(-key_rad, -key_rad, key_sz, key_sz); - qreal key_x = GetKeyframeSceneX(key); - key_rect.translate(key_x, GetKeyframeSceneY(track, key)); + qreal key_x = get_keyframe_scene_x(key); + key_rect.translate(key_x, get_keyframe_scene_y(track, key)); if (key_rect.left() >= rect.right()) { // Break after last keyframe break; } - DrawKeyframe(painter, key, track, key_rect); + draw_keyframe(painter, key, track, key_rect); - next_key = GetUnadjustedKeyframeTime(key, SceneToTime(key_x + 1)); + next_key = get_unadjusted_keyframe_time(key, scene_to_time(key_x + 1)); last_type = key->type(); } } @@ -457,24 +457,24 @@ void KeyframeView::drawForeground(QPainter *painter, const QRectF &rect) super::drawForeground(painter, rect); } -void KeyframeView::DrawKeyframe(QPainter *painter, NodeKeyframe *key, +void KeyframeView::draw_keyframe(QPainter *painter, NodeKeyframe *key, KeyframeViewInputConnection *track, const QRectF &key_rect) { painter->setPen(Qt::black); - if (IsKeyframeSelected(key)) { + if (is_keyframe_selected(key)) { painter->setBrush(palette().highlight()); } else { - painter->setBrush(track->GetBrush()); + painter->setBrush(track->get_brush()); } - selection_manager_.DeclareDrawnObject(key, key_rect); + selection_manager_.declare_drawn_object(key, key_rect); switch (key->type()) { - case NodeKeyframe::kInvalid: + case NodeKeyframe::k_invalid: break; - case NodeKeyframe::kLinear: { + case NodeKeyframe::k_linear: { QPointF points[] = { QPointF(key_rect.center().x(), key_rect.top()), QPointF(key_rect.right(), key_rect.center().y()), QPointF(key_rect.center().x(), key_rect.bottom()), @@ -483,10 +483,10 @@ void KeyframeView::DrawKeyframe(QPainter *painter, NodeKeyframe *key, painter->drawPolygon(points, 4); break; } - case NodeKeyframe::kBezier: + case NodeKeyframe::k_bezier: painter->drawEllipse(key_rect); break; - case NodeKeyframe::kHold: + case NodeKeyframe::k_hold: painter->drawRect(key_rect); break; } @@ -496,19 +496,19 @@ void KeyframeView::ScaleChangedEvent(const double &scale) { super::ScaleChangedEvent(scale); - Redraw(); + redraw(); } void KeyframeView::TimeTargetChangedEvent(ViewerOutput *v) { - Redraw(); + redraw(); } -void KeyframeView::TimebaseChangedEvent(const rational &timebase) +void KeyframeView::TimebaseChangedEvent(const Rational &timebase) { super::TimebaseChangedEvent(timebase); - selection_manager_.SetTimebase(timebase); + selection_manager_.set_timebase(timebase); } void KeyframeView::ContextMenuEvent(Menu &m) @@ -516,46 +516,46 @@ void KeyframeView::ContextMenuEvent(Menu &m) Q_UNUSED(m) } -void KeyframeView::SelectKeyframe(NodeKeyframe *key) +void KeyframeView::select_keyframe(NodeKeyframe *key) { - if (selection_manager_.Select(key)) { - Redraw(); + if (selection_manager_.select(key)) { + redraw(); - emit SelectionChanged(); + emit selection_changed(); } } -void KeyframeView::DeselectKeyframe(NodeKeyframe *key) +void KeyframeView::deselect_keyframe(NodeKeyframe *key) { - if (selection_manager_.Deselect(key)) { - Redraw(); + if (selection_manager_.deselect(key)) { + redraw(); - emit SelectionChanged(); + emit selection_changed(); } } -rational KeyframeView::GetUnadjustedKeyframeTime(NodeKeyframe *key, - const rational &time) +Rational KeyframeView::get_unadjusted_keyframe_time(NodeKeyframe *key, + const Rational &time) { - return GetAdjustedTime(GetTimeTarget(), key->parent(), time, - Node::kTransformTowardsInput); + return get_adjusted_time(get_time_target(), key->parent(), time, + Node::k_transform_towards_input); } -rational KeyframeView::GetAdjustedKeyframeTime(NodeKeyframe *key) +Rational KeyframeView::get_adjusted_keyframe_time(NodeKeyframe *key) { - return GetAdjustedTime(key->parent(), GetTimeTarget(), key->time(), - Node::kTransformTowardsOutput); + return get_adjusted_time(key->parent(), get_time_target(), key->time(), + Node::k_transform_towards_output); } -double KeyframeView::GetKeyframeSceneX(NodeKeyframe *key) +double KeyframeView::get_keyframe_scene_x(NodeKeyframe *key) { - return TimeToScene(GetAdjustedKeyframeTime(key)); + return time_to_scene(get_adjusted_keyframe_time(key)); } -qreal KeyframeView::GetKeyframeSceneY(KeyframeViewInputConnection *track, +qreal KeyframeView::get_keyframe_scene_y(KeyframeViewInputConnection *track, NodeKeyframe *key) { - return mapFromGlobal(QPoint(0, track->GetKeyframeY())).y(); + return mapFromGlobal(QPoint(0, track->get_keyframe_y())).y(); } void KeyframeView::SceneRectUpdateEvent(QRectF &rect) @@ -564,29 +564,29 @@ void KeyframeView::SceneRectUpdateEvent(QRectF &rect) rect.setHeight(max_scroll_); } -rational KeyframeView::CalculateNewTimeFromScreen(const rational &old_time, +Rational KeyframeView::calculate_new_time_from_screen(const Rational &old_time, double cursor_diff) { - return rational::fromDouble(old_time.toDouble() + cursor_diff); + return Rational::from_double(old_time.to_double() + cursor_diff); } -void KeyframeView::ShowContextMenu() +void KeyframeView::show_context_menu() { Menu m; - MenuShared::instance()->AddItemsForEditMenu(&m, false); + MenuShared::instance()->add_items_for_edit_menu(&m, false); QAction *linear_key_action = nullptr; QAction *bezier_key_action = nullptr; QAction *hold_key_action = nullptr; - if (!GetSelectedKeyframes().empty()) { + if (!get_selected_keyframes().empty()) { bool all_keys_are_same_type = true; - NodeKeyframe::Type type = GetSelectedKeyframes().front()->type(); + NodeKeyframe::Type type = get_selected_keyframes().front()->type(); - for (size_t i = 1; i < GetSelectedKeyframes().size(); i++) { - NodeKeyframe *key_item = GetSelectedKeyframes().at(i); - NodeKeyframe *prev_item = GetSelectedKeyframes().at(i - 1); + for (size_t i = 1; i < get_selected_keyframes().size(); i++) { + NodeKeyframe *key_item = get_selected_keyframes().at(i); + NodeKeyframe *prev_item = get_selected_keyframes().at(i - 1); if (key_item->type() != prev_item->type()) { all_keys_are_same_type = false; @@ -602,15 +602,15 @@ void KeyframeView::ShowContextMenu() if (all_keys_are_same_type) { switch (type) { - case NodeKeyframe::kInvalid: + case NodeKeyframe::k_invalid: break; - case NodeKeyframe::kLinear: + case NodeKeyframe::k_linear: linear_key_action->setChecked(true); break; - case NodeKeyframe::kBezier: + case NodeKeyframe::k_bezier: bezier_key_action->setChecked(true); break; - case NodeKeyframe::kHold: + case NodeKeyframe::k_hold: hold_key_action->setChecked(true); break; } @@ -621,12 +621,12 @@ void KeyframeView::ShowContextMenu() ContextMenuEvent(m); - if (!GetSelectedKeyframes().empty()) { + if (!get_selected_keyframes().empty()) { m.addSeparator(); QAction *properties_action = m.addAction(tr("P&roperties")); connect(properties_action, &QAction::triggered, this, - &KeyframeView::ShowKeyframePropertiesDialog); + &KeyframeView::show_keyframe_properties_dialog); } QAction *selected = m.exec(QCursor::pos()); @@ -638,38 +638,38 @@ void KeyframeView::ShowContextMenu() NodeKeyframe::Type new_type; if (selected == hold_key_action) { - new_type = NodeKeyframe::kHold; + new_type = NodeKeyframe::k_hold; } else if (selected == bezier_key_action) { - new_type = NodeKeyframe::kBezier; + new_type = NodeKeyframe::k_bezier; } else { - new_type = NodeKeyframe::kLinear; + new_type = NodeKeyframe::k_linear; } MultiUndoCommand *command = new MultiUndoCommand(); - foreach (NodeKeyframe *item, GetSelectedKeyframes()) { + foreach (NodeKeyframe *item, get_selected_keyframes()) { command->add_child(new KeyframeSetTypeCommand(item, new_type)); } Core::instance()->undo_stack()->push( command, tr("Set Type of %1 Keyframe(s)") - .arg(GetSelectedKeyframes().size())); + .arg(get_selected_keyframes().size())); } } } -void KeyframeView::ShowKeyframePropertiesDialog() +void KeyframeView::show_keyframe_properties_dialog() { - if (!GetSelectedKeyframes().empty()) { - KeyframePropertiesDialog kd(GetSelectedKeyframes(), timebase(), this); + if (!get_selected_keyframes().empty()) { + KeyframePropertiesDialog kd(get_selected_keyframes(), timebase(), this); kd.exec(); } } -void KeyframeView::UpdateRubberBandForScroll() +void KeyframeView::update_rubber_band_for_scroll() { - this->selection_manager_.ForceDragUpdate(); + this->selection_manager_.force_drag_update(); } -void KeyframeView::Redraw() +void KeyframeView::redraw() { viewport()->update(); } diff --git a/app/widget/keyframeview/keyframeview.h b/app/widget/keyframeview/keyframeview.h index 2eb150725..5208dd6f3 100644 --- a/app/widget/keyframeview/keyframeview.h +++ b/app/widget/keyframeview/keyframeview.h @@ -19,8 +19,8 @@ ***/ -#ifndef KEYFRAMEVIEWBASE_H -#define KEYFRAMEVIEWBASE_H +#ifndef OAK_KEYFRAMEVIEWBASE_H +#define OAK_KEYFRAMEVIEWBASE_H #include @@ -39,35 +39,35 @@ class KeyframeView : public TimeBasedView, public TimeTargetObject { public: KeyframeView(QWidget *parent = nullptr); - void DeleteSelected(); + void delete_selected(); using ElementConnections = QVector; using InputConnections = QVector; using NodeConnections = QMap; - NodeConnections AddKeyframesOfNode(Node *n); + NodeConnections add_keyframes_of_node(Node *n); - InputConnections AddKeyframesOfInput(Node *n, const QString &input); + InputConnections add_keyframes_of_input(Node *n, const QString &input); - ElementConnections AddKeyframesOfElement(const NodeInput &input); + ElementConnections add_keyframes_of_element(const NodeInput &input); KeyframeViewInputConnection * - AddKeyframesOfTrack(const NodeKeyframeTrackReference &ref); + add_keyframes_of_track(const NodeKeyframeTrackReference &ref); - void RemoveKeyframesOfTrack(KeyframeViewInputConnection *connection); + void remove_keyframes_of_track(KeyframeViewInputConnection *connection); - void SelectAll(); + void select_all(); - void DeselectAll(); + void deselect_all(); - void Clear(); + void clear(); - const std::vector &GetSelectedKeyframes() const + const std::vector &get_selected_keyframes() const { - return selection_manager_.GetSelectedObjects(); + return selection_manager_.get_selected_objects(); } - const QVector &GetKeyframeTracks() const + const QVector &get_keyframe_tracks() const { return tracks_; } @@ -75,24 +75,24 @@ public: virtual void SelectionManagerSelectEvent(void *obj) override; virtual void SelectionManagerDeselectEvent(void *obj) override; - void SetMaxScroll(int i) + void set_max_scroll(int i) { max_scroll_ = i; - UpdateSceneRect(); + update_scene_rect(); } - bool CopySelected(bool cut); + bool copy_selected(bool cut); - bool Paste(std::function find_node_function); + bool paste(std::function find_node_function); virtual void CatchUpScrollEvent() override; signals: - void Dragged(int current_x, int current_y); + void dragged(int current_x, int current_y); - void SelectionChanged(); + void selection_changed(); - void Released(); + void released(); protected: virtual void mousePressEvent(QMouseEvent *event) override; @@ -101,7 +101,7 @@ protected: virtual void drawForeground(QPainter *painter, const QRectF &rect) override; - virtual void DrawKeyframe(QPainter *painter, NodeKeyframe *key, + virtual void draw_keyframe(QPainter *painter, NodeKeyframe *key, KeyframeViewInputConnection *track, const QRectF &key_rect); @@ -109,55 +109,55 @@ protected: virtual void TimeTargetChangedEvent(ViewerOutput *v) override; - virtual void TimebaseChangedEvent(const rational &timebase) override; + virtual void TimebaseChangedEvent(const Rational &timebase) override; virtual void ContextMenuEvent(Menu &m); - virtual bool FirstChanceMousePress(QMouseEvent *event) + virtual bool first_chance_mouse_press(QMouseEvent *event) { return false; } - virtual void FirstChanceMouseMove(QMouseEvent *event) + virtual void first_chance_mouse_move(QMouseEvent *event) { } - virtual void FirstChanceMouseRelease(QMouseEvent *event) + virtual void first_chance_mouse_release(QMouseEvent *event) { } - virtual void KeyframeDragStart(QMouseEvent *event) + virtual void keyframe_drag_start(QMouseEvent *event) { } - virtual void KeyframeDragMove(QMouseEvent *event, QString &tip) + virtual void keyframe_drag_move(QMouseEvent *event, QString &tip) { } - virtual void KeyframeDragRelease(QMouseEvent *event, + virtual void keyframe_drag_release(QMouseEvent *event, MultiUndoCommand *command) { } - void SelectKeyframe(NodeKeyframe *key); + void select_keyframe(NodeKeyframe *key); - void DeselectKeyframe(NodeKeyframe *key); + void deselect_keyframe(NodeKeyframe *key); - bool IsKeyframeSelected(NodeKeyframe *key) const + bool is_keyframe_selected(NodeKeyframe *key) const { - return selection_manager_.IsSelected(key); + return selection_manager_.is_selected(key); } - rational GetUnadjustedKeyframeTime(NodeKeyframe *key, const rational &time); - rational GetUnadjustedKeyframeTime(NodeKeyframe *key) + Rational get_unadjusted_keyframe_time(NodeKeyframe *key, const Rational &time); + Rational get_unadjusted_keyframe_time(NodeKeyframe *key) { - return GetUnadjustedKeyframeTime(key, key->time()); + return get_unadjusted_keyframe_time(key, key->time()); } - rational GetAdjustedKeyframeTime(NodeKeyframe *key); + Rational get_adjusted_keyframe_time(NodeKeyframe *key); - double GetKeyframeSceneX(NodeKeyframe *key); + double get_keyframe_scene_x(NodeKeyframe *key); - virtual qreal GetKeyframeSceneY(KeyframeViewInputConnection *track, + virtual qreal get_keyframe_scene_y(KeyframeViewInputConnection *track, NodeKeyframe *key); - void SetAutoSelectSiblings(bool e) + void set_auto_select_siblings(bool e) { autoselect_siblings_ = e; } @@ -165,10 +165,10 @@ protected: virtual void SceneRectUpdateEvent(QRectF &rect) override; protected slots: - void Redraw(); + void redraw(); private: - rational CalculateNewTimeFromScreen(const rational &old_time, + Rational calculate_new_time_from_screen(const Rational &old_time, double cursor_diff); QVector tracks_; @@ -182,13 +182,13 @@ private: bool first_chance_mouse_event_; private slots: - void ShowContextMenu(); + void show_context_menu(); - void ShowKeyframePropertiesDialog(); + void show_keyframe_properties_dialog(); - void UpdateRubberBandForScroll(); + void update_rubber_band_for_scroll(); }; } -#endif // KEYFRAMEVIEWBASE_H +#endif // OAK_KEYFRAMEVIEWBASE_H diff --git a/app/widget/keyframeview/keyframeviewinputconnection.cpp b/app/widget/keyframeview/keyframeviewinputconnection.cpp index 7a0d0086a..12a9c6c15 100644 --- a/app/widget/keyframeview/keyframeviewinputconnection.cpp +++ b/app/widget/keyframeview/keyframeviewinputconnection.cpp @@ -32,77 +32,77 @@ KeyframeViewInputConnection::KeyframeViewInputConnection( , keyframe_view_(parent) , input_(input) , y_(0) - , y_behavior_(kSingleRow) + , y_behavior_(k_single_row) , brush_(Qt::white) { Node *n = input.input().node(); - connect(n, &Node::KeyframeAdded, this, - &KeyframeViewInputConnection::AddKeyframe); - connect(n, &Node::KeyframeRemoved, this, - &KeyframeViewInputConnection::RemoveKeyframe); - connect(n, &Node::KeyframeTimeChanged, this, - &KeyframeViewInputConnection::KeyframeChanged); - connect(n, &Node::KeyframeTypeChanged, this, - &KeyframeViewInputConnection::KeyframeChanged); - connect(n, &Node::KeyframeTypeChanged, this, - &KeyframeViewInputConnection::KeyframeTypeChanged); - connect(n, &Node::KeyframeValueChanged, this, - &KeyframeViewInputConnection::KeyframeChanged); + connect(n, &Node::keyframe_added, this, + &KeyframeViewInputConnection::add_keyframe); + connect(n, &Node::keyframe_removed, this, + &KeyframeViewInputConnection::remove_keyframe); + connect(n, &Node::keyframe_time_changed, this, + &KeyframeViewInputConnection::keyframe_changed); + connect(n, &Node::keyframe_type_changed, this, + &KeyframeViewInputConnection::keyframe_changed); + connect(n, &Node::keyframe_type_changed, this, + &KeyframeViewInputConnection::keyframe_type_changed); + connect(n, &Node::keyframe_value_changed, this, + &KeyframeViewInputConnection::keyframe_changed); } -void KeyframeViewInputConnection::SetKeyframeY(int y) +void KeyframeViewInputConnection::set_keyframe_y(int y) { if (y_ != y) { y_ = y; - emit RequireUpdate(); + emit require_update(); } } -void KeyframeViewInputConnection::SetYBehavior(YBehavior e) +void KeyframeViewInputConnection::set_y_behavior(YBehavior e) { if (y_behavior_ != e) { y_behavior_ = e; - emit RequireUpdate(); + emit require_update(); } } -void KeyframeViewInputConnection::SetBrush(const QBrush &brush) +void KeyframeViewInputConnection::set_brush(const QBrush &brush) { if (brush_ != brush) { brush_ = brush; - emit RequireUpdate(); + emit require_update(); } } -void KeyframeViewInputConnection::AddKeyframe(NodeKeyframe *key) +void KeyframeViewInputConnection::add_keyframe(NodeKeyframe *key) { if (key->key_track_ref() == input_) { - emit RequireUpdate(); + emit require_update(); } } -void KeyframeViewInputConnection::RemoveKeyframe(NodeKeyframe *key) +void KeyframeViewInputConnection::remove_keyframe(NodeKeyframe *key) { if (key->key_track_ref() == input_) { - emit RequireUpdate(); + emit require_update(); } } -void KeyframeViewInputConnection::KeyframeChanged(NodeKeyframe *key) +void KeyframeViewInputConnection::keyframe_changed(NodeKeyframe *key) { if (key->key_track_ref() == input_) { - emit RequireUpdate(); + emit require_update(); } } -void KeyframeViewInputConnection::KeyframeTypeChanged(NodeKeyframe *key) +void KeyframeViewInputConnection::keyframe_type_changed(NodeKeyframe *key) { if (key->key_track_ref() == input_) { - emit TypeChanged(); + emit type_changed(); } } diff --git a/app/widget/keyframeview/keyframeviewinputconnection.h b/app/widget/keyframeview/keyframeviewinputconnection.h index 1724a323a..9431f2ac0 100644 --- a/app/widget/keyframeview/keyframeviewinputconnection.h +++ b/app/widget/keyframeview/keyframeviewinputconnection.h @@ -19,8 +19,8 @@ ***/ -#ifndef KEYFRAMEVIEWINPUTCONNECTION_H -#define KEYFRAMEVIEWINPUTCONNECTION_H +#ifndef OAK_KEYFRAMEVIEWINPUTCONNECTION_H +#define OAK_KEYFRAMEVIEWINPUTCONNECTION_H #include @@ -38,41 +38,41 @@ public: KeyframeViewInputConnection(const NodeKeyframeTrackReference &input, KeyframeView *parent); - const int &GetKeyframeY() const + const int &get_keyframe_y() const { return y_; } - void SetKeyframeY(int y); + void set_keyframe_y(int y); - enum YBehavior { kSingleRow, kValueIsHeight }; + enum YBehavior { k_single_row, k_value_is_height }; - void SetYBehavior(YBehavior e); + void set_y_behavior(YBehavior e); - const QVector &GetKeyframes() const + const QVector &get_keyframes() const { return input_.input() .node() - ->GetKeyframeTracks(input_.input()) + ->get_keyframe_tracks(input_.input()) .at(input_.track()); } - const QBrush &GetBrush() const + const QBrush &get_brush() const { return brush_; } - const NodeKeyframeTrackReference &GetReference() const + const NodeKeyframeTrackReference &get_reference() const { return input_; } - void SetBrush(const QBrush &brush); + void set_brush(const QBrush &brush); signals: - void RequireUpdate(); + void require_update(); - void TypeChanged(); + void type_changed(); private: KeyframeView *keyframe_view_; @@ -86,15 +86,15 @@ private: QBrush brush_; private slots: - void AddKeyframe(NodeKeyframe *key); + void add_keyframe(NodeKeyframe *key); - void RemoveKeyframe(NodeKeyframe *key); + void remove_keyframe(NodeKeyframe *key); - void KeyframeChanged(NodeKeyframe *key); + void keyframe_changed(NodeKeyframe *key); - void KeyframeTypeChanged(NodeKeyframe *key); + void keyframe_type_changed(NodeKeyframe *key); }; } -#endif // KEYFRAMEVIEWINPUTCONNECTION_H +#endif // OAK_KEYFRAMEVIEWINPUTCONNECTION_H diff --git a/app/widget/keyframeview/keyframeviewundo.cpp b/app/widget/keyframeview/keyframeviewundo.cpp index fe24c9f34..268cda9c2 100644 --- a/app/widget/keyframeview/keyframeviewundo.cpp +++ b/app/widget/keyframeview/keyframeviewundo.cpp @@ -35,7 +35,7 @@ KeyframeSetTypeCommand::KeyframeSetTypeCommand(NodeKeyframe *key, { } -Project *KeyframeSetTypeCommand::GetRelevantProject() const +Project *KeyframeSetTypeCommand::get_relevant_project() const { return key_->parent()->project(); } @@ -69,7 +69,7 @@ KeyframeSetBezierControlPoint::KeyframeSetBezierControlPoint( { } -Project *KeyframeSetBezierControlPoint::GetRelevantProject() const +Project *KeyframeSetBezierControlPoint::get_relevant_project() const { return key_->parent()->project(); } diff --git a/app/widget/keyframeview/keyframeviewundo.h b/app/widget/keyframeview/keyframeviewundo.h index eca6c8f3e..a737f7ee8 100644 --- a/app/widget/keyframeview/keyframeviewundo.h +++ b/app/widget/keyframeview/keyframeviewundo.h @@ -19,8 +19,8 @@ ***/ -#ifndef KEYFRAMEVIEWUNDO_H -#define KEYFRAMEVIEWUNDO_H +#ifndef OAK_KEYFRAMEVIEWUNDO_H +#define OAK_KEYFRAMEVIEWUNDO_H #include "node/keyframe.h" #include "undo/undocommand.h" @@ -32,7 +32,7 @@ class KeyframeSetTypeCommand : public UndoCommand { public: KeyframeSetTypeCommand(NodeKeyframe *key, NodeKeyframe::Type type); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -56,7 +56,7 @@ public: const QPointF &new_point, const QPointF &old_point); - virtual Project *GetRelevantProject() const override; + virtual Project *get_relevant_project() const override; protected: virtual void redo() override; @@ -74,4 +74,4 @@ private: } -#endif // KEYFRAMEVIEWUNDO_H +#endif // OAK_KEYFRAMEVIEWUNDO_H diff --git a/app/widget/manageddisplay/manageddisplay.cpp b/app/widget/manageddisplay/manageddisplay.cpp index 38c9f98b1..8b43a3e81 100644 --- a/app/widget/manageddisplay/manageddisplay.cpp +++ b/app/widget/manageddisplay/manageddisplay.cpp @@ -50,10 +50,10 @@ ManagedDisplayWidget::ManagedDisplayWidget(QWidget *parent) #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND { auto *dynamic_renderer = new DynamicRenderer( - RenderManager::BackendToString( + RenderManager::backend_to_string( RenderManager::instance()->requested_backend()), this); - if (!dynamic_renderer->Load()) { + if (!dynamic_renderer->load()) { qWarning() << "Failed to load dynamic render backend for viewer, falling back to OpenGL"; delete dynamic_renderer; @@ -66,22 +66,22 @@ ManagedDisplayWidget::ManagedDisplayWidget(QWidget *parent) attached_renderer_ = new OpenGLRenderer(this); #endif - if (attached_renderer_->IsOpenGL()) { + if (attached_renderer_->is_open_gl()) { // OpenGL path inner_widget_ = new ManagedDisplayWidgetOpenGL(); inner_widget_->setAttribute(Qt::WA_TranslucentBackground, false); connect(static_cast(inner_widget_), - &ManagedDisplayWidgetOpenGL::OnInit, this, - &ManagedDisplayWidget::OnInit, Qt::DirectConnection); + &ManagedDisplayWidgetOpenGL::on_init, this, + &ManagedDisplayWidget::on_init, Qt::DirectConnection); connect(static_cast(inner_widget_), - &ManagedDisplayWidgetOpenGL::OnDestroy, this, - &ManagedDisplayWidget::OnDestroy, Qt::DirectConnection); + &ManagedDisplayWidgetOpenGL::on_destroy, this, + &ManagedDisplayWidget::on_destroy, Qt::DirectConnection); connect(static_cast(inner_widget_), - &ManagedDisplayWidgetOpenGL::OnPaint, this, - &ManagedDisplayWidget::OnPaint, Qt::DirectConnection); + &ManagedDisplayWidgetOpenGL::on_paint, this, + &ManagedDisplayWidget::on_paint, Qt::DirectConnection); connect(static_cast(inner_widget_), &ManagedDisplayWidgetOpenGL::frameSwapped, this, - &ManagedDisplayWidget::frameSwapped, Qt::DirectConnection); + &ManagedDisplayWidget::frame_swapped, Qt::DirectConnection); inner_widget_->installEventFilter(this); @@ -100,8 +100,8 @@ ManagedDisplayWidget::ManagedDisplayWidget(QWidget *parent) inner_widget_ = bn_widget; inner_widget_->setAttribute(Qt::WA_OpaquePaintEvent); inner_widget_->installEventFilter(this); - connect(bn_widget, &ManagedDisplayWidgetBackendNeutral::OnPaint, this, - &ManagedDisplayWidget::OnPaint, Qt::DirectConnection); + connect(bn_widget, &ManagedDisplayWidgetBackendNeutral::on_paint, this, + &ManagedDisplayWidget::on_paint, Qt::DirectConnection); wrapper_ = inner_widget_; layout->addWidget(wrapper_); } @@ -113,37 +113,37 @@ ManagedDisplayWidget::~ManagedDisplayWidget() MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR_INNER; disconnect(static_cast(inner_widget_), - &ManagedDisplayWidgetOpenGL::OnDestroy, this, - &ManagedDisplayWidget::OnDestroy); + &ManagedDisplayWidgetOpenGL::on_destroy, this, + &ManagedDisplayWidget::on_destroy); } else { - OnDestroy(); + on_destroy(); } } -void ManagedDisplayWidget::ConnectColorManager(ColorManager *color_manager) +void ManagedDisplayWidget::connect_color_manager(ColorManager *color_manager) { if (color_manager_ == color_manager) { return; } if (color_manager_ != nullptr) { - disconnect(color_manager_, &ColorManager::ConfigChanged, this, - &ManagedDisplayWidget::ColorConfigChanged); - disconnect(color_manager_, &ColorManager::ReferenceSpaceChanged, this, - &ManagedDisplayWidget::ColorConfigChanged); + disconnect(color_manager_, &ColorManager::config_changed, this, + &ManagedDisplayWidget::color_config_changed); + disconnect(color_manager_, &ColorManager::reference_space_changed, this, + &ManagedDisplayWidget::color_config_changed); } color_manager_ = color_manager; if (color_manager_ != nullptr) { - connect(color_manager_, &ColorManager::ConfigChanged, this, - &ManagedDisplayWidget::ColorConfigChanged); - connect(color_manager_, &ColorManager::ReferenceSpaceChanged, this, - &ManagedDisplayWidget::ColorConfigChanged); + connect(color_manager_, &ColorManager::config_changed, this, + &ManagedDisplayWidget::color_config_changed); + connect(color_manager_, &ColorManager::reference_space_changed, this, + &ManagedDisplayWidget::color_config_changed); } - ColorConfigChanged(); - emit ColorManagerChanged(color_manager_); + color_config_changed(); + emit color_manager_changed(color_manager_); } ColorManager *ManagedDisplayWidget::color_manager() const @@ -151,25 +151,25 @@ ColorManager *ManagedDisplayWidget::color_manager() const return color_manager_; } -void ManagedDisplayWidget::DisconnectColorManager() +void ManagedDisplayWidget::disconnect_color_manager() { - ConnectColorManager(nullptr); + connect_color_manager(nullptr); } -const ColorTransform &ManagedDisplayWidget::GetColorTransform() const +const ColorTransform &ManagedDisplayWidget::get_color_transform() const { return color_transform_; } -Menu *ManagedDisplayWidget::GetColorSpaceMenu(QMenu *parent, bool auto_connect) +Menu *ManagedDisplayWidget::get_color_space_menu(QMenu *parent, bool auto_connect) { - QStringList colorspaces = color_manager()->ListAvailableColorspaces(); + QStringList colorspaces = color_manager()->list_available_colorspaces(); Menu *ocio_colorspace_menu = new Menu(tr("Color Space"), parent); if (auto_connect) { connect(ocio_colorspace_menu, &Menu::triggered, this, - &ManagedDisplayWidget::MenuColorspaceSelect); + &ManagedDisplayWidget::menu_colorspace_select); } foreach (const QString &c, colorspaces) { @@ -182,7 +182,7 @@ Menu *ManagedDisplayWidget::GetColorSpaceMenu(QMenu *parent, bool auto_connect) return ocio_colorspace_menu; } -void ManagedDisplayWidget::ColorConfigChanged() +void ManagedDisplayWidget::color_config_changed() { if (!color_manager_) { color_service_ = nullptr; @@ -195,13 +195,13 @@ void ManagedDisplayWidget::ColorConfigChanged() // which is usually a scene-referred space (e.g. ACEScg / Linear) and makes // the picture look raw/wrong on a monitor. if (color_transform_.output().isEmpty()) { - QString display = color_manager_->GetDefaultDisplay(); - QString view = color_manager_->GetDefaultView(display); - SetColorTransform(color_manager_->GetCompliantColorSpace( + QString display = color_manager_->get_default_display(); + QString view = color_manager_->get_default_view(display); + set_color_transform(color_manager_->get_compliant_color_space( ColorTransform(display, view, QString()), true)); } else { - SetColorTransform( - color_manager_->GetCompliantColorSpace(color_transform_, false)); + set_color_transform( + color_manager_->get_compliant_color_space(color_transform_, false)); } } @@ -210,16 +210,16 @@ ColorProcessorPtr ManagedDisplayWidget::color_service() return color_service_; } -void ManagedDisplayWidget::ShowDefaultContextMenu() +void ManagedDisplayWidget::show_default_context_menu() { Menu m(this); if (color_manager_) { - m.addMenu(GetColorSpaceMenu(&m)); + m.addMenu(get_color_space_menu(&m)); m.addSeparator(); - m.addMenu(GetDisplayMenu(&m)); - m.addMenu(GetViewMenu(&m)); - m.addMenu(GetLookMenu(&m)); + m.addMenu(get_display_menu(&m)); + m.addMenu(get_view_menu(&m)); + m.addMenu(get_look_menu(&m)); } else { QAction *a = m.addAction(tr("No color manager connected")); a->setEnabled(false); @@ -228,61 +228,61 @@ void ManagedDisplayWidget::ShowDefaultContextMenu() m.exec(QCursor::pos()); } -void ManagedDisplayWidget::MenuDisplaySelect(QAction *action) +void ManagedDisplayWidget::menu_display_select(QAction *action) { - const ColorTransform &old_transform = GetColorTransform(); + const ColorTransform &old_transform = get_color_transform(); - ColorTransform new_transform = color_manager()->GetCompliantColorSpace( + ColorTransform new_transform = color_manager()->get_compliant_color_space( ColorTransform(action->data().toString(), old_transform.view(), old_transform.look())); - SetColorTransform(new_transform); + set_color_transform(new_transform); } -void ManagedDisplayWidget::MenuViewSelect(QAction *action) +void ManagedDisplayWidget::menu_view_select(QAction *action) { - const ColorTransform &old_transform = GetColorTransform(); + const ColorTransform &old_transform = get_color_transform(); - ColorTransform new_transform = color_manager()->GetCompliantColorSpace( + ColorTransform new_transform = color_manager()->get_compliant_color_space( ColorTransform(old_transform.display(), action->data().toString(), old_transform.look())); - SetColorTransform(new_transform); + set_color_transform(new_transform); } -void ManagedDisplayWidget::MenuLookSelect(QAction *action) +void ManagedDisplayWidget::menu_look_select(QAction *action) { - const ColorTransform &old_transform = GetColorTransform(); + const ColorTransform &old_transform = get_color_transform(); - ColorTransform new_transform = color_manager()->GetCompliantColorSpace( + ColorTransform new_transform = color_manager()->get_compliant_color_space( ColorTransform(old_transform.display(), old_transform.view(), action->data().toString())); - SetColorTransform(new_transform); + set_color_transform(new_transform); } -void ManagedDisplayWidget::MenuColorspaceSelect(QAction *action) +void ManagedDisplayWidget::menu_colorspace_select(QAction *action) { - SetColorTransform(color_manager()->GetCompliantColorSpace( + set_color_transform(color_manager()->get_compliant_color_space( ColorTransform(action->data().toString()))); } -void ManagedDisplayWidget::OnDestroy() +void ManagedDisplayWidget::on_destroy() { - attached_renderer_->Destroy(); - attached_renderer_->PostDestroy(); + attached_renderer_->destroy(); + attached_renderer_->post_destroy(); } -void ManagedDisplayWidget::SetColorTransform(const ColorTransform &transform) +void ManagedDisplayWidget::set_color_transform(const ColorTransform &transform) { color_transform_ = transform; - SetupColorProcessor(); + setup_color_processor(); ColorProcessorChangedEvent(); } -void ManagedDisplayWidget::OnInit() +void ManagedDisplayWidget::on_init() { if (!is_backend_neutral_) { QOpenGLContext *context = @@ -290,23 +290,23 @@ void ManagedDisplayWidget::OnInit() #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND if (auto *dynamic_renderer = dynamic_cast(attached_renderer_)) { - dynamic_renderer->InitWithOpenGLContext(context); - dynamic_renderer->PostInit(); + dynamic_renderer->init_with_open_gl_context(context); + dynamic_renderer->post_init(); return; } #endif - static_cast(attached_renderer_)->Init(context); - static_cast(attached_renderer_)->PostInit(); + static_cast(attached_renderer_)->init(context); + static_cast(attached_renderer_)->post_init(); } else { - attached_renderer_->Init(); - attached_renderer_->PostInit(); + attached_renderer_->init(); + attached_renderer_->post_init(); } } -void ManagedDisplayWidget::EnableDefaultContextMenu() +void ManagedDisplayWidget::enable_default_context_menu() { connect(this, &ManagedDisplayWidget::customContextMenuRequested, this, - &ManagedDisplayWidget::ShowDefaultContextMenu); + &ManagedDisplayWidget::show_default_context_menu); } void ManagedDisplayWidget::ColorProcessorChangedEvent() @@ -314,14 +314,14 @@ void ManagedDisplayWidget::ColorProcessorChangedEvent() update(); } -void ManagedDisplayWidget::makeCurrent() +void ManagedDisplayWidget::make_current() { if (!is_backend_neutral_) { static_cast(inner_widget_)->makeCurrent(); } } -void ManagedDisplayWidget::doneCurrent() +void ManagedDisplayWidget::done_current() { if (!is_backend_neutral_) { static_cast(inner_widget_)->doneCurrent(); @@ -333,21 +333,21 @@ QPaintDevice *ManagedDisplayWidget::paint_device() const return inner_widget_; } -void ManagedDisplayWidget::SetInnerMouseTracking(bool e) +void ManagedDisplayWidget::set_inner_mouse_tracking(bool e) { if (wrapper_) { wrapper_->setMouseTracking(e); } } -VideoParams ManagedDisplayWidget::GetViewportParams() const +VideoParams ManagedDisplayWidget::get_viewport_params() const { int device_width = width() * devicePixelRatioF(); int device_height = height() * devicePixelRatioF(); PixelFormat device_format = static_cast( - OLIVE_CONFIG("OfflinePixelFormat").toInt()); + OAK_CONFIG("OfflinePixelFormat").toInt()); return VideoParams(device_width, device_height, device_format, - VideoParams::kInternalChannelCount); + VideoParams::k_internal_channel_count); } void ManagedDisplayWidget::update() @@ -367,7 +367,7 @@ bool ManagedDisplayWidget::eventFilter(QObject *o, QEvent *e) case QEvent::FocusIn: // HACK: QWindow focus isn't accounted for in QApplication::focusChanged, so we handle it // manually here. - PanelManager::instance()->FocusChanged(nullptr, this); + PanelManager::instance()->focus_changed(nullptr, this); break; case QEvent::ContextMenu: { QContextMenuEvent *ctx = static_cast(e); @@ -391,15 +391,15 @@ bool ManagedDisplayWidget::eventFilter(QObject *o, QEvent *e) return super::eventFilter(o, e); } -Menu *ManagedDisplayWidget::GetDisplayMenu(QMenu *parent, bool auto_connect) +Menu *ManagedDisplayWidget::get_display_menu(QMenu *parent, bool auto_connect) { - QStringList displays = color_manager()->ListAvailableDisplays(); + QStringList displays = color_manager()->list_available_displays(); Menu *ocio_display_menu = new Menu(tr("Display"), parent); if (auto_connect) { connect(ocio_display_menu, &Menu::triggered, this, - &ManagedDisplayWidget::MenuDisplaySelect); + &ManagedDisplayWidget::menu_display_select); } foreach (const QString &d, displays) { @@ -412,16 +412,16 @@ Menu *ManagedDisplayWidget::GetDisplayMenu(QMenu *parent, bool auto_connect) return ocio_display_menu; } -Menu *ManagedDisplayWidget::GetViewMenu(QMenu *parent, bool auto_connect) +Menu *ManagedDisplayWidget::get_view_menu(QMenu *parent, bool auto_connect) { QStringList views = - color_manager()->ListAvailableViews(color_transform_.display()); + color_manager()->list_available_views(color_transform_.display()); Menu *ocio_view_menu = new Menu(tr("View"), parent); if (auto_connect) { connect(ocio_view_menu, &Menu::triggered, this, - &ManagedDisplayWidget::MenuViewSelect); + &ManagedDisplayWidget::menu_view_select); } foreach (const QString &v, views) { @@ -434,15 +434,15 @@ Menu *ManagedDisplayWidget::GetViewMenu(QMenu *parent, bool auto_connect) return ocio_view_menu; } -Menu *ManagedDisplayWidget::GetLookMenu(QMenu *parent, bool auto_connect) +Menu *ManagedDisplayWidget::get_look_menu(QMenu *parent, bool auto_connect) { - QStringList looks = color_manager()->ListAvailableLooks(); + QStringList looks = color_manager()->list_available_looks(); Menu *ocio_look_menu = new Menu(tr("Look"), parent); if (auto_connect) { connect(ocio_look_menu, &Menu::triggered, this, - &ManagedDisplayWidget::MenuLookSelect); + &ManagedDisplayWidget::menu_look_select); } // Setup "no look" action @@ -462,17 +462,17 @@ Menu *ManagedDisplayWidget::GetLookMenu(QMenu *parent, bool auto_connect) return ocio_look_menu; } -void ManagedDisplayWidget::SetupColorProcessor() +void ManagedDisplayWidget::setup_color_processor() { color_service_ = nullptr; if (color_manager_) { // (Re)create color processor try { - color_service_ = ColorProcessor::Create( - color_manager_, color_manager_->GetReferenceColorSpace(), + color_service_ = ColorProcessor::create( + color_manager_, color_manager_->get_reference_color_space(), color_transform_); - } catch (OCIO::Exception &e) { + } catch (ocio::Exception &e) { QMessageBox::critical( this, tr("OpenColorIO Error"), tr("Failed to set color configuration: %1").arg(e.what()), @@ -482,7 +482,7 @@ void ManagedDisplayWidget::SetupColorProcessor() color_service_ = nullptr; } - emit ColorProcessorChanged(color_service_); + emit color_processor_changed(color_service_); } } diff --git a/app/widget/manageddisplay/manageddisplay.h b/app/widget/manageddisplay/manageddisplay.h index 1c299e9fa..1c6c8186a 100644 --- a/app/widget/manageddisplay/manageddisplay.h +++ b/app/widget/manageddisplay/manageddisplay.h @@ -19,8 +19,8 @@ ***/ -#ifndef MANAGEDDISPLAYOBJECT_H -#define MANAGEDDISPLAYOBJECT_H +#ifndef OAK_MANAGEDDISPLAYOBJECT_H +#define OAK_MANAGEDDISPLAYOBJECT_H //#define USE_QOPENGLWINDOW @@ -53,48 +53,48 @@ public: virtual ~ManagedDisplayWidgetOpenGL() override { if (context()) { - DestroyListener(); + destroy_listener(); disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, - &ManagedDisplayWidgetOpenGL::DestroyListener); + &ManagedDisplayWidgetOpenGL::destroy_listener); } } signals: // Render signals - void OnInit(); - void OnPaint(); - void OnDestroy(); + void on_init(); + void on_paint(); + void on_destroy(); protected: virtual void initializeGL() override { connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, - &ManagedDisplayWidgetOpenGL::DestroyListener, + &ManagedDisplayWidgetOpenGL::destroy_listener, Qt::DirectConnection); - emit OnInit(); + emit on_init(); } virtual void paintGL() override { - emit OnPaint(); + emit on_paint(); } private slots: - void DestroyListener() + void destroy_listener() { makeCurrent(); - emit OnDestroy(); + emit on_destroy(); doneCurrent(); } }; #define MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR_INNER \ - makeCurrent(); \ - OnDestroy(); \ - doneCurrent() + make_current(); \ + on_destroy(); \ + done_current() #define MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(x) \ virtual ~x() override \ { \ @@ -116,14 +116,14 @@ public: } signals: - void OnPaint(); + void on_paint(); protected: virtual void paintEvent(QPaintEvent *event) override { QWidget::paintEvent(event); - emit OnPaint(); + emit on_paint(); } }; @@ -137,7 +137,7 @@ public: /** * @brief Disconnect a ColorManager (equivalent to ConnectColorManager(nullptr)) */ - void DisconnectColorManager(); + void disconnect_color_manager(); /** * @brief Access currently connected ColorManager (nullptr if none) @@ -147,27 +147,27 @@ public: /** * @brief Get current color transform */ - const ColorTransform &GetColorTransform() const; + const ColorTransform &get_color_transform() const; /** * @brief Get menu that can be used to select the colorspace */ - Menu *GetColorSpaceMenu(QMenu *parent, bool auto_connect = true); + Menu *get_color_space_menu(QMenu *parent, bool auto_connect = true); /** * @brief Get menu that can be used to select the display transform */ - Menu *GetDisplayMenu(QMenu *parent, bool auto_connect = true); + Menu *get_display_menu(QMenu *parent, bool auto_connect = true); /** * @brief Get menu that can be used to select the view transform */ - Menu *GetViewMenu(QMenu *parent, bool auto_connect = true); + Menu *get_view_menu(QMenu *parent, bool auto_connect = true); /** * @brief Get menu that can be used to select the look transform */ - Menu *GetLookMenu(QMenu *parent, bool auto_connect = true); + Menu *get_look_menu(QMenu *parent, bool auto_connect = true); /** * @brief Passes update signal through to inner widget @@ -180,25 +180,25 @@ public slots: /** * @brief Replaces the color transform with a new one */ - void SetColorTransform(const ColorTransform &transform); + void set_color_transform(const ColorTransform &transform); /** * @brief Connect a ColorManager (ColorManagers usually belong to the Project) */ - void ConnectColorManager(ColorManager *color_manager); + void connect_color_manager(ColorManager *color_manager); signals: /** * @brief Emitted when the color processor changes */ - void ColorProcessorChanged(ColorProcessorPtr processor); + void color_processor_changed(ColorProcessorPtr processor); /** * @brief Emitted when a new color manager is connected */ - void ColorManagerChanged(ColorManager *color_manager); + void color_manager_changed(ColorManager *color_manager); - void frameSwapped(); + void frame_swapped(); protected: /** @@ -209,7 +209,7 @@ protected: /** * @brief Enables a context menu that allows simple access to the DVL pipeline */ - void EnableDefaultContextMenu(); + void enable_default_context_menu(); /** * @brief Function called whenever the processor changes @@ -223,9 +223,9 @@ protected: return attached_renderer_; } - void makeCurrent(); + void make_current(); - void doneCurrent(); + void done_current(); #ifdef USE_QOPENGLWINDOW QWindow * @@ -245,46 +245,46 @@ protected: */ QPaintDevice *paint_device() const; - void SetInnerMouseTracking(bool e); + void set_inner_mouse_tracking(bool e); - bool IsBackendNeutral() const + bool is_backend_neutral() const { return is_backend_neutral_; } - QRect GetInnerRect() const + QRect get_inner_rect() const { return wrapper_ ? wrapper_->rect() : QRect(); } - VideoParams GetViewportParams() const; + VideoParams get_viewport_params() const; protected slots: /** * @brief Called whenever the internal rendering context has been created */ - virtual void OnInit(); + virtual void on_init(); /** * @brief Called while the internal rendering context is being rendered */ - virtual void OnPaint() = 0; + virtual void on_paint() = 0; /** * @brief Called just before the internal rendering context is destroyed */ - virtual void OnDestroy(); + virtual void on_destroy(); private: /** * @brief Call this if this user has selected a different display/view/look to recreate the processor */ - void SetupColorProcessor(); + void setup_color_processor(); /** * @brief Cleanup function */ - void ClearOCIOLutTexture(); + void clear_ocio_lut_texture(); /** * @brief Main drawing surface abstraction @@ -322,34 +322,34 @@ private slots: /** * @brief Sets all color settings to the defaults pertaining to this configuration */ - void ColorConfigChanged(); + void color_config_changed(); /** * @brief The default context menu shown */ - void ShowDefaultContextMenu(); + void show_default_context_menu(); /** * @brief If GetDisplayMenu() is called with `auto_connect` set to true, it will be connected to this */ - void MenuDisplaySelect(QAction *action); + void menu_display_select(QAction *action); /** * @brief If GetViewMenu() is called with `auto_connect` set to true, it will be connected to this */ - void MenuViewSelect(QAction *action); + void menu_view_select(QAction *action); /** * @brief If GetLookMenu() is called with `auto_connect` set to true, it will be connected to this */ - void MenuLookSelect(QAction *action); + void menu_look_select(QAction *action); /** * @brief If GetColorSpaceMenu() is called with `auto_connect` set to true, it will be connected to this */ - void MenuColorspaceSelect(QAction *action); + void menu_colorspace_select(QAction *action); }; } -#endif // MANAGEDDISPLAYOBJECT_H +#endif // OAK_MANAGEDDISPLAYOBJECT_H diff --git a/app/widget/menu/menu.cpp b/app/widget/menu/menu.cpp index 3013d29d6..765e003c3 100644 --- a/app/widget/menu/menu.cpp +++ b/app/widget/menu/menu.cpp @@ -30,29 +30,29 @@ Menu::Menu(QMenuBar *bar) { bar->addMenu(this); - Init(); + init(); } Menu::Menu(Menu *menu) { menu->addMenu(this); - Init(); + init(); } Menu::Menu(QWidget *parent) : QMenu(parent) { - Init(); + init(); } Menu::Menu(const QString &s, QWidget *parent) : QMenu(s, parent) { - Init(); + init(); } -QAction *Menu::AddActionWithData(const QString &text, const QVariant &d, +QAction *Menu::add_action_with_data(const QString &text, const QVariant &d, const QVariant &compare) { QAction *a = addAction(text); @@ -64,14 +64,14 @@ QAction *Menu::AddActionWithData(const QString &text, const QVariant &d, return a; } -QAction *Menu::InsertAlphabetically(const QString &s) +QAction *Menu::insert_alphabetically(const QString &s) { QAction *action = new QAction(s, this); - InsertAlphabetically(action); + insert_alphabetically(action); return action; } -void Menu::InsertAlphabetically(QAction *entry) +void Menu::insert_alphabetically(QAction *entry) { QList actions = this->actions(); @@ -85,12 +85,12 @@ void Menu::InsertAlphabetically(QAction *entry) addAction(entry); } -void Menu::InsertAlphabetically(Menu *menu) +void Menu::insert_alphabetically(Menu *menu) { - InsertAlphabetically(menu->menuAction()); + insert_alphabetically(menu->menuAction()); } -void Menu::ConformItem(QAction *a, const QString &id, const QKeySequence &key) +void Menu::conform_item(QAction *a, const QString &id, const QKeySequence &key) { a->setProperty("id", id); @@ -103,7 +103,7 @@ void Menu::ConformItem(QAction *a, const QString &id, const QKeySequence &key) } } -void Menu::Init() +void Menu::init() { // HACK: Disables embossing on disabled text for a slightly nicer UI QPalette p = palette(); diff --git a/app/widget/menu/menu.h b/app/widget/menu/menu.h index d4e1b8f53..1660504eb 100644 --- a/app/widget/menu/menu.h +++ b/app/widget/menu/menu.h @@ -19,8 +19,8 @@ ***/ -#ifndef WIDGETMENU_H -#define WIDGETMENU_H +#ifndef OAK_WIDGETMENU_H +#define OAK_WIDGETMENU_H #include #include @@ -63,8 +63,8 @@ public: { bar->addMenu(this); - Init(); - ConnectAboutToShow(receiver, member); + init(); + connect_about_to_show(receiver, member); } Menu(Menu *menu); @@ -82,7 +82,7 @@ public: { menu->addMenu(this); - Init(); + init(); ConnectAboutToShow(receiver, member); } @@ -121,23 +121,23 @@ public: * The QAction that was created and added to this Menu */ QAction * - AddItem(const QString &id, + add_item(const QString &id, const typename QtPrivate::FunctionPointer::Object *receiver, Func member, const QKeySequence &key = QKeySequence()) { - QAction *a = CreateItem(this, id, receiver, member, key); + QAction *a = create_item(this, id, receiver, member, key); addAction(a); return a; } - QAction *AddActionWithData(const QString &text, const QVariant &d, + QAction *add_action_with_data(const QString &text, const QVariant &d, const QVariant &compare); - QAction *InsertAlphabetically(const QString &s); - void InsertAlphabetically(QAction *entry); - void InsertAlphabetically(Menu *menu); + QAction *insert_alphabetically(const QString &s); + void insert_alphabetically(QAction *entry); + void insert_alphabetically(Menu *menu); template /** @@ -167,14 +167,14 @@ public: * * The QAction that was created and added to this Menu */ - static QAction *CreateItem( + static QAction *create_item( QObject *parent, const QString &id, const typename QtPrivate::FunctionPointer::Object *receiver, Func member, const QKeySequence &key = QKeySequence()) { QAction *a = new QAction(parent); - ConformItem(a, id, receiver, member, key); + conform_item(a, id, receiver, member, key); return a; } @@ -206,24 +206,24 @@ public: * * Default keyboard sequence */ - static void ConformItem( + static void conform_item( QAction *a, const QString &id, const typename QtPrivate::FunctionPointer::Object *receiver, Func member, const QKeySequence &key = QKeySequence()) { - ConformItem(a, id, key); + conform_item(a, id, key); connect(a, &QAction::triggered, receiver, member); } - static void ConformItem(QAction *a, const QString &id, + static void conform_item(QAction *a, const QString &id, const QKeySequence &key = QKeySequence()); private: - void Init(); + void init(); template - void ConnectAboutToShow( + void connect_about_to_show( const typename QtPrivate::FunctionPointer::Object *receiver, Func member) { @@ -233,4 +233,4 @@ private: } -#endif // WIDGETMENU_H +#endif // OAK_WIDGETMENU_H diff --git a/app/widget/menu/menushared.cpp b/app/widget/menu/menushared.cpp index 957285903..0d6ff7c7d 100644 --- a/app/widget/menu/menushared.cpp +++ b/app/widget/menu/menushared.cpp @@ -36,115 +36,115 @@ MenuShared *MenuShared::instance_ = nullptr; MenuShared::MenuShared() { // "New" menu shared items - new_project_item_ = Menu::CreateItem(this, "newproj", Core::instance(), - &Core::CreateNewProject, tr("Ctrl+N")); - new_sequence_item_ = Menu::CreateItem(this, "newseq", Core::instance(), - &Core::CreateNewSequence, + new_project_item_ = Menu::create_item(this, "newproj", Core::instance(), + &Core::create_new_project, tr("Ctrl+N")); + new_sequence_item_ = Menu::create_item(this, "newseq", Core::instance(), + &Core::create_new_sequence, tr("Ctrl+Shift+N")); - new_folder_item_ = Menu::CreateItem(this, "newfolder", Core::instance(), - &Core::CreateNewFolder); + new_folder_item_ = Menu::create_item(this, "newfolder", Core::instance(), + &Core::create_new_folder); // "Edit" menu shared items - edit_cut_item_ = Menu::CreateItem(this, "cut", this, - &MenuShared::CutTriggered, tr("Ctrl+X")); - edit_copy_item_ = Menu::CreateItem( - this, "copy", this, &MenuShared::CopyTriggered, tr("Ctrl+C")); - edit_paste_item_ = Menu::CreateItem( - this, "paste", this, &MenuShared::PasteTriggered, tr("Ctrl+V")); + edit_cut_item_ = Menu::create_item(this, "cut", this, + &MenuShared::cut_triggered, tr("Ctrl+X")); + edit_copy_item_ = Menu::create_item( + this, "copy", this, &MenuShared::copy_triggered, tr("Ctrl+C")); + edit_paste_item_ = Menu::create_item( + this, "paste", this, &MenuShared::paste_triggered, tr("Ctrl+V")); edit_paste_insert_item_ = - Menu::CreateItem(this, "pasteinsert", this, - &MenuShared::PasteInsertTriggered, tr("Ctrl+Shift+V")); - edit_duplicate_item_ = Menu::CreateItem( - this, "duplicate", this, &MenuShared::DuplicateTriggered, tr("Ctrl+D")); - edit_rename_item_ = Menu::CreateItem( - this, "rename", this, &MenuShared::RenameSelectedTriggered, tr("F2")); - edit_delete_item_ = Menu::CreateItem( - this, "delete", this, &MenuShared::DeleteSelectedTriggered, tr("Del")); + Menu::create_item(this, "pasteinsert", this, + &MenuShared::paste_insert_triggered, tr("Ctrl+Shift+V")); + edit_duplicate_item_ = Menu::create_item( + this, "duplicate", this, &MenuShared::duplicate_triggered, tr("Ctrl+D")); + edit_rename_item_ = Menu::create_item( + this, "rename", this, &MenuShared::rename_selected_triggered, tr("F2")); + edit_delete_item_ = Menu::create_item( + this, "delete", this, &MenuShared::delete_selected_triggered, tr("Del")); edit_ripple_delete_item_ = - Menu::CreateItem(this, "rippledelete", this, - &MenuShared::RippleDeleteTriggered, tr("Shift+Del")); - edit_split_item_ = Menu::CreateItem(this, "split", this, - &MenuShared::SplitAtPlayheadTriggered, + Menu::create_item(this, "rippledelete", this, + &MenuShared::ripple_delete_triggered, tr("Shift+Del")); + edit_split_item_ = Menu::create_item(this, "split", this, + &MenuShared::split_at_playhead_triggered, tr("Ctrl+K")); edit_speedduration_item_ = - Menu::CreateItem(this, "speeddur", this, - &MenuShared::SpeedDurationTriggered, tr("Ctrl+R")); + Menu::create_item(this, "speeddur", this, + &MenuShared::speed_duration_triggered, tr("Ctrl+R")); // List of addable items - for (int i = 0; i < Tool::kAddableCount; i++) { + for (int i = 0; i < Tool::k_addable_count; i++) { Tool::AddableObject t = static_cast(i); - QAction *a = Menu::CreateItem( - this, QStringLiteral("add:%1").arg(Tool::GetAddableObjectID(t)), - this, &MenuShared::AddableItemTriggered); + QAction *a = Menu::create_item( + this, QStringLiteral("add:%1").arg(Tool::get_addable_object_id(t)), + this, &MenuShared::addable_item_triggered); a->setData(t); addable_items_.append(a); } // "In/Out" menu shared items - inout_set_in_item_ = Menu::CreateItem(this, "setinpoint", this, - &MenuShared::SetInTriggered, tr("I")); - inout_set_out_item_ = Menu::CreateItem( - this, "setoutpoint", this, &MenuShared::SetOutTriggered, tr("O")); + inout_set_in_item_ = Menu::create_item(this, "setinpoint", this, + &MenuShared::set_in_triggered, tr("I")); + inout_set_out_item_ = Menu::create_item( + this, "setoutpoint", this, &MenuShared::set_out_triggered, tr("O")); inout_reset_in_item_ = - Menu::CreateItem(this, "resetin", this, &MenuShared::ResetInTriggered); - inout_reset_out_item_ = Menu::CreateItem(this, "resetout", this, - &MenuShared::ResetOutTriggered); - inout_clear_inout_item_ = Menu::CreateItem( - this, "clearinout", this, &MenuShared::ClearInOutTriggered, tr("G")); + Menu::create_item(this, "resetin", this, &MenuShared::reset_in_triggered); + inout_reset_out_item_ = Menu::create_item(this, "resetout", this, + &MenuShared::reset_out_triggered); + inout_clear_inout_item_ = Menu::create_item( + this, "clearinout", this, &MenuShared::clear_in_out_triggered, tr("G")); // "Clip Edit" menu shared items - clip_add_default_transition_item_ = Menu::CreateItem( - this, "deftransition", this, &MenuShared::DefaultTransitionTriggered, + clip_add_default_transition_item_ = Menu::create_item( + this, "deftransition", this, &MenuShared::default_transition_triggered, tr("Ctrl+Shift+D")); - clip_link_unlink_item_ = Menu::CreateItem(this, "linkunlink", this, - &MenuShared::ToggleLinksTriggered, + clip_link_unlink_item_ = Menu::create_item(this, "linkunlink", this, + &MenuShared::toggle_links_triggered, tr("Ctrl+L")); clip_enable_disable_item_ = - Menu::CreateItem(this, "enabledisable", this, - &MenuShared::EnableDisableTriggered, tr("Shift+E")); + Menu::create_item(this, "enabledisable", this, + &MenuShared::enable_disable_triggered, tr("Shift+E")); clip_nest_item_ = - Menu::CreateItem(this, "nest", this, &MenuShared::NestTriggered); + Menu::create_item(this, "nest", this, &MenuShared::nest_triggered); // TimeRuler menu shared items frame_view_mode_group_ = new QActionGroup(this); - view_timecode_view_dropframe_item_ = Menu::CreateItem( - this, "modedropframe", this, &MenuShared::TimecodeDisplayTriggered); - view_timecode_view_dropframe_item_->setData(Timecode::kTimecodeDropFrame); + view_timecode_view_dropframe_item_ = Menu::create_item( + this, "modedropframe", this, &MenuShared::timecode_display_triggered); + view_timecode_view_dropframe_item_->setData(Timecode::k_timecode_drop_frame); view_timecode_view_dropframe_item_->setCheckable(true); frame_view_mode_group_->addAction(view_timecode_view_dropframe_item_); - view_timecode_view_nondropframe_item_ = Menu::CreateItem( - this, "modenondropframe", this, &MenuShared::TimecodeDisplayTriggered); + view_timecode_view_nondropframe_item_ = Menu::create_item( + this, "modenondropframe", this, &MenuShared::timecode_display_triggered); view_timecode_view_nondropframe_item_->setData( - Timecode::kTimecodeNonDropFrame); + Timecode::k_timecode_non_drop_frame); view_timecode_view_nondropframe_item_->setCheckable(true); frame_view_mode_group_->addAction(view_timecode_view_nondropframe_item_); - view_timecode_view_seconds_item_ = Menu::CreateItem( - this, "modeseconds", this, &MenuShared::TimecodeDisplayTriggered); - view_timecode_view_seconds_item_->setData(Timecode::kTimecodeSeconds); + view_timecode_view_seconds_item_ = Menu::create_item( + this, "modeseconds", this, &MenuShared::timecode_display_triggered); + view_timecode_view_seconds_item_->setData(Timecode::k_timecode_seconds); view_timecode_view_seconds_item_->setCheckable(true); frame_view_mode_group_->addAction(view_timecode_view_seconds_item_); - view_timecode_view_frames_item_ = Menu::CreateItem( - this, "modeframes", this, &MenuShared::TimecodeDisplayTriggered); - view_timecode_view_frames_item_->setData(Timecode::kFrames); + view_timecode_view_frames_item_ = Menu::create_item( + this, "modeframes", this, &MenuShared::timecode_display_triggered); + view_timecode_view_frames_item_->setData(Timecode::k_frames); view_timecode_view_frames_item_->setCheckable(true); frame_view_mode_group_->addAction(view_timecode_view_frames_item_); - view_timecode_view_milliseconds_item_ = Menu::CreateItem( - this, "milliseconds", this, &MenuShared::TimecodeDisplayTriggered); - view_timecode_view_milliseconds_item_->setData(Timecode::kMilliseconds); + view_timecode_view_milliseconds_item_ = Menu::create_item( + this, "milliseconds", this, &MenuShared::timecode_display_triggered); + view_timecode_view_milliseconds_item_->setData(Timecode::k_milliseconds); view_timecode_view_milliseconds_item_->setCheckable(true); frame_view_mode_group_->addAction(view_timecode_view_milliseconds_item_); // Color coding menu items color_coding_menu_ = new ColorLabelMenu(); - connect(color_coding_menu_, &ColorLabelMenu::ColorSelected, this, - &MenuShared::ColorLabelTriggered); + connect(color_coding_menu_, &ColorLabelMenu::color_selected, this, + &MenuShared::color_label_triggered); - Retranslate(); + retranslate(); } MenuShared::~MenuShared() @@ -152,17 +152,17 @@ MenuShared::~MenuShared() delete color_coding_menu_; } -void MenuShared::CreateInstance() +void MenuShared::create_instance() { instance_ = new MenuShared(); } -void MenuShared::DestroyInstance() +void MenuShared::destroy_instance() { delete instance_; } -void MenuShared::AddItemsForNewMenu(Menu *m) +void MenuShared::add_items_for_new_menu(Menu *m) { m->addAction(new_project_item_); m->addSeparator(); @@ -170,7 +170,7 @@ void MenuShared::AddItemsForNewMenu(Menu *m) m->addAction(new_folder_item_); } -void MenuShared::AddItemsForEditMenu(Menu *m, bool for_clips) +void MenuShared::add_items_for_edit_menu(Menu *m, bool for_clips) { m->addAction(Core::instance()->undo_stack()->GetUndoAction()); m->addAction(Core::instance()->undo_stack()->GetRedoAction()); @@ -199,16 +199,16 @@ void MenuShared::AddItemsForEditMenu(Menu *m, bool for_clips) } } -void MenuShared::AddItemsForAddableObjectsMenu(Menu *m) +void MenuShared::add_items_for_addable_objects_menu(Menu *m) { for (QAction *a : qAsConst(addable_items_)) { a->setChecked((a->data().toInt() == - Core::instance()->GetSelectedAddableObject())); + Core::instance()->get_selected_addable_object())); m->addAction(a); } } -void MenuShared::AddItemsForInOutMenu(Menu *m) +void MenuShared::add_items_for_in_out_menu(Menu *m) { m->addAction(inout_set_in_item_); m->addAction(inout_set_out_item_); @@ -218,12 +218,12 @@ void MenuShared::AddItemsForInOutMenu(Menu *m) m->addAction(inout_clear_inout_item_); } -void MenuShared::AddColorCodingMenu(Menu *m) +void MenuShared::add_color_coding_menu(Menu *m) { m->addMenu(color_coding_menu_); } -void MenuShared::AddItemsForClipEditMenu(Menu *m) +void MenuShared::add_items_for_clip_edit_menu(Menu *m) { m->addAction(clip_add_default_transition_item_); m->addAction(clip_link_unlink_item_); @@ -231,7 +231,7 @@ void MenuShared::AddItemsForClipEditMenu(Menu *m) m->addAction(clip_nest_item_); } -void MenuShared::AddItemsForTimeRulerMenu(Menu *m) +void MenuShared::add_items_for_time_ruler_menu(Menu *m) { m->addAction(view_timecode_view_dropframe_item_); m->addAction(view_timecode_view_nondropframe_item_); @@ -240,21 +240,21 @@ void MenuShared::AddItemsForTimeRulerMenu(Menu *m) m->addAction(view_timecode_view_milliseconds_item_); } -void MenuShared::AboutToShowTimeRulerActions(const rational &timebase) +void MenuShared::about_to_show_time_ruler_actions(const Rational &timebase) { QList timecode_display_actions = frame_view_mode_group_->actions(); Timecode::Display current_timecode_display = - Core::instance()->GetTimecodeDisplay(); + Core::instance()->get_timecode_display(); // Only show the drop-frame option if the timebase is drop-frame view_timecode_view_dropframe_item_->setVisible( !timebase.isNull() && Timecode::timebase_is_drop_frame(timebase)); if (!view_timecode_view_dropframe_item_->isVisible() && - current_timecode_display == Timecode::kTimecodeDropFrame) { + current_timecode_display == Timecode::k_timecode_drop_frame) { // If the current setting is drop-frame, correct to non-drop frame - current_timecode_display = Timecode::kTimecodeNonDropFrame; + current_timecode_display = Timecode::k_timecode_non_drop_frame; } foreach (QAction *a, timecode_display_actions) { @@ -270,106 +270,106 @@ MenuShared *MenuShared::instance() return instance_; } -void MenuShared::SplitAtPlayheadTriggered() +void MenuShared::split_at_playhead_triggered() { TimelinePanel *timeline = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); if (timeline != nullptr) { - timeline->SplitAtPlayhead(); + timeline->split_at_playhead(); } } -void MenuShared::DeleteSelectedTriggered() +void MenuShared::delete_selected_triggered() { - PanelManager::instance()->CurrentlyFocused()->DeleteSelected(); + PanelManager::instance()->currently_focused()->delete_selected(); } -void MenuShared::RippleDeleteTriggered() +void MenuShared::ripple_delete_triggered() { - PanelManager::instance()->CurrentlyFocused()->RippleDelete(); + PanelManager::instance()->currently_focused()->ripple_delete(); } -void MenuShared::SetInTriggered() +void MenuShared::set_in_triggered() { - PanelManager::instance()->CurrentlyFocused()->SetIn(); + PanelManager::instance()->currently_focused()->set_in(); } -void MenuShared::SetOutTriggered() +void MenuShared::set_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->SetOut(); + PanelManager::instance()->currently_focused()->set_out(); } -void MenuShared::ResetInTriggered() +void MenuShared::reset_in_triggered() { - PanelManager::instance()->CurrentlyFocused()->ResetIn(); + PanelManager::instance()->currently_focused()->reset_in(); } -void MenuShared::ResetOutTriggered() +void MenuShared::reset_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->ResetOut(); + PanelManager::instance()->currently_focused()->reset_out(); } -void MenuShared::ClearInOutTriggered() +void MenuShared::clear_in_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->ClearInOut(); + PanelManager::instance()->currently_focused()->clear_in_out(); } -void MenuShared::ToggleLinksTriggered() +void MenuShared::toggle_links_triggered() { - PanelManager::instance()->CurrentlyFocused()->ToggleLinks(); + PanelManager::instance()->currently_focused()->toggle_links(); } -void MenuShared::CutTriggered() +void MenuShared::cut_triggered() { - PanelManager::instance()->CurrentlyFocused()->CutSelected(); + PanelManager::instance()->currently_focused()->cut_selected(); } -void MenuShared::CopyTriggered() +void MenuShared::copy_triggered() { - PanelManager::instance()->CurrentlyFocused()->CopySelected(); + PanelManager::instance()->currently_focused()->copy_selected(); } -void MenuShared::PasteTriggered() +void MenuShared::paste_triggered() { - PanelManager::instance()->CurrentlyFocused()->Paste(); + PanelManager::instance()->currently_focused()->paste(); } -void MenuShared::PasteInsertTriggered() +void MenuShared::paste_insert_triggered() { - PanelManager::instance()->CurrentlyFocused()->PasteInsert(); + PanelManager::instance()->currently_focused()->paste_insert(); } -void MenuShared::DuplicateTriggered() +void MenuShared::duplicate_triggered() { - PanelManager::instance()->CurrentlyFocused()->Duplicate(); + PanelManager::instance()->currently_focused()->duplicate(); } -void MenuShared::RenameSelectedTriggered() +void MenuShared::rename_selected_triggered() { - PanelManager::instance()->CurrentlyFocused()->RenameSelected(); + PanelManager::instance()->currently_focused()->rename_selected(); } -void MenuShared::EnableDisableTriggered() +void MenuShared::enable_disable_triggered() { - PanelManager::instance()->CurrentlyFocused()->ToggleSelectedEnabled(); + PanelManager::instance()->currently_focused()->toggle_selected_enabled(); } -void MenuShared::NestTriggered() +void MenuShared::nest_triggered() { PanelManager::instance() - ->MostRecentlyFocused() - ->NestSelectedClips(); + ->most_recently_focused() + ->nest_selected_clips(); } -void MenuShared::DefaultTransitionTriggered() +void MenuShared::default_transition_triggered() { PanelManager::instance() - ->MostRecentlyFocused() - ->AddDefaultTransitionsToSelected(); + ->most_recently_focused() + ->add_default_transitions_to_selected(); } -void MenuShared::TimecodeDisplayTriggered() +void MenuShared::timecode_display_triggered() { // Assume the sender is a QAction QAction *action = static_cast(sender()); @@ -379,33 +379,33 @@ void MenuShared::TimecodeDisplayTriggered() static_cast(action->data().toInt()); // Set the current display mode - Core::instance()->SetTimecodeDisplay(display); + Core::instance()->set_timecode_display(display); } -void MenuShared::ColorLabelTriggered(int color_index) +void MenuShared::color_label_triggered(int color_index) { - PanelManager::instance()->CurrentlyFocused()->SetColorLabel(color_index); + PanelManager::instance()->currently_focused()->set_color_label(color_index); } -void MenuShared::SpeedDurationTriggered() +void MenuShared::speed_duration_triggered() { TimelinePanel *timeline = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); if (timeline) { - timeline->ShowSpeedDurationDialogForSelectedClips(); + timeline->show_speed_duration_dialog_for_selected_clips(); } } -void MenuShared::AddableItemTriggered() +void MenuShared::addable_item_triggered() { QAction *a = static_cast(sender()); Tool::AddableObject i = static_cast(a->data().toInt()); - Core::instance()->SetTool(Tool::kAdd); - Core::instance()->SetSelectedAddableObject(i); + Core::instance()->set_tool(Tool::k_add); + Core::instance()->set_selected_addable_object(i); } -void MenuShared::Retranslate() +void MenuShared::retranslate() { // "New" menu shared items new_project_item_->setText(tr("&Project")); @@ -425,7 +425,7 @@ void MenuShared::Retranslate() edit_speedduration_item_->setText(tr("Speed/Duration")); for (QAction *a : qAsConst(addable_items_)) { - a->setText(Tool::GetAddableObjectName( + a->setText(Tool::get_addable_object_name( static_cast(a->data().toInt()))); } diff --git a/app/widget/menu/menushared.h b/app/widget/menu/menushared.h index 8a6612a0b..5c7858f35 100644 --- a/app/widget/menu/menushared.h +++ b/app/widget/menu/menushared.h @@ -19,8 +19,8 @@ ***/ -#ifndef MENUSHARED_H -#define MENUSHARED_H +#ifndef OAK_MENUSHARED_H +#define OAK_MENUSHARED_H #include #include "widget/colorlabelmenu/colorlabelmenu.h" @@ -40,20 +40,20 @@ public: MenuShared(); virtual ~MenuShared() override; - static void CreateInstance(); - static void DestroyInstance(); + static void create_instance(); + static void destroy_instance(); - void Retranslate(); + void retranslate(); - void AddItemsForNewMenu(Menu *m); - void AddItemsForEditMenu(Menu *m, bool for_clips); - void AddItemsForAddableObjectsMenu(Menu *m); - void AddItemsForInOutMenu(Menu *m); - void AddColorCodingMenu(Menu *m); - void AddItemsForClipEditMenu(Menu *m); - void AddItemsForTimeRulerMenu(Menu *m); + void add_items_for_new_menu(Menu *m); + void add_items_for_edit_menu(Menu *m, bool for_clips); + void add_items_for_addable_objects_menu(Menu *m); + void add_items_for_in_out_menu(Menu *m); + void add_color_coding_menu(Menu *m); + void add_items_for_clip_edit_menu(Menu *m); + void add_items_for_time_ruler_menu(Menu *m); - void AboutToShowTimeRulerActions(const rational &timebase); + void about_to_show_time_ruler_actions(const Rational &timebase); static MenuShared *instance(); @@ -63,7 +63,7 @@ public: } public slots: - void DeleteSelectedTriggered(); + void delete_selected_triggered(); private: // "New" menu shared items @@ -113,39 +113,39 @@ private: static MenuShared *instance_; private slots: - void SplitAtPlayheadTriggered(); + void split_at_playhead_triggered(); - void RippleDeleteTriggered(); + void ripple_delete_triggered(); - void SetInTriggered(); + void set_in_triggered(); - void SetOutTriggered(); + void set_out_triggered(); - void ResetInTriggered(); + void reset_in_triggered(); - void ResetOutTriggered(); + void reset_out_triggered(); - void ClearInOutTriggered(); + void clear_in_out_triggered(); - void ToggleLinksTriggered(); + void toggle_links_triggered(); - void CutTriggered(); + void cut_triggered(); - void CopyTriggered(); + void copy_triggered(); - void PasteTriggered(); + void paste_triggered(); - void PasteInsertTriggered(); + void paste_insert_triggered(); - void DuplicateTriggered(); + void duplicate_triggered(); - void RenameSelectedTriggered(); + void rename_selected_triggered(); - void EnableDisableTriggered(); + void enable_disable_triggered(); - void NestTriggered(); + void nest_triggered(); - void DefaultTransitionTriggered(); + void default_transition_triggered(); /** * @brief A slot for the timecode display menu items @@ -153,15 +153,15 @@ private slots: * Assumes a QAction* sender() and its data() is a member of enum Timecode::Display. Uses the data() to signal a * timecode change throughout the rest of the application. */ - void TimecodeDisplayTriggered(); + void timecode_display_triggered(); - void ColorLabelTriggered(int color_index); + void color_label_triggered(int color_index); - void SpeedDurationTriggered(); + void speed_duration_triggered(); - void AddableItemTriggered(); + void addable_item_triggered(); }; } -#endif // MENUSHARED_H +#endif // OAK_MENUSHARED_H diff --git a/app/widget/multicam/multicamdisplay.cpp b/app/widget/multicam/multicamdisplay.cpp index 2f11f1c15..70564eddb 100644 --- a/app/widget/multicam/multicamdisplay.cpp +++ b/app/widget/multicam/multicamdisplay.cpp @@ -34,9 +34,9 @@ MulticamDisplay::MulticamDisplay(QWidget *parent) { } -void MulticamDisplay::OnPaint() +void MulticamDisplay::on_paint() { - super::OnPaint(); + super::on_paint(); if (node_) { QPainter p(paint_device()); @@ -45,43 +45,43 @@ void MulticamDisplay::OnPaint() p.setBrush(Qt::NoBrush); int rows, cols; - node_->GetRowsAndColumns(&rows, &cols); + node_->get_rows_and_columns(&rows, &cols); int multi = std::max(rows, cols); int cell_width = width() / multi; int cell_height = height() / multi; int col, row; - node_->IndexToRowCols(node_->GetCurrentSource(), rows, cols, &row, + node_->index_to_row_cols(node_->get_current_source(), rows, cols, &row, &col); QRect r(cell_width * col, cell_height * row, cell_width, cell_height); - p.drawRect(GenerateWorldTransform().mapRect(r)); + p.drawRect(generate_world_transform().mapRect(r)); } } -void MulticamDisplay::OnDestroy() +void MulticamDisplay::on_destroy() { shader_ = QVariant(); } -TexturePtr MulticamDisplay::LoadCustomTextureFromFrame(const QVariant &v) +TexturePtr MulticamDisplay::load_custom_texture_from_frame(const QVariant &v) { if (v.canConvert>()) { QVector tex = v.value>(); - TexturePtr main = renderer()->CreateTexture(this->GetViewportParams()); + TexturePtr main = renderer()->create_texture(this->get_viewport_params()); int rows, cols; - MultiCamNode::GetRowsAndColumns(tex.size(), &rows, &cols); + MultiCamNode::get_rows_and_columns(tex.size(), &rows, &cols); if (shader_.isNull() || rows_ != rows || cols_ != cols) { if (!shader_.isNull()) { - renderer()->DestroyNativeShader(shader_); + renderer()->destroy_native_shader(shader_); } - shader_ = renderer()->CreateNativeShader( - ShaderCode(GenerateShaderCode(rows, cols))); + shader_ = renderer()->create_native_shader( + ShaderCode(generate_shader_code(rows, cols))); rows_ = rows; cols_ = cols; @@ -91,26 +91,26 @@ TexturePtr MulticamDisplay::LoadCustomTextureFromFrame(const QVariant &v) for (int i = 0; i < tex.size(); i++) { int c, r; - MultiCamNode::IndexToRowCols(i, rows, cols, &r, &c); - job.Insert(QStringLiteral("tex_%1_%2") + MultiCamNode::index_to_row_cols(i, rows, cols, &r, &c); + job.insert(QStringLiteral("tex_%1_%2") .arg(QString::number(r), QString::number(c)), - NodeValue(NodeValue::kTexture, tex.at(i))); + NodeValue(NodeValue::k_texture, tex.at(i))); } - renderer()->BlitToTexture(shader_, job, main.get()); + renderer()->blit_to_texture(shader_, job, main.get()); return main; } else { - return super::LoadCustomTextureFromFrame(v); + return super::load_custom_texture_from_frame(v); } } -QString dblToGlsl(double d) +QString dbl_to_glsl(double d) { return QString::number(d, 'f'); } -QString MulticamDisplay::GenerateShaderCode(int rows, int cols) +QString MulticamDisplay::generate_shader_code(int rows, int cols) { int multiplier = std::max(cols, rows); @@ -139,7 +139,7 @@ QString MulticamDisplay::GenerateShaderCode(int rows, int cols) } else { shader.append( QStringLiteral(" if (ove_texcoord.x < %1) {") - .arg(dblToGlsl(double(x + 1) / double(multiplier)))); + .arg(dbl_to_glsl(double(x + 1) / double(multiplier)))); } for (int y = 0; y < rows; y++) { @@ -151,17 +151,17 @@ QString MulticamDisplay::GenerateShaderCode(int rows, int cols) } else { shader.append( QStringLiteral(" if (ove_texcoord.y < %1) {") - .arg(dblToGlsl(double(y + 1) / double(multiplier)))); + .arg(dbl_to_glsl(double(y + 1) / double(multiplier)))); } QString input = QStringLiteral("tex_%1_%2") .arg(QString::number(y), QString::number(x)); shader.append( QStringLiteral( " vec2 coord = vec2((ove_texcoord.x+%1)*%2, (ove_texcoord.y+%3)*%4);") - .arg(dblToGlsl(-double(x) / double(multiplier)), - dblToGlsl(multiplier), - dblToGlsl(-double(y) / double(multiplier)), - dblToGlsl(multiplier))); + .arg(dbl_to_glsl(-double(x) / double(multiplier)), + dbl_to_glsl(multiplier), + dbl_to_glsl(-double(y) / double(multiplier)), + dbl_to_glsl(multiplier))); shader.append( QStringLiteral( " if (%1_enabled && coord.x >= 0.0 && coord.x < 1.0 && coord.y >= 0.0 && coord.y < 1.0) {") @@ -183,7 +183,7 @@ QString MulticamDisplay::GenerateShaderCode(int rows, int cols) return shader.join('\n'); } -void MulticamDisplay::SetMulticamNode(MultiCamNode *n) +void MulticamDisplay::set_multicam_node(MultiCamNode *n) { node_ = n; } diff --git a/app/widget/multicam/multicamdisplay.h b/app/widget/multicam/multicamdisplay.h index 505150c08..730d20801 100644 --- a/app/widget/multicam/multicamdisplay.h +++ b/app/widget/multicam/multicamdisplay.h @@ -19,8 +19,8 @@ ***/ -#ifndef MULTICAMDISPLAY_H -#define MULTICAMDISPLAY_H +#ifndef OAK_MULTICAMDISPLAY_H +#define OAK_MULTICAMDISPLAY_H #include "node/input/multicam/multicamnode.h" #include "widget/viewer/viewerdisplay.h" @@ -33,17 +33,17 @@ class MulticamDisplay : public ViewerDisplayWidget { public: explicit MulticamDisplay(QWidget *parent = nullptr); - void SetMulticamNode(MultiCamNode *n); + void set_multicam_node(MultiCamNode *n); protected: - virtual void OnPaint() override; + virtual void on_paint() override; - virtual void OnDestroy() override; + virtual void on_destroy() override; - virtual TexturePtr LoadCustomTextureFromFrame(const QVariant &v) override; + virtual TexturePtr load_custom_texture_from_frame(const QVariant &v) override; private: - static QString GenerateShaderCode(int rows, int cols); + static QString generate_shader_code(int rows, int cols); MultiCamNode *node_; @@ -54,4 +54,4 @@ private: } -#endif // MULTICAMDISPLAY_H +#endif // OAK_MULTICAMDISPLAY_H diff --git a/app/widget/multicam/multicamwidget.cpp b/app/widget/multicam/multicamwidget.cpp index 4a092b933..c404fc2ca 100644 --- a/app/widget/multicam/multicamwidget.cpp +++ b/app/widget/multicam/multicamwidget.cpp @@ -43,17 +43,17 @@ MulticamWidget::MulticamWidget(QWidget *parent) layout->addWidget(sizer_); display_ = new MulticamDisplay(this); - display_->SetShowWidgetBackground(true); - connect(display_, &ViewerDisplayWidget::DragStarted, this, - &MulticamWidget::DisplayClicked); + display_->set_show_widget_background(true); + connect(display_, &ViewerDisplayWidget::drag_started, this, + &MulticamWidget::display_clicked); - connect(sizer_, &ViewerSizer::RequestScale, display_, - &ViewerDisplayWidget::SetMatrixZoom); - connect(sizer_, &ViewerSizer::RequestTranslate, display_, - &ViewerDisplayWidget::SetMatrixTranslate); - connect(display_, &ViewerDisplayWidget::HandDragMoved, sizer_, - &ViewerSizer::HandDragMove); - sizer_->SetWidget(display_); + connect(sizer_, &ViewerSizer::request_scale, display_, + &ViewerDisplayWidget::set_matrix_zoom); + connect(sizer_, &ViewerSizer::request_translate, display_, + &ViewerDisplayWidget::set_matrix_translate); + connect(display_, &ViewerDisplayWidget::hand_drag_moved, sizer_, + &ViewerSizer::hand_drag_move); + sizer_->set_widget(display_); layout->addWidget(this->ruler()); layout->addWidget(this->scrollbar()); @@ -66,16 +66,16 @@ MulticamWidget::MulticamWidget(QWidget *parent) } } -void MulticamWidget::SetMulticamNodeInternal(ViewerOutput *viewer, +void MulticamWidget::set_multicam_node_internal(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip) { - if (GetConnectedNode() != viewer) { - ConnectViewerNode(viewer); + if (get_connected_node() != viewer) { + connect_viewer_node(viewer); } if (node_ != n) { node_ = n; - display_->SetMulticamNode(n); + display_->set_multicam_node(n); } if (clip_ != clip) { @@ -83,12 +83,12 @@ void MulticamWidget::SetMulticamNodeInternal(ViewerOutput *viewer, } } -void MulticamWidget::SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n, - ClipBlock *clip, const rational &time) +void MulticamWidget::set_multicam_node(ViewerOutput *viewer, MultiCamNode *n, + ClipBlock *clip, const Rational &time) { - if (time.isNaN() || !GetConnectedNode() || - time == GetConnectedNode()->GetPlayhead()) { - SetMulticamNodeInternal(viewer, n, clip); + if (time.isNaN() || !get_connected_node() || + time == get_connected_node()->get_playhead()) { + set_multicam_node_internal(viewer, n, clip); play_queue_.clear(); } else { MulticamNodeQueue m = { time, viewer, n, clip }; @@ -98,31 +98,31 @@ void MulticamWidget::SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n, void MulticamWidget::ConnectNodeEvent(ViewerOutput *n) { - connect(n, &ViewerOutput::SizeChanged, sizer_, &ViewerSizer::SetChildSize); - connect(n, &ViewerOutput::PixelAspectChanged, sizer_, - &ViewerSizer::SetPixelAspectRatio); + connect(n, &ViewerOutput::size_changed, sizer_, &ViewerSizer::set_child_size); + connect(n, &ViewerOutput::pixel_aspect_changed, sizer_, + &ViewerSizer::set_pixel_aspect_ratio); - VideoParams vp = n->GetVideoParams(); - sizer_->SetChildSize(vp.width(), vp.height()); - sizer_->SetPixelAspectRatio(vp.pixel_aspect_ratio()); + VideoParams vp = n->get_video_params(); + sizer_->set_child_size(vp.width(), vp.height()); + sizer_->set_pixel_aspect_ratio(vp.pixel_aspect_ratio()); } void MulticamWidget::DisconnectNodeEvent(ViewerOutput *n) { - disconnect(n, &ViewerOutput::SizeChanged, sizer_, - &ViewerSizer::SetChildSize); - disconnect(n, &ViewerOutput::PixelAspectChanged, sizer_, - &ViewerSizer::SetPixelAspectRatio); + disconnect(n, &ViewerOutput::size_changed, sizer_, + &ViewerSizer::set_child_size); + disconnect(n, &ViewerOutput::pixel_aspect_changed, sizer_, + &ViewerSizer::set_pixel_aspect_ratio); } -void MulticamWidget::TimeChangedEvent(const rational &t) +void MulticamWidget::TimeChangedEvent(const Rational &t) { super::TimeChangedEvent(t); if (!play_queue_.empty()) { const MulticamNodeQueue &m = play_queue_.front(); if (m.time >= t) { - SetMulticamNodeInternal(m.viewer, m.node, m.clip); + set_multicam_node_internal(m.viewer, m.node, m.clip); play_queue_.pop_front(); } } @@ -142,33 +142,33 @@ void MulticamWidget::Switch(int source, bool split_clip) BlockSplitPreservingLinksCommand *split = nullptr; if (clip_ && split_clip && - clip_->in() < GetConnectedNode()->GetPlayhead() && - clip_->out() > GetConnectedNode()->GetPlayhead()) { + clip_->in() < get_connected_node()->get_playhead() && + clip_->out() > get_connected_node()->get_playhead()) { QVector blocks; blocks.append(clip_); blocks.append(clip_->block_links()); split = new BlockSplitPreservingLinksCommand( - blocks, { GetConnectedNode()->GetPlayhead() }); + blocks, { get_connected_node()->get_playhead() }); split->redo_now(); command->add_child(split); - clip = static_cast(split->GetSplit(clip_, 0)); + clip = static_cast(split->get_split(clip_, 0)); - cam = clip->FindMulticam(); + cam = clip->find_multicam(); } command->add_child(new NodeParamSetStandardValueCommand( - NodeKeyframeTrackReference(NodeInput(cam, cam->kCurrentInput)), + NodeKeyframeTrackReference(NodeInput(cam, cam->k_current_input)), source)); for (Block *link : clip->block_links()) { if (ClipBlock *clink = dynamic_cast(link)) { - if (MultiCamNode *mlink = clink->FindMulticam()) { + if (MultiCamNode *mlink = clink->find_multicam()) { command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(mlink, mlink->kCurrentInput)), + NodeInput(mlink, mlink->k_current_input)), source)); } } @@ -179,18 +179,18 @@ void MulticamWidget::Switch(int source, bool split_clip) display_->update(); - emit Switched(); + emit switched(); } -void MulticamWidget::DisplayClicked(const QPoint &p) +void MulticamWidget::display_clicked(const QPoint &p) { if (!node_) { return; } - QPointF click = display_->ScreenToScenePoint(p); - int width = display_->GetVideoParams().width(); - int height = display_->GetVideoParams().height(); + QPointF click = display_->screen_to_scene_point(p); + int width = display_->get_video_params().width(); + int height = display_->get_video_params().height(); if (click.x() < 0 || click.y() < 0 || click.x() >= width || click.y() >= height) { @@ -198,14 +198,14 @@ void MulticamWidget::DisplayClicked(const QPoint &p) } int rows, cols; - node_->GetRowsAndColumns(&rows, &cols); + node_->get_rows_and_columns(&rows, &cols); int multi = std::max(cols, rows); int c = click.x() / (width / multi); int r = click.y() / (height / multi); - int source = node_->RowsColsToIndex(r, c, rows, cols); + int source = node_->rows_cols_to_index(r, c, rows, cols); Switch(source, true); } diff --git a/app/widget/multicam/multicamwidget.h b/app/widget/multicam/multicamwidget.h index d789e908f..bb46dffa5 100644 --- a/app/widget/multicam/multicamwidget.h +++ b/app/widget/multicam/multicamwidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef MULTICAMWIDGET_H -#define MULTICAMWIDGET_H +#ifndef OAK_MULTICAMWIDGET_H +#define OAK_MULTICAMWIDGET_H #include "multicamdisplay.h" #include "node/input/multicam/multicamnode.h" @@ -34,24 +34,24 @@ class MulticamWidget : public TimeBasedWidget { public: explicit MulticamWidget(QWidget *parent = nullptr); - MulticamDisplay *GetDisplayWidget() const + MulticamDisplay *get_display_widget() const { return display_; } - void SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip, - const rational &time); + void set_multicam_node(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip, + const Rational &time); protected: virtual void ConnectNodeEvent(ViewerOutput *n) override; virtual void DisconnectNodeEvent(ViewerOutput *n) override; - virtual void TimeChangedEvent(const rational &t) override; + virtual void TimeChangedEvent(const Rational &t) override; signals: - void Switched(); + void switched(); private: - void SetMulticamNodeInternal(ViewerOutput *viewer, MultiCamNode *n, + void set_multicam_node_internal(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip); void Switch(int source, bool split_clip); @@ -65,7 +65,7 @@ private: ClipBlock *clip_; struct MulticamNodeQueue { - rational time; + Rational time; ViewerOutput *viewer; MultiCamNode *node; ClipBlock *clip; @@ -74,9 +74,9 @@ private: std::list play_queue_; private slots: - void DisplayClicked(const QPoint &p); + void display_clicked(const QPoint &p); }; } -#endif // MULTICAMWIDGET_H +#endif // OAK_MULTICAMWIDGET_H diff --git a/app/widget/nodecombobox/nodecombobox.cpp b/app/widget/nodecombobox/nodecombobox.cpp index be1d14d81..e8ec76913 100644 --- a/app/widget/nodecombobox/nodecombobox.cpp +++ b/app/widget/nodecombobox/nodecombobox.cpp @@ -39,56 +39,56 @@ NodeComboBox::NodeComboBox(QWidget *parent) void NodeComboBox::showPopup() { - Menu *m = NodeFactory::CreateMenu(this, true); + Menu *m = NodeFactory::create_menu(this, true); QAction *selected = m->exec(parentWidget()->mapToGlobal(pos())); if (selected) { QString new_id = NodeFactory::GetIDFromMenuAction(selected); - SetNodeInternal(new_id, true); + set_node_internal(new_id, true); } delete m; } -const QString &NodeComboBox::GetSelectedNode() const +const QString &NodeComboBox::get_selected_node() const { return selected_id_; } -void NodeComboBox::SetNode(const QString &id) +void NodeComboBox::set_node(const QString &id) { - SetNodeInternal(id, false); + set_node_internal(id, false); } void NodeComboBox::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - UpdateText(); + update_text(); } QComboBox::changeEvent(e); } -void NodeComboBox::UpdateText() +void NodeComboBox::update_text() { clear(); if (!selected_id_.isEmpty()) { - addItem(NodeFactory::GetNameFromID(selected_id_)); + addItem(NodeFactory::get_name_from_id(selected_id_)); } } -void NodeComboBox::SetNodeInternal(const QString &id, bool emit_signal) +void NodeComboBox::set_node_internal(const QString &id, bool emit_signal) { if (selected_id_ != id) { selected_id_ = id; - UpdateText(); + update_text(); if (emit_signal) { - emit NodeChanged(selected_id_); + emit node_changed(selected_id_); } } } diff --git a/app/widget/nodecombobox/nodecombobox.h b/app/widget/nodecombobox/nodecombobox.h index fb9c95414..6f6739059 100644 --- a/app/widget/nodecombobox/nodecombobox.h +++ b/app/widget/nodecombobox/nodecombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODECOMBOBOX_H -#define NODECOMBOBOX_H +#ifndef OAK_NODECOMBOBOX_H +#define OAK_NODECOMBOBOX_H #include @@ -36,21 +36,21 @@ public: virtual void showPopup() override; - const QString &GetSelectedNode() const; + const QString &get_selected_node() const; public slots: - void SetNode(const QString &id); + void set_node(const QString &id); protected: virtual void changeEvent(QEvent *e) override; signals: - void NodeChanged(const QString &id); + void node_changed(const QString &id); private: - void UpdateText(); + void update_text(); - void SetNodeInternal(const QString &id, bool emit_signal); + void set_node_internal(const QString &id, bool emit_signal); QString selected_id_; }; diff --git a/app/widget/nodeparamview/nodeparambutton.h b/app/widget/nodeparamview/nodeparambutton.h index 840eb0575..c7a9c67ea 100644 --- a/app/widget/nodeparamview/nodeparambutton.h +++ b/app/widget/nodeparamview/nodeparambutton.h @@ -17,9 +17,9 @@ * */ -#ifndef NODEPARAMBUTTON_H -#define NODEPARAMBUTTON_H -#include "node/plugins/Plugin.h" +#ifndef OAK_NODEPARAMBUTTON_H +#define OAK_NODEPARAMBUTTON_H +#include "node/plugins/plugin.h" #include @@ -33,15 +33,15 @@ public: connect(this, &QPushButton::clicked, this, &NodeParamButton::pressed); } signals: - void onPressed(QString name); + void on_pressed(QString name); private slots: void pressed() { - emit onPressed(name_); + emit on_pressed(name_); } private: QString name_; }; -#endif //NODEPARAMBUTTON_H +#endif //OAK_NODEPARAMBUTTON_H diff --git a/app/widget/nodeparamview/nodeparamview.cpp b/app/widget/nodeparamview/nodeparamview.cpp index d337c368e..7dfc7dac2 100644 --- a/app/widget/nodeparamview/nodeparamview.cpp +++ b/app/widget/nodeparamview/nodeparamview.cpp @@ -75,28 +75,28 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent) param_widget_container_layout->addStretch(INT_MAX); // Create contexts for three different types - context_items_.resize(Track::kCount + 1); + context_items_.resize(Track::k_count + 1); for (int i = 0; i < context_items_.size(); i++) { NodeParamViewContext *c = new NodeParamViewContext(param_widget_area_); c->setVisible(false); - connect(c, &NodeParamViewContext::AboutToDeleteItem, this, - &NodeParamView::ItemAboutToBeRemoved, Qt::DirectConnection); + connect(c, &NodeParamViewContext::about_to_delete_item, this, + &NodeParamView::item_about_to_be_removed, Qt::DirectConnection); NodeParamViewItemTitleBar *title_bar = static_cast(c->titleBarWidget()); - if (i == Track::kVideo || i == Track::kAudio) { - c->SetEffectType(static_cast(i)); - title_bar->SetAddEffectButtonVisible(true); - title_bar->SetText(tr("%1 Nodes") - .arg(Footage::GetStreamTypeName( + if (i == Track::k_video || i == Track::k_audio) { + c->set_effect_type(static_cast(i)); + title_bar->set_add_effect_button_visible(true); + title_bar->set_text(tr("%1 Nodes") + .arg(Footage::get_stream_type_name( static_cast(i)))); } else { - title_bar->SetText(tr("Other")); + title_bar->set_text(tr("Other")); } context_items_[i] = c; - param_widget_area_->AddItem(c); + param_widget_area_->add_item(c); } // Disable collapsing param view (but collapsing keyframe view is permitted) @@ -113,7 +113,7 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent) connect(param_scroll_area_->verticalScrollBar(), &QScrollBar::rangeChanged, vertical_scrollbar_, &QScrollBar::setRange); connect(param_scroll_area_->verticalScrollBar(), &QScrollBar::rangeChanged, - this, &NodeParamView::UpdateGlobalScrollBar); + this, &NodeParamView::update_global_scroll_bar); connect(vertical_scrollbar_, &QScrollBar::valueChanged, param_scroll_area_->verticalScrollBar(), &QScrollBar::setValue); @@ -130,17 +130,17 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent) // Create keyframe view keyframe_view_ = new KeyframeView(); keyframe_view_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - keyframe_view_->SetSnapService(this); - ConnectTimelineView(keyframe_view_); + keyframe_view_->set_snap_service(this); + connect_timeline_view(keyframe_view_); keyframe_area_layout->addWidget(keyframe_view_); // Connect ruler and keyframe view together - connect(keyframe_view_, &KeyframeView::Dragged, this, + connect(keyframe_view_, &KeyframeView::dragged, this, static_cast( - &NodeParamView::SetCatchUpScrollValue)); - connect(keyframe_view_, &KeyframeView::Released, this, + &NodeParamView::set_catch_up_scroll_value)); + connect(keyframe_view_, &KeyframeView::released, this, static_cast( - &NodeParamView::StopCatchUpScrollTimer)); + &NodeParamView::stop_catch_up_scroll_timer)); splitter->addWidget(keyframe_area); @@ -180,7 +180,7 @@ NodeParamView::~NodeParamView() qDeleteAll(context_items_); } -void NodeParamView::CloseContextsBelongingToProject(Project *p) +void NodeParamView::close_contexts_belonging_to_project(Project *p) { QVector new_contexts = contexts_; @@ -191,7 +191,7 @@ void NodeParamView::CloseContextsBelongingToProject(Project *p) } } - SetContexts(new_contexts); + set_contexts(new_contexts); } /*void NodeParamView::SelectNodes(const QVector &nodes) @@ -253,14 +253,14 @@ void NodeParamView::DeselectNodes(const QVector &nodes) } }*/ -void NodeParamView::UpdateContexts() +void NodeParamView::update_contexts() { bool changes_made = false; foreach (Node *ctx, current_contexts_) { if (!contexts_.contains(ctx)) { // Context is being removed - RemoveContext(ctx); + remove_context(ctx); changes_made = true; } } @@ -268,7 +268,7 @@ void NodeParamView::UpdateContexts() foreach (Node *ctx, contexts_) { if (!current_contexts_.contains(ctx)) { // Context is being added - AddContext(ctx); + add_context(ctx); changes_made = true; } } @@ -276,38 +276,38 @@ void NodeParamView::UpdateContexts() if (changes_made) { current_contexts_ = contexts_; - if (IsGroupMode()) { + if (is_group_mode()) { // Check inputs that have been passed through NodeGroup *group = static_cast(contexts_.first()); - for (auto it = group->GetInputPassthroughs().cbegin(); - it != group->GetInputPassthroughs().cend(); it++) { - GroupInputPassthroughAdded(group, it->second); + for (auto it = group->get_input_passthroughs().cbegin(); + it != group->get_input_passthroughs().cend(); it++) { + group_input_passthrough_added(group, it->second); } - connect(group, &NodeGroup::InputPassthroughAdded, this, - &NodeParamView::GroupInputPassthroughAdded); - connect(group, &NodeGroup::InputPassthroughRemoved, this, - &NodeParamView::GroupInputPassthroughRemoved); + connect(group, &NodeGroup::input_passthrough_added, this, + &NodeParamView::group_input_passthrough_added); + connect(group, &NodeGroup::input_passthrough_removed, this, + &NodeParamView::group_input_passthrough_removed); } foreach (NodeParamViewContext *ctx, context_items_) { - SortItemsInContext(ctx); + sort_items_in_context(ctx); } if (keyframe_view_) { - QueueKeyframePositionUpdate(); + queue_keyframe_position_update(); } } } -void NodeParamView::ItemAboutToBeRemoved(NodeParamViewItem *item) +void NodeParamView::item_about_to_be_removed(NodeParamViewItem *item) { if (keyframe_view_) { - for (auto it = item->GetKeyframeConnections().begin(); - it != item->GetKeyframeConnections().end(); it++) { + for (auto it = item->get_keyframe_connections().begin(); + it != item->get_keyframe_connections().end(); it++) { for (auto jt = it->begin(); jt != it->end(); jt++) { for (auto kt = jt->begin(); kt != jt->end(); kt++) { - keyframe_view_->RemoveKeyframesOfTrack(*kt); + keyframe_view_->remove_keyframes_of_track(*kt); } } } @@ -315,36 +315,36 @@ void NodeParamView::ItemAboutToBeRemoved(NodeParamViewItem *item) QVector copy = selected_nodes_; if (copy.removeOne(item)) { - SetSelectedNodes(copy); + set_selected_nodes(copy); } } -void NodeParamView::ItemClicked() +void NodeParamView::item_clicked() { - ToggleSelect(static_cast(sender())); + toggle_select(static_cast(sender())); } -void NodeParamView::SelectNodeFromConnectedLink(Node *node) +void NodeParamView::select_node_from_connected_link(Node *node) { NodeParamViewItem *item = static_cast(sender()); - Node::ContextPair p = { node, item->GetContext() }; - SetSelectedNodes({ p }); + Node::ContextPair p = { node, item->get_context() }; + set_selected_nodes({ p }); } -void NodeParamView::RequestEditTextInViewer() +void NodeParamView::request_edit_text_in_viewer() { NodeParamViewItem *item = static_cast(sender()); - SetSelectedNodes({ item }); - emit RequestViewerToStartEditingText(); + set_selected_nodes({ item }); + emit request_viewer_to_start_editing_text(); } -void NodeParamView::SetContexts(const QVector &contexts) +void NodeParamView::set_contexts(const QVector &contexts) { // Setting contexts is expensive, so we queue it here to prevent multiple calls in a short timespan contexts_ = contexts; - UpdateContexts(); + update_contexts(); } void NodeParamView::resizeEvent(QResizeEvent *event) @@ -359,20 +359,20 @@ void NodeParamView::ScaleChangedEvent(const double &scale) super::ScaleChangedEvent(scale); if (keyframe_view_) { - keyframe_view_->SetScale(scale); + keyframe_view_->set_scale(scale); } } -void NodeParamView::TimebaseChangedEvent(const rational &timebase) +void NodeParamView::TimebaseChangedEvent(const Rational &timebase) { super::TimebaseChangedEvent(timebase); if (keyframe_view_) { - keyframe_view_->SetTimebase(timebase); + keyframe_view_->set_timebase(timebase); } foreach (NodeParamViewContext *ctx, context_items_) { - ctx->SetTimebase(timebase); + ctx->set_timebase(timebase); } } @@ -380,15 +380,15 @@ void NodeParamView::ConnectedNodeChangeEvent(ViewerOutput *n) { if (keyframe_view_) { // Set viewer as a time target - keyframe_view_->SetTimeTarget(n); + keyframe_view_->set_time_target(n); } foreach (NodeParamViewContext *item, context_items_) { - item->SetTimeTarget(n); + item->set_time_target(n); } } -void ReconnectOutputsIfNotDeletingNode(MultiUndoCommand *c, +void reconnect_outputs_if_not_deleting_node(MultiUndoCommand *c, NodeViewDeleteCommand *dc, Node *output, Node *deleting, Node *context) { @@ -396,9 +396,9 @@ void ReconnectOutputsIfNotDeletingNode(MultiUndoCommand *c, it != deleting->output_connections().cend(); it++) { const NodeInput &proposed_reconnect = it->second; - if (dc->ContainsNode(proposed_reconnect.node(), context)) { + if (dc->contains_node(proposed_reconnect.node(), context)) { // Uh-oh we're deleting this node too, instead connect to its outputs - ReconnectOutputsIfNotDeletingNode( + reconnect_outputs_if_not_deleting_node( c, dc, output, proposed_reconnect.node(), context); } else { c->add_child(new NodeEdgeAddCommand(output, it->second)); @@ -409,7 +409,7 @@ void ReconnectOutputsIfNotDeletingNode(MultiUndoCommand *c, void NodeParamView::DeleteSelected() { if (keyframe_view_ && keyframe_view_->hasFocus()) { - keyframe_view_->DeleteSelected(); + keyframe_view_->delete_selected(); } else if (!selected_nodes_.isEmpty()) { MultiUndoCommand *c = new MultiUndoCommand(); @@ -419,24 +419,24 @@ void NodeParamView::DeleteSelected() // Add all nodes foreach (NodeParamViewItem *item, selected_nodes_) { - Node *n = item->GetNode(); - dc->AddNode(n, item->GetContext()); + Node *n = item->get_node(); + dc->add_node(n, item->get_context()); } // Make reconnections where possible foreach (NodeParamViewItem *item, selected_nodes_) { - Node *n = item->GetNode(); + Node *n = item->get_node(); Node *node_being_deleted = n; Node *connected_to_effect_input = nullptr; while (true) { - if (node_being_deleted->GetEffectInput().IsValid()) { + if (node_being_deleted->get_effect_input().is_valid()) { if ((connected_to_effect_input = - node_being_deleted->GetEffectInput() - .GetConnectedOutput())) { - if (dc->ContainsNode(connected_to_effect_input, - item->GetContext())) { + node_being_deleted->get_effect_input() + .get_connected_output())) { + if (dc->contains_node(connected_to_effect_input, + item->get_context())) { // Node's getting deleted, recurse node_being_deleted = connected_to_effect_input; continue; @@ -448,8 +448,8 @@ void NodeParamView::DeleteSelected() } if (connected_to_effect_input) { - ReconnectOutputsIfNotDeletingNode( - c, dc, connected_to_effect_input, n, item->GetContext()); + reconnect_outputs_if_not_deleting_node( + c, dc, connected_to_effect_input, n, item->get_context()); } } @@ -458,7 +458,7 @@ void NodeParamView::DeleteSelected() } } -void NodeParamView::SetSelectedNodes(const QVector &nodes, +void NodeParamView::set_selected_nodes(const QVector &nodes, bool handle_focused_node, bool emit_signal) { if (handle_focused_node) { @@ -467,7 +467,7 @@ void NodeParamView::SetSelectedNodes(const QVector &nodes, } foreach (NodeParamViewItem *n, selected_nodes_) { - n->SetHighlighted(false); + n->set_highlighted(false); } selected_nodes_ = nodes; @@ -479,10 +479,10 @@ void NodeParamView::SetSelectedNodes(const QVector &nodes, for (int i = 0; i < selected_nodes_.size(); i++) { NodeParamViewItem *n = selected_nodes_.at(i); - n->SetHighlighted(true); + n->set_highlighted(true); if (emit_signal) { - p[i] = { n->GetNode(), n->GetContext() }; + p[i] = { n->get_node(), n->get_context() }; } } @@ -490,22 +490,22 @@ void NodeParamView::SetSelectedNodes(const QVector &nodes, focused_node_ = nullptr; foreach (NodeParamViewItem *n, selected_nodes_) { - if (n->GetNode()->HasGizmos()) { + if (n->get_node()->has_gizmos()) { focused_node_ = n; break; } } - Node *n = focused_node_ ? focused_node_->GetNode() : nullptr; - emit FocusedNodeChanged(n); + Node *n = focused_node_ ? focused_node_->get_node() : nullptr; + emit focused_node_changed(n); } if (emit_signal) { - emit SelectedNodesChanged(p); + emit selected_nodes_changed(p); } } -void NodeParamView::SetSelectedNodes(const QVector &nodes, +void NodeParamView::set_selected_nodes(const QVector &nodes, bool emit_signal) { QVector items; @@ -516,7 +516,7 @@ void NodeParamView::SetSelectedNodes(const QVector &nodes, it++) { NodeParamViewContext *ctx = *it; - NodeParamViewItem *item = ctx->GetItem(n.node, n.context); + NodeParamViewItem *item = ctx->get_item(n.node, n.context); if (item) { items.append(item); @@ -527,7 +527,7 @@ void NodeParamView::SetSelectedNodes(const QVector &nodes, } } - SetSelectedNodes(items, true, emit_signal); + set_selected_nodes(items, true, emit_signal); if (!selected_nodes_.empty()) { NodeParamViewItem *scrolled_to = selected_nodes_.front(); @@ -540,31 +540,31 @@ void NodeParamView::SetSelectedNodes(const QVector &nodes, // Make sure the dock/tab containing this node is visible if (scrolled_ctx) { - scrolled_ctx->SetExpanded(true); + scrolled_ctx->set_expanded(true); scrolled_ctx->raise(); } } } -Node *NodeParamView::GetNodeWithID(const QString &id) +Node *NodeParamView::get_node_with_id(const QString &id) { - return GetNodeWithIDAndIgnoreList(id, QVector()); + return get_node_with_id_and_ignore_list(id, QVector()); } -Node *NodeParamView::GetNodeWithIDAndIgnoreList(const QString &id, +Node *NodeParamView::get_node_with_id_and_ignore_list(const QString &id, const QVector &ignore) { for (NodeParamViewItem *item : selected_nodes_) { - if (item->GetNode()->id() == id && !ignore.contains(item->GetNode())) { - return item->GetNode(); + if (item->get_node()->id() == id && !ignore.contains(item->get_node())) { + return item->get_node(); } } for (NodeParamViewContext *ctx : context_items_) { - for (NodeParamViewItem *item : ctx->GetItems()) { - if (item->GetNode()->id() == id && - !ignore.contains(item->GetNode())) { - return item->GetNode(); + for (NodeParamViewItem *item : ctx->get_items()) { + if (item->get_node()->id() == id && + !ignore.contains(item->get_node())) { + return item->get_node(); } } } @@ -572,14 +572,14 @@ Node *NodeParamView::GetNodeWithIDAndIgnoreList(const QString &id, return nullptr; } -bool NodeParamView::CopySelected(bool cut) +bool NodeParamView::copy_selected(bool cut) { - if (super::CopySelected(cut)) { + if (super::copy_selected(cut)) { return true; } if (keyframe_view_ && keyframe_view_->hasFocus()) { - if (keyframe_view_->CopySelected(cut)) { + if (keyframe_view_->copy_selected(cut)) { return true; } } @@ -588,18 +588,18 @@ bool NodeParamView::CopySelected(bool cut) return false; } - ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyNodes); + ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_nodes); ProjectSerializer::SerializedProperties properties; QVector nodes; for (NodeParamViewItem *item : selected_nodes_) { - Node *n = item->GetNode(); + Node *n = item->get_node(); if (!nodes.contains(n)) { nodes.append(n); Node::Position pos = - item->GetContext()->GetNodePositionDataInContext(n); + item->get_context()->get_node_position_data_in_context(n); properties[n][QStringLiteral("x")] = QString::number(pos.position.x()); @@ -610,10 +610,10 @@ bool NodeParamView::CopySelected(bool cut) } } - sdata.SetOnlySerializeNodesAndResolveGroups(nodes); - sdata.SetProperties(properties); + sdata.set_only_serialize_nodes_and_resolve_groups(nodes); + sdata.set_properties(properties); - ProjectSerializer::Copy(sdata); + ProjectSerializer::copy(sdata); if (cut) { DeleteSelected(); @@ -622,34 +622,34 @@ bool NodeParamView::CopySelected(bool cut) return false; } -bool NodeParamView::Paste() +bool NodeParamView::paste() { if (keyframe_view_) { - if (keyframe_view_->Paste(std::bind(&NodeParamView::GetNodeWithID, this, + if (keyframe_view_->paste(std::bind(&NodeParamView::get_node_with_id, this, std::placeholders::_1))) { return true; } } - return Paste(this, std::bind(&NodeParamView::GenerateExistingPasteMap, this, + return paste(this, std::bind(&NodeParamView::generate_existing_paste_map, this, std::placeholders::_1)); } -bool NodeParamView::Paste( +bool NodeParamView::paste( QWidget *parent, std::function(const ProjectSerializer::Result &)> get_existing_map_function) { ProjectSerializer::Result res = - ProjectSerializer::Paste(ProjectSerializer::kOnlyNodes); - if (res.GetLoadData().nodes.isEmpty()) { + ProjectSerializer::paste(ProjectSerializer::k_only_nodes); + if (res.get_load_data().nodes.isEmpty()) { return false; } // Determine if any nodes of this type are already in the editor QHash existing_nodes = get_existing_map_function(res); - QVector nodes_to_paste_as_new = res.GetLoadData().nodes; + QVector nodes_to_paste_as_new = res.get_load_data().nodes; MultiUndoCommand *command = new MultiUndoCommand(); if (!existing_nodes.empty()) { @@ -659,7 +659,7 @@ bool NodeParamView::Paste( QStringList node_names; for (auto it = existing_nodes.cbegin(); it != existing_nodes.cend(); it++) { - node_names.append(it.key()->GetLabelAndName()); + node_names.append(it.key()->get_label_and_name()); } b.setText( @@ -685,7 +685,7 @@ bool NodeParamView::Paste( // Filter out existing nodes for (auto it = existing_nodes.cbegin(); it != existing_nodes.cend(); it++) { - Node::CopyInputs(it.value(), it.key(), false, command); + Node::copy_inputs(it.value(), it.key(), false, command); nodes_to_paste_as_new.removeOne(it.value()); } } @@ -694,8 +694,8 @@ bool NodeParamView::Paste( if (!nodes_to_paste_as_new.isEmpty()) { Node::PositionMap map; - for (auto it = res.GetLoadData().properties.cbegin(); - it != res.GetLoadData().properties.cend(); it++) { + for (auto it = res.get_load_data().properties.cbegin(); + it != res.get_load_data().properties.cend(); it++) { if (nodes_to_paste_as_new.contains(it.key())) { Node::Position pos; @@ -718,106 +718,106 @@ bool NodeParamView::Paste( return true; } -void NodeParamView::QueueKeyframePositionUpdate() +void NodeParamView::queue_keyframe_position_update() { - QMetaObject::invokeMethod(this, &NodeParamView::UpdateElementY, + QMetaObject::invokeMethod(this, &NodeParamView::update_element_y, Qt::QueuedConnection); } -void NodeParamView::AddContext(Node *ctx) +void NodeParamView::add_context(Node *ctx) { - NodeParamViewContext *item = GetContextItemFromContext(ctx); + NodeParamViewContext *item = get_context_item_from_context(ctx); // TEMP: Creating many NPV items is EXTREMELY slow so limit to one item per context for now. // I have a better solution in the works to use one UI for several nodes, but I haven't // done it yet, and this can severely affect productivity. - if (item->GetContexts().size() == 1) { + if (item->get_contexts().size() == 1) { return; } // Queued so that if any further work is done in connecting this node to the context, it'll be // done before our sorting function is called - connect(ctx, &Node::NodeAddedToContext, this, - &NodeParamView::NodeAddedToContext, Qt::QueuedConnection); - connect(ctx, &Node::NodeRemovedFromContext, this, - &NodeParamView::NodeRemovedFromContext, Qt::QueuedConnection); + connect(ctx, &Node::node_added_to_context, this, + &NodeParamView::node_added_to_context, Qt::QueuedConnection); + connect(ctx, &Node::node_removed_from_context, this, + &NodeParamView::node_removed_from_context, Qt::QueuedConnection); - item->AddContext(ctx); + item->add_context(ctx); item->setVisible(true); - for (auto it = ctx->GetContextPositions().cbegin(); - it != ctx->GetContextPositions().cend(); it++) { - AddNode(it.key(), ctx, item); + for (auto it = ctx->get_context_positions().cbegin(); + it != ctx->get_context_positions().cend(); it++) { + add_node(it.key(), ctx, item); } } -void NodeParamView::RemoveContext(Node *ctx) +void NodeParamView::remove_context(Node *ctx) { - disconnect(ctx, &Node::NodeAddedToContext, this, - &NodeParamView::NodeAddedToContext); - disconnect(ctx, &Node::NodeRemovedFromContext, this, - &NodeParamView::NodeRemovedFromContext); + disconnect(ctx, &Node::node_added_to_context, this, + &NodeParamView::node_added_to_context); + disconnect(ctx, &Node::node_removed_from_context, this, + &NodeParamView::node_removed_from_context); foreach (NodeParamViewContext *item, context_items_) { - item->RemoveContext(ctx); - item->RemoveNodesWithContext(ctx); + item->remove_context(ctx); + item->remove_nodes_with_context(ctx); - if (item->GetContexts().isEmpty()) { + if (item->get_contexts().isEmpty()) { item->setVisible(false); } } } -void NodeParamView::AddNode(Node *n, Node *ctx, NodeParamViewContext *context) +void NodeParamView::add_node(Node *n, Node *ctx, NodeParamViewContext *context) { - if ((n->GetFlags() & Node::kDontShowInParamView) && !IsGroupMode() && + if ((n->get_flags() & Node::k_dont_show_in_param_view) && !is_group_mode() && !show_all_nodes_) { return; } NodeParamViewItem *item = new NodeParamViewItem( - n, IsGroupMode() ? kCheckBoxesOnNonConnected : kNoCheckBoxes, - context->GetDockArea()); + n, is_group_mode() ? k_check_boxes_on_non_connected : k_no_check_boxes, + context->get_dock_area()); - connect(item, &NodeParamViewItem::RequestSelectNode, this, - &NodeParamView::SelectNodeFromConnectedLink); - connect(item, &NodeParamViewItem::PinToggled, this, - &NodeParamView::PinNode); - connect(item, &NodeParamViewItem::InputCheckedChanged, this, - &NodeParamView::InputCheckBoxChanged); - connect(item, &NodeParamViewItem::Clicked, this, - &NodeParamView::ItemClicked); - connect(item, &NodeParamViewItem::RequestEditTextInViewer, this, - &NodeParamView::RequestEditTextInViewer); + connect(item, &NodeParamViewItem::request_select_node, this, + &NodeParamView::select_node_from_connected_link); + connect(item, &NodeParamViewItem::pin_toggled, this, + &NodeParamView::pin_node); + connect(item, &NodeParamViewItem::input_checked_changed, this, + &NodeParamView::input_check_box_changed); + connect(item, &NodeParamViewItem::clicked, this, + &NodeParamView::item_clicked); + connect(item, &NodeParamViewItem::request_edit_text_in_viewer, this, + &NodeParamView::request_edit_text_in_viewer); - item->SetContext(ctx); - item->SetTimeTarget(GetConnectedNode()); - item->SetTimebase(timebase()); + item->set_context(ctx); + item->set_time_target(get_connected_node()); + item->set_timebase(timebase()); - context->AddNode(item); + context->add_node(item); - if (!focused_node_ && n->HasGizmos()) { + if (!focused_node_ && n->has_gizmos()) { // We'll focus this node now - SetSelectedNodes({ item }); + set_selected_nodes({ item }); } if (keyframe_view_) { connect(item, &NodeParamViewItem::dockLocationChanged, this, - &NodeParamView::QueueKeyframePositionUpdate); - connect(item, &NodeParamViewItem::ArrayExpandedChanged, this, - &NodeParamView::QueueKeyframePositionUpdate); - connect(item, &NodeParamViewItem::ExpandedChanged, this, - &NodeParamView::QueueKeyframePositionUpdate); - connect(item, &NodeParamViewItem::Moved, this, - &NodeParamView::QueueKeyframePositionUpdate); - connect(item, &NodeParamViewItem::InputArraySizeChanged, this, - &NodeParamView::InputArraySizeChanged); + &NodeParamView::queue_keyframe_position_update); + connect(item, &NodeParamViewItem::array_expanded_changed, this, + &NodeParamView::queue_keyframe_position_update); + connect(item, &NodeParamViewItem::expanded_changed, this, + &NodeParamView::queue_keyframe_position_update); + connect(item, &NodeParamViewItem::moved, this, + &NodeParamView::queue_keyframe_position_update); + connect(item, &NodeParamViewItem::input_array_size_changed, this, + &NodeParamView::input_array_size_changed); - item->SetKeyframeConnections(keyframe_view_->AddKeyframesOfNode(n)); + item->set_keyframe_connections(keyframe_view_->add_keyframes_of_node(n)); } } -int GetDistanceBetweenNodes(Node *start, Node *end) +int get_distance_between_nodes(Node *start, Node *end) { if (start == end) { return 0; @@ -825,7 +825,7 @@ int GetDistanceBetweenNodes(Node *start, Node *end) for (auto it = start->input_connections().cbegin(); it != start->input_connections().cend(); it++) { - int this_node_dist = GetDistanceBetweenNodes(it->second, end); + int this_node_dist = get_distance_between_nodes(it->second, end); if (this_node_dist != -1) { return 1 + this_node_dist; } @@ -834,18 +834,18 @@ int GetDistanceBetweenNodes(Node *start, Node *end) return -1; } -void NodeParamView::SortItemsInContext(NodeParamViewContext *context_item) +void NodeParamView::sort_items_in_context(NodeParamViewContext *context_item) { QVector> distances; - for (auto it = context_item->GetItems().cbegin(); - it != context_item->GetItems().cend(); it++) { + for (auto it = context_item->get_items().cbegin(); + it != context_item->get_items().cend(); it++) { NodeParamViewItem *item = *it; int distance = -1; - foreach (Node *ctx, context_item->GetContexts()) { + foreach (Node *ctx, context_item->get_contexts()) { distance = - qMax(distance, GetDistanceBetweenNodes(ctx, item->GetNode())); + qMax(distance, get_distance_between_nodes(ctx, item->get_node())); } if (distance == -1) { @@ -869,22 +869,22 @@ void NodeParamView::SortItemsInContext(NodeParamViewContext *context_item) } foreach (auto info, distances) { - context_item->GetDockArea()->AddItem(info.first); + context_item->get_dock_area()->add_item(info.first); } } -NodeParamViewContext *NodeParamView::GetContextItemFromContext(Node *ctx) +NodeParamViewContext *NodeParamView::get_context_item_from_context(Node *ctx) { - Track::Type ctx_type = Track::kCount; + Track::Type ctx_type = Track::k_count; if (ClipBlock *clip = dynamic_cast(ctx)) { if (clip->track()) { - if (clip->track()->type() != Track::kNone) { + if (clip->track()->type() != Track::k_none) { ctx_type = clip->track()->type(); } } } else if (Track *track = dynamic_cast(ctx)) { - if (track->type() != Track::kNone) { + if (track->type() != Track::k_none) { ctx_type = track->type(); } } @@ -892,7 +892,7 @@ NodeParamViewContext *NodeParamView::GetContextItemFromContext(Node *ctx) return context_items_.at(ctx_type); } -void NodeParamView::ToggleSelect(NodeParamViewItem *item) +void NodeParamView::toggle_select(NodeParamViewItem *item) { QVector new_sel; @@ -904,31 +904,31 @@ void NodeParamView::ToggleSelect(NodeParamViewItem *item) // De-select this node if (qApp->keyboardModifiers() & Qt::ShiftModifier) { new_sel.removeOne(item); - SetSelectedNodes(new_sel, true); + set_selected_nodes(new_sel, true); } } else { new_sel.append(item); - SetSelectedNodes(new_sel, false); + set_selected_nodes(new_sel, false); if (!new_sel.contains(focused_node_)) { // This node gets sent to both the curve editor and viewer, so we focus it even if it has // no gizmos focused_node_ = item; - emit FocusedNodeChanged(focused_node_ ? focused_node_->GetNode() : + emit focused_node_changed(focused_node_ ? focused_node_->get_node() : nullptr); } } } QHash -NodeParamView::GenerateExistingPasteMap(const ProjectSerializer::Result &r) +NodeParamView::generate_existing_paste_map(const ProjectSerializer::Result &r) { QVector ignore_nodes; QHash existing_nodes; - for (Node *n : r.GetLoadData().nodes) { + for (Node *n : r.get_load_data().nodes) { if (Node *existing = - GetNodeWithIDAndIgnoreList(n->id(), ignore_nodes)) { + get_node_with_id_and_ignore_list(n->id(), ignore_nodes)) { existing_nodes.insert(existing, n); ignore_nodes.append(existing); } @@ -936,18 +936,18 @@ NodeParamView::GenerateExistingPasteMap(const ProjectSerializer::Result &r) return existing_nodes; } -void NodeParamView::UpdateGlobalScrollBar() +void NodeParamView::update_global_scroll_bar() { if (keyframe_view_) { - keyframe_view_->SetMaxScroll(param_widget_container_->height() - + keyframe_view_->set_max_scroll(param_widget_container_->height() - ruler()->height()); } } -void NodeParamView::PinNode(bool pin) +void NodeParamView::pin_node(bool pin) { NodeParamViewItem *item = static_cast(sender()); - Node *node = item->GetNode(); + Node *node = item->get_node(); if (pin) { pinned_nodes_.append(node); @@ -991,27 +991,27 @@ void NodeParamView::PinNode(bool pin) } }*/ -void NodeParamView::UpdateElementY() +void NodeParamView::update_element_y() { for (NodeParamViewContext *ctx : context_items_) { - for (auto it = ctx->GetItems().cbegin(); it != ctx->GetItems().cend(); + for (auto it = ctx->get_items().cbegin(); it != ctx->get_items().cend(); it++) { NodeParamViewItem *item = *it; - Node *node = item->GetNode(); + Node *node = item->get_node(); const KeyframeView::NodeConnections &connections = - item->GetKeyframeConnections(); + item->get_keyframe_connections(); if (!connections.isEmpty()) { for (const QString &input : node->inputs()) { - if (!(node->GetInputFlags(input) & kInputFlagHidden)) { + if (!(node->get_input_flags(input) & k_input_flag_hidden)) { int arr_sz = - NodeGroup::ResolveInput(NodeInput(node, input)) - .GetArraySize(); + NodeGroup::resolve_input(NodeInput(node, input)) + .get_array_size(); for (int i = -1; i < arr_sz; i++) { NodeInput ic = { node, input, i }; - int y = item->GetElementY(ic); + int y = item->get_element_y(ic); // For some reason Qt's mapToGlobal doesn't seem to handle this, so we offset here y += vertical_scrollbar_->value(); @@ -1024,7 +1024,7 @@ void NodeParamView::UpdateElementY() input_con.at(ic.element() + 1); for (KeyframeViewInputConnection *track : ele_con) { - track->SetKeyframeY(y); + track->set_keyframe_y(y); } } } @@ -1035,68 +1035,68 @@ void NodeParamView::UpdateElementY() } } -void NodeParamView::NodeAddedToContext(Node *n) +void NodeParamView::node_added_to_context(Node *n) { Node *ctx = static_cast(sender()); - NodeParamViewContext *item = GetContextItemFromContext(ctx); + NodeParamViewContext *item = get_context_item_from_context(ctx); - AddNode(n, ctx, item); + add_node(n, ctx, item); - SortItemsInContext(item); + sort_items_in_context(item); if (keyframe_view_) { - QueueKeyframePositionUpdate(); + queue_keyframe_position_update(); } } -void NodeParamView::NodeRemovedFromContext(Node *n) +void NodeParamView::node_removed_from_context(Node *n) { Node *ctx = static_cast(sender()); foreach (NodeParamViewContext *ctx_item, context_items_) { - ctx_item->RemoveNode(n, ctx); + ctx_item->remove_node(n, ctx); } if (keyframe_view_) { - QueueKeyframePositionUpdate(); + queue_keyframe_position_update(); } } -void NodeParamView::InputCheckBoxChanged(const NodeInput &input, bool e) +void NodeParamView::input_check_box_changed(const NodeInput &input, bool e) { NodeGroup *group = static_cast(contexts_.first()); if (e) { - group->AddInputPassthrough(input); + group->add_input_passthrough(input); } else { - group->RemoveInputPassthrough(input); + group->remove_input_passthrough(input); } } -void NodeParamView::GroupInputPassthroughAdded(NodeGroup *group, +void NodeParamView::group_input_passthrough_added(NodeGroup *group, const NodeInput &input) { foreach (NodeParamViewContext *pvctx, context_items_) { - pvctx->SetInputChecked(input, true); + pvctx->set_input_checked(input, true); } } -void NodeParamView::GroupInputPassthroughRemoved(NodeGroup *group, +void NodeParamView::group_input_passthrough_removed(NodeGroup *group, const NodeInput &input) { foreach (NodeParamViewContext *pvctx, context_items_) { - pvctx->SetInputChecked(input, false); + pvctx->set_input_checked(input, false); } } -void NodeParamView::InputArraySizeChanged(const QString &input, int, +void NodeParamView::input_array_size_changed(const QString &input, int, int new_size) { NodeParamViewItem *sender = static_cast(this->sender()); KeyframeView::NodeConnections &connections = - sender->GetKeyframeConnections(); + sender->get_keyframe_connections(); KeyframeView::InputConnections &inputs = connections[input]; int adj_new_size = new_size + 1; @@ -1107,7 +1107,7 @@ void NodeParamView::InputArraySizeChanged(const QString &input, int, for (int i = adj_new_size; i < inputs.size(); i++) { const KeyframeView::ElementConnections &ec = inputs.at(i); for (auto kc : ec) { - keyframe_view_->RemoveKeyframesOfTrack(kc); + keyframe_view_->remove_keyframes_of_track(kc); } } @@ -1122,13 +1122,13 @@ void NodeParamView::InputArraySizeChanged(const QString &input, int, // Fill in extra elements for (int i = old_size; i < inputs.size(); i++) { - inputs[i] = keyframe_view_->AddKeyframesOfElement( - NodeInput(sender->GetNode(), input, i - 1)); + inputs[i] = keyframe_view_->add_keyframes_of_element( + NodeInput(sender->get_node(), input, i - 1)); } } } - QueueKeyframePositionUpdate(); + queue_keyframe_position_update(); } } diff --git a/app/widget/nodeparamview/nodeparamview.h b/app/widget/nodeparamview/nodeparamview.h index e6ae460ef..e6c7cc2db 100644 --- a/app/widget/nodeparamview/nodeparamview.h +++ b/app/widget/nodeparamview/nodeparamview.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEW_H -#define NODEPARAMVIEW_H +#ifndef OAK_NODEPARAMVIEW_H +#define OAK_NODEPARAMVIEW_H #include #include @@ -48,104 +48,104 @@ public: virtual ~NodeParamView() override; - void CloseContextsBelongingToProject(Project *p); + void close_contexts_belonging_to_project(Project *p); void DeleteSelected(); - void SelectAll() + void select_all() { - keyframe_view_->SelectAll(); + keyframe_view_->select_all(); } - void DeselectAll() + void deselect_all() { - keyframe_view_->DeselectAll(); + keyframe_view_->deselect_all(); } - void SetSelectedNodes(const QVector &nodes, + void set_selected_nodes(const QVector &nodes, bool handle_focused_node = true, bool emit_signal = true); - void SetSelectedNodes(const QVector &nodes, + void set_selected_nodes(const QVector &nodes, bool emit_signal = true); - Node *GetNodeWithID(const QString &id); - Node *GetNodeWithIDAndIgnoreList(const QString &id, + Node *get_node_with_id(const QString &id); + Node *get_node_with_id_and_ignore_list(const QString &id, const QVector &ignore); - const QVector &GetContexts() const + const QVector &get_contexts() const { return contexts_; } - virtual bool CopySelected(bool cut) override; + virtual bool copy_selected(bool cut) override; - virtual bool Paste() override; - static bool Paste( + virtual bool paste() override; + static bool paste( QWidget *parent, std::function(const ProjectSerializer::Result &)> get_existing_map_function); public slots: - void SetContexts(const QVector &contexts); + void set_contexts(const QVector &contexts); - void UpdateElementY(); + void update_element_y(); signals: - void FocusedNodeChanged(Node *n); + void focused_node_changed(Node *n); - void SelectedNodesChanged(const QVector &nodes); + void selected_nodes_changed(const QVector &nodes); - void RequestViewerToStartEditingText(); + void request_viewer_to_start_editing_text(); protected: virtual void resizeEvent(QResizeEvent *event) override; virtual void ScaleChangedEvent(const double &) override; - virtual void TimebaseChangedEvent(const rational &) override; + virtual void TimebaseChangedEvent(const Rational &) override; virtual void ConnectedNodeChangeEvent(ViewerOutput *n) override; virtual const QVector * - GetSnapKeyframes() const override + get_snap_keyframes() const override { - return keyframe_view_ ? &keyframe_view_->GetKeyframeTracks() : nullptr; + return keyframe_view_ ? &keyframe_view_->get_keyframe_tracks() : nullptr; } virtual const std::vector * - GetSnapIgnoreKeyframes() const override + get_snap_ignore_keyframes() const override { - return keyframe_view_ ? &keyframe_view_->GetSelectedKeyframes() : + return keyframe_view_ ? &keyframe_view_->get_selected_keyframes() : nullptr; } - virtual const TimeTargetObject *GetKeyframeTimeTarget() const override + virtual const TimeTargetObject *get_keyframe_time_target() const override { return keyframe_view_; } private: - void QueueKeyframePositionUpdate(); + void queue_keyframe_position_update(); - void AddContext(Node *context); + void add_context(Node *context); - void RemoveContext(Node *context); + void remove_context(Node *context); - void AddNode(Node *n, Node *ctx, NodeParamViewContext *context); + void add_node(Node *n, Node *ctx, NodeParamViewContext *context); - void SortItemsInContext(NodeParamViewContext *context); + void sort_items_in_context(NodeParamViewContext *context); - NodeParamViewContext *GetContextItemFromContext(Node *context); + NodeParamViewContext *get_context_item_from_context(Node *context); - bool IsGroupMode() const + bool is_group_mode() const { return contexts_.size() == 1 && dynamic_cast(contexts_.first()); } - void ToggleSelect(NodeParamViewItem *item); + void toggle_select(NodeParamViewItem *item); QHash - GenerateExistingPasteMap(const ProjectSerializer::Result &r); + generate_existing_paste_map(const ProjectSerializer::Result &r); KeyframeView *keyframe_view_; @@ -174,38 +174,38 @@ private: bool show_all_nodes_; private slots: - void UpdateGlobalScrollBar(); + void update_global_scroll_bar(); - void PinNode(bool pin); + void pin_node(bool pin); //void FocusChanged(QWidget *old, QWidget *now); - void NodeAddedToContext(Node *n); + void node_added_to_context(Node *n); - void NodeRemovedFromContext(Node *n); + void node_removed_from_context(Node *n); - void InputCheckBoxChanged(const NodeInput &input, bool e); + void input_check_box_changed(const NodeInput &input, bool e); - void GroupInputPassthroughAdded(olive::NodeGroup *group, + void group_input_passthrough_added(olive::NodeGroup *group, const olive::NodeInput &input); - void GroupInputPassthroughRemoved(olive::NodeGroup *group, + void group_input_passthrough_removed(olive::NodeGroup *group, const olive::NodeInput &input); - void UpdateContexts(); + void update_contexts(); - void ItemAboutToBeRemoved(NodeParamViewItem *item); + void item_about_to_be_removed(NodeParamViewItem *item); - void ItemClicked(); + void item_clicked(); - void SelectNodeFromConnectedLink(Node *node); + void select_node_from_connected_link(Node *node); - void RequestEditTextInViewer(); + void request_edit_text_in_viewer(); - void InputArraySizeChanged(const QString &input, int old_size, + void input_array_size_changed(const QString &input, int old_size, int new_size); }; } -#endif // NODEPARAMVIEW_H +#endif // OAK_NODEPARAMVIEW_H diff --git a/app/widget/nodeparamview/nodeparamviewarraywidget.cpp b/app/widget/nodeparamview/nodeparamviewarraywidget.cpp index d7dbfd27c..8c3f84c9d 100644 --- a/app/widget/nodeparamview/nodeparamviewarraywidget.cpp +++ b/app/widget/nodeparamview/nodeparamviewarraywidget.cpp @@ -41,20 +41,20 @@ NodeParamViewArrayWidget::NodeParamViewArrayWidget(Node *node, count_lbl_ = new QLabel(); layout->addWidget(count_lbl_); - connect(node_, &Node::InputArraySizeChanged, this, - &NodeParamViewArrayWidget::UpdateCounter); + connect(node_, &Node::input_array_size_changed, this, + &NodeParamViewArrayWidget::update_counter); - UpdateCounter(input_, 0, node_->InputArraySize(input_)); + update_counter(input_, 0, node_->input_array_size(input_)); } void NodeParamViewArrayWidget::mouseDoubleClickEvent(QMouseEvent *event) { QWidget::mouseDoubleClickEvent(event); - emit DoubleClicked(); + emit double_clicked(); } -void NodeParamViewArrayWidget::UpdateCounter(const QString &input, int old_size, +void NodeParamViewArrayWidget::update_counter(const QString &input, int old_size, int new_size) { Q_UNUSED(old_size) @@ -68,7 +68,7 @@ NodeParamViewArrayButton::NodeParamViewArrayButton( : QPushButton(parent) , type_(type) { - Retranslate(); + retranslate(); int sz = sizeHint().height() / 3 * 2; setFixedSize(sz, sz); @@ -77,15 +77,15 @@ NodeParamViewArrayButton::NodeParamViewArrayButton( void NodeParamViewArrayButton::changeEvent(QEvent *event) { if (event->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } QPushButton::changeEvent(event); } -void NodeParamViewArrayButton::Retranslate() +void NodeParamViewArrayButton::retranslate() { - if (type_ == kAdd) { + if (type_ == k_add) { setText(tr("+")); } else { setText(tr("-")); diff --git a/app/widget/nodeparamview/nodeparamviewarraywidget.h b/app/widget/nodeparamview/nodeparamviewarraywidget.h index 27aee635d..ce98bb91a 100644 --- a/app/widget/nodeparamview/nodeparamviewarraywidget.h +++ b/app/widget/nodeparamview/nodeparamviewarraywidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWARRAYWIDGET_H -#define NODEPARAMVIEWARRAYWIDGET_H +#ifndef OAK_NODEPARAMVIEWARRAYWIDGET_H +#define OAK_NODEPARAMVIEWARRAYWIDGET_H #include #include @@ -34,7 +34,7 @@ namespace olive class NodeParamViewArrayButton : public QPushButton { Q_OBJECT public: - enum Type { kAdd, kRemove }; + enum Type { k_add, k_remove }; NodeParamViewArrayButton(Type type, QWidget *parent = nullptr); @@ -42,7 +42,7 @@ protected: virtual void changeEvent(QEvent *event) override; private: - void Retranslate(); + void retranslate(); Type type_; }; @@ -54,7 +54,7 @@ public: QWidget *parent = nullptr); signals: - void DoubleClicked(); + void double_clicked(); protected: virtual void mouseDoubleClickEvent(QMouseEvent *event) override; @@ -67,9 +67,9 @@ private: QLabel *count_lbl_; private slots: - void UpdateCounter(const QString &input, int old_size, int new_size); + void update_counter(const QString &input, int old_size, int new_size); }; } -#endif // NODEPARAMVIEWARRAYWIDGET_H +#endif // OAK_NODEPARAMVIEWARRAYWIDGET_H diff --git a/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp b/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp index 3f9c03d59..5efb922ff 100644 --- a/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp +++ b/app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp @@ -51,7 +51,7 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input, // Set up label area QHBoxLayout *label_layout = new QHBoxLayout(); label_layout->setSpacing( - QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral(" "))); + QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral(" "))); label_layout->setContentsMargins(0, 0, 0, 0); layout->addLayout(label_layout); @@ -64,10 +64,10 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input, connected_to_lbl_ = new ClickableLabel(this); connected_to_lbl_->setCursor(Qt::PointingHandCursor); connected_to_lbl_->setContextMenuPolicy(Qt::CustomContextMenu); - connect(connected_to_lbl_, &ClickableLabel::MouseClicked, this, - &NodeParamViewConnectedLabel::ConnectionClicked); + connect(connected_to_lbl_, &ClickableLabel::mouse_clicked, this, + &NodeParamViewConnectedLabel::connection_clicked); connect(connected_to_lbl_, &ClickableLabel::customContextMenuRequested, - this, &NodeParamViewConnectedLabel::ShowLabelContextMenu); + this, &NodeParamViewConnectedLabel::show_label_context_menu); label_layout->addWidget(connected_to_lbl_); label_layout->addStretch(); @@ -78,47 +78,47 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input, connected_to_lbl_->setForegroundRole(QPalette::Link); connected_to_lbl_->setFont(link_font); - if (input_.IsConnected()) { - InputConnected(input_.GetConnectedOutput(), input_); + if (input_.is_connected()) { + input_connected(input_.get_connected_output(), input_); } else { - InputDisconnected(nullptr, input_); + input_disconnected(nullptr, input_); } - connect(input_.node(), &Node::InputConnected, this, - &NodeParamViewConnectedLabel::InputConnected); - connect(input_.node(), &Node::InputDisconnected, this, - &NodeParamViewConnectedLabel::InputDisconnected); + connect(input_.node(), &Node::input_connected, this, + &NodeParamViewConnectedLabel::input_connected); + connect(input_.node(), &Node::input_disconnected, this, + &NodeParamViewConnectedLabel::input_disconnected); // Creating the tree is expensive, hold off until the user specifically requests it value_tree_ = nullptr; connect(collapse_btn, &CollapseButton::toggled, this, - &NodeParamViewConnectedLabel::SetValueTreeVisible); + &NodeParamViewConnectedLabel::set_value_tree_visible); } -void NodeParamViewConnectedLabel::SetViewerNode(ViewerOutput *viewer) +void NodeParamViewConnectedLabel::set_viewer_node(ViewerOutput *viewer) { if (viewer_) { - disconnect(viewer_, &ViewerOutput::PlayheadChanged, this, - &NodeParamViewConnectedLabel::UpdateValueTree); + disconnect(viewer_, &ViewerOutput::playhead_changed, this, + &NodeParamViewConnectedLabel::update_value_tree); } viewer_ = viewer; if (viewer_) { - connect(viewer_, &ViewerOutput::PlayheadChanged, this, - &NodeParamViewConnectedLabel::UpdateValueTree); - UpdateValueTree(); + connect(viewer_, &ViewerOutput::playhead_changed, this, + &NodeParamViewConnectedLabel::update_value_tree); + update_value_tree(); } } -void NodeParamViewConnectedLabel::CreateTree() +void NodeParamViewConnectedLabel::create_tree() { // Set up table area value_tree_ = new NodeValueTree(this); layout()->addWidget(value_tree_); } -void NodeParamViewConnectedLabel::InputConnected(Node *output, +void NodeParamViewConnectedLabel::input_connected(Node *output, const NodeInput &input) { if (input_ != input) { @@ -127,10 +127,10 @@ void NodeParamViewConnectedLabel::InputConnected(Node *output, connected_node_ = output; - UpdateLabel(); + update_label(); } -void NodeParamViewConnectedLabel::InputDisconnected(Node *output, +void NodeParamViewConnectedLabel::input_disconnected(Node *output, const NodeInput &input) { if (input_ != input) { @@ -141,10 +141,10 @@ void NodeParamViewConnectedLabel::InputDisconnected(Node *output, connected_node_ = nullptr; - UpdateLabel(); + update_label(); } -void NodeParamViewConnectedLabel::ShowLabelContextMenu() +void NodeParamViewConnectedLabel::show_label_context_menu() { Menu m(this); @@ -152,25 +152,25 @@ void NodeParamViewConnectedLabel::ShowLabelContextMenu() connect(disconnect_action, &QAction::triggered, this, [this]() { Core::instance()->undo_stack()->push( new NodeEdgeRemoveCommand(connected_node_, input_), - Node::GetDisconnectCommandString(connected_node_, input_)); + Node::get_disconnect_command_string(connected_node_, input_)); }); m.exec(QCursor::pos()); } -void NodeParamViewConnectedLabel::ConnectionClicked() +void NodeParamViewConnectedLabel::connection_clicked() { if (connected_node_) { - emit RequestSelectNode(connected_node_); + emit request_select_node(connected_node_); } } -void NodeParamViewConnectedLabel::UpdateLabel() +void NodeParamViewConnectedLabel::update_label() { QString s; if (connected_node_) { - s = connected_node_->Name(); + s = connected_node_->name(); } else { s = tr("Nothing"); } @@ -178,14 +178,14 @@ void NodeParamViewConnectedLabel::UpdateLabel() connected_to_lbl_->setText(s); } -void NodeParamViewConnectedLabel::UpdateValueTree() +void NodeParamViewConnectedLabel::update_value_tree() { if (value_tree_ && viewer_ && value_tree_->isVisible()) { - value_tree_->SetNode(input_, viewer_->GetPlayhead()); + value_tree_->set_node(input_, viewer_->get_playhead()); } } -void NodeParamViewConnectedLabel::SetValueTreeVisible(bool e) +void NodeParamViewConnectedLabel::set_value_tree_visible(bool e) { if (value_tree_) { value_tree_->setVisible(e); @@ -193,11 +193,11 @@ void NodeParamViewConnectedLabel::SetValueTreeVisible(bool e) if (e) { if (!value_tree_) { - CreateTree(); + create_tree(); value_tree_->setVisible(true); } - UpdateValueTree(); + update_value_tree(); } } diff --git a/app/widget/nodeparamview/nodeparamviewconnectedlabel.h b/app/widget/nodeparamview/nodeparamviewconnectedlabel.h index ecfedf98d..470731f8e 100644 --- a/app/widget/nodeparamview/nodeparamviewconnectedlabel.h +++ b/app/widget/nodeparamview/nodeparamviewconnectedlabel.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWCONNECTEDLABEL_H -#define NODEPARAMVIEWCONNECTEDLABEL_H +#ifndef OAK_NODEPARAMVIEWCONNECTEDLABEL_H +#define OAK_NODEPARAMVIEWCONNECTEDLABEL_H #include "node/param.h" #include "widget/clickablelabel/clickablelabel.h" @@ -35,26 +35,26 @@ public: NodeParamViewConnectedLabel(const NodeInput &input, QWidget *parent = nullptr); - void SetViewerNode(ViewerOutput *viewer); + void set_viewer_node(ViewerOutput *viewer); signals: - void RequestSelectNode(Node *n); + void request_select_node(Node *n); private slots: - void InputConnected(Node *output, const NodeInput &input); + void input_connected(Node *output, const NodeInput &input); - void InputDisconnected(Node *output, const NodeInput &input); + void input_disconnected(Node *output, const NodeInput &input); - void ShowLabelContextMenu(); + void show_label_context_menu(); - void ConnectionClicked(); + void connection_clicked(); private: - void UpdateLabel(); + void update_label(); - void UpdateValueTree(); + void update_value_tree(); - void CreateTree(); + void create_tree(); ClickableLabel *connected_to_lbl_; @@ -67,9 +67,9 @@ private: ViewerOutput *viewer_; private slots: - void SetValueTreeVisible(bool e); + void set_value_tree_visible(bool e); }; } -#endif // NODEPARAMVIEWCONNECTEDLABEL_H +#endif // OAK_NODEPARAMVIEWCONNECTEDLABEL_H diff --git a/app/widget/nodeparamview/nodeparamviewcontext.cpp b/app/widget/nodeparamview/nodeparamviewcontext.cpp index 22b82a584..b16b253db 100644 --- a/app/widget/nodeparamview/nodeparamviewcontext.cpp +++ b/app/widget/nodeparamview/nodeparamviewcontext.cpp @@ -34,29 +34,29 @@ namespace olive NodeParamViewContext::NodeParamViewContext(QWidget *parent) : super(parent) - , type_(Track::kNone) + , type_(Track::k_none) { QWidget *body = new QWidget(); QHBoxLayout *body_layout = new QHBoxLayout(body); - SetBody(body); + set_body(body); dock_area_ = new NodeParamViewDockArea(); body_layout->addWidget(dock_area_); setBackgroundRole(QPalette::Base); - Retranslate(); + retranslate(); - connect(title_bar(), &NodeParamViewItemTitleBar::AddEffectButtonClicked, - this, &NodeParamViewContext::AddEffectButtonClicked); + connect(title_bar(), &NodeParamViewItemTitleBar::add_effect_button_clicked, + this, &NodeParamViewContext::add_effect_button_clicked); } -NodeParamViewItem *NodeParamViewContext::GetItem(Node *node, Node *ctx) +NodeParamViewItem *NodeParamViewContext::get_item(Node *node, Node *ctx) { for (auto it = items_.begin(); it != items_.end(); it++) { NodeParamViewItem *item = *it; - if (item->GetNode() == node && item->GetContext() == ctx) { + if (item->get_node() == node && item->get_context() == ctx) { return item; } } @@ -64,20 +64,20 @@ NodeParamViewItem *NodeParamViewContext::GetItem(Node *node, Node *ctx) return nullptr; } -void NodeParamViewContext::AddNode(NodeParamViewItem *item) +void NodeParamViewContext::add_node(NodeParamViewItem *item) { items_.append(item); - dock_area_->AddItem(item); + dock_area_->add_item(item); } -void NodeParamViewContext::RemoveNode(Node *node, Node *ctx) +void NodeParamViewContext::remove_node(Node *node, Node *ctx) { for (auto it = items_.begin(); it != items_.end();) { NodeParamViewItem *item = *it; - if (item->GetNode() == node && item->GetContext() == ctx) { - emit AboutToDeleteItem(item); - dock_area_->RemoveItem(item); + if (item->get_node() == node && item->get_context() == ctx) { + emit about_to_delete_item(item); + dock_area_->remove_item(item); it = items_.erase(it); } else { it++; @@ -85,14 +85,14 @@ void NodeParamViewContext::RemoveNode(Node *node, Node *ctx) } } -void NodeParamViewContext::RemoveNodesWithContext(Node *ctx) +void NodeParamViewContext::remove_nodes_with_context(Node *ctx) { for (auto it = items_.begin(); it != items_.end();) { NodeParamViewItem *item = *it; - if (item->GetContext() == ctx) { - emit AboutToDeleteItem(item); - dock_area_->RemoveItem(item); + if (item->get_context() == ctx) { + emit about_to_delete_item(item); + dock_area_->remove_item(item); it = items_.erase(it); } else { it++; @@ -100,72 +100,72 @@ void NodeParamViewContext::RemoveNodesWithContext(Node *ctx) } } -void NodeParamViewContext::SetInputChecked(const NodeInput &input, bool e) +void NodeParamViewContext::set_input_checked(const NodeInput &input, bool e) { foreach (NodeParamViewItem *item, items_) { - if (item->GetNode() == input.node()) { - item->SetInputChecked(input, e); + if (item->get_node() == input.node()) { + item->set_input_checked(input, e); } } } -void NodeParamViewContext::SetTimebase(const rational &timebase) +void NodeParamViewContext::set_timebase(const Rational &timebase) { foreach (NodeParamViewItem *item, items_) { - item->SetTimebase(timebase); + item->set_timebase(timebase); } } -void NodeParamViewContext::SetTimeTarget(ViewerOutput *n) +void NodeParamViewContext::set_time_target(ViewerOutput *n) { foreach (NodeParamViewItem *item, items_) { - item->SetTimeTarget(n); + item->set_time_target(n); } } -void NodeParamViewContext::SetEffectType(Track::Type type) +void NodeParamViewContext::set_effect_type(Track::Type type) { type_ = type; } -void NodeParamViewContext::Retranslate() +void NodeParamViewContext::retranslate() { } -void NodeParamViewContext::AddEffectButtonClicked() +void NodeParamViewContext::add_effect_button_clicked() { - Node::Flag flag = Node::kNone; + Node::Flag flag = Node::k_none; - if (type_ == Track::kVideo) { - flag = Node::kVideoEffect; + if (type_ == Track::k_video) { + flag = Node::k_video_effect; } else { - flag = Node::kAudioEffect; + flag = Node::k_audio_effect; } - if (flag == Node::kNone) { + if (flag == Node::k_none) { return; } Menu *m = - NodeFactory::CreateMenu(this, false, Node::kCategoryUnknown, flag); + NodeFactory::create_menu(this, false, Node::k_category_unknown, flag); connect(m, &Menu::triggered, this, - &NodeParamViewContext::AddEffectMenuItemTriggered); + &NodeParamViewContext::add_effect_menu_item_triggered); m->exec(QCursor::pos()); delete m; } -void NodeParamViewContext::AddEffectMenuItemTriggered(QAction *a) +void NodeParamViewContext::add_effect_menu_item_triggered(QAction *a) { Node *n = NodeFactory::CreateFromMenuAction(a); if (n) { - NodeInput new_node_input = n->GetEffectInput(); + NodeInput new_node_input = n->get_effect_input(); MultiUndoCommand *command = new MultiUndoCommand(); QVector graphs_added_to; foreach (Node *ctx, contexts_) { - NodeInput ctx_input = ctx->GetEffectInput(); + NodeInput ctx_input = ctx->get_effect_input(); if (!graphs_added_to.contains(ctx->parent())) { command->add_child(new NodeAddCommand(ctx->parent(), n)); @@ -173,12 +173,12 @@ void NodeParamViewContext::AddEffectMenuItemTriggered(QAction *a) } command->add_child(new NodeSetPositionCommand( - n, ctx, ctx->GetNodePositionInContext(ctx))); + n, ctx, ctx->get_node_position_in_context(ctx))); command->add_child(new NodeSetPositionCommand( - ctx, ctx, ctx->GetNodePositionInContext(ctx) + QPointF(1, 0))); + ctx, ctx, ctx->get_node_position_in_context(ctx) + QPointF(1, 0))); - if (ctx_input.IsConnected()) { - Node *prev_output = ctx_input.GetConnectedOutput(); + if (ctx_input.is_connected()) { + Node *prev_output = ctx_input.get_connected_output(); command->add_child( new NodeEdgeRemoveCommand(prev_output, ctx_input)); @@ -190,7 +190,7 @@ void NodeParamViewContext::AddEffectMenuItemTriggered(QAction *a) } Core::instance()->undo_stack()->push( - command, tr("Added %1 to Node Chain").arg(n->Name())); + command, tr("Added %1 to Node Chain").arg(n->name())); } } diff --git a/app/widget/nodeparamview/nodeparamviewcontext.h b/app/widget/nodeparamview/nodeparamviewcontext.h index 3f99b9c0e..81f844916 100644 --- a/app/widget/nodeparamview/nodeparamviewcontext.h +++ b/app/widget/nodeparamview/nodeparamviewcontext.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWCONTEXT_H -#define NODEPARAMVIEWCONTEXT_H +#ifndef OAK_NODEPARAMVIEWCONTEXT_H +#define OAK_NODEPARAMVIEWCONTEXT_H #include "nodeparamviewdockarea.h" #include "nodeparamviewitembase.h" @@ -34,53 +34,53 @@ class NodeParamViewContext : public NodeParamViewItemBase { public: NodeParamViewContext(QWidget *parent = nullptr); - NodeParamViewDockArea *GetDockArea() const + NodeParamViewDockArea *get_dock_area() const { return dock_area_; } - const QVector &GetContexts() const + const QVector &get_contexts() const { return contexts_; } - const QVector &GetItems() const + const QVector &get_items() const { return items_; } - NodeParamViewItem *GetItem(Node *node, Node *ctx); + NodeParamViewItem *get_item(Node *node, Node *ctx); - void AddNode(NodeParamViewItem *item); + void add_node(NodeParamViewItem *item); - void RemoveNode(Node *node, Node *ctx); + void remove_node(Node *node, Node *ctx); - void RemoveNodesWithContext(Node *ctx); + void remove_nodes_with_context(Node *ctx); - void SetInputChecked(const NodeInput &input, bool e); + void set_input_checked(const NodeInput &input, bool e); - void SetTimebase(const rational &timebase); + void set_timebase(const Rational &timebase); - void SetTimeTarget(ViewerOutput *n); + void set_time_target(ViewerOutput *n); - void SetEffectType(Track::Type type); + void set_effect_type(Track::Type type); signals: - void AboutToDeleteItem(NodeParamViewItem *item); + void about_to_delete_item(NodeParamViewItem *item); public slots: - void AddContext(Node *node) + void add_context(Node *node) { contexts_.append(node); } - void RemoveContext(Node *node) + void remove_context(Node *node) { contexts_.removeOne(node); } protected slots: - virtual void Retranslate() override; + virtual void retranslate() override; private: NodeParamViewDockArea *dock_area_; @@ -92,11 +92,11 @@ private: Track::Type type_; private slots: - void AddEffectButtonClicked(); + void add_effect_button_clicked(); - void AddEffectMenuItemTriggered(QAction *a); + void add_effect_menu_item_triggered(QAction *a); }; } -#endif // NODEPARAMVIEWCONTEXT_H +#endif // OAK_NODEPARAMVIEWCONTEXT_H diff --git a/app/widget/nodeparamview/nodeparamviewdockarea.cpp b/app/widget/nodeparamview/nodeparamviewdockarea.cpp index af91aa80f..0903d2d22 100644 --- a/app/widget/nodeparamview/nodeparamviewdockarea.cpp +++ b/app/widget/nodeparamview/nodeparamviewdockarea.cpp @@ -42,7 +42,7 @@ QMenu *NodeParamViewDockArea::createPopupMenu() return nullptr; } -void NodeParamViewDockArea::AddItem(QDockWidget *item) +void NodeParamViewDockArea::add_item(QDockWidget *item) { item->setAllowedAreas(Qt::LeftDockWidgetArea); item->setFeatures(QDockWidget::DockWidgetClosable | @@ -50,7 +50,7 @@ void NodeParamViewDockArea::AddItem(QDockWidget *item) addDockWidget(Qt::LeftDockWidgetArea, item); } -void NodeParamViewDockArea::RemoveItem(QDockWidget *item) +void NodeParamViewDockArea::remove_item(QDockWidget *item) { if (!item) { return; diff --git a/app/widget/nodeparamview/nodeparamviewdockarea.h b/app/widget/nodeparamview/nodeparamviewdockarea.h index 44826876f..bde6e8921 100644 --- a/app/widget/nodeparamview/nodeparamviewdockarea.h +++ b/app/widget/nodeparamview/nodeparamviewdockarea.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWDOCKAREA_H -#define NODEPARAMVIEWDOCKAREA_H +#ifndef OAK_NODEPARAMVIEWDOCKAREA_H +#define OAK_NODEPARAMVIEWDOCKAREA_H #include @@ -36,10 +36,10 @@ public: virtual QMenu *createPopupMenu() override; - void AddItem(QDockWidget *item); - void RemoveItem(QDockWidget *item); + void add_item(QDockWidget *item); + void remove_item(QDockWidget *item); }; } -#endif // NODEPARAMVIEWDOCKAREA_H +#endif // OAK_NODEPARAMVIEWDOCKAREA_H diff --git a/app/widget/nodeparamview/nodeparamviewitem.cpp b/app/widget/nodeparamview/nodeparamviewitem.cpp index 526ab169d..d2c4f1975 100644 --- a/app/widget/nodeparamview/nodeparamviewitem.cpp +++ b/app/widget/nodeparamview/nodeparamviewitem.cpp @@ -30,21 +30,21 @@ #include "node/group/group.h" #include "node/nodeundo.h" #include "node/project/sequence/sequence.h" -#include "pluginSupport/OlivePluginInstance.h" +#include "pluginSupport/oliveplugininstance.h" namespace olive { -const int NodeParamViewItemBody::kKeyControlColumn = 10; -const int NodeParamViewItemBody::kArrayInsertColumn = kKeyControlColumn - 1; -const int NodeParamViewItemBody::kArrayRemoveColumn = kArrayInsertColumn - 1; -const int NodeParamViewItemBody::kExtraButtonColumn = kKeyControlColumn - 1; +const int NodeParamViewItemBody::k_key_control_column = 10; +const int NodeParamViewItemBody::k_array_insert_column = k_key_control_column - 1; +const int NodeParamViewItemBody::k_array_remove_column = k_array_insert_column - 1; +const int NodeParamViewItemBody::k_extra_button_column = k_key_control_column - 1; -const int NodeParamViewItemBody::kOptionalCheckBox = 0; -const int NodeParamViewItemBody::kArrayCollapseBtnColumn = 1; -const int NodeParamViewItemBody::kLabelColumn = 2; -const int NodeParamViewItemBody::kWidgetStartColumn = 3; -const int NodeParamViewItemBody::kMaxWidgetColumn = kArrayRemoveColumn; +const int NodeParamViewItemBody::k_optional_check_box = 0; +const int NodeParamViewItemBody::k_array_collapse_btn_column = 1; +const int NodeParamViewItemBody::k_label_column = 2; +const int NodeParamViewItemBody::k_widget_start_column = 3; +const int NodeParamViewItemBody::k_max_widget_column = k_array_remove_column; #define super NodeParamViewItemBase @@ -61,21 +61,21 @@ NodeParamViewItem::NodeParamViewItem( , ctx_(nullptr) , time_target_(nullptr) { - node_->Retranslate(); + node_->retranslate(); // Create and add contents widget - RecreateBody(); + recreate_body(); - connect(node_, &Node::LabelChanged, this, &NodeParamViewItem::Retranslate); - connect(node_, &Node::InputArraySizeChanged, this, - &NodeParamViewItem::InputArraySizeChanged); - connect(node_, &Node::MessageCountChanged, this, - &NodeParamViewItem::UpdateMessagePanel); + connect(node_, &Node::label_changed, this, &NodeParamViewItem::retranslate); + connect(node_, &Node::input_array_size_changed, this, + &NodeParamViewItem::input_array_size_changed); + connect(node_, &Node::message_count_changed, this, + &NodeParamViewItem::update_message_panel); // FIXME: Implemented to pick up when an input is set to hidden or not - DEFINITELY not a fast // way of doing this, but "fine" for now. - connect(node_, &Node::InputFlagsChanged, this, - &NodeParamViewItem::RecreateBody); + connect(node_, &Node::input_flags_changed, this, + &NodeParamViewItem::recreate_body); setBackgroundRole(QPalette::Window); @@ -84,19 +84,19 @@ NodeParamViewItem::NodeParamViewItem( //title_bar()->SetEnabledCheckBoxChecked(node_->IsEnabled()); //connect(title_bar(), &NodeParamViewItemTitleBar::EnabledCheckBoxClicked, node_, &Node::SetEnabled); - Retranslate(); + retranslate(); } -void NodeParamViewItem::Retranslate() +void NodeParamViewItem::retranslate() { - node_->Retranslate(); + node_->retranslate(); - title_bar()->SetText(GetTitleBarTextFromNode(node_)); + title_bar()->set_text(get_title_bar_text_from_node(node_)); - body_->Retranslate(); + body_->retranslate(); } -void NodeParamViewItem::RecreateBody() +void NodeParamViewItem::recreate_body() { if (body_) { body_->setParent(nullptr); @@ -111,17 +111,17 @@ void NodeParamViewItem::RecreateBody() } body_ = new NodeParamViewItemBody(node_, create_checkboxes_, this); - connect(body_, &NodeParamViewItemBody::RequestSelectNode, this, - &NodeParamViewItem::RequestSelectNode); - connect(body_, &NodeParamViewItemBody::ArrayExpandedChanged, this, - &NodeParamViewItem::ArrayExpandedChanged); - connect(body_, &NodeParamViewItemBody::InputCheckedChanged, this, - &NodeParamViewItem::InputCheckedChanged); - connect(body_, &NodeParamViewItemBody::RequestEditTextInViewer, this, - &NodeParamViewItem::RequestEditTextInViewer); - body_->Retranslate(); - body_->SetTimebase(timebase_); - body_->SetTimeTarget(time_target_); + connect(body_, &NodeParamViewItemBody::request_select_node, this, + &NodeParamViewItem::request_select_node); + connect(body_, &NodeParamViewItemBody::array_expanded_changed, this, + &NodeParamViewItem::array_expanded_changed); + connect(body_, &NodeParamViewItemBody::input_checked_changed, this, + &NodeParamViewItem::input_checked_changed); + connect(body_, &NodeParamViewItemBody::request_edit_text_in_viewer, this, + &NodeParamViewItem::request_edit_text_in_viewer); + body_->retranslate(); + body_->set_timebase(timebase_); + body_->set_time_target(time_target_); message_container_ = new QWidget(this); QVBoxLayout *message_layout = new QVBoxLayout(message_container_); @@ -134,7 +134,7 @@ void NodeParamViewItem::RecreateBody() message_clear_button_ = new QPushButton(tr("Clear"), message_container_); message_clear_button_->setVisible(false); connect(message_clear_button_, &QPushButton::clicked, this, - &NodeParamViewItem::ClearMessages); + &NodeParamViewItem::clear_messages); message_header->addWidget(message_clear_button_); message_layout->addLayout(message_header); @@ -146,11 +146,11 @@ void NodeParamViewItem::RecreateBody() message_layout->addWidget(message_label_); message_layout->addWidget(body_); - SetBody(message_container_); - UpdateMessagePanel(); + set_body(message_container_); + update_message_panel(); } -void NodeParamViewItem::UpdateMessagePanel() +void NodeParamViewItem::update_message_panel() { if (!message_label_) { return; @@ -159,7 +159,7 @@ void NodeParamViewItem::UpdateMessagePanel() auto *instance = node_->getPluginInstance(); auto *olive_instance = dynamic_cast(instance); - if (!olive_instance || olive_instance->persistentMessageCount() == 0) { + if (!olive_instance || olive_instance->persistent_message_count() == 0) { message_label_->setVisible(false); if (message_clear_button_) { message_clear_button_->setVisible(false); @@ -168,16 +168,16 @@ void NodeParamViewItem::UpdateMessagePanel() } QStringList lines; - for (const auto &msg : olive_instance->persistentMessages()) { + for (const auto &msg : olive_instance->persistent_messages()) { QString prefix; switch (msg.type) { - case plugin::ErrorType::Error: + case plugin::ErrorType::error: prefix = QStringLiteral("Error"); break; - case plugin::ErrorType::Warning: + case plugin::ErrorType::warning: prefix = QStringLiteral("Warning"); break; - case plugin::ErrorType::Message: + case plugin::ErrorType::message: prefix = QStringLiteral("Message"); break; } @@ -191,22 +191,22 @@ void NodeParamViewItem::UpdateMessagePanel() } } -int NodeParamViewItem::GetElementY(const NodeInput &c) const +int NodeParamViewItem::get_element_y(const NodeInput &c) const { - if (IsExpanded()) { - return body_->GetElementY(c); + if (is_expanded()) { + return body_->get_element_y(c); } else { // Not expanded, put keyframes at the titlebar Y return mapToGlobal(title_bar()->rect().center()).y(); } } -void NodeParamViewItem::SetInputChecked(const NodeInput &input, bool e) +void NodeParamViewItem::set_input_checked(const NodeInput &input, bool e) { - body_->SetInputChecked(input, e); + body_->set_input_checked(input, e); } -void NodeParamViewItem::ClearMessages() +void NodeParamViewItem::clear_messages() { auto *instance = node_->getPluginInstance(); auto *olive_instance = @@ -238,14 +238,14 @@ NodeParamViewItemBody::NodeParamViewItemBody( foreach (QString input, node->inputs()) { Node *n = node; - NodeInput resolved = NodeGroup::ResolveInput(NodeInput(n, input)); + NodeInput resolved = NodeGroup::resolve_input(NodeInput(n, input)); if (!connected_signals.contains(resolved.node())) { - connect(resolved.node(), &Node::InputArraySizeChanged, this, - &NodeParamViewItemBody::InputArraySizeChanged); - connect(resolved.node(), &Node::InputConnected, this, - &NodeParamViewItemBody::EdgeChanged); - connect(resolved.node(), &Node::InputDisconnected, this, - &NodeParamViewItemBody::EdgeChanged); + connect(resolved.node(), &Node::input_array_size_changed, this, + &NodeParamViewItemBody::input_array_size_changed); + connect(resolved.node(), &Node::input_connected, this, + &NodeParamViewItemBody::edge_changed); + connect(resolved.node(), &Node::input_disconnected, this, + &NodeParamViewItemBody::edge_changed); connected_signals.append(resolved.node()); } @@ -253,11 +253,11 @@ NodeParamViewItemBody::NodeParamViewItemBody( input_group_lookup_.insert({ resolved.node(), resolved.input() }, { n, input }); - if (!(n->GetInputFlags(input) & kInputFlagHidden)) { + if (!(n->get_input_flags(input) & k_input_flag_hidden)) { QString page_label = - n->GetInputProperty(input, QStringLiteral("ui_page")).toString(); + n->get_input_property(input, QStringLiteral("ui_page")).toString(); QString group_label = - n->GetInputProperty(input, QStringLiteral("ui_group")) + n->get_input_property(input, QStringLiteral("ui_group")) .toString(); if (!page_label.isEmpty() && page_label != current_page) { QLabel *page_title = new QLabel(page_label, this); @@ -278,17 +278,17 @@ NodeParamViewItemBody::NodeParamViewItemBody( insert_row++; current_group = group_label; } - CreateWidgets(root_layout, n, input, -1, insert_row); + create_widgets(root_layout, n, input, -1, insert_row); insert_row++; - if (n->InputIsArray(input)) { + if (n->input_is_array(input)) { // Insert here QWidget *array_widget = new QWidget(this); QGridLayout *array_layout = new QGridLayout(array_widget); array_layout->setContentsMargins( - QtUtils::QFontMetricsWidth(fontMetrics(), + QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral(" ")), 0, 0, 0); @@ -300,11 +300,11 @@ NodeParamViewItemBody::NodeParamViewItemBody( // Add one last add button for appending to the array NodeParamViewArrayButton *append_btn = - new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd, + new NodeParamViewArrayButton(NodeParamViewArrayButton::k_add, this); connect(append_btn, &NodeParamViewArrayButton::clicked, this, - &NodeParamViewItemBody::ArrayAppendClicked); - array_layout->addWidget(append_btn, arr_sz, kArrayInsertColumn); + &NodeParamViewItemBody::array_append_clicked); + array_layout->addWidget(append_btn, arr_sz, k_array_insert_column); array_widget->setVisible(false); @@ -317,7 +317,7 @@ NodeParamViewItemBody::NodeParamViewItemBody( } } -void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node, +void NodeParamViewItemBody::create_widgets(QGridLayout *layout, Node *node, const QString &input, int element, int row) { @@ -333,11 +333,11 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node, if (create_checkboxes_) { ui_objects.optional_checkbox = new QCheckBox(this); connect(ui_objects.optional_checkbox, &QCheckBox::clicked, this, - &NodeParamViewItemBody::OptionalCheckBoxClicked); - layout->addWidget(ui_objects.optional_checkbox, row, kOptionalCheckBox); + &NodeParamViewItemBody::optional_check_box_clicked); + layout->addWidget(ui_objects.optional_checkbox, row, k_optional_check_box); - if (create_checkboxes_ == kCheckBoxesOnNonConnected && - input_ref.IsConnected()) { + if (create_checkboxes_ == k_check_boxes_on_non_connected && + input_ref.is_connected()) { ui_objects.optional_checkbox->setVisible(false); } } @@ -346,9 +346,9 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node, ui_objects.main_label = new QLabel(this); // Create input label - layout->addWidget(ui_objects.main_label, row, kLabelColumn); + layout->addWidget(ui_objects.main_label, row, k_label_column); - if (node->InputIsArray(input)) { + if (node->input_is_array(input)) { if (element == -1) { // Create a collapse toggle for expanding/collapsing the array CollapseButton *array_collapse_btn = new CollapseButton(this); @@ -357,32 +357,32 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node, array_collapse_btn->setChecked(false); // Add collapse button to layout - layout->addWidget(array_collapse_btn, row, kArrayCollapseBtnColumn); + layout->addWidget(array_collapse_btn, row, k_array_collapse_btn_column); // Connect signal to show/hide array params when toggled connect(array_collapse_btn, &CollapseButton::toggled, this, - &NodeParamViewItemBody::ArrayCollapseBtnPressed); + &NodeParamViewItemBody::array_collapse_btn_pressed); array_collapse_buttons_.insert({ node, input }, array_collapse_btn); } else { NodeParamViewArrayButton *insert_element_btn = - new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd, + new NodeParamViewArrayButton(NodeParamViewArrayButton::k_add, this); NodeParamViewArrayButton *remove_element_btn = - new NodeParamViewArrayButton(NodeParamViewArrayButton::kRemove, + new NodeParamViewArrayButton(NodeParamViewArrayButton::k_remove, this); - layout->addWidget(insert_element_btn, row, kArrayInsertColumn); - layout->addWidget(remove_element_btn, row, kArrayRemoveColumn); + layout->addWidget(insert_element_btn, row, k_array_insert_column); + layout->addWidget(remove_element_btn, row, k_array_remove_column); ui_objects.array_insert_btn = insert_element_btn; ui_objects.array_remove_btn = remove_element_btn; connect(insert_element_btn, &NodeParamViewArrayButton::clicked, - this, &NodeParamViewItemBody::ArrayInsertClicked); + this, &NodeParamViewItemBody::array_insert_clicked); connect(remove_element_btn, &NodeParamViewArrayButton::clicked, - this, &NodeParamViewItemBody::ArrayRemoveClicked); + this, &NodeParamViewItemBody::array_remove_clicked); } } @@ -390,80 +390,80 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node, ui_objects.widget_bridge = new NodeParamViewWidgetBridge(NodeInput(node, input, element), this); connect(ui_objects.widget_bridge, - &NodeParamViewWidgetBridge::WidgetsRecreated, this, - &NodeParamViewItemBody::ReplaceWidgets); + &NodeParamViewWidgetBridge::widgets_recreated, this, + &NodeParamViewItemBody::replace_widgets); connect(ui_objects.widget_bridge, - &NodeParamViewWidgetBridge::ArrayWidgetDoubleClicked, this, - &NodeParamViewItemBody::ToggleArrayExpanded); + &NodeParamViewWidgetBridge::array_widget_double_clicked, this, + &NodeParamViewItemBody::toggle_array_expanded); connect(ui_objects.widget_bridge, - &NodeParamViewWidgetBridge::RequestEditTextInViewer, this, - &NodeParamViewItemBody::RequestEditTextInViewer); + &NodeParamViewWidgetBridge::request_edit_text_in_viewer, this, + &NodeParamViewItemBody::request_edit_text_in_viewer); // Place widgets into layout - PlaceWidgetsFromBridge(layout, ui_objects.widget_bridge, row); + place_widgets_from_bridge(layout, ui_objects.widget_bridge, row); // In case this input is a group, resolve that actual input to use for connected labels - NodeInput resolved = NodeGroup::ResolveInput(input_ref); + NodeInput resolved = NodeGroup::resolve_input(input_ref); - if (node->IsInputConnectable(input)) { + if (node->is_input_connectable(input)) { // Create clickable label used when an input is connected ui_objects.connected_label = new NodeParamViewConnectedLabel(resolved, this); connect(ui_objects.connected_label, - &NodeParamViewConnectedLabel::RequestSelectNode, this, - &NodeParamViewItemBody::RequestSelectNode); - layout->addWidget(ui_objects.connected_label, row, kWidgetStartColumn, - 1, kKeyControlColumn - kWidgetStartColumn); + &NodeParamViewConnectedLabel::request_select_node, this, + &NodeParamViewItemBody::request_select_node); + layout->addWidget(ui_objects.connected_label, row, k_widget_start_column, + 1, k_key_control_column - k_widget_start_column); } // Add keyframe control to this layout if parameter is keyframable - if (node->IsInputKeyframable(input)) { + if (node->is_input_keyframable(input)) { ui_objects.key_control = new NodeParamViewKeyframeControl(this); - ui_objects.key_control->SetInput(resolved); - layout->addWidget(ui_objects.key_control, row, kKeyControlColumn); + ui_objects.key_control->set_input(resolved); + layout->addWidget(ui_objects.key_control, row, k_key_control_column); } input_ui_map_.insert(input_ref, ui_objects); - if (node->IsInputConnectable(input)) { - UpdateUIForEdgeConnection(input_ref); + if (node->is_input_connectable(input)) { + update_ui_for_edge_connection(input_ref); } - SetTimeTargetOnInputUI(ui_objects); - SetTimebaseOnInputUI(ui_objects); + set_time_target_on_input_ui(ui_objects); + set_timebase_on_input_ui(ui_objects); } -void NodeParamViewItemBody::SetTimeTarget(ViewerOutput *target) +void NodeParamViewItemBody::set_time_target(ViewerOutput *target) { time_target_ = target; foreach (const InputUI &ui_obj, input_ui_map_) { - SetTimeTargetOnInputUI(ui_obj); + set_time_target_on_input_ui(ui_obj); } } -void NodeParamViewItemBody::SetTimeTargetOnInputUI(const InputUI &ui_obj) +void NodeParamViewItemBody::set_time_target_on_input_ui(const InputUI &ui_obj) { // Only keyframable inputs have a key control widget if (ui_obj.key_control) { - ui_obj.key_control->SetTimeTarget(time_target_); + ui_obj.key_control->set_time_target(time_target_); } if (ui_obj.connected_label) { - ui_obj.connected_label->SetViewerNode(time_target_); + ui_obj.connected_label->set_viewer_node(time_target_); } - ui_obj.widget_bridge->SetTimeTarget(time_target_); + ui_obj.widget_bridge->set_time_target(time_target_); } -void NodeParamViewItemBody::Retranslate() +void NodeParamViewItemBody::retranslate() { for (auto i = input_ui_map_.begin(); i != input_ui_map_.end(); i++) { const NodeInput &ic = i.key(); - if (ic.IsArray() && ic.element() >= 0) { + if (ic.is_array() && ic.element() >= 0) { // Make the label the array index i.value().main_label->setText(tr("%1:").arg( ic.element() + - ic.GetProperty(QStringLiteral("arraystart")).toInt())); + ic.get_property(QStringLiteral("arraystart")).toInt())); } else { // Set to the input's name i.value().main_label->setText(tr("%1:").arg(ic.name())); @@ -471,9 +471,9 @@ void NodeParamViewItemBody::Retranslate() } } -int NodeParamViewItemBody::GetElementY(NodeInput c) const +int NodeParamViewItemBody::get_element_y(NodeInput c) const { - if (c.IsArray() && !array_ui_.value(c.input_pair()).widget->isVisible()) { + if (c.is_array() && !array_ui_.value(c.input_pair()).widget->isVisible()) { // Array is collapsed, so we'll return the Y of its root c.set_element(-1); } @@ -493,7 +493,7 @@ int NodeParamViewItemBody::GetElementY(NodeInput c) const return lbl_center.y(); } -void NodeParamViewItemBody::EdgeChanged(Node *output, const NodeInput &input) +void NodeParamViewItemBody::edge_changed(Node *output, const NodeInput &input) { Q_UNUSED(output) @@ -501,16 +501,16 @@ void NodeParamViewItemBody::EdgeChanged(Node *output, const NodeInput &input) input_group_lookup_.value({ input.node(), input.input() }); NodeInput resolved(pair.node, pair.input, input.element()); - UpdateUIForEdgeConnection(resolved); + update_ui_for_edge_connection(resolved); } -void NodeParamViewItemBody::UpdateUIForEdgeConnection(const NodeInput &input) +void NodeParamViewItemBody::update_ui_for_edge_connection(const NodeInput &input) { // Show/hide bridge widgets if (input_ui_map_.contains(input)) { const InputUI &ui_objects = input_ui_map_[input]; - bool is_connected = NodeGroup::ResolveInput(input).IsConnected(); + bool is_connected = NodeGroup::resolve_input(input).is_connected(); foreach (QWidget *w, ui_objects.widget_bridge->widgets()) { w->setVisible(!is_connected); @@ -524,25 +524,25 @@ void NodeParamViewItemBody::UpdateUIForEdgeConnection(const NodeInput &input) } // Show/hide optional checkbox if requested - if (create_checkboxes_ == kCheckBoxesOnNonConnected) { + if (create_checkboxes_ == k_check_boxes_on_non_connected) { ui_objects.optional_checkbox->setVisible(!is_connected); } } } -void NodeParamViewItemBody::PlaceWidgetsFromBridge( +void NodeParamViewItemBody::place_widgets_from_bridge( QGridLayout *layout, NodeParamViewWidgetBridge *bridge, int row) { // Add widgets for this parameter to the layout for (int i = 0; i < bridge->widgets().size(); i++) { QWidget *w = bridge->widgets().at(i); - int col = i + kWidgetStartColumn; + int col = i + k_widget_start_column; int colspan; if (i == bridge->widgets().size() - 1) { // Span this widget among remaining columns - colspan = kMaxWidgetColumn - col; + colspan = k_max_widget_column - col; } else { colspan = 1; } @@ -551,7 +551,7 @@ void NodeParamViewItemBody::PlaceWidgetsFromBridge( } } -void NodeParamViewItemBody::InputArraySizeChangedInternal(Node *node, +void NodeParamViewItemBody::input_array_size_changed_internal(Node *node, const QString &input, int size) { @@ -569,10 +569,10 @@ void NodeParamViewItemBody::InputArraySizeChangedInternal(Node *node, if (array_ui.count < size) { // Our UI count is smaller than the size, create more - grid->addWidget(array_ui.append_btn, size, kArrayInsertColumn); + grid->addWidget(array_ui.append_btn, size, k_array_insert_column); for (int i = array_ui.count; i < size; i++) { - CreateWidgets(grid, node, input, i, i); + create_widgets(grid, node, input, i, i); } } else { for (int i = array_ui.count - 1; i >= size; i--) { @@ -587,16 +587,16 @@ void NodeParamViewItemBody::InputArraySizeChangedInternal(Node *node, delete input_ui.array_remove_btn; } - grid->addWidget(array_ui.append_btn, size, kArrayInsertColumn); + grid->addWidget(array_ui.append_btn, size, k_array_insert_column); } array_ui.count = size; - Retranslate(); + retranslate(); } } -void NodeParamViewItemBody::ArrayCollapseBtnPressed(bool checked) +void NodeParamViewItemBody::array_collapse_btn_pressed(bool checked) { const NodeInputPair &input = array_collapse_buttons_.key(static_cast(sender())); @@ -605,15 +605,15 @@ void NodeParamViewItemBody::ArrayCollapseBtnPressed(bool checked) if (checked) { // Ensure widgets are created (the signal will be ignored if they are) NodeInput resolved = - NodeGroup::ResolveInput(NodeInput(input.node, input.input)); - InputArraySizeChangedInternal(input.node, input.input, - resolved.GetArraySize()); + NodeGroup::resolve_input(NodeInput(input.node, input.input)); + input_array_size_changed_internal(input.node, input.input, + resolved.get_array_size()); } - emit ArrayExpandedChanged(checked); + emit array_expanded_changed(checked); } -void NodeParamViewItemBody::InputArraySizeChanged(const QString &input, +void NodeParamViewItemBody::input_array_size_changed(const QString &input, int old_sz, int size) { Q_UNUSED(old_sz) @@ -621,58 +621,58 @@ void NodeParamViewItemBody::InputArraySizeChanged(const QString &input, NodeInputPair nip = input_group_lookup_.value({ static_cast(sender()), input }); - InputArraySizeChangedInternal(nip.node, nip.input, size); + input_array_size_changed_internal(nip.node, nip.input, size); } -void NodeParamViewItemBody::ArrayAppendClicked() +void NodeParamViewItemBody::array_append_clicked() { for (auto it = array_ui_.cbegin(); it != array_ui_.cend(); it++) { if (it.value().append_btn == sender()) { - NodeInput real_input = NodeGroup::ResolveInput( + NodeInput real_input = NodeGroup::resolve_input( NodeInput(it.key().node, it.key().input)); Core::instance()->undo_stack()->push( new NodeArrayInsertCommand(real_input.node(), real_input.input(), - real_input.GetArraySize()), + real_input.get_array_size()), tr("Appended Array Element In %1 - %2") - .arg(real_input.node()->GetLabelAndName(), - real_input.GetInputName())); + .arg(real_input.node()->get_label_and_name(), + real_input.get_input_name())); break; } } } -void NodeParamViewItemBody::ArrayInsertClicked() +void NodeParamViewItemBody::array_insert_clicked() { for (auto it = input_ui_map_.cbegin(); it != input_ui_map_.cend(); it++) { if (it.value().array_insert_btn == sender()) { // Found our input and element - NodeInput ic = NodeGroup::ResolveInput(it.key()); + NodeInput ic = NodeGroup::resolve_input(it.key()); Core::instance()->undo_stack()->push( new NodeArrayInsertCommand(ic.node(), ic.input(), ic.element()), tr("Inserted Array Element In %1 - %2") - .arg(ic.node()->GetLabelAndName(), ic.GetInputName())); + .arg(ic.node()->get_label_and_name(), ic.get_input_name())); break; } } } -void NodeParamViewItemBody::ArrayRemoveClicked() +void NodeParamViewItemBody::array_remove_clicked() { for (auto it = input_ui_map_.cbegin(); it != input_ui_map_.cend(); it++) { if (it.value().array_remove_btn == sender()) { // Found our input and element - NodeInput ic = NodeGroup::ResolveInput(it.key()); + NodeInput ic = NodeGroup::resolve_input(it.key()); Core::instance()->undo_stack()->push( new NodeArrayRemoveCommand(ic.node(), ic.input(), ic.element()), tr("Removed Array Element In %1 - %2") - .arg(ic.node()->GetLabelAndName(), ic.GetInputName())); + .arg(ic.node()->get_label_and_name(), ic.get_input_name())); break; } } } -void NodeParamViewItemBody::ToggleArrayExpanded() +void NodeParamViewItemBody::toggle_array_expanded() { NodeParamViewWidgetBridge *bridge = static_cast(sender()); @@ -687,21 +687,21 @@ void NodeParamViewItemBody::ToggleArrayExpanded() } } -void NodeParamViewItemBody::SetTimebase(const rational &timebase) +void NodeParamViewItemBody::set_timebase(const Rational &timebase) { timebase_ = timebase; foreach (const InputUI &ui_obj, input_ui_map_) { - SetTimebaseOnInputUI(ui_obj); + set_timebase_on_input_ui(ui_obj); } } -void NodeParamViewItemBody::SetTimebaseOnInputUI(const InputUI &ui_obj) +void NodeParamViewItemBody::set_timebase_on_input_ui(const InputUI &ui_obj) { - ui_obj.widget_bridge->SetTimebase(timebase_); + ui_obj.widget_bridge->set_timebase(timebase_); } -void NodeParamViewItemBody::SetInputChecked(const NodeInput &input, bool e) +void NodeParamViewItemBody::set_input_checked(const NodeInput &input, bool e) { if (input_ui_map_.contains(input)) { QCheckBox *cb = input_ui_map_.value(input).optional_checkbox; @@ -711,13 +711,13 @@ void NodeParamViewItemBody::SetInputChecked(const NodeInput &input, bool e) } } -void NodeParamViewItemBody::ReplaceWidgets(const NodeInput &input) +void NodeParamViewItemBody::replace_widgets(const NodeInput &input) { InputUI ui = input_ui_map_.value(input); - PlaceWidgetsFromBridge(ui.layout, ui.widget_bridge, ui.row); + place_widgets_from_bridge(ui.layout, ui.widget_bridge, ui.row); } -void NodeParamViewItemBody::ShowSpeedDurationDialogForNode() +void NodeParamViewItemBody::show_speed_duration_dialog_for_node() { // We should only get there if the node is a clip, determined by the dynamic_cast in CreateWidgets SpeedDurationDialog sdd({ static_cast(node_) }, timebase_, @@ -725,13 +725,13 @@ void NodeParamViewItemBody::ShowSpeedDurationDialogForNode() sdd.exec(); } -void NodeParamViewItemBody::OptionalCheckBoxClicked(bool e) +void NodeParamViewItemBody::optional_check_box_clicked(bool e) { QCheckBox *cb = static_cast(sender()); for (auto it = input_ui_map_.cbegin(); it != input_ui_map_.cend(); it++) { if (it.value().optional_checkbox == cb) { - emit InputCheckedChanged(it.key(), e); + emit input_checked_changed(it.key(), e); break; } } diff --git a/app/widget/nodeparamview/nodeparamviewitem.h b/app/widget/nodeparamview/nodeparamviewitem.h index 8e2beabba..03da38be2 100644 --- a/app/widget/nodeparamview/nodeparamviewitem.h +++ b/app/widget/nodeparamview/nodeparamviewitem.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWITEM_H -#define NODEPARAMVIEWITEM_H +#ifndef OAK_NODEPARAMVIEWITEM_H +#define OAK_NODEPARAMVIEWITEM_H #include #include @@ -43,9 +43,9 @@ namespace olive { enum NodeParamViewCheckBoxBehavior { - kNoCheckBoxes, - kCheckBoxesOn, - kCheckBoxesOnNonConnected + k_no_check_boxes, + k_check_boxes_on, + k_check_boxes_on_non_connected }; class NodeParamViewItemBody : public QWidget { @@ -55,36 +55,36 @@ public: NodeParamViewCheckBoxBehavior create_checkboxes, QWidget *parent = nullptr); - void SetTimeTarget(ViewerOutput *target); + void set_time_target(ViewerOutput *target); - void Retranslate(); + void retranslate(); - int GetElementY(NodeInput c) const; + int get_element_y(NodeInput c) const; // Set the timebase of any timebased widgets contained here - void SetTimebase(const rational &timebase); + void set_timebase(const Rational &timebase); - void SetInputChecked(const NodeInput &input, bool e); + void set_input_checked(const NodeInput &input, bool e); signals: - void RequestSelectNode(Node *node); + void request_select_node(Node *node); - void ArrayExpandedChanged(bool e); + void array_expanded_changed(bool e); - void InputCheckedChanged(const NodeInput &input, bool e); + void input_checked_changed(const NodeInput &input, bool e); - void RequestEditTextInViewer(); + void request_edit_text_in_viewer(); private: - void CreateWidgets(QGridLayout *layout, Node *node, const QString &input, + void create_widgets(QGridLayout *layout, Node *node, const QString &input, int element, int row_index); - void UpdateUIForEdgeConnection(const NodeInput &input); + void update_ui_for_edge_connection(const NodeInput &input); - void PlaceWidgetsFromBridge(QGridLayout *layout, + void place_widgets_from_bridge(QGridLayout *layout, NodeParamViewWidgetBridge *bridge, int row); - void InputArraySizeChangedInternal(Node *node, const QString &input, + void input_array_size_changed_internal(Node *node, const QString &input, int size); struct InputUI { @@ -111,8 +111,8 @@ private: NodeParamViewArrayButton *append_btn; }; - void SetTimeTargetOnInputUI(const InputUI &ui); - void SetTimebaseOnInputUI(const InputUI &ui); + void set_time_target_on_input_ui(const InputUI &ui); + void set_timebase_on_input_ui(const InputUI &ui); Node *node_; @@ -120,7 +120,7 @@ private: QHash array_collapse_buttons_; - rational timebase_; + Rational timebase_; ViewerOutput *time_target_; @@ -134,38 +134,38 @@ private: * Serves as an effective "maximum column" index because the keyframe button is always aligned * to the right edge. */ - static const int kKeyControlColumn; + static const int k_key_control_column; - static const int kArrayInsertColumn; - static const int kArrayRemoveColumn; - static const int kExtraButtonColumn; + static const int k_array_insert_column; + static const int k_array_remove_column; + static const int k_extra_button_column; - static const int kOptionalCheckBox; - static const int kArrayCollapseBtnColumn; - static const int kLabelColumn; - static const int kWidgetStartColumn; - static const int kMaxWidgetColumn; + static const int k_optional_check_box; + static const int k_array_collapse_btn_column; + static const int k_label_column; + static const int k_widget_start_column; + static const int k_max_widget_column; private slots: - void EdgeChanged(Node *output, const NodeInput &input); + void edge_changed(Node *output, const NodeInput &input); - void ArrayCollapseBtnPressed(bool checked); + void array_collapse_btn_pressed(bool checked); - void InputArraySizeChanged(const QString &input, int old_sz, int size); + void input_array_size_changed(const QString &input, int old_sz, int size); - void ArrayAppendClicked(); + void array_append_clicked(); - void ArrayInsertClicked(); + void array_insert_clicked(); - void ArrayRemoveClicked(); + void array_remove_clicked(); - void ToggleArrayExpanded(); + void toggle_array_expanded(); - void ReplaceWidgets(const NodeInput &input); + void replace_widgets(const NodeInput &input); - void ShowSpeedDurationDialogForNode(); + void show_speed_duration_dialog_for_node(); - void OptionalCheckBoxClicked(bool e); + void optional_check_box_clicked(bool e); }; class NodeParamViewItem : public NodeParamViewItemBase { @@ -175,63 +175,63 @@ public: NodeParamViewCheckBoxBehavior create_checkboxes, QWidget *parent = nullptr); - void SetTimeTarget(ViewerOutput *target) + void set_time_target(ViewerOutput *target) { time_target_ = target; - body_->SetTimeTarget(target); + body_->set_time_target(target); } - void SetTimebase(const rational &timebase) + void set_timebase(const Rational &timebase) { timebase_ = timebase; - body_->SetTimebase(timebase); + body_->set_timebase(timebase); } - Node *GetContext() const + Node *get_context() const { return ctx_; } - void SetContext(Node *ctx) + void set_context(Node *ctx) { ctx_ = ctx; } - Node *GetNode() const + Node *get_node() const { return node_; } - int GetElementY(const NodeInput &c) const; + int get_element_y(const NodeInput &c) const; - void SetInputChecked(const NodeInput &input, bool e); + void set_input_checked(const NodeInput &input, bool e); - KeyframeView::NodeConnections &GetKeyframeConnections() + KeyframeView::NodeConnections &get_keyframe_connections() { return keyframe_connections_; } - void SetKeyframeConnections(const KeyframeView::NodeConnections &c) + void set_keyframe_connections(const KeyframeView::NodeConnections &c) { keyframe_connections_ = c; } signals: - void RequestSelectNode(Node *node); + void request_select_node(Node *node); - void ArrayExpandedChanged(bool e); + void array_expanded_changed(bool e); - void InputCheckedChanged(const NodeInput &input, bool e); + void input_checked_changed(const NodeInput &input, bool e); - void RequestEditTextInViewer(); + void request_edit_text_in_viewer(); - void InputArraySizeChanged(const QString &input, int old_size, + void input_array_size_changed(const QString &input, int old_size, int new_size); protected slots: - virtual void Retranslate() override; + virtual void retranslate() override; private: NodeParamViewItemBody *body_; @@ -247,16 +247,16 @@ private: ViewerOutput *time_target_; - rational timebase_; + Rational timebase_; KeyframeView::NodeConnections keyframe_connections_; private slots: - void RecreateBody(); - void UpdateMessagePanel(); - void ClearMessages(); + void recreate_body(); + void update_message_panel(); + void clear_messages(); }; } -#endif // NODEPARAMVIEWITEM_H +#endif // OAK_NODEPARAMVIEWITEM_H diff --git a/app/widget/nodeparamview/nodeparamviewitembase.cpp b/app/widget/nodeparamview/nodeparamviewitembase.cpp index b3ed57434..13445890d 100644 --- a/app/widget/nodeparamview/nodeparamviewitembase.cpp +++ b/app/widget/nodeparamview/nodeparamviewitembase.cpp @@ -40,12 +40,12 @@ NodeParamViewItemBase::NodeParamViewItemBase(QWidget *parent) this->setTitleBarWidget(title_bar_); // Connect title bar to this - connect(title_bar_, &NodeParamViewItemTitleBar::ExpandedStateChanged, this, - &NodeParamViewItemBase::SetExpanded); - connect(title_bar_, &NodeParamViewItemTitleBar::PinToggled, this, - &NodeParamViewItemBase::PinToggled); - connect(title_bar_, &NodeParamViewItemTitleBar::Clicked, this, - &NodeParamViewItemBase::Clicked); + connect(title_bar_, &NodeParamViewItemTitleBar::expanded_state_changed, this, + &NodeParamViewItemBase::set_expanded); + connect(title_bar_, &NodeParamViewItemTitleBar::pin_toggled, this, + &NodeParamViewItemBase::pin_toggled); + connect(title_bar_, &NodeParamViewItemTitleBar::clicked, this, + &NodeParamViewItemBase::clicked); // Use dummy QWidget to retain width when not expanded (QDockWidget seems to ignore the titlebar // size hints and will shrink as small as possible if the body is hidden) @@ -60,26 +60,26 @@ NodeParamViewItemBase::NodeParamViewItemBase(QWidget *parent) setFocusPolicy(Qt::ClickFocus); } -bool NodeParamViewItemBase::IsExpanded() const +bool NodeParamViewItemBase::is_expanded() const { - return title_bar_->IsExpanded(); + return title_bar_->is_expanded(); } -QString NodeParamViewItemBase::GetTitleBarTextFromNode(Node *n) +QString NodeParamViewItemBase::get_title_bar_text_from_node(Node *n) { - if (n->GetLabel().isEmpty()) { - return n->Name(); + if (n->get_label().isEmpty()) { + return n->name(); } else { - return tr("%1 (%2)").arg(n->GetLabel(), n->Name()); + return tr("%1 (%2)").arg(n->get_label(), n->name()); } } -void NodeParamViewItemBase::SetBody(QWidget *body) +void NodeParamViewItemBase::set_body(QWidget *body) { body_ = body; body_->setParent(this); - if (title_bar_->IsExpanded()) { + if (title_bar_->is_expanded()) { setWidget(body_); } } @@ -97,18 +97,18 @@ void NodeParamViewItemBase::paintEvent(QPaintEvent *event) } } -void NodeParamViewItemBase::SetExpanded(bool e) +void NodeParamViewItemBase::set_expanded(bool e) { setWidget(e ? body_ : hidden_body_); - title_bar_->SetExpanded(e); + title_bar_->set_expanded(e); - emit ExpandedChanged(e); + emit expanded_changed(e); } void NodeParamViewItemBase::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } super::changeEvent(e); @@ -118,14 +118,14 @@ void NodeParamViewItemBase::moveEvent(QMoveEvent *event) { super::moveEvent(event); - emit Moved(); + emit moved(); } void NodeParamViewItemBase::mousePressEvent(QMouseEvent *e) { super::mousePressEvent(e); - emit Clicked(); + emit clicked(); } } diff --git a/app/widget/nodeparamview/nodeparamviewitembase.h b/app/widget/nodeparamview/nodeparamviewitembase.h index fd137b7e1..1504dfc4f 100644 --- a/app/widget/nodeparamview/nodeparamviewitembase.h +++ b/app/widget/nodeparamview/nodeparamviewitembase.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWITEMBASE_H -#define NODEPARAMVIEWITEMBASE_H +#ifndef OAK_NODEPARAMVIEWITEMBASE_H +#define OAK_NODEPARAMVIEWITEMBASE_H #include @@ -35,41 +35,41 @@ class NodeParamViewItemBase : public QDockWidget { public: NodeParamViewItemBase(QWidget *parent = nullptr); - void SetHighlighted(bool e) + void set_highlighted(bool e) { highlighted_ = e; update(); } - bool IsHighlighted() const + bool is_highlighted() const { return highlighted_; } - bool IsExpanded() const; + bool is_expanded() const; - static QString GetTitleBarTextFromNode(Node *n); + static QString get_title_bar_text_from_node(Node *n); public slots: - void SetExpanded(bool e); + void set_expanded(bool e); - void ToggleExpanded() + void toggle_expanded() { - SetExpanded(!IsExpanded()); + set_expanded(!is_expanded()); } signals: - void PinToggled(bool e); + void pin_toggled(bool e); - void ExpandedChanged(bool e); + void expanded_changed(bool e); - void Moved(); + void moved(); - void Clicked(); + void clicked(); protected: - void SetBody(QWidget *body); + void set_body(QWidget *body); virtual void paintEvent(QPaintEvent *event) override; @@ -85,7 +85,7 @@ protected: virtual void mousePressEvent(QMouseEvent *e) override; protected slots: - virtual void Retranslate() + virtual void retranslate() { } @@ -101,4 +101,4 @@ private: } -#endif // NODEPARAMVIEWITEMBASE_H +#endif // OAK_NODEPARAMVIEWITEMBASE_H diff --git a/app/widget/nodeparamview/nodeparamviewitemtitlebar.cpp b/app/widget/nodeparamview/nodeparamviewitemtitlebar.cpp index 03ce287df..d9b40108d 100644 --- a/app/widget/nodeparamview/nodeparamviewitemtitlebar.cpp +++ b/app/widget/nodeparamview/nodeparamviewitemtitlebar.cpp @@ -37,7 +37,7 @@ NodeParamViewItemTitleBar::NodeParamViewItemTitleBar(QWidget *parent) collapse_btn_ = new CollapseButton(this); connect(collapse_btn_, &QPushButton::clicked, this, - &NodeParamViewItemTitleBar::ExpandedStateChanged); + &NodeParamViewItemTitleBar::expanded_state_changed); layout->addWidget(collapse_btn_); lbl_ = new QLabel(this); @@ -47,13 +47,13 @@ NodeParamViewItemTitleBar::NodeParamViewItemTitleBar(QWidget *parent) layout->addStretch(); add_fx_btn_ = new QPushButton(this); - add_fx_btn_->setIcon(icon::AddEffect); + add_fx_btn_->setIcon(icon::add_effect); add_fx_btn_->setFixedSize(add_fx_btn_->sizeHint().height(), add_fx_btn_->sizeHint().height()); add_fx_btn_->setVisible(false); layout->addWidget(add_fx_btn_); connect(add_fx_btn_, &QPushButton::clicked, this, - &NodeParamViewItemTitleBar::AddEffectButtonClicked); + &NodeParamViewItemTitleBar::add_effect_button_clicked); pin_btn_ = new QPushButton(QStringLiteral("P"), this); pin_btn_->setCheckable(true); @@ -62,16 +62,16 @@ NodeParamViewItemTitleBar::NodeParamViewItemTitleBar(QWidget *parent) pin_btn_->setVisible(false); layout->addWidget(pin_btn_); connect(pin_btn_, &QPushButton::clicked, this, - &NodeParamViewItemTitleBar::PinToggled); + &NodeParamViewItemTitleBar::pin_toggled); enabled_checkbox_ = new QCheckBox(this); enabled_checkbox_->setVisible(false); layout->addWidget(enabled_checkbox_); connect(enabled_checkbox_, &QCheckBox::clicked, this, - &NodeParamViewItemTitleBar::EnabledCheckBoxClicked); + &NodeParamViewItemTitleBar::enabled_check_box_clicked); } -void NodeParamViewItemTitleBar::SetExpanded(bool e) +void NodeParamViewItemTitleBar::set_expanded(bool e) { draw_border_ = e; collapse_btn_->setChecked(e); @@ -97,7 +97,7 @@ void NodeParamViewItemTitleBar::mousePressEvent(QMouseEvent *event) { QWidget::mousePressEvent(event); - emit Clicked(); + emit clicked(); } void NodeParamViewItemTitleBar::mouseDoubleClickEvent(QMouseEvent *event) diff --git a/app/widget/nodeparamview/nodeparamviewitemtitlebar.h b/app/widget/nodeparamview/nodeparamviewitemtitlebar.h index 11334d369..87086701a 100644 --- a/app/widget/nodeparamview/nodeparamviewitemtitlebar.h +++ b/app/widget/nodeparamview/nodeparamviewitemtitlebar.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWITEMTITLEBAR_H -#define NODEPARAMVIEWITEMTITLEBAR_H +#ifndef OAK_NODEPARAMVIEWITEMTITLEBAR_H +#define OAK_NODEPARAMVIEWITEMTITLEBAR_H #include #include @@ -36,51 +36,51 @@ class NodeParamViewItemTitleBar : public QWidget { public: NodeParamViewItemTitleBar(QWidget *parent = nullptr); - bool IsExpanded() const + bool is_expanded() const { return collapse_btn_->isChecked(); } public slots: - void SetExpanded(bool e); + void set_expanded(bool e); - void SetText(const QString &s) + void set_text(const QString &s) { lbl_->setText(s); lbl_->setToolTip(s); lbl_->setMinimumWidth(1); } - void SetPinButtonVisible(bool e) + void set_pin_button_visible(bool e) { pin_btn_->setVisible(e); } - void SetAddEffectButtonVisible(bool e) + void set_add_effect_button_visible(bool e) { add_fx_btn_->setVisible(e); } - void SetEnabledCheckBoxVisible(bool e) + void set_enabled_check_box_visible(bool e) { enabled_checkbox_->setVisible(e); } - void SetEnabledCheckBoxChecked(bool e) + void set_enabled_check_box_checked(bool e) { enabled_checkbox_->setChecked(e); } signals: - void ExpandedStateChanged(bool e); + void expanded_state_changed(bool e); - void PinToggled(bool e); + void pin_toggled(bool e); - void AddEffectButtonClicked(); + void add_effect_button_clicked(); - void EnabledCheckBoxClicked(bool e); + void enabled_check_box_clicked(bool e); - void Clicked(); + void clicked(); protected: virtual void paintEvent(QPaintEvent *event) override; @@ -104,4 +104,4 @@ private: } -#endif // NODEPARAMVIEWITEMTITLEBAR_H +#endif // OAK_NODEPARAMVIEWITEMTITLEBAR_H diff --git a/app/widget/nodeparamview/nodeparamviewkeyframecontrol.cpp b/app/widget/nodeparamview/nodeparamviewkeyframecontrol.cpp index f66ae4a8b..415bd8524 100644 --- a/app/widget/nodeparamview/nodeparamviewkeyframecontrol.cpp +++ b/app/widget/nodeparamview/nodeparamviewkeyframecontrol.cpp @@ -44,89 +44,89 @@ NodeParamViewKeyframeControl::NodeParamViewKeyframeControl(bool right_align, layout->addStretch(); } - prev_key_btn_ = CreateNewToolButton(icon::TriLeft); + prev_key_btn_ = create_new_tool_button(icon::tri_left); prev_key_btn_->setIconSize(prev_key_btn_->iconSize() / 2); layout->addWidget(prev_key_btn_); - toggle_key_btn_ = CreateNewToolButton(icon::Diamond); + toggle_key_btn_ = create_new_tool_button(icon::diamond); toggle_key_btn_->setCheckable(true); toggle_key_btn_->setIconSize(toggle_key_btn_->iconSize() / 2); layout->addWidget(toggle_key_btn_); - next_key_btn_ = CreateNewToolButton(icon::TriRight); + next_key_btn_ = create_new_tool_button(icon::tri_right); next_key_btn_->setIconSize(next_key_btn_->iconSize() / 2); layout->addWidget(next_key_btn_); - enable_key_btn_ = CreateNewToolButton(icon::Clock); + enable_key_btn_ = create_new_tool_button(icon::clock); enable_key_btn_->setCheckable(true); enable_key_btn_->setIconSize(enable_key_btn_->iconSize() / 4 * 3); layout->addWidget(enable_key_btn_); connect(prev_key_btn_, &QPushButton::clicked, this, - &NodeParamViewKeyframeControl::GoToPreviousKey); + &NodeParamViewKeyframeControl::go_to_previous_key); connect(next_key_btn_, &QPushButton::clicked, this, - &NodeParamViewKeyframeControl::GoToNextKey); + &NodeParamViewKeyframeControl::go_to_next_key); connect(toggle_key_btn_, &QPushButton::clicked, this, - &NodeParamViewKeyframeControl::ToggleKeyframe); + &NodeParamViewKeyframeControl::toggle_keyframe); connect(enable_key_btn_, &QPushButton::toggled, this, - &NodeParamViewKeyframeControl::ShowButtonsFromKeyframeEnable); + &NodeParamViewKeyframeControl::show_buttons_from_keyframe_enable); connect(enable_key_btn_, &QPushButton::clicked, this, - &NodeParamViewKeyframeControl::KeyframeEnableBtnClicked); + &NodeParamViewKeyframeControl::keyframe_enable_btn_clicked); // Set defaults - SetInput(NodeInput()); - ShowButtonsFromKeyframeEnable(false); + set_input(NodeInput()); + show_buttons_from_keyframe_enable(false); } -void NodeParamViewKeyframeControl::SetInput(const NodeInput &input) +void NodeParamViewKeyframeControl::set_input(const NodeInput &input) { - if (input_.IsValid()) { - disconnect(input_.node(), &Node::KeyframeEnableChanged, this, - &NodeParamViewKeyframeControl::KeyframeEnableChanged); - disconnect(input_.node(), &Node::KeyframeAdded, this, - &NodeParamViewKeyframeControl::UpdateState); - disconnect(input_.node(), &Node::KeyframeRemoved, this, - &NodeParamViewKeyframeControl::UpdateState); - disconnect(input_.node(), &Node::KeyframeTimeChanged, this, - &NodeParamViewKeyframeControl::UpdateState); + if (input_.is_valid()) { + disconnect(input_.node(), &Node::keyframe_enable_changed, this, + &NodeParamViewKeyframeControl::keyframe_enable_changed); + disconnect(input_.node(), &Node::keyframe_added, this, + &NodeParamViewKeyframeControl::update_state); + disconnect(input_.node(), &Node::keyframe_removed, this, + &NodeParamViewKeyframeControl::update_state); + disconnect(input_.node(), &Node::keyframe_time_changed, this, + &NodeParamViewKeyframeControl::update_state); } input_ = input; - SetButtonsEnabled(input_.IsValid()); + set_buttons_enabled(input_.is_valid()); // Pick up keyframing value - enable_key_btn_->setChecked(input_.IsValid() && input_.IsKeyframing()); + enable_key_btn_->setChecked(input_.is_valid() && input_.is_keyframing()); // Update buttons - UpdateState(); + update_state(); - if (input_.IsValid()) { - connect(input_.node(), &Node::KeyframeEnableChanged, this, - &NodeParamViewKeyframeControl::KeyframeEnableChanged); - connect(input_.node(), &Node::KeyframeAdded, this, - &NodeParamViewKeyframeControl::UpdateState); - connect(input_.node(), &Node::KeyframeRemoved, this, - &NodeParamViewKeyframeControl::UpdateState); - connect(input_.node(), &Node::KeyframeTimeChanged, this, - &NodeParamViewKeyframeControl::UpdateState); + if (input_.is_valid()) { + connect(input_.node(), &Node::keyframe_enable_changed, this, + &NodeParamViewKeyframeControl::keyframe_enable_changed); + connect(input_.node(), &Node::keyframe_added, this, + &NodeParamViewKeyframeControl::update_state); + connect(input_.node(), &Node::keyframe_removed, this, + &NodeParamViewKeyframeControl::update_state); + connect(input_.node(), &Node::keyframe_time_changed, this, + &NodeParamViewKeyframeControl::update_state); } } void NodeParamViewKeyframeControl::TimeTargetDisconnectEvent(ViewerOutput *v) { - disconnect(v, &ViewerOutput::PlayheadChanged, this, - &NodeParamViewKeyframeControl::UpdateState); + disconnect(v, &ViewerOutput::playhead_changed, this, + &NodeParamViewKeyframeControl::update_state); } void NodeParamViewKeyframeControl::TimeTargetConnectEvent(ViewerOutput *v) { - connect(v, &ViewerOutput::PlayheadChanged, this, - &NodeParamViewKeyframeControl::UpdateState); - UpdateState(); + connect(v, &ViewerOutput::playhead_changed, this, + &NodeParamViewKeyframeControl::update_state); + update_state(); } QPushButton * -NodeParamViewKeyframeControl::CreateNewToolButton(const QIcon &icon) const +NodeParamViewKeyframeControl::create_new_tool_button(const QIcon &icon) const { QPushButton *btn = new QPushButton(); btn->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); @@ -135,7 +135,7 @@ NodeParamViewKeyframeControl::CreateNewToolButton(const QIcon &icon) const return btn; } -void NodeParamViewKeyframeControl::SetButtonsEnabled(bool e) +void NodeParamViewKeyframeControl::set_buttons_enabled(bool e) { prev_key_btn_->setEnabled(e); toggle_key_btn_->setEnabled(e); @@ -143,45 +143,45 @@ void NodeParamViewKeyframeControl::SetButtonsEnabled(bool e) enable_key_btn_->setEnabled(e); } -rational NodeParamViewKeyframeControl::GetCurrentTimeAsNodeTime() const +Rational NodeParamViewKeyframeControl::get_current_time_as_node_time() const { - return GetAdjustedTime(GetTimeTarget(), input_.node(), - GetTimeTarget()->GetPlayhead(), - Node::kTransformTowardsInput); + return get_adjusted_time(get_time_target(), input_.node(), + get_time_target()->get_playhead(), + Node::k_transform_towards_input); } -rational -NodeParamViewKeyframeControl::ConvertToViewerTime(const rational &r) const +Rational +NodeParamViewKeyframeControl::convert_to_viewer_time(const Rational &r) const { - return GetAdjustedTime(input_.node(), GetTimeTarget(), r, - Node::kTransformTowardsOutput); + return get_adjusted_time(input_.node(), get_time_target(), r, + Node::k_transform_towards_output); } -void NodeParamViewKeyframeControl::ShowButtonsFromKeyframeEnable(bool e) +void NodeParamViewKeyframeControl::show_buttons_from_keyframe_enable(bool e) { prev_key_btn_->setVisible(e); toggle_key_btn_->setVisible(e); next_key_btn_->setVisible(e); } -void NodeParamViewKeyframeControl::ToggleKeyframe(bool e) +void NodeParamViewKeyframeControl::toggle_keyframe(bool e) { - rational node_time = GetCurrentTimeAsNodeTime(); + Rational node_time = get_current_time_as_node_time(); QVector keys = - input_.node()->GetKeyframesAtTime(input_, node_time); + input_.node()->get_keyframes_at_time(input_, node_time); MultiUndoCommand *command = new MultiUndoCommand(); - int nb_tracks = input_.node()->GetNumberOfKeyframeTracks(input_); + int nb_tracks = input_.node()->get_number_of_keyframe_tracks(input_); if (e && keys.isEmpty()) { // Add a keyframe here (one for each track) for (int i = 0; i < nb_tracks; i++) { NodeKeyframe *key = new NodeKeyframe( node_time, - input_.node()->GetSplitValueAtTimeOnTrack(input_, node_time, i), - input_.node()->GetBestKeyframeTypeForTimeOnTrack(input_, + input_.node()->get_split_value_at_time_on_track(input_, node_time, i), + input_.node()->get_best_keyframe_type_for_time_on_track(input_, node_time, i), i, input_.element(), input_.input()); @@ -193,11 +193,11 @@ void NodeParamViewKeyframeControl::ToggleKeyframe(bool e) foreach (NodeKeyframe *key, keys) { command->add_child(new NodeParamRemoveKeyframeCommand(key)); - if (input_.node()->GetKeyframeTracks(input_).size() == 1) { + if (input_.node()->get_keyframe_tracks(input_).size() == 1) { // If this was the last keyframe on this track, set the standard value to the value at this time too command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference(input_, key->track()), - input_.node()->GetSplitValueAtTimeOnTrack(input_, node_time, + input_.node()->get_split_value_at_time_on_track(input_, node_time, key->track()))); } } @@ -206,52 +206,52 @@ void NodeParamViewKeyframeControl::ToggleKeyframe(bool e) Core::instance()->undo_stack()->push(command, tr("Toggled Keyframe")); } -void NodeParamViewKeyframeControl::UpdateState() +void NodeParamViewKeyframeControl::update_state() { - if (!input_.IsValid() || !input_.IsKeyframing() || !GetTimeTarget()) { + if (!input_.is_valid() || !input_.is_keyframing() || !get_time_target()) { return; } - NodeKeyframe *earliest_key = input_.node()->GetEarliestKeyframe(input_); - NodeKeyframe *latest_key = input_.node()->GetLatestKeyframe(input_); + NodeKeyframe *earliest_key = input_.node()->get_earliest_keyframe(input_); + NodeKeyframe *latest_key = input_.node()->get_latest_keyframe(input_); - rational node_time = GetCurrentTimeAsNodeTime(); + Rational node_time = get_current_time_as_node_time(); prev_key_btn_->setEnabled(earliest_key && node_time > earliest_key->time()); next_key_btn_->setEnabled(latest_key && node_time < latest_key->time()); toggle_key_btn_->setChecked( - input_.node()->HasKeyframeAtTime(input_, node_time)); + input_.node()->has_keyframe_at_time(input_, node_time)); } -void NodeParamViewKeyframeControl::GoToPreviousKey() +void NodeParamViewKeyframeControl::go_to_previous_key() { - rational node_time = GetCurrentTimeAsNodeTime(); + Rational node_time = get_current_time_as_node_time(); NodeKeyframe *previous_key = - input_.node()->GetClosestKeyframeBeforeTime(input_, node_time); + input_.node()->get_closest_keyframe_before_time(input_, node_time); - if (previous_key && GetTimeTarget()) { - rational key_time = ConvertToViewerTime(previous_key->time()); - GetTimeTarget()->SetPlayhead(key_time); + if (previous_key && get_time_target()) { + Rational key_time = convert_to_viewer_time(previous_key->time()); + get_time_target()->set_playhead(key_time); } } -void NodeParamViewKeyframeControl::GoToNextKey() +void NodeParamViewKeyframeControl::go_to_next_key() { - rational node_time = GetCurrentTimeAsNodeTime(); + Rational node_time = get_current_time_as_node_time(); NodeKeyframe *next_key = - input_.node()->GetClosestKeyframeAfterTime(input_, node_time); + input_.node()->get_closest_keyframe_after_time(input_, node_time); - if (next_key && GetTimeTarget()) { - rational key_time = ConvertToViewerTime(next_key->time()); - GetTimeTarget()->SetPlayhead(key_time); + if (next_key && get_time_target()) { + Rational key_time = convert_to_viewer_time(next_key->time()); + get_time_target()->set_playhead(key_time); } } -void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e) +void NodeParamViewKeyframeControl::keyframe_enable_btn_clicked(bool e) { - if (e == input_.IsKeyframing()) { + if (e == input_.is_keyframing()) { // No-op return; } @@ -266,12 +266,12 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e) // Create one keyframe across all tracks here const QVector &key_vals = - input_.node()->GetSplitStandardValue(input_); + input_.node()->get_split_standard_value(input_); for (int i = 0; i < key_vals.size(); i++) { NodeKeyframe *key = - new NodeKeyframe(GetCurrentTimeAsNodeTime(), key_vals.at(i), - NodeKeyframe::kDefaultType, i, + new NodeKeyframe(get_current_time_as_node_time(), key_vals.at(i), + NodeKeyframe::k_default_type, i, input_.element(), input_.input()); command->add_child( @@ -280,7 +280,7 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e) command_name = tr("Enabled Keyframing On %1 - %2") - .arg(input_.node()->GetLabelAndName(), input_.GetInputName()); + .arg(input_.node()->get_label_and_name(), input_.get_input_name()); } else { // Confirm the user wants to clear all keyframes if (QMessageBox::warning( @@ -289,12 +289,12 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e) QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { // Store value at this time, we'll set this as the persistent value later const QVector &stored_vals = - input_.node()->GetSplitValueAtTime(input_, - GetCurrentTimeAsNodeTime()); + input_.node()->get_split_value_at_time(input_, + get_current_time_as_node_time()); // Delete all keyframes foreach (const NodeKeyframeTrack &track, - input_.node()->GetKeyframeTracks(input_)) { + input_.node()->get_keyframe_tracks(input_)) { for (int i = track.size() - 1; i >= 0; i--) { command->add_child( new NodeParamRemoveKeyframeCommand(track.at(i))); @@ -312,8 +312,8 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e) new NodeParamSetKeyframingCommand(input_, false)); command_name = tr("Disabled Keyframing On %1 - %2") - .arg(input_.node()->GetLabelAndName(), - input_.GetInputName()); + .arg(input_.node()->get_label_and_name(), + input_.get_input_name()); } else { // Disable action has effectively been ignored enable_key_btn_->setChecked(true); @@ -323,7 +323,7 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e) Core::instance()->undo_stack()->push(command, command_name); } -void NodeParamViewKeyframeControl::KeyframeEnableChanged(const NodeInput &input, +void NodeParamViewKeyframeControl::keyframe_enable_changed(const NodeInput &input, bool e) { if (input_ == input) { diff --git a/app/widget/nodeparamview/nodeparamviewkeyframecontrol.h b/app/widget/nodeparamview/nodeparamviewkeyframecontrol.h index 1fb2a2ea8..6e7f079aa 100644 --- a/app/widget/nodeparamview/nodeparamviewkeyframecontrol.h +++ b/app/widget/nodeparamview/nodeparamviewkeyframecontrol.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWKEYFRAMECONTROL_H -#define NODEPARAMVIEWKEYFRAMECONTROL_H +#ifndef OAK_NODEPARAMVIEWKEYFRAMECONTROL_H +#define OAK_NODEPARAMVIEWKEYFRAMECONTROL_H #include #include @@ -40,25 +40,25 @@ public: { } - const NodeInput &GetConnectedInput() const + const NodeInput &get_connected_input() const { return input_; } - void SetInput(const NodeInput &input); + void set_input(const NodeInput &input); protected: virtual void TimeTargetDisconnectEvent(ViewerOutput *v) override; virtual void TimeTargetConnectEvent(ViewerOutput *v) override; private: - QPushButton *CreateNewToolButton(const QIcon &icon) const; + QPushButton *create_new_tool_button(const QIcon &icon) const; - void SetButtonsEnabled(bool e); + void set_buttons_enabled(bool e); - rational GetCurrentTimeAsNodeTime() const; + Rational get_current_time_as_node_time() const; - rational ConvertToViewerTime(const rational &r) const; + Rational convert_to_viewer_time(const Rational &r) const; QPushButton *prev_key_btn_; QPushButton *toggle_key_btn_; @@ -68,21 +68,21 @@ private: NodeInput input_; private slots: - void ShowButtonsFromKeyframeEnable(bool e); + void show_buttons_from_keyframe_enable(bool e); - void ToggleKeyframe(bool e); + void toggle_keyframe(bool e); - void UpdateState(); + void update_state(); - void GoToPreviousKey(); + void go_to_previous_key(); - void GoToNextKey(); + void go_to_next_key(); - void KeyframeEnableBtnClicked(bool e); + void keyframe_enable_btn_clicked(bool e); - void KeyframeEnableChanged(const NodeInput &input, bool e); + void keyframe_enable_changed(const NodeInput &input, bool e); }; } -#endif // NODEPARAMVIEWKEYFRAMECONTROL_H +#endif // OAK_NODEPARAMVIEWKEYFRAMECONTROL_H diff --git a/app/widget/nodeparamview/nodeparamviewtextedit.cpp b/app/widget/nodeparamview/nodeparamviewtextedit.cpp index 9da0ff5fd..42ced7789 100644 --- a/app/widget/nodeparamview/nodeparamviewtextedit.cpp +++ b/app/widget/nodeparamview/nodeparamviewtextedit.cpp @@ -38,46 +38,46 @@ NodeParamViewTextEdit::NodeParamViewTextEdit(QWidget *parent) line_edit_ = new QPlainTextEdit(); line_edit_->setUndoRedoEnabled(true); connect(line_edit_, &QPlainTextEdit::textChanged, this, - &NodeParamViewTextEdit::InnerWidgetTextChanged); + &NodeParamViewTextEdit::inner_widget_text_changed); layout->addWidget(line_edit_); edit_btn_ = new QPushButton(); - edit_btn_->setIcon(icon::ToolEdit); + edit_btn_->setIcon(icon::tool_edit); edit_btn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding); layout->addWidget(edit_btn_); connect(edit_btn_, &QPushButton::clicked, this, - &NodeParamViewTextEdit::ShowTextDialog); + &NodeParamViewTextEdit::show_text_dialog); edit_in_viewer_btn_ = new QPushButton(tr("Edit In Viewer")); - edit_in_viewer_btn_->setIcon(icon::Pencil); + edit_in_viewer_btn_->setIcon(icon::pencil); layout->addWidget(edit_in_viewer_btn_); connect(edit_in_viewer_btn_, &QPushButton::clicked, this, - &NodeParamViewTextEdit::RequestEditInViewer); + &NodeParamViewTextEdit::request_edit_in_viewer); - SetEditInViewerOnlyMode(false); + set_edit_in_viewer_only_mode(false); } -void NodeParamViewTextEdit::SetEditInViewerOnlyMode(bool on) +void NodeParamViewTextEdit::set_edit_in_viewer_only_mode(bool on) { line_edit_->setVisible(!on); edit_btn_->setVisible(!on); edit_in_viewer_btn_->setVisible(on); } -void NodeParamViewTextEdit::ShowTextDialog() +void NodeParamViewTextEdit::show_text_dialog() { TextDialog d(this->text(), this); if (d.exec() == QDialog::Accepted) { QString s = d.text(); line_edit_->setPlainText(s); - emit textEdited(s); + emit text_edited(s); } } -void NodeParamViewTextEdit::InnerWidgetTextChanged() +void NodeParamViewTextEdit::inner_widget_text_changed() { - emit textEdited(this->text()); + emit text_edited(this->text()); } } diff --git a/app/widget/nodeparamview/nodeparamviewtextedit.h b/app/widget/nodeparamview/nodeparamviewtextedit.h index 427942972..75ed76c67 100644 --- a/app/widget/nodeparamview/nodeparamviewtextedit.h +++ b/app/widget/nodeparamview/nodeparamviewtextedit.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWTEXTEDIT_H -#define NODEPARAMVIEWTEXTEDIT_H +#ifndef OAK_NODEPARAMVIEWTEXTEDIT_H +#define OAK_NODEPARAMVIEWTEXTEDIT_H #include #include @@ -41,7 +41,7 @@ public: return line_edit_->toPlainText(); } - void SetEditInViewerOnlyMode(bool on); + void set_edit_in_viewer_only_mode(bool on); public slots: void setText(const QString &s) @@ -66,9 +66,9 @@ public slots: } signals: - void textEdited(const QString &); + void text_edited(const QString &); - void RequestEditInViewer(); + void request_edit_in_viewer(); private: QPlainTextEdit *line_edit_; @@ -78,11 +78,11 @@ private: QPushButton *edit_in_viewer_btn_; private slots: - void ShowTextDialog(); + void show_text_dialog(); - void InnerWidgetTextChanged(); + void inner_widget_text_changed(); }; } -#endif // NODEPARAMVIEWTEXTEDIT_H +#endif // OAK_NODEPARAMVIEWTEXTEDIT_H diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp index d41b89442..492261d73 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp @@ -59,71 +59,71 @@ NodeParamViewWidgetBridge::NodeParamViewWidgetBridge(NodeInput input, do { input_hierarchy_.append(input); - connect(input.node(), &Node::ValueChanged, this, - &NodeParamViewWidgetBridge::InputValueChanged); - connect(input.node(), &Node::InputPropertyChanged, this, - &NodeParamViewWidgetBridge::PropertyChanged); - connect(input.node(), &Node::InputDataTypeChanged, this, - &NodeParamViewWidgetBridge::InputDataTypeChanged); - } while (NodeGroup::GetInner(&input)); + connect(input.node(), &Node::value_changed, this, + &NodeParamViewWidgetBridge::input_value_changed); + connect(input.node(), &Node::input_property_changed, this, + &NodeParamViewWidgetBridge::property_changed); + connect(input.node(), &Node::input_data_type_changed, this, + &NodeParamViewWidgetBridge::input_data_type_changed); + } while (NodeGroup::get_inner(&input)); - CreateWidgets(); + create_widgets(); } -int GetSliderCount(NodeValue::Type type) +int get_slider_count(NodeValue::Type type) { return NodeValue::get_number_of_keyframe_tracks(type); } -void NodeParamViewWidgetBridge::CreateWidgets() +void NodeParamViewWidgetBridge::create_widgets() { QWidget *parent = dynamic_cast(this->parent()); - if (GetInnerInput().IsArray() && GetInnerInput().element() == -1) { + if (get_inner_input().is_array() && get_inner_input().element() == -1) { NodeParamViewArrayWidget *w = new NodeParamViewArrayWidget( - GetInnerInput().node(), GetInnerInput().input(), parent); - connect(w, &NodeParamViewArrayWidget::DoubleClicked, this, - &NodeParamViewWidgetBridge::ArrayWidgetDoubleClicked); + get_inner_input().node(), get_inner_input().input(), parent); + connect(w, &NodeParamViewArrayWidget::double_clicked, this, + &NodeParamViewWidgetBridge::array_widget_double_clicked); widgets_.append(w); } else { // We assume the first data type is the "primary" type - NodeValue::Type t = GetDataType(); + NodeValue::Type t = get_data_type(); switch (t) { // None of these inputs have applicable UI widgets - case NodeValue::kNone: - case NodeValue::kTexture: - case NodeValue::kMatrix: - case NodeValue::kSamples: - case NodeValue::kVideoParams: - case NodeValue::kAudioParams: - case NodeValue::kSubtitleParams: - case NodeValue::kBinary: - case NodeValue::kDataTypeCount: + case NodeValue::k_none: + case NodeValue::k_texture: + case NodeValue::k_matrix: + case NodeValue::k_samples: + case NodeValue::k_video_params: + case NodeValue::k_audio_params: + case NodeValue::k_subtitle_params: + case NodeValue::k_binary: + case NodeValue::k_data_type_count: break; - case NodeValue::kInt: { - CreateSliders(1, parent); + case NodeValue::k_int: { + create_sliders(1, parent); break; } - case NodeValue::kRational: { - CreateSliders(1, parent); + case NodeValue::k_rational: { + create_sliders(1, parent); break; } - case NodeValue::kFloat: - case NodeValue::kVec2: - case NodeValue::kVec3: - case NodeValue::kVec4: { - CreateSliders(GetSliderCount(t), parent); + case NodeValue::k_float: + case NodeValue::k_vec2: + case NodeValue::k_vec3: + case NodeValue::k_vec4: { + create_sliders(get_slider_count(t), parent); break; } - case NodeValue::kCombo: - case NodeValue::kStrCombo: { + case NodeValue::k_combo: + case NodeValue::k_str_combo: { QComboBox *combobox = new QComboBox(parent); - QStringList items = GetInnerInput().GetComboBoxStrings(); + QStringList items = get_inner_input().get_combo_box_strings(); QStringList values = - GetInnerInput().GetProperty("combo_value_str").toStringList(); - const bool use_value_data = (t == NodeValue::kStrCombo) && + get_inner_input().get_property("combo_value_str").toStringList(); + const bool use_value_data = (t == NodeValue::k_str_combo) && !values.isEmpty(); for (int i = 0; i < items.size(); ++i) { const QString &label = items.at(i); @@ -138,12 +138,12 @@ void NodeParamViewWidgetBridge::CreateWidgets() connect(combobox, static_cast( &QComboBox::currentIndexChanged), - this, &NodeParamViewWidgetBridge::WidgetCallback); + this, &NodeParamViewWidgetBridge::widget_callback); break; } - case NodeValue::kFile: { + case NodeValue::k_file: { FileField *file_field; - if (GetInnerInput().GetProperty(QStringLiteral("lut_library")) + if (get_inner_input().get_property(QStringLiteral("lut_library")) .toBool()) { // File inputs that accept LUTs get a combo box for picking // from the global LUT library @@ -152,80 +152,80 @@ void NodeParamViewWidgetBridge::CreateWidgets() file_field = new FileField(parent); } widgets_.append(file_field); - connect(file_field, &FileField::FilenameChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); + connect(file_field, &FileField::filename_changed, this, + &NodeParamViewWidgetBridge::widget_callback); break; } - case NodeValue::kColor: { - if (GetInnerInput().GetProperty("color_semantic").toString() == + case NodeValue::k_color: { + if (get_inner_input().get_property("color_semantic").toString() == QStringLiteral("scalar")) { - CreateSliders(4, parent); + create_sliders(4, parent); } else { ColorButton *color_button = new ColorButton( - GetInnerInput().node()->project()->color_manager(), parent); + get_inner_input().node()->project()->color_manager(), parent); widgets_.append(color_button); - connect(color_button, &ColorButton::ColorChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); + connect(color_button, &ColorButton::color_changed, this, + &NodeParamViewWidgetBridge::widget_callback); } break; } - case NodeValue::kText: { + case NodeValue::k_text: { NodeParamViewTextEdit *line_edit = new NodeParamViewTextEdit(parent); widgets_.append(line_edit); - connect(line_edit, &NodeParamViewTextEdit::textEdited, this, - &NodeParamViewWidgetBridge::WidgetCallback); - connect(line_edit, &NodeParamViewTextEdit::RequestEditInViewer, - this, &NodeParamViewWidgetBridge::RequestEditTextInViewer); + connect(line_edit, &NodeParamViewTextEdit::text_edited, this, + &NodeParamViewWidgetBridge::widget_callback); + connect(line_edit, &NodeParamViewTextEdit::request_edit_in_viewer, + this, &NodeParamViewWidgetBridge::request_edit_text_in_viewer); break; } - case NodeValue::kBoolean: { + case NodeValue::k_boolean: { QCheckBox *check_box = new QCheckBox(parent); widgets_.append(check_box); connect(check_box, &QCheckBox::clicked, this, - &NodeParamViewWidgetBridge::WidgetCallback); + &NodeParamViewWidgetBridge::widget_callback); break; } - case NodeValue::kFont: { + case NodeValue::k_font: { QFontComboBox *font_combobox = new QFontComboBox(parent); widgets_.append(font_combobox); connect(font_combobox, &QFontComboBox::currentFontChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); + &NodeParamViewWidgetBridge::widget_callback); break; } - case NodeValue::kBezier: { + case NodeValue::k_bezier: { BezierWidget *bezier = new BezierWidget(parent); widgets_.append(bezier); - connect(bezier->x_slider(), &FloatSlider::ValueChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); - connect(bezier->y_slider(), &FloatSlider::ValueChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); - connect(bezier->cp1_x_slider(), &FloatSlider::ValueChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); - connect(bezier->cp1_y_slider(), &FloatSlider::ValueChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); - connect(bezier->cp2_x_slider(), &FloatSlider::ValueChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); - connect(bezier->cp2_y_slider(), &FloatSlider::ValueChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); + connect(bezier->x_slider(), &FloatSlider::value_changed, this, + &NodeParamViewWidgetBridge::widget_callback); + connect(bezier->y_slider(), &FloatSlider::value_changed, this, + &NodeParamViewWidgetBridge::widget_callback); + connect(bezier->cp1_x_slider(), &FloatSlider::value_changed, this, + &NodeParamViewWidgetBridge::widget_callback); + connect(bezier->cp1_y_slider(), &FloatSlider::value_changed, this, + &NodeParamViewWidgetBridge::widget_callback); + connect(bezier->cp2_x_slider(), &FloatSlider::value_changed, this, + &NodeParamViewWidgetBridge::widget_callback); + connect(bezier->cp2_y_slider(), &FloatSlider::value_changed, this, + &NodeParamViewWidgetBridge::widget_callback); break; } - case NodeValue::kPushButton: { - NodeInput input = GetInnerInput(); + case NodeValue::k_push_button: { + NodeInput input = get_inner_input(); NodeParamButton *button = new NodeParamButton(input.name(), parent); widgets_.append(button); plugin::PluginNode *plugin_node = dynamic_cast(input.node()); - connect(button, &NodeParamButton::onPressed, plugin_node, - &plugin::PluginNode::pushButtonClicked); + connect(button, &NodeParamButton::on_pressed, plugin_node, + &plugin::PluginNode::push_button_clicked); } } // Check all properties - UpdateProperties(); + update_properties(); - UpdateWidgetValues(); + update_widget_values(); // Install event filter to disable widgets picking up scroll events foreach (QWidget *w, widgets_) { @@ -234,174 +234,174 @@ void NodeParamViewWidgetBridge::CreateWidgets() } } -void NodeParamViewWidgetBridge::SetInputValue(const QVariant &value, int track) +void NodeParamViewWidgetBridge::set_input_value(const QVariant &value, int track) { MultiUndoCommand *command = new MultiUndoCommand(); - SetInputValueInternal(value, track, command, true); + set_input_value_internal(value, track, command, true); - Core::instance()->undo_stack()->push(command, GetCommandName()); + Core::instance()->undo_stack()->push(command, get_command_name()); } -void NodeParamViewWidgetBridge::SetInputValueInternal( +void NodeParamViewWidgetBridge::set_input_value_internal( const QVariant &value, int track, MultiUndoCommand *command, bool insert_on_all_tracks_if_no_key) { - Node::SetValueAtTime(GetInnerInput(), GetCurrentTimeAsNodeTime(), value, + Node::set_value_at_time(get_inner_input(), get_current_time_as_node_time(), value, track, command, insert_on_all_tracks_if_no_key); } -void NodeParamViewWidgetBridge::ProcessSlider(NumericSliderBase *slider, +void NodeParamViewWidgetBridge::process_slider(NumericSliderBase *slider, int slider_track, const QVariant &value) { - if (slider->IsDragging()) { + if (slider->is_dragging()) { // While we're dragging, we block the input's normal signalling and create our own - if (!dragger_.IsStarted()) { - rational node_time = GetCurrentTimeAsNodeTime(); + if (!dragger_.is_started()) { + Rational node_time = get_current_time_as_node_time(); - dragger_.Start(NodeKeyframeTrackReference(GetInnerInput(), + dragger_.start(NodeKeyframeTrackReference(get_inner_input(), slider_track), node_time); } - dragger_.Drag(value); + dragger_.drag(value); - } else if (dragger_.IsStarted()) { + } else if (dragger_.is_started()) { // We were dragging and just stopped - dragger_.Drag(value); + dragger_.drag(value); MultiUndoCommand *command = new MultiUndoCommand(); - dragger_.End(command); - Core::instance()->undo_stack()->push(command, GetCommandName()); + dragger_.end(command); + Core::instance()->undo_stack()->push(command, get_command_name()); } else { // No drag was involved, we can just push the value - SetInputValue(value, slider_track); + set_input_value(value, slider_track); } } -void NodeParamViewWidgetBridge::WidgetCallback() +void NodeParamViewWidgetBridge::widget_callback() { - switch (GetDataType()) { + switch (get_data_type()) { // None of these inputs have applicable UI widgets - case NodeValue::kNone: - case NodeValue::kTexture: - case NodeValue::kMatrix: - case NodeValue::kSamples: - case NodeValue::kVideoParams: - case NodeValue::kAudioParams: - case NodeValue::kSubtitleParams: - case NodeValue::kDataTypeCount: + case NodeValue::k_none: + case NodeValue::k_texture: + case NodeValue::k_matrix: + case NodeValue::k_samples: + case NodeValue::k_video_params: + case NodeValue::k_audio_params: + case NodeValue::k_subtitle_params: + case NodeValue::k_data_type_count: break; - case NodeValue::kInt: { + case NodeValue::k_int: { // Widget is a IntegerSlider IntegerSlider *slider = static_cast(sender()); - ProcessSlider(slider, QVariant::fromValue(slider->GetValue())); + process_slider(slider, QVariant::fromValue(slider->get_value())); break; } - case NodeValue::kFloat: { + case NodeValue::k_float: { // Widget is a FloatSlider FloatSlider *slider = static_cast(sender()); - ProcessSlider(slider, slider->GetValue()); + process_slider(slider, slider->get_value()); break; } - case NodeValue::kRational: { + case NodeValue::k_rational: { // Widget is a RationalSlider RationalSlider *slider = static_cast(sender()); - ProcessSlider(slider, QVariant::fromValue(slider->GetValue())); + process_slider(slider, QVariant::fromValue(slider->get_value())); break; } - case NodeValue::kVec2: { + case NodeValue::k_vec2: { // Widget is a FloatSlider FloatSlider *slider = static_cast(sender()); - ProcessSlider(slider, slider->GetValue()); + process_slider(slider, slider->get_value()); break; } - case NodeValue::kVec3: { + case NodeValue::k_vec3: { // Widget is a FloatSlider FloatSlider *slider = static_cast(sender()); - ProcessSlider(slider, slider->GetValue()); + process_slider(slider, slider->get_value()); break; } - case NodeValue::kVec4: { + case NodeValue::k_vec4: { // Widget is a FloatSlider FloatSlider *slider = static_cast(sender()); - ProcessSlider(slider, slider->GetValue()); + process_slider(slider, slider->get_value()); break; } - case NodeValue::kFile: { - SetInputValue(static_cast(sender())->GetFilename(), 0); + case NodeValue::k_file: { + set_input_value(static_cast(sender())->get_filename(), 0); break; } - case NodeValue::kColor: { - if (GetInnerInput().GetProperty("color_semantic").toString() == + case NodeValue::k_color: { + if (get_inner_input().get_property("color_semantic").toString() == QStringLiteral("scalar")) { FloatSlider *slider = static_cast(sender()); - ProcessSlider(slider, slider->GetValue()); + process_slider(slider, slider->get_value()); } else { // Sender is a ColorButton - ManagedColor c = static_cast(sender())->GetColor(); + ManagedColor c = static_cast(sender())->get_color(); MultiUndoCommand *command = new MultiUndoCommand(); - SetInputValueInternal(c.red(), 0, command, false); - SetInputValueInternal(c.green(), 1, command, false); - SetInputValueInternal(c.blue(), 2, command, false); - SetInputValueInternal(c.alpha(), 3, command, false); + set_input_value_internal(c.red(), 0, command, false); + set_input_value_internal(c.green(), 1, command, false); + set_input_value_internal(c.blue(), 2, command, false); + set_input_value_internal(c.alpha(), 3, command, false); - Node *n = GetInnerInput().node(); + Node *n = get_inner_input().node(); n->blockSignals(true); - n->SetInputProperty(GetInnerInput().input(), + n->set_input_property(get_inner_input().input(), QStringLiteral("col_input"), c.color_input()); - n->SetInputProperty(GetInnerInput().input(), + n->set_input_property(get_inner_input().input(), QStringLiteral("col_display"), c.color_output().display()); - n->SetInputProperty(GetInnerInput().input(), + n->set_input_property(get_inner_input().input(), QStringLiteral("col_view"), c.color_output().view()); - n->SetInputProperty(GetInnerInput().input(), + n->set_input_property(get_inner_input().input(), QStringLiteral("col_look"), c.color_output().look()); n->blockSignals(false); - Core::instance()->undo_stack()->push(command, GetCommandName()); + Core::instance()->undo_stack()->push(command, get_command_name()); } break; } - case NodeValue::kText: { + case NodeValue::k_text: { // Sender is a NodeParamViewRichText - SetInputValue(static_cast(sender())->text(), + set_input_value(static_cast(sender())->text(), 0); break; } - case NodeValue::kBinary: { + case NodeValue::k_binary: { QString text = static_cast(sender())->text(); QByteArray raw = text.toUtf8(); QByteArray decoded = QByteArray::fromBase64(raw); if (decoded.isEmpty() && !raw.isEmpty()) { decoded = raw; } - SetInputValue(decoded, 0); + set_input_value(decoded, 0); break; } - case NodeValue::kBoolean: { + case NodeValue::k_boolean: { // Widget is a QCheckBox - SetInputValue(static_cast(sender())->isChecked(), 0); + set_input_value(static_cast(sender())->isChecked(), 0); break; } - case NodeValue::kFont: { + case NodeValue::k_font: { // Widget is a QFontComboBox - SetInputValue( + set_input_value( static_cast(sender())->currentFont().family(), 0); break; } - case NodeValue::kCombo: { + case NodeValue::k_combo: { // Widget is a QComboBox QComboBox *cb = static_cast(widgets_.first()); int index = cb->currentIndex(); @@ -414,20 +414,20 @@ void NodeParamViewWidgetBridge::WidgetCallback() } } - SetInputValue(index, 0); + set_input_value(index, 0); break; } - case NodeValue::kStrCombo: { + case NodeValue::k_str_combo: { QComboBox *cb = static_cast(widgets_.first()); const QVariant data = cb->currentData(); if (data.isValid()) { - SetInputValue(data.toString(), 0); + set_input_value(data.toString(), 0); } else { - SetInputValue(cb->currentText(), 0); + set_input_value(cb->currentText(), 0); } break; } - case NodeValue::kBezier: { + case NodeValue::k_bezier: { // Widget is a FloatSlider (child of BezierWidget) BezierWidget *bw = static_cast(widgets_.first()); FloatSlider *fs = static_cast(sender()); @@ -448,7 +448,7 @@ void NodeParamViewWidgetBridge::WidgetCallback() } if (index != -1) { - ProcessSlider(fs, index, fs->GetValue()); + process_slider(fs, index, fs->get_value()); } break; } @@ -456,167 +456,167 @@ void NodeParamViewWidgetBridge::WidgetCallback() } template -void NodeParamViewWidgetBridge::CreateSliders(int count, QWidget *parent) +void NodeParamViewWidgetBridge::create_sliders(int count, QWidget *parent) { for (int i = 0; i < count; i++) { T *fs = new T(parent); - fs->SliderBase::SetDefaultValue( - GetInnerInput().GetSplitDefaultValueForTrack(i)); - fs->SetLadderElementCount(2); + fs->SliderBase::set_default_value( + get_inner_input().get_split_default_value_for_track(i)); + fs->set_ladder_element_count(2); // HACK: Force some spacing between sliders fs->setContentsMargins( 0, 0, - QtUtils::QFontMetricsWidth(fs->fontMetrics(), + QtUtils::q_font_metrics_width(fs->fontMetrics(), QStringLiteral(" ")), 0); widgets_.append(fs); - connect(fs, &T::ValueChanged, this, - &NodeParamViewWidgetBridge::WidgetCallback); + connect(fs, &T::value_changed, this, + &NodeParamViewWidgetBridge::widget_callback); } } -void NodeParamViewWidgetBridge::UpdateWidgetValues() +void NodeParamViewWidgetBridge::update_widget_values() { - if (GetInnerInput().IsArray() && GetInnerInput().element() == -1) { + if (get_inner_input().is_array() && get_inner_input().element() == -1) { return; } - rational node_time; - if (GetInnerInput().IsKeyframing()) { - node_time = GetCurrentTimeAsNodeTime(); + Rational node_time; + if (get_inner_input().is_keyframing()) { + node_time = get_current_time_as_node_time(); } // We assume the first data type is the "primary" type - switch (GetDataType()) { + switch (get_data_type()) { // None of these inputs have applicable UI widgets - case NodeValue::kNone: - case NodeValue::kTexture: - case NodeValue::kMatrix: - case NodeValue::kSamples: - case NodeValue::kVideoParams: - case NodeValue::kAudioParams: - case NodeValue::kSubtitleParams: - case NodeValue::kDataTypeCount: + case NodeValue::k_none: + case NodeValue::k_texture: + case NodeValue::k_matrix: + case NodeValue::k_samples: + case NodeValue::k_video_params: + case NodeValue::k_audio_params: + case NodeValue::k_subtitle_params: + case NodeValue::k_data_type_count: break; - case NodeValue::kBinary: { + case NodeValue::k_binary: { NodeParamViewTextEdit *e = static_cast(widgets_.first()); QByteArray bytes = - GetInnerInput().GetValueAtTime(node_time).toByteArray(); + get_inner_input().get_value_at_time(node_time).toByteArray(); e->setTextPreservingCursor(QString::fromUtf8(bytes.toBase64())); break; } - case NodeValue::kInt: { + case NodeValue::k_int: { static_cast(widgets_.first()) - ->SetValue(GetInnerInput().GetValueAtTime(node_time).toLongLong()); + ->set_value(get_inner_input().get_value_at_time(node_time).toLongLong()); break; } - case NodeValue::kFloat: { + case NodeValue::k_float: { static_cast(widgets_.first()) - ->SetValue(GetInnerInput().GetValueAtTime(node_time).toDouble()); + ->set_value(get_inner_input().get_value_at_time(node_time).toDouble()); break; } - case NodeValue::kRational: { + case NodeValue::k_rational: { static_cast(widgets_.first()) - ->SetValue( - GetInnerInput().GetValueAtTime(node_time).value()); + ->set_value( + get_inner_input().get_value_at_time(node_time).value()); break; } - case NodeValue::kVec2: { + case NodeValue::k_vec2: { QVector2D vec2 = - GetInnerInput().GetValueAtTime(node_time).value(); + get_inner_input().get_value_at_time(node_time).value(); static_cast(widgets_.at(0)) - ->SetValue(static_cast(vec2.x())); + ->set_value(static_cast(vec2.x())); static_cast(widgets_.at(1)) - ->SetValue(static_cast(vec2.y())); + ->set_value(static_cast(vec2.y())); break; } - case NodeValue::kVec3: { + case NodeValue::k_vec3: { QVector3D vec3 = - GetInnerInput().GetValueAtTime(node_time).value(); + get_inner_input().get_value_at_time(node_time).value(); static_cast(widgets_.at(0)) - ->SetValue(static_cast(vec3.x())); + ->set_value(static_cast(vec3.x())); static_cast(widgets_.at(1)) - ->SetValue(static_cast(vec3.y())); + ->set_value(static_cast(vec3.y())); static_cast(widgets_.at(2)) - ->SetValue(static_cast(vec3.z())); + ->set_value(static_cast(vec3.z())); break; } - case NodeValue::kVec4: { + case NodeValue::k_vec4: { QVector4D vec4 = - GetInnerInput().GetValueAtTime(node_time).value(); + get_inner_input().get_value_at_time(node_time).value(); static_cast(widgets_.at(0)) - ->SetValue(static_cast(vec4.x())); + ->set_value(static_cast(vec4.x())); static_cast(widgets_.at(1)) - ->SetValue(static_cast(vec4.y())); + ->set_value(static_cast(vec4.y())); static_cast(widgets_.at(2)) - ->SetValue(static_cast(vec4.z())); + ->set_value(static_cast(vec4.z())); static_cast(widgets_.at(3)) - ->SetValue(static_cast(vec4.w())); + ->set_value(static_cast(vec4.w())); break; } - case NodeValue::kFile: { + case NodeValue::k_file: { FileField *ff = static_cast(widgets_.first()); - ff->SetFilename(GetInnerInput().GetValueAtTime(node_time).toString()); + ff->set_filename(get_inner_input().get_value_at_time(node_time).toString()); break; } - case NodeValue::kColor: { - if (GetInnerInput().GetProperty("color_semantic").toString() == + case NodeValue::k_color: { + if (get_inner_input().get_property("color_semantic").toString() == QStringLiteral("scalar")) { - Color c = GetInnerInput().GetValueAtTime(node_time).value(); + Color c = get_inner_input().get_value_at_time(node_time).value(); static_cast(widgets_.at(0)) - ->SetValue(static_cast(c.red())); + ->set_value(static_cast(c.red())); static_cast(widgets_.at(1)) - ->SetValue(static_cast(c.green())); + ->set_value(static_cast(c.green())); static_cast(widgets_.at(2)) - ->SetValue(static_cast(c.blue())); + ->set_value(static_cast(c.blue())); static_cast(widgets_.at(3)) - ->SetValue(static_cast(c.alpha())); + ->set_value(static_cast(c.alpha())); } else { ManagedColor mc = - GetInnerInput().GetValueAtTime(node_time).value(); + get_inner_input().get_value_at_time(node_time).value(); mc.set_color_input( - GetInnerInput().GetProperty("col_input").toString()); + get_inner_input().get_property("col_input").toString()); - QString d = GetInnerInput().GetProperty("col_display").toString(); - QString v = GetInnerInput().GetProperty("col_view").toString(); - QString l = GetInnerInput().GetProperty("col_look").toString(); + QString d = get_inner_input().get_property("col_display").toString(); + QString v = get_inner_input().get_property("col_view").toString(); + QString l = get_inner_input().get_property("col_look").toString(); mc.set_color_output(ColorTransform(d, v, l)); - static_cast(widgets_.first())->SetColor(mc); + static_cast(widgets_.first())->set_color(mc); } break; } - case NodeValue::kText: { + case NodeValue::k_text: { NodeParamViewTextEdit *e = static_cast(widgets_.first()); e->setTextPreservingCursor( - GetInnerInput().GetValueAtTime(node_time).toString()); + get_inner_input().get_value_at_time(node_time).toString()); break; } - case NodeValue::kBoolean: + case NodeValue::k_boolean: static_cast(widgets_.first()) - ->setChecked(GetInnerInput().GetValueAtTime(node_time).toBool()); + ->setChecked(get_inner_input().get_value_at_time(node_time).toBool()); break; - case NodeValue::kFont: { + case NodeValue::k_font: { QFontComboBox *fc = static_cast(widgets_.first()); fc->blockSignals(true); fc->setCurrentFont( - GetInnerInput().GetValueAtTime(node_time).toString()); + get_inner_input().get_value_at_time(node_time).toString()); fc->blockSignals(false); break; } - case NodeValue::kCombo: { + case NodeValue::k_combo: { QComboBox *cb = static_cast(widgets_.first()); cb->blockSignals(true); - int index = GetInnerInput().GetValueAtTime(node_time).toInt(); + int index = get_inner_input().get_value_at_time(node_time).toInt(); for (int i = 0; i < cb->count(); i++) { if (cb->itemData(i).toInt() == index) { cb->setCurrentIndex(i); @@ -625,11 +625,11 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues() cb->blockSignals(false); break; } - case NodeValue::kStrCombo: { + case NodeValue::k_str_combo: { QComboBox *cb = static_cast(widgets_.first()); cb->blockSignals(true); const QString current = - GetInnerInput().GetValueAtTime(node_time).toString(); + get_inner_input().get_value_at_time(node_time).toString(); for (int i = 0; i < cb->count(); ++i) { const QVariant data = cb->itemData(i); if ((data.isValid() && data.toString() == current) || @@ -641,66 +641,66 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues() cb->blockSignals(false); break; } - case NodeValue::kBezier: { + case NodeValue::k_bezier: { BezierWidget *bw = static_cast(widgets_.first()); - bw->SetValue(GetInnerInput().GetValueAtTime(node_time).value()); + bw->set_value(get_inner_input().get_value_at_time(node_time).value()); break; } } } -rational NodeParamViewWidgetBridge::GetCurrentTimeAsNodeTime() const +Rational NodeParamViewWidgetBridge::get_current_time_as_node_time() const { - if (GetTimeTarget()) { - return GetAdjustedTime(GetTimeTarget(), GetInnerInput().node(), - GetTimeTarget()->GetPlayhead(), - Node::kTransformTowardsInput); + if (get_time_target()) { + return get_adjusted_time(get_time_target(), get_inner_input().node(), + get_time_target()->get_playhead(), + Node::k_transform_towards_input); } else { return 0; } } -QString NodeParamViewWidgetBridge::GetCommandName() const +QString NodeParamViewWidgetBridge::get_command_name() const { - NodeInput i = GetInnerInput(); + NodeInput i = get_inner_input(); return tr("Edited Value Of %1 - %2") - .arg(i.node()->GetLabelAndName(), i.node()->GetInputName(i.input())); + .arg(i.node()->get_label_and_name(), i.node()->get_input_name(i.input())); } -void NodeParamViewWidgetBridge::SetTimebase(const rational &timebase) +void NodeParamViewWidgetBridge::set_timebase(const Rational &timebase) { - if (GetDataType() == NodeValue::kRational) { - static_cast(widgets_.first())->SetTimebase(timebase); + if (get_data_type() == NodeValue::k_rational) { + static_cast(widgets_.first())->set_timebase(timebase); } } void NodeParamViewWidgetBridge::TimeTargetDisconnectEvent(ViewerOutput *v) { - disconnect(v, &ViewerOutput::PlayheadChanged, this, - &NodeParamViewWidgetBridge::UpdateWidgetValues); + disconnect(v, &ViewerOutput::playhead_changed, this, + &NodeParamViewWidgetBridge::update_widget_values); } void NodeParamViewWidgetBridge::TimeTargetConnectEvent(ViewerOutput *v) { - connect(v, &ViewerOutput::PlayheadChanged, this, - &NodeParamViewWidgetBridge::UpdateWidgetValues); + connect(v, &ViewerOutput::playhead_changed, this, + &NodeParamViewWidgetBridge::update_widget_values); } -void NodeParamViewWidgetBridge::InputValueChanged(const NodeInput &input, +void NodeParamViewWidgetBridge::input_value_changed(const NodeInput &input, const TimeRange &range) { - if (GetTimeTarget() && GetInnerInput() == input && !dragger_.IsStarted() && - range.in() <= GetTimeTarget()->GetPlayhead() && - range.out() >= GetTimeTarget()->GetPlayhead()) { + if (get_time_target() && get_inner_input() == input && !dragger_.is_started() && + range.in() <= get_time_target()->get_playhead() && + range.out() >= get_time_target()->get_playhead()) { // We'll need to update the widgets because the values have changed on our current time - UpdateWidgetValues(); + update_widget_values(); } } -void NodeParamViewWidgetBridge::SetProperty(const QString &key, +void NodeParamViewWidgetBridge::set_property(const QString &key, const QVariant &value) { - NodeValue::Type data_type = GetDataType(); + NodeValue::Type data_type = get_data_type(); // Parameters for all types bool key_is_disable = key.startsWith(QStringLiteral("disable")); @@ -736,37 +736,37 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, NodeValue::type_is_vector(data_type)) { if (key == QStringLiteral("min")) { switch (data_type) { - case NodeValue::kInt: + case NodeValue::k_int: static_cast(widgets_.first()) - ->SetMinimum(value.value()); + ->set_minimum(value.value()); break; - case NodeValue::kFloat: + case NodeValue::k_float: static_cast(widgets_.first()) - ->SetMinimum(value.toDouble()); + ->set_minimum(value.toDouble()); break; - case NodeValue::kRational: + case NodeValue::k_rational: static_cast(widgets_.first()) - ->SetMinimum(value.value()); + ->set_minimum(value.value()); break; - case NodeValue::kVec2: { + case NodeValue::k_vec2: { QVector2D min = value.value(); - static_cast(widgets_.at(0))->SetMinimum(min.x()); - static_cast(widgets_.at(1))->SetMinimum(min.y()); + static_cast(widgets_.at(0))->set_minimum(min.x()); + static_cast(widgets_.at(1))->set_minimum(min.y()); break; } - case NodeValue::kVec3: { + case NodeValue::k_vec3: { QVector3D min = value.value(); - static_cast(widgets_.at(0))->SetMinimum(min.x()); - static_cast(widgets_.at(1))->SetMinimum(min.y()); - static_cast(widgets_.at(2))->SetMinimum(min.z()); + static_cast(widgets_.at(0))->set_minimum(min.x()); + static_cast(widgets_.at(1))->set_minimum(min.y()); + static_cast(widgets_.at(2))->set_minimum(min.z()); break; } - case NodeValue::kVec4: { + case NodeValue::k_vec4: { QVector4D min = value.value(); - static_cast(widgets_.at(0))->SetMinimum(min.x()); - static_cast(widgets_.at(1))->SetMinimum(min.y()); - static_cast(widgets_.at(2))->SetMinimum(min.z()); - static_cast(widgets_.at(3))->SetMinimum(min.w()); + static_cast(widgets_.at(0))->set_minimum(min.x()); + static_cast(widgets_.at(1))->set_minimum(min.y()); + static_cast(widgets_.at(2))->set_minimum(min.z()); + static_cast(widgets_.at(3))->set_minimum(min.w()); break; } default: @@ -774,37 +774,37 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, } } else if (key == QStringLiteral("max")) { switch (data_type) { - case NodeValue::kInt: + case NodeValue::k_int: static_cast(widgets_.first()) - ->SetMaximum(value.value()); + ->set_maximum(value.value()); break; - case NodeValue::kFloat: + case NodeValue::k_float: static_cast(widgets_.first()) - ->SetMaximum(value.toDouble()); + ->set_maximum(value.toDouble()); break; - case NodeValue::kRational: + case NodeValue::k_rational: static_cast(widgets_.first()) - ->SetMaximum(value.value()); + ->set_maximum(value.value()); break; - case NodeValue::kVec2: { + case NodeValue::k_vec2: { QVector2D max = value.value(); - static_cast(widgets_.at(0))->SetMaximum(max.x()); - static_cast(widgets_.at(1))->SetMaximum(max.y()); + static_cast(widgets_.at(0))->set_maximum(max.x()); + static_cast(widgets_.at(1))->set_maximum(max.y()); break; } - case NodeValue::kVec3: { + case NodeValue::k_vec3: { QVector3D max = value.value(); - static_cast(widgets_.at(0))->SetMaximum(max.x()); - static_cast(widgets_.at(1))->SetMaximum(max.y()); - static_cast(widgets_.at(2))->SetMaximum(max.z()); + static_cast(widgets_.at(0))->set_maximum(max.x()); + static_cast(widgets_.at(1))->set_maximum(max.y()); + static_cast(widgets_.at(2))->set_maximum(max.z()); break; } - case NodeValue::kVec4: { + case NodeValue::k_vec4: { QVector4D max = value.value(); - static_cast(widgets_.at(0))->SetMaximum(max.x()); - static_cast(widgets_.at(1))->SetMaximum(max.y()); - static_cast(widgets_.at(2))->SetMaximum(max.z()); - static_cast(widgets_.at(3))->SetMaximum(max.w()); + static_cast(widgets_.at(0))->set_maximum(max.x()); + static_cast(widgets_.at(1))->set_maximum(max.y()); + static_cast(widgets_.at(2))->set_maximum(max.z()); + static_cast(widgets_.at(3))->set_maximum(max.w()); break; } default: @@ -819,10 +819,10 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, for (int i = 0; i < tracks; i++) { static_cast(widgets_.at(i)) - ->SetOffset(offsets.at(i)); + ->set_offset(offsets.at(i)); } - UpdateWidgetValues(); + update_widget_values(); } else if (key.startsWith(QStringLiteral("color"))) { QColor c(value.toString()); @@ -832,13 +832,13 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, if (key.size() == 5) { // Set for all tracks for (int i = 0; i < tracks; i++) { - static_cast(widgets_.at(i))->SetColor(c); + static_cast(widgets_.at(i))->set_color(c); } } else { bool ok; int element = key.mid(5).toInt(&ok); if (ok && element >= 0 && element < tracks) { - static_cast(widgets_.at(element))->SetColor(c); + static_cast(widgets_.at(element))->set_color(c); } } @@ -846,13 +846,13 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, double d = value.toDouble(); for (int i = 0; i < widgets_.size(); i++) { static_cast(widgets_.at(i)) - ->SetDragMultiplier(d); + ->set_drag_multiplier(d); } } } // ComboBox strings changing - if (data_type == NodeValue::kCombo || data_type == NodeValue::kStrCombo) { + if (data_type == NodeValue::k_combo || data_type == NodeValue::k_str_combo) { if (key == QStringLiteral("combo_str")) { QComboBox *cb = static_cast(widgets_.first()); @@ -865,8 +865,8 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, QStringList items = value.toStringList(); QStringList values = - GetInnerInput().GetProperty("combo_value_str").toStringList(); - const bool use_value_data = (data_type == NodeValue::kStrCombo) && + get_inner_input().get_property("combo_value_str").toStringList(); + const bool use_value_data = (data_type == NodeValue::k_str_combo) && !values.isEmpty(); int index = 0; for (int i = 0; i < items.size(); ++i) { @@ -891,106 +891,106 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key, // In case the amount of items is LESS and the previous index cannot be set, NOW we trigger a re-cache since the // value has changed if (cb->currentIndex() != old_index) { - WidgetCallback(); + widget_callback(); } } } // Parameters for floats and vectors only - if (data_type == NodeValue::kFloat || + if (data_type == NodeValue::k_float || NodeValue::type_is_vector(data_type)) { if (key == QStringLiteral("view")) { FloatSlider::DisplayType display_type = static_cast(value.toInt()); foreach (QWidget *w, widgets_) { - static_cast(w)->SetDisplayType(display_type); + static_cast(w)->set_display_type(display_type); } } else if (key == QStringLiteral("decimalplaces")) { int dec_places = value.toInt(); foreach (QWidget *w, widgets_) { - static_cast(w)->SetDecimalPlaces(dec_places); + static_cast(w)->set_decimal_places(dec_places); } } else if (key == QStringLiteral("autotrim")) { bool autotrim = value.toBool(); foreach (QWidget *w, widgets_) { - static_cast(w)->SetAutoTrimDecimalPlaces( + static_cast(w)->set_auto_trim_decimal_places( autotrim); } } } - if (data_type == NodeValue::kRational) { + if (data_type == NodeValue::k_rational) { if (key == QStringLiteral("view")) { RationalSlider::DisplayType display_type = static_cast(value.toInt()); foreach (QWidget *w, widgets_) { - static_cast(w)->SetDisplayType(display_type); + static_cast(w)->set_display_type(display_type); } } else if (key == QStringLiteral("viewlock")) { bool locked = value.toBool(); foreach (QWidget *w, widgets_) { - static_cast(w)->SetLockDisplayType(locked); + static_cast(w)->set_lock_display_type(locked); } } } // Parameters for files - if (data_type == NodeValue::kFile) { + if (data_type == NodeValue::k_file) { FileField *ff = static_cast(widgets_.first()); if (key == QStringLiteral("placeholder")) { - ff->SetPlaceholder(value.toString()); + ff->set_placeholder(value.toString()); } else if (key == QStringLiteral("directory")) { - ff->SetDirectoryMode(value.toBool()); + ff->set_directory_mode(value.toBool()); } else if (key == QStringLiteral("filter")) { - ff->SetNameFilter(value.toString()); + ff->set_name_filter(value.toString()); } else if (key == QStringLiteral("lut_library") && value.toBool()) { // Offer the global LUT library directories as sidebar shortcuts in // the browse dialog QList sidebar_urls; - for (const QString &dir : LUTLibrary::GetDirectories()) { + for (const QString &dir : LUTLibrary::get_directories()) { sidebar_urls.append(QUrl::fromLocalFile(dir)); } if (!sidebar_urls.isEmpty()) { - ff->SetSidebarUrls(sidebar_urls); + ff->set_sidebar_urls(sidebar_urls); } } } // Parameters for text - if (data_type == NodeValue::kText) { + if (data_type == NodeValue::k_text) { NodeParamViewTextEdit *tex = static_cast(widgets_.first()); if (key == QStringLiteral("vieweronly")) { - tex->SetEditInViewerOnlyMode(value.toBool()); + tex->set_edit_in_viewer_only_mode(value.toBool()); } } } -void NodeParamViewWidgetBridge::InputDataTypeChanged(const QString &input, +void NodeParamViewWidgetBridge::input_data_type_changed(const QString &input, NodeValue::Type type) { - if (sender() == GetOuterInput().node() && - input == GetOuterInput().input()) { + if (sender() == get_outer_input().node() && + input == get_outer_input().input()) { // Delete all widgets qDeleteAll(widgets_); widgets_.clear(); // Create new widgets - CreateWidgets(); + create_widgets(); // Signal that widgets are new - emit WidgetsRecreated(GetOuterInput()); + emit widgets_recreated(get_outer_input()); } } -void NodeParamViewWidgetBridge::PropertyChanged(const QString &input, +void NodeParamViewWidgetBridge::property_changed(const QString &input, const QString &key, const QVariant &value) { @@ -1005,19 +1005,19 @@ void NodeParamViewWidgetBridge::PropertyChanged(const QString &input, } if (found) { - UpdateProperties(); + update_properties(); } } -void NodeParamViewWidgetBridge::UpdateProperties() +void NodeParamViewWidgetBridge::update_properties() { // Set properties from the last entry (the innermost input) to the first (the outermost) for (auto it = input_hierarchy_.crbegin(); it != input_hierarchy_.crend(); it++) { - auto input_properties = it->node()->GetInputProperties(it->input()); + auto input_properties = it->node()->get_input_properties(it->input()); for (auto jt = input_properties.cbegin(); jt != input_properties.cend(); jt++) { - SetProperty(jt.key(), jt.value()); + set_property(jt.key(), jt.value()); } } } diff --git a/app/widget/nodeparamview/nodeparamviewwidgetbridge.h b/app/widget/nodeparamview/nodeparamviewwidgetbridge.h index 9780b381d..dd970d114 100644 --- a/app/widget/nodeparamview/nodeparamviewwidgetbridge.h +++ b/app/widget/nodeparamview/nodeparamviewwidgetbridge.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEPARAMVIEWWIDGETBRIDGE_H -#define NODEPARAMVIEWWIDGETBRIDGE_H +#ifndef OAK_NODEPARAMVIEWWIDGETBRIDGE_H +#define OAK_NODEPARAMVIEWWIDGETBRIDGE_H #include @@ -48,61 +48,61 @@ public: } // Set the timebase of certain Timebased widgets - void SetTimebase(const rational &timebase); + void set_timebase(const Rational &timebase); signals: - void ArrayWidgetDoubleClicked(); + void array_widget_double_clicked(); - void WidgetsRecreated(const NodeInput &input); + void widgets_recreated(const NodeInput &input); - void RequestEditTextInViewer(); + void request_edit_text_in_viewer(); protected: virtual void TimeTargetDisconnectEvent(ViewerOutput *v) override; virtual void TimeTargetConnectEvent(ViewerOutput *v) override; private: - void CreateWidgets(); + void create_widgets(); - void SetInputValue(const QVariant &value, int track); + void set_input_value(const QVariant &value, int track); - void SetInputValueInternal(const QVariant &value, int track, + void set_input_value_internal(const QVariant &value, int track, MultiUndoCommand *command, bool insert_on_all_tracks_if_no_key); - void ProcessSlider(NumericSliderBase *slider, int slider_track, + void process_slider(NumericSliderBase *slider, int slider_track, const QVariant &value); - void ProcessSlider(NumericSliderBase *slider, const QVariant &value) + void process_slider(NumericSliderBase *slider, const QVariant &value) { - ProcessSlider(slider, widgets_.indexOf(slider), value); + process_slider(slider, widgets_.indexOf(slider), value); } - void SetProperty(const QString &key, const QVariant &value); + void set_property(const QString &key, const QVariant &value); - template void CreateSliders(int count, QWidget *parent); + template void create_sliders(int count, QWidget *parent); - void UpdateWidgetValues(); + void update_widget_values(); - rational GetCurrentTimeAsNodeTime() const; + Rational get_current_time_as_node_time() const; - const NodeInput &GetOuterInput() const + const NodeInput &get_outer_input() const { return input_hierarchy_.first(); } - const NodeInput &GetInnerInput() const + const NodeInput &get_inner_input() const { return input_hierarchy_.last(); } - QString GetCommandName() const; + QString get_command_name() const; - NodeValue::Type GetDataType() const + NodeValue::Type get_data_type() const { - return GetOuterInput().GetDataType(); + return get_outer_input().get_data_type(); } - void UpdateProperties(); + void update_properties(); QVector input_hierarchy_; @@ -113,16 +113,16 @@ private: NodeParamViewScrollBlocker scroll_filter_; private slots: - void WidgetCallback(); + void widget_callback(); - void InputValueChanged(const NodeInput &input, const TimeRange &range); + void input_value_changed(const NodeInput &input, const TimeRange &range); - void InputDataTypeChanged(const QString &input, NodeValue::Type type); + void input_data_type_changed(const QString &input, NodeValue::Type type); - void PropertyChanged(const QString &input, const QString &key, + void property_changed(const QString &input, const QString &key, const QVariant &value); }; } -#endif // NODEPARAMVIEWWIDGETBRIDGE_H +#endif // OAK_NODEPARAMVIEWWIDGETBRIDGE_H diff --git a/app/widget/nodetableview/nodetableview.cpp b/app/widget/nodetableview/nodetableview.cpp index 810ffadef..0dd4e74a2 100644 --- a/app/widget/nodetableview/nodetableview.cpp +++ b/app/widget/nodetableview/nodetableview.cpp @@ -37,27 +37,27 @@ NodeTableView::NodeTableView(QWidget *parent) tr("A/W") }); } -void NodeTableView::SelectNodes(const QVector &nodes) +void NodeTableView::select_nodes(const QVector &nodes) { foreach (Node *n, nodes) { QTreeWidgetItem *top_item = new QTreeWidgetItem(); - top_item->setText(0, n->GetLabelAndName()); + top_item->setText(0, n->get_label_and_name()); top_item->setFirstColumnSpanned(true); this->addTopLevelItem(top_item); top_level_item_map_.insert(n, top_item); } - SetTime(last_time_); + set_time(last_time_); } -void NodeTableView::DeselectNodes(const QVector &nodes) +void NodeTableView::deselect_nodes(const QVector &nodes) { foreach (Node *n, nodes) { delete top_level_item_map_.take(n); } } -void NodeTableView::SetTime(const rational &time) +void NodeTableView::set_time(const Rational &time) { last_time_ = time; @@ -70,7 +70,7 @@ void NodeTableView::SetTime(const rational &time) // Generate a value database for this node at this time NodeValueDatabase db = - traverser.GenerateDatabase(node, TimeRange(time, time)); + traverser.generate_database(node, TimeRange(time, time)); // Delete any children of this item that aren't in this database for (int j = 0; j < item->childCount(); j++) { @@ -85,7 +85,7 @@ void NodeTableView::SetTime(const rational &time) for (auto l = db.begin(); l != db.end(); l++) { const NodeValueTable &table = l.value(); - if (!node->HasInputWithID(l.key())) { + if (!node->has_input_with_id(l.key())) { // Filters out table entries that aren't inputs (like "global") continue; } @@ -103,49 +103,49 @@ void NodeTableView::SetTime(const rational &time) if (!input_item) { input_item = new QTreeWidgetItem(); - input_item->setText(0, node->GetInputName(l.key())); + input_item->setText(0, node->get_input_name(l.key())); input_item->setData(0, Qt::UserRole, l.key()); input_item->setFirstColumnSpanned(true); item->addChild(input_item); } // Create children if necessary - while (input_item->childCount() < table.Count()) { + while (input_item->childCount() < table.count()) { input_item->addChild(new QTreeWidgetItem()); } // Remove children if necessary - while (input_item->childCount() > table.Count()) { + while (input_item->childCount() > table.count()) { delete input_item->takeChild(input_item->childCount() - 1); } - for (int j = 0; j < table.Count(); j++) { - const NodeValue &value = table.at(table.Count() - 1 - j); + for (int j = 0; j < table.count(); j++) { + const NodeValue &value = table.at(table.count() - 1 - j); // Create item QTreeWidgetItem *sub_item = input_item->child(j); // Set data type name sub_item->setText( - 0, NodeValue::GetPrettyDataTypeName(value.type())); + 0, NodeValue::get_pretty_data_type_name(value.type())); // Determine source QString source_name; if (value.source()) { - source_name = value.source()->GetLabelAndName(); + source_name = value.source()->get_label_and_name(); } else { source_name = tr("(unknown)"); } sub_item->setText(1, source_name); switch (value.type()) { - case NodeValue::kVideoParams: - case NodeValue::kAudioParams: + case NodeValue::k_video_params: + case NodeValue::k_audio_params: // These types have no string representation break; - case NodeValue::kTexture: { + case NodeValue::k_texture: { // NodeTraverser puts video params in here - for (int k = 0; k < VideoParams::kRGBAChannelCount; k++) { + for (int k = 0; k < VideoParams::k_rgba_channel_count; k++) { this->setItemWidget(sub_item, 2 + k, new QCheckBox()); } break; @@ -153,7 +153,7 @@ void NodeTableView::SetTime(const rational &time) default: { QVector split_values = value.to_split_value(); for (int k = 0; k < split_values.size(); k++) { - sub_item->setText(2 + k, NodeValue::ValueToString( + sub_item->setText(2 + k, NodeValue::value_to_string( value.type(), split_values.at(k), true)); } diff --git a/app/widget/nodetableview/nodetableview.h b/app/widget/nodetableview/nodetableview.h index f89c50a64..eef1f0a91 100644 --- a/app/widget/nodetableview/nodetableview.h +++ b/app/widget/nodetableview/nodetableview.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODETABLEVIEW_H -#define NODETABLEVIEW_H +#ifndef OAK_NODETABLEVIEW_H +#define OAK_NODETABLEVIEW_H #include @@ -34,18 +34,18 @@ class NodeTableView : public QTreeWidget { public: NodeTableView(QWidget *parent = nullptr); - void SelectNodes(const QVector &nodes); + void select_nodes(const QVector &nodes); - void DeselectNodes(const QVector &nodes); + void deselect_nodes(const QVector &nodes); - void SetTime(const rational &time); + void set_time(const Rational &time); private: QMap top_level_item_map_; - rational last_time_; + Rational last_time_; }; } -#endif // NODETABLEVIEW_H +#endif // OAK_NODETABLEVIEW_H diff --git a/app/widget/nodetableview/nodetablewidget.h b/app/widget/nodetableview/nodetablewidget.h index 5384af5c0..0b1372667 100644 --- a/app/widget/nodetableview/nodetablewidget.h +++ b/app/widget/nodetableview/nodetablewidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODETABLEWIDGET_H -#define NODETABLEWIDGET_H +#ifndef OAK_NODETABLEWIDGET_H +#define OAK_NODETABLEWIDGET_H #include "nodetableview.h" #include "widget/timebased/timebasedwidget.h" @@ -32,20 +32,20 @@ class NodeTableWidget : public TimeBasedWidget { public: NodeTableWidget(QWidget *parent = nullptr); - void SelectNodes(const QVector &nodes) + void select_nodes(const QVector &nodes) { - view_->SelectNodes(nodes); + view_->select_nodes(nodes); } - void DeselectNodes(const QVector &nodes) + void deselect_nodes(const QVector &nodes) { - view_->DeselectNodes(nodes); + view_->deselect_nodes(nodes); } protected: - virtual void TimeChangedEvent(const rational &time) override + virtual void TimeChangedEvent(const Rational &time) override { - view_->SetTime(time); + view_->set_time(time); } private: @@ -54,4 +54,4 @@ private: } -#endif // NODETABLEWIDGET_H +#endif // OAK_NODETABLEWIDGET_H diff --git a/app/widget/nodetreeview/nodetreeview.cpp b/app/widget/nodetreeview/nodetreeview.cpp index 6e8a57e80..4243b3962 100644 --- a/app/widget/nodetreeview/nodetreeview.cpp +++ b/app/widget/nodetreeview/nodetreeview.cpp @@ -33,24 +33,24 @@ NodeTreeView::NodeTreeView(QWidget *parent) , checkboxes_enabled_(false) { connect(this, &NodeTreeView::itemChanged, this, - &NodeTreeView::ItemCheckStateChanged); + &NodeTreeView::item_check_state_changed); connect(this, &NodeTreeView::itemSelectionChanged, this, - &NodeTreeView::SelectionChanged); + &NodeTreeView::selection_changed); - Retranslate(); + retranslate(); } -bool NodeTreeView::IsNodeEnabled(Node *n) const +bool NodeTreeView::is_node_enabled(Node *n) const { return !disabled_nodes_.contains(n); } -bool NodeTreeView::IsInputEnabled(const NodeKeyframeTrackReference &ref) const +bool NodeTreeView::is_input_enabled(const NodeKeyframeTrackReference &ref) const { return !disabled_inputs_.contains(ref); } -void NodeTreeView::SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref, +void NodeTreeView::set_keyframe_track_color(const NodeKeyframeTrackReference &ref, const QColor &color) { // Insert into hashmap @@ -63,7 +63,7 @@ void NodeTreeView::SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref, } } -void NodeTreeView::SetNodes(const QVector &nodes) +void NodeTreeView::set_nodes(const QVector &nodes) { nodes_ = nodes; @@ -72,33 +72,33 @@ void NodeTreeView::SetNodes(const QVector &nodes) foreach (Node *n, nodes_) { QTreeWidgetItem *node_item = new QTreeWidgetItem(); - node_item->setText(0, n->Name()); + node_item->setText(0, n->name()); if (checkboxes_enabled_) { node_item->setCheckState( 0, disabled_nodes_.contains(n) ? Qt::Unchecked : Qt::Checked); } - node_item->setData(0, kItemType, kItemTypeNode); - node_item->setData(0, kItemNodePointer, QtUtils::PtrToValue(n)); + node_item->setData(0, k_item_type, k_item_type_node); + node_item->setData(0, k_item_node_pointer, QtUtils::ptr_to_value(n)); foreach (const QString &input, n->inputs()) { - if (n->IsInputHidden(input) || - (only_show_keyframable_ && !n->IsInputKeyframable(input))) { + if (n->is_input_hidden(input) || + (only_show_keyframable_ && !n->is_input_keyframable(input))) { continue; } QTreeWidgetItem *input_item = nullptr; - int arr_sz = n->InputArraySize(input); + int arr_sz = n->input_array_size(input); for (int i = -1; i < arr_sz; i++) { NodeInput input_ref(n, input, i); const QVector &key_tracks = - n->GetKeyframeTracks(input_ref); + n->get_keyframe_tracks(input_ref); int this_element_track; if (show_keyframe_tracks_as_rows_ && (key_tracks.size() == 1 || - (i == -1 && n->InputIsArray(input)))) { + (i == -1 && n->input_is_array(input)))) { this_element_track = 0; } else { this_element_track = -1; @@ -107,19 +107,19 @@ void NodeTreeView::SetNodes(const QVector &nodes) QTreeWidgetItem *element_item; if (input_item) { - element_item = CreateItem( + element_item = create_item( input_item, NodeKeyframeTrackReference( input_ref, this_element_track)); } else { - input_item = CreateItem(node_item, + input_item = create_item(node_item, NodeKeyframeTrackReference( input_ref, this_element_track)); element_item = input_item; } if (show_keyframe_tracks_as_rows_ && key_tracks.size() > 1 && - (!n->InputIsArray(input) || i >= 0)) { - CreateItemsForTracks(element_item, input_ref, + (!n->input_is_array(input) || i >= 0)) { + create_items_for_tracks(element_item, input_ref, key_tracks.size()); } } @@ -141,7 +141,7 @@ void NodeTreeView::changeEvent(QEvent *e) QTreeWidget::changeEvent(e); if (e->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } } @@ -149,19 +149,19 @@ void NodeTreeView::mouseDoubleClickEvent(QMouseEvent *e) { QTreeWidget::mouseDoubleClickEvent(e); - NodeKeyframeTrackReference ref = GetSelectedInput(); + NodeKeyframeTrackReference ref = get_selected_input(); - if (ref.input().IsValid()) { - emit InputDoubleClicked(ref); + if (ref.input().is_valid()) { + emit input_double_clicked(ref); } } -void NodeTreeView::Retranslate() +void NodeTreeView::retranslate() { setHeaderLabel(tr("Nodes")); } -NodeKeyframeTrackReference NodeTreeView::GetSelectedInput() +NodeKeyframeTrackReference NodeTreeView::get_selected_input() { QList sel = selectedItems(); @@ -170,12 +170,12 @@ NodeKeyframeTrackReference NodeTreeView::GetSelectedInput() if (!sel.isEmpty()) { QTreeWidgetItem *item = sel.first(); - if (item->data(0, kItemType).toInt() == kItemTypeInput) { - selected_ref = item->data(0, kItemInputReference) + if (item->data(0, k_item_type).toInt() == k_item_type_input) { + selected_ref = item->data(0, k_item_input_reference) .value(); } else { selected_ref = NodeKeyframeTrackReference(NodeInput( - QtUtils::ValueToPtr(item->data(0, kItemNodePointer)), + QtUtils::value_to_ptr(item->data(0, k_item_node_pointer)), QString())); } } @@ -183,16 +183,16 @@ NodeKeyframeTrackReference NodeTreeView::GetSelectedInput() return selected_ref; } -QTreeWidgetItem *NodeTreeView::CreateItem(QTreeWidgetItem *parent, +QTreeWidgetItem *NodeTreeView::create_item(QTreeWidgetItem *parent, const NodeKeyframeTrackReference &ref) { QTreeWidgetItem *input_item = new QTreeWidgetItem(parent); QString item_name; if (ref.track() == -1 || - NodeValue::get_number_of_keyframe_tracks(ref.input().GetDataType()) == + NodeValue::get_number_of_keyframe_tracks(ref.input().get_data_type()) == 1 || - (ref.input().IsArray() && ref.input().element() == -1)) { + (ref.input().is_array() && ref.input().element() == -1)) { if (ref.input().element() == -1) { item_name = ref.input().name(); } else { @@ -201,16 +201,16 @@ QTreeWidgetItem *NodeTreeView::CreateItem(QTreeWidgetItem *parent, } else { switch (ref.track()) { case 0: - item_name = UseRGBAOverXYZW(ref) ? tr("R") : tr("X"); + item_name = use_rgba_over_xyzw(ref) ? tr("R") : tr("X"); break; case 1: - item_name = UseRGBAOverXYZW(ref) ? tr("G") : tr("Y"); + item_name = use_rgba_over_xyzw(ref) ? tr("G") : tr("Y"); break; case 2: - item_name = UseRGBAOverXYZW(ref) ? tr("B") : tr("Z"); + item_name = use_rgba_over_xyzw(ref) ? tr("B") : tr("Z"); break; case 3: - item_name = UseRGBAOverXYZW(ref) ? tr("A") : tr("W"); + item_name = use_rgba_over_xyzw(ref) ? tr("A") : tr("W"); break; default: item_name = QString::number(ref.track()); @@ -222,8 +222,8 @@ QTreeWidgetItem *NodeTreeView::CreateItem(QTreeWidgetItem *parent, input_item->setCheckState( 0, disabled_inputs_.contains(ref) ? Qt::Unchecked : Qt::Checked); } - input_item->setData(0, kItemType, kItemTypeInput); - input_item->setData(0, kItemInputReference, QVariant::fromValue(ref)); + input_item->setData(0, k_item_type, k_item_type_input); + input_item->setData(0, k_item_input_reference, QVariant::fromValue(ref)); if (keyframe_colors_.contains(ref)) { input_item->setForeground(0, keyframe_colors_.value(ref)); @@ -234,59 +234,59 @@ QTreeWidgetItem *NodeTreeView::CreateItem(QTreeWidgetItem *parent, return input_item; } -void NodeTreeView::CreateItemsForTracks(QTreeWidgetItem *parent, +void NodeTreeView::create_items_for_tracks(QTreeWidgetItem *parent, const NodeInput &input, int track_count) { for (int j = 0; j < track_count; j++) { - CreateItem(parent, NodeKeyframeTrackReference(input, j)); + create_item(parent, NodeKeyframeTrackReference(input, j)); } } -bool NodeTreeView::UseRGBAOverXYZW(const NodeKeyframeTrackReference &ref) +bool NodeTreeView::use_rgba_over_xyzw(const NodeKeyframeTrackReference &ref) { - return ref.input().GetDataType() == NodeValue::kColor; + return ref.input().get_data_type() == NodeValue::k_color; } -void NodeTreeView::ItemCheckStateChanged(QTreeWidgetItem *item, int column) +void NodeTreeView::item_check_state_changed(QTreeWidgetItem *item, int column) { Q_UNUSED(column) - switch (item->data(0, kItemType).toInt()) { - case kItemTypeNode: { - Node *n = QtUtils::ValueToPtr(item->data(0, kItemNodePointer)); + switch (item->data(0, k_item_type).toInt()) { + case k_item_type_node: { + Node *n = QtUtils::value_to_ptr(item->data(0, k_item_node_pointer)); if (item->checkState(0) == Qt::Checked) { if (disabled_nodes_.contains(n)) { disabled_nodes_.removeOne(n); - emit NodeEnableChanged(n, true); + emit node_enable_changed(n, true); } } else if (!disabled_nodes_.contains(n)) { disabled_nodes_.append(n); - emit NodeEnableChanged(n, false); + emit node_enable_changed(n, false); } break; } - case kItemTypeInput: { - NodeKeyframeTrackReference i = item->data(0, kItemInputReference) + case k_item_type_input: { + NodeKeyframeTrackReference i = item->data(0, k_item_input_reference) .value(); if (item->checkState(0) == Qt::Checked) { if (disabled_inputs_.contains(i)) { disabled_inputs_.removeOne(i); - emit InputEnableChanged(i, true); + emit input_enable_changed(i, true); } } else if (!disabled_inputs_.contains(i)) { disabled_inputs_.append(i); - emit InputEnableChanged(i, false); + emit input_enable_changed(i, false); } break; } } } -void NodeTreeView::SelectionChanged() +void NodeTreeView::selection_changed() { - emit InputSelectionChanged(GetSelectedInput()); + emit input_selection_changed(get_selected_input()); } } diff --git a/app/widget/nodetreeview/nodetreeview.h b/app/widget/nodetreeview/nodetreeview.h index 577d66671..9d573647d 100644 --- a/app/widget/nodetreeview/nodetreeview.h +++ b/app/widget/nodetreeview/nodetreeview.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODETREEVIEW_H -#define NODETREEVIEW_H +#ifndef OAK_NODETREEVIEW_H +#define OAK_NODETREEVIEW_H #include @@ -34,39 +34,39 @@ class NodeTreeView : public QTreeWidget { public: NodeTreeView(QWidget *parent = nullptr); - bool IsNodeEnabled(Node *n) const; + bool is_node_enabled(Node *n) const; - bool IsInputEnabled(const NodeKeyframeTrackReference &ref) const; + bool is_input_enabled(const NodeKeyframeTrackReference &ref) const; - void SetCheckBoxesEnabled(bool e) + void set_check_boxes_enabled(bool e) { checkboxes_enabled_ = e; } - void SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref, + void set_keyframe_track_color(const NodeKeyframeTrackReference &ref, const QColor &color); - void SetOnlyShowKeyframable(bool e) + void set_only_show_keyframable(bool e) { only_show_keyframable_ = e; } - void SetShowKeyframeTracksAsRows(bool e) + void set_show_keyframe_tracks_as_rows(bool e) { show_keyframe_tracks_as_rows_ = e; } public slots: - void SetNodes(const QVector &nodes); + void set_nodes(const QVector &nodes); signals: - void NodeEnableChanged(Node *n, bool e); + void node_enable_changed(Node *n, bool e); - void InputEnableChanged(const NodeKeyframeTrackReference &ref, bool e); + void input_enable_changed(const NodeKeyframeTrackReference &ref, bool e); - void InputSelectionChanged(const NodeKeyframeTrackReference &ref); + void input_selection_changed(const NodeKeyframeTrackReference &ref); - void InputDoubleClicked(const NodeKeyframeTrackReference &ref); + void input_double_clicked(const NodeKeyframeTrackReference &ref); protected: virtual void changeEvent(QEvent *e) override; @@ -74,23 +74,23 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent *e) override; private: - void Retranslate(); + void retranslate(); - NodeKeyframeTrackReference GetSelectedInput(); + NodeKeyframeTrackReference get_selected_input(); - QTreeWidgetItem *CreateItem(QTreeWidgetItem *parent, + QTreeWidgetItem *create_item(QTreeWidgetItem *parent, const NodeKeyframeTrackReference &ref); - void CreateItemsForTracks(QTreeWidgetItem *parent, const NodeInput &input, + void create_items_for_tracks(QTreeWidgetItem *parent, const NodeInput &input, int track_count); - static bool UseRGBAOverXYZW(const NodeKeyframeTrackReference &ref); + static bool use_rgba_over_xyzw(const NodeKeyframeTrackReference &ref); - enum ItemType { kItemTypeNode, kItemTypeInput }; + enum ItemType { k_item_type_node, k_item_type_input }; - static const int kItemType = Qt::UserRole; - static const int kItemInputReference = Qt::UserRole + 1; - static const int kItemNodePointer = Qt::UserRole + 1; + static const int k_item_type = Qt::UserRole; + static const int k_item_input_reference = Qt::UserRole + 1; + static const int k_item_node_pointer = Qt::UserRole + 1; QVector nodes_; @@ -109,11 +109,11 @@ private: bool checkboxes_enabled_; private slots: - void ItemCheckStateChanged(QTreeWidgetItem *item, int column); + void item_check_state_changed(QTreeWidgetItem *item, int column); - void SelectionChanged(); + void selection_changed(); }; } -#endif // NODETREEVIEW_H +#endif // OAK_NODETREEVIEW_H diff --git a/app/widget/nodevaluetree/nodevaluetree.cpp b/app/widget/nodevaluetree/nodevaluetree.cpp index 5a408ca0f..9485813c1 100644 --- a/app/widget/nodevaluetree/nodevaluetree.cpp +++ b/app/widget/nodevaluetree/nodevaluetree.cpp @@ -37,31 +37,31 @@ NodeValueTree::NodeValueTree(QWidget *parent) p.setHorizontalStretch(1); setSizePolicy(p); - static const int kMinimumRows = 10; - setMinimumHeight(fontMetrics().height() * kMinimumRows); + static const int k_minimum_rows = 10; + setMinimumHeight(fontMetrics().height() * k_minimum_rows); - Retranslate(); + retranslate(); } -void NodeValueTree::SetNode(const NodeInput &input, const rational &time) +void NodeValueTree::set_node(const NodeInput &input, const Rational &time) { clear(); NodeTraverser traverser; - Node *connected_node = input.GetConnectedOutput(); + Node *connected_node = input.get_connected_output(); NodeValueTable table = - traverser.GenerateTable(connected_node, TimeRange(time, time)); + traverser.generate_table(connected_node, TimeRange(time, time)); - int index = traverser.GenerateRowValueElementIndex( + int index = traverser.generate_row_value_element_index( input.node(), input.input(), input.element(), &table); - for (int i = 0; i < table.Count(); i++) { + for (int i = 0; i < table.count(); i++) { const NodeValue &value = table.at(i); QTreeWidgetItem *item = new QTreeWidgetItem(this); - Node::ValueHint hint({ value.type() }, table.Count() - 1 - i, + Node::ValueHint hint({ value.type() }, table.count() - 1 - i, value.tag()); QRadioButton *radio = new QRadioButton(this); @@ -71,37 +71,37 @@ void NodeValueTree::SetNode(const NodeInput &input, const rational &time) radio->setChecked(true); } connect(radio, &QRadioButton::clicked, this, - &NodeValueTree::RadioButtonChecked); + &NodeValueTree::radio_button_checked); setItemWidget(item, 0, radio); - item->setText(1, NodeValue::GetPrettyDataTypeName(value.type())); - item->setText(2, NodeValue::ValueToString(value, false)); - item->setText(3, value.source()->GetLabelAndName()); + item->setText(1, NodeValue::get_pretty_data_type_name(value.type())); + item->setText(2, NodeValue::value_to_string(value, false)); + item->setText(3, value.source()->get_label_and_name()); } } void NodeValueTree::changeEvent(QEvent *event) { if (event->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } super::changeEvent(event); } -void NodeValueTree::Retranslate() +void NodeValueTree::retranslate() { setHeaderLabels({ QString(), tr("Type"), tr("Value"), tr("Source") }); } -void NodeValueTree::RadioButtonChecked(bool e) +void NodeValueTree::radio_button_checked(bool e) { if (e) { QRadioButton *btn = static_cast(sender()); Node::ValueHint hint = btn->property("hint").value(); NodeInput input = btn->property("input").value(); - input.node()->SetValueHintForInput(input.input(), hint, + input.node()->set_value_hint_for_input(input.input(), hint, input.element()); } } diff --git a/app/widget/nodevaluetree/nodevaluetree.h b/app/widget/nodevaluetree/nodevaluetree.h index 075f79472..d55a2e5f8 100644 --- a/app/widget/nodevaluetree/nodevaluetree.h +++ b/app/widget/nodevaluetree/nodevaluetree.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef NODEVALUETREE_H -#define NODEVALUETREE_H +#ifndef OAK_NODEVALUETREE_H +#define OAK_NODEVALUETREE_H #include #include @@ -32,18 +32,18 @@ class NodeValueTree : public QTreeWidget { public: NodeValueTree(QWidget *parent = nullptr); - void SetNode(const NodeInput &input, const rational &time); + void set_node(const NodeInput &input, const Rational &time); protected: virtual void changeEvent(QEvent *event) override; private: - void Retranslate(); + void retranslate(); private slots: - void RadioButtonChecked(bool e); + void radio_button_checked(bool e); }; } -#endif // NODEVALUETREE_H +#endif // OAK_NODEVALUETREE_H diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index 150eb8329..df7ee85be 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -46,8 +46,8 @@ namespace olive { -const double NodeView::kMinimumScale = 0.1; -const int NodeView::kMaximumContexts = 10; +const double NodeView::k_minimum_scale = 0.1; +const int NodeView::k_maximum_contexts = 10; NodeView::NodeView(QWidget *parent) : HandMovableView(parent) @@ -61,43 +61,43 @@ NodeView::NodeView(QWidget *parent) , show_in_param_editor_action_(nullptr) { setScene(&scene_); - SetDefaultDragMode(RubberBandDrag); + set_default_drag_mode(RubberBandDrag); setContextMenuPolicy(Qt::CustomContextMenu); setMouseTracking(true); setRenderHint(QPainter::Antialiasing); setViewportUpdateMode(FullViewportUpdate); connect(this, &NodeView::customContextMenuRequested, this, - &NodeView::ShowContextMenu); + &NodeView::show_context_menu); - ConnectSelectionChangedSignal(); + connect_selection_changed_signal(); - SetFlowDirection(NodeViewCommon::kLeftToRight); + set_flow_direction(NodeViewCommon::k_left_to_right); show_in_param_editor_action_ = new QAction(tr("Show in Parameter Editor"), this); - Menu::ConformItem(show_in_param_editor_action_, + Menu::conform_item(show_in_param_editor_action_, QStringLiteral("shownodeparams"), QKeySequence(tr("Shift+P"))); show_in_param_editor_action_->setShortcutContext(Qt::WindowShortcut); addAction(show_in_param_editor_action_); connect(show_in_param_editor_action_, &QAction::triggered, this, - &NodeView::ShowSelectedNodeInParamEditor); + &NodeView::show_selected_node_in_param_editor); - UpdateSceneBoundingRect(); + update_scene_bounding_rect(); connect(&scene_, &QGraphicsScene::changed, this, - &NodeView::UpdateSceneBoundingRect); + &NodeView::update_scene_bounding_rect); minimap_ = new NodeViewMiniMap(&scene_, this); minimap_->show(); - connect(minimap_, &NodeViewMiniMap::Resized, this, - &NodeView::RepositionMiniMap); - connect(minimap_, &NodeViewMiniMap::MoveToScenePoint, this, - &NodeView::MoveToScenePoint); + connect(minimap_, &NodeViewMiniMap::resized, this, + &NodeView::reposition_mini_map); + connect(minimap_, &NodeViewMiniMap::move_to_scene_point, this, + &NodeView::move_to_scene_point); connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, - &NodeView::UpdateViewportOnMiniMap); + &NodeView::update_viewport_on_mini_map); connect(verticalScrollBar(), &QScrollBar::valueChanged, this, - &NodeView::UpdateViewportOnMiniMap); + &NodeView::update_viewport_on_mini_map); viewport()->installEventFilter(this); } @@ -105,39 +105,39 @@ NodeView::NodeView(QWidget *parent) NodeView::~NodeView() { // Unset the current graph - ClearGraph(); + clear_graph(); } -void NodeView::SetContexts(const QVector &nodes) +void NodeView::set_contexts(const QVector &nodes) { if (overlay_view_) { - CloseOverlay(); + close_overlay(); } // Remove contexts that are no longer in the list foreach (Node *n, contexts_) { if (!nodes.contains(n)) { - RemoveContext(n); + remove_context(n); } } // Add contexts that are now in the list foreach (Node *n, nodes) { - if (scene_.context_map().size() >= kMaximumContexts) { + if (scene_.context_map().size() >= k_maximum_contexts) { break; } if (!contexts_.contains(n)) { - AddContext(n); + add_context(n); } } contexts_ = nodes; - CenterOnItemsBoundingRect(); + center_on_items_bounding_rect(); } -void NodeView::CloseContextsBelongingToProject(Project *project) +void NodeView::close_contexts_belonging_to_project(Project *project) { QVector new_contexts = contexts_; @@ -149,42 +149,42 @@ void NodeView::CloseContextsBelongingToProject(Project *project) } } - SetContexts(new_contexts); + set_contexts(new_contexts); } -void NodeView::ClearGraph() +void NodeView::clear_graph() { - SetContexts(QVector()); + set_contexts(QVector()); } -void NodeView::DeleteSelected() +void NodeView::delete_selected() { NodeViewDeleteCommand *command = new NodeViewDeleteCommand(); int count = 0; foreach (NodeViewContext *ctx, scene_.context_map()) { - count += ctx->DeleteSelected(command); + count += ctx->delete_selected(command); } Core::instance()->undo_stack()->push(command, tr("Deleted %1 Node(s)").arg(count)); } -void NodeView::SelectAll() +void NodeView::select_all() { // Optimization: rather than respond to every single item being selected, ignore the signal and // then handle them all at the end. - DisconnectSelectionChangedSignal(); + disconnect_selection_changed_signal(); - scene_.SelectAll(); + scene_.select_all(); - ConnectSelectionChangedSignal(); + connect_selection_changed_signal(); - UpdateSelectionCache(); + update_selection_cache(); } -void NodeView::DeselectAll() +void NodeView::deselect_all() { if (selected_nodes_.isEmpty()) { return; @@ -192,35 +192,35 @@ void NodeView::DeselectAll() // Optimization: rather than respond to every single item being selected, ignore the signal and // then handle them all at the end. - DisconnectSelectionChangedSignal(); + disconnect_selection_changed_signal(); - scene_.DeselectAll(); + scene_.deselect_all(); - ConnectSelectionChangedSignal(); + connect_selection_changed_signal(); // Just emit all the nodes that are currently selected as no longer selected - emit NodesDeselected(selected_nodes_); + emit nodes_deselected(selected_nodes_); selected_nodes_.clear(); - emit NodeSelectionChanged(selected_nodes_); - emit NodeSelectionChangedWithContexts(QVector()); + emit node_selection_changed(selected_nodes_); + emit node_selection_changed_with_contexts(QVector()); } -void NodeView::Select(const QVector &nodes, +void NodeView::select(const QVector &nodes, bool center_view_on_item) { // Optimization: rather than respond to every single item being selected, ignore the signal and // then handle them all at the end. - DisconnectSelectionChangedSignal(); + disconnect_selection_changed_signal(); QVector deselections = selected_nodes_; QVector new_selections; - scene_.DeselectAll(); + scene_.deselect_all(); foreach (const Node::ContextPair &p, nodes) { NodeViewContext *ctx = scene_.context_map().value(p.context); if (ctx) { - NodeViewItem *item = ctx->GetItemFromMap(p.node); + NodeViewItem *item = ctx->get_item_from_map(p.node); if (item) { item->setSelected(true); } @@ -229,19 +229,19 @@ void NodeView::Select(const QVector &nodes, // Center on something if (center_view_on_item && !nodes.isEmpty()) { - QMetaObject::invokeMethod(this, "CenterOnNode", Qt::QueuedConnection, + QMetaObject::invokeMethod(this, "center_on_node", Qt::QueuedConnection, OLIVE_NS_ARG(Node *, nodes.first().node)); } - ConnectSelectionChangedSignal(); + connect_selection_changed_signal(); // Don't signal when this function was likely triggered from another widget's signal anyway dont_emit_selection_signals_ = true; - UpdateSelectionCache(); + update_selection_cache(); dont_emit_selection_signals_ = false; } -void NodeView::CopySelected(bool cut) +void NodeView::copy_selected(bool cut) { if (selected_nodes_.isEmpty()) { return; @@ -250,16 +250,16 @@ void NodeView::CopySelected(bool cut) QString copy_str; QXmlStreamWriter writer(©_str); - ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyNodes); - sdata.SetOnlySerializeNodesAndResolveGroups(selected_nodes_); + ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_nodes); + sdata.set_only_serialize_nodes_and_resolve_groups(selected_nodes_); ProjectSerializer::SerializedProperties properties; for (Node *n : selected_nodes_) { - NodeViewItem *item = GetAssumedItemForSelectedNode(n); + NodeViewItem *item = get_assumed_item_for_selected_node(n); if (item) { - Node::Position pos = item->GetNodePositionData(); + Node::Position pos = item->get_node_position_data(); properties[n][QStringLiteral("x")] = QString::number(pos.position.x()); @@ -270,33 +270,33 @@ void NodeView::CopySelected(bool cut) } } - sdata.SetProperties(properties); + sdata.set_properties(properties); - ProjectSerializer::Save(&writer, sdata); + ProjectSerializer::save(&writer, sdata); - Core::CopyStringToClipboard(copy_str); + Core::copy_string_to_clipboard(copy_str); if (cut) { - DeleteSelected(); + delete_selected(); } } -void NodeView::Paste() +void NodeView::paste() { if (contexts_.isEmpty()) { return; } ProjectSerializer::Result res = - ProjectSerializer::Paste(ProjectSerializer::kOnlyNodes); - if (res.GetLoadData().nodes.isEmpty()) { + ProjectSerializer::paste(ProjectSerializer::k_only_nodes); + if (res.get_load_data().nodes.isEmpty()) { return; } Node::PositionMap map; - for (auto it = res.GetLoadData().properties.cbegin(); - it != res.GetLoadData().properties.cend(); it++) { + for (auto it = res.get_load_data().properties.cbegin(); + it != res.get_load_data().properties.cend(); it++) { Node::Position pos; const QMap &node_props = it.value(); @@ -307,10 +307,10 @@ void NodeView::Paste() map.insert(it.key(), pos); } - PostPaste(res.GetLoadData().nodes, map); + post_paste(res.get_load_data().nodes, map); } -void NodeView::Duplicate() +void NodeView::duplicate() { if (!selected_nodes_.isEmpty()) { QVector selected = selected_nodes_; @@ -324,8 +324,8 @@ void NodeView::Duplicate() new_nodes[i] = selected.at(i)->copy(); if (NodeGroup *g = dynamic_cast(selected.at(i))) { - for (auto it = g->GetContextPositions().cbegin(); - it != g->GetContextPositions().cend(); it++) { + for (auto it = g->get_context_positions().cbegin(); + it != g->get_context_positions().cend(); it++) { if (!selected.contains(it.key())) { // This should automatically recurse if this is a group inside a group selected.append(it.key()); @@ -341,49 +341,49 @@ void NodeView::Duplicate() Node *copy = new_nodes.at(i); Node::Position pos; - if (GetAssumedPositionForSelectedNode(og, &pos)) { + if (get_assumed_position_for_selected_node(og, &pos)) { map.insert(copy, pos); } - for (auto it = og->GetContextPositions().cbegin(); - it != og->GetContextPositions().cend(); it++) { + for (auto it = og->get_context_positions().cbegin(); + it != og->get_context_positions().cend(); it++) { Node *child_og = it.key(); int child_index = selected.indexOf(child_og); if (child_index != -1) { Node *child_copy = new_nodes.at(child_index); - copy->SetNodePositionInContext(child_copy, it.value()); + copy->set_node_position_in_context(child_copy, it.value()); } } if (NodeGroup *src_group = dynamic_cast(og)) { NodeGroup *dst_group = static_cast(copy); - for (auto it = src_group->GetInputPassthroughs().cbegin(); - it != src_group->GetInputPassthroughs().cend(); it++) { + for (auto it = src_group->get_input_passthroughs().cbegin(); + it != src_group->get_input_passthroughs().cend(); it++) { NodeInput input = it->second; input.set_node( new_nodes.at(selected.indexOf(input.node()))); - dst_group->AddInputPassthrough(input, it->first); + dst_group->add_input_passthrough(input, it->first); } - dst_group->SetOutputPassthrough(new_nodes.at( - selected.indexOf(src_group->GetOutputPassthrough()))); + dst_group->set_output_passthrough(new_nodes.at( + selected.indexOf(src_group->get_output_passthrough()))); } - Node::CopyInputs(selected.at(i), new_nodes.at(i), false); + Node::copy_inputs(selected.at(i), new_nodes.at(i), false); } // Copy connections - Node::CopyDependencyGraph(selected, new_nodes, nullptr); + Node::copy_dependency_graph(selected, new_nodes, nullptr); // Set root level context positions and attach to - PostPaste(new_nodes, map); + post_paste(new_nodes, map); } } -void NodeView::SetColorLabel(int index) +void NodeView::set_color_label(int index) { MultiUndoCommand *command = new MultiUndoCommand(); @@ -395,14 +395,14 @@ void NodeView::SetColorLabel(int index) command, tr("Set Color of %1 Node(s)").arg(selected_nodes_.size())); } -void NodeView::ZoomIn() +void NodeView::zoom_in() { - ZoomFromKeyboard(1.25); + zoom_from_keyboard(1.25); } -void NodeView::ZoomOut() +void NodeView::zoom_out() { - ZoomFromKeyboard(0.8); + zoom_from_keyboard(0.8); } void NodeView::keyPressEvent(QKeyEvent *event) @@ -415,9 +415,9 @@ void NodeView::keyPressEvent(QKeyEvent *event) MultiUndoCommand *pos_command = new MultiUndoCommand(); for (Node *n : qAsConst(selected_nodes_)) { for (Node *context : qAsConst(contexts_)) { - if (context->ContextContainsNode(n)) { + if (context->context_contains_node(n)) { Node::Position old_pos = - context->GetNodePositionInContext(n); + context->get_node_position_in_context(n); // Determine one pixel in scene units double movement_amt = 1.0 / scale_; @@ -440,8 +440,8 @@ void NodeView::keyPressEvent(QKeyEvent *event) } // Translate from screen units into node units - node_movement = NodeViewItem::ScreenToNodePoint( - node_movement, scene_.GetFlowDirection()); + node_movement = NodeViewItem::screen_to_node_point( + node_movement, scene_.get_flow_direction()); // Move command pos_command->add_child(new NodeSetPositionCommand( @@ -455,11 +455,11 @@ void NodeView::keyPressEvent(QKeyEvent *event) } case Qt::Key_Escape: if (!attached_items_.isEmpty()) { - DetachItemsFromCursor(); + detach_items_from_cursor(); break; } - emit EscPressed(); + emit esc_pressed(); /* fall through */ default: @@ -471,7 +471,7 @@ void NodeView::keyPressEvent(QKeyEvent *event) void NodeView::mousePressEvent(QMouseEvent *event) { // Handle mouse press event - if (HandPress(event)) + if (hand_press(event)) return; // Get the item that the user clicked on, if any @@ -481,22 +481,22 @@ void NodeView::mousePressEvent(QMouseEvent *event) // Sane defaults create_edge_already_exists_ = false; create_edge_from_output_ = true; - create_edge_input_.Reset(); + create_edge_input_.reset(); if (event->modifiers() & Qt::ControlModifier) { NodeViewItem *mouse_item = dynamic_cast(item); if (mouse_item) { - if (mouse_item->IsOutputItem()) { + if (mouse_item->is_output_item()) { create_edge_output_item_ = mouse_item; } else { create_edge_input_item_ = mouse_item; - create_edge_input_ = mouse_item->GetInput(); + create_edge_input_ = mouse_item->get_input(); create_edge_from_output_ = false; } // Highlight start item for better user experience - mouse_item->SetHighlighted(true); + mouse_item->set_highlighted(true); } } @@ -507,7 +507,7 @@ void NodeView::mousePressEvent(QMouseEvent *event) NodeViewItem *attached = static_cast(connector->parentItem()); - if (connector->IsOutput()) { + if (connector->is_output()) { create_edge_output_item_ = attached; } else { create_edge_input_item_ = attached; @@ -521,7 +521,7 @@ void NodeView::mousePressEvent(QMouseEvent *event) } else { create_edge_from_output_ = false; create_edge_input_ = - create_edge_input_item_->GetInput(); + create_edge_input_item_->get_input(); } } } @@ -531,13 +531,13 @@ void NodeView::mousePressEvent(QMouseEvent *event) !create_edge_already_exists_) { // Create a new edge from this output create_edge_ = new NodeViewEdge(); - create_edge_->SetCurved(scene_.GetEdgesAreCurved()); + create_edge_->set_curved(scene_.get_edges_are_curved()); // Add edge to scene scene_.addItem(create_edge_); // Position edge to mouse cursor - PositionNewEdge(event->pos()); + position_new_edge(event->pos()); return; } } @@ -563,22 +563,22 @@ void NodeView::mousePressEvent(QMouseEvent *event) } // For any selected item, store its position in case the user is dragging it somewhere else - auto selected_items = scene_.GetSelectedItems(); + auto selected_items = scene_.get_selected_items(); foreach (NodeViewItem *i, selected_items) { // Ignore items attached to the cursor - if (!IsItemAttachedToCursor(i)) { - dragging_items_.insert(i, i->GetNodePosition()); + if (!is_item_attached_to_cursor(i)) { + dragging_items_.insert(i, i->get_node_position()); } } } void NodeView::mouseMoveEvent(QMouseEvent *event) { - if (HandMove(event)) + if (hand_move(event)) return; if (create_edge_) { - PositionNewEdge(event->pos()); + position_new_edge(event->pos()); return; } @@ -588,17 +588,17 @@ void NodeView::mouseMoveEvent(QMouseEvent *event) // See if there are any items attached if (!attached_items_.isEmpty()) { - ProcessMovingAttachedNodes(event->pos()); + process_moving_attached_nodes(event->pos()); } } void NodeView::mouseReleaseEvent(QMouseEvent *event) { - if (HandRelease(event)) + if (hand_release(event)) return; if (create_edge_) { - EndEdgeDrag(); + end_edge_drag(); } MultiUndoCommand *command = new MultiUndoCommand(); @@ -609,10 +609,10 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event) bool had_attached_items = !attached_items_.isEmpty(); if (!attached_items_.isEmpty()) { - select_context = GetContextAtMousePos(event->pos()); + select_context = get_context_at_mouse_pos(event->pos()); if (select_context) { - select_nodes = ProcessDroppingAttachedNodes(command, select_context, + select_nodes = process_dropping_attached_nodes(command, select_context, event->pos()); } else { QToolTip::showText(QCursor::pos(), @@ -630,10 +630,10 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event) if (!i) { continue; } - QPointF current_pos = i->GetNodePosition(); + QPointF current_pos = i->get_node_position(); if (dragging_items_.value(i) != current_pos) { command->add_child(new NodeSetPositionCommand( - i->GetNode(), i->GetContext(), current_pos)); + i->get_node(), i->get_context(), current_pos)); } } @@ -647,8 +647,8 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event) } if (select_context) { - DeselectAll(); - scene_.context_map().value(select_context)->Select(select_nodes); + deselect_all(); + scene_.context_map().value(select_context)->select(select_nodes); } } @@ -660,7 +660,7 @@ void NodeView::mouseDoubleClickEvent(QMouseEvent *event) NodeViewItem *item_at_cursor = dynamic_cast(itemAt(event->pos())); if (item_at_cursor) { - item_at_cursor->ToggleExpanded(); + item_at_cursor->toggle_expanded(); } } } @@ -674,8 +674,8 @@ void NodeView::dragEnterEvent(QDragEnterEvent *event) QStringList mime_fmts = event->mimeData()->formats(); - if (mime_fmts.contains(Project::kItemMimeType)) { - QByteArray model_data = event->mimeData()->data(Project::kItemMimeType); + if (mime_fmts.contains(Project::k_item_mime_type)) { + QByteArray model_data = event->mimeData()->data(Project::k_item_mime_type); QDataStream stream(&model_data, QIODevice::ReadOnly); // Variables to deserialize into @@ -695,8 +695,8 @@ void NodeView::dragEnterEvent(QDragEnterEvent *event) NodeViewItem *new_item; new_item = new NodeViewItem(f, nullptr); - new_item->SetFlowDirection(scene_.GetFlowDirection()); - new_item->SetNodePosition(QPointF(0, y)); + new_item->set_flow_direction(scene_.get_flow_direction()); + new_item->set_node_position(QPointF(0, y)); y++; scene_.addItem(new_item); @@ -707,7 +707,7 @@ void NodeView::dragEnterEvent(QDragEnterEvent *event) if (new_attached.empty()) { event->ignore(); } else { - SetAttachedItems(new_attached); + set_attached_items(new_attached); event->accept(); } @@ -719,9 +719,9 @@ void NodeView::dragMoveEvent(QDragMoveEvent *event) if (attached_items_.empty()) { event->ignore(); } else { - ProcessMovingAttachedNodes(event->pos()); + process_moving_attached_nodes(event->pos()); - if (GetContextAtMousePos(event->pos())) { + if (get_context_at_mouse_pos(event->pos())) { event->accept(); } else { event->ignore(); @@ -731,19 +731,19 @@ void NodeView::dragMoveEvent(QDragMoveEvent *event) void NodeView::dropEvent(QDropEvent *event) { - if (Node *drop_ctx = GetContextAtMousePos(event->pos())) { + if (Node *drop_ctx = get_context_at_mouse_pos(event->pos())) { MultiUndoCommand *command = new MultiUndoCommand(); QVector select_nodes = - ProcessDroppingAttachedNodes(command, drop_ctx, event->pos()); + process_dropping_attached_nodes(command, drop_ctx, event->pos()); Core::instance()->undo_stack()->push( command, tr("Dropped %1 Node(s)").arg(select_nodes.size())); - DeselectAll(); - scene_.context_map().value(drop_ctx)->Select(select_nodes); + deselect_all(); + scene_.context_map().value(drop_ctx)->select(select_nodes); event->accept(); } else { - DetachItemsFromCursor(false); + detach_items_from_cursor(false); event->ignore(); } } @@ -753,7 +753,7 @@ void NodeView::dragLeaveEvent(QDragLeaveEvent *event) if (attached_items_.empty()) { event->ignore(); } else { - DetachItemsFromCursor(false); + detach_items_from_cursor(false); event->accept(); } @@ -763,16 +763,16 @@ void NodeView::resizeEvent(QResizeEvent *event) { super::resizeEvent(event); - RepositionMiniMap(); + reposition_mini_map(); if (overlay_view_) { - ResizeOverlay(); + resize_overlay(); } } -void NodeView::UpdateSelectionCache() +void NodeView::update_selection_cache() { - QVector current_selection = scene_.GetSelectedItems(); + QVector current_selection = scene_.get_selected_items(); QVector selected; QVector deselected; @@ -782,13 +782,13 @@ void NodeView::UpdateSelectionCache() // Determine which nodes are newly selected for (int j = 0; j < current_selection.size(); j++) { NodeViewItem *i = current_selection.at(j); - Node *n = i->GetNode(); + Node *n = i->get_node(); if (!selected_nodes_.contains(n)) { selected.append(n); selected_nodes_.append(n); } - sel_with_ctx[j] = { n, i->GetContext() }; + sel_with_ctx[j] = { n, i->get_context() }; } // Determine which nodes are newly deselected @@ -801,7 +801,7 @@ void NodeView::UpdateSelectionCache() bool still_selected = false; foreach (NodeViewItem *i, current_selection) { - if (i->GetNode() == n) { + if (i->get_node() == n) { still_selected = true; break; } @@ -815,20 +815,20 @@ void NodeView::UpdateSelectionCache() } if (!deselected.isEmpty()) { - emit NodesDeselected(deselected); + emit nodes_deselected(deselected); } if (!selected.isEmpty()) { - emit NodesSelected(selected); + emit nodes_selected(selected); } if (!dont_emit_selection_signals_) { - emit NodeSelectionChanged(selected_nodes_); - emit NodeSelectionChangedWithContexts(sel_with_ctx); + emit node_selection_changed(selected_nodes_); + emit node_selection_changed_with_contexts(sel_with_ctx); } } -void NodeView::ShowContextMenu(const QPoint &pos) +void NodeView::show_context_menu(const QPoint &pos) { if (contexts_.isEmpty()) { return; @@ -836,11 +836,11 @@ void NodeView::ShowContextMenu(const QPoint &pos) Menu m; - MenuShared::instance()->AddItemsForEditMenu(&m, false); + MenuShared::instance()->add_items_for_edit_menu(&m, false); m.addSeparator(); - QVector selected = scene_.GetSelectedItems(); + QVector selected = scene_.get_selected_items(); NodeViewItem *item_under_cursor = dynamic_cast(itemAt(pos)); @@ -850,33 +850,33 @@ void NodeView::ShowContextMenu(const QPoint &pos) // operate on it. scene_.clearSelection(); item_under_cursor->setSelected(true); - selected = scene_.GetSelectedItems(); + selected = scene_.get_selected_items(); } if (item_under_cursor && !selected.isEmpty()) { // Grouping if (selected.size() == 1 && - dynamic_cast(selected.first()->GetNode())) { + dynamic_cast(selected.first()->get_node())) { QAction *ungroup_action = m.addAction(tr("Ungroup")); connect(ungroup_action, &QAction::triggered, this, - &NodeView::UngroupNodes); + &NodeView::ungroup_nodes); } else { QAction *group_action = m.addAction(tr("Group")); connect(group_action, &QAction::triggered, this, - &NodeView::GroupNodes); + &NodeView::group_nodes); } // Color menu - MenuShared::instance()->AddColorCodingMenu(&m); + MenuShared::instance()->add_color_coding_menu(&m); // Show in Viewer option for nodes based on Viewer if (ViewerOutput *viewer = - dynamic_cast(selected.first()->GetNode())) { + dynamic_cast(selected.first()->get_node())) { Q_UNUSED(viewer) m.addSeparator(); QAction *open_in_viewer_action = m.addAction(tr("Open in Viewer")); connect(open_in_viewer_action, &QAction::triggered, this, - &NodeView::OpenSelectedNodeInViewer); + &NodeView::open_selected_node_in_viewer); } m.addSeparator(); @@ -887,60 +887,60 @@ void NodeView::ShowContextMenu(const QPoint &pos) show_in_param_editor_action->setShortcut( show_in_param_editor_action_->shortcut()); connect(show_in_param_editor_action, &QAction::triggered, this, - &NodeView::ShowSelectedNodeInParamEditor); + &NodeView::show_selected_node_in_param_editor); // Properties QAction *properties_action = m.addAction(tr("P&roperties")); connect(properties_action, &QAction::triggered, this, - &NodeView::ShowNodeProperties); + &NodeView::show_node_properties); } else { QAction *curved_action = m.addAction(tr("Smooth Edges")); curved_action->setCheckable(true); - curved_action->setChecked(scene_.GetEdgesAreCurved()); + curved_action->setChecked(scene_.get_edges_are_curved()); connect(curved_action, &QAction::triggered, &scene_, - &NodeViewScene::SetEdgesAreCurved); + &NodeViewScene::set_edges_are_curved); m.addSeparator(); Menu *direction_menu = new Menu(tr("Direction"), &m); m.addMenu(direction_menu); - direction_menu->AddActionWithData(tr("Top to Bottom"), - NodeViewCommon::kTopToBottom, - scene_.GetFlowDirection()); + direction_menu->add_action_with_data(tr("Top to Bottom"), + NodeViewCommon::k_top_to_bottom, + scene_.get_flow_direction()); - direction_menu->AddActionWithData(tr("Bottom to Top"), - NodeViewCommon::kBottomToTop, - scene_.GetFlowDirection()); + direction_menu->add_action_with_data(tr("Bottom to Top"), + NodeViewCommon::k_bottom_to_top, + scene_.get_flow_direction()); - direction_menu->AddActionWithData(tr("Left to Right"), - NodeViewCommon::kLeftToRight, - scene_.GetFlowDirection()); + direction_menu->add_action_with_data(tr("Left to Right"), + NodeViewCommon::k_left_to_right, + scene_.get_flow_direction()); - direction_menu->AddActionWithData(tr("Right to Left"), - NodeViewCommon::kRightToLeft, - scene_.GetFlowDirection()); + direction_menu->add_action_with_data(tr("Right to Left"), + NodeViewCommon::k_right_to_left, + scene_.get_flow_direction()); connect(direction_menu, &Menu::triggered, this, - &NodeView::ContextMenuSetDirection); + &NodeView::context_menu_set_direction); m.addSeparator(); - Menu *add_menu = CreateAddMenu(&m); + Menu *add_menu = create_add_menu(&m); m.addMenu(add_menu); } m.exec(mapToGlobal(pos)); } -void NodeView::CreateNodeSlot(QAction *action) +void NodeView::create_node_slot(QAction *action) { Node *new_node = NodeFactory::CreateFromMenuAction(action); if (new_node) { NodeViewItem *new_item = new NodeViewItem(new_node, nullptr); - new_item->SetFlowDirection(scene_.GetFlowDirection()); + new_item->set_flow_direction(scene_.get_flow_direction()); scene_.addItem(new_item); QVector new_attached; @@ -948,34 +948,34 @@ void NodeView::CreateNodeSlot(QAction *action) new_attached.append({ new_item, new_node, QPointF(0, 0) }); if (NodeGroup *new_group = dynamic_cast(new_node)) { - for (auto it = new_group->GetContextPositions().cbegin(); - it != new_group->GetContextPositions().cend(); it++) { + for (auto it = new_group->get_context_positions().cbegin(); + it != new_group->get_context_positions().cend(); it++) { new_attached.append({ nullptr, it.key(), QPointF(0, 0) }); } } - SetAttachedItems(new_attached); + set_attached_items(new_attached); } } -void NodeView::ContextMenuSetDirection(QAction *action) +void NodeView::context_menu_set_direction(QAction *action) { - SetFlowDirection( + set_flow_direction( static_cast(action->data().toInt())); } -void NodeView::OpenSelectedNodeInViewer() +void NodeView::open_selected_node_in_viewer() { // Find first viewer in list of selected nodes and open it foreach (Node *n, selected_nodes_) { if (ViewerOutput *viewer = dynamic_cast(n)) { - Core::instance()->OpenNodeInViewer(viewer); + Core::instance()->open_node_in_viewer(viewer); break; } } } -void NodeView::UpdateSceneBoundingRect() +void NodeView::update_scene_bounding_rect() { // Get current items bounding rect QRectF r = scene_.itemsBoundingRect(); @@ -987,22 +987,22 @@ void NodeView::UpdateSceneBoundingRect() scene_.setSceneRect(r); } -void NodeView::CenterOnItemsBoundingRect() +void NodeView::center_on_items_bounding_rect() { centerOn(scene_.itemsBoundingRect().center()); } -void NodeView::CenterOnNode(Node *n) +void NodeView::center_on_node(Node *n) { foreach (NodeViewContext *ctx, scene_.context_map()) { - if (NodeViewItem *item = ctx->GetItemFromMap(n)) { + if (NodeViewItem *item = ctx->get_item_from_map(n)) { centerOn(item); break; } } } -void NodeView::RepositionMiniMap() +void NodeView::reposition_mini_map() { if (minimap_->isVisible()) { int margin = fontMetrics().height(); @@ -1020,32 +1020,32 @@ void NodeView::RepositionMiniMap() minimap_->move(w, h); - UpdateViewportOnMiniMap(); + update_viewport_on_mini_map(); } } -void NodeView::UpdateViewportOnMiniMap() +void NodeView::update_viewport_on_mini_map() { if (minimap_->isVisible()) { - minimap_->SetViewportRect(mapToScene(viewport()->rect())); + minimap_->set_viewport_rect(mapToScene(viewport()->rect())); } } -void NodeView::MoveToScenePoint(const QPointF &pos) +void NodeView::move_to_scene_point(const QPointF &pos) { centerOn(pos); } -void NodeView::NodeRemovedFromGraph() +void NodeView::node_removed_from_graph() { Node *context = static_cast(sender()); - RemoveContext(context); + remove_context(context); contexts_.removeOne(context); } -void NodeView::DetachItemsFromCursor(bool delete_nodes_too) +void NodeView::detach_items_from_cursor(bool delete_nodes_too) { foreach (const AttachedItem &ai, attached_items_) { delete ai.item; @@ -1059,12 +1059,12 @@ void NodeView::DetachItemsFromCursor(bool delete_nodes_too) attached_items_.clear(); } -void NodeView::SetFlowDirection(NodeViewCommon::FlowDirection dir) +void NodeView::set_flow_direction(NodeViewCommon::FlowDirection dir) { - scene_.SetFlowDirection(dir); + scene_.set_flow_direction(dir); } -void NodeView::MoveAttachedNodesToCursor(const QPoint &p) +void NodeView::move_attached_nodes_to_cursor(const QPoint &p) { QPointF item_pos = mapToScene(p); @@ -1075,14 +1075,14 @@ void NodeView::MoveAttachedNodesToCursor(const QPoint &p) } } -void NodeView::ProcessMovingAttachedNodes(const QPoint &pos) +void NodeView::process_moving_attached_nodes(const QPoint &pos) { // Move those items to the cursor - MoveAttachedNodesToCursor(pos); + move_attached_nodes_to_cursor(pos); // See if the user clicked on an edge (only when dropping single nodes) if (attached_items_.size() == 1) { - Node *attached_node = attached_items_.first().item->GetNode(); + Node *attached_node = attached_items_.first().item->get_node(); QRect edge_detect_rect(pos, pos); @@ -1099,32 +1099,32 @@ void NodeView::ProcessMovingAttachedNodes(const QPoint &pos) new_drop_edge = dynamic_cast(item); if (new_drop_edge) { - drop_input_.Reset(); + drop_input_.reset(); NodeValue::Type drop_edge_data_type = - new_drop_edge->input().GetDataType(); + new_drop_edge->input().get_data_type(); // Determine best input to connect to our new node - if (attached_node->GetEffectInput().IsValid()) { + if (attached_node->get_effect_input().is_valid()) { // If node specifies an effect input, use that immediately - drop_input_ = attached_node->GetEffectInput(); + drop_input_ = attached_node->get_effect_input(); } else { // Otherwise, we may have to iterate to find a valid one for (const QString &input : attached_node->inputs()) { - if (input == Node::kEnabledInput) { + if (input == Node::k_enabled_input) { // Ignore enabled input continue; } NodeInput i(attached_node, input); - if (attached_node->IsInputConnectable(input)) { - if (attached_node->GetInputDataType(input) == + if (attached_node->is_input_connectable(input)) { + if (attached_node->get_input_data_type(input) == drop_edge_data_type) { // Found exactly the type we're looking for, set and break this loop drop_input_ = i; break; - } else if (!drop_input_.IsValid()) { + } else if (!drop_input_.is_valid()) { // Default to first connectable input drop_input_ = i; } @@ -1132,12 +1132,12 @@ void NodeView::ProcessMovingAttachedNodes(const QPoint &pos) } } - if (attached_node->InputsFrom(new_drop_edge->input().node(), + if (attached_node->inputs_from(new_drop_edge->input().node(), true)) { - drop_input_.Reset(); + drop_input_.reset(); } - if (drop_input_.IsValid()) { + if (drop_input_.is_valid()) { break; } else { new_drop_edge = nullptr; @@ -1147,20 +1147,20 @@ void NodeView::ProcessMovingAttachedNodes(const QPoint &pos) if (drop_edge_ != new_drop_edge) { if (drop_edge_) { - drop_edge_->SetHighlighted(false); + drop_edge_->set_highlighted(false); } drop_edge_ = new_drop_edge; if (drop_edge_) { - drop_edge_->SetHighlighted(true); + drop_edge_->set_highlighted(true); } } } } QVector -NodeView::ProcessDroppingAttachedNodes(MultiUndoCommand *command, +NodeView::process_dropping_attached_nodes(MultiUndoCommand *command, Node *select_context, const QPoint &pos) { QVector select_nodes; @@ -1171,9 +1171,9 @@ NodeView::ProcessDroppingAttachedNodes(MultiUndoCommand *command, for (int i = 0; i < attached.size(); i++) { const AttachedItem &ai = attached.at(i); - if (ai.node->InputsFrom(select_context, true)) { + if (ai.node->inputs_from(select_context, true)) { attached.removeAt(i); - } else if (select_context->ContextContainsNode(ai.node)) { + } else if (select_context->context_contains_node(ai.node)) { select_nodes.append(ai.node); attached.removeAt(i); } @@ -1187,7 +1187,7 @@ NodeView::ProcessDroppingAttachedNodes(MultiUndoCommand *command, if (ai.node->parent() != select_context->parent()) { add_command->add_child( new NodeAddCommand(select_context->parent(), ai.node)); - if (ai.node->IsItem() && !ai.node->folder()) { + if (ai.node->is_item() && !ai.node->folder()) { add_command->add_child(new FolderAddChild( select_context->parent()->root(), ai.node)); } @@ -1200,7 +1200,7 @@ NodeView::ProcessDroppingAttachedNodes(MultiUndoCommand *command, ai.node, select_context, scene_.context_map() .value(select_context) - ->MapScenePosToNodePosInContext(ai.item->pos()))); + ->map_scene_pos_to_node_pos_in_context(ai.item->pos()))); } } @@ -1219,7 +1219,7 @@ NodeView::ProcessDroppingAttachedNodes(MultiUndoCommand *command, Node *dropping_node = nullptr; foreach (const AttachedItem &ai, attached) { - if (ai.item && !ai.node->InputsFrom(select_context, true)) { + if (ai.item && !ai.node->inputs_from(select_context, true)) { dropping_node = ai.node; break; } @@ -1247,44 +1247,44 @@ NodeView::ProcessDroppingAttachedNodes(MultiUndoCommand *command, } } - DetachItemsFromCursor(false); + detach_items_from_cursor(false); return select_nodes; } -Node *NodeView::GetContextAtMousePos(const QPoint &p) +Node *NodeView::get_context_at_mouse_pos(const QPoint &p) { QList items_at_cursor = this->items(p); foreach (QGraphicsItem *i, items_at_cursor) { if (NodeViewContext *context_item = dynamic_cast(i)) { - return context_item->GetContext(); + return context_item->get_context(); } } return nullptr; } -void NodeView::ConnectSelectionChangedSignal() +void NodeView::connect_selection_changed_signal() { connect(&scene_, &QGraphicsScene::selectionChanged, this, - &NodeView::UpdateSelectionCache); + &NodeView::update_selection_cache); } -void NodeView::DisconnectSelectionChangedSignal() +void NodeView::disconnect_selection_changed_signal() { disconnect(&scene_, &QGraphicsScene::selectionChanged, this, - &NodeView::UpdateSelectionCache); + &NodeView::update_selection_cache); } -void NodeView::ZoomIntoCursorPosition(QWheelEvent *event, double multiplier, +void NodeView::zoom_into_cursor_position(QWheelEvent *event, double multiplier, const QPointF &cursor_pos) { Q_UNUSED(event) double test_scale = scale_ * multiplier; - if (test_scale > kMinimumScale) { + if (test_scale > k_minimum_scale) { int anchor_x = qRound(double(cursor_pos.x() + horizontalScrollBar()->value()) / scale_ * test_scale - @@ -1329,7 +1329,7 @@ void NodeView::changeEvent(QEvent *e) super::changeEvent(e); } -void NodeView::ZoomFromKeyboard(double multiplier) +void NodeView::zoom_from_keyboard(double multiplier) { QPoint cursor_pos = mapFromGlobal(QCursor::pos()); @@ -1338,28 +1338,28 @@ void NodeView::ZoomFromKeyboard(double multiplier) cursor_pos = QPoint(width() / 2, height() / 2); } - ZoomIntoCursorPosition(nullptr, multiplier, cursor_pos); + zoom_into_cursor_position(nullptr, multiplier, cursor_pos); } -void NodeView::ClearCreateEdgeInputIfNecessary() +void NodeView::clear_create_edge_input_if_necessary() { - if (create_edge_from_output_ && create_edge_input_.IsValid()) { - create_edge_input_.Reset(); + if (create_edge_from_output_ && create_edge_input_.is_valid()) { + create_edge_input_.reset(); } } -QPointF NodeView::GetEstimatedPositionForContext(NodeViewItem *item, +QPointF NodeView::get_estimated_position_for_context(NodeViewItem *item, Node *context) const { - return item->GetNodePosition() - context_offsets_.value(context); + return item->get_node_position() - context_offsets_.value(context); } -NodeViewItem *NodeView::GetAssumedItemForSelectedNode(Node *node) +NodeViewItem *NodeView::get_assumed_item_for_selected_node(Node *node) { // Try to find corresponding selected item foreach (NodeViewContext *ctx, scene_.context_map()) { - NodeViewItem *item = ctx->GetItemFromMap(node); - if (item && item->GetNode() == node && item->isSelected()) { + NodeViewItem *item = ctx->get_item_from_map(node); + if (item && item->get_node() == node && item->isSelected()) { // Good enough return item; } @@ -1368,26 +1368,26 @@ NodeViewItem *NodeView::GetAssumedItemForSelectedNode(Node *node) return nullptr; } -bool NodeView::GetAssumedPositionForSelectedNode(Node *node, +bool NodeView::get_assumed_position_for_selected_node(Node *node, Node::Position *pos) { - if (NodeViewItem *item = GetAssumedItemForSelectedNode(node)) { - *pos = item->GetNodePositionData(); + if (NodeViewItem *item = get_assumed_item_for_selected_node(node)) { + *pos = item->get_node_position_data(); return true; } else { return false; } } -Menu *NodeView::CreateAddMenu(Menu *parent) +Menu *NodeView::create_add_menu(Menu *parent) { - Menu *add_menu = NodeFactory::CreateMenu(parent); + Menu *add_menu = NodeFactory::create_menu(parent); add_menu->setTitle(tr("Add")); - connect(add_menu, &Menu::triggered, this, &NodeView::CreateNodeSlot); + connect(add_menu, &Menu::triggered, this, &NodeView::create_node_slot); return add_menu; } -void NodeView::PositionNewEdge(const QPoint &pos) +void NodeView::position_new_edge(const QPoint &pos) { // Determine scene coordinate QPointF scene_pt = mapToScene(pos); @@ -1403,7 +1403,7 @@ void NodeView::PositionNewEdge(const QPoint &pos) create_edge_output_item_; // Filter out connecting to self - if (item_at_cursor && item_at_cursor->GetNode() == source_item->GetNode()) { + if (item_at_cursor && item_at_cursor->get_node() == source_item->get_node()) { item_at_cursor = nullptr; } @@ -1415,7 +1415,7 @@ void NodeView::PositionNewEdge(const QPoint &pos) if (nvi->scene() == &scene_ && (nvi->contains(local_pt) || - (!nvi->IsOutputItem() && + (!nvi->is_output_item() && nvi->parentItem()->contains( nvi->parentItem()->mapFromScene(scene_pt)) && local_pt.y() > nvi->rect().bottom()))) { @@ -1429,34 +1429,34 @@ void NodeView::PositionNewEdge(const QPoint &pos) if (opposing_item && opposing_item->parentItem() == nvi) { opposing_item = nullptr; - ClearCreateEdgeInputIfNecessary(); + clear_create_edge_input_if_necessary(); } - CollapseItem(nvi); + collapse_item(nvi); } } create_edge_expanded_items_.resize(i + 1); // Expand item if possible - if (item_at_cursor && item_at_cursor->CanBeExpanded() && - !item_at_cursor->IsExpanded() && create_edge_from_output_) { - ExpandItem(item_at_cursor); + if (item_at_cursor && item_at_cursor->can_be_expanded() && + !item_at_cursor->is_expanded() && create_edge_from_output_) { + expand_item(item_at_cursor); create_edge_expanded_items_.append(item_at_cursor); } // Filter out connecting to a node that connects to us or an item of the same type if (item_at_cursor && - ((create_edge_from_output_ && source_item->GetNode()->InputsFrom( - item_at_cursor->GetNode(), true)) || - (!create_edge_from_output_ && item_at_cursor->GetNode()->InputsFrom( - source_item->GetNode(), true)) || - (create_edge_from_output_ == item_at_cursor->IsOutputItem()))) { + ((create_edge_from_output_ && source_item->get_node()->inputs_from( + item_at_cursor->get_node(), true)) || + (!create_edge_from_output_ && item_at_cursor->get_node()->inputs_from( + source_item->get_node(), true)) || + (create_edge_from_output_ == item_at_cursor->is_output_item()))) { item_at_cursor = nullptr; } // Filter out "output node" of the context, we assume users won't want to fetch the output of this if (item_at_cursor && !create_edge_from_output_ && - item_at_cursor->IsLabelledAsOutputOfContext()) { + item_at_cursor->is_labelled_as_output_of_context()) { item_at_cursor = nullptr; } @@ -1464,56 +1464,56 @@ void NodeView::PositionNewEdge(const QPoint &pos) if (item_at_cursor != opposing_item) { // If we had a destination active, disconnect from it since the item has changed if (opposing_item) { - opposing_item->SetHighlighted(false); + opposing_item->set_highlighted(false); opposing_item = nullptr; } // Clear cached input - ClearCreateEdgeInputIfNecessary(); + clear_create_edge_input_if_necessary(); // If this is an input and we're opposing_item = item_at_cursor; if (opposing_item) { - opposing_item->SetHighlighted(true); - if (!opposing_item->IsOutputItem()) { - create_edge_input_ = opposing_item->GetInput(); + opposing_item->set_highlighted(true); + if (!opposing_item->is_output_item()) { + create_edge_input_ = opposing_item->get_input(); } } } QPointF output_point = create_edge_output_item_ ? - create_edge_output_item_->GetOutputPoint() : + create_edge_output_item_->get_output_point() : scene_pt; - QPointF input_point = create_edge_input_.IsValid() ? - create_edge_input_item_->GetInputPoint() : + QPointF input_point = create_edge_input_.is_valid() ? + create_edge_input_item_->get_input_point() : scene_pt; - create_edge_->SetPoints(output_point, input_point); - create_edge_->SetConnected(create_edge_output_item_ && - create_edge_input_.IsValid()); + create_edge_->set_points(output_point, input_point); + create_edge_->set_connected(create_edge_output_item_ && + create_edge_input_.is_valid()); } -void NodeView::GroupNodes() +void NodeView::group_nodes() { // Get items - QVector items = scene_.GetSelectedItems(); + QVector items = scene_.get_selected_items(); if (items.isEmpty()) { return; } // Get node context - Node *context = items.first()->GetContext(); - QPointF avg_pos = items.first()->GetNodePosition(); + Node *context = items.first()->get_context(); + QPointF avg_pos = items.first()->get_node_position(); for (int i = 1; i < items.size(); i++) { - if (items.at(i)->GetContext() != context) { + if (items.at(i)->get_context() != context) { QMessageBox::critical( this, tr("Failed to group nodes"), tr("Nodes can only be grouped if they're in the same context.")); return; } - avg_pos += items.at(i)->GetNodePosition(); + avg_pos += items.at(i)->get_node_position(); } avg_pos /= items.size(); @@ -1526,18 +1526,18 @@ void NodeView::GroupNodes() // Add nodes to group Node *output_passthrough = nullptr; QVector nodes_to_group = selected_nodes_; - DeselectAll(); + deselect_all(); foreach (Node *n, nodes_to_group) { command->add_child( new NodeRemovePositionFromContextCommand(n, context)); command->add_child(new NodeSetPositionCommand( - n, group, context->GetNodePositionDataInContext(n))); + n, group, context->get_node_position_data_in_context(n))); for (auto it = n->inputs().cbegin(); it != n->inputs().cend(); it++) { NodeInput input(n, *it, -1); - if (!input.IsConnected() || - !nodes_to_group.contains(input.GetConnectedOutput())) { + if (!input.is_connected() || + !nodes_to_group.contains(input.get_connected_output())) { command->add_child( new NodeGroupAddInputPassthrough(group, input)); } @@ -1547,7 +1547,7 @@ void NodeView::GroupNodes() // Default to the first node we find that doesn't output to a node inside the group output_passthrough = nodes_to_group.first(); foreach (Node *potential_in, nodes_to_group) { - if (potential_in != n && !potential_in->InputsFrom(n, false)) { + if (potential_in != n && !potential_in->inputs_from(n, false)) { output_passthrough = n; break; } @@ -1564,22 +1564,22 @@ void NodeView::GroupNodes() command->add_child(new NodeSetPositionCommand(group, context, avg_pos)); // Do command - Core::instance()->LabelNodes({ group }, command); + Core::instance()->label_nodes({ group }, command); Core::instance()->undo_stack()->push(command, tr("Grouped Nodes")); } -void NodeView::UngroupNodes() +void NodeView::ungroup_nodes() { NodeViewItem *group_item = nullptr; - QVector items = scene_.GetSelectedItems(); + QVector items = scene_.get_selected_items(); if (items.isEmpty()) { return; } NodeGroup *group = nullptr; foreach (NodeViewItem *i, items) { - if ((group = dynamic_cast(i->GetNode()))) { + if ((group = dynamic_cast(i->get_node()))) { group_item = i; break; } @@ -1591,24 +1591,24 @@ void NodeView::UngroupNodes() MultiUndoCommand *command = new MultiUndoCommand(); - Node *context = group_item->GetContext(); + Node *context = group_item->get_context(); command->add_child( new NodeRemovePositionFromContextCommand(group, context)); command->add_child(new NodeRemoveAndDisconnectCommand(group)); - for (auto it = group->GetContextPositions().cbegin(); - it != group->GetContextPositions().cend(); it++) { + for (auto it = group->get_context_positions().cbegin(); + it != group->get_context_positions().cend(); it++) { command->add_child( new NodeRemovePositionFromContextCommand(it.key(), group)); command->add_child(new NodeSetPositionCommand( - it.key(), context, group->GetNodePositionDataInContext(it.key()))); + it.key(), context, group->get_node_position_data_in_context(it.key()))); } Core::instance()->undo_stack()->push(command, tr("Ungrouped Nodes")); } -void NodeView::ShowNodeProperties() +void NodeView::show_node_properties() { Node *first_node = selected_nodes_.first(); @@ -1618,23 +1618,23 @@ void NodeView::ShowNodeProperties() overlay_view_->show(); QPushButton *overlay_close_btn = new QPushButton(overlay_view_); - overlay_close_btn->setIcon(icon::Error); + overlay_close_btn->setIcon(icon::error); int offset = overlay_close_btn->sizeHint().width() / 2; overlay_close_btn->move(offset, offset); overlay_close_btn->show(); - connect(overlay_view_, &NodeView::NodesSelected, this, - &NodeView::NodesSelected); - connect(overlay_view_, &NodeView::NodesDeselected, this, - &NodeView::NodesDeselected); - connect(overlay_view_, &NodeView::NodeGroupOpened, this, - &NodeView::NodeGroupOpened); - connect(overlay_view_, &NodeView::NodeGroupClosed, this, - &NodeView::NodeGroupClosed); - connect(overlay_view_, &NodeView::EscPressed, this, - &NodeView::CloseOverlay); + connect(overlay_view_, &NodeView::nodes_selected, this, + &NodeView::nodes_selected); + connect(overlay_view_, &NodeView::nodes_deselected, this, + &NodeView::nodes_deselected); + connect(overlay_view_, &NodeView::node_group_opened, this, + &NodeView::node_group_opened); + connect(overlay_view_, &NodeView::node_group_closed, this, + &NodeView::node_group_closed); + connect(overlay_view_, &NodeView::esc_pressed, this, + &NodeView::close_overlay); connect(overlay_close_btn, &QPushButton::clicked, this, - &NodeView::CloseOverlay); + &NodeView::close_overlay); const QColor &bgcol = overlay_view_->palette().base().color(); overlay_view_->setStyleSheet( @@ -1647,27 +1647,27 @@ void NodeView::ShowNodeProperties() overlay_close_btn->setStyleSheet( QStringLiteral("background: transparent; border: none;")); } - overlay_view_->SetContexts({ group }); - ResizeOverlay(); + overlay_view_->set_contexts({ group }); + resize_overlay(); QMetaObject::invokeMethod(overlay_view_, - &NodeView::CenterOnItemsBoundingRect, + &NodeView::center_on_items_bounding_rect, Qt::QueuedConnection); overlay_view_->setFocus(); - emit NodesDeselected(selected_nodes_); - emit NodeSelectionChanged(QVector()); - emit NodeSelectionChangedWithContexts(QVector()); - overlay_view_->SelectAll(); + emit nodes_deselected(selected_nodes_); + emit node_selection_changed(QVector()); + emit node_selection_changed_with_contexts(QVector()); + overlay_view_->select_all(); - emit NodeGroupOpened(group); + emit node_group_opened(group); } else { - LabelSelectedNodes(); + label_selected_nodes(); } } -void NodeView::ShowSelectedNodeInParamEditor() +void NodeView::show_selected_node_in_param_editor() { - QVector selected = scene_.GetSelectedItems(); + QVector selected = scene_.get_selected_items(); if (selected.isEmpty()) { return; } @@ -1675,9 +1675,9 @@ void NodeView::ShowSelectedNodeInParamEditor() QVector selection_with_contexts; selection_with_contexts.reserve(selected.size()); foreach (NodeViewItem *item, selected) { - if (item && item->GetNode()) { + if (item && item->get_node()) { selection_with_contexts.append( - Node::ContextPair{ item->GetNode(), item->GetContext() }); + Node::ContextPair{ item->get_node(), item->get_context() }); } } @@ -1686,7 +1686,7 @@ void NodeView::ShowSelectedNodeInParamEditor() } if (PanelManager::instance()) { - if (PanelWidget *panel = PanelManager::instance()->GetPanelWithName( + if (PanelWidget *panel = PanelManager::instance()->get_panel_with_name( QStringLiteral("ParamPanel"))) { panel->show(); QMetaObject::invokeMethod(panel, &PanelWidget::raise, @@ -1701,22 +1701,22 @@ void NodeView::ShowSelectedNodeInParamEditor() } } - emit NodeSelectionChangedWithContexts(selection_with_contexts); + emit node_selection_changed_with_contexts(selection_with_contexts); } -void NodeView::LabelSelectedNodes() +void NodeView::label_selected_nodes() { - Core::instance()->LabelNodes(selected_nodes_); + Core::instance()->label_nodes(selected_nodes_); } -void NodeView::ItemAboutToBeDeleted(NodeViewItem *item) +void NodeView::item_about_to_be_deleted(NodeViewItem *item) { dragging_items_.remove(item); if (create_edge_) { // Item should be removed from scene, but not yet deleted, allowing a safe PositionNewEdge call // to disconnect - PositionNewEdge(mapFromGlobal(QCursor::pos())); + position_new_edge(mapFromGlobal(QCursor::pos())); QGraphicsItem *test = item; do { @@ -1729,40 +1729,40 @@ void NodeView::ItemAboutToBeDeleted(NodeViewItem *item) if (test == item) { // Cancel edge function - EndEdgeDrag(true); + end_edge_drag(true); } } } -void NodeView::CloseOverlay() +void NodeView::close_overlay() { if (overlay_view_->overlay_view_) { - overlay_view_->CloseOverlay(); + overlay_view_->close_overlay(); } overlay_view_->deleteLater(); overlay_view_ = nullptr; - emit NodeGroupClosed(); + emit node_group_closed(); } -void NodeView::AddContext(Node *n) +void NodeView::add_context(Node *n) { - NodeViewContext *ctx = scene_.AddContext(n); + NodeViewContext *ctx = scene_.add_context(n); - connect(ctx, &NodeViewContext::ItemAboutToBeDeleted, this, - &NodeView::ItemAboutToBeDeleted); + connect(ctx, &NodeViewContext::item_about_to_be_deleted, this, + &NodeView::item_about_to_be_deleted); - connect(n, &Node::RemovedFromGraph, this, &NodeView::NodeRemovedFromGraph); + connect(n, &Node::removed_from_graph, this, &NodeView::node_removed_from_graph); } -void NodeView::RemoveContext(Node *n) +void NodeView::remove_context(Node *n) { - scene_.RemoveContext(n); - disconnect(n, &Node::RemovedFromGraph, this, - &NodeView::NodeRemovedFromGraph); + scene_.remove_context(n); + disconnect(n, &Node::removed_from_graph, this, + &NodeView::node_removed_from_graph); } -bool NodeView::IsItemAttachedToCursor(NodeViewItem *item) const +bool NodeView::is_item_attached_to_cursor(NodeViewItem *item) const { foreach (const AttachedItem &ai, attached_items_) { if (ai.item == item) { @@ -1773,19 +1773,19 @@ bool NodeView::IsItemAttachedToCursor(NodeViewItem *item) const return false; } -void NodeView::ExpandItem(NodeViewItem *item) +void NodeView::expand_item(NodeViewItem *item) { - item->SetExpanded(true); + item->set_expanded(true); item->setZValue(100); } -void NodeView::CollapseItem(NodeViewItem *item) +void NodeView::collapse_item(NodeViewItem *item) { - item->SetExpanded(false); + item->set_expanded(false); item->setZValue(0); } -void NodeView::EndEdgeDrag(bool cancel) +void NodeView::end_edge_drag(bool cancel) { // Check if the edge was reconnected to the same place as before MultiUndoCommand *command = new MultiUndoCommand(); @@ -1812,49 +1812,49 @@ void NodeView::EndEdgeDrag(bool cancel) // Clear highlight if we set one if (create_edge_output_item_) { - create_edge_output_item_->SetHighlighted(false); + create_edge_output_item_->set_highlighted(false); } if (create_edge_input_item_) { - create_edge_input_item_->SetHighlighted(false); + create_edge_input_item_->set_highlighted(false); } QString command_name; NodeInput &creating_input = create_edge_input_; if (create_edge_output_item_ && create_edge_input_item_ && !cancel) { - if (creating_input.IsValid()) { + if (creating_input.is_valid()) { // Make connection if (!reconnected_to_itself) { - Node *creating_output = create_edge_output_item_->GetNode(); + Node *creating_output = create_edge_output_item_->get_node(); while (NodeGroup *output_group = dynamic_cast(creating_output)) { - creating_output = output_group->GetOutputPassthrough(); + creating_output = output_group->get_output_passthrough(); } while (NodeGroup *input_group = dynamic_cast(creating_input.node())) { creating_input = - input_group->GetInputFromID(creating_input.input()); + input_group->get_input_from_id(creating_input.input()); } - if (creating_input.IsConnected()) { + if (creating_input.is_connected()) { Node::OutputConnection existing_edge_to_remove = { - creating_input.GetConnectedOutput(), creating_input + creating_input.get_connected_output(), creating_input }; Node *already_connected_output = - creating_input.GetConnectedOutput(); + creating_input.get_connected_output(); NodeViewContext *ctx = - GetContextItemFromNodeItem(create_edge_input_item_); - if (ctx && !ctx->GetItemFromMap(already_connected_output)) { + get_context_item_from_node_item(create_edge_input_item_); + if (ctx && !ctx->get_item_from_map(already_connected_output)) { if (QMessageBox::warning( this, QString(), tr("Input \"%1\" is currently connected to node \"%2\", which is not visible in this context. " "By connecting this, that connection will be removed. Do you wish to continue?") .arg(creating_input.name(), already_connected_output - ->GetLabelAndName()), + ->get_label_and_name()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { cancel = true; @@ -1872,21 +1872,21 @@ void NodeView::EndEdgeDrag(bool cancel) command->add_child(new NodeEdgeAddCommand(creating_output, creating_input)); - command_name = Node::GetConnectCommandString( + command_name = Node::get_connect_command_string( creating_output, creating_input); // If the output is not in the input's context, add it now. We check the item rather than // the node itself, because sometimes a node may not be in the context but another node // representing it will be (e.g. groups) if (!scene_.context_map() - .value(create_edge_input_item_->GetContext()) - ->GetItemFromMap(creating_output)) { + .value(create_edge_input_item_->get_context()) + ->get_item_from_map(creating_output)) { command->add_child(new NodeSetPositionCommand( creating_output, - create_edge_input_item_->GetContext(), + create_edge_input_item_->get_context(), scene_.context_map() - .value(create_edge_input_item_->GetContext()) - ->MapScenePosToNodePosInContext( + .value(create_edge_input_item_->get_context()) + ->map_scene_pos_to_node_pos_in_context( create_edge_output_item_->scenePos()))); } } @@ -1894,21 +1894,21 @@ void NodeView::EndEdgeDrag(bool cancel) } } - creating_input.Reset(); + creating_input.reset(); create_edge_output_item_ = nullptr; create_edge_input_item_ = nullptr; // Collapse any items we expanded for (auto it = create_edge_expanded_items_.crbegin(); it != create_edge_expanded_items_.crend(); it++) { - CollapseItem(*it); + collapse_item(*it); } create_edge_expanded_items_.clear(); Core::instance()->undo_stack()->push(command, command_name); } -void NodeView::PostPaste(const QVector &new_nodes, +void NodeView::post_paste(const QVector &new_nodes, const Node::PositionMap &map) { QVector new_attached; @@ -1923,8 +1923,8 @@ void NodeView::PostPaste(const QVector &new_nodes, if (map.contains(node)) { new_item = new NodeViewItem(node, nullptr); - new_item->SetFlowDirection(scene_.GetFlowDirection()); - new_item->SetNodePosition(map.value(node)); + new_item->set_flow_direction(scene_.get_flow_direction()); + new_item->set_node_position(map.value(node)); scene_.addItem(new_item); if (!first_item) { @@ -1948,15 +1948,15 @@ void NodeView::PostPaste(const QVector &new_nodes, } } - SetAttachedItems(new_attached); + set_attached_items(new_attached); } -void NodeView::ResizeOverlay() +void NodeView::resize_overlay() { overlay_view_->resize(this->size()); } -NodeViewContext *NodeView::GetContextItemFromNodeItem(NodeViewItem *item) +NodeViewContext *NodeView::get_context_item_from_node_item(NodeViewItem *item) { QGraphicsItem *i = item; while ((i = i->parentItem())) { @@ -1967,15 +1967,15 @@ NodeViewContext *NodeView::GetContextItemFromNodeItem(NodeViewItem *item) return nullptr; } -void NodeView::SetAttachedItems(const QVector &items) +void NodeView::set_attached_items(const QVector &items) { // Detach anything currently attached - DetachItemsFromCursor(); + detach_items_from_cursor(); attached_items_ = items; // Move to cursor - MoveAttachedNodesToCursor(mapFromGlobal(QCursor::pos())); + move_attached_nodes_to_cursor(mapFromGlobal(QCursor::pos())); } } diff --git a/app/widget/nodeview/nodeview.h b/app/widget/nodeview/nodeview.h index 8b4ec47cb..052665915 100644 --- a/app/widget/nodeview/nodeview.h +++ b/app/widget/nodeview/nodeview.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEVIEW_H -#define NODEVIEW_H +#ifndef OAK_NODEVIEW_H +#define OAK_NODEVIEW_H #include #include @@ -50,85 +50,85 @@ public: virtual ~NodeView() override; - void SetContexts(const QVector &nodes); + void set_contexts(const QVector &nodes); - const QVector &GetContexts() const + const QVector &get_contexts() const { if (overlay_view_) { - return overlay_view_->GetContexts(); + return overlay_view_->get_contexts(); } else { return contexts_; } } - bool IsGroupOverlay() const + bool is_group_overlay() const { return overlay_view_; } - void CloseContextsBelongingToProject(Project *project); + void close_contexts_belonging_to_project(Project *project); - void ClearGraph(); + void clear_graph(); /** * @brief Delete selected nodes from graph (user-friendly/undoable) */ - void DeleteSelected(); + void delete_selected(); - void SelectAll(); - void DeselectAll(); + void select_all(); + void deselect_all(); - void Select(const QVector &nodes, + void select(const QVector &nodes, bool center_view_on_item); - void CopySelected(bool cut); - void Paste(); + void copy_selected(bool cut); + void paste(); - void Duplicate(); + void duplicate(); - void SetColorLabel(int index); + void set_color_label(int index); - void ZoomIn(); + void zoom_in(); - void ZoomOut(); + void zoom_out(); - const QVector &GetCurrentContexts() const + const QVector &get_current_contexts() const { return contexts_; } public slots: - void SetMiniMapEnabled(bool e) + void set_mini_map_enabled(bool e) { minimap_->setVisible(e); } - void ShowAddMenu() + void show_add_menu() { - Menu *m = CreateAddMenu(nullptr); + Menu *m = create_add_menu(nullptr); m->exec(QCursor::pos()); delete m; } - void CenterOnItemsBoundingRect(); + void center_on_items_bounding_rect(); - void CenterOnNode(olive::Node *n); + void center_on_node(olive::Node *n); - void LabelSelectedNodes(); + void label_selected_nodes(); signals: - void NodesSelected(const QVector &nodes); + void nodes_selected(const QVector &nodes); - void NodesDeselected(const QVector &nodes); + void nodes_deselected(const QVector &nodes); - void NodeSelectionChanged(const QVector &nodes); + void node_selection_changed(const QVector &nodes); void - NodeSelectionChangedWithContexts(const QVector &nodes); + node_selection_changed_with_contexts(const QVector &nodes); - void NodeGroupOpened(NodeGroup *group); - void NodeGroupClosed(); + void node_group_opened(NodeGroup *group); + void node_group_closed(); - void EscPressed(); + void esc_pressed(); protected: virtual void keyPressEvent(QKeyEvent *event) override; @@ -145,7 +145,7 @@ protected: virtual void resizeEvent(QResizeEvent *event) override; - virtual void ZoomIntoCursorPosition(QWheelEvent *event, double multiplier, + virtual void zoom_into_cursor_position(QWheelEvent *event, double multiplier, const QPointF &cursor_pos) override; virtual bool event(QEvent *event) override; @@ -155,54 +155,54 @@ protected: virtual void changeEvent(QEvent *e) override; private: - void DetachItemsFromCursor(bool delete_nodes_too = true); + void detach_items_from_cursor(bool delete_nodes_too = true); - void SetFlowDirection(NodeViewCommon::FlowDirection dir); + void set_flow_direction(NodeViewCommon::FlowDirection dir); - void MoveAttachedNodesToCursor(const QPoint &p); - void ProcessMovingAttachedNodes(const QPoint &pos); - QVector ProcessDroppingAttachedNodes(MultiUndoCommand *command, + void move_attached_nodes_to_cursor(const QPoint &p); + void process_moving_attached_nodes(const QPoint &pos); + QVector process_dropping_attached_nodes(MultiUndoCommand *command, Node *select_context, const QPoint &pos); - Node *GetContextAtMousePos(const QPoint &p); + Node *get_context_at_mouse_pos(const QPoint &p); - void ConnectSelectionChangedSignal(); - void DisconnectSelectionChangedSignal(); + void connect_selection_changed_signal(); + void disconnect_selection_changed_signal(); - void ZoomFromKeyboard(double multiplier); + void zoom_from_keyboard(double multiplier); - void ClearCreateEdgeInputIfNecessary(); + void clear_create_edge_input_if_necessary(); - QPointF GetEstimatedPositionForContext(NodeViewItem *item, + QPointF get_estimated_position_for_context(NodeViewItem *item, Node *context) const; - NodeViewItem *GetAssumedItemForSelectedNode(Node *node); - bool GetAssumedPositionForSelectedNode(Node *node, Node::Position *pos); + NodeViewItem *get_assumed_item_for_selected_node(Node *node); + bool get_assumed_position_for_selected_node(Node *node, Node::Position *pos); - Menu *CreateAddMenu(Menu *parent); + Menu *create_add_menu(Menu *parent); - void PositionNewEdge(const QPoint &pos); + void position_new_edge(const QPoint &pos); - void AddContext(Node *n); + void add_context(Node *n); - void RemoveContext(Node *n); + void remove_context(Node *n); - bool IsItemAttachedToCursor(NodeViewItem *item) const; + bool is_item_attached_to_cursor(NodeViewItem *item) const; - void ExpandItem(NodeViewItem *item); + void expand_item(NodeViewItem *item); - void CollapseItem(NodeViewItem *item); + void collapse_item(NodeViewItem *item); - void EndEdgeDrag(bool cancel = false); + void end_edge_drag(bool cancel = false); - void PostPaste(const QVector &new_nodes, + void post_paste(const QVector &new_nodes, const Node::PositionMap &map); - void ResizeOverlay(); + void resize_overlay(); NodeViewMiniMap *minimap_; - NodeViewContext *GetContextItemFromNodeItem(NodeViewItem *item); + NodeViewContext *get_context_item_from_node_item(NodeViewItem *item); struct AttachedItem { NodeViewItem *item; @@ -210,7 +210,7 @@ private: QPointF original_pos; }; - void SetAttachedItems(const QVector &items); + void set_attached_items(const QVector &items); QVector attached_items_; NodeViewEdge *drop_edge_; @@ -243,59 +243,59 @@ private: QAction *show_in_param_editor_action_; - static const double kMinimumScale; + static const double k_minimum_scale; - static const int kMaximumContexts; + static const int k_maximum_contexts; private slots: /** * @brief Receiver for when the scene's selected items change */ - void UpdateSelectionCache(); + void update_selection_cache(); /** * @brief Receiver for when the user right clicks (or otherwise requests a context menu) */ - void ShowContextMenu(const QPoint &pos); + void show_context_menu(const QPoint &pos); /** * @brief Receiver for when the user requests a new node from the add menu */ - void CreateNodeSlot(QAction *action); + void create_node_slot(QAction *action); /** * @brief Receiver for setting the direction from the context menu */ - void ContextMenuSetDirection(QAction *action); + void context_menu_set_direction(QAction *action); /** * @brief Opens the selected node in a Viewer */ - void OpenSelectedNodeInViewer(); + void open_selected_node_in_viewer(); - void UpdateSceneBoundingRect(); + void update_scene_bounding_rect(); - void RepositionMiniMap(); + void reposition_mini_map(); - void UpdateViewportOnMiniMap(); + void update_viewport_on_mini_map(); - void MoveToScenePoint(const QPointF &pos); + void move_to_scene_point(const QPointF &pos); - void NodeRemovedFromGraph(); + void node_removed_from_graph(); - void GroupNodes(); + void group_nodes(); - void UngroupNodes(); + void ungroup_nodes(); - void ShowNodeProperties(); + void show_node_properties(); - void ShowSelectedNodeInParamEditor(); + void show_selected_node_in_param_editor(); - void ItemAboutToBeDeleted(NodeViewItem *item); + void item_about_to_be_deleted(NodeViewItem *item); - void CloseOverlay(); + void close_overlay(); }; } -#endif // NODEVIEW_H +#endif // OAK_NODEVIEW_H diff --git a/app/widget/nodeview/nodeviewcommon.h b/app/widget/nodeview/nodeviewcommon.h index bc0384338..c6562e5c4 100644 --- a/app/widget/nodeview/nodeviewcommon.h +++ b/app/widget/nodeview/nodeviewcommon.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEVIEWCOMMON_H -#define NODEVIEWCOMMON_H +#ifndef OAK_NODEVIEWCOMMON_H +#define OAK_NODEVIEWCOMMON_H #include @@ -32,45 +32,45 @@ namespace olive class NodeViewCommon { public: enum FlowDirection { - kInvalidDirection = -1, - kTopToBottom, - kBottomToTop, - kLeftToRight, - kRightToLeft + k_invalid_direction = -1, + k_top_to_bottom, + k_bottom_to_top, + k_left_to_right, + k_right_to_left }; - static Qt::Orientation GetFlowOrientation(FlowDirection dir) + static Qt::Orientation get_flow_orientation(FlowDirection dir) { - if (dir == kTopToBottom || dir == kBottomToTop) { + if (dir == k_top_to_bottom || dir == k_bottom_to_top) { return Qt::Vertical; } else { return Qt::Horizontal; } } - static bool IsFlowVertical(FlowDirection dir) + static bool is_flow_vertical(FlowDirection dir) { - return dir == kTopToBottom || dir == kBottomToTop; + return dir == k_top_to_bottom || dir == k_bottom_to_top; } - static bool IsFlowHorizontal(FlowDirection dir) + static bool is_flow_horizontal(FlowDirection dir) { - return dir == kLeftToRight || dir == kRightToLeft; + return dir == k_left_to_right || dir == k_right_to_left; } - static bool DirectionsAreOpposing(FlowDirection a, FlowDirection b) + static bool directions_are_opposing(FlowDirection a, FlowDirection b) { - return ((a == NodeViewCommon::kLeftToRight && - b == NodeViewCommon::kRightToLeft) || - (a == NodeViewCommon::kRightToLeft && - b == NodeViewCommon::kLeftToRight) || - (a == NodeViewCommon::kTopToBottom && - b == NodeViewCommon::kBottomToTop) || - (a == NodeViewCommon::kBottomToTop && - b == NodeViewCommon::kTopToBottom)); + return ((a == NodeViewCommon::k_left_to_right && + b == NodeViewCommon::k_right_to_left) || + (a == NodeViewCommon::k_right_to_left && + b == NodeViewCommon::k_left_to_right) || + (a == NodeViewCommon::k_top_to_bottom && + b == NodeViewCommon::k_bottom_to_top) || + (a == NodeViewCommon::k_bottom_to_top && + b == NodeViewCommon::k_top_to_bottom)); } }; } -#endif // NODEVIEWCOMMON_H +#endif // OAK_NODEVIEWCOMMON_H diff --git a/app/widget/nodeview/nodeviewcontext.cpp b/app/widget/nodeview/nodeviewcontext.cpp index 8faa79e33..4175a3c2a 100644 --- a/app/widget/nodeview/nodeviewcontext.cpp +++ b/app/widget/nodeview/nodeviewcontext.cpp @@ -45,36 +45,36 @@ NodeViewContext::NodeViewContext(Node *context, QGraphicsItem *item) { Block *block = dynamic_cast(context_); if (block && block->track() && block->track()->sequence()) { - rational timebase = block->track() + Rational timebase = block->track() ->sequence() - ->GetVideoParams() + ->get_video_params() .frame_rate_as_time_base(); lbl_ = QCoreApplication::translate("NodeViewContext", "%1 [%2] :: %3 - %4") - .arg(block->GetLabelAndName(), - Track::Reference::TypeToTranslatedString( + .arg(block->get_label_and_name(), + Track::Reference::type_to_translated_string( block->track()->type()), QString::fromStdString(Timecode::time_to_timecode( block->in(), timebase, - Core::instance()->GetTimecodeDisplay())), + Core::instance()->get_timecode_display())), QString::fromStdString(Timecode::time_to_timecode( block->out(), timebase, - Core::instance()->GetTimecodeDisplay()))); + Core::instance()->get_timecode_display()))); } else { - lbl_ = context_->GetLabelAndName(); + lbl_ = context_->get_label_and_name(); } - const Node::PositionMap &map = context_->GetContextPositions(); + const Node::PositionMap &map = context_->get_context_positions(); for (auto it = map.cbegin(); it != map.cend(); it++) { - AddChild(it.key()); + add_child(it.key()); } - connect(context_, &Node::NodeAddedToContext, this, - &NodeViewContext::AddChild, Qt::DirectConnection); - connect(context_, &Node::NodePositionInContextChanged, this, - &NodeViewContext::SetChildPosition, Qt::DirectConnection); - connect(context_, &Node::NodeRemovedFromContext, this, - &NodeViewContext::RemoveChild, Qt::DirectConnection); + connect(context_, &Node::node_added_to_context, this, + &NodeViewContext::add_child, Qt::DirectConnection); + connect(context_, &Node::node_position_in_context_changed, this, + &NodeViewContext::set_child_position, Qt::DirectConnection); + connect(context_, &Node::node_removed_from_context, this, + &NodeViewContext::remove_child, Qt::DirectConnection); } NodeViewContext::~NodeViewContext() @@ -84,50 +84,50 @@ NodeViewContext::~NodeViewContext() edges_.clear(); } -void NodeViewContext::AddChild(Node *node) +void NodeViewContext::add_child(Node *node) { if (!context_) { return; } NodeViewItem *item = new NodeViewItem(node, context_, this); - item->SetFlowDirection(flow_dir_); + item->set_flow_direction(flow_dir_); - AddNodeInternal(node, item); + add_node_internal(node, item); if (NodeGroup *group = dynamic_cast(node)) { - for (auto it = group->GetContextPositions().cbegin(); - it != group->GetContextPositions().cend(); it++) { + for (auto it = group->get_context_positions().cbegin(); + it != group->get_context_positions().cend(); it++) { // Use this item as the representative for all of these nodes too - AddNodeInternal(it.key(), item); + add_node_internal(it.key(), item); } - connect(group, &NodeGroup::NodeAddedToContext, this, - &NodeViewContext::GroupAddedNode); - connect(group, &NodeGroup::NodeRemovedFromContext, this, - &NodeViewContext::GroupRemovedNode); + connect(group, &NodeGroup::node_added_to_context, this, + &NodeViewContext::group_added_node); + connect(group, &NodeGroup::node_removed_from_context, this, + &NodeViewContext::group_removed_node); } - UpdateRect(); + update_rect(); } -void NodeViewContext::SetChildPosition(Node *node, const QPointF &pos) +void NodeViewContext::set_child_position(Node *node, const QPointF &pos) { - item_map_.value(node)->SetNodePosition(pos); + item_map_.value(node)->set_node_position(pos); } -void NodeViewContext::RemoveChild(Node *node) +void NodeViewContext::remove_child(Node *node) { - disconnect(node, &Node::InputConnected, this, - &NodeViewContext::ChildInputConnected); - disconnect(node, &Node::InputDisconnected, this, - &NodeViewContext::ChildInputDisconnected); + disconnect(node, &Node::input_connected, this, + &NodeViewContext::child_input_connected); + disconnect(node, &Node::input_disconnected, this, + &NodeViewContext::child_input_disconnected); if (NodeGroup *group = dynamic_cast(node)) { - disconnect(group, &NodeGroup::NodeAddedToContext, this, - &NodeViewContext::GroupAddedNode); - disconnect(group, &NodeGroup::NodeRemovedFromContext, this, - &NodeViewContext::GroupRemovedNode); + disconnect(group, &NodeGroup::node_added_to_context, this, + &NodeViewContext::group_added_node); + disconnect(group, &NodeGroup::node_removed_from_context, this, + &NodeViewContext::group_removed_node); } NodeViewItem *item = item_map_.take(node); @@ -136,22 +136,22 @@ void NodeViewContext::RemoveChild(Node *node) // now can be handled before the item is destroyed scene()->removeItem(item); - emit ItemAboutToBeDeleted(item); + emit item_about_to_be_deleted(item); // Delete edges first because the edge destructor will try to reference item (maybe that should // be changed...) - QVector edges_to_remove = item->GetAllEdgesRecursively(); + QVector edges_to_remove = item->get_all_edges_recursively(); foreach (NodeViewEdge *edge, edges_to_remove) { - if (node == item->GetNode() || edge->output() == node || + if (node == item->get_node() || edge->output() == node || edge->input().node() == node) { - ChildInputDisconnected(edge->output(), edge->input()); + child_input_disconnected(edge->output(), edge->input()); } } // Check if this item is specifically for this node and the node is a group. If so, remove it for // all other entries in the map. - if (item->GetNode() == node) { - if (dynamic_cast(item->GetNode())) { + if (item->get_node() == node) { + if (dynamic_cast(item->get_node())) { for (auto it = item_map_.begin(); it != item_map_.end();) { if (it.value() == item) { it = item_map_.erase(it); @@ -164,22 +164,22 @@ void NodeViewContext::RemoveChild(Node *node) delete item; } - UpdateRect(); + update_rect(); } -void NodeViewContext::ChildInputConnected(Node *output, const NodeInput &input) +void NodeViewContext::child_input_connected(Node *output, const NodeInput &input) { // Add edge - if (!input.IsHidden()) { + if (!input.is_hidden()) { if (NodeViewItem *output_item = item_map_.value(output)) { - AddEdgeInternal( + add_edge_internal( output, input, output_item, - item_map_.value(input.node())->GetItemForInput(input)); + item_map_.value(input.node())->get_item_for_input(input)); } } } -bool NodeViewContext::ChildInputDisconnected(Node *output, +bool NodeViewContext::child_input_disconnected(Node *output, const NodeInput &input) { // Remove edge @@ -195,59 +195,59 @@ bool NodeViewContext::ChildInputDisconnected(Node *output, return false; } -qreal GetTextOffset(const QFontMetricsF &fm) +qreal get_text_offset(const QFontMetricsF &fm) { return fm.height() / 2; } -void NodeViewContext::UpdateRect() +void NodeViewContext::update_rect() { QFont f; QFontMetricsF fm(f); - qreal lbl_offset = GetTextOffset(fm); + qreal lbl_offset = get_text_offset(fm); QRectF cbr = childrenBoundingRect(); QRectF rect = cbr; - int pad = NodeViewItem::DefaultItemHeight(); + int pad = NodeViewItem::default_item_height(); rect.adjust(-pad, -lbl_offset * 2 - fm.height() - pad, pad, pad); setRect(rect); last_titlebar_height_ = rect.y() + (cbr.y() - rect.y()) - pad; } -void NodeViewContext::SetFlowDirection(NodeViewCommon::FlowDirection dir) +void NodeViewContext::set_flow_direction(NodeViewCommon::FlowDirection dir) { flow_dir_ = dir; foreach (NodeViewItem *item, item_map_) { - item->SetFlowDirection(dir); + item->set_flow_direction(dir); } } -void NodeViewContext::SetCurvedEdges(bool e) +void NodeViewContext::set_curved_edges(bool e) { curved_edges_ = e; foreach (NodeViewEdge *edge, edges_) { - edge->SetCurved(e); + edge->set_curved(e); } } -int NodeViewContext::DeleteSelected(NodeViewDeleteCommand *command) +int NodeViewContext::delete_selected(NodeViewDeleteCommand *command) { int count = 0; // Delete any selected edges foreach (NodeViewEdge *edge, edges_) { if (edge->isSelected()) { - command->AddEdge(edge->output(), edge->input()); + command->add_edge(edge->output(), edge->input()); } } // Delete any selected nodes foreach (NodeViewItem *node, item_map_) { if (node->isSelected()) { - command->AddNode(node->GetNode(), context_); + command->add_node(node->get_node(), context_); count++; } } @@ -255,7 +255,7 @@ int NodeViewContext::DeleteSelected(NodeViewDeleteCommand *command) return count; } -void NodeViewContext::Select(const QVector &nodes) +void NodeViewContext::select(const QVector &nodes) { foreach (Node *n, nodes) { if (NodeViewItem *item = item_map_.value(n)) { @@ -264,7 +264,7 @@ void NodeViewContext::Select(const QVector &nodes) } } -QVector NodeViewContext::GetSelectedItems() const +QVector NodeViewContext::get_selected_items() const { QVector items; @@ -279,12 +279,12 @@ QVector NodeViewContext::GetSelectedItems() const return items; } -QPointF NodeViewContext::MapScenePosToNodePosInContext(const QPointF &pos) const +QPointF NodeViewContext::map_scene_pos_to_node_pos_in_context(const QPointF &pos) const { for (auto it = item_map_.cbegin(); it != item_map_.cend(); it++) { QPointF pos_inside_parent = it.value()->mapToParent(it.value()->mapFromScene(pos)); - return NodeViewItem::ScreenToNodePoint(pos_inside_parent, flow_dir_); + return NodeViewItem::screen_to_node_point(pos_inside_parent, flow_dir_); } return QPointF(0, 0); } @@ -295,7 +295,7 @@ void NodeViewContext::paint(QPainter *painter, { // Set pen and brush Color color = context_->color(); - QColor c = QtUtils::toQColor(color); + QColor c = QtUtils::to_q_color(color); QPen pen(c, 2); if (option->state & QStyle::State_Selected) { pen.setStyle(Qt::DotLine); @@ -319,9 +319,9 @@ void NodeViewContext::paint(QPainter *painter, painter->setClipping(false); // Draw titlebar text - painter->setPen(ColorCoding::GetUISelectorColor(color)); + painter->setPen(ColorCoding::get_ui_selector_color(color)); - int offset = GetTextOffset(painter->fontMetrics()); + int offset = get_text_offset(painter->fontMetrics()); QRectF text_rect = rect(); text_rect.adjust(offset, offset, -offset, -offset); @@ -344,41 +344,41 @@ void NodeViewContext::mousePressEvent(QGraphicsSceneMouseEvent *event) super::mousePressEvent(event); } -void NodeViewContext::AddNodeInternal(Node *node, NodeViewItem *item) +void NodeViewContext::add_node_internal(Node *node, NodeViewItem *item) { - connect(node, &Node::InputConnected, this, - &NodeViewContext::ChildInputConnected); - connect(node, &Node::InputDisconnected, this, - &NodeViewContext::ChildInputDisconnected); + connect(node, &Node::input_connected, this, + &NodeViewContext::child_input_connected); + connect(node, &Node::input_disconnected, this, + &NodeViewContext::child_input_disconnected); item_map_.insert(node, item); if (node == context_) { - item->SetLabelAsOutput(true); + item->set_label_as_output(true); } for (auto it = node->output_connections().cbegin(); it != node->output_connections().cend(); it++) { - if (!it->second.IsHidden()) { + if (!it->second.is_hidden()) { if (NodeViewItem *other_item = item_map_.value(it->second.node())) { - AddEdgeInternal(node, it->second, item, - other_item->GetItemForInput(it->second)); + add_edge_internal(node, it->second, item, + other_item->get_item_for_input(it->second)); } } } for (auto it = node->input_connections().cbegin(); it != node->input_connections().cend(); it++) { - if (!it->first.IsHidden()) { + if (!it->first.is_hidden()) { if (NodeViewItem *other_item = item_map_.value(it->second)) { - AddEdgeInternal(it->second, it->first, other_item, - item->GetItemForInput(it->first)); + add_edge_internal(it->second, it->first, other_item, + item->get_item_for_input(it->first)); } } } } -void NodeViewContext::AddEdgeInternal(Node *output, const NodeInput &input, +void NodeViewContext::add_edge_internal(Node *output, const NodeInput &input, NodeViewItem *from, NodeViewItem *to) { if (from == to) { @@ -387,20 +387,20 @@ void NodeViewContext::AddEdgeInternal(Node *output, const NodeInput &input, NodeViewEdge *edge_ui = new NodeViewEdge(output, input, from, to, this); - edge_ui->Adjust(); - edge_ui->SetCurved(curved_edges_); + edge_ui->adjust(); + edge_ui->set_curved(curved_edges_); edges_.append(edge_ui); } -void NodeViewContext::GroupAddedNode(Node *node) +void NodeViewContext::group_added_node(Node *node) { NodeGroup *group = static_cast(sender()); - AddNodeInternal(node, item_map_.value(group)); + add_node_internal(node, item_map_.value(group)); } -void NodeViewContext::GroupRemovedNode(Node *node) +void NodeViewContext::group_removed_node(Node *node) { NodeGroup *group = static_cast(sender()); diff --git a/app/widget/nodeview/nodeviewcontext.h b/app/widget/nodeview/nodeviewcontext.h index 9f9e57b10..f62ef6ff4 100644 --- a/app/widget/nodeview/nodeviewcontext.h +++ b/app/widget/nodeview/nodeviewcontext.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef NODEVIEWCONTEXT_H -#define NODEVIEWCONTEXT_H +#ifndef OAK_NODEVIEWCONTEXT_H +#define OAK_NODEVIEWCONTEXT_H #include #include @@ -37,26 +37,26 @@ public: virtual ~NodeViewContext() override; - Node *GetContext() const + Node *get_context() const { return context_; } - void UpdateRect(); + void update_rect(); - void SetFlowDirection(NodeViewCommon::FlowDirection dir); + void set_flow_direction(NodeViewCommon::FlowDirection dir); - void SetCurvedEdges(bool e); + void set_curved_edges(bool e); - int DeleteSelected(NodeViewDeleteCommand *command); + int delete_selected(NodeViewDeleteCommand *command); - void Select(const QVector &nodes); + void select(const QVector &nodes); - QVector GetSelectedItems() const; + QVector get_selected_items() const; - QPointF MapScenePosToNodePosInContext(const QPointF &pos) const; + QPointF map_scene_pos_to_node_pos_in_context(const QPointF &pos) const; - NodeViewItem *GetItemFromMap(Node *node) const + NodeViewItem *get_item_from_map(Node *node) const { return item_map_.value(node); } @@ -66,18 +66,18 @@ public: QWidget *widget = nullptr) override; public slots: - void AddChild(Node *node); + void add_child(Node *node); - void SetChildPosition(Node *node, const QPointF &pos); + void set_child_position(Node *node, const QPointF &pos); - void RemoveChild(Node *node); + void remove_child(Node *node); - void ChildInputConnected(Node *output, const NodeInput &input); + void child_input_connected(Node *output, const NodeInput &input); - bool ChildInputDisconnected(Node *output, const NodeInput &input); + bool child_input_disconnected(Node *output, const NodeInput &input); signals: - void ItemAboutToBeDeleted(NodeViewItem *item); + void item_about_to_be_deleted(NodeViewItem *item); protected: virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, @@ -86,9 +86,9 @@ protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; private: - void AddNodeInternal(Node *node, NodeViewItem *item); + void add_node_internal(Node *node, NodeViewItem *item); - void AddEdgeInternal(Node *output, const NodeInput &input, + void add_edge_internal(Node *output, const NodeInput &input, NodeViewItem *from, NodeViewItem *to); Node *context_; @@ -106,11 +106,11 @@ private: QVector edges_; private slots: - void GroupAddedNode(Node *node); + void group_added_node(Node *node); - void GroupRemovedNode(Node *node); + void group_removed_node(Node *node); }; } -#endif // NODEVIEWCONTEXT_H +#endif // OAK_NODEVIEWCONTEXT_H diff --git a/app/widget/nodeview/nodeviewedge.cpp b/app/widget/nodeview/nodeviewedge.cpp index 883893336..7625ef94a 100644 --- a/app/widget/nodeview/nodeviewedge.cpp +++ b/app/widget/nodeview/nodeviewedge.cpp @@ -45,11 +45,11 @@ NodeViewEdge::NodeViewEdge(Node *output, const NodeInput &input, , from_item_(from_item) , to_item_(to_item) { - Init(); - SetConnected(true); + init(); + set_connected(true); - from_item_->AddEdge(this); - to_item_->AddEdge(this); + from_item_->add_edge(this); + to_item_->add_edge(this); } NodeViewEdge::NodeViewEdge(QGraphicsItem *parent) @@ -57,83 +57,83 @@ NodeViewEdge::NodeViewEdge(QGraphicsItem *parent) , from_item_(nullptr) , to_item_(nullptr) { - Init(); + init(); } NodeViewEdge::~NodeViewEdge() { if (from_item_) { - from_item_->RemoveEdge(this); + from_item_->remove_edge(this); } if (to_item_) { - to_item_->RemoveEdge(this); + to_item_->remove_edge(this); } } void NodeViewEdge::set_from_item(NodeViewItem *i) { if (from_item_) { - from_item_->RemoveEdge(this); + from_item_->remove_edge(this); } from_item_ = i; if (from_item_) { - from_item_->AddEdge(this); + from_item_->add_edge(this); } - Adjust(); + adjust(); } void NodeViewEdge::set_to_item(NodeViewItem *i) { if (to_item_) { - to_item_->RemoveEdge(this); + to_item_->remove_edge(this); } to_item_ = i; if (to_item_) { - to_item_->AddEdge(this); + to_item_->add_edge(this); } - Adjust(); + adjust(); } -void NodeViewEdge::Adjust() +void NodeViewEdge::adjust() { // Draw a line between the two - SetPoints(from_item()->GetOutputPoint(), to_item()->GetInputPoint()); + set_points(from_item()->get_output_point(), to_item()->get_input_point()); } -void NodeViewEdge::SetConnected(bool c) +void NodeViewEdge::set_connected(bool c) { connected_ = c; update(); } -void NodeViewEdge::SetHighlighted(bool e) +void NodeViewEdge::set_highlighted(bool e) { highlighted_ = e; update(); } -void NodeViewEdge::SetPoints(const QPointF &start, const QPointF &end) +void NodeViewEdge::set_points(const QPointF &start, const QPointF &end) { cached_start_ = start; cached_end_ = end; - UpdateCurve(); + update_curve(); } -void NodeViewEdge::SetCurved(bool e) +void NodeViewEdge::set_curved(bool e) { curved_ = e; - UpdateCurve(); + update_curve(); } void NodeViewEdge::paint(QPainter *painter, @@ -162,7 +162,7 @@ void NodeViewEdge::paint(QPainter *painter, painter->drawPath(path()); } -void NodeViewEdge::Init() +void NodeViewEdge::init() { connected_ = false; highlighted_ = false; @@ -177,7 +177,7 @@ void NodeViewEdge::Init() edge_width_ = QFontMetrics(QFont()).height() / 12; } -void NodeViewEdge::UpdateCurve() +void NodeViewEdge::update_curve() { const QPointF &start = cached_start_; const QPointF &end = cached_end_; @@ -194,30 +194,30 @@ void NodeViewEdge::UpdateCurve() QPointF cp1, cp2; NodeViewCommon::FlowDirection from_flow = - from_item_ ? from_item_->GetFlowDirection() : - NodeViewCommon::kInvalidDirection; + from_item_ ? from_item_->get_flow_direction() : + NodeViewCommon::k_invalid_direction; NodeViewCommon::FlowDirection to_flow = - to_item_ ? to_item_->GetFlowDirection() : - NodeViewCommon::kInvalidDirection; + to_item_ ? to_item_->get_flow_direction() : + NodeViewCommon::k_invalid_direction; - if (from_flow == NodeViewCommon::kInvalidDirection && - to_flow == NodeViewCommon::kInvalidDirection) { + if (from_flow == NodeViewCommon::k_invalid_direction && + to_flow == NodeViewCommon::k_invalid_direction) { // This is a technically unsupported scenario, but to avoid issues, we'll use a fallback - from_flow = NodeViewCommon::kLeftToRight; - to_flow = NodeViewCommon::kLeftToRight; - } else if (from_flow == NodeViewCommon::kInvalidDirection) { + from_flow = NodeViewCommon::k_left_to_right; + to_flow = NodeViewCommon::k_left_to_right; + } else if (from_flow == NodeViewCommon::k_invalid_direction) { from_flow = to_flow; - } else if (to_flow == NodeViewCommon::kInvalidDirection) { + } else if (to_flow == NodeViewCommon::k_invalid_direction) { to_flow = from_flow; } - if (NodeViewCommon::GetFlowOrientation(from_flow) == Qt::Horizontal) { + if (NodeViewCommon::get_flow_orientation(from_flow) == Qt::Horizontal) { cp1 = QPointF(half_x, start.y()); } else { cp1 = QPointF(start.x(), half_y); } - if (NodeViewCommon::GetFlowOrientation(to_flow) == Qt::Horizontal) { + if (NodeViewCommon::get_flow_orientation(to_flow) == Qt::Horizontal) { cp2 = QPointF(half_x, end.y()); } else { cp2 = QPointF(end.x(), half_y); @@ -244,8 +244,8 @@ void NodeViewEdge::UpdateCurve() std::swap(y2, y3); } - double t = Bezier::CubicXtoT(continue_x, x1, x2, x3, x4); - double y = Bezier::CubicTtoY(y1, y2, y3, y4, t); + double t = Bezier::cubic_xto_t(continue_x, x1, x2, x3, x4); + double y = Bezier::cubic_tto_y(y1, y2, y3, y4, t); angle = std::atan2(end.y() - y, end.x() - continue_x); } diff --git a/app/widget/nodeview/nodeviewedge.h b/app/widget/nodeview/nodeviewedge.h index 863050729..db33ab60d 100644 --- a/app/widget/nodeview/nodeviewedge.h +++ b/app/widget/nodeview/nodeviewedge.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEEDGEITEM_H -#define NODEEDGEITEM_H +#ifndef OAK_NODEEDGEITEM_H +#define OAK_NODEEDGEITEM_H #include #include @@ -76,7 +76,7 @@ public: void set_to_item(NodeViewItem *i); - void Adjust(); + void adjust(); /** * @brief Set the connected state of this line @@ -88,9 +88,9 @@ public: * Using SetEdge() automatically sets this to true. Under most circumstances this should be left alone, and only * be set when an edge is being created/dragged. */ - void SetConnected(bool c); + void set_connected(bool c); - bool IsConnected() const + bool is_connected() const { return connected_; } @@ -100,17 +100,17 @@ public: * * Changes color of edge. */ - void SetHighlighted(bool e); + void set_highlighted(bool e); /** * @brief Set points to create curve from */ - void SetPoints(const QPointF &start, const QPointF &end); + void set_points(const QPointF &start, const QPointF &end); /** * @brief Set whether edges should be drawn as curved or as straight lines */ - void SetCurved(bool e); + void set_curved(bool e); protected: virtual void paint(QPainter *painter, @@ -118,9 +118,9 @@ protected: QWidget *widget = nullptr) override; private: - void Init(); + void init(); - void UpdateCurve(); + void update_curve(); Node *output_; @@ -146,4 +146,4 @@ private: } -#endif // NODEEDGEITEM_H +#endif // OAK_NODEEDGEITEM_H diff --git a/app/widget/nodeview/nodeviewitem.cpp b/app/widget/nodeview/nodeviewitem.cpp index d84253b03..320e0469b 100644 --- a/app/widget/nodeview/nodeviewitem.cpp +++ b/app/widget/nodeview/nodeviewitem.cpp @@ -32,7 +32,7 @@ #include "core.h" #include "node/nodeundo.h" #include "node/value.h" -#include "pluginSupport/OlivePluginInstance.h" +#include "pluginSupport/oliveplugininstance.h" #include "nodeview.h" #include "nodeviewscene.h" #include "ui/colorcoding.h" @@ -51,7 +51,7 @@ NodeViewItem::NodeViewItem(Node *node, const QString &input, int element, , context_(context) , expanded_(false) , highlighted_(false) - , flow_dir_(NodeViewCommon::kInvalidDirection) + , flow_dir_(NodeViewCommon::k_invalid_direction) , arrow_click_(false) , label_as_output_(false) { @@ -60,28 +60,28 @@ NodeViewItem::NodeViewItem(Node *node, const QString &input, int element, // // Set border width - node_border_width_ = DefaultItemBorder(); + node_border_width_ = default_item_border(); // Set rect size to default - SetRectSize(); + set_rect_size(); // Create connector input_connector_ = new NodeViewItemConnector(false, this); output_connector_ = new NodeViewItemConnector(true, this); - connect(node_, &Node::LabelChanged, this, - &NodeViewItem::NodeAppearanceChanged); - connect(node_, &Node::ColorChanged, this, - &NodeViewItem::NodeAppearanceChanged); - connect(node_, &Node::MessageCountChanged, this, - &NodeViewItem::NodeAppearanceChanged); + connect(node_, &Node::label_changed, this, + &NodeViewItem::node_appearance_changed); + connect(node_, &Node::color_changed, this, + &NodeViewItem::node_appearance_changed); + connect(node_, &Node::message_count_changed, this, + &NodeViewItem::node_appearance_changed); - if (IsOutputItem()) { - connect(node_, &Node::InputAdded, this, - &NodeViewItem::RepopulateInputs); - connect(node_, &Node::InputRemoved, this, - &NodeViewItem::RepopulateInputs); - RepopulateInputs(); + if (is_output_item()) { + connect(node_, &Node::input_added, this, + &NodeViewItem::repopulate_inputs); + connect(node_, &Node::input_removed, this, + &NodeViewItem::repopulate_inputs); + repopulate_inputs(); // Set flags for this widget setFlag(QGraphicsItem::ItemSendsGeometryChanges); @@ -89,19 +89,19 @@ NodeViewItem::NodeViewItem(Node *node, const QString &input, int element, setFlag(QGraphicsItem::ItemIsSelectable); if (context_) { - SetNodePosition(context_->GetNodePositionDataInContext(node_)); + set_node_position(context_->get_node_position_data_in_context(node_)); } } else { output_connector_->setVisible(false); - connect(node_, &Node::InputArraySizeChanged, this, - &NodeViewItem::InputArraySizeChanged); - connect(node_, &Node::InputArraySizeChanged, this, - &NodeViewItem::InputArraySizeChanged); + connect(node_, &Node::input_array_size_changed, this, + &NodeViewItem::input_array_size_changed); + connect(node_, &Node::input_array_size_changed, this, + &NodeViewItem::input_array_size_changed); } // This should be set during runtime, but just in case here's a default fallback - SetFlowDirection(NodeViewCommon::kLeftToRight); + set_flow_direction(NodeViewCommon::k_left_to_right); } NodeViewItem::~NodeViewItem() @@ -109,185 +109,185 @@ NodeViewItem::~NodeViewItem() Q_ASSERT(edges_.isEmpty()); } -Node::Position NodeViewItem::GetNodePositionData() const +Node::Position NodeViewItem::get_node_position_data() const { - return Node::Position(GetNodePosition(), IsExpanded()); + return Node::Position(get_node_position(), is_expanded()); } -QPointF NodeViewItem::GetNodePosition() const +QPointF NodeViewItem::get_node_position() const { - return ScreenToNodePoint(pos(), flow_dir_); + return screen_to_node_point(pos(), flow_dir_); } -void NodeViewItem::SetNodePosition(const QPointF &pos) +void NodeViewItem::set_node_position(const QPointF &pos) { cached_node_pos_ = pos; - UpdateNodePosition(); + update_node_position(); } -void NodeViewItem::SetNodePosition(const Node::Position &pos) +void NodeViewItem::set_node_position(const Node::Position &pos) { - SetNodePosition(pos.position); - SetExpanded(pos.expanded); + set_node_position(pos.position); + set_expanded(pos.expanded); } -QVector NodeViewItem::GetAllEdgesRecursively() const +QVector NodeViewItem::get_all_edges_recursively() const { QVector list = edges_; foreach (NodeViewItem *item, children_) { - list.append(item->GetAllEdgesRecursively()); + list.append(item->get_all_edges_recursively()); } return list; } -int NodeViewItem::DefaultTextPadding() +int NodeViewItem::default_text_padding() { return QFontMetrics(QFont()).height() / 4; } -int NodeViewItem::DefaultItemHeight() +int NodeViewItem::default_item_height() { - return QFontMetrics(QFont()).height() + DefaultTextPadding() * 2; + return QFontMetrics(QFont()).height() + default_text_padding() * 2; } -int NodeViewItem::DefaultItemWidth() +int NodeViewItem::default_item_width() { - return QtUtils::QFontMetricsWidth(QFontMetrics(QFont()), + return QtUtils::q_font_metrics_width(QFontMetrics(QFont()), "HHHHHHHHHHHHHHHH"); ; } -int NodeViewItem::DefaultItemBorder() +int NodeViewItem::default_item_border() { return QFontMetrics(QFont()).height() / 12; } -QPointF NodeViewItem::NodeToScreenPoint(QPointF p, +QPointF NodeViewItem::node_to_screen_point(QPointF p, NodeViewCommon::FlowDirection direction) { switch (direction) { - case NodeViewCommon::kLeftToRight: + case NodeViewCommon::k_left_to_right: // NodeGraphs are always left-to-right internally, no need to translate break; - case NodeViewCommon::kRightToLeft: + case NodeViewCommon::k_right_to_left: // Invert X value p.setX(-p.x()); break; - case NodeViewCommon::kTopToBottom: + case NodeViewCommon::k_top_to_bottom: // Swap X/Y p = QPointF(p.y(), p.x()); break; - case NodeViewCommon::kBottomToTop: + case NodeViewCommon::k_bottom_to_top: // Swap X/Y and invert Y p = QPointF(p.y(), -p.x()); break; - case NodeViewCommon::kInvalidDirection: + case NodeViewCommon::k_invalid_direction: break; } // Multiply by item sizes for this direction - p.setX(p.x() * DefaultItemHorizontalPadding(direction)); - p.setY(p.y() * DefaultItemVerticalPadding(direction)); + p.setX(p.x() * default_item_horizontal_padding(direction)); + p.setY(p.y() * default_item_vertical_padding(direction)); return p; } -QPointF NodeViewItem::ScreenToNodePoint(QPointF p, +QPointF NodeViewItem::screen_to_node_point(QPointF p, NodeViewCommon::FlowDirection direction) { // Divide by item sizes for this direction - p.setX(p.x() / DefaultItemHorizontalPadding(direction)); - p.setY(p.y() / DefaultItemVerticalPadding(direction)); + p.setX(p.x() / default_item_horizontal_padding(direction)); + p.setY(p.y() / default_item_vertical_padding(direction)); switch (direction) { - case NodeViewCommon::kLeftToRight: + case NodeViewCommon::k_left_to_right: // NodeGraphs are always left-to-right internally, no need to translate break; - case NodeViewCommon::kRightToLeft: + case NodeViewCommon::k_right_to_left: // Invert X value p.setX(-p.x()); break; - case NodeViewCommon::kTopToBottom: + case NodeViewCommon::k_top_to_bottom: // Swap X/Y p = QPointF(p.y(), p.x()); break; - case NodeViewCommon::kBottomToTop: + case NodeViewCommon::k_bottom_to_top: // Swap X/Y and invert Y p = QPointF(-p.y(), p.x()); break; - case NodeViewCommon::kInvalidDirection: + case NodeViewCommon::k_invalid_direction: break; } return p; } -qreal NodeViewItem::DefaultItemHorizontalPadding( +qreal NodeViewItem::default_item_horizontal_padding( NodeViewCommon::FlowDirection dir) { - if (NodeViewCommon::GetFlowOrientation(dir) == Qt::Horizontal) { - return DefaultItemWidth() * 1.5; + if (NodeViewCommon::get_flow_orientation(dir) == Qt::Horizontal) { + return default_item_width() * 1.5; } else { - return DefaultItemWidth() * 1.25; + return default_item_width() * 1.25; } } -qreal NodeViewItem::DefaultItemVerticalPadding(NodeViewCommon::FlowDirection dir) +qreal NodeViewItem::default_item_vertical_padding(NodeViewCommon::FlowDirection dir) { - if (NodeViewCommon::GetFlowOrientation(dir) == Qt::Horizontal) { - return DefaultItemHeight() * 1.5; + if (NodeViewCommon::get_flow_orientation(dir) == Qt::Horizontal) { + return default_item_height() * 1.5; } else { - return DefaultItemHeight() * 2.0; + return default_item_height() * 2.0; } } -qreal NodeViewItem::DefaultItemHorizontalPadding() const +qreal NodeViewItem::default_item_horizontal_padding() const { - return DefaultItemHorizontalPadding(flow_dir_); + return default_item_horizontal_padding(flow_dir_); } -qreal NodeViewItem::DefaultItemVerticalPadding() const +qreal NodeViewItem::default_item_vertical_padding() const { - return DefaultItemVerticalPadding(flow_dir_); + return default_item_vertical_padding(flow_dir_); } -void NodeViewItem::AddEdge(NodeViewEdge *edge) +void NodeViewItem::add_edge(NodeViewEdge *edge) { edges_.append(edge); } -void NodeViewItem::RemoveEdge(NodeViewEdge *edge) +void NodeViewItem::remove_edge(NodeViewEdge *edge) { edges_.removeOne(edge); } -void NodeViewItem::SetExpanded(bool e, bool hide_titlebar) +void NodeViewItem::set_expanded(bool e, bool hide_titlebar) { - if (!CanBeExpanded() || (expanded_ == e)) { + if (!can_be_expanded() || (expanded_ == e)) { return; } expanded_ = e; if (context_) { - context_->SetNodeExpandedInContext(node_, e); + context_->set_node_expanded_in_context(node_, e); } - if (IsOutputItem()) { + if (is_output_item()) { // We don't have to check has_connectable_inputs_ here because we did it at the top input_connector_->setVisible(!expanded_); } if (expanded_) { - node_->Retranslate(); + node_->retranslate(); - if (IsOutputItem()) { + if (is_output_item()) { // Create items for each input of the node foreach (const QString &input, node_->inputs()) { - if (IsInputValid(input)) { + if (is_input_valid(input)) { NodeViewItem *item = new NodeViewItem(node_, input, -1, context_, this); children_.append(item); @@ -297,12 +297,12 @@ void NodeViewItem::SetExpanded(bool e, bool hide_titlebar) QVector edges = edges_; for (auto it = edges.cbegin(); it != edges.cend(); it++) { if ((*it)->to_item() == this) { - (*it)->set_to_item(GetItemForInput((*it)->input())); + (*it)->set_to_item(get_item_for_input((*it)->input())); } } } else { // Create items for each element of the input array - int arr_sz = node_->InputArraySize(input_); + int arr_sz = node_->input_array_size(input_); children_.resize(arr_sz); for (int i = 0; i < arr_sz; i++) { NodeViewItem *item = @@ -313,7 +313,7 @@ void NodeViewItem::SetExpanded(bool e, bool hide_titlebar) QVector edges = edges_; for (auto it = edges.cbegin(); it != edges.cend(); it++) { if ((*it)->to_item() == this) { - (*it)->set_to_item(GetItemForInput((*it)->input())); + (*it)->set_to_item(get_item_for_input((*it)->input())); } } } @@ -328,22 +328,22 @@ void NodeViewItem::SetExpanded(bool e, bool hide_titlebar) children_.clear(); } - UpdateChildrenPositions(); + update_children_positions(); - if (flow_dir_ == NodeViewCommon::kTopToBottom) { - UpdateOutputConnectorPosition(); + if (flow_dir_ == NodeViewCommon::k_top_to_bottom) { + update_output_connector_position(); } - ReadjustAllEdges(); + readjust_all_edges(); - UpdateContextRect(); + update_context_rect(); update(); } -void NodeViewItem::ToggleExpanded() +void NodeViewItem::toggle_expanded() { - SetExpanded(!IsExpanded()); + set_expanded(!is_expanded()); } void NodeViewItem::paint(QPainter *painter, @@ -355,9 +355,9 @@ void NodeViewItem::paint(QPainter *painter, // We only draw a single unit's worth QRectF single_unit_rect = rect(); - single_unit_rect.setHeight(DefaultItemHeight()); + single_unit_rect.setHeight(default_item_height()); - if (IsOutputItem()) { + if (is_output_item()) { // Set output item colors painter->setPen(Qt::black); painter->setBrush( @@ -382,30 +382,30 @@ void NodeViewItem::paint(QPainter *painter, // Determine what text to draw and whether to draw an arrow QString node_label, node_name; - if (IsOutputItem()) { + if (is_output_item()) { if (label_as_output_) { node_name = QCoreApplication::translate("NodeViewItem", "Output"); } else { - node_label = node_->GetLabel(); - node_name = node_->ShortName(); + node_label = node_->get_label(); + node_name = node_->short_name(); } } else { if (element_ == -1) { - node_name = node_->GetInputName(input_); + node_name = node_->get_input_name(input_); } else { node_name = QString::number( element_ + - node_->GetInputProperty(input_, QStringLiteral("arraystart")) + node_->get_input_property(input_, QStringLiteral("arraystart")) .toInt()); } } // Draw arrow if necessary - int arrow_size = CanBeExpanded() ? DrawExpandArrow(painter) : 0; + int arrow_size = can_be_expanded() ? draw_expand_arrow(painter) : 0; - if (IsOutputItem()) { + if (is_output_item()) { // Determine the text color (automatically calculate from node background color) - painter->setPen(ColorCoding::GetUISelectorColor(node_->color())); + painter->setPen(ColorCoding::get_ui_selector_color(node_->color())); } else { // Just use text item painter->setPen(app_pal.text().color()); @@ -413,10 +413,10 @@ void NodeViewItem::paint(QPainter *painter, if (node_label.isEmpty()) { // Draw name only - DrawNodeTitle(painter, node_name, single_unit_rect, Qt::AlignVCenter, + draw_node_title(painter, node_name, single_unit_rect, Qt::AlignVCenter, arrow_size); } else { - int text_pad = DefaultTextPadding() / 2; + int text_pad = default_text_padding() / 2; QRectF safe_label_bounds = single_unit_rect.adjusted(text_pad, text_pad, -text_pad, -text_pad); QFont f; @@ -425,22 +425,22 @@ void NodeViewItem::paint(QPainter *painter, // Draw label as larger/upper text f.setPointSizeF(font_sz * 0.8); painter->setFont(f); - DrawNodeTitle(painter, node_label, safe_label_bounds, Qt::AlignTop, + draw_node_title(painter, node_label, safe_label_bounds, Qt::AlignTop, arrow_size); // Draw node name as smaller/lower text f.setPointSizeF(font_sz * 0.6); painter->setFont(f); - DrawNodeTitle(painter, node_name, safe_label_bounds, Qt::AlignBottom, + draw_node_title(painter, node_name, safe_label_bounds, Qt::AlignBottom, arrow_size); } - if (IsOutputItem()) { + if (is_output_item()) { auto *instance = node_->getPluginInstance(); auto *olive_instance = dynamic_cast(instance); int message_count = - olive_instance ? olive_instance->persistentMessageCount() : 0; + olive_instance ? olive_instance->persistent_message_count() : 0; if (message_count > 0) { QString badge_text = QString::number(message_count); @@ -470,7 +470,7 @@ void NodeViewItem::paint(QPainter *painter, } // Draw final border (output only) - if (IsOutputItem()) { + if (is_output_item()) { QPen border_pen; border_pen.setWidth(node_border_width_); @@ -491,12 +491,12 @@ void NodeViewItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (last_arrow_rect_.contains(event->pos().toPoint())) { arrow_click_ = true; - ToggleExpanded(); + toggle_expanded(); return; } event->setModifiers( - QtUtils::FlipControlAndShiftModifiers(event->modifiers())); + QtUtils::flip_control_and_shift_modifiers(event->modifiers())); QGraphicsRectItem::mousePressEvent(event); } @@ -508,7 +508,7 @@ void NodeViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } event->setModifiers( - QtUtils::FlipControlAndShiftModifiers(event->modifiers())); + QtUtils::flip_control_and_shift_modifiers(event->modifiers())); QGraphicsRectItem::mouseMoveEvent(event); } @@ -521,7 +521,7 @@ void NodeViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } event->setModifiers( - QtUtils::FlipControlAndShiftModifiers(event->modifiers())); + QtUtils::flip_control_and_shift_modifiers(event->modifiers())); QGraphicsRectItem::mouseReleaseEvent(event); } @@ -531,9 +531,9 @@ QVariant NodeViewItem::itemChange(QGraphicsItem::GraphicsItemChange change, { if (node_) { if (change == ItemPositionHasChanged) { - ReadjustAllEdges(); + readjust_all_edges(); - UpdateContextRect(); + update_context_rect(); } else if (change == ItemSelectedHasChanged) { if (value.toBool()) { qDebug() << "Selected node:" << node_; @@ -544,28 +544,28 @@ QVariant NodeViewItem::itemChange(QGraphicsItem::GraphicsItemChange change, return QGraphicsItem::itemChange(change, value); } -void NodeViewItem::ReadjustAllEdges() +void NodeViewItem::readjust_all_edges() { foreach (NodeViewEdge *edge, edges_) { if (NodeViewItem *to_item = edge->to_item()) { static_cast(to_item->parentItem()) - ->UpdateFlowDirectionOfInputItem(to_item); + ->update_flow_direction_of_input_item(to_item); } - edge->Adjust(); + edge->adjust(); } foreach (NodeViewItem *child, children_) { - child->ReadjustAllEdges(); + child->readjust_all_edges(); } } -void NodeViewItem::UpdateContextRect() +void NodeViewItem::update_context_rect() { QGraphicsItem *item = parentItem(); while (item) { if (NodeViewContext *ctx = dynamic_cast(item)) { - ctx->UpdateRect(); + ctx->update_rect(); break; } @@ -573,7 +573,7 @@ void NodeViewItem::UpdateContextRect() } } -void NodeViewItem::DrawNodeTitle(QPainter *painter, QString text, +void NodeViewItem::draw_node_title(QPainter *painter, QString text, const QRectF &rect, Qt::Alignment vertical_align, int icon_full_size) @@ -582,8 +582,8 @@ void NodeViewItem::DrawNodeTitle(QPainter *painter, QString text, // Calculate how much space we have for text int item_width = this->rect().width(); - int max_text_width = item_width - DefaultTextPadding() * 2 - icon_full_size; - int label_width = QtUtils::QFontMetricsWidth(fm, text); + int max_text_width = item_width - default_text_padding() * 2 - icon_full_size; + int label_width = QtUtils::q_font_metrics_width(fm, text); // Concatenate text if necessary (adds a "..." to the end and removes characters until the // string fits in the bounds) @@ -594,7 +594,7 @@ void NodeViewItem::DrawNodeTitle(QPainter *painter, QString text, text.chop(1); concatenated = QCoreApplication::translate("NodeViewItem", "%1...").arg(text); - } while ((label_width = QtUtils::QFontMetricsWidth(fm, concatenated)) > + } while ((label_width = QtUtils::q_font_metrics_width(fm, concatenated)) > max_text_width); text = concatenated; @@ -613,16 +613,16 @@ void NodeViewItem::DrawNodeTitle(QPainter *painter, QString text, painter->drawText(text_rect, text_align, text); } -int NodeViewItem::DrawExpandArrow(QPainter *painter) +int NodeViewItem::draw_expand_arrow(QPainter *painter) { // Draw right or down arrow based on expanded state int icon_size = painter->fontMetrics().height() / 2; - int icon_padding = DefaultItemHeight() / 2 - icon_size / 2; + int icon_padding = default_item_height() / 2 - icon_size / 2; int icon_full_size = icon_size + icon_padding * 2; painter->setRenderHint(QPainter::SmoothPixmapTransform); - const QIcon &expand_icon = IsExpanded() ? icon::TriDown : icon::TriRight; + const QIcon &expand_icon = is_expanded() ? icon::tri_down : icon::tri_right; int icon_size_scaled = icon_size * painter->transform().m11(); last_arrow_rect_ = QRect(this->rect().x() + icon_padding, @@ -636,35 +636,35 @@ int NodeViewItem::DrawExpandArrow(QPainter *painter) return icon_full_size; } -void NodeViewItem::SetLabelAsOutput(bool e) +void NodeViewItem::set_label_as_output(bool e) { label_as_output_ = e; output_connector_->setVisible(!e); update(); } -QPointF NodeViewItem::GetInputPoint() const +QPointF NodeViewItem::get_input_point() const { return input_connector_->scenePos(); } -QPointF NodeViewItem::GetOutputPoint() const +QPointF NodeViewItem::get_output_point() const { QPointF p = output_connector_->scenePos(); QRectF r = output_connector_->polygon().boundingRect(); switch (flow_dir_) { - case NodeViewCommon::kLeftToRight: + case NodeViewCommon::k_left_to_right: default: p.setX(p.x() + r.width()); break; - case NodeViewCommon::kRightToLeft: + case NodeViewCommon::k_right_to_left: p.setX(p.x() - r.width()); break; - case NodeViewCommon::kTopToBottom: + case NodeViewCommon::k_top_to_bottom: p.setY(p.y() + r.height()); break; - case NodeViewCommon::kBottomToTop: + case NodeViewCommon::k_bottom_to_top: p.setY(p.y() - r.height()); break; } @@ -672,173 +672,173 @@ QPointF NodeViewItem::GetOutputPoint() const return p; } -void NodeViewItem::SetFlowDirection(NodeViewCommon::FlowDirection dir) +void NodeViewItem::set_flow_direction(NodeViewCommon::FlowDirection dir) { if (flow_dir_ != dir) { flow_dir_ = dir; - input_connector_->SetFlowDirection(dir); - output_connector_->SetFlowDirection(dir); + input_connector_->set_flow_direction(dir); + output_connector_->set_flow_direction(dir); - UpdateInputConnectorPosition(); - UpdateOutputConnectorPosition(); + update_input_connector_position(); + update_output_connector_position(); - if (IsOutputItem()) { - UpdateNodePosition(); + if (is_output_item()) { + update_node_position(); } - ReadjustAllEdges(); + readjust_all_edges(); } } -void NodeViewItem::UpdateNodePosition() +void NodeViewItem::update_node_position() { - setPos(NodeToScreenPoint(cached_node_pos_, flow_dir_)); + setPos(node_to_screen_point(cached_node_pos_, flow_dir_)); } -void NodeViewItem::UpdateInputConnectorPosition() +void NodeViewItem::update_input_connector_position() { QRectF output_rect = input_connector_->polygon().boundingRect(); NodeViewCommon::FlowDirection using_flow_dir = flow_dir_; - if (IsExpanded() && !NodeViewCommon::IsFlowHorizontal(flow_dir_)) { + if (is_expanded() && !NodeViewCommon::is_flow_horizontal(flow_dir_)) { if (edges_.isEmpty() || edges_.first()->from_item()->x() < this->x()) { - using_flow_dir = NodeViewCommon::kLeftToRight; + using_flow_dir = NodeViewCommon::k_left_to_right; } else { - using_flow_dir = NodeViewCommon::kRightToLeft; + using_flow_dir = NodeViewCommon::k_right_to_left; } } // Input connector flow directions change conditionally switch (using_flow_dir) { - case NodeViewCommon::kLeftToRight: + case NodeViewCommon::k_left_to_right: input_connector_->setPos(rect().left() - output_rect.width(), 0); break; - case NodeViewCommon::kRightToLeft: + case NodeViewCommon::k_right_to_left: input_connector_->setPos(rect().right() + output_rect.width(), 0); break; - case NodeViewCommon::kTopToBottom: + case NodeViewCommon::k_top_to_bottom: input_connector_->setPos(rect().center().x(), rect().top() - output_rect.height()); break; - case NodeViewCommon::kBottomToTop: + case NodeViewCommon::k_bottom_to_top: input_connector_->setPos(rect().center().x(), rect().bottom() + output_rect.height()); break; - case NodeViewCommon::kInvalidDirection: + case NodeViewCommon::k_invalid_direction: break; } } -void NodeViewItem::UpdateOutputConnectorPosition() +void NodeViewItem::update_output_connector_position() { switch (flow_dir_) { - case NodeViewCommon::kLeftToRight: + case NodeViewCommon::k_left_to_right: output_connector_->setPos(rect().right(), 0); break; - case NodeViewCommon::kRightToLeft: + case NodeViewCommon::k_right_to_left: output_connector_->setPos(rect().left(), 0); break; - case NodeViewCommon::kTopToBottom: + case NodeViewCommon::k_top_to_bottom: output_connector_->setPos(rect().center().x(), rect().bottom()); break; - case NodeViewCommon::kBottomToTop: + case NodeViewCommon::k_bottom_to_top: output_connector_->setPos(rect().center().x(), rect().top()); break; - case NodeViewCommon::kInvalidDirection: + case NodeViewCommon::k_invalid_direction: break; } } -bool NodeViewItem::IsInputValid(const QString &input) +bool NodeViewItem::is_input_valid(const QString &input) { - if (!node_->IsInputConnectable(input) || node_->IsInputHidden(input)) { + if (!node_->is_input_connectable(input) || node_->is_input_hidden(input)) { return false; } // For OFX plugin nodes, only show texture inputs in the node graph // to avoid excessively tall nodes with dozens of scalar parameters. // Scalar parameters are still visible in the parameter panel. if (node_->getPluginInstance() != nullptr && - node_->GetInputDataType(input) != NodeValue::kTexture) { + node_->get_input_data_type(input) != NodeValue::k_texture) { return false; } return true; } -void NodeViewItem::SetRectSize(int height_units) +void NodeViewItem::set_rect_size(int height_units) { // Set rect - int widget_width = DefaultItemWidth(); - int widget_height = DefaultItemHeight(); + int widget_width = default_item_width(); + int widget_height = default_item_height(); setRect(QRectF(-widget_width / 2, -widget_height / 2, widget_width, widget_height * height_units)); } -bool NodeViewItem::CanBeExpanded() const +bool NodeViewItem::can_be_expanded() const { - if (IsOutputItem()) { + if (is_output_item()) { return has_connectable_inputs_; } else { - return node_->GetInputFlags(input_) & kInputFlagArray && - element_ == -1 && !node_->IsInputConnected(input_); + return node_->get_input_flags(input_) & k_input_flag_array && + element_ == -1 && !node_->is_input_connected(input_); } } -void NodeViewItem::UpdateChildrenPositions() +void NodeViewItem::update_children_positions() { int y = 1; - int h = DefaultItemHeight(); + int h = default_item_height(); foreach (NodeViewItem *c, children_) { c->setPos(QPointF(0, y * h)); - y += c->GetLogicalHeightWithChildren(); + y += c->get_logical_height_with_children(); } - SetRectSize(y); + set_rect_size(y); if (NodeViewItem *p = dynamic_cast(parentItem())) { - p->UpdateChildrenPositions(); + p->update_children_positions(); } } -int NodeViewItem::GetLogicalHeightWithChildren() const +int NodeViewItem::get_logical_height_with_children() const { int h = 1; foreach (NodeViewItem *c, children_) { - h += c->GetLogicalHeightWithChildren(); + h += c->get_logical_height_with_children(); } return h; } -void NodeViewItem::UpdateFlowDirectionOfInputItem(NodeViewItem *child) +void NodeViewItem::update_flow_direction_of_input_item(NodeViewItem *child) { - if (!child->IsOutputItem()) { - if (NodeViewCommon::IsFlowVertical(flow_dir_)) { + if (!child->is_output_item()) { + if (NodeViewCommon::is_flow_vertical(flow_dir_)) { if (!child->edges().isEmpty() && child->edges().first()->from_item()->scenePos().x() > child->scenePos().x()) { - child->SetFlowDirection(NodeViewCommon::kRightToLeft); + child->set_flow_direction(NodeViewCommon::k_right_to_left); } else { - child->SetFlowDirection(NodeViewCommon::kLeftToRight); + child->set_flow_direction(NodeViewCommon::k_left_to_right); } } else { - child->SetFlowDirection(flow_dir_); + child->set_flow_direction(flow_dir_); } } } -void NodeViewItem::RepopulateInputs() +void NodeViewItem::repopulate_inputs() { - if (IsOutputItem()) { + if (is_output_item()) { has_connectable_inputs_ = false; foreach (const QString &input, node_->inputs()) { - if (IsInputValid(input)) { + if (is_input_valid(input)) { has_connectable_inputs_ = true; break; } @@ -847,55 +847,55 @@ void NodeViewItem::RepopulateInputs() input_connector_->setVisible(has_connectable_inputs_); } - if (IsExpanded() && (IsOutputItem() || element_ == -1)) { + if (is_expanded() && (is_output_item() || element_ == -1)) { // Create or remove inputs when necessary // NOTE: This is not the most efficient thing in the world, but it does work - SetExpanded(false); - SetExpanded(true); + set_expanded(false); + set_expanded(true); } } -void NodeViewItem::InputArraySizeChanged(const QString &input) +void NodeViewItem::input_array_size_changed(const QString &input) { if (input == input_) { - RepopulateInputs(); + repopulate_inputs(); } } -void NodeViewItem::NodeAppearanceChanged() +void NodeViewItem::node_appearance_changed() { update(); } -void NodeViewItem::SetHighlighted(bool e) +void NodeViewItem::set_highlighted(bool e) { highlighted_ = e; update(); } -NodeViewItem *NodeViewItem::GetItemForInput(NodeInput input) +NodeViewItem *NodeViewItem::get_item_for_input(NodeInput input) { if (NodeGroup *group = dynamic_cast(node_)) { if (input.node() != group) { // Translate input to group input - QString id = group->GetIDOfPassthrough(input); + QString id = group->get_id_of_passthrough(input); input.set_node(group); input.set_input(id); } } - if (IsExpanded()) { + if (is_expanded()) { if (input_.isEmpty()) { // Look for the input in our children foreach (NodeViewItem *i, children_) { if (i->input_ == input.input()) { - return i->GetItemForInput(input); + return i->get_item_for_input(input); } } } else { // Look for element in our children if (input.element() >= 0 && input.element() < children_.size()) { - return children_.at(input.element())->GetItemForInput(input); + return children_.at(input.element())->get_item_for_input(input); } } } diff --git a/app/widget/nodeview/nodeviewitem.h b/app/widget/nodeview/nodeviewitem.h index f8c04588f..93d4f13ac 100644 --- a/app/widget/nodeview/nodeviewitem.h +++ b/app/widget/nodeview/nodeviewitem.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEVIEWITEM_H -#define NODEVIEWITEM_H +#ifndef OAK_NODEVIEWITEM_H +#define OAK_NODEVIEWITEM_H #include #include @@ -56,27 +56,27 @@ public: virtual ~NodeViewItem() override; - Node::Position GetNodePositionData() const; - QPointF GetNodePosition() const; - void SetNodePosition(const QPointF &pos); - void SetNodePosition(const Node::Position &pos); + Node::Position get_node_position_data() const; + QPointF get_node_position() const; + void set_node_position(const QPointF &pos); + void set_node_position(const Node::Position &pos); - QVector GetAllEdgesRecursively() const; + QVector get_all_edges_recursively() const; /** * @brief Get currently attached node */ - Node *GetNode() const + Node *get_node() const { return node_; } - NodeInput GetInput() const + NodeInput get_input() const { return NodeInput(node_, input_, element_); } - Node *GetContext() const + Node *get_context() const { return context_; } @@ -84,7 +84,7 @@ public: /** * @brief Get expanded state */ - bool IsExpanded() const + bool is_expanded() const { return expanded_; } @@ -97,65 +97,65 @@ public: /** * @brief Set expanded state */ - void SetExpanded(bool e, bool hide_titlebar = false); - void ToggleExpanded(); + void set_expanded(bool e, bool hide_titlebar = false); + void toggle_expanded(); - QPointF GetInputPoint() const; - QPointF GetOutputPoint() const; + QPointF get_input_point() const; + QPointF get_output_point() const; /** * @brief Sets the direction nodes are flowing */ - void SetFlowDirection(NodeViewCommon::FlowDirection dir); + void set_flow_direction(NodeViewCommon::FlowDirection dir); - NodeViewCommon::FlowDirection GetFlowDirection() const + NodeViewCommon::FlowDirection get_flow_direction() const { return flow_dir_; } - static int DefaultTextPadding(); + static int default_text_padding(); - static int DefaultItemHeight(); + static int default_item_height(); - static int DefaultItemWidth(); + static int default_item_width(); - static int DefaultItemBorder(); + static int default_item_border(); - static QPointF NodeToScreenPoint(QPointF p, + static QPointF node_to_screen_point(QPointF p, NodeViewCommon::FlowDirection direction); - static QPointF ScreenToNodePoint(QPointF p, + static QPointF screen_to_node_point(QPointF p, NodeViewCommon::FlowDirection direction); static qreal - DefaultItemHorizontalPadding(NodeViewCommon::FlowDirection dir); - static qreal DefaultItemVerticalPadding(NodeViewCommon::FlowDirection dir); - qreal DefaultItemHorizontalPadding() const; - qreal DefaultItemVerticalPadding() const; + default_item_horizontal_padding(NodeViewCommon::FlowDirection dir); + static qreal default_item_vertical_padding(NodeViewCommon::FlowDirection dir); + qreal default_item_horizontal_padding() const; + qreal default_item_vertical_padding() const; - void AddEdge(NodeViewEdge *edge); - void RemoveEdge(NodeViewEdge *edge); + void add_edge(NodeViewEdge *edge); + void remove_edge(NodeViewEdge *edge); - bool IsLabelledAsOutputOfContext() const + bool is_labelled_as_output_of_context() const { return label_as_output_; } - void SetLabelAsOutput(bool e); + void set_label_as_output(bool e); - void SetHighlighted(bool e); + void set_highlighted(bool e); - NodeViewItem *GetItemForInput(NodeInput input); + NodeViewItem *get_item_for_input(NodeInput input); - bool IsOutputItem() const + bool is_output_item() const { return input_.isEmpty(); } - void ReadjustAllEdges(); + void readjust_all_edges(); - void UpdateFlowDirectionOfInputItem(NodeViewItem *child); + void update_flow_direction_of_input_item(NodeViewItem *child); - bool CanBeExpanded() const; + bool can_be_expanded() const; protected: virtual void paint(QPainter *painter, @@ -170,28 +170,28 @@ protected: const QVariant &value) override; private: - void UpdateContextRect(); + void update_context_rect(); - void DrawNodeTitle(QPainter *painter, QString text, const QRectF &rect, + void draw_node_title(QPainter *painter, QString text, const QRectF &rect, Qt::Alignment vertical_align, int icon_full_size); - int DrawExpandArrow(QPainter *painter); + int draw_expand_arrow(QPainter *painter); /** * @brief Internal update function when logical position changes */ - void UpdateNodePosition(); + void update_node_position(); - void UpdateInputConnectorPosition(); - void UpdateOutputConnectorPosition(); + void update_input_connector_position(); + void update_output_connector_position(); - bool IsInputValid(const QString &input); + bool is_input_valid(const QString &input); - void SetRectSize(int height_units = 1); + void set_rect_size(int height_units = 1); - void UpdateChildrenPositions(); + void update_children_positions(); - int GetLogicalHeightWithChildren() const; + int get_logical_height_with_children() const; /** * @brief Reference to attached Node @@ -234,13 +234,13 @@ private: bool label_as_output_; private slots: - void NodeAppearanceChanged(); + void node_appearance_changed(); - void RepopulateInputs(); + void repopulate_inputs(); - void InputArraySizeChanged(const QString &input); + void input_array_size_changed(const QString &input); }; } -#endif // NODEVIEWITEM_H +#endif // OAK_NODEVIEWITEM_H diff --git a/app/widget/nodeview/nodeviewitemconnector.cpp b/app/widget/nodeview/nodeviewitemconnector.cpp index ebf5b3285..8e05ade87 100644 --- a/app/widget/nodeview/nodeviewitemconnector.cpp +++ b/app/widget/nodeview/nodeviewitemconnector.cpp @@ -37,11 +37,11 @@ NodeViewItemConnector::NodeViewItemConnector(bool is_output, , output_(is_output) { QColor c = qApp->palette().text().color(); - setPen(QPen(c, NodeViewItem::DefaultItemBorder())); + setPen(QPen(c, NodeViewItem::default_item_border())); setBrush(c); } -void NodeViewItemConnector::SetFlowDirection(NodeViewCommon::FlowDirection dir) +void NodeViewItemConnector::set_flow_direction(NodeViewCommon::FlowDirection dir) { QFont f; QFontMetricsF fm(f); @@ -53,31 +53,31 @@ void NodeViewItemConnector::SetFlowDirection(NodeViewCommon::FlowDirection dir) p.resize(3); switch (dir) { - case NodeViewCommon::kLeftToRight: + case NodeViewCommon::k_left_to_right: // Triangle pointing right p[0] = QPointF(0, -triangle_sz_half); p[1] = QPointF(triangle_sz_half, 0); p[2] = QPointF(0, triangle_sz_half); break; - case NodeViewCommon::kTopToBottom: + case NodeViewCommon::k_top_to_bottom: // Triangle pointing down p[0] = QPointF(-triangle_sz_half, 0); p[1] = QPointF(0, triangle_sz_half); p[2] = QPointF(triangle_sz_half, 0); break; - case NodeViewCommon::kBottomToTop: + case NodeViewCommon::k_bottom_to_top: // Triangle pointing up p[0] = QPointF(-triangle_sz_half, 0); p[1] = QPointF(0, -triangle_sz_half); p[2] = QPointF(triangle_sz_half, 0); break; - case NodeViewCommon::kRightToLeft: + case NodeViewCommon::k_right_to_left: // Triangle pointing left p[0] = QPointF(0, -triangle_sz_half); p[1] = QPointF(-triangle_sz_half, 0); p[2] = QPointF(0, triangle_sz_half); break; - case NodeViewCommon::kInvalidDirection: + case NodeViewCommon::k_invalid_direction: break; } diff --git a/app/widget/nodeview/nodeviewitemconnector.h b/app/widget/nodeview/nodeviewitemconnector.h index a7dffe5ad..253e15014 100644 --- a/app/widget/nodeview/nodeviewitemconnector.h +++ b/app/widget/nodeview/nodeviewitemconnector.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEVIEWITEMCONNECTOR_H -#define NODEVIEWITEMCONNECTOR_H +#ifndef OAK_NODEVIEWITEMCONNECTOR_H +#define OAK_NODEVIEWITEMCONNECTOR_H #include @@ -33,9 +33,9 @@ class NodeViewItemConnector : public QGraphicsPolygonItem { public: NodeViewItemConnector(bool is_output, QGraphicsItem *parent = nullptr); - void SetFlowDirection(NodeViewCommon::FlowDirection dir); + void set_flow_direction(NodeViewCommon::FlowDirection dir); - bool IsOutput() const + bool is_output() const { return output_; } @@ -49,4 +49,4 @@ private: } -#endif // NODEVIEWITEMCONNECTOR_H +#endif // OAK_NODEVIEWITEMCONNECTOR_H diff --git a/app/widget/nodeview/nodeviewminimap.cpp b/app/widget/nodeview/nodeviewminimap.cpp index 37fe868f5..3e7baace5 100644 --- a/app/widget/nodeview/nodeviewminimap.cpp +++ b/app/widget/nodeview/nodeviewminimap.cpp @@ -33,7 +33,7 @@ NodeViewMiniMap::NodeViewMiniMap(NodeViewScene *scene, QWidget *parent) , resizing_(false) { connect(scene, &QGraphicsScene::sceneRectChanged, this, - &NodeViewMiniMap::SceneChanged); + &NodeViewMiniMap::scene_changed); setScene(scene); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -43,13 +43,13 @@ NodeViewMiniMap::NodeViewMiniMap(NodeViewScene *scene, QWidget *parent) setFrameShadow(QFrame::Plain); setMouseTracking(true); - QMetaObject::invokeMethod(this, &NodeViewMiniMap::SetDefaultSize, + QMetaObject::invokeMethod(this, &NodeViewMiniMap::set_default_size, Qt::QueuedConnection); resize_triangle_sz_ = fontMetrics().height() / 2; } -void NodeViewMiniMap::SetViewportRect(const QPolygonF &rect) +void NodeViewMiniMap::set_viewport_rect(const QPolygonF &rect) { viewport_rect_ = rect; @@ -85,20 +85,20 @@ void NodeViewMiniMap::resizeEvent(QResizeEvent *event) { super::resizeEvent(event); - emit Resized(); + emit resized(); - SceneChanged(sceneRect()); + scene_changed(sceneRect()); } void NodeViewMiniMap::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (MouseInsideResizeTriangle(event)) { + if (mouse_inside_resize_triangle(event)) { // Resizing! resizing_ = true; resize_anchor_ = QCursor::pos(); } else { - EmitMoveSignal(event); + emit_move_signal(event); } } } @@ -111,10 +111,10 @@ void NodeViewMiniMap::mouseMoveEvent(QMouseEvent *event) resize(QSize(width() - movement.x(), height() - movement.y())); resize_anchor_ = QCursor::pos(); } else { - EmitMoveSignal(event); + emit_move_signal(event); } } else { - if (MouseInsideResizeTriangle(event)) { + if (mouse_inside_resize_triangle(event)) { setCursor(Qt::SizeFDiagCursor); } else { unsetCursor(); @@ -127,7 +127,7 @@ void NodeViewMiniMap::mouseReleaseEvent(QMouseEvent *event) resizing_ = false; } -void NodeViewMiniMap::SceneChanged(const QRectF &bounding) +void NodeViewMiniMap::scene_changed(const QRectF &bounding) { double x_scale = double(this->width()) / bounding.width(); double y_scale = double(this->height()) / bounding.height(); @@ -140,22 +140,22 @@ void NodeViewMiniMap::SceneChanged(const QRectF &bounding) setTransform(transform); } -void NodeViewMiniMap::SetDefaultSize() +void NodeViewMiniMap::set_default_size() { if (parentWidget()) { resize(parentWidget()->width() / 4, parentWidget()->height() / 4); } } -bool NodeViewMiniMap::MouseInsideResizeTriangle(QMouseEvent *event) +bool NodeViewMiniMap::mouse_inside_resize_triangle(QMouseEvent *event) { return event->pos().x() <= resize_triangle_sz_ && event->pos().y() <= resize_triangle_sz_; } -void NodeViewMiniMap::EmitMoveSignal(QMouseEvent *event) +void NodeViewMiniMap::emit_move_signal(QMouseEvent *event) { - emit MoveToScenePoint(mapToScene(event->pos())); + emit move_to_scene_point(mapToScene(event->pos())); } } diff --git a/app/widget/nodeview/nodeviewminimap.h b/app/widget/nodeview/nodeviewminimap.h index 6ab88abe2..de7176d50 100644 --- a/app/widget/nodeview/nodeviewminimap.h +++ b/app/widget/nodeview/nodeviewminimap.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEVIEWMINIMAP_H -#define NODEVIEWMINIMAP_H +#ifndef OAK_NODEVIEWMINIMAP_H +#define OAK_NODEVIEWMINIMAP_H #include @@ -35,12 +35,12 @@ public: NodeViewMiniMap(NodeViewScene *scene, QWidget *parent = nullptr); public slots: - void SetViewportRect(const QPolygonF &rect); + void set_viewport_rect(const QPolygonF &rect); signals: - void Resized(); + void resized(); - void MoveToScenePoint(const QPointF &pos); + void move_to_scene_point(const QPointF &pos); protected: virtual void drawForeground(QPainter *painter, const QRectF &rect) override; @@ -55,14 +55,14 @@ protected: } private slots: - void SceneChanged(const QRectF &bounding); + void scene_changed(const QRectF &bounding); - void SetDefaultSize(); + void set_default_size(); private: - bool MouseInsideResizeTriangle(QMouseEvent *event); + bool mouse_inside_resize_triangle(QMouseEvent *event); - void EmitMoveSignal(QMouseEvent *event); + void emit_move_signal(QMouseEvent *event); int resize_triangle_sz_; @@ -75,4 +75,4 @@ private: } -#endif // NODEVIEWMINIMAP_H +#endif // OAK_NODEVIEWMINIMAP_H diff --git a/app/widget/nodeview/nodeviewscene.cpp b/app/widget/nodeview/nodeviewscene.cpp index 5df079778..bb302efcc 100644 --- a/app/widget/nodeview/nodeviewscene.cpp +++ b/app/widget/nodeview/nodeviewscene.cpp @@ -31,54 +31,54 @@ namespace olive NodeViewScene::NodeViewScene(QObject *parent) : QGraphicsScene(parent) - , direction_(NodeViewCommon::kLeftToRight) + , direction_(NodeViewCommon::k_left_to_right) , curved_edges_(true) { } -void NodeViewScene::SetFlowDirection(NodeViewCommon::FlowDirection direction) +void NodeViewScene::set_flow_direction(NodeViewCommon::FlowDirection direction) { direction_ = direction; foreach (NodeViewContext *ctx, context_map_) { - ctx->SetFlowDirection(direction_); + ctx->set_flow_direction(direction_); } } -void NodeViewScene::SelectAll() +void NodeViewScene::select_all() { foreach (QGraphicsItem *i, items()) { i->setSelected(true); } } -void NodeViewScene::DeselectAll() +void NodeViewScene::deselect_all() { foreach (QGraphicsItem *i, items()) { i->setSelected(false); } } -QVector NodeViewScene::GetSelectedItems() const +QVector NodeViewScene::get_selected_items() const { QVector items; foreach (NodeViewContext *ctx, context_map_) { - items.append(ctx->GetSelectedItems()); + items.append(ctx->get_selected_items()); } return items; } -NodeViewContext *NodeViewScene::AddContext(Node *node) +NodeViewContext *NodeViewScene::add_context(Node *node) { NodeViewContext *context_item = context_map_.value(node); if (!context_item) { context_item = new NodeViewContext(node); - context_item->SetFlowDirection(GetFlowDirection()); - context_item->SetCurvedEdges(GetEdgesAreCurved()); + context_item->set_flow_direction(get_flow_direction()); + context_item->set_curved_edges(get_edges_are_curved()); QPointF pos(0, 0); QRectF item_rect = context_item->rect(); @@ -96,23 +96,23 @@ NodeViewContext *NodeViewScene::AddContext(Node *node) return context_item; } -void NodeViewScene::RemoveContext(Node *node) +void NodeViewScene::remove_context(Node *node) { delete context_map_.take(node); } -Qt::Orientation NodeViewScene::GetFlowOrientation() const +Qt::Orientation NodeViewScene::get_flow_orientation() const { - return NodeViewCommon::GetFlowOrientation(direction_); + return NodeViewCommon::get_flow_orientation(direction_); } -void NodeViewScene::SetEdgesAreCurved(bool curved) +void NodeViewScene::set_edges_are_curved(bool curved) { if (curved_edges_ != curved) { curved_edges_ = curved; foreach (NodeViewContext *ctx, context_map_) { - ctx->SetCurvedEdges(curved_edges_); + ctx->set_curved_edges(curved_edges_); } } } diff --git a/app/widget/nodeview/nodeviewscene.h b/app/widget/nodeview/nodeviewscene.h index d5b05c654..297f16447 100644 --- a/app/widget/nodeview/nodeviewscene.h +++ b/app/widget/nodeview/nodeviewscene.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEVIEWSCENE_H -#define NODEVIEWSCENE_H +#ifndef OAK_NODEVIEWSCENE_H +#define OAK_NODEVIEWSCENE_H #include #include @@ -39,38 +39,38 @@ class NodeViewScene : public QGraphicsScene { public: NodeViewScene(QObject *parent = nullptr); - void SelectAll(); - void DeselectAll(); + void select_all(); + void deselect_all(); - QVector GetSelectedItems() const; + QVector get_selected_items() const; const QHash &context_map() const { return context_map_; } - Qt::Orientation GetFlowOrientation() const; + Qt::Orientation get_flow_orientation() const; - NodeViewCommon::FlowDirection GetFlowDirection() const + NodeViewCommon::FlowDirection get_flow_direction() const { return direction_; } - void SetFlowDirection(NodeViewCommon::FlowDirection direction); + void set_flow_direction(NodeViewCommon::FlowDirection direction); - bool GetEdgesAreCurved() const + bool get_edges_are_curved() const { return curved_edges_; } public slots: - NodeViewContext *AddContext(Node *node); - void RemoveContext(Node *node); + NodeViewContext *add_context(Node *node); + void remove_context(Node *node); /** * @brief Set whether edges in this scene should be curved or not */ - void SetEdgesAreCurved(bool curved); + void set_edges_are_curved(bool curved); private: QHash context_map_; @@ -84,4 +84,4 @@ private: } -#endif // NODEVIEWSCENE_H +#endif // OAK_NODEVIEWSCENE_H diff --git a/app/widget/nodeview/nodeviewtoolbar.cpp b/app/widget/nodeview/nodeviewtoolbar.cpp index b2f789280..54d377407 100644 --- a/app/widget/nodeview/nodeviewtoolbar.cpp +++ b/app/widget/nodeview/nodeviewtoolbar.cpp @@ -36,41 +36,41 @@ NodeViewToolBar::NodeViewToolBar(QWidget *parent) add_node_btn_ = new QPushButton(); connect(add_node_btn_, &QPushButton::clicked, this, - &NodeViewToolBar::AddNodeClicked); + &NodeViewToolBar::add_node_clicked); layout->addWidget(add_node_btn_); minimap_btn_ = new QPushButton(); minimap_btn_->setCheckable(true); connect(minimap_btn_, &QPushButton::clicked, this, - &NodeViewToolBar::MiniMapEnabledToggled); + &NodeViewToolBar::mini_map_enabled_toggled); layout->addWidget(minimap_btn_); layout->addStretch(); - Retranslate(); - UpdateIcons(); + retranslate(); + update_icons(); } void NodeViewToolBar::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } else if (e->type() == QEvent::StyleChange) { - UpdateIcons(); + update_icons(); } super::changeEvent(e); } -void NodeViewToolBar::Retranslate() +void NodeViewToolBar::retranslate() { add_node_btn_->setToolTip(tr("Add Node")); minimap_btn_->setToolTip(tr("Toggle Mini-Map")); } -void NodeViewToolBar::UpdateIcons() +void NodeViewToolBar::update_icons() { - add_node_btn_->setIcon(icon::Add); - minimap_btn_->setIcon(icon::MiniMap); + add_node_btn_->setIcon(icon::add); + minimap_btn_->setIcon(icon::mini_map); } } diff --git a/app/widget/nodeview/nodeviewtoolbar.h b/app/widget/nodeview/nodeviewtoolbar.h index 519f1850f..9dbe49bbf 100644 --- a/app/widget/nodeview/nodeviewtoolbar.h +++ b/app/widget/nodeview/nodeviewtoolbar.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef NODEVIEWTOOLBAR_H -#define NODEVIEWTOOLBAR_H +#ifndef OAK_NODEVIEWTOOLBAR_H +#define OAK_NODEVIEWTOOLBAR_H #include #include @@ -31,23 +31,23 @@ public: NodeViewToolBar(QWidget *parent = nullptr); public slots: - void SetMiniMapEnabled(bool e) + void set_mini_map_enabled(bool e) { minimap_btn_->setChecked(e); } signals: - void AddNodeClicked(); + void add_node_clicked(); - void MiniMapEnabledToggled(bool e); + void mini_map_enabled_toggled(bool e); protected: virtual void changeEvent(QEvent *e) override; private: - void Retranslate(); + void retranslate(); - void UpdateIcons(); + void update_icons(); QPushButton *add_node_btn_; @@ -56,4 +56,4 @@ private: } -#endif // NODEVIEWTOOLBAR_H +#endif // OAK_NODEVIEWTOOLBAR_H diff --git a/app/widget/nodeview/nodewidget.cpp b/app/widget/nodeview/nodewidget.cpp index d7fd7762d..0f3b62e90 100644 --- a/app/widget/nodeview/nodewidget.cpp +++ b/app/widget/nodeview/nodewidget.cpp @@ -40,14 +40,14 @@ NodeWidget::NodeWidget(QWidget *parent) outer_layout->addWidget(node_view_); // Connect toolbar to NodeView - connect(toolbar_, &NodeViewToolBar::MiniMapEnabledToggled, node_view_, - &NodeView::SetMiniMapEnabled); - connect(toolbar_, &NodeViewToolBar::AddNodeClicked, node_view_, - &NodeView::ShowAddMenu); + connect(toolbar_, &NodeViewToolBar::mini_map_enabled_toggled, node_view_, + &NodeView::set_mini_map_enabled); + connect(toolbar_, &NodeViewToolBar::add_node_clicked, node_view_, + &NodeView::show_add_menu); // Set defaults - toolbar_->SetMiniMapEnabled(true); - node_view_->SetMiniMapEnabled(true); + toolbar_->set_mini_map_enabled(true); + node_view_->set_mini_map_enabled(true); setSizePolicy(node_view_->sizePolicy()); } diff --git a/app/widget/nodeview/nodewidget.h b/app/widget/nodeview/nodewidget.h index 7909cc88c..2715a2863 100644 --- a/app/widget/nodeview/nodewidget.h +++ b/app/widget/nodeview/nodewidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef NODEWIDGET_H -#define NODEWIDGET_H +#ifndef OAK_NODEWIDGET_H +#define OAK_NODEWIDGET_H #include @@ -40,9 +40,9 @@ public: return node_view_; } - void SetContexts(const QVector &nodes) + void set_contexts(const QVector &nodes) { - node_view_->SetContexts(nodes); + node_view_->set_contexts(nodes); toolbar_->setEnabled(!nodes.isEmpty()); } @@ -54,4 +54,4 @@ private: } -#endif // NODEWIDGET_H +#endif // OAK_NODEWIDGET_H diff --git a/app/widget/path/pathwidget.cpp b/app/widget/path/pathwidget.cpp index 30074a66d..00e15e0c0 100644 --- a/app/widget/path/pathwidget.cpp +++ b/app/widget/path/pathwidget.cpp @@ -40,16 +40,16 @@ PathWidget::PathWidget(const QString &path, QWidget *parent) path_edit_->setText(path); layout->addWidget(path_edit_); connect(path_edit_, &QLineEdit::textChanged, this, - &PathWidget::LineEditChanged); + &PathWidget::line_edit_changed); browse_btn_ = new QPushButton(tr("Browse")); layout->addWidget(browse_btn_); connect(browse_btn_, &QPushButton::clicked, this, - &PathWidget::BrowseClicked); + &PathWidget::browse_clicked); } -void PathWidget::BrowseClicked() +void PathWidget::browse_clicked() { QString dir = QFileDialog::getExistingDirectory( static_cast(parent()), tr("Browse for path"), @@ -60,9 +60,9 @@ void PathWidget::BrowseClicked() } } -void PathWidget::LineEditChanged() +void PathWidget::line_edit_changed() { - if (FileFunctions::DirectoryIsValid(text(), false)) { + if (FileFunctions::directory_is_valid(text(), false)) { path_edit_->setStyleSheet(QString()); } else { path_edit_->setStyleSheet(QStringLiteral("QLineEdit {color: red;}")); diff --git a/app/widget/path/pathwidget.h b/app/widget/path/pathwidget.h index f57a2ad2e..fc9820937 100644 --- a/app/widget/path/pathwidget.h +++ b/app/widget/path/pathwidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef PATHWIDGET_H -#define PATHWIDGET_H +#ifndef OAK_PATHWIDGET_H +#define OAK_PATHWIDGET_H #include #include @@ -41,9 +41,9 @@ public: } private slots: - void BrowseClicked(); + void browse_clicked(); - void LineEditChanged(); + void line_edit_changed(); private: QLineEdit *path_edit_; @@ -53,4 +53,4 @@ private: } -#endif // PATHWIDGET_H +#endif // OAK_PATHWIDGET_H diff --git a/app/widget/pixelsampler/pixelsampler.cpp b/app/widget/pixelsampler/pixelsampler.cpp index 241472e51..0ecc8445d 100644 --- a/app/widget/pixelsampler/pixelsampler.cpp +++ b/app/widget/pixelsampler/pixelsampler.cpp @@ -42,18 +42,18 @@ PixelSamplerWidget::PixelSamplerWidget(QWidget *parent) setTitle(tr("Color")); - UpdateLabelInternal(); + update_label_internal(); } -void PixelSamplerWidget::SetValues(const Color &color) +void PixelSamplerWidget::set_values(const Color &color) { color_ = color; - UpdateLabelInternal(); + update_label_internal(); } -void PixelSamplerWidget::UpdateLabelInternal() +void PixelSamplerWidget::update_label_internal() { - box_->SetColor(color_); + box_->set_color(color_); label_->setText(tr("" "R: %1 (%5)
" @@ -86,11 +86,11 @@ ManagedPixelSamplerWidget::ManagedPixelSamplerWidget(QWidget *parent) layout->addWidget(reference_view_); } -void ManagedPixelSamplerWidget::SetValues(const Color &reference, +void ManagedPixelSamplerWidget::set_values(const Color &reference, const Color &display) { - reference_view_->SetValues(reference); - display_view_->SetValues(display); + reference_view_->set_values(reference); + display_view_->set_values(display); } } diff --git a/app/widget/pixelsampler/pixelsampler.h b/app/widget/pixelsampler/pixelsampler.h index 8956fa8dc..56ce14150 100644 --- a/app/widget/pixelsampler/pixelsampler.h +++ b/app/widget/pixelsampler/pixelsampler.h @@ -19,8 +19,8 @@ ***/ -#ifndef PIXELSAMPLERWIDGET_H -#define PIXELSAMPLERWIDGET_H +#ifndef OAK_PIXELSAMPLERWIDGET_H +#define OAK_PIXELSAMPLERWIDGET_H #include #include @@ -37,10 +37,10 @@ public: PixelSamplerWidget(QWidget *parent = nullptr); public slots: - void SetValues(const Color &color); + void set_values(const Color &color); private: - void UpdateLabelInternal(); + void update_label_internal(); Color color_; @@ -55,7 +55,7 @@ public: ManagedPixelSamplerWidget(QWidget *parent = nullptr); public slots: - void SetValues(const Color &reference, const Color &display); + void set_values(const Color &reference, const Color &display); private: PixelSamplerWidget *reference_view_; @@ -65,4 +65,4 @@ private: } -#endif // PIXELSAMPLERWIDGET_H +#endif // OAK_PIXELSAMPLERWIDGET_H diff --git a/app/widget/playbackcontrols/dragbutton.cpp b/app/widget/playbackcontrols/dragbutton.cpp index 716c6bf4d..ea64aae20 100644 --- a/app/widget/playbackcontrols/dragbutton.cpp +++ b/app/widget/playbackcontrols/dragbutton.cpp @@ -43,7 +43,7 @@ void DragButton::mouseMoveEvent(QMouseEvent *event) QPushButton::mouseMoveEvent(event); if (event->buttons() && !dragging_) { - emit DragStarted(); + emit drag_started(); dragging_ = true; } } diff --git a/app/widget/playbackcontrols/dragbutton.h b/app/widget/playbackcontrols/dragbutton.h index d4e6a68ca..cab350bcf 100644 --- a/app/widget/playbackcontrols/dragbutton.h +++ b/app/widget/playbackcontrols/dragbutton.h @@ -19,8 +19,8 @@ ***/ -#ifndef DRAGBUTTON_H -#define DRAGBUTTON_H +#ifndef OAK_DRAGBUTTON_H +#define OAK_DRAGBUTTON_H #include @@ -35,7 +35,7 @@ public: DragButton(QWidget *parent = nullptr); signals: - void DragStarted(); + void drag_started(); protected: virtual void mousePressEvent(QMouseEvent *event) override; @@ -50,4 +50,4 @@ private: } -#endif // DRAGBUTTON_H +#endif // OAK_DRAGBUTTON_H diff --git a/app/widget/playbackcontrols/playbackcontrols.cpp b/app/widget/playbackcontrols/playbackcontrols.cpp index 9fcf1a442..52d18d3e7 100644 --- a/app/widget/playbackcontrols/playbackcontrols.cpp +++ b/app/widget/playbackcontrols/playbackcontrols.cpp @@ -57,10 +57,10 @@ PlaybackControls::PlaybackControls(QWidget *parent) lower_left_layout->setContentsMargins(0, 0, 0, 0); cur_tc_lbl_ = new RationalSlider(); - cur_tc_lbl_->SetDisplayType(RationalSlider::kTime); - cur_tc_lbl_->SetMinimum(0); - connect(cur_tc_lbl_, &RationalSlider::ValueChanged, this, - &PlaybackControls::TimeChanged); + cur_tc_lbl_->set_display_type(RationalSlider::k_time); + cur_tc_lbl_->set_minimum(0); + connect(cur_tc_lbl_, &RationalSlider::value_changed, this, + &PlaybackControls::time_changed); lower_left_layout->addWidget(cur_tc_lbl_); lower_left_layout->addStretch(); @@ -87,14 +87,14 @@ PlaybackControls::PlaybackControls(QWidget *parent) go_to_start_btn_->setSizePolicy(btn_sz_policy); lower_middle_layout->addWidget(go_to_start_btn_); connect(go_to_start_btn_, &QPushButton::clicked, this, - &PlaybackControls::BeginClicked); + &PlaybackControls::begin_clicked); // Prev Frame Button prev_frame_btn_ = new QPushButton(); prev_frame_btn_->setSizePolicy(btn_sz_policy); lower_middle_layout->addWidget(prev_frame_btn_); connect(prev_frame_btn_, &QPushButton::clicked, this, - &PlaybackControls::PrevFrameClicked); + &PlaybackControls::prev_frame_clicked); // Play/Pause Button playpause_stack_ = new QStackedWidget(); @@ -104,12 +104,12 @@ PlaybackControls::PlaybackControls(QWidget *parent) play_btn_ = new QPushButton(); playpause_stack_->addWidget(play_btn_); connect(play_btn_, &QPushButton::clicked, this, - &PlaybackControls::PlayClicked); + &PlaybackControls::play_clicked); pause_btn_ = new QPushButton(); playpause_stack_->addWidget(pause_btn_); connect(pause_btn_, &QPushButton::clicked, this, - &PlaybackControls::PauseClicked); + &PlaybackControls::pause_clicked); // Default to showing play button playpause_stack_->setCurrentWidget(play_btn_); @@ -119,14 +119,14 @@ PlaybackControls::PlaybackControls(QWidget *parent) next_frame_btn_->setSizePolicy(btn_sz_policy); lower_middle_layout->addWidget(next_frame_btn_); connect(next_frame_btn_, &QPushButton::clicked, this, - &PlaybackControls::NextFrameClicked); + &PlaybackControls::next_frame_clicked); // Go To End Button go_to_end_btn_ = new QPushButton(); go_to_end_btn_->setSizePolicy(btn_sz_policy); lower_middle_layout->addWidget(go_to_end_btn_); connect(go_to_end_btn_, &QPushButton::clicked, this, - &PlaybackControls::EndClicked); + &PlaybackControls::end_clicked); lower_middle_layout->addStretch(); @@ -137,15 +137,15 @@ PlaybackControls::PlaybackControls(QWidget *parent) av_btn_layout->setContentsMargins(0, 0, 0, 0); video_drag_btn_ = new DragButton(); connect(video_drag_btn_, &QPushButton::clicked, this, - &PlaybackControls::VideoClicked); - connect(video_drag_btn_, &DragButton::DragStarted, this, - &PlaybackControls::VideoDragged); + &PlaybackControls::video_clicked); + connect(video_drag_btn_, &DragButton::drag_started, this, + &PlaybackControls::video_dragged); av_btn_layout->addWidget(video_drag_btn_); audio_drag_btn_ = new DragButton(); connect(audio_drag_btn_, &QPushButton::clicked, this, - &PlaybackControls::AudioClicked); - connect(audio_drag_btn_, &DragButton::DragStarted, this, - &PlaybackControls::AudioDragged); + &PlaybackControls::audio_clicked); + connect(audio_drag_btn_, &DragButton::drag_started, this, + &PlaybackControls::audio_dragged); av_btn_layout->addWidget(audio_drag_btn_); lower_control_layout->addWidget(av_btn_widget); @@ -163,31 +163,31 @@ PlaybackControls::PlaybackControls(QWidget *parent) end_tc_lbl_ = new QLabel(); lower_right_layout->addWidget(end_tc_lbl_); - UpdateIcons(); + update_icons(); - SetTimebase(0); + set_timebase(0); - SetAudioVideoDragButtonsVisible(false); + set_audio_video_drag_buttons_visible(false); - connect(Core::instance(), &Core::TimecodeDisplayChanged, this, - &PlaybackControls::TimecodeChanged); + connect(Core::instance(), &Core::timecode_display_changed, this, + &PlaybackControls::timecode_changed); play_blink_timer_ = new QTimer(this); play_blink_timer_->setInterval(500); connect(play_blink_timer_, &QTimer::timeout, this, - &PlaybackControls::PlayBlink); + &PlaybackControls::play_blink); } -void PlaybackControls::SetTimecodeEnabled(bool enabled) +void PlaybackControls::set_timecode_enabled(bool enabled) { lower_left_container_->setVisible(enabled); lower_right_container_->setVisible(enabled); } -void PlaybackControls::SetTimebase(const rational &r) +void PlaybackControls::set_timebase(const Rational &r) { time_base_ = r; - cur_tc_lbl_->SetTimebase(r); + cur_tc_lbl_->set_timebase(r); cur_tc_lbl_->setVisible(!r.isNull()); end_tc_lbl_->setVisible(!r.isNull()); @@ -195,18 +195,18 @@ void PlaybackControls::SetTimebase(const rational &r) setEnabled(!r.isNull()); } -void PlaybackControls::SetAudioVideoDragButtonsVisible(bool e) +void PlaybackControls::set_audio_video_drag_buttons_visible(bool e) { video_drag_btn_->setVisible(e); audio_drag_btn_->setVisible(e); } -void PlaybackControls::SetTime(const rational &r) +void PlaybackControls::set_time(const Rational &r) { - cur_tc_lbl_->SetValue(r); + cur_tc_lbl_->set_value(r); } -void PlaybackControls::SetEndTime(const rational &r) +void PlaybackControls::set_end_time(const Rational &r) { if (time_base_.isNull()) { return; @@ -215,16 +215,16 @@ void PlaybackControls::SetEndTime(const rational &r) end_time_ = r; end_tc_lbl_->setText(QString::fromStdString(Timecode::time_to_timecode( - end_time_, time_base_, Core::instance()->GetTimecodeDisplay()))); + end_time_, time_base_, Core::instance()->get_timecode_display()))); } -void PlaybackControls::ShowPauseButton() +void PlaybackControls::show_pause_button() { // Play was clicked, toggle to pause playpause_stack_->setCurrentWidget(pause_btn_); } -void PlaybackControls::ShowPlayButton() +void PlaybackControls::show_play_button() { playpause_stack_->setCurrentWidget(play_btn_); } @@ -234,36 +234,36 @@ void PlaybackControls::changeEvent(QEvent *e) QWidget::changeEvent(e); if (e->type() == QEvent::StyleChange) { - UpdateIcons(); + update_icons(); } } -void PlaybackControls::UpdateIcons() +void PlaybackControls::update_icons() { - go_to_start_btn_->setIcon(icon::GoToStart); - prev_frame_btn_->setIcon(icon::PrevFrame); - play_btn_->setIcon(icon::Play); - pause_btn_->setIcon(icon::Pause); - next_frame_btn_->setIcon(icon::NextFrame); - go_to_end_btn_->setIcon(icon::GoToEnd); - video_drag_btn_->setIcon(icon::Video); - audio_drag_btn_->setIcon(icon::Audio); + go_to_start_btn_->setIcon(icon::go_to_start); + prev_frame_btn_->setIcon(icon::prev_frame); + play_btn_->setIcon(icon::play); + pause_btn_->setIcon(icon::pause); + next_frame_btn_->setIcon(icon::next_frame); + go_to_end_btn_->setIcon(icon::go_to_end); + video_drag_btn_->setIcon(icon::video); + audio_drag_btn_->setIcon(icon::audio); } -void PlaybackControls::SetButtonRecordingState(QPushButton *btn, bool on) +void PlaybackControls::set_button_recording_state(QPushButton *btn, bool on) { btn->setStyleSheet(on ? QStringLiteral("background: red;") : QString()); } -void PlaybackControls::TimecodeChanged() +void PlaybackControls::timecode_changed() { // Update end time - SetEndTime(end_time_); + set_end_time(end_time_); } -void PlaybackControls::PlayBlink() +void PlaybackControls::play_blink() { - SetButtonRecordingState(play_btn_, play_btn_->styleSheet().isEmpty()); + set_button_recording_state(play_btn_, play_btn_->styleSheet().isEmpty()); } } diff --git a/app/widget/playbackcontrols/playbackcontrols.h b/app/widget/playbackcontrols/playbackcontrols.h index 0b56054bc..ead2c10f5 100644 --- a/app/widget/playbackcontrols/playbackcontrols.h +++ b/app/widget/playbackcontrols/playbackcontrols.h @@ -19,8 +19,8 @@ ***/ -#ifndef PLAYBACKCONTROLS_H -#define PLAYBACKCONTROLS_H +#ifndef OAK_PLAYBACKCONTROLS_H +#define OAK_PLAYBACKCONTROLS_H #include #include @@ -46,86 +46,86 @@ public: /** * @brief Set whether the timecodes should be shown or not */ - void SetTimecodeEnabled(bool enabled); + void set_timecode_enabled(bool enabled); - void SetTimebase(const rational &r); + void set_timebase(const Rational &r); - void SetAudioVideoDragButtonsVisible(bool e); + void set_audio_video_drag_buttons_visible(bool e); public slots: - void SetTime(const rational &r); + void set_time(const Rational &r); - void SetEndTime(const rational &r); + void set_end_time(const Rational &r); - void ShowPauseButton(); + void show_pause_button(); - void ShowPlayButton(); + void show_play_button(); - void StartPlayBlink() + void start_play_blink() { play_blink_timer_->start(); - SetButtonRecordingState(play_btn_, true); + set_button_recording_state(play_btn_, true); } - void StopPlayBlink() + void stop_play_blink() { play_blink_timer_->stop(); - SetButtonRecordingState(play_btn_, false); + set_button_recording_state(play_btn_, false); } - void SetPauseButtonRecordingState(bool on) + void set_pause_button_recording_state(bool on) { - SetButtonRecordingState(pause_btn_, on); + set_button_recording_state(pause_btn_, on); } signals: /** * @brief Signal emitted when "Go to Start" is clicked */ - void BeginClicked(); + void begin_clicked(); /** * @brief Signal emitted when "Previous Frame" is clicked */ - void PrevFrameClicked(); + void prev_frame_clicked(); /** * @brief Signal emitted when "Play" is clicked */ - void PlayClicked(); + void play_clicked(); /** * @brief Signal emitted when "Pause" is clicked */ - void PauseClicked(); + void pause_clicked(); /** * @brief Signal emitted when "Next Frame" is clicked */ - void NextFrameClicked(); + void next_frame_clicked(); /** * @brief Signal emitted when "Go to End" is clicked */ - void EndClicked(); + void end_clicked(); - void AudioClicked(); + void audio_clicked(); - void VideoClicked(); + void video_clicked(); - void AudioDragged(); + void audio_dragged(); - void VideoDragged(); + void video_dragged(); - void TimeChanged(const rational &t); + void time_changed(const Rational &t); protected: virtual void changeEvent(QEvent *) override; private: - void UpdateIcons(); + void update_icons(); - static void SetButtonRecordingState(QPushButton *btn, bool on); + static void set_button_recording_state(QPushButton *btn, bool on); QWidget *lower_left_container_; QWidget *lower_right_container_; @@ -133,9 +133,9 @@ private: RationalSlider *cur_tc_lbl_; QLabel *end_tc_lbl_; - rational end_time_; + Rational end_time_; - rational time_base_; + Rational time_base_; QPushButton *go_to_start_btn_; QPushButton *prev_frame_btn_; @@ -151,11 +151,11 @@ private: QTimer *play_blink_timer_; private slots: - void TimecodeChanged(); + void timecode_changed(); - void PlayBlink(); + void play_blink(); }; } -#endif // PLAYBACKCONTROLS_H +#endif // OAK_PLAYBACKCONTROLS_H diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index 4c14cb9a9..cda9a6490 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -50,12 +50,12 @@ namespace olive namespace { -QVector GetSelectedProxyFootage(const QVector &items) +QVector get_selected_proxy_footage(const QVector &items) { QVector footage; for (Node *node : items) { Footage *candidate = dynamic_cast(node); - if (!candidate || !candidate->GetFirstEnabledVideoStream().is_valid() || + if (!candidate || !candidate->get_first_enabled_video_stream().is_valid() || footage.contains(candidate)) { continue; } @@ -76,10 +76,10 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) // Set up navigation bar nav_bar_ = new ProjectExplorerNavigation(this); - connect(nav_bar_, &ProjectExplorerNavigation::SizeChanged, this, - &ProjectExplorer::SizeChangedSlot); - connect(nav_bar_, &ProjectExplorerNavigation::DirectoryUpClicked, this, - &ProjectExplorer::DirUpSlot); + connect(nav_bar_, &ProjectExplorerNavigation::size_changed, this, + &ProjectExplorer::size_changed_slot); + connect(nav_bar_, &ProjectExplorerNavigation::directory_up_clicked, this, + &ProjectExplorer::dir_up_slot); layout->addWidget(nav_bar_); // Set up stacked widget @@ -89,39 +89,39 @@ ProjectExplorer::ProjectExplorer(QWidget *parent) // Set up sort filter proxy model sort_model_.setSourceModel(&model_); sort_model_.setFilterCaseSensitivity(Qt::CaseInsensitive); - sort_model_.setSortRole(ProjectViewModel::kInnerTextRole); + sort_model_.setSortRole(ProjectViewModel::k_inner_text_role); // Add tree view to stacked widget tree_view_ = new ProjectExplorerTreeView(stacked_widget_); tree_view_->setSortingEnabled(true); tree_view_->sortByColumn(0, Qt::AscendingOrder); tree_view_->setContextMenuPolicy(Qt::CustomContextMenu); - AddView(tree_view_); + add_view(tree_view_); // Add list view to stacked widget list_view_ = new ProjectExplorerListView(stacked_widget_); list_view_->setContextMenuPolicy(Qt::CustomContextMenu); - AddView(list_view_); + add_view(list_view_); // Add icon view to stacked widget icon_view_ = new ProjectExplorerIconView(stacked_widget_); icon_view_->setContextMenuPolicy(Qt::CustomContextMenu); - AddView(icon_view_); + add_view(icon_view_); // Set default view to tree view - set_view_type(ProjectToolbar::TreeView); + set_view_type(ProjectToolbar::tree_view); // Set default icon size - SizeChangedSlot(kProjectIconSizeDefault); + size_changed_slot(k_project_icon_size_default); connect(tree_view_, &ProjectExplorerTreeView::customContextMenuRequested, - this, &ProjectExplorer::ShowContextMenu); + this, &ProjectExplorer::show_context_menu); connect(list_view_, &ProjectExplorerListView::customContextMenuRequested, - this, &ProjectExplorer::ShowContextMenu); + this, &ProjectExplorer::show_context_menu); connect(icon_view_, &ProjectExplorerIconView::customContextMenuRequested, - this, &ProjectExplorer::ShowContextMenu); + this, &ProjectExplorer::show_context_menu); - UpdateNavBarText(); + update_nav_bar_text(); } const ProjectToolbar::ViewType &ProjectExplorer::view_type() const @@ -135,54 +135,54 @@ void ProjectExplorer::set_view_type(ProjectToolbar::ViewType type) // Set widget based on view type switch (view_type_) { - case ProjectToolbar::TreeView: + case ProjectToolbar::tree_view: stacked_widget_->setCurrentWidget(tree_view_); nav_bar_->setVisible(false); break; - case ProjectToolbar::ListView: + case ProjectToolbar::list_view: stacked_widget_->setCurrentWidget(list_view_); nav_bar_->setVisible(true); break; - case ProjectToolbar::IconView: + case ProjectToolbar::icon_view: stacked_widget_->setCurrentWidget(icon_view_); nav_bar_->setVisible(true); break; } } -void ProjectExplorer::Edit(Node *item) +void ProjectExplorer::edit(Node *item) { - CurrentView()->edit( - sort_model_.mapFromSource(model_.CreateIndexFromItem(item))); + current_view()->edit( + sort_model_.mapFromSource(model_.create_index_from_item(item))); } -void ProjectExplorer::AddView(QAbstractItemView *view) +void ProjectExplorer::add_view(QAbstractItemView *view) { view->setModel(&sort_model_); view->setEditTriggers(QAbstractItemView::SelectedClicked); connect(view, &QAbstractItemView::doubleClicked, this, - &ProjectExplorer::ItemDoubleClickedSlot); + &ProjectExplorer::item_double_clicked_slot); connect(view->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &ProjectExplorer::ViewSelectionChanged); - connect(view, SIGNAL(DoubleClickedEmptyArea()), this, - SLOT(ViewEmptyAreaDoubleClickedSlot())); + this, &ProjectExplorer::view_selection_changed); + connect(view, SIGNAL(double_clicked_empty_area()), this, + SLOT(view_empty_area_double_clicked_slot())); stacked_widget_->addWidget(view); } -void ProjectExplorer::BrowseToFolder(const QModelIndex &index) +void ProjectExplorer::browse_to_folder(const QModelIndex &index) { // Set appropriate views to this index icon_view_->setRootIndex(index); list_view_->setRootIndex(index); // Set navbar text to folder's name - UpdateNavBarText(); + update_nav_bar_text(); // Set directory up enabled button based on whether we're in root or not nav_bar_->set_dir_up_enabled(index.isValid()); } -int ProjectExplorer::ConfirmItemDeletion(Node *item) +int ProjectExplorer::confirm_item_deletion(Node *item) { QMessageBox msgbox(this); msgbox.setWindowTitle(tr("Confirm Item Deletion")); @@ -193,7 +193,7 @@ int ProjectExplorer::ConfirmItemDeletion(Node *item) item->output_connections()) { if (!dynamic_cast(connected.second.node())) { connected_nodes_names.append( - GetHumanReadableNodeName(connected.second.node())); + get_human_readable_node_name(connected.second.node())); } } @@ -201,7 +201,7 @@ int ProjectExplorer::ConfirmItemDeletion(Node *item) tr("The item \"%1\" is currently connected to the following nodes:\n\n" "%2\n\n" "Are you sure you wish to delete this footage?") - .arg(GetHumanReadableNodeName(item), + .arg(get_human_readable_node_name(item), connected_nodes_names.join('\n'))); // Set up buttons @@ -214,7 +214,7 @@ int ProjectExplorer::ConfirmItemDeletion(Node *item) return msgbox.exec(); } -bool ProjectExplorer::DeleteItemsInternal(const QVector &selected, +bool ProjectExplorer::delete_items_internal(const QVector &selected, bool &check_if_item_is_in_use, MultiUndoCommand *command) { @@ -230,7 +230,7 @@ bool ProjectExplorer::DeleteItemsInternal(const QVector &selected, Folder *folder_test = dynamic_cast(oc.second.node()); if (!folder_test) { // This sequence outputs to SOMETHING, confirm the user if they want to delete this - int r = ConfirmItemDeletion(node); + int r = confirm_item_deletion(node); switch (r) { case QMessageBox::No: @@ -249,7 +249,7 @@ bool ProjectExplorer::DeleteItemsInternal(const QVector &selected, if (can_delete_item) { Sequence *sequence = dynamic_cast(node); if (sequence && - Core::instance()->main_window()->IsSequenceOpen(sequence)) { + Core::instance()->main_window()->is_sequence_open(sequence)) { command->add_child(new CloseSequenceCommand(sequence)); } @@ -266,23 +266,23 @@ bool ProjectExplorer::DeleteItemsInternal(const QVector &selected, return true; } -QString ProjectExplorer::GetHumanReadableNodeName(Node *node) +QString ProjectExplorer::get_human_readable_node_name(Node *node) { - if (node->GetLabel().isEmpty()) { - return node->Name(); + if (node->get_label().isEmpty()) { + return node->name(); } else { - return tr("%1 (%2)").arg(node->GetLabel(), node->Name()); + return tr("%1 (%2)").arg(node->get_label(), node->name()); } } -void ProjectExplorer::UpdateNavBarText() +void ProjectExplorer::update_nav_bar_text() { QString absolute; Folder *f = static_cast( sort_model_.mapToSource(list_view_->rootIndex()).internalPointer()); while (f && f != project()->root()) { - absolute.prepend(QStringLiteral("%1 / ").arg(f->GetLabel())); + absolute.prepend(QStringLiteral("%1 / ").arg(f->get_label())); f = f->folder(); } @@ -291,17 +291,17 @@ void ProjectExplorer::UpdateNavBarText() nav_bar_->set_text(absolute); } -QAbstractItemView *ProjectExplorer::CurrentView() const +QAbstractItemView *ProjectExplorer::current_view() const { return static_cast(stacked_widget_->currentWidget()); } -void ProjectExplorer::ViewEmptyAreaDoubleClickedSlot() +void ProjectExplorer::view_empty_area_double_clicked_slot() { - emit DoubleClickedItem(nullptr); + emit double_clicked_item(nullptr); } -void ProjectExplorer::ItemDoubleClickedSlot(const QModelIndex &index) +void ProjectExplorer::item_double_clicked_slot(const QModelIndex &index) { // Retrieve source item from index Node *i = @@ -309,65 +309,65 @@ void ProjectExplorer::ItemDoubleClickedSlot(const QModelIndex &index) // If the item is a folder, browse to it if (dynamic_cast(i) && - (view_type() == ProjectToolbar::ListView || - view_type() == ProjectToolbar::IconView)) { - BrowseToFolder(index); + (view_type() == ProjectToolbar::list_view || + view_type() == ProjectToolbar::icon_view)) { + browse_to_folder(index); } // Emit a signal - emit DoubleClickedItem(i); + emit double_clicked_item(i); } -void ProjectExplorer::SizeChangedSlot(int s) +void ProjectExplorer::size_changed_slot(int s) { icon_view_->setGridSize(QSize(s, s)); list_view_->setIconSize(QSize(s, s)); } -void ProjectExplorer::DirUpSlot() +void ProjectExplorer::dir_up_slot() { QModelIndex current_root = icon_view_->rootIndex(); if (current_root.isValid()) { QModelIndex parent = current_root.parent(); - BrowseToFolder(parent); + browse_to_folder(parent); } } -void ProjectExplorer::RenameSelectedItem() +void ProjectExplorer::rename_selected_item() { - auto indexes = CurrentView()->selectionModel()->selectedRows(); + auto indexes = current_view()->selectionModel()->selectedRows(); if (!indexes.empty()) { - CurrentView()->edit(indexes.first()); + current_view()->edit(indexes.first()); } } -void ProjectExplorer::SetSearchFilter(const QString &s) +void ProjectExplorer::set_search_filter(const QString &s) { sort_model_.setFilterFixedString(s); } -void ProjectExplorer::ShowContextMenu() +void ProjectExplorer::show_context_menu() { Menu menu; Menu new_menu; - context_menu_items_ = SelectedItems(); + context_menu_items_ = selected_items(); if (context_menu_items_.isEmpty()) { // Items to show if no items are selected // "New" menu new_menu.setTitle(tr("&New")); - MenuShared::instance()->AddItemsForNewMenu(&new_menu); + MenuShared::instance()->add_items_for_new_menu(&new_menu); menu.addMenu(&new_menu); // "Import" action QAction *import_action = menu.addAction(tr("&Import...")); connect(import_action, &QAction::triggered, Core::instance(), - &Core::DialogImportShow); + &Core::dialog_import_show); } else { // Actions to add when only one item is selected if (context_menu_items_.size() == 1) { @@ -377,12 +377,12 @@ void ProjectExplorer::ShowContextMenu() QAction *open_in_new_tab = menu.addAction(tr("Open in New Tab")); connect(open_in_new_tab, &QAction::triggered, this, - &ProjectExplorer::OpenContextMenuItemInNewTab); + &ProjectExplorer::open_context_menu_item_in_new_tab); QAction *open_in_new_window = menu.addAction(tr("Open in New Window")); connect(open_in_new_window, &QAction::triggered, this, - &ProjectExplorer::OpenContextMenuItemInNewWindow); + &ProjectExplorer::open_context_menu_item_in_new_window); } else if (dynamic_cast(context_menu_item)) { QString reveal_text; @@ -397,11 +397,11 @@ void ProjectExplorer::ShowContextMenu() QAction *reveal_action = menu.addAction(reveal_text); connect(reveal_action, &QAction::triggered, this, - &ProjectExplorer::RevealSelectedFootage); + &ProjectExplorer::reveal_selected_footage); QAction *replace_action = menu.addAction(tr("Replace Footage")); connect(replace_action, &QAction::triggered, this, - &ProjectExplorer::ReplaceSelectedFootage); + &ProjectExplorer::replace_selected_footage); } menu.addSeparator(); @@ -416,7 +416,7 @@ void ProjectExplorer::ShowContextMenu() Sequence *sequence_cast_test = dynamic_cast(i); if (footage_cast_test && - !footage_cast_test->HasEnabledVideoStreams()) { + !footage_cast_test->has_enabled_video_streams()) { all_items_have_video_streams = false; } @@ -431,7 +431,7 @@ void ProjectExplorer::ShowContextMenu() if (all_items_are_footage && all_items_have_video_streams) { const QVector proxy_footage = - GetSelectedProxyFootage(context_menu_items_); + get_selected_proxy_footage(context_menu_items_); Menu *proxy_menu = new Menu(tr("Proxy"), &menu); menu.addMenu(proxy_menu); @@ -440,7 +440,7 @@ void ProjectExplorer::ShowContextMenu() proxy_menu->addAction(tr("Generate Proxy")); generate_proxy->setEnabled(!proxy_footage.isEmpty()); connect(generate_proxy, &QAction::triggered, this, - &ProjectExplorer::GenerateProxiesForSelectedFootage); + &ProjectExplorer::generate_proxies_for_selected_footage); QAction *use_proxy = proxy_menu->addAction(tr("Use Proxy")); use_proxy->setCheckable(true); @@ -452,7 +452,7 @@ void ProjectExplorer::ShowContextMenu() return footage->proxy_enabled(); })); connect(use_proxy, &QAction::triggered, this, - &ProjectExplorer::SetSelectedFootageProxyEnabled); + &ProjectExplorer::set_selected_footage_proxy_enabled); QAction *reveal_proxy = proxy_menu->addAction(tr("Reveal Proxy")); reveal_proxy->setEnabled( @@ -461,7 +461,7 @@ void ProjectExplorer::ShowContextMenu() return !footage->proxy_path().isEmpty(); })); connect(reveal_proxy, &QAction::triggered, this, - &ProjectExplorer::RevealProxyForSelectedFootage); + &ProjectExplorer::reveal_proxy_for_selected_footage); QAction *delete_proxy = proxy_menu->addAction(tr("Delete Proxy")); delete_proxy->setEnabled( @@ -470,12 +470,12 @@ void ProjectExplorer::ShowContextMenu() return !footage->proxy_path().isEmpty(); })); connect(delete_proxy, &QAction::triggered, this, - &ProjectExplorer::DeleteProxiesForSelectedFootage); + &ProjectExplorer::delete_proxies_for_selected_footage); QAction *proxy_settings = proxy_menu->addAction(tr("Proxy Settings...")); connect(proxy_settings, &QAction::triggered, this, - &ProjectExplorer::ShowProxyDialogForSelectedFootage); + &ProjectExplorer::show_proxy_dialog_for_selected_footage); } Q_UNUSED(all_items_are_footage_or_sequence) @@ -485,26 +485,26 @@ void ProjectExplorer::ShowContextMenu() auto rename_action = menu.addAction(tr("Rename")); connect(rename_action, &QAction::triggered, this, - &ProjectExplorer::RenameSelectedItem); + &ProjectExplorer::rename_selected_item); } auto delete_action = menu.addAction(tr("Delete")); connect(delete_action, &QAction::triggered, this, - &ProjectExplorer::DeleteSelected); + &ProjectExplorer::delete_selected); if (context_menu_items_.size() == 1) { menu.addSeparator(); QAction *properties_action = menu.addAction(tr("P&roperties")); connect(properties_action, &QAction::triggered, this, - &ProjectExplorer::ShowItemPropertiesDialog); + &ProjectExplorer::show_item_properties_dialog); } } menu.exec(QCursor::pos()); } -void ProjectExplorer::ShowItemPropertiesDialog() +void ProjectExplorer::show_item_properties_dialog() { Node *sel = context_menu_items_.first(); @@ -514,16 +514,16 @@ void ProjectExplorer::ShowItemPropertiesDialog() fpd.exec(); } else if (dynamic_cast(sel)) { - Core::instance()->LabelNodes(context_menu_items_); + Core::instance()->label_nodes(context_menu_items_); } else if (dynamic_cast(sel)) { SequenceDialog sd(static_cast(sel), - SequenceDialog::kExisting, this); + SequenceDialog::k_existing, this); sd.exec(); } } -void ProjectExplorer::RevealSelectedFootage() +void ProjectExplorer::reveal_selected_footage() { Footage *footage = static_cast(context_menu_items_.first()); @@ -549,15 +549,15 @@ void ProjectExplorer::RevealSelectedFootage() #endif } -void ProjectExplorer::ReplaceSelectedFootage() +void ProjectExplorer::replace_selected_footage() { Footage *footage = static_cast(context_menu_items_.first()); QString file = QFileDialog::getOpenFileName(this, tr("Replace Footage"), QString(), - Core::FootageFileDialogFilter()); + Core::footage_file_dialog_filter()); if (!file.isEmpty()) { - if (!Core::IsFootageExtensionAllowed(file)) { + if (!Core::is_footage_extension_allowed(file)) { QMessageBox::warning( this, tr("Unsupported media"), tr("This file type is not allowed by the current media type " @@ -570,10 +570,10 @@ void ProjectExplorer::ReplaceSelectedFootage() // Change filename parameter p->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(footage, Footage::kFilenameInput)), + NodeInput(footage, Footage::k_filename_input)), file)); - if (QFileInfo(footage->filename()).fileName() == footage->GetLabel()) { + if (QFileInfo(footage->filename()).fileName() == footage->get_label()) { // Footage label == filename, change label too p->add_child( new NodeRenameCommand(footage, QFileInfo(file).fileName())); @@ -583,19 +583,19 @@ void ProjectExplorer::ReplaceSelectedFootage() } } -void ProjectExplorer::OpenContextMenuItemInNewTab() +void ProjectExplorer::open_context_menu_item_in_new_tab() { - Core::instance()->main_window()->OpenFolder( + Core::instance()->main_window()->open_folder( static_cast(context_menu_items_.first()), false); } -void ProjectExplorer::OpenContextMenuItemInNewWindow() +void ProjectExplorer::open_context_menu_item_in_new_window() { - Core::instance()->main_window()->OpenFolder( + Core::instance()->main_window()->open_folder( static_cast(context_menu_items_.first()), true); } -void ProjectExplorer::GenerateProxiesForSelectedFootage() +void ProjectExplorer::generate_proxies_for_selected_footage() { if (!ProxyManager::instance() || !project()) { qWarning() @@ -604,12 +604,12 @@ void ProjectExplorer::GenerateProxiesForSelectedFootage() } const QVector footage = - GetSelectedProxyFootage(context_menu_items_); + get_selected_proxy_footage(context_menu_items_); qDebug() << "GenerateProxiesForSelectedFootage: starting proxy generation for" << footage.size() << "footage item(s)"; for (Footage *item : footage) { - const VideoParams video = item->GetFirstEnabledVideoStream(); + const VideoParams video = item->get_first_enabled_video_stream(); if (!video.is_valid()) { qWarning() << "GenerateProxiesForSelectedFootage: skipping item with no valid video stream" @@ -617,25 +617,25 @@ void ProjectExplorer::GenerateProxiesForSelectedFootage() continue; } - ProxyManager::ProxyParams params = item->GetEffectiveProxyParams(); + ProxyManager::ProxyParams params = item->get_effective_proxy_params(); const ProxyManager::Proxy proxy = - ProxyManager::instance()->GetOrStartProxy( + ProxyManager::instance()->get_or_start_proxy( item->project()->cache_path(), item->filename(), video.stream_index(), params); qDebug() << "GenerateProxiesForSelectedFootage: proxy state=" - << ProxyManager::ProxyStateToString(proxy.state) + << ProxyManager::proxy_state_to_string(proxy.state) << "file=" << proxy.filename << "cache=" << item->project()->cache_path(); - item->SetProxy(proxy.filename, proxy.state, video.stream_index(), + item->set_proxy(proxy.filename, proxy.state, video.stream_index(), params.version, true); - item->InvalidateAll(Footage::kFilenameInput); + item->invalidate_all(Footage::k_filename_input); } } -void ProjectExplorer::SetSelectedFootageProxyEnabled(bool enabled) +void ProjectExplorer::set_selected_footage_proxy_enabled(bool enabled) { const QVector footage = - GetSelectedProxyFootage(context_menu_items_); + get_selected_proxy_footage(context_menu_items_); qDebug() << "ProjectExplorer::SetSelectedFootageProxyEnabled:" << enabled << "footage count=" << footage.size(); for (Footage *item : footage) { @@ -646,14 +646,14 @@ void ProjectExplorer::SetSelectedFootageProxyEnabled(bool enabled) } item->set_proxy_enabled(enabled); - item->InvalidateAll(Footage::kFilenameInput); + item->invalidate_all(Footage::k_filename_input); } } -void ProjectExplorer::RevealProxyForSelectedFootage() +void ProjectExplorer::reveal_proxy_for_selected_footage() { const QVector footage = - GetSelectedProxyFootage(context_menu_items_); + get_selected_proxy_footage(context_menu_items_); for (Footage *item : footage) { if (item->proxy_path().isEmpty()) { continue; @@ -681,28 +681,28 @@ void ProjectExplorer::RevealProxyForSelectedFootage() } } -void ProjectExplorer::DeleteProxiesForSelectedFootage() +void ProjectExplorer::delete_proxies_for_selected_footage() { const QVector footage = - GetSelectedProxyFootage(context_menu_items_); + get_selected_proxy_footage(context_menu_items_); for (Footage *item : footage) { if (item->proxy_path().isEmpty()) { continue; } QFile::remove(item->proxy_path()); - item->ClearProxy(); - item->InvalidateAll(Footage::kFilenameInput); + item->clear_proxy(); + item->invalidate_all(Footage::k_filename_input); } } -void ProjectExplorer::ShowProxyDialogForSelectedFootage() +void ProjectExplorer::show_proxy_dialog_for_selected_footage() { - ProxyDialog d(this, GetSelectedProxyFootage(context_menu_items_)); + ProxyDialog d(this, get_selected_proxy_footage(context_menu_items_)); d.exec(); } -void ProjectExplorer::ViewSelectionChanged() +void ProjectExplorer::view_selection_changed() { QItemSelectionModel *model = static_cast(sender()); @@ -722,7 +722,7 @@ void ProjectExplorer::ViewSelectionChanged() nodes.append(get_root()); } - emit SelectionChanged(nodes); + emit selection_changed(nodes); } Project *ProjectExplorer::project() const @@ -749,17 +749,17 @@ Folder *ProjectExplorer::get_root() const void ProjectExplorer::set_root(Folder *item) { QModelIndex index = - sort_model_.mapFromSource(model_.CreateIndexFromItem(item)); + sort_model_.mapFromSource(model_.create_index_from_item(item)); - BrowseToFolder(index); + browse_to_folder(index); tree_view_->setRootIndex(index); } -QVector ProjectExplorer::SelectedItems() const +QVector ProjectExplorer::selected_items() const { // Determine which view is active and get its selected indexes QModelIndexList index_list = - CurrentView()->selectionModel()->selectedRows(); + current_view()->selectionModel()->selectedRows(); // Convert indexes to item objects QVector selected_items; @@ -775,7 +775,7 @@ QVector ProjectExplorer::SelectedItems() const return selected_items; } -Folder *ProjectExplorer::GetSelectedFolder() const +Folder *ProjectExplorer::get_selected_folder() const { if (project() == nullptr) { return nullptr; @@ -784,7 +784,7 @@ Folder *ProjectExplorer::GetSelectedFolder() const Folder *folder = nullptr; // Get the selected items from the panel - QVector selected_items = SelectedItems(); + QVector selected_nodes = selected_items(); // Heuristic for finding the selected folder: // @@ -793,8 +793,8 @@ Folder *ProjectExplorer::GetSelectedFolder() const // - Otherwise, if all folders found are the same, we'll use that to import into. // - If more than one folder is found, we play it safe and import into the root folder - for (int i = 0; i < selected_items.size(); i++) { - Node *sel_item = selected_items.at(i); + for (int i = 0; i < selected_nodes.size(); i++) { + Node *sel_item = selected_nodes.at(i); // If this item is not a folder, presumably it's parent is if (!dynamic_cast(sel_item)) { @@ -825,19 +825,19 @@ ProjectViewModel *ProjectExplorer::model() return &model_; } -void ProjectExplorer::SelectAll() +void ProjectExplorer::select_all() { - CurrentView()->selectAll(); + current_view()->selectAll(); } -void ProjectExplorer::DeselectAll() +void ProjectExplorer::deselect_all() { - CurrentView()->selectionModel()->clearSelection(); + current_view()->selectionModel()->clearSelection(); } -void ProjectExplorer::DeleteSelected() +void ProjectExplorer::delete_selected() { - QVector selected = SelectedItems(); + QVector selected = selected_items(); if (selected.isEmpty()) { return; @@ -847,7 +847,7 @@ void ProjectExplorer::DeleteSelected() bool check_if_item_is_in_use = true; - if (DeleteItemsInternal(selected, check_if_item_is_in_use, command)) { + if (delete_items_internal(selected, check_if_item_is_in_use, command)) { Core::instance()->undo_stack()->push( command, tr("Deleted %1 Item(s)").arg(selected.size())); } else { @@ -855,29 +855,29 @@ void ProjectExplorer::DeleteSelected() } } -bool ProjectExplorer::SelectItem(Node *n, bool deselect_all_first) +bool ProjectExplorer::select_item(Node *n, bool deselect_all_first) { if (deselect_all_first) { - DeselectAll(); + deselect_all(); } - QModelIndex index = model_.CreateIndexFromItem(n); + QModelIndex index = model_.create_index_from_item(n); if (index.isValid()) { index = sort_model_.mapFromSource(index); QModelIndex parent = index.parent(); - if (view_type() == ProjectToolbar::TreeView) { + if (view_type() == ProjectToolbar::tree_view) { // Expand all folders until this index is visible while (parent.isValid()) { tree_view_->expand(parent); parent = parent.parent(); } } else { - BrowseToFolder(parent); + browse_to_folder(parent); } - CurrentView()->selectionModel()->select( + current_view()->selectionModel()->select( index, QItemSelectionModel::Select | QItemSelectionModel::Rows); return true; diff --git a/app/widget/projectexplorer/projectexplorer.h b/app/widget/projectexplorer/projectexplorer.h index 9ef43a418..4f79ceaf2 100644 --- a/app/widget/projectexplorer/projectexplorer.h +++ b/app/widget/projectexplorer/projectexplorer.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORER_H -#define PROJECTEXPLORER_H +#ifndef OAK_PROJECTEXPLORER_H +#define OAK_PROJECTEXPLORER_H #include #include @@ -59,7 +59,7 @@ public: Folder *get_root() const; void set_root(Folder *item); - QVector SelectedItems() const; + QVector selected_items() const; /** * @brief Use a heuristic to determine which (if any) folder is selected @@ -73,29 +73,29 @@ public: * A folder that's heuristically been determined as "selected", or the root directory if none, or nullptr if no * project is open. */ - Folder *GetSelectedFolder() const; + Folder *get_selected_folder() const; /** * @brief Access the ViewModel model of the project */ ProjectViewModel *model(); - void SelectAll(); + void select_all(); - void DeselectAll(); + void deselect_all(); - void DeleteSelected(); + void delete_selected(); - bool SelectItem(Node *n, bool deselect_all_first = true); + bool select_item(Node *n, bool deselect_all_first = true); public slots: void set_view_type(ProjectToolbar::ViewType type); - void Edit(Node *item); + void edit(Node *item); - void RenameSelectedItem(); + void rename_selected_item(); - void SetSearchFilter(const QString &s); + void set_search_filter(const QString &s); signals: /** @@ -105,9 +105,9 @@ signals: * * The Item that was double clicked, or nullptr if empty area was double clicked */ - void DoubleClickedItem(Node *item); + void double_clicked_item(Node *item); - void SelectionChanged(const QVector &selected); + void selection_changed(const QVector &selected); private: /** @@ -115,7 +115,7 @@ private: * * Ignores blocks that depend on multiple inputs */ - QList GetFootageBlocks(QList nodes); + QList get_footage_blocks(QList nodes); /** * @brief Simple convenience function for adding a view to this stacked widget @@ -126,7 +126,7 @@ private: * * View to add to the stack */ - void AddView(QAbstractItemView *view); + void add_view(QAbstractItemView *view); /** * @brief Browse to a specific folder index in the model @@ -137,22 +137,22 @@ private: * * Either an invalid index to return to the project root, or an index to a valid Folder object. */ - void BrowseToFolder(const QModelIndex &index); + void browse_to_folder(const QModelIndex &index); - int ConfirmItemDeletion(Node *item); + int confirm_item_deletion(Node *item); - bool DeleteItemsInternal(const QVector &selected, + bool delete_items_internal(const QVector &selected, bool &check_if_item_is_in_use, MultiUndoCommand *command); - static QString GetHumanReadableNodeName(Node *node); + static QString get_human_readable_node_name(Node *node); - void UpdateNavBarText(); + void update_nav_bar_text(); /** * @brief Get the currently active QAbstractItemView */ - QAbstractItemView *CurrentView() const; + QAbstractItemView *current_view() const; QStackedWidget *stacked_widget_; @@ -170,39 +170,39 @@ private: QVector context_menu_items_; private slots: - void ViewEmptyAreaDoubleClickedSlot(); + void view_empty_area_double_clicked_slot(); - void ItemDoubleClickedSlot(const QModelIndex &index); + void item_double_clicked_slot(const QModelIndex &index); - void SizeChangedSlot(int s); + void size_changed_slot(int s); - void DirUpSlot(); + void dir_up_slot(); - void ShowContextMenu(); + void show_context_menu(); - void ShowItemPropertiesDialog(); + void show_item_properties_dialog(); - void RevealSelectedFootage(); + void reveal_selected_footage(); - void ReplaceSelectedFootage(); + void replace_selected_footage(); - void OpenContextMenuItemInNewTab(); + void open_context_menu_item_in_new_tab(); - void OpenContextMenuItemInNewWindow(); + void open_context_menu_item_in_new_window(); - void GenerateProxiesForSelectedFootage(); + void generate_proxies_for_selected_footage(); - void SetSelectedFootageProxyEnabled(bool enabled); + void set_selected_footage_proxy_enabled(bool enabled); - void RevealProxyForSelectedFootage(); + void reveal_proxy_for_selected_footage(); - void DeleteProxiesForSelectedFootage(); + void delete_proxies_for_selected_footage(); - void ShowProxyDialogForSelectedFootage(); + void show_proxy_dialog_for_selected_footage(); - void ViewSelectionChanged(); + void view_selection_changed(); }; } -#endif // PROJECTEXPLORER_H +#endif // OAK_PROJECTEXPLORER_H diff --git a/app/widget/projectexplorer/projectexplorericonview.h b/app/widget/projectexplorer/projectexplorericonview.h index b4d417caf..ce5871c78 100644 --- a/app/widget/projectexplorer/projectexplorericonview.h +++ b/app/widget/projectexplorer/projectexplorericonview.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORERICONVIEW_H -#define PROJECTEXPLORERICONVIEW_H +#ifndef OAK_PROJECTEXPLORERICONVIEW_H +#define OAK_PROJECTEXPLORERICONVIEW_H #include "projectexplorerlistviewbase.h" #include "projectexplorericonviewitemdelegate.h" @@ -42,4 +42,4 @@ private: } -#endif // PROJECTEXPLORERICONVIEW_H +#endif // OAK_PROJECTEXPLORERICONVIEW_H diff --git a/app/widget/projectexplorer/projectexplorericonviewitemdelegate.cpp b/app/widget/projectexplorer/projectexplorericonviewitemdelegate.cpp index 3f06c8b50..692ddf4ce 100644 --- a/app/widget/projectexplorer/projectexplorericonviewitemdelegate.cpp +++ b/app/widget/projectexplorer/projectexplorericonviewitemdelegate.cpp @@ -72,7 +72,7 @@ void ProjectExplorerIconViewItemDelegate::paint( QString duration_str = index.data(Qt::UserRole).toString(); - int timecode_width = QtUtils::QFontMetricsWidth(fm, duration_str); + int timecode_width = QtUtils::q_font_metrics_width(fm, duration_str); int max_name_width = option.rect.width(); diff --git a/app/widget/projectexplorer/projectexplorericonviewitemdelegate.h b/app/widget/projectexplorer/projectexplorericonviewitemdelegate.h index ac5a136ee..d7c2d01e3 100644 --- a/app/widget/projectexplorer/projectexplorericonviewitemdelegate.h +++ b/app/widget/projectexplorer/projectexplorericonviewitemdelegate.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORERICONVIEWITEMDELEGATE_H -#define PROJECTEXPLORERICONVIEWITEMDELEGATE_H +#ifndef OAK_PROJECTEXPLORERICONVIEWITEMDELEGATE_H +#define OAK_PROJECTEXPLORERICONVIEWITEMDELEGATE_H #include @@ -44,4 +44,4 @@ public: } -#endif // PROJECTEXPLORERICONVIEWITEMDELEGATE_H +#endif // OAK_PROJECTEXPLORERICONVIEWITEMDELEGATE_H diff --git a/app/widget/projectexplorer/projectexplorerlistview.h b/app/widget/projectexplorer/projectexplorerlistview.h index 2f7d823fe..2a34429f8 100644 --- a/app/widget/projectexplorer/projectexplorerlistview.h +++ b/app/widget/projectexplorer/projectexplorerlistview.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORERLISTVIEW_H -#define PROJECTEXPLORERLISTVIEW_H +#ifndef OAK_PROJECTEXPLORERLISTVIEW_H +#define OAK_PROJECTEXPLORERLISTVIEW_H #include "projectexplorerlistviewbase.h" #include "projectexplorerlistviewitemdelegate.h" @@ -42,4 +42,4 @@ private: } -#endif // PROJECTEXPLORERLISTVIEW_H +#endif // OAK_PROJECTEXPLORERLISTVIEW_H diff --git a/app/widget/projectexplorer/projectexplorerlistviewbase.cpp b/app/widget/projectexplorer/projectexplorerlistviewbase.cpp index c98799c84..848528713 100644 --- a/app/widget/projectexplorer/projectexplorerlistviewbase.cpp +++ b/app/widget/projectexplorer/projectexplorerlistviewbase.cpp @@ -52,7 +52,7 @@ void ProjectExplorerListViewBase::mouseDoubleClickEvent(QMouseEvent *event) // QAbstractItemView already has a doubleClicked() signal, but we emit another here for double clicking empty space if (!item_at_location) { - emit DoubleClickedEmptyArea(); + emit double_clicked_empty_area(); } } diff --git a/app/widget/projectexplorer/projectexplorerlistviewbase.h b/app/widget/projectexplorer/projectexplorerlistviewbase.h index 8f3adebcf..2169b573a 100644 --- a/app/widget/projectexplorer/projectexplorerlistviewbase.h +++ b/app/widget/projectexplorer/projectexplorerlistviewbase.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORERLISTVIEWBASE_H -#define PROJECTEXPLORERLISTVIEWBASE_H +#ifndef OAK_PROJECTEXPLORERLISTVIEWBASE_H +#define OAK_PROJECTEXPLORERLISTVIEWBASE_H #include @@ -55,9 +55,9 @@ signals: * * Emits a signal when the view is double clicked but not on any particular item */ - void DoubleClickedEmptyArea(); + void double_clicked_empty_area(); }; } -#endif // PROJECTEXPLORERLISTVIEWBASE_H +#endif // OAK_PROJECTEXPLORERLISTVIEWBASE_H diff --git a/app/widget/projectexplorer/projectexplorerlistviewitemdelegate.h b/app/widget/projectexplorer/projectexplorerlistviewitemdelegate.h index 0211401c9..7297fdf33 100644 --- a/app/widget/projectexplorer/projectexplorerlistviewitemdelegate.h +++ b/app/widget/projectexplorer/projectexplorerlistviewitemdelegate.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORERLISTVIEWITEMDELEGATE_H -#define PROJECTEXPLORERLISTVIEWITEMDELEGATE_H +#ifndef OAK_PROJECTEXPLORERLISTVIEWITEMDELEGATE_H +#define OAK_PROJECTEXPLORERLISTVIEWITEMDELEGATE_H #include @@ -44,4 +44,4 @@ public: } -#endif // PROJECTEXPLORERLISTVIEWITEMDELEGATE_H +#endif // OAK_PROJECTEXPLORERLISTVIEWITEMDELEGATE_H diff --git a/app/widget/projectexplorer/projectexplorernavigation.cpp b/app/widget/projectexplorer/projectexplorernavigation.cpp index 22ba6dc54..ea7b90d7f 100644 --- a/app/widget/projectexplorer/projectexplorernavigation.cpp +++ b/app/widget/projectexplorer/projectexplorernavigation.cpp @@ -43,7 +43,7 @@ ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) dir_up_btn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); layout->addWidget(dir_up_btn_); connect(dir_up_btn_, SIGNAL(clicked(bool)), this, - SIGNAL(DirectoryUpClicked())); + SIGNAL(directory_up_clicked())); // Create directory tree label dir_lbl_ = new QLabel(this); @@ -56,10 +56,10 @@ ProjectExplorerNavigation::ProjectExplorerNavigation(QWidget *parent) size_slider_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); layout->addWidget(size_slider_); connect(size_slider_, SIGNAL(valueChanged(int)), this, - SIGNAL(SizeChanged(int))); + SIGNAL(size_changed(int))); - Retranslate(); - UpdateIcons(); + retranslate(); + update_icons(); } void ProjectExplorerNavigation::set_text(const QString &s) @@ -80,24 +80,24 @@ void ProjectExplorerNavigation::set_size_value(int s) void ProjectExplorerNavigation::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } else if (e->type() == QEvent::StyleChange) { - UpdateIcons(); + update_icons(); } QWidget::changeEvent(e); } -void ProjectExplorerNavigation::Retranslate() +void ProjectExplorerNavigation::retranslate() { dir_up_btn_->setToolTip(tr("Go to parent folder")); } -void ProjectExplorerNavigation::UpdateIcons() +void ProjectExplorerNavigation::update_icons() { - dir_up_btn_->setIcon(icon::DirUp); - size_slider_->setMinimum(kProjectIconSizeMinimum); - size_slider_->setMaximum(kProjectIconSizeMaximum); - size_slider_->setValue(kProjectIconSizeDefault); + dir_up_btn_->setIcon(icon::dir_up); + size_slider_->setMinimum(k_project_icon_size_minimum); + size_slider_->setMaximum(k_project_icon_size_maximum); + size_slider_->setValue(k_project_icon_size_default); } } diff --git a/app/widget/projectexplorer/projectexplorernavigation.h b/app/widget/projectexplorer/projectexplorernavigation.h index 101fb187f..4bf12fa30 100644 --- a/app/widget/projectexplorer/projectexplorernavigation.h +++ b/app/widget/projectexplorer/projectexplorernavigation.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORERLISTVIEWTOOLBAR_H -#define PROJECTEXPLORERLISTVIEWTOOLBAR_H +#ifndef OAK_PROJECTEXPLORERLISTVIEWTOOLBAR_H +#define OAK_PROJECTEXPLORERLISTVIEWTOOLBAR_H #include #include @@ -87,7 +87,7 @@ signals: /** * @brief Signal emitted when the directory up button is clicked */ - void DirectoryUpClicked(); + void directory_up_clicked(); /** * @brief Signal emitted when the icon size slider changes value @@ -96,15 +96,15 @@ signals: * * New size set in the slider */ - void SizeChanged(int size); + void size_changed(int size); protected: virtual void changeEvent(QEvent *) override; private: - void Retranslate(); + void retranslate(); - void UpdateIcons(); + void update_icons(); QPushButton *dir_up_btn_; @@ -115,4 +115,4 @@ private: } -#endif // PROJECTEXPLORERLISTVIEWTOOLBAR_H +#endif // OAK_PROJECTEXPLORERLISTVIEWTOOLBAR_H diff --git a/app/widget/projectexplorer/projectexplorertreeview.cpp b/app/widget/projectexplorer/projectexplorertreeview.cpp index d874b03a4..76ae834dc 100644 --- a/app/widget/projectexplorer/projectexplorertreeview.cpp +++ b/app/widget/projectexplorer/projectexplorertreeview.cpp @@ -52,7 +52,7 @@ void ProjectExplorerTreeView::mouseDoubleClickEvent(QMouseEvent *event) // QAbstractItemView already has a doubleClicked() signal, but we emit another here for double clicking empty space if (!indexAt(event->pos()).isValid()) { - emit DoubleClickedEmptyArea(); + emit double_clicked_empty_area(); } } diff --git a/app/widget/projectexplorer/projectexplorertreeview.h b/app/widget/projectexplorer/projectexplorertreeview.h index a6ba237ba..a334c36d5 100644 --- a/app/widget/projectexplorer/projectexplorertreeview.h +++ b/app/widget/projectexplorer/projectexplorertreeview.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORERTREEVIEW_H -#define PROJECTEXPLORERTREEVIEW_H +#ifndef OAK_PROJECTEXPLORERTREEVIEW_H +#define OAK_PROJECTEXPLORERTREEVIEW_H #include @@ -57,9 +57,9 @@ signals: * * Emits a signal when the view is double clicked but not on any particular item */ - void DoubleClickedEmptyArea(); + void double_clicked_empty_area(); }; } -#endif // PROJECTEXPLORERTREEVIEW_H +#endif // OAK_PROJECTEXPLORERTREEVIEW_H diff --git a/app/widget/projectexplorer/projectexplorerundo.h b/app/widget/projectexplorer/projectexplorerundo.h index aeb2bbdc7..0dc337a2d 100644 --- a/app/widget/projectexplorer/projectexplorerundo.h +++ b/app/widget/projectexplorer/projectexplorerundo.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTEXPLORERUNDO_H -#define PROJECTEXPLORERUNDO_H +#ifndef OAK_PROJECTEXPLORERUNDO_H +#define OAK_PROJECTEXPLORERUNDO_H #include "undo/undocommand.h" @@ -29,4 +29,4 @@ namespace olive } -#endif // PROJECTEXPLORERUNDO_H +#endif // OAK_PROJECTEXPLORERUNDO_H diff --git a/app/widget/projectexplorer/projectviewmodel.cpp b/app/widget/projectexplorer/projectviewmodel.cpp index 9df75d2c3..dc6538695 100644 --- a/app/widget/projectexplorer/projectviewmodel.cpp +++ b/app/widget/projectexplorer/projectviewmodel.cpp @@ -48,13 +48,13 @@ void ProjectViewModel::set_project(Project *p) beginResetModel(); if (project_) { - DisconnectItem(project_->root()); + disconnect_item(project_->root()); } project_ = p; if (project_) { - ConnectItem(project_->root()); + connect_item(project_->root()); } endResetModel(); @@ -69,7 +69,7 @@ QModelIndex ProjectViewModel::index(int row, int column, } // Get the parent object, we assume it's a folder since only folders can have children - Folder *item_parent = static_cast(GetItemObjectFromIndex(parent)); + Folder *item_parent = static_cast(get_item_object_from_index(parent)); // Return an index to this object return createIndex(row, column, item_parent->item_child(row)); @@ -78,7 +78,7 @@ QModelIndex ProjectViewModel::index(int row, int column, QModelIndex ProjectViewModel::parent(const QModelIndex &child) const { // Get the Item object from the index - Node *item = GetItemObjectFromIndex(child); + Node *item = get_item_object_from_index(child); // Get Item's parent object Folder *par = item->folder(); @@ -89,7 +89,7 @@ QModelIndex ProjectViewModel::parent(const QModelIndex &child) const } // Otherwise return a true index to its parent - int parent_index = IndexOfChild(par); + int parent_index = index_of_child(par); // Make sure the index is valid (there's no reason it shouldn't be) Q_ASSERT(parent_index > -1); @@ -111,7 +111,7 @@ int ProjectViewModel::rowCount(const QModelIndex &parent) const } // Otherwise, the index must contain a valid pointer, so we just return its child count - return static_cast(GetItemObjectFromIndex(parent)) + return static_cast(get_item_object_from_index(parent)) ->item_child_count(); } @@ -124,33 +124,33 @@ int ProjectViewModel::columnCount(const QModelIndex &parent) const return 0; } - return kColumnCount; + return k_column_count; } QVariant ProjectViewModel::data(const QModelIndex &index, int role) const { - Node *internal_item = GetItemObjectFromIndex(index); + Node *internal_item = get_item_object_from_index(index); ColumnType column_type = static_cast(index.column()); switch (role) { case Qt::DisplayRole: - case kInnerTextRole: { + case k_inner_text_role: { // Standard text role switch (column_type) { - case kName: - return internal_item->GetLabel(); - case kDuration: - return internal_item->data(Node::DURATION); - case kRate: - return internal_item->data(Node::FREQUENCY_RATE); - case kLastModified: - case kCreatedTime: { + case k_name: + return internal_item->get_label(); + case k_duration: + return internal_item->data(Node::duration); + case k_rate: + return internal_item->data(Node::frequency_rate); + case k_last_modified: + case k_created_time: { qint64 using_time = - (column_type == kLastModified) ? - internal_item->data(Node::MODIFIED_TIME).toLongLong() : - internal_item->data(Node::CREATED_TIME).toLongLong(); + (column_type == k_last_modified) ? + internal_item->data(Node::modified_time).toLongLong() : + internal_item->data(Node::created_time).toLongLong(); if (using_time == 0) { // 0 is the null value, return nothing @@ -159,34 +159,34 @@ QVariant ProjectViewModel::data(const QModelIndex &index, int role) const QVariant ret; - if (role == kInnerTextRole) { + if (role == k_inner_text_role) { // Use time value directly for correct sorting ret = using_time; } else { // Display role, format to a human readable string - ret = QtUtils::GetFormattedDateTime( + ret = QtUtils::get_formatted_date_time( QDateTime::fromSecsSinceEpoch(using_time)); } return ret; } - case kColumnCount: + case k_column_count: break; } } break; case Qt::EditRole: - if (column_type == kName) { - return internal_item->GetLabel(); + if (column_type == k_name) { + return internal_item->get_label(); } break; case Qt::DecorationRole: // If this is the first column, return the Item's icon - if (column_type == kName) { - return internal_item->data(Node::ICON); + if (column_type == k_name) { + return internal_item->data(Node::icon); } break; case Qt::ToolTipRole: - return internal_item->data(Node::TOOLTIP); + return internal_item->data(Node::tooltip); } return QVariant(); @@ -202,17 +202,17 @@ QVariant ProjectViewModel::headerData(int section, Qt::Orientation orientation, // Return the name based on the column's current type switch (column_type) { - case kName: + case k_name: return tr("Name"); - case kDuration: + case k_duration: return tr("Duration"); - case kRate: + case k_rate: return tr("Rate"); - case kLastModified: + case k_last_modified: return tr("Modified"); - case kCreatedTime: + case k_created_time: return tr("Created"); - case kColumnCount: + case k_column_count: break; } } @@ -224,7 +224,7 @@ bool ProjectViewModel::hasChildren(const QModelIndex &parent) const { // If it's a folder, we always return TRUE in order to always show the "expand triangle" icon, // even when there are no "physical" children - Node *item = GetItemObjectFromIndex(parent); + Node *item = get_item_object_from_index(parent); return dynamic_cast(item); } @@ -233,19 +233,19 @@ bool ProjectViewModel::setData(const QModelIndex &index, const QVariant &value, int role) { // The name is editable - if (index.isValid() && index.column() == kName && role == Qt::EditRole) { - Node *item = GetItemObjectFromIndex(index); + if (index.isValid() && index.column() == k_name && role == Qt::EditRole) { + Node *item = get_item_object_from_index(index); QString new_name = value.toString(); if (!new_name.isEmpty()) { NodeRenameCommand *nrc = new NodeRenameCommand(); - nrc->AddNode(item, value.toString()); + nrc->add_node(item, value.toString()); Core::instance()->undo_stack()->push( nrc, tr("Renamed Item \"%1\" to \"%2\"") - .arg(item->GetLabel(), new_name)); + .arg(item->get_label(), new_name)); return true; } @@ -269,12 +269,12 @@ Qt::ItemFlags ProjectViewModel::flags(const QModelIndex &index) const Qt::ItemFlags f = Qt::ItemIsDragEnabled | QAbstractItemModel::flags(index); - if (dynamic_cast(GetItemObjectFromIndex(index))) { + if (dynamic_cast(get_item_object_from_index(index))) { f |= Qt::ItemIsDropEnabled; } // If the column is the kName column, that means it's editable - if (index.column() == kName) { + if (index.column() == k_name) { f |= Qt::ItemIsEditable; } @@ -284,7 +284,7 @@ Qt::ItemFlags ProjectViewModel::flags(const QModelIndex &index) const QStringList ProjectViewModel::mimeTypes() const { // Allow data from this model and a file list from external sources - return { Project::kItemMimeType, QStringLiteral("text/uri-list") }; + return { Project::k_item_mime_type, QStringLiteral("text/uri-list") }; } QMimeData *ProjectViewModel::mimeData(const QModelIndexList &indexes) const @@ -315,7 +315,7 @@ QMimeData *ProjectViewModel::mimeData(const QModelIndexList &indexes) const if (ViewerOutput *footage = dynamic_cast(item)) { - streams = footage->GetEnabledStreamsAsReferences(); + streams = footage->get_enabled_streams_as_references(); } stream << streams << reinterpret_cast(item); @@ -326,7 +326,7 @@ QMimeData *ProjectViewModel::mimeData(const QModelIndexList &indexes) const } // Set byte array as the mime data and return the mime data - data->setData(Project::kItemMimeType, encoded_data); + data->setData(Project::k_item_mime_type, encoded_data); return data; } @@ -347,16 +347,16 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, // Probe mime data for its format QStringList mime_formats = data->formats(); - if (mime_formats.contains(Project::kItemMimeType)) { + if (mime_formats.contains(Project::k_item_mime_type)) { // Data is drag/drop data from this model - QByteArray model_data = data->data(Project::kItemMimeType); + QByteArray model_data = data->data(Project::k_item_mime_type); // Use QDataStream to deserialize the data QDataStream stream(&model_data, QIODevice::ReadOnly); // Get the Item object that the items were dropped on Folder *drop_location = - dynamic_cast(GetItemObjectFromIndex(drop)); + dynamic_cast(get_item_object_from_index(drop)); // If this is not a folder, we cannot drop these items here if (!drop_location) { @@ -382,11 +382,11 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, if (item != drop_location && item->folder() != drop_location && (!dynamic_cast(item) || - !ItemIsParentOfChild(static_cast(item), + !item_is_parent_of_child(static_cast(item), drop_location))) { move_command->add_child(new NodeEdgeRemoveCommand( item, - NodeInput(item->folder(), Folder::kChildInput, + NodeInput(item->folder(), Folder::k_child_input, item->folder()->index_of_child_in_array(item)))); move_command->add_child( new FolderAddChild(drop_location, item)); @@ -417,7 +417,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, } // Get folder dropped onto - Node *drop_item = GetItemObjectFromIndex(drop); + Node *drop_item = get_item_object_from_index(drop); // If we didn't drop onto an item, find the nearest parent folder (should eventually terminate at root either way) if (!dynamic_cast(drop_item)) { @@ -430,7 +430,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, } // Trigger an import - Core::instance()->ImportFiles(urls, static_cast(drop_item)); + Core::instance()->import_files(urls, static_cast(drop_item)); return true; } @@ -438,7 +438,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, return false; } -int ProjectViewModel::IndexOfChild(Node *item) const +int ProjectViewModel::index_of_child(Node *item) const { // Find parent's index within its own parent Folder *parent = item->folder(); @@ -450,7 +450,7 @@ int ProjectViewModel::IndexOfChild(Node *item) const return -1; } -Node *ProjectViewModel::GetItemObjectFromIndex(const QModelIndex &index) const +Node *ProjectViewModel::get_item_object_from_index(const QModelIndex &index) const { if (index.isValid()) { return static_cast(index.internalPointer()); @@ -459,7 +459,7 @@ Node *ProjectViewModel::GetItemObjectFromIndex(const QModelIndex &index) const return project_ ? project_->root() : nullptr; } -bool ProjectViewModel::ItemIsParentOfChild(Folder *parent, Node *child) const +bool ProjectViewModel::item_is_parent_of_child(Folder *parent, Node *child) const { // Loop through parent hierarchy checking if `parent` is one of its parents do { @@ -473,100 +473,100 @@ bool ProjectViewModel::ItemIsParentOfChild(Folder *parent, Node *child) const return false; } -void ProjectViewModel::ConnectItem(Node *n) +void ProjectViewModel::connect_item(Node *n) { - connect(n, &Node::LabelChanged, this, &ProjectViewModel::ItemRenamed); + connect(n, &Node::label_changed, this, &ProjectViewModel::item_renamed); Folder *f = dynamic_cast(n); if (f) { - connect(f, &Folder::BeginInsertItem, this, - &ProjectViewModel::FolderBeginInsertItem); - connect(f, &Folder::EndInsertItem, this, - &ProjectViewModel::FolderEndInsertItem); - connect(f, &Folder::BeginRemoveItem, this, - &ProjectViewModel::FolderBeginRemoveItem); - connect(f, &Folder::EndRemoveItem, this, - &ProjectViewModel::FolderEndRemoveItem); + connect(f, &Folder::begin_insert_item, this, + &ProjectViewModel::folder_begin_insert_item); + connect(f, &Folder::end_insert_item, this, + &ProjectViewModel::folder_end_insert_item); + connect(f, &Folder::begin_remove_item, this, + &ProjectViewModel::folder_begin_remove_item); + connect(f, &Folder::end_remove_item, this, + &ProjectViewModel::folder_end_remove_item); foreach (Node *c, f->children()) { - ConnectItem(c); + connect_item(c); } } } -void ProjectViewModel::DisconnectItem(Node *n) +void ProjectViewModel::disconnect_item(Node *n) { - disconnect(n, &Node::LabelChanged, this, &ProjectViewModel::ItemRenamed); + disconnect(n, &Node::label_changed, this, &ProjectViewModel::item_renamed); Folder *f = dynamic_cast(n); if (f) { - disconnect(f, &Folder::BeginInsertItem, this, - &ProjectViewModel::FolderBeginInsertItem); - disconnect(f, &Folder::EndInsertItem, this, - &ProjectViewModel::FolderEndInsertItem); - disconnect(f, &Folder::BeginRemoveItem, this, - &ProjectViewModel::FolderBeginRemoveItem); - disconnect(f, &Folder::EndRemoveItem, this, - &ProjectViewModel::FolderEndRemoveItem); + disconnect(f, &Folder::begin_insert_item, this, + &ProjectViewModel::folder_begin_insert_item); + disconnect(f, &Folder::end_insert_item, this, + &ProjectViewModel::folder_end_insert_item); + disconnect(f, &Folder::begin_remove_item, this, + &ProjectViewModel::folder_begin_remove_item); + disconnect(f, &Folder::end_remove_item, this, + &ProjectViewModel::folder_end_remove_item); foreach (Node *c, f->children()) { - DisconnectItem(c); + disconnect_item(c); } } } -void ProjectViewModel::FolderBeginInsertItem(Node *n, int insert_index) +void ProjectViewModel::folder_begin_insert_item(Node *n, int insert_index) { Folder *folder = static_cast(sender()); - ConnectItem(n); + connect_item(n); QModelIndex index; if (folder != project_->root()) { - index = CreateIndexFromItem(folder); + index = create_index_from_item(folder); } beginInsertRows(index, insert_index, insert_index); } -void ProjectViewModel::FolderEndInsertItem() +void ProjectViewModel::folder_end_insert_item() { endInsertRows(); } -void ProjectViewModel::FolderBeginRemoveItem(Node *n, int child_index) +void ProjectViewModel::folder_begin_remove_item(Node *n, int child_index) { Folder *folder = static_cast(sender()); - DisconnectItem(n); + disconnect_item(n); QModelIndex index; if (folder != project_->root()) { - index = CreateIndexFromItem(folder); + index = create_index_from_item(folder); } beginRemoveRows(index, child_index, child_index); } -void ProjectViewModel::FolderEndRemoveItem() +void ProjectViewModel::folder_end_remove_item() { endRemoveRows(); } -void ProjectViewModel::ItemRenamed() +void ProjectViewModel::item_renamed() { Node *item = static_cast(sender()); - QModelIndex index = CreateIndexFromItem(item); + QModelIndex index = create_index_from_item(item); emit dataChanged(index, index, { Qt::DisplayRole, Qt::EditRole }); } -QModelIndex ProjectViewModel::CreateIndexFromItem(Node *item, int column) +QModelIndex ProjectViewModel::create_index_from_item(Node *item, int column) { - return createIndex(IndexOfChild(item), column, item); + return createIndex(index_of_child(item), column, item); } } diff --git a/app/widget/projectexplorer/projectviewmodel.h b/app/widget/projectexplorer/projectviewmodel.h index 8f0e4d9a9..85cddb825 100644 --- a/app/widget/projectexplorer/projectviewmodel.h +++ b/app/widget/projectexplorer/projectviewmodel.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWMODEL_H -#define VIEWMODEL_H +#ifndef OAK_VIEWMODEL_H +#define OAK_VIEWMODEL_H #include @@ -44,25 +44,25 @@ class ProjectViewModel : public QAbstractItemModel { public: enum ColumnType { /// Media name - kName, + k_name, /// Media duration - kDuration, + k_duration, /// Media rate (frame rate for video, sample rate for audio) - kRate, + k_rate, /// Last modified time (for footage/files) - kLastModified, + k_last_modified, /// Creation time (for footage/files) - kCreatedTime, + k_created_time, /// Count - kColumnCount + k_column_count }; - static const int kInnerTextRole = Qt::UserRole + 1; + static const int k_inner_text_role = Qt::UserRole + 1; /** * @brief ProjectViewModel Constructor @@ -124,7 +124,7 @@ public: /** * @brief Convenience function for creating QModelIndexes from an Item object */ - QModelIndex CreateIndexFromItem(Node *item, int column = 0); + QModelIndex create_index_from_item(Node *item, int column = 0); private: /** @@ -137,40 +137,40 @@ private: * * Index of the specified item, or -1 if the item is root (in which case it has no parent). */ - int IndexOfChild(Node *item) const; + int index_of_child(Node *item) const; /** * @brief Retrieves the Item object from a given index * * A convenience function for retrieving Item objects. If the index is not valid, this returns the root Item. */ - Node *GetItemObjectFromIndex(const QModelIndex &index) const; + Node *get_item_object_from_index(const QModelIndex &index) const; /** * @brief Check if an Item is a parent of a Child * * Checks entire "parent hierarchy" of `child` to see if `parent` is one of its parents. */ - bool ItemIsParentOfChild(Folder *parent, Node *child) const; + bool item_is_parent_of_child(Folder *parent, Node *child) const; - void ConnectItem(Node *n); + void connect_item(Node *n); - void DisconnectItem(Node *n); + void disconnect_item(Node *n); Project *project_; private slots: - void FolderBeginInsertItem(Node *n, int insert_index); + void folder_begin_insert_item(Node *n, int insert_index); - void FolderEndInsertItem(); + void folder_end_insert_item(); - void FolderBeginRemoveItem(Node *n, int child_index); + void folder_begin_remove_item(Node *n, int child_index); - void FolderEndRemoveItem(); + void folder_end_remove_item(); - void ItemRenamed(); + void item_renamed(); }; } -#endif // VIEWMODEL_H +#endif // OAK_VIEWMODEL_H diff --git a/app/widget/projecttoolbar/projecttoolbar.cpp b/app/widget/projecttoolbar/projecttoolbar.cpp index 692bbcecc..488efe728 100644 --- a/app/widget/projecttoolbar/projecttoolbar.cpp +++ b/app/widget/projecttoolbar/projecttoolbar.cpp @@ -39,41 +39,41 @@ ProjectToolbar::ProjectToolbar(QWidget *parent) new_button_ = new QPushButton(); connect(new_button_, &QPushButton::clicked, this, - &ProjectToolbar::NewClicked); + &ProjectToolbar::new_clicked); layout->addWidget(new_button_); open_button_ = new QPushButton(); connect(open_button_, &QPushButton::clicked, this, - &ProjectToolbar::OpenClicked); + &ProjectToolbar::open_clicked); layout->addWidget(open_button_); save_button_ = new QPushButton(); connect(save_button_, &QPushButton::clicked, this, - &ProjectToolbar::SaveClicked); + &ProjectToolbar::save_clicked); layout->addWidget(save_button_); search_field_ = new QLineEdit(); search_field_->setClearButtonEnabled(true); connect(search_field_, &QLineEdit::textChanged, this, - &ProjectToolbar::SearchChanged); + &ProjectToolbar::search_changed); layout->addWidget(search_field_); tree_button_ = new QPushButton(); tree_button_->setCheckable(true); connect(tree_button_, &QPushButton::clicked, this, - &ProjectToolbar::ViewButtonClicked); + &ProjectToolbar::view_button_clicked); layout->addWidget(tree_button_); list_button_ = new QPushButton(); list_button_->setCheckable(true); connect(list_button_, &QPushButton::clicked, this, - &ProjectToolbar::ViewButtonClicked); + &ProjectToolbar::view_button_clicked); layout->addWidget(list_button_); icon_button_ = new QPushButton(); icon_button_->setCheckable(true); connect(icon_button_, &QPushButton::clicked, this, - &ProjectToolbar::ViewButtonClicked); + &ProjectToolbar::view_button_clicked); layout->addWidget(icon_button_); // Group Tree/List/Icon view buttons into a button group for easy exclusive-buttons @@ -83,20 +83,20 @@ ProjectToolbar::ProjectToolbar(QWidget *parent) view_button_group->addButton(list_button_); view_button_group->addButton(icon_button_); - Retranslate(); - UpdateIcons(); + retranslate(); + update_icons(); } -void ProjectToolbar::SetView(ViewType type) +void ProjectToolbar::set_view(ViewType type) { switch (type) { - case TreeView: + case tree_view: tree_button_->setChecked(true); break; - case IconView: + case icon_view: icon_button_->setChecked(true); break; - case ListView: + case list_view: list_button_->setChecked(true); break; } @@ -105,14 +105,14 @@ void ProjectToolbar::SetView(ViewType type) void ProjectToolbar::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } else if (e->type() == QEvent::StyleChange) { - UpdateIcons(); + update_icons(); } QWidget::changeEvent(e); } -void ProjectToolbar::Retranslate() +void ProjectToolbar::retranslate() { new_button_->setToolTip(tr("New...")); open_button_->setToolTip(tr("Open Project")); @@ -125,25 +125,25 @@ void ProjectToolbar::Retranslate() icon_button_->setToolTip(tr("Icon View")); } -void ProjectToolbar::UpdateIcons() +void ProjectToolbar::update_icons() { new_button_->setIcon(icon::New); - open_button_->setIcon(icon::Open); - save_button_->setIcon(icon::Save); - tree_button_->setIcon(icon::TreeView); - list_button_->setIcon(icon::ListView); - icon_button_->setIcon(icon::IconView); + open_button_->setIcon(icon::open); + save_button_->setIcon(icon::save); + tree_button_->setIcon(icon::tree_view); + list_button_->setIcon(icon::list_view); + icon_button_->setIcon(icon::icon_view); } -void ProjectToolbar::ViewButtonClicked() +void ProjectToolbar::view_button_clicked() { // Determine which view button triggered this slot and emit a signal accordingly if (sender() == tree_button_) { - emit ViewChanged(ProjectToolbar::TreeView); + emit view_changed(ProjectToolbar::tree_view); } else if (sender() == icon_button_) { - emit ViewChanged(ProjectToolbar::IconView); + emit view_changed(ProjectToolbar::icon_view); } else if (sender() == list_button_) { - emit ViewChanged(ProjectToolbar::ListView); + emit view_changed(ProjectToolbar::list_view); } 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 96205d6d1..120968abf 100644 --- a/app/widget/projecttoolbar/projecttoolbar.h +++ b/app/widget/projecttoolbar/projecttoolbar.h @@ -19,8 +19,8 @@ ***/ -#ifndef PROJECTTOOLBAR_H -#define PROJECTTOOLBAR_H +#ifndef OAK_PROJECTTOOLBAR_H +#define OAK_PROJECTTOOLBAR_H #include #include @@ -44,26 +44,26 @@ class ProjectToolbar : public QWidget { public: ProjectToolbar(QWidget *parent); - enum ViewType { TreeView, ListView, IconView }; + enum ViewType { tree_view, list_view, icon_view }; public slots: - void SetView(ViewType type); + void set_view(ViewType type); protected: void changeEvent(QEvent *) override; signals: - void NewClicked(); - void OpenClicked(); - void SaveClicked(); + void new_clicked(); + void open_clicked(); + void save_clicked(); - void SearchChanged(const QString &); + void search_changed(const QString &); - void ViewChanged(ViewType type); + void view_changed(ViewType type); private: - void Retranslate(); - void UpdateIcons(); + void retranslate(); + void update_icons(); QPushButton *new_button_; QPushButton *open_button_; @@ -76,9 +76,9 @@ private: QPushButton *icon_button_; private slots: - void ViewButtonClicked(); + void view_button_clicked(); }; } -#endif // PROJECTTOOLBAR_H +#endif // OAK_PROJECTTOOLBAR_H diff --git a/app/widget/resizablescrollbar/resizablescrollbar.cpp b/app/widget/resizablescrollbar/resizablescrollbar.cpp index f6786b6ce..4c7d1a3ab 100644 --- a/app/widget/resizablescrollbar/resizablescrollbar.cpp +++ b/app/widget/resizablescrollbar/resizablescrollbar.cpp @@ -31,49 +31,49 @@ namespace olive { -const int ResizableScrollBar::kHandleWidth = 10; +const int ResizableScrollBar::k_handle_width = 10; ResizableScrollBar::ResizableScrollBar(QWidget *parent) : QScrollBar(parent) { - Init(); + init(); } ResizableScrollBar::ResizableScrollBar(Qt::Orientation orientation, QWidget *parent) : QScrollBar(orientation, parent) { - Init(); + init(); } void ResizableScrollBar::mousePressEvent(QMouseEvent *event) { - if (mouse_handle_state_ == kNotInHandle) { + if (mouse_handle_state_ == k_not_in_handle) { QScrollBar::mousePressEvent(event); } else { dragging_ = true; - drag_start_point_ = GetActiveMousePos(event); + drag_start_point_ = get_active_mouse_pos(event); - emit ResizeBegan(GetActiveBarSize(), - (mouse_handle_state_ == kInTopHandle)); + emit resize_began(get_active_bar_size(), + (mouse_handle_state_ == k_in_top_handle)); } } void ResizableScrollBar::mouseMoveEvent(QMouseEvent *event) { - QRect sr = GetScrollBarRect(); + QRect sr = get_scroll_bar_rect(); if (dragging_) { // Determine how much the cursor has moved - int mouse_movement = GetActiveMousePos(event) - drag_start_point_; + int mouse_movement = get_active_mouse_pos(event) - drag_start_point_; - emit ResizeMoved(mouse_movement); + emit resize_moved(mouse_movement); } else { int mouse_pos, top, bottom; Qt::CursorShape target_cursor; - mouse_pos = GetActiveMousePos(event); + mouse_pos = get_active_mouse_pos(event); if (orientation() == Qt::Horizontal) { top = sr.left(); @@ -85,15 +85,15 @@ void ResizableScrollBar::mouseMoveEvent(QMouseEvent *event) target_cursor = Qt::SizeVerCursor; } - if (InRange(mouse_pos, top, kHandleWidth)) { - mouse_handle_state_ = kInTopHandle; - } else if (InRange(mouse_pos, bottom, kHandleWidth)) { - mouse_handle_state_ = kInBottomHandle; + if (in_range(mouse_pos, top, k_handle_width)) { + mouse_handle_state_ = k_in_top_handle; + } else if (in_range(mouse_pos, bottom, k_handle_width)) { + mouse_handle_state_ = k_in_bottom_handle; } else { - mouse_handle_state_ = kNotInHandle; + mouse_handle_state_ = k_not_in_handle; } - if (mouse_handle_state_ == kNotInHandle) { + if (mouse_handle_state_ == k_not_in_handle) { unsetCursor(); } else { setCursor(target_cursor); @@ -108,13 +108,13 @@ void ResizableScrollBar::mouseReleaseEvent(QMouseEvent *event) if (dragging_) { dragging_ = false; - emit ResizeEnded(); + emit resize_ended(); } else { QScrollBar::mouseReleaseEvent(event); } } -QRect ResizableScrollBar::GetScrollBarRect() +QRect ResizableScrollBar::get_scroll_bar_rect() { // Initialize "style option". I don't know what this does, I just ripped it straight from // Qt source code @@ -126,17 +126,17 @@ QRect ResizableScrollBar::GetScrollBarRect() QStyle::SC_ScrollBarSlider, this); } -void ResizableScrollBar::Init() +void ResizableScrollBar::init() { setSingleStep(20); setMaximum(0); setMouseTracking(true); - mouse_handle_state_ = kNotInHandle; + mouse_handle_state_ = k_not_in_handle; dragging_ = false; } -int ResizableScrollBar::GetActiveMousePos(QMouseEvent *event) +int ResizableScrollBar::get_active_mouse_pos(QMouseEvent *event) { if (orientation() == Qt::Horizontal) { return event->pos().x(); @@ -145,9 +145,9 @@ int ResizableScrollBar::GetActiveMousePos(QMouseEvent *event) } } -int ResizableScrollBar::GetActiveBarSize() +int ResizableScrollBar::get_active_bar_size() { - QRect sr = GetScrollBarRect(); + QRect sr = get_scroll_bar_rect(); if (orientation() == Qt::Horizontal) { return sr.width(); diff --git a/app/widget/resizablescrollbar/resizablescrollbar.h b/app/widget/resizablescrollbar/resizablescrollbar.h index 3f75507b6..7465c29e6 100644 --- a/app/widget/resizablescrollbar/resizablescrollbar.h +++ b/app/widget/resizablescrollbar/resizablescrollbar.h @@ -19,8 +19,8 @@ ***/ -#ifndef RESIZABLESCROLLBAR_H -#define RESIZABLESCROLLBAR_H +#ifndef OAK_RESIZABLESCROLLBAR_H +#define OAK_RESIZABLESCROLLBAR_H #include @@ -36,11 +36,11 @@ public: ResizableScrollBar(Qt::Orientation orientation, QWidget *parent = nullptr); signals: - void ResizeBegan(int old_bar_width, bool top_handle); + void resize_began(int old_bar_width, bool top_handle); - void ResizeMoved(int movement); + void resize_moved(int movement); - void ResizeEnded(); + void resize_ended(); protected: virtual void mousePressEvent(QMouseEvent *event) override; @@ -50,17 +50,17 @@ protected: virtual void mouseReleaseEvent(QMouseEvent *event) override; private: - QRect GetScrollBarRect(); + QRect get_scroll_bar_rect(); - static const int kHandleWidth; + static const int k_handle_width; - enum MouseHandleState { kNotInHandle, kInTopHandle, kInBottomHandle }; + enum MouseHandleState { k_not_in_handle, k_in_top_handle, k_in_bottom_handle }; - void Init(); + void init(); - int GetActiveMousePos(QMouseEvent *event); + int get_active_mouse_pos(QMouseEvent *event); - int GetActiveBarSize(); + int get_active_bar_size(); MouseHandleState mouse_handle_state_; @@ -71,4 +71,4 @@ private: } -#endif // RESIZABLESCROLLBAR_H +#endif // OAK_RESIZABLESCROLLBAR_H diff --git a/app/widget/resizablescrollbar/resizabletimelinescrollbar.cpp b/app/widget/resizablescrollbar/resizabletimelinescrollbar.cpp index cfd4bf1ce..3593437b0 100644 --- a/app/widget/resizablescrollbar/resizabletimelinescrollbar.cpp +++ b/app/widget/resizablescrollbar/resizabletimelinescrollbar.cpp @@ -48,16 +48,16 @@ ResizableTimelineScrollBar::ResizableTimelineScrollBar( { } -void ResizableTimelineScrollBar::ConnectMarkers(TimelineMarkerList *markers) +void ResizableTimelineScrollBar::connect_markers(TimelineMarkerList *markers) { if (markers_) { - disconnect(markers_, &TimelineMarkerList::MarkerAdded, this, + disconnect(markers_, &TimelineMarkerList::marker_added, this, static_cast( &ResizableTimelineScrollBar::update)); - disconnect(markers_, &TimelineMarkerList::MarkerRemoved, this, + disconnect(markers_, &TimelineMarkerList::marker_removed, this, static_cast( &ResizableTimelineScrollBar::update)); - disconnect(markers_, &TimelineMarkerList::MarkerModified, this, + disconnect(markers_, &TimelineMarkerList::marker_modified, this, static_cast( &ResizableTimelineScrollBar::update)); } @@ -65,13 +65,13 @@ void ResizableTimelineScrollBar::ConnectMarkers(TimelineMarkerList *markers) markers_ = markers; if (markers_) { - connect(markers_, &TimelineMarkerList::MarkerAdded, this, + connect(markers_, &TimelineMarkerList::marker_added, this, static_cast( &ResizableTimelineScrollBar::update)); - connect(markers_, &TimelineMarkerList::MarkerRemoved, this, + connect(markers_, &TimelineMarkerList::marker_removed, this, static_cast( &ResizableTimelineScrollBar::update)); - connect(markers_, &TimelineMarkerList::MarkerModified, this, + connect(markers_, &TimelineMarkerList::marker_modified, this, static_cast( &ResizableTimelineScrollBar::update)); } @@ -79,13 +79,13 @@ void ResizableTimelineScrollBar::ConnectMarkers(TimelineMarkerList *markers) update(); } -void ResizableTimelineScrollBar::ConnectWorkArea(TimelineWorkArea *workarea) +void ResizableTimelineScrollBar::connect_work_area(TimelineWorkArea *workarea) { if (workarea_) { - disconnect(workarea_, &TimelineWorkArea::RangeChanged, this, + disconnect(workarea_, &TimelineWorkArea::range_changed, this, static_cast( &ResizableTimelineScrollBar::update)); - disconnect(workarea_, &TimelineWorkArea::EnabledChanged, this, + disconnect(workarea_, &TimelineWorkArea::enabled_changed, this, static_cast( &ResizableTimelineScrollBar::update)); } @@ -93,10 +93,10 @@ void ResizableTimelineScrollBar::ConnectWorkArea(TimelineWorkArea *workarea) workarea_ = workarea; if (workarea_) { - connect(workarea_, &TimelineWorkArea::RangeChanged, this, + connect(workarea_, &TimelineWorkArea::range_changed, this, static_cast( &ResizableTimelineScrollBar::update)); - connect(workarea_, &TimelineWorkArea::EnabledChanged, this, + connect(workarea_, &TimelineWorkArea::enabled_changed, this, static_cast( &ResizableTimelineScrollBar::update)); } @@ -133,14 +133,14 @@ void ResizableTimelineScrollBar::paintEvent(QPaintEvent *event) workarea_color.setAlpha(128); qint64 in = - qMax(qint64(0), qRound64(ratio * TimeToScene(workarea_->in()))); + qMax(qint64(0), qRound64(ratio * time_to_scene(workarea_->in()))); qint64 out; if (workarea_->out() == RATIONAL_MAX) { out = gr.width(); } else { out = qMin(qint64(gr.width()), - qRound64(ratio * TimeToScene(workarea_->out()))); + qRound64(ratio * time_to_scene(workarea_->out()))); } qint64 length = qMax(qint64(1), out - in); @@ -154,10 +154,10 @@ void ResizableTimelineScrollBar::paintEvent(QPaintEvent *event) TimelineMarker *marker = *it; QColor marker_color = - QtUtils::toQColor(ColorCoding::GetColor(marker->color())); - int64_t in = qRound64(ratio * TimeToScene(marker->time().in())); + QtUtils::to_q_color(ColorCoding::get_color(marker->color())); + int64_t in = qRound64(ratio * time_to_scene(marker->time().in())); int64_t out = - qRound64(ratio * TimeToScene(marker->time().out())); + qRound64(ratio * time_to_scene(marker->time().out())); int64_t length = qMax(int64_t(1), out - in); p.fillRect(gr.x() + in, 0, length, height(), marker_color); diff --git a/app/widget/resizablescrollbar/resizabletimelinescrollbar.h b/app/widget/resizablescrollbar/resizabletimelinescrollbar.h index f6633171c..09420a8b7 100644 --- a/app/widget/resizablescrollbar/resizabletimelinescrollbar.h +++ b/app/widget/resizablescrollbar/resizabletimelinescrollbar.h @@ -19,8 +19,8 @@ ***/ -#ifndef RESIZABLETIMELINESCROLLBAR_H -#define RESIZABLETIMELINESCROLLBAR_H +#ifndef OAK_RESIZABLETIMELINESCROLLBAR_H +#define OAK_RESIZABLETIMELINESCROLLBAR_H #include "resizablescrollbar.h" #include "timeline/timelinemarker.h" @@ -38,8 +38,8 @@ public: ResizableTimelineScrollBar(Qt::Orientation orientation, QWidget *parent = nullptr); - void ConnectMarkers(TimelineMarkerList *markers); - void ConnectWorkArea(TimelineWorkArea *workarea); + void connect_markers(TimelineMarkerList *markers); + void connect_work_area(TimelineWorkArea *workarea); void SetScale(double d); @@ -56,4 +56,4 @@ private: } -#endif // RESIZABLETIMELINESCROLLBAR_H +#endif // OAK_RESIZABLETIMELINESCROLLBAR_H diff --git a/app/widget/scope/histogram/histogram.cpp b/app/widget/scope/histogram/histogram.cpp index 898103327..efa0adf30 100644 --- a/app/widget/scope/histogram/histogram.cpp +++ b/app/widget/scope/histogram/histogram.cpp @@ -39,33 +39,33 @@ HistogramScope::HistogramScope(QWidget *parent) { } -void HistogramScope::OnInit() +void HistogramScope::on_init() { - super::OnInit(); + super::on_init(); ShaderCode secondary_code( - FileFunctions::ReadFileAsString( + FileFunctions::read_file_as_string( ":/shaders/rgbhistogram_secondary.frag"), - FileFunctions::ReadFileAsString(":/shaders/rgbhistogram.vert")); - pipeline_secondary_ = renderer()->CreateNativeShader(secondary_code); + FileFunctions::read_file_as_string(":/shaders/rgbhistogram.vert")); + pipeline_secondary_ = renderer()->create_native_shader(secondary_code); } -void HistogramScope::OnDestroy() +void HistogramScope::on_destroy() { pipeline_secondary_.clear(); texture_row_sums_ = nullptr; - super::OnDestroy(); + super::on_destroy(); } -ShaderCode HistogramScope::GenerateShaderCode() +ShaderCode HistogramScope::generate_shader_code() { return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/rgbhistogram.frag"), - FileFunctions::ReadFileAsString(":/shaders/default.vert")); + FileFunctions::read_file_as_string(":/shaders/rgbhistogram.frag"), + FileFunctions::read_file_as_string(":/shaders/default.vert")); } -void HistogramScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) +void HistogramScope::draw_scope(TexturePtr managed_tex, QVariant pipeline) { float histogram_scale = 0.80f; // This value is eyeballed for usefulness. Until we have a geometry @@ -76,32 +76,32 @@ void HistogramScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) ShaderJob shader_job; - shader_job.Insert(QStringLiteral("viewport"), - NodeValue(NodeValue::kVec2, + shader_job.insert(QStringLiteral("viewport"), + NodeValue(NodeValue::k_vec2, QVector2D(width(), height()))); - shader_job.Insert(QStringLiteral("histogram_scale"), - NodeValue(NodeValue::kFloat, histogram_scale)); - shader_job.Insert(QStringLiteral("histogram_power"), - NodeValue(NodeValue::kFloat, histogram_power)); + shader_job.insert(QStringLiteral("histogram_scale"), + NodeValue(NodeValue::k_float, histogram_scale)); + shader_job.insert(QStringLiteral("histogram_power"), + NodeValue(NodeValue::k_float, histogram_power)); if (!texture_row_sums_ || texture_row_sums_->width() != this->width() || texture_row_sums_->height() != this->height()) { - texture_row_sums_ = renderer()->CreateTexture( + texture_row_sums_ = renderer()->create_texture( VideoParams(width(), height(), managed_tex->format(), managed_tex->channel_count())); } // Draw managed texture to a sums texture - shader_job.Insert(QStringLiteral("ove_maintex"), - NodeValue(NodeValue::kTexture, + shader_job.insert(QStringLiteral("ove_maintex"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(managed_tex))); - renderer()->BlitToTexture(pipeline, shader_job, texture_row_sums_.get()); + renderer()->blit_to_texture(pipeline, shader_job, texture_row_sums_.get()); // Draw sums into a histogram - shader_job.Insert(QStringLiteral("ove_maintex"), - NodeValue(NodeValue::kTexture, + shader_job.insert(QStringLiteral("ove_maintex"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(texture_row_sums_))); - renderer()->Blit(pipeline_secondary_, shader_job, + renderer()->blit(pipeline_secondary_, shader_job, texture_row_sums_->params()); // Draw line overlays @@ -139,7 +139,7 @@ void HistogramScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) (histogram_dim_y * pow(1.0 - *it, histogram_base)) + histogram_start_dim_y); label = QString::number(*it * 100, 'f', 1) + "%"; - font_x_offset = QtUtils::QFontMetricsWidth(font_metrics, label) + 4; + font_x_offset = QtUtils::q_font_metrics_width(font_metrics, label) + 4; p.drawText(histogram_start_dim_x - font_x_offset, (histogram_dim_y * pow(1.0 - *it, histogram_base)) + @@ -149,7 +149,7 @@ void HistogramScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) p.drawLines(histogram_lines); } -void HistogramScope::DrawScopeSoftware(QPainter &p, const QImage &image) +void HistogramScope::draw_scope_software(QPainter &p, const QImage &image) { const float histogram_scale = 0.80f; const float histogram_base = 2.5f; @@ -241,7 +241,7 @@ void HistogramScope::DrawScopeSoftware(QPainter &p, const QImage &image) (histogram_dim_y * pow(1.0 - *it, histogram_base)) + histogram_start_dim_y); label = QString::number(*it * 100, 'f', 1) + "%"; - font_x_offset = QtUtils::QFontMetricsWidth(font_metrics, label) + 4; + font_x_offset = QtUtils::q_font_metrics_width(font_metrics, label) + 4; p.drawText(histogram_start_dim_x - font_x_offset, (histogram_dim_y * pow(1.0 - *it, histogram_base)) + diff --git a/app/widget/scope/histogram/histogram.h b/app/widget/scope/histogram/histogram.h index 53037c57c..764b3f92b 100644 --- a/app/widget/scope/histogram/histogram.h +++ b/app/widget/scope/histogram/histogram.h @@ -19,8 +19,8 @@ ***/ -#ifndef HISTOGRAMSCOPE_H -#define HISTOGRAMSCOPE_H +#ifndef OAK_HISTOGRAMSCOPE_H +#define OAK_HISTOGRAMSCOPE_H #include "widget/scope/scopebase/scopebase.h" @@ -35,17 +35,17 @@ public: MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(HistogramScope) protected slots: - virtual void OnInit() override; + virtual void on_init() override; - virtual void OnDestroy() override; + virtual void on_destroy() override; protected: - virtual ShaderCode GenerateShaderCode() override; - QVariant CreateSecondaryShader(); + virtual ShaderCode generate_shader_code() override; + QVariant create_secondary_shader(); - virtual void DrawScope(TexturePtr managed_tex, QVariant pipeline) override; + virtual void draw_scope(TexturePtr managed_tex, QVariant pipeline) override; - virtual void DrawScopeSoftware(QPainter &p, const QImage &image) override; + virtual void draw_scope_software(QPainter &p, const QImage &image) override; private: QVariant pipeline_secondary_; @@ -54,4 +54,4 @@ private: } -#endif // HISTOGRAMSCOPE_H +#endif // OAK_HISTOGRAMSCOPE_H diff --git a/app/widget/scope/scopebase/scopebase.cpp b/app/widget/scope/scopebase/scopebase.cpp index 80fd03cbf..27372f111 100644 --- a/app/widget/scope/scopebase/scopebase.cpp +++ b/app/widget/scope/scopebase/scopebase.cpp @@ -35,10 +35,10 @@ ScopeBase::ScopeBase(QWidget *parent) , managed_tex_up_to_date_(false) , software_image_up_to_date_(false) { - EnableDefaultContextMenu(); + enable_default_context_menu(); } -void ScopeBase::SetBuffer(TexturePtr frame) +void ScopeBase::set_buffer(TexturePtr frame) { texture_ = frame; managed_tex_up_to_date_ = false; @@ -51,20 +51,20 @@ void ScopeBase::showEvent(QShowEvent *e) super::showEvent(e); } -void ScopeBase::DrawScope(TexturePtr managed_tex, QVariant pipeline) +void ScopeBase::draw_scope(TexturePtr managed_tex, QVariant pipeline) { ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), - NodeValue(NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(managed_tex))); - renderer()->Blit(pipeline, job, GetViewportParams()); + renderer()->blit(pipeline, job, get_viewport_params()); } -void ScopeBase::UpdateSoftwareImage() +void ScopeBase::update_software_image() { - if (!texture_ || texture_->IsDummy() || !renderer()) { + if (!texture_ || texture_->is_dummy() || !renderer()) { software_image_ = QImage(); software_image_up_to_date_ = true; return; @@ -76,18 +76,18 @@ void ScopeBase::UpdateSoftwareImage() // it into this scope's renderer before we can sample it. TexturePtr source_tex = texture_; if (texture_->renderer() && texture_->renderer() != renderer()) { - FramePtr temp_frame = Frame::Create(); + FramePtr temp_frame = Frame::create(); temp_frame->set_video_params(texture_->params()); temp_frame->allocate(); - texture_->Download(temp_frame->data(), temp_frame->linesize_pixels()); + texture_->download(temp_frame->data(), temp_frame->linesize_pixels()); - local_texture_ = renderer()->CreateTexture( + local_texture_ = renderer()->create_texture( temp_frame->video_params(), temp_frame->data(), temp_frame->linesize_pixels()); source_tex = local_texture_; } - if (!source_tex || source_tex->IsDummy()) { + if (!source_tex || source_tex->is_dummy()) { software_image_ = QImage(); software_image_up_to_date_ = true; return; @@ -97,94 +97,94 @@ void ScopeBase::UpdateSoftwareImage() const int texture_height = static_cast(height() * devicePixelRatioF()); const VideoParams offscreen_params(texture_width, texture_height, - PixelFormat::U8, - VideoParams::kRGBAChannelCount); + PixelFormat::u8, + VideoParams::k_rgba_channel_count); if (!software_tex_ || software_tex_->params() != offscreen_params) { - software_tex_ = renderer()->CreateTexture(offscreen_params); + software_tex_ = renderer()->create_texture(offscreen_params); software_buffer_.resize( texture_width * texture_height * - VideoParams::GetBytesPerPixel(PixelFormat::U8, - VideoParams::kRGBAChannelCount)); + VideoParams::get_bytes_per_pixel(PixelFormat::u8, + VideoParams::k_rgba_channel_count)); } - if (!software_tex_ || software_tex_->IsDummy()) { + if (!software_tex_ || software_tex_->is_dummy()) { software_image_ = QImage(); software_image_up_to_date_ = true; return; } ColorTransformJob job; - job.SetColorProcessor(color_service()); - job.SetInputTexture(source_tex); - job.SetInputAlphaAssociation(kAlphaNone); - job.SetClearDestinationEnabled(true); - job.SetForceOpaque(true); + job.set_color_processor(color_service()); + job.set_input_texture(source_tex); + job.set_input_alpha_association(k_alpha_none); + job.set_clear_destination_enabled(true); + job.set_force_opaque(true); - renderer()->BlitColorManaged(job, software_tex_.get()); - renderer()->DownloadFromTexture(software_tex_->id(), + renderer()->blit_color_managed(job, software_tex_.get()); + renderer()->download_from_texture(software_tex_->id(), software_tex_->params(), software_buffer_.data(), 0); software_image_ = QImage( reinterpret_cast(software_buffer_.constData()), texture_width, texture_height, - texture_width * VideoParams::GetBytesPerPixel( - PixelFormat::U8, VideoParams::kRGBAChannelCount), + texture_width * VideoParams::get_bytes_per_pixel( + PixelFormat::u8, VideoParams::k_rgba_channel_count), QImage::Format_RGBA8888_Premultiplied); software_image_.setDevicePixelRatio(devicePixelRatioF()); software_image_up_to_date_ = true; } -void ScopeBase::OnInit() +void ScopeBase::on_init() { - super::OnInit(); + super::on_init(); - if (!IsBackendNeutral()) { - pipeline_ = renderer()->CreateNativeShader(GenerateShaderCode()); + if (!is_backend_neutral()) { + pipeline_ = renderer()->create_native_shader(generate_shader_code()); } } -void ScopeBase::OnPaint() +void ScopeBase::on_paint() { - if (IsBackendNeutral()) { + if (is_backend_neutral()) { if (!software_image_up_to_date_) { - UpdateSoftwareImage(); + update_software_image(); } QPainter p(paint_device()); p.fillRect(rect(), Qt::black); if (!software_image_.isNull()) { - DrawScopeSoftware(p, software_image_); + draw_scope_software(p, software_image_); } return; } // Clear display surface - renderer()->ClearDestination(); + renderer()->clear_destination(); if (texture_) { // Convert reference frame to display space if (!managed_tex_ || !managed_tex_up_to_date_ || managed_tex_->params() != texture_->params()) { - managed_tex_ = renderer()->CreateTexture(texture_->params()); + managed_tex_ = renderer()->create_texture(texture_->params()); ColorTransformJob job; - job.SetColorProcessor(color_service()); - job.SetInputTexture(texture_); - job.SetInputAlphaAssociation(kAlphaNone); + job.set_color_processor(color_service()); + job.set_input_texture(texture_); + job.set_input_alpha_association(k_alpha_none); - renderer()->BlitColorManaged(job, managed_tex_.get()); + renderer()->blit_color_managed(job, managed_tex_.get()); managed_tex_up_to_date_ = true; } - DrawScope(managed_tex_, pipeline_); + draw_scope(managed_tex_, pipeline_); } } -void ScopeBase::OnDestroy() +void ScopeBase::on_destroy() { local_texture_ = nullptr; software_tex_ = nullptr; @@ -194,7 +194,7 @@ void ScopeBase::OnDestroy() texture_ = nullptr; pipeline_.clear(); - super::OnDestroy(); + super::on_destroy(); } } diff --git a/app/widget/scope/scopebase/scopebase.h b/app/widget/scope/scopebase/scopebase.h index 37e81e617..50ae3c1ec 100644 --- a/app/widget/scope/scopebase/scopebase.h +++ b/app/widget/scope/scopebase/scopebase.h @@ -19,8 +19,8 @@ ***/ -#ifndef SCOPEBASE_H -#define SCOPEBASE_H +#ifndef OAK_SCOPEBASE_H +#define OAK_SCOPEBASE_H #include "codec/frame.h" #include "render/colorprocessor.h" @@ -36,26 +36,26 @@ public: MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(ScopeBase) public slots: - void SetBuffer(TexturePtr frame); + void set_buffer(TexturePtr frame); protected slots: - virtual void OnInit() override; + virtual void on_init() override; - virtual void OnPaint() override; + virtual void on_paint() override; - virtual void OnDestroy() override; + virtual void on_destroy() override; protected: virtual void showEvent(QShowEvent *e) override; - virtual ShaderCode GenerateShaderCode() = 0; + virtual ShaderCode generate_shader_code() = 0; /** * @brief GPU-accelerated draw function used on OpenGL backends. * * Override this if your sub-class scope needs extra drawing. */ - virtual void DrawScope(TexturePtr managed_tex, QVariant pipeline); + virtual void draw_scope(TexturePtr managed_tex, QVariant pipeline); /** * @brief Software draw function used on backend-neutral paths (e.g. Vulkan). @@ -63,10 +63,10 @@ protected: * Implementations receive an 8-bit sRGB/display-ready image and should draw * the scope visualization with QPainter. */ - virtual void DrawScopeSoftware(QPainter &p, const QImage &image) = 0; + virtual void draw_scope_software(QPainter &p, const QImage &image) = 0; private: - void UpdateSoftwareImage(); + void update_software_image(); QVariant pipeline_; @@ -86,4 +86,4 @@ private: } -#endif // SCOPEBASE_H +#endif // OAK_SCOPEBASE_H diff --git a/app/widget/scope/vectorscope/vectorscope.cpp b/app/widget/scope/vectorscope/vectorscope.cpp index 7553c44e3..f4017a5a5 100644 --- a/app/widget/scope/vectorscope/vectorscope.cpp +++ b/app/widget/scope/vectorscope/vectorscope.cpp @@ -39,14 +39,14 @@ VectorscopeScope::VectorscopeScope(QWidget *parent) { } -ShaderCode VectorscopeScope::GenerateShaderCode() +ShaderCode VectorscopeScope::generate_shader_code() { return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/rgbvectorscope.frag"), - FileFunctions::ReadFileAsString(":/shaders/rgbvectorscope.vert")); + FileFunctions::read_file_as_string(":/shaders/rgbvectorscope.frag"), + FileFunctions::read_file_as_string(":/shaders/rgbvectorscope.vert")); } -void VectorscopeScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) +void VectorscopeScope::draw_scope(TexturePtr managed_tex, QVariant pipeline) { float vectorscope_scale = 0.80f; float vectorscope_gain = 1.45f; @@ -56,32 +56,32 @@ void VectorscopeScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) ShaderJob job; - job.Insert(QStringLiteral("viewport"), - NodeValue(NodeValue::kVec2, QVector2D(width(), height()))); + job.insert(QStringLiteral("viewport"), + NodeValue(NodeValue::k_vec2, QVector2D(width(), height()))); double luma_coeffs[3] = { 0.0f, 0.0f, 0.0f }; - color_manager()->GetDefaultLumaCoefs(luma_coeffs); - job.Insert( + color_manager()->get_default_luma_coefs(luma_coeffs); + job.insert( QStringLiteral("luma_coeffs"), - NodeValue(NodeValue::kVec3, + NodeValue(NodeValue::k_vec3, QVector3D(luma_coeffs[0], luma_coeffs[1], luma_coeffs[2]))); - job.Insert(QStringLiteral("vectorscope_scale"), - NodeValue(NodeValue::kFloat, vectorscope_scale)); - job.Insert(QStringLiteral("vectorscope_gain"), - NodeValue(NodeValue::kFloat, vectorscope_gain)); - job.Insert(QStringLiteral("vectorscope_point_radius"), - NodeValue(NodeValue::kFloat, vectorscope_point_radius)); - job.Insert(QStringLiteral("vectorscope_intensity"), - NodeValue(NodeValue::kFloat, vectorscope_intensity)); - job.Insert(QStringLiteral("vectorscope_sample_grid"), - NodeValue(NodeValue::kFloat, vectorscope_sample_grid)); + job.insert(QStringLiteral("vectorscope_scale"), + NodeValue(NodeValue::k_float, vectorscope_scale)); + job.insert(QStringLiteral("vectorscope_gain"), + NodeValue(NodeValue::k_float, vectorscope_gain)); + job.insert(QStringLiteral("vectorscope_point_radius"), + NodeValue(NodeValue::k_float, vectorscope_point_radius)); + job.insert(QStringLiteral("vectorscope_intensity"), + NodeValue(NodeValue::k_float, vectorscope_intensity)); + job.insert(QStringLiteral("vectorscope_sample_grid"), + NodeValue(NodeValue::k_float, vectorscope_sample_grid)); - job.Insert(QStringLiteral("ove_maintex"), - NodeValue(NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(managed_tex))); - renderer()->Blit(pipeline, job, GetViewportParams()); + renderer()->blit(pipeline, job, get_viewport_params()); QPainter p(paint_device()); QFont font = p.font(); @@ -113,10 +113,10 @@ void VectorscopeScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) const float label_radius = radius + 12.0f; const float marker_radius = radius * 0.72f; - constexpr float kPi = 3.14159265358979323846f; + constexpr float k_pi = 3.14159265358979323846f; for (const Target &target : targets) { - float radians = target.angle * kPi / 180.0f; + float radians = target.angle * k_pi / 180.0f; QPointF direction(qCos(radians), -qSin(radians)); QPointF marker = center + direction * marker_radius; QPointF label_pos = center + direction * label_radius; @@ -124,12 +124,12 @@ void VectorscopeScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) p.drawEllipse(marker, 3.0, 3.0); p.drawText(label_pos.x() - - QtUtils::QFontMetricsWidth(font_metrics, label) * 0.5, + QtUtils::q_font_metrics_width(font_metrics, label) * 0.5, label_pos.y() + font_metrics.capHeight() * 0.5, label); } } -void VectorscopeScope::DrawScopeSoftware(QPainter &p, const QImage &image) +void VectorscopeScope::draw_scope_software(QPainter &p, const QImage &image) { const float vectorscope_scale = 0.80f; const float vectorscope_gain = 1.45f; @@ -139,7 +139,7 @@ void VectorscopeScope::DrawScopeSoftware(QPainter &p, const QImage &image) buf.fill(Qt::transparent); double luma_coeffs[3] = { 0.0, 0.0, 0.0 }; - color_manager()->GetDefaultLumaCoefs(luma_coeffs); + color_manager()->get_default_luma_coefs(luma_coeffs); const int src_w = image.width(); const int src_h = image.height(); @@ -214,10 +214,10 @@ void VectorscopeScope::DrawScopeSoftware(QPainter &p, const QImage &image) const float label_radius = radius + 12.0f; const float marker_radius = radius * 0.72f; - constexpr float kPi = 3.14159265358979323846f; + constexpr float k_pi = 3.14159265358979323846f; for (const Target &target : targets) { - float radians = target.angle * kPi / 180.0f; + float radians = target.angle * k_pi / 180.0f; QPointF direction(qCos(radians), -qSin(radians)); QPointF marker = center + direction * marker_radius; QPointF label_pos = center + direction * label_radius; @@ -225,7 +225,7 @@ void VectorscopeScope::DrawScopeSoftware(QPainter &p, const QImage &image) p.drawEllipse(marker, 3.0, 3.0); p.drawText(label_pos.x() - - QtUtils::QFontMetricsWidth(font_metrics, label) * 0.5, + QtUtils::q_font_metrics_width(font_metrics, label) * 0.5, label_pos.y() + font_metrics.capHeight() * 0.5, label); } } diff --git a/app/widget/scope/vectorscope/vectorscope.h b/app/widget/scope/vectorscope/vectorscope.h index 9cc804351..1c7f9671d 100644 --- a/app/widget/scope/vectorscope/vectorscope.h +++ b/app/widget/scope/vectorscope/vectorscope.h @@ -19,8 +19,8 @@ ***/ -#ifndef VECTORSCOPESCOPE_H -#define VECTORSCOPESCOPE_H +#ifndef OAK_VECTORSCOPESCOPE_H +#define OAK_VECTORSCOPESCOPE_H #include "widget/scope/scopebase/scopebase.h" @@ -35,13 +35,13 @@ public: MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(VectorscopeScope) protected: - virtual ShaderCode GenerateShaderCode() override; + virtual ShaderCode generate_shader_code() override; - virtual void DrawScope(TexturePtr managed_tex, QVariant pipeline) override; + virtual void draw_scope(TexturePtr managed_tex, QVariant pipeline) override; - virtual void DrawScopeSoftware(QPainter &p, const QImage &image) override; + virtual void draw_scope_software(QPainter &p, const QImage &image) override; }; } -#endif // VECTORSCOPESCOPE_H +#endif // OAK_VECTORSCOPESCOPE_H diff --git a/app/widget/scope/waveform/waveform.cpp b/app/widget/scope/waveform/waveform.cpp index 7c3439f83..82d672cd6 100644 --- a/app/widget/scope/waveform/waveform.cpp +++ b/app/widget/scope/waveform/waveform.cpp @@ -42,14 +42,14 @@ WaveformScope::WaveformScope(QWidget *parent) { } -ShaderCode WaveformScope::GenerateShaderCode() +ShaderCode WaveformScope::generate_shader_code() { return ShaderCode( - FileFunctions::ReadFileAsString(":/shaders/rgbwaveform.frag"), - FileFunctions::ReadFileAsString(":/shaders/rgbwaveform.vert")); + FileFunctions::read_file_as_string(":/shaders/rgbwaveform.frag"), + FileFunctions::read_file_as_string(":/shaders/rgbwaveform.vert")); } -void WaveformScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) +void WaveformScope::draw_scope(TexturePtr managed_tex, QVariant pipeline) { float waveform_scale = 0.80f; @@ -57,27 +57,27 @@ void WaveformScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) ShaderJob job; // Set viewport size - job.Insert(QStringLiteral("viewport"), - NodeValue(NodeValue::kVec2, QVector2D(width(), height()))); + job.insert(QStringLiteral("viewport"), + NodeValue(NodeValue::k_vec2, QVector2D(width(), height()))); // Set luma coefficients double luma_coeffs[3] = { 0.0f, 0.0f, 0.0f }; - color_manager()->GetDefaultLumaCoefs(luma_coeffs); - job.Insert( + color_manager()->get_default_luma_coefs(luma_coeffs); + job.insert( QStringLiteral("luma_coeffs"), - NodeValue(NodeValue::kVec3, + NodeValue(NodeValue::k_vec3, QVector3D(luma_coeffs[0], luma_coeffs[1], luma_coeffs[2]))); // Scale of the waveform relative to the viewport surface. - job.Insert(QStringLiteral("waveform_scale"), - NodeValue(NodeValue::kFloat, waveform_scale)); + job.insert(QStringLiteral("waveform_scale"), + NodeValue(NodeValue::k_float, waveform_scale)); // Insert source texture - job.Insert(QStringLiteral("ove_maintex"), - NodeValue(NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + NodeValue(NodeValue::k_texture, QVariant::fromValue(managed_tex))); - renderer()->Blit(pipeline, job, GetViewportParams()); + renderer()->blit(pipeline, job, get_viewport_params()); float waveform_dim_x = ceil((width() - 1.0) * waveform_scale); float waveform_dim_y = ceil((height() - 1.0) * waveform_scale); @@ -109,7 +109,7 @@ void WaveformScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) waveform_end_dim_x, (waveform_dim_y * (i * ire_increment)) + waveform_start_dim_y); label = QString::number(1.0 - (i * ire_increment), 'f', 1); - font_x_offset = QtUtils::QFontMetricsWidth(font_metrics, label) + 4; + font_x_offset = QtUtils::q_font_metrics_width(font_metrics, label) + 4; p.drawText(waveform_start_dim_x - font_x_offset, (waveform_dim_y * (i * ire_increment)) + @@ -120,7 +120,7 @@ void WaveformScope::DrawScope(TexturePtr managed_tex, QVariant pipeline) p.drawLines(ire_lines); } -void WaveformScope::DrawScopeSoftware(QPainter &p, const QImage &image) +void WaveformScope::draw_scope_software(QPainter &p, const QImage &image) { const float waveform_scale = 0.80f; const int waveform_dim_x = qCeil((width() - 1.0) * waveform_scale); @@ -203,7 +203,7 @@ void WaveformScope::DrawScopeSoftware(QPainter &p, const QImage &image) waveform_end_dim_x, (waveform_dim_y * (i * ire_increment)) + waveform_start_dim_y); label = QString::number(1.0 - (i * ire_increment), 'f', 1); - font_x_offset = QtUtils::QFontMetricsWidth(font_metrics, label) + 4; + font_x_offset = QtUtils::q_font_metrics_width(font_metrics, label) + 4; p.drawText(waveform_start_dim_x - font_x_offset, (waveform_dim_y * (i * ire_increment)) + diff --git a/app/widget/scope/waveform/waveform.h b/app/widget/scope/waveform/waveform.h index 1b9dfd332..2b07132ca 100644 --- a/app/widget/scope/waveform/waveform.h +++ b/app/widget/scope/waveform/waveform.h @@ -19,8 +19,8 @@ ***/ -#ifndef WAVEFORMSCOPE_H -#define WAVEFORMSCOPE_H +#ifndef OAK_WAVEFORMSCOPE_H +#define OAK_WAVEFORMSCOPE_H #include "widget/scope/scopebase/scopebase.h" @@ -35,13 +35,13 @@ public: MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(WaveformScope) protected: - virtual ShaderCode GenerateShaderCode() override; + virtual ShaderCode generate_shader_code() override; - virtual void DrawScope(TexturePtr managed_tex, QVariant pipeline) override; + virtual void draw_scope(TexturePtr managed_tex, QVariant pipeline) override; - virtual void DrawScopeSoftware(QPainter &p, const QImage &image) override; + virtual void draw_scope_software(QPainter &p, const QImage &image) override; }; } -#endif // WAVEFORMSCOPE_H +#endif // OAK_WAVEFORMSCOPE_H diff --git a/app/widget/slider/base/decimalsliderbase.cpp b/app/widget/slider/base/decimalsliderbase.cpp index 66ae792f4..4776712d6 100644 --- a/app/widget/slider/base/decimalsliderbase.cpp +++ b/app/widget/slider/base/decimalsliderbase.cpp @@ -33,14 +33,14 @@ DecimalSliderBase::DecimalSliderBase(QWidget *parent) { } -void DecimalSliderBase::SetAutoTrimDecimalPlaces(bool e) +void DecimalSliderBase::set_auto_trim_decimal_places(bool e) { autotrim_decimal_places_ = e; - UpdateLabel(); + update_label(); } -QString DecimalSliderBase::FloatToString(double val, int decimal_places, +QString DecimalSliderBase::float_to_string(double val, int decimal_places, bool autotrim_decimal_places) { QString s = QString::number(val, 'f', decimal_places); @@ -54,11 +54,11 @@ QString DecimalSliderBase::FloatToString(double val, int decimal_places, return s; } -void DecimalSliderBase::SetDecimalPlaces(int i) +void DecimalSliderBase::set_decimal_places(int i) { decimal_places_ = i; - UpdateLabel(); + update_label(); } } diff --git a/app/widget/slider/base/decimalsliderbase.h b/app/widget/slider/base/decimalsliderbase.h index 3ab4a78c8..66c3bcb14 100644 --- a/app/widget/slider/base/decimalsliderbase.h +++ b/app/widget/slider/base/decimalsliderbase.h @@ -19,8 +19,8 @@ ***/ -#ifndef DECIMALSLIDERBASE_H -#define DECIMALSLIDERBASE_H +#ifndef OAK_DECIMALSLIDERBASE_H +#define OAK_DECIMALSLIDERBASE_H #include "numericsliderbase.h" @@ -31,19 +31,19 @@ class DecimalSliderBase : public NumericSliderBase { public: DecimalSliderBase(QWidget *parent = nullptr); - int GetDecimalPlaces() const + int get_decimal_places() const { return decimal_places_; } - void SetDecimalPlaces(int i); + void set_decimal_places(int i); - bool GetAutoTrimDecimalPlaces() const + bool get_auto_trim_decimal_places() const { return autotrim_decimal_places_; }; - void SetAutoTrimDecimalPlaces(bool e); + void set_auto_trim_decimal_places(bool e); - static QString FloatToString(double val, int decimal_places, + static QString float_to_string(double val, int decimal_places, bool autotrim_decimal_places); private: @@ -54,4 +54,4 @@ private: } -#endif // DECIMALSLIDERBASE_H +#endif // OAK_DECIMALSLIDERBASE_H diff --git a/app/widget/slider/base/numericsliderbase.cpp b/app/widget/slider/base/numericsliderbase.cpp index 933c5399b..de11c30c3 100644 --- a/app/widget/slider/base/numericsliderbase.cpp +++ b/app/widget/slider/base/numericsliderbase.cpp @@ -28,7 +28,7 @@ namespace olive { -bool NumericSliderBase::effects_slider_is_being_dragged_ = false; +bool NumericSliderBase::effects_slider_is_being_dragged = false; NumericSliderBase::NumericSliderBase(QWidget *parent) : SliderBase(parent) @@ -44,60 +44,60 @@ NumericSliderBase::NumericSliderBase(QWidget *parent) // Numeric sliders are draggable, so we have a cursor that indicates that setCursor(Qt::SizeHorCursor); - connect(label(), &SliderLabel::LabelPressed, this, - &NumericSliderBase::LabelPressed); + connect(label(), &SliderLabel::label_pressed, this, + &NumericSliderBase::label_pressed); } -void NumericSliderBase::SetDragMultiplier(const double &d) +void NumericSliderBase::set_drag_multiplier(const double &d) { drag_multiplier_ = d; } -void NumericSliderBase::LabelPressed() +void NumericSliderBase::label_pressed() { drag_ladder_ = new SliderLadder(drag_multiplier_, ladder_element_count_, - GetFormattedValueToString(99999999)); - connect(drag_ladder_, &SliderLadder::DraggedByValue, this, - &NumericSliderBase::LadderDragged); - connect(drag_ladder_, &SliderLadder::Released, this, - &NumericSliderBase::LadderReleased); + get_formatted_value_to_string(99999999)); + connect(drag_ladder_, &SliderLadder::dragged_by_value, this, + &NumericSliderBase::ladder_dragged); + connect(drag_ladder_, &SliderLadder::released, this, + &NumericSliderBase::ladder_released); - drag_ladder_->SetValue(GetFormattedValueToString()); + drag_ladder_->set_value(get_formatted_value_to_string()); drag_ladder_->resize(drag_ladder_->sizeHint()); - RepositionLadder(); + reposition_ladder(); drag_ladder_->show(); - drag_start_value_ = GetValueInternal(); + drag_start_value_ = get_value_internal(); } -void NumericSliderBase::LadderDragged(int value, double multiplier) +void NumericSliderBase::ladder_dragged(int value, double multiplier) { dragged_ = true; dragged_diff_ += value * multiplier; // Store current value to try and prevent any unnecessary signalling if the value doesn't change - QVariant pre_set_value = GetValueInternal(); + QVariant pre_set_value = get_value_internal(); setting_drag_value_ = true; - SetValueInternal( - AdjustDragDistanceInternal(drag_start_value_, dragged_diff_)); + set_value_internal( + adjust_drag_distance_internal(drag_start_value_, dragged_diff_)); setting_drag_value_ = false; - if (GetValueInternal() != pre_set_value) { + if (get_value_internal() != pre_set_value) { // We retrieve the value instead of storing it ourselves because SetValueInternal may do extra // processing (such as clamping). - drag_ladder_->SetValue(GetFormattedValueToString()); + drag_ladder_->set_value(get_formatted_value_to_string()); - if (!UsingLadders()) { - RepositionLadder(); + if (!using_ladders()) { + reposition_ladder(); } - ValueSignalEvent(GetValueInternal()); + value_signal_event(get_value_internal()); } } -void NumericSliderBase::LadderReleased() +void NumericSliderBase::ladder_released() { drag_ladder_->deleteLater(); drag_ladder_ = nullptr; @@ -105,24 +105,24 @@ void NumericSliderBase::LadderReleased() if (dragged_) { // This was a drag, send another value changed event - ValueSignalEvent(GetValueInternal()); + value_signal_event(get_value_internal()); dragged_ = false; } else { - ShowEditor(); + show_editor(); } } -void NumericSliderBase::RepositionLadder() +void NumericSliderBase::reposition_ladder() { if (drag_ladder_) { - if (UsingLadders()) { + if (using_ladders()) { drag_ladder_->move( QCursor::pos() - QPoint(drag_ladder_->width() / 2, drag_ladder_->height() / 2)); } else { QPoint label_global_pos = label()->mapToGlobal(label()->pos()); - int text_width = QtUtils::QFontMetricsWidth(label()->fontMetrics(), + int text_width = QtUtils::q_font_metrics_width(label()->fontMetrics(), label()->text()); if (label()->alignment() & Qt::AlignRight) { @@ -141,83 +141,83 @@ void NumericSliderBase::RepositionLadder() drag_ladder_->move(ladder_x, ladder_y); } - drag_ladder_->StartListeningToMouseInput(); + drag_ladder_->start_listening_to_mouse_input(); } } -bool NumericSliderBase::IsDragging() const +bool NumericSliderBase::is_dragging() const { return drag_ladder_; } -bool NumericSliderBase::UsingLadders() const +bool NumericSliderBase::using_ladders() const { return ladder_element_count_ > 0 && - OLIVE_CONFIG("UseSliderLadders").toBool(); + OAK_CONFIG("UseSliderLadders").toBool(); } -QVariant NumericSliderBase::AdjustValue(const QVariant &value) const +QVariant NumericSliderBase::adjust_value(const QVariant &value) const { // Clamps between min/max - if (has_min_ && ValueLessThan(value, min_value_)) { + if (has_min_ && value_less_than(value, min_value_)) { return min_value_; - } else if (has_max_ && ValueGreaterThan(value, max_value_)) { + } else if (has_max_ && value_greater_than(value, max_value_)) { return max_value_; } return value; } -void NumericSliderBase::SetOffset(const QVariant &v) +void NumericSliderBase::set_offset(const QVariant &v) { offset_ = v; - UpdateLabel(); + update_label(); } -QVariant NumericSliderBase::AdjustDragDistanceInternal(const QVariant &start, +QVariant NumericSliderBase::adjust_drag_distance_internal(const QVariant &start, const double &drag) const { return start.toDouble() + drag; } -void NumericSliderBase::SetMinimumInternal(const QVariant &v) +void NumericSliderBase::set_minimum_internal(const QVariant &v) { min_value_ = v; has_min_ = true; // Limit value by this new minimum value - if (ValueLessThan(GetValueInternal(), min_value_)) { - SetValueInternal(min_value_); + if (value_less_than(get_value_internal(), min_value_)) { + set_value_internal(min_value_); } } -void NumericSliderBase::SetMaximumInternal(const QVariant &v) +void NumericSliderBase::set_maximum_internal(const QVariant &v) { max_value_ = v; has_max_ = true; // Limit value by this new maximum value - if (ValueGreaterThan(GetValueInternal(), max_value_)) { - SetValueInternal(max_value_); + if (value_greater_than(get_value_internal(), max_value_)) { + set_value_internal(max_value_); } } -bool NumericSliderBase::ValueGreaterThan(const QVariant &lhs, +bool NumericSliderBase::value_greater_than(const QVariant &lhs, const QVariant &rhs) const { return lhs.toDouble() > rhs.toDouble(); } -bool NumericSliderBase::ValueLessThan(const QVariant &lhs, +bool NumericSliderBase::value_less_than(const QVariant &lhs, const QVariant &rhs) const { return lhs.toDouble() < rhs.toDouble(); } -bool NumericSliderBase::CanSetValue() const +bool NumericSliderBase::can_set_value() const { - return !IsDragging() || setting_drag_value_; + return !is_dragging() || setting_drag_value_; } } diff --git a/app/widget/slider/base/numericsliderbase.h b/app/widget/slider/base/numericsliderbase.h index 38848b158..b031e7872 100644 --- a/app/widget/slider/base/numericsliderbase.h +++ b/app/widget/slider/base/numericsliderbase.h @@ -19,8 +19,8 @@ ***/ -#ifndef NUMERICSLIDERBASE_H -#define NUMERICSLIDERBASE_H +#ifndef OAK_NUMERICSLIDERBASE_H +#define OAK_NUMERICSLIDERBASE_H #include "sliderbase.h" @@ -32,41 +32,41 @@ class NumericSliderBase : public SliderBase { public: NumericSliderBase(QWidget *parent = nullptr); - void SetLadderElementCount(int b) + void set_ladder_element_count(int b) { ladder_element_count_ = b; } - void SetDragMultiplier(const double &d); + void set_drag_multiplier(const double &d); - void SetOffset(const QVariant &v); + void set_offset(const QVariant &v); - bool IsDragging() const; + bool is_dragging() const; protected: - const QVariant &GetOffset() const + const QVariant &get_offset() const { return offset_; } - virtual QVariant AdjustDragDistanceInternal(const QVariant &start, + virtual QVariant adjust_drag_distance_internal(const QVariant &start, const double &drag) const; - void SetMinimumInternal(const QVariant &v); + void set_minimum_internal(const QVariant &v); - void SetMaximumInternal(const QVariant &v); + void set_maximum_internal(const QVariant &v); - virtual bool ValueGreaterThan(const QVariant &lhs, + virtual bool value_greater_than(const QVariant &lhs, const QVariant &rhs) const; - virtual bool ValueLessThan(const QVariant &lhs, const QVariant &rhs) const; + virtual bool value_less_than(const QVariant &lhs, const QVariant &rhs) const; - virtual bool CanSetValue() const override; + virtual bool can_set_value() const override; private: - bool UsingLadders() const; + bool using_ladders() const; - virtual QVariant AdjustValue(const QVariant &value) const override; + virtual QVariant adjust_value(const QVariant &value) const override; SliderLadder *drag_ladder_; @@ -93,18 +93,18 @@ private: /** * @brief An effects slider somewhere is being dragged */ - static bool effects_slider_is_being_dragged_; + static bool effects_slider_is_being_dragged; private slots: - void LabelPressed(); + void label_pressed(); - void RepositionLadder(); + void reposition_ladder(); - void LadderDragged(int value, double multiplier); + void ladder_dragged(int value, double multiplier); - void LadderReleased(); + void ladder_released(); }; } -#endif // NUMERICSLIDERBASE_H +#endif // OAK_NUMERICSLIDERBASE_H diff --git a/app/widget/slider/base/sliderbase.cpp b/app/widget/slider/base/sliderbase.cpp index 54aeeb23b..18a3ac9fe 100644 --- a/app/widget/slider/base/sliderbase.cpp +++ b/app/widget/slider/base/sliderbase.cpp @@ -50,51 +50,51 @@ SliderBase::SliderBase(QWidget *parent) editor_ = new FocusableLineEdit(this); addWidget(editor_); - connect(label_, &SliderLabel::focused, this, &SliderBase::ShowEditor); - connect(label_, &SliderLabel::RequestReset, this, &SliderBase::ResetValue); - connect(editor_, &FocusableLineEdit::Confirmed, this, - &SliderBase::LineEditConfirmed); - connect(editor_, &FocusableLineEdit::Cancelled, this, - &SliderBase::LineEditCancelled); + connect(label_, &SliderLabel::focused, this, &SliderBase::show_editor); + connect(label_, &SliderLabel::request_reset, this, &SliderBase::reset_value); + connect(editor_, &FocusableLineEdit::confirmed, this, + &SliderBase::line_edit_confirmed); + connect(editor_, &FocusableLineEdit::cancelled, this, + &SliderBase::line_edit_cancelled); } -void SliderBase::SetAlignment(Qt::Alignment alignment) +void SliderBase::set_alignment(Qt::Alignment alignment) { label_->setAlignment(alignment); editor_->setAlignment(alignment); } -bool SliderBase::IsTristate() const +bool SliderBase::is_tristate() const { return tristate_; } -void SliderBase::SetTristate() +void SliderBase::set_tristate() { tristate_ = true; - UpdateLabel(); + update_label(); } -const QVariant &SliderBase::GetValueInternal() const +const QVariant &SliderBase::get_value_internal() const { return value_; } -void SliderBase::SetValueInternal(const QVariant &v) +void SliderBase::set_value_internal(const QVariant &v) { - if (!CanSetValue()) { + if (!can_set_value()) { return; } - value_ = AdjustValue(v); + value_ = adjust_value(v); // Disable tristate tristate_ = false; - UpdateLabel(); + update_label(); } -void SliderBase::SetDefaultValue(const QVariant &v) +void SliderBase::set_default_value(const QVariant &v) { default_value_ = v; } @@ -102,12 +102,12 @@ void SliderBase::SetDefaultValue(const QVariant &v) void SliderBase::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - UpdateLabel(); + update_label(); } super::changeEvent(e); } -bool SliderBase::GetLabelSubstitution(const QVariant &v, QString *out) const +bool SliderBase::get_label_substitution(const QVariant &v, QString *out) const { for (auto it = label_substitutions_.constBegin(); it != label_substitutions_.constEnd(); it++) { @@ -120,41 +120,41 @@ bool SliderBase::GetLabelSubstitution(const QVariant &v, QString *out) const return false; } -void SliderBase::UpdateLabel() +void SliderBase::update_label() { QString s; if (tristate_) { s = tr("---"); - } else if (GetLabelSubstitution(GetValueInternal(), &s)) { + } else if (get_label_substitution(get_value_internal(), &s)) { // String will already be set, just pass through } else { - s = GetFormattedValueToString(); + s = get_formatted_value_to_string(); } label_->setText(s); } -QVariant SliderBase::AdjustValue(const QVariant &value) const +QVariant SliderBase::adjust_value(const QVariant &value) const { return value; } -bool SliderBase::CanSetValue() const +bool SliderBase::can_set_value() const { return true; } -void SliderBase::ValueSignalEvent(const QVariant &value) +void SliderBase::value_signal_event(const QVariant &value) { Q_UNUSED(value) } -void SliderBase::ShowEditor() +void SliderBase::show_editor() { // This was a simple click // Load label's text into editor - editor_->setText(ValueToString(value_)); + editor_->setText(value_to_string(value_)); // Show editor setCurrentWidget(editor_); @@ -164,21 +164,21 @@ void SliderBase::ShowEditor() editor_->selectAll(); } -void SliderBase::LineEditConfirmed() +void SliderBase::line_edit_confirmed() { bool is_valid = true; - QVariant test_val = StringToValue(editor_->text(), &is_valid); + QVariant test_val = string_to_value(editor_->text(), &is_valid); // Ensure editor doesn't signal that the focus is lost editor_->blockSignals(true); label_->blockSignals(true); if (is_valid) { - SetValueInternal(test_val); + set_value_internal(test_val); setCurrentWidget(label_); - ValueSignalEvent(value_); + value_signal_event(value_); } else { QMessageBox::critical( this, tr("Invalid Value"), @@ -193,7 +193,7 @@ void SliderBase::LineEditConfirmed() label_->blockSignals(false); } -void SliderBase::LineEditCancelled() +void SliderBase::line_edit_cancelled() { // Ensure editor doesn't signal that the focus is lost editor_->blockSignals(true); @@ -206,33 +206,33 @@ void SliderBase::LineEditCancelled() label_->blockSignals(false); } -void SliderBase::ResetValue() +void SliderBase::reset_value() { if (default_value_.isValid()) { - SetValueInternal(default_value_); - ValueSignalEvent(value_); + set_value_internal(default_value_); + value_signal_event(value_); } } -void SliderBase::SetFormat(const QString &s, const bool plural) +void SliderBase::set_format(const QString &s, const bool plural) { custom_format_ = s; format_plural_ = plural; - UpdateLabel(); + update_label(); } -void SliderBase::ClearFormat() +void SliderBase::clear_format() { custom_format_.clear(); - UpdateLabel(); + update_label(); } -bool SliderBase::IsFormatPlural() const +bool SliderBase::is_format_plural() const { return format_plural_; } -QString SliderBase::GetFormat() const +QString SliderBase::get_format() const { if (custom_format_.isEmpty()) { return QStringLiteral("%1"); @@ -241,17 +241,17 @@ QString SliderBase::GetFormat() const } } -QString SliderBase::GetFormattedValueToString() const +QString SliderBase::get_formatted_value_to_string() const { - return GetFormattedValueToString(GetValueInternal()); + return get_formatted_value_to_string(get_value_internal()); } -QString SliderBase::GetFormattedValueToString(const QVariant &v) const +QString SliderBase::get_formatted_value_to_string(const QVariant &v) const { if (format_plural_) { - return tr(GetFormat().toUtf8().constData(), nullptr, v.toInt()); + return tr(get_format().toUtf8().constData(), nullptr, v.toInt()); } else { - return GetFormat().arg(ValueToString(v)); + return get_format().arg(value_to_string(v)); } } diff --git a/app/widget/slider/base/sliderbase.h b/app/widget/slider/base/sliderbase.h index 7e5bd33a1..435c89065 100644 --- a/app/widget/slider/base/sliderbase.h +++ b/app/widget/slider/base/sliderbase.h @@ -19,8 +19,8 @@ ***/ -#ifndef SLIDERBASE_H -#define SLIDERBASE_H +#ifndef OAK_SLIDERBASE_H +#define OAK_SLIDERBASE_H #include @@ -36,65 +36,65 @@ class SliderBase : public QStackedWidget { public: SliderBase(QWidget *parent = nullptr); - void SetAlignment(Qt::Alignment alignment); + void set_alignment(Qt::Alignment alignment); - bool IsTristate() const; - void SetTristate(); + bool is_tristate() const; + void set_tristate(); - void SetFormat(const QString &s, const bool plural = false); - void ClearFormat(); + void set_format(const QString &s, const bool plural = false); + void clear_format(); - bool IsFormatPlural() const; + bool is_format_plural() const; - void SetDefaultValue(const QVariant &v); + void set_default_value(const QVariant &v); - QString GetFormattedValueToString(const QVariant &v) const; + QString get_formatted_value_to_string(const QVariant &v) const; - void InsertLabelSubstitution(const QVariant &value, const QString &label) + void insert_label_substitution(const QVariant &value, const QString &label) { label_substitutions_.append({ value, label }); - UpdateLabel(); + update_label(); } - void SetColor(const QColor &c) + void set_color(const QColor &c) { - label_->SetColor(c); + label_->set_color(c); } public slots: - void ShowEditor(); + void show_editor(); protected slots: - void UpdateLabel(); + void update_label(); protected: - const QVariant &GetValueInternal() const; + const QVariant &get_value_internal() const; - void SetValueInternal(const QVariant &v); + void set_value_internal(const QVariant &v); - QString GetFormat() const; + QString get_format() const; - QString GetFormattedValueToString() const; + QString get_formatted_value_to_string() const; SliderLabel *label() { return label_; } - virtual QString ValueToString(const QVariant &v) const = 0; + virtual QString value_to_string(const QVariant &v) const = 0; - virtual QVariant StringToValue(const QString &s, bool *ok) const = 0; + virtual QVariant string_to_value(const QString &s, bool *ok) const = 0; - virtual QVariant AdjustValue(const QVariant &value) const; + virtual QVariant adjust_value(const QVariant &value) const; - virtual bool CanSetValue() const; + virtual bool can_set_value() const; - virtual void ValueSignalEvent(const QVariant &value) = 0; + virtual void value_signal_event(const QVariant &value) = 0; virtual void changeEvent(QEvent *e) override; private: - bool GetLabelSubstitution(const QVariant &v, QString *out) const; + bool get_label_substitution(const QVariant &v, QString *out) const; SliderLabel *label_; @@ -112,13 +112,13 @@ private: QVector> label_substitutions_; private slots: - void LineEditConfirmed(); + void line_edit_confirmed(); - void LineEditCancelled(); + void line_edit_cancelled(); - void ResetValue(); + void reset_value(); }; } -#endif // SLIDERBASE_H +#endif // OAK_SLIDERBASE_H diff --git a/app/widget/slider/base/sliderlabel.cpp b/app/widget/slider/base/sliderlabel.cpp index d261af337..c0931ed6b 100644 --- a/app/widget/slider/base/sliderlabel.cpp +++ b/app/widget/slider/base/sliderlabel.cpp @@ -54,7 +54,7 @@ SliderLabel::SliderLabel(QWidget *parent) setContextMenuPolicy(Qt::CustomContextMenu); } -void SliderLabel::SetColor(const QColor &c) +void SliderLabel::set_color(const QColor &c) { // Prevent infinite loop in changeEvent when we set the stylesheet override_color_enabled_ = false; @@ -78,9 +78,9 @@ void SliderLabel::mousePressEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { if (e->modifiers() & Qt::AltModifier) { - emit RequestReset(); + emit request_reset(); } else { - emit LabelPressed(); + emit label_pressed(); } } } @@ -89,7 +89,7 @@ void SliderLabel::mouseReleaseEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { if (!(e->modifiers() & Qt::AltModifier)) { - emit LabelReleased(); + emit label_released(); } } } @@ -108,7 +108,7 @@ void SliderLabel::changeEvent(QEvent *event) QWidget::changeEvent(event); if (override_color_enabled_ && event->type() == QEvent::StyleChange) { - SetColor(override_color_); + set_color(override_color_); } } diff --git a/app/widget/slider/base/sliderlabel.h b/app/widget/slider/base/sliderlabel.h index 6ea2f5615..7bf4399b6 100644 --- a/app/widget/slider/base/sliderlabel.h +++ b/app/widget/slider/base/sliderlabel.h @@ -19,8 +19,8 @@ ***/ -#ifndef SLIDERLABEL_H -#define SLIDERLABEL_H +#ifndef OAK_SLIDERLABEL_H +#define OAK_SLIDERLABEL_H #include @@ -34,7 +34,7 @@ class SliderLabel : public QLabel { public: SliderLabel(QWidget *parent); - void SetColor(const QColor &c); + void set_color(const QColor &c); protected: virtual void mousePressEvent(QMouseEvent *e) override; @@ -46,15 +46,15 @@ protected: virtual void changeEvent(QEvent *event) override; signals: - void LabelPressed(); + void label_pressed(); - void LabelReleased(); + void label_released(); void focused(); - void RequestReset(); + void request_reset(); - void ChangeSliderType(); + void change_slider_type(); private: bool override_color_enabled_; @@ -63,4 +63,4 @@ private: } -#endif // SLIDERLABEL_H +#endif // OAK_SLIDERLABEL_H diff --git a/app/widget/slider/base/sliderladder.cpp b/app/widget/slider/base/sliderladder.cpp index 8b393a8c1..244d57152 100644 --- a/app/widget/slider/base/sliderladder.cpp +++ b/app/widget/slider/base/sliderladder.cpp @@ -50,7 +50,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values, setFrameShape(QFrame::Box); setLineWidth(1); - if (!OLIVE_CONFIG("UseSliderLadders").toBool()) { + if (!OAK_CONFIG("UseSliderLadders").toBool()) { nb_outer_values = 0; } @@ -63,7 +63,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values, SliderLadderElement *start_element = new SliderLadderElement(drag_multiplier, width_hint); active_element_ = elements_.size(); - start_element->SetHighlighted(true); + start_element->set_highlighted(true); elements_.append(start_element); for (int i = 0; i < nb_outer_values; i++) { @@ -76,11 +76,11 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values, } if (elements_.size() == 1) { - elements_.first()->SetMultiplierVisible(false); + elements_.first()->set_multiplier_visible(false); } drag_timer_.setInterval(10); - connect(&drag_timer_, &QTimer::timeout, this, &SliderLadder::TimerUpdate); + connect(&drag_timer_, &QTimer::timeout, this, &SliderLadder::timer_update); screen_ = nullptr; foreach (QScreen *screen, qApp->screens()) { @@ -90,7 +90,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values, } } - if (UsingLadders()) { + if (using_ladders()) { drag_start_x_ = -1; wrap_count_ = 0; } else { @@ -110,7 +110,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values, SliderLadder::~SliderLadder() { - if (UsingLadders()) { + if (using_ladders()) { if (wrap_count_ != 0) { // If wrapped, restore cursor to ladder QCursor::setPos(pos() + rect().center()); @@ -126,14 +126,14 @@ SliderLadder::~SliderLadder() } } -void SliderLadder::SetValue(const QString &s) +void SliderLadder::set_value(const QString &s) { foreach (SliderLadderElement *e, elements_) { - e->SetValue(s); + e->set_value(s); } } -void SliderLadder::StartListeningToMouseInput() +void SliderLadder::start_listening_to_mouse_input() { QMetaObject::invokeMethod(&drag_timer_, "start", Qt::QueuedConnection); } @@ -151,18 +151,18 @@ void SliderLadder::closeEvent(QCloseEvent *event) drag_timer_.stop(); - emit Released(); + emit released(); QFrame::closeEvent(event); } -void SliderLadder::TimerUpdate() +void SliderLadder::timer_update() { int ladder_left = this->x(); int ladder_right = this->x() + this->width() - 1; int now_pos = QCursor::pos().x(); - if (UsingLadders()) { + if (using_ladders()) { bool is_under_mouse = (now_pos >= ladder_left && now_pos <= ladder_right && wrap_count_ == 0); @@ -180,8 +180,8 @@ void SliderLadder::TimerUpdate() } int makeup_value = anchor - drag_start_x_; - emit DraggedByValue(makeup_value, - elements_.at(active_element_)->GetMultiplier()); + emit dragged_by_value(makeup_value, + elements_.at(active_element_)->get_multiplier()); drag_start_x_ = -1; } @@ -191,9 +191,9 @@ void SliderLadder::TimerUpdate() for (int i = 0; i < elements_.size(); i++) { if (elements_.at(i)->underMouse()) { if (i != active_element_) { - elements_.at(active_element_)->SetHighlighted(false); + elements_.at(active_element_)->set_highlighted(false); active_element_ = i; - elements_.at(active_element_)->SetHighlighted(true); + elements_.at(active_element_)->set_highlighted(true); } break; @@ -210,8 +210,8 @@ void SliderLadder::TimerUpdate() } } - emit DraggedByValue(now_pos - drag_start_x_, - elements_.at(active_element_)->GetMultiplier()); + emit dragged_by_value(now_pos - drag_start_x_, + elements_.at(active_element_)->get_multiplier()); // Determine if cursor is at desktop edge, if so wrap around to other side if (screen_) { @@ -268,12 +268,12 @@ void SliderLadder::TimerUpdate() multiplier *= 100.0; } - emit DraggedByValue(x_mvmt + y_mvmt, multiplier); + emit dragged_by_value(x_mvmt + y_mvmt, multiplier); } } } -bool SliderLadder::UsingLadders() const +bool SliderLadder::using_ladders() const { return elements_.size() > 1; } @@ -290,7 +290,7 @@ SliderLadderElement::SliderLadderElement(const double &multiplier, label_ = new QLabel(); label_->setAlignment(Qt::AlignCenter); label_->setFixedWidth( - QtUtils::QFontMetricsWidth(label_->fontMetrics(), width_hint)); + QtUtils::q_font_metrics_width(label_->fontMetrics(), width_hint)); layout->addWidget(label_); QPalette p = palette(); @@ -301,10 +301,10 @@ SliderLadderElement::SliderLadderElement(const double &multiplier, setAutoFillBackground(true); - UpdateLabel(); + update_label(); } -void SliderLadderElement::SetHighlighted(bool e) +void SliderLadderElement::set_highlighted(bool e) { highlighted_ = e; @@ -314,24 +314,24 @@ void SliderLadderElement::SetHighlighted(bool e) setBackgroundRole(QPalette::Window); } - UpdateLabel(); + update_label(); } -void SliderLadderElement::SetValue(const QString &value) +void SliderLadderElement::set_value(const QString &value) { value_ = value; - UpdateLabel(); + update_label(); } -void SliderLadderElement::SetMultiplierVisible(bool e) +void SliderLadderElement::set_multiplier_visible(bool e) { multiplier_visible_ = e; - UpdateLabel(); + update_label(); } -void SliderLadderElement::UpdateLabel() +void SliderLadderElement::update_label() { if (multiplier_visible_) { QString val_text; diff --git a/app/widget/slider/base/sliderladder.h b/app/widget/slider/base/sliderladder.h index df7e201df..01e220279 100644 --- a/app/widget/slider/base/sliderladder.h +++ b/app/widget/slider/base/sliderladder.h @@ -19,8 +19,8 @@ ***/ -#ifndef SLIDERLADDER_H -#define SLIDERLADDER_H +#ifndef OAK_SLIDERLADDER_H +#define OAK_SLIDERLADDER_H #include #include @@ -37,19 +37,19 @@ public: SliderLadderElement(const double &multiplier, QString width_hint, QWidget *parent = nullptr); - void SetHighlighted(bool e); + void set_highlighted(bool e); - void SetValue(const QString &value); + void set_value(const QString &value); - void SetMultiplierVisible(bool e); + void set_multiplier_visible(bool e); - double GetMultiplier() const + double get_multiplier() const { return multiplier_; } private: - void UpdateLabel(); + void update_label(); QLabel *label_; @@ -69,9 +69,9 @@ public: virtual ~SliderLadder() override; - void SetValue(const QString &s); + void set_value(const QString &s); - void StartListeningToMouseInput(); + void start_listening_to_mouse_input(); protected: virtual void mouseReleaseEvent(QMouseEvent *event) override; @@ -79,12 +79,12 @@ protected: virtual void closeEvent(QCloseEvent *event) override; signals: - void DraggedByValue(int value, double multiplier); + void dragged_by_value(int value, double multiplier); - void Released(); + void released(); private: - bool UsingLadders() const; + bool using_ladders() const; int drag_start_x_; int drag_start_y_; @@ -99,9 +99,9 @@ private: QScreen *screen_; private slots: - void TimerUpdate(); + void timer_update(); }; } -#endif // SLIDERLADDER_H +#endif // OAK_SLIDERLADDER_H diff --git a/app/widget/slider/floatslider.cpp b/app/widget/slider/floatslider.cpp index f219ea959..909932d80 100644 --- a/app/widget/slider/floatslider.cpp +++ b/app/widget/slider/floatslider.cpp @@ -33,62 +33,62 @@ namespace olive FloatSlider::FloatSlider(QWidget *parent) : super(parent) - , display_type_(kNormal) + , display_type_(k_normal) { - SetValue(0.0); + set_value(0.0); } -double FloatSlider::GetValue() const +double FloatSlider::get_value() const { - return GetValueInternal().toDouble(); + return get_value_internal().toDouble(); } -void FloatSlider::SetValue(const double &d) +void FloatSlider::set_value(const double &d) { - SetValueInternal(d); + set_value_internal(d); } void FloatSlider::SetDefaultValue(const double &d) { - super::SetDefaultValue(d); + super::set_default_value(d); } -void FloatSlider::SetMinimum(const double &d) +void FloatSlider::set_minimum(const double &d) { - SetMinimumInternal(d); + set_minimum_internal(d); } -void FloatSlider::SetMaximum(const double &d) +void FloatSlider::set_maximum(const double &d) { - SetMaximumInternal(d); + set_maximum_internal(d); } -void FloatSlider::SetDisplayType(const FloatSlider::DisplayType &type) +void FloatSlider::set_display_type(const FloatSlider::DisplayType &type) { display_type_ = type; switch (display_type_) { - case kNormal: - ClearFormat(); + case k_normal: + clear_format(); break; - case kDecibel: - SetFormat(tr("%1 dB")); + case k_decibel: + set_format(tr("%1 dB")); break; - case kPercentage: - SetFormat(tr("%1%")); + case k_percentage: + set_format(tr("%1%")); break; } } -double FloatSlider::TransformValueToDisplay(double val, DisplayType display) +double FloatSlider::transform_value_to_display(double val, DisplayType display) { switch (display) { - case kNormal: + case k_normal: break; - case kDecibel: - val = Decibel::fromLinear(val); + case k_decibel: + val = Decibel::from_linear(val); break; - case kPercentage: + case k_percentage: val *= 100.0; break; } @@ -96,15 +96,15 @@ double FloatSlider::TransformValueToDisplay(double val, DisplayType display) return val; } -double FloatSlider::TransformDisplayToValue(double val, DisplayType display) +double FloatSlider::transform_display_to_value(double val, DisplayType display) { switch (display) { - case kNormal: + case k_normal: break; - case kDecibel: - val = Decibel::toLinear(val); + case k_decibel: + val = Decibel::to_linear(val); break; - case kPercentage: + case k_percentage: val *= 0.01; break; } @@ -112,26 +112,26 @@ double FloatSlider::TransformDisplayToValue(double val, DisplayType display) return val; } -QString FloatSlider::ValueToString(double val, FloatSlider::DisplayType display, +QString FloatSlider::value_to_string(double val, FloatSlider::DisplayType display, int decimal_places, bool autotrim_decimal_places) { // Return negative infinity for zero volume - if (display == kDecibel && qIsNull(val)) { + if (display == k_decibel && qIsNull(val)) { return tr("\xE2\x88\x9E"); } - return FloatToString(TransformValueToDisplay(val, display), decimal_places, + return float_to_string(transform_value_to_display(val, display), decimal_places, autotrim_decimal_places); } -QString FloatSlider::ValueToString(const QVariant &v) const +QString FloatSlider::value_to_string(const QVariant &v) const { - return ValueToString(v.toDouble() + GetOffset().toDouble(), display_type_, - GetDecimalPlaces(), GetAutoTrimDecimalPlaces()); + return value_to_string(v.toDouble() + get_offset().toDouble(), display_type_, + get_decimal_places(), get_auto_trim_decimal_places()); } -QVariant FloatSlider::StringToValue(const QString &s, bool *ok) const +QVariant FloatSlider::string_to_value(const QString &s, bool *ok) const { bool valid; double val = s.toDouble(&valid); @@ -143,37 +143,37 @@ QVariant FloatSlider::StringToValue(const QString &s, bool *ok) const // If valid, transform it from display if (valid) { - val = TransformDisplayToValue(val, display_type_); + val = transform_display_to_value(val, display_type_); } // Return un-offset value - return val - GetOffset().toDouble(); + return val - get_offset().toDouble(); } -QVariant FloatSlider::AdjustDragDistanceInternal(const QVariant &start, +QVariant FloatSlider::adjust_drag_distance_internal(const QVariant &start, const double &drag) const { switch (display_type_) { - case kNormal: + case k_normal: // No change here break; - case kDecibel: { - double current_db = Decibel::fromLinear(start.toDouble()); + case k_decibel: { + double current_db = Decibel::from_linear(start.toDouble()); current_db += drag; - double adjusted_linear = Decibel::toLinear(current_db); + double adjusted_linear = Decibel::to_linear(current_db); return adjusted_linear; } - case kPercentage: - return super::AdjustDragDistanceInternal(start, drag * 0.01); + case k_percentage: + return super::adjust_drag_distance_internal(start, drag * 0.01); } - return super::AdjustDragDistanceInternal(start, drag); + return super::adjust_drag_distance_internal(start, drag); } -void FloatSlider::ValueSignalEvent(const QVariant &value) +void FloatSlider::value_signal_event(const QVariant &value) { - emit ValueChanged(value.toDouble()); + emit value_changed(value.toDouble()); } } diff --git a/app/widget/slider/floatslider.h b/app/widget/slider/floatslider.h index cc00f633a..3b8b7f13e 100644 --- a/app/widget/slider/floatslider.h +++ b/app/widget/slider/floatslider.h @@ -19,8 +19,8 @@ ***/ -#ifndef FLOATSLIDER_H -#define FLOATSLIDER_H +#ifndef OAK_FLOATSLIDER_H +#define OAK_FLOATSLIDER_H #include "base/decimalsliderbase.h" @@ -32,41 +32,41 @@ class FloatSlider : public DecimalSliderBase { public: FloatSlider(QWidget *parent = nullptr); - enum DisplayType { kNormal, kDecibel, kPercentage }; + enum DisplayType { k_normal, k_decibel, k_percentage }; - double GetValue() const; + double get_value() const; - void SetValue(const double &d); + void set_value(const double &d); void SetDefaultValue(const double &d); - void SetMinimum(const double &d); + void set_minimum(const double &d); - void SetMaximum(const double &d); + void set_maximum(const double &d); - void SetDisplayType(const DisplayType &type); + void set_display_type(const DisplayType &type); - static double TransformValueToDisplay(double val, DisplayType display); + static double transform_value_to_display(double val, DisplayType display); - static double TransformDisplayToValue(double val, DisplayType display); + static double transform_display_to_value(double val, DisplayType display); - static QString ValueToString(double val, DisplayType display, + static QString value_to_string(double val, DisplayType display, int decimal_places, bool autotrim_decimal_places); protected: - virtual QString ValueToString(const QVariant &v) const override; + virtual QString value_to_string(const QVariant &v) const override; - virtual QVariant StringToValue(const QString &s, bool *ok) const override; + virtual QVariant string_to_value(const QString &s, bool *ok) const override; virtual QVariant - AdjustDragDistanceInternal(const QVariant &start, + adjust_drag_distance_internal(const QVariant &start, const double &drag) const override; - virtual void ValueSignalEvent(const QVariant &value) override; + virtual void value_signal_event(const QVariant &value) override; signals: - void ValueChanged(double); + void value_changed(double); private: DisplayType display_type_; @@ -74,4 +74,4 @@ private: } -#endif // FLOATSLIDER_H +#endif // OAK_FLOATSLIDER_H diff --git a/app/widget/slider/integerslider.cpp b/app/widget/slider/integerslider.cpp index 6f8e3ea6f..8607fdf88 100644 --- a/app/widget/slider/integerslider.cpp +++ b/app/widget/slider/integerslider.cpp @@ -29,40 +29,40 @@ namespace olive IntegerSlider::IntegerSlider(QWidget *parent) : super(parent) { - SetValue(0); + set_value(0); } -int64_t IntegerSlider::GetValue() +int64_t IntegerSlider::get_value() { - return GetValueInternal().toLongLong(); + return get_value_internal().toLongLong(); } -void IntegerSlider::SetValue(const int64_t &v) +void IntegerSlider::set_value(const int64_t &v) { - SetValueInternal(QVariant::fromValue(v)); + set_value_internal(QVariant::fromValue(v)); } -void IntegerSlider::SetMinimum(const int64_t &d) +void IntegerSlider::set_minimum(const int64_t &d) { - SetMinimumInternal(QVariant::fromValue(d)); + set_minimum_internal(QVariant::fromValue(d)); } -void IntegerSlider::SetMaximum(const int64_t &d) +void IntegerSlider::set_maximum(const int64_t &d) { - SetMaximumInternal(QVariant::fromValue(d)); + set_maximum_internal(QVariant::fromValue(d)); } void IntegerSlider::SetDefaultValue(const int64_t &d) { - super::SetDefaultValue(QVariant::fromValue(d)); + super::set_default_value(QVariant::fromValue(d)); } -QString IntegerSlider::ValueToString(const QVariant &v) const +QString IntegerSlider::value_to_string(const QVariant &v) const { - return QString::number(v.toLongLong() + GetOffset().toLongLong()); + return QString::number(v.toLongLong() + get_offset().toLongLong()); } -QVariant IntegerSlider::StringToValue(const QString &s, bool *ok) const +QVariant IntegerSlider::string_to_value(const QString &s, bool *ok) const { bool valid; @@ -73,7 +73,7 @@ QVariant IntegerSlider::StringToValue(const QString &s, bool *ok) const *ok = valid; } - decimal_val -= GetOffset().toLongLong(); + decimal_val -= get_offset().toLongLong(); if (valid) { // But for an integer, we round it @@ -83,15 +83,15 @@ QVariant IntegerSlider::StringToValue(const QString &s, bool *ok) const return QVariant(); } -void IntegerSlider::ValueSignalEvent(const QVariant &value) +void IntegerSlider::value_signal_event(const QVariant &value) { - emit ValueChanged(value.toInt()); + emit value_changed(value.toInt()); } -QVariant IntegerSlider::AdjustDragDistanceInternal(const QVariant &start, +QVariant IntegerSlider::adjust_drag_distance_internal(const QVariant &start, const double &drag) const { - return qRound64(super::AdjustDragDistanceInternal(start, drag).toDouble()); + return qRound64(super::adjust_drag_distance_internal(start, drag).toDouble()); } } diff --git a/app/widget/slider/integerslider.h b/app/widget/slider/integerslider.h index fe18ff924..578aa7866 100644 --- a/app/widget/slider/integerslider.h +++ b/app/widget/slider/integerslider.h @@ -19,8 +19,8 @@ ***/ -#ifndef INTEGERSLIDER_H -#define INTEGERSLIDER_H +#ifndef OAK_INTEGERSLIDER_H +#define OAK_INTEGERSLIDER_H #include "base/numericsliderbase.h" @@ -32,31 +32,31 @@ class IntegerSlider : public NumericSliderBase { public: IntegerSlider(QWidget *parent = nullptr); - int64_t GetValue(); + int64_t get_value(); - void SetValue(const int64_t &v); + void set_value(const int64_t &v); - void SetMinimum(const int64_t &d); + void set_minimum(const int64_t &d); - void SetMaximum(const int64_t &d); + void set_maximum(const int64_t &d); void SetDefaultValue(const int64_t &d); protected: - virtual QString ValueToString(const QVariant &v) const override; + virtual QString value_to_string(const QVariant &v) const override; - virtual QVariant StringToValue(const QString &s, bool *ok) const override; + virtual QVariant string_to_value(const QString &s, bool *ok) const override; - virtual void ValueSignalEvent(const QVariant &value) override; + virtual void value_signal_event(const QVariant &value) override; virtual QVariant - AdjustDragDistanceInternal(const QVariant &start, + adjust_drag_distance_internal(const QVariant &start, const double &drag) const override; signals: - void ValueChanged(int64_t); + void value_changed(int64_t); }; } -#endif // INTEGERSLIDER_H +#endif // OAK_INTEGERSLIDER_H diff --git a/app/widget/slider/rationalslider.cpp b/app/widget/slider/rationalslider.cpp index 6aaa2289d..b4e1ef11d 100644 --- a/app/widget/slider/rationalslider.cpp +++ b/app/widget/slider/rationalslider.cpp @@ -34,200 +34,200 @@ RationalSlider::RationalSlider(QWidget *parent) : super(parent) , lock_display_type_(false) { - connect(Core::instance(), &Core::TimecodeDisplayChanged, this, - &RationalSlider::UpdateLabel); + connect(Core::instance(), &Core::timecode_display_changed, this, + &RationalSlider::update_label); connect(SliderBase::label(), &SliderLabel::customContextMenuRequested, this, - &RationalSlider::ShowDisplayTypeMenu); + &RationalSlider::show_display_type_menu); - SetDisplayType(kFloat); + set_display_type(k_float); - SetValue(rational(0, 0)); + set_value(Rational(0, 0)); } -rational RationalSlider::GetValue() +Rational RationalSlider::get_value() { - return GetValueInternal().value(); + return get_value_internal().value(); } -void RationalSlider::SetValue(const rational &d) +void RationalSlider::set_value(const Rational &d) { - SetValueInternal(QVariant::fromValue(d)); + set_value_internal(QVariant::fromValue(d)); } -void RationalSlider::SetDefaultValue(const rational &r) +void RationalSlider::SetDefaultValue(const Rational &r) { - super::SetDefaultValue(QVariant::fromValue(r)); + super::set_default_value(QVariant::fromValue(r)); } -void RationalSlider::SetMinimum(const rational &d) +void RationalSlider::set_minimum(const Rational &d) { - SetMinimumInternal(QVariant::fromValue(d)); + set_minimum_internal(QVariant::fromValue(d)); } -void RationalSlider::SetMaximum(const rational &d) +void RationalSlider::set_maximum(const Rational &d) { - SetMaximumInternal(QVariant::fromValue(d)); + set_maximum_internal(QVariant::fromValue(d)); } -void RationalSlider::SetTimebase(const rational &timebase) +void RationalSlider::set_timebase(const Rational &timebase) { timebase_ = timebase; // Refresh label since we have a new timebase to generate a timecode with - UpdateLabel(); + update_label(); } -void RationalSlider::SetDisplayType(const RationalSlider::DisplayType &type) +void RationalSlider::set_display_type(const RationalSlider::DisplayType &type) { display_type_ = type; - UpdateLabel(); + update_label(); } -void RationalSlider::SetLockDisplayType(bool e) +void RationalSlider::set_lock_display_type(bool e) { lock_display_type_ = e; } -bool RationalSlider::GetLockDisplayType() +bool RationalSlider::get_lock_display_type() { return lock_display_type_; } -void RationalSlider::DisableDisplayType(RationalSlider::DisplayType type) +void RationalSlider::disable_display_type(RationalSlider::DisplayType type) { disabled_.append(type); } -QString RationalSlider::ValueToString(const QVariant &v) const +QString RationalSlider::value_to_string(const QVariant &v) const { - rational r = v.value(); + Rational r = v.value(); if (r.isNaN()) { return tr("NaN"); } else { - double val = r.toDouble() + GetOffset().value().toDouble(); + double val = r.to_double() + get_offset().value().to_double(); switch (display_type_) { - case kTime: + case k_time: return QString::fromStdString(Timecode::time_to_timecode( - r, timebase_, Core::instance()->GetTimecodeDisplay())); - case kFloat: - return FloatToString(val, GetDecimalPlaces(), - GetAutoTrimDecimalPlaces()); - case kRational: - return QString::fromStdString(v.value().toString()); + r, timebase_, Core::instance()->get_timecode_display())); + case k_float: + return float_to_string(val, get_decimal_places(), + get_auto_trim_decimal_places()); + case k_rational: + return QString::fromStdString(v.value().to_string()); } return v.toString(); } } -QVariant RationalSlider::StringToValue(const QString &s, bool *ok) const +QVariant RationalSlider::string_to_value(const QString &s, bool *ok) const { - rational r; + Rational r; *ok = false; switch (display_type_) { - case kTime: { + case k_time: { r = Timecode::timecode_to_time(s.toStdString(), timebase_, - Core::instance()->GetTimecodeDisplay(), + Core::instance()->get_timecode_display(), ok); break; } - case kFloat: { + case k_float: { // First, convert to a double double d = s.toDouble(ok); if (!(*ok)) { break; } - // If double conversion succeeded, convert to a rational - r = rational::fromDouble(d, ok); + // If double conversion succeeded, convert to a Rational + r = Rational::from_double(d, ok); break; } - case kRational: - r = rational::fromString(s.toStdString(), ok); + case k_rational: + r = Rational::from_string(s.toStdString(), ok); break; } - //return QVariant::fromValue(r - GetOffset().value()); + //return QVariant::fromValue(r - GetOffset().value()); return QVariant::fromValue(r); } -QVariant RationalSlider::AdjustDragDistanceInternal(const QVariant &start, +QVariant RationalSlider::adjust_drag_distance_internal(const QVariant &start, const double &drag) const { // Assume we want smallest increment to be timebase or 1 frame - return QVariant::fromValue(start.value() + - rational::fromDouble(drag) * timebase_); + return QVariant::fromValue(start.value() + + Rational::from_double(drag) * timebase_); } -void RationalSlider::ValueSignalEvent(const QVariant &v) +void RationalSlider::value_signal_event(const QVariant &v) { - emit ValueChanged(v.value()); + emit value_changed(v.value()); } -bool RationalSlider::ValueGreaterThan(const QVariant &lhs, +bool RationalSlider::value_greater_than(const QVariant &lhs, const QVariant &rhs) const { - return lhs.value() > rhs.value(); + return lhs.value() > rhs.value(); } -bool RationalSlider::ValueLessThan(const QVariant &lhs, +bool RationalSlider::value_less_than(const QVariant &lhs, const QVariant &rhs) const { - return lhs.value() < rhs.value(); + return lhs.value() < rhs.value(); } -void RationalSlider::ShowDisplayTypeMenu() +void RationalSlider::show_display_type_menu() { Menu m(this); - if (!GetLockDisplayType()) { - if (!disabled_.contains(kFloat)) { + if (!get_lock_display_type()) { + if (!disabled_.contains(k_float)) { QAction *float_action = m.addAction(tr("Float")); - float_action->setData(kFloat); + float_action->setData(k_float); connect(float_action, &QAction::triggered, this, - &RationalSlider::SetDisplayTypeFromMenu); + &RationalSlider::set_display_type_from_menu); } - if (!disabled_.contains(kRational)) { + if (!disabled_.contains(k_rational)) { QAction *rational_action = m.addAction(tr("Rational")); - rational_action->setData(kRational); + rational_action->setData(k_rational); connect(rational_action, &QAction::triggered, this, - &RationalSlider::SetDisplayTypeFromMenu); + &RationalSlider::set_display_type_from_menu); } - if (!disabled_.contains(kTime)) { + if (!disabled_.contains(k_time)) { QAction *time_action = m.addAction(tr("Time")); - time_action->setData(kTime); + time_action->setData(k_time); connect(time_action, &QAction::triggered, this, - &RationalSlider::SetDisplayTypeFromMenu); + &RationalSlider::set_display_type_from_menu); } } - if (display_type_ == kTime) { + if (display_type_ == k_time) { if (!m.actions().isEmpty()) { m.addSeparator(); } - MenuShared::instance()->AddItemsForTimeRulerMenu(&m); - MenuShared::instance()->AboutToShowTimeRulerActions(timebase_); + MenuShared::instance()->add_items_for_time_ruler_menu(&m); + MenuShared::instance()->about_to_show_time_ruler_actions(timebase_); } if (!m.actions().isEmpty()) { m.exec(QCursor::pos()); - UpdateLabel(); + update_label(); } } -void RationalSlider::SetDisplayTypeFromMenu() +void RationalSlider::set_display_type_from_menu() { QAction *action = static_cast(sender()); DisplayType type = static_cast(action->data().toInt()); - SetDisplayType(type); + set_display_type(type); } } diff --git a/app/widget/slider/rationalslider.h b/app/widget/slider/rationalslider.h index a42a1ea71..3eb305e9f 100644 --- a/app/widget/slider/rationalslider.h +++ b/app/widget/slider/rationalslider.h @@ -19,8 +19,8 @@ ***/ -#ifndef RATIONALSLIDER_H -#define RATIONALSLIDER_H +#ifndef OAK_RATIONALSLIDER_H +#define OAK_RATIONALSLIDER_H #include #include @@ -33,7 +33,7 @@ namespace olive using namespace core; /** - * @brief A olive::rational based slider + * @brief A olive::Rational based slider * * A slider that can display rationals as either timecode (drop or non-drop), a timestamp (frames), * or a float (seconds). @@ -44,90 +44,90 @@ public: /** * @brief enum containing the possibly display types */ - enum DisplayType { kTime, kFloat, kRational }; + enum DisplayType { k_time, k_float, k_rational }; RationalSlider(QWidget *parent = nullptr); /** - * @brief Returns the sliders value as a rational + * @brief Returns the sliders value as a Rational */ - rational GetValue(); + Rational get_value(); /** * @brief Sets the sliders default value */ - void SetDefaultValue(const rational &r); + void SetDefaultValue(const Rational &r); /** * @brief Sets the sliders minimum value */ - void SetMinimum(const rational &d); + void set_minimum(const Rational &d); /** * @brief Sets the sliders maximum value */ - void SetMaximum(const rational &d); + void set_maximum(const Rational &d); /** * @brief Sets the display type of the slider */ - void SetDisplayType(const DisplayType &type); + void set_display_type(const DisplayType &type); /** * @brief Set whether the user can change the display type or not */ - void SetLockDisplayType(bool e); + void set_lock_display_type(bool e); /** * @brief Get whether the user can change the display type or not */ - bool GetLockDisplayType(); + bool get_lock_display_type(); /** * @brief Hide display type in menu */ - void DisableDisplayType(DisplayType type); + void disable_display_type(DisplayType type); public slots: /** * @brief Sets the sliders timebase which is also the minimum increment of the slider */ - void SetTimebase(const rational &timebase); + void set_timebase(const Rational &timebase); /** * @brief Sets the sliders value */ - void SetValue(const rational &d); + void set_value(const Rational &d); protected: - virtual QString ValueToString(const QVariant &v) const override; + virtual QString value_to_string(const QVariant &v) const override; - virtual QVariant StringToValue(const QString &s, bool *ok) const override; + virtual QVariant string_to_value(const QString &s, bool *ok) const override; virtual QVariant - AdjustDragDistanceInternal(const QVariant &start, + adjust_drag_distance_internal(const QVariant &start, const double &drag) const override; - virtual void ValueSignalEvent(const QVariant &v) override; + virtual void value_signal_event(const QVariant &v) override; - virtual bool ValueGreaterThan(const QVariant &lhs, + virtual bool value_greater_than(const QVariant &lhs, const QVariant &rhs) const override; - virtual bool ValueLessThan(const QVariant &lhs, + virtual bool value_less_than(const QVariant &lhs, const QVariant &rhs) const override; signals: - void ValueChanged(rational); + void value_changed(Rational); private slots: - void ShowDisplayTypeMenu(); + void show_display_type_menu(); - void SetDisplayTypeFromMenu(); + void set_display_type_from_menu(); private: DisplayType display_type_; - rational timebase_; + Rational timebase_; bool lock_display_type_; @@ -136,4 +136,4 @@ private: } -#endif // RATIONALSLIDER_H +#endif // OAK_RATIONALSLIDER_H diff --git a/app/widget/slider/stringslider.cpp b/app/widget/slider/stringslider.cpp index 8771a7bf7..55c34a6fa 100644 --- a/app/widget/slider/stringslider.cpp +++ b/app/widget/slider/stringslider.cpp @@ -29,42 +29,42 @@ namespace olive StringSlider::StringSlider(QWidget *parent) : super(parent) { - SetValue(QString()); + set_value(QString()); - connect(label(), &SliderLabel::LabelReleased, this, - &SliderBase::ShowEditor); + connect(label(), &SliderLabel::label_released, this, + &SliderBase::show_editor); } -QString StringSlider::GetValue() const +QString StringSlider::get_value() const { - return GetValueInternal().toString(); + return get_value_internal().toString(); } -void StringSlider::SetValue(const QString &v) +void StringSlider::set_value(const QString &v) { - SetValueInternal(v); + set_value_internal(v); } void StringSlider::SetDefaultValue(const QString &v) { - super::SetDefaultValue(v); + super::set_default_value(v); } -QString StringSlider::ValueToString(const QVariant &v) const +QString StringSlider::value_to_string(const QVariant &v) const { QString vstr = v.toString(); return (vstr.isEmpty()) ? tr("(none)") : vstr; } -QVariant StringSlider::StringToValue(const QString &s, bool *ok) const +QVariant StringSlider::string_to_value(const QString &s, bool *ok) const { *ok = true; return s; } -void StringSlider::ValueSignalEvent(const QVariant &value) +void StringSlider::value_signal_event(const QVariant &value) { - emit ValueChanged(value.toString()); + emit value_changed(value.toString()); } } diff --git a/app/widget/slider/stringslider.h b/app/widget/slider/stringslider.h index 0a481680d..8be59b0d1 100644 --- a/app/widget/slider/stringslider.h +++ b/app/widget/slider/stringslider.h @@ -19,8 +19,8 @@ ***/ -#ifndef STRINGSLIDER_H -#define STRINGSLIDER_H +#ifndef OAK_STRINGSLIDER_H +#define OAK_STRINGSLIDER_H #include "base/sliderbase.h" @@ -34,23 +34,23 @@ public: void SetDragMultiplier(const double &d) = delete; - QString GetValue() const; + QString get_value() const; - void SetValue(const QString &v); + void set_value(const QString &v); void SetDefaultValue(const QString &v); signals: - void ValueChanged(const QString &str); + void value_changed(const QString &str); protected: - virtual QString ValueToString(const QVariant &value) const override; + virtual QString value_to_string(const QVariant &value) const override; - virtual QVariant StringToValue(const QString &s, bool *ok) const override; + virtual QVariant string_to_value(const QString &s, bool *ok) const override; - virtual void ValueSignalEvent(const QVariant &value) override; + virtual void value_signal_event(const QVariant &value) override; }; } -#endif // STRINGSLIDER_H +#endif // OAK_STRINGSLIDER_H diff --git a/app/widget/standardcombos/channellayoutcombobox.h b/app/widget/standardcombos/channellayoutcombobox.h index 6e9fcc1e0..9e4efe2e0 100644 --- a/app/widget/standardcombos/channellayoutcombobox.h +++ b/app/widget/standardcombos/channellayoutcombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef CHANNELLAYOUTCOMBOBOX_H -#define CHANNELLAYOUTCOMBOBOX_H +#ifndef OAK_CHANNELLAYOUTCOMBOBOX_H +#define OAK_CHANNELLAYOUTCOMBOBOX_H #include #include @@ -38,16 +38,16 @@ public: : QComboBox(parent) { foreach (const uint64_t &ch_layout, - AudioParams::kSupportedChannelLayouts) { - this->addItem(HumanStrings::ChannelLayoutToString(ch_layout), + AudioParams::k_supported_channel_layouts) { + this->addItem(HumanStrings::channel_layout_to_string(ch_layout), QVariant::fromValue(ch_layout)); } } - [[nodiscard]] uint64_t GetChannelLayout() const + [[nodiscard]] uint64_t get_channel_layout() const { return this->currentData().toULongLong(); } - void SetChannelLayout(uint64_t ch) + void set_channel_layout(uint64_t ch) { for (int i = 0; i < this->count(); i++) { if (this->itemData(i).toULongLong() == ch) { @@ -62,4 +62,4 @@ private: } -#endif // CHANNELLAYOUTCOMBOBOX_H +#endif // OAK_CHANNELLAYOUTCOMBOBOX_H diff --git a/app/widget/standardcombos/frameratecombobox.h b/app/widget/standardcombos/frameratecombobox.h index b38684817..1673394a3 100644 --- a/app/widget/standardcombos/frameratecombobox.h +++ b/app/widget/standardcombos/frameratecombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef FRAMERATECOMBOBOX_H -#define FRAMERATECOMBOBOX_H +#ifndef OAK_FRAMERATECOMBOBOX_H +#define OAK_FRAMERATECOMBOBOX_H #include #include @@ -46,33 +46,33 @@ public: layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(inner_); - RepopulateList(); + repopulate_list(); old_index_ = 0; connect(inner_, static_cast( &QComboBox::currentIndexChanged), - this, &FrameRateComboBox::IndexChanged); + this, &FrameRateComboBox::index_changed); } - rational GetFrameRate() const + Rational get_frame_rate() const { if (inner_->currentIndex() == inner_->count() - 1) { return custom_rate_; } else { - return inner_->currentData().value(); + return inner_->currentData().value(); } } - void SetFrameRate(const rational &r) + void set_frame_rate(const Rational &r) { int standard_rates = inner_->count() - 1; for (int i = 0; i < standard_rates; i++) { - if (inner_->itemData(i).value() == r) { + if (inner_->itemData(i).value() == r) { // Set standard frame rate old_index_ = i; - SetInnerIndexWithoutSignal(i); + set_inner_index_without_signal(i); return; } } @@ -80,12 +80,12 @@ public: // If we're here, set a custom rate custom_rate_ = r; old_index_ = inner_->count() - 1; - SetInnerIndexWithoutSignal(old_index_); - RepopulateList(); + set_inner_index_without_signal(old_index_); + repopulate_list(); } signals: - void FrameRateChanged(const rational &frame_rate); + void frame_rate_changed(const Rational &frame_rate); protected: virtual void changeEvent(QEvent *event) override @@ -93,12 +93,12 @@ protected: QWidget::changeEvent(event); if (event->type() == QEvent::LanguageChange) { - RepopulateList(); + repopulate_list(); } } private slots: - void IndexChanged(int index) + void index_changed(int index) { if (index == inner_->count() - 1) { // Custom @@ -106,7 +106,7 @@ private slots: bool ok; if (!custom_rate_.isNull()) { - s = QString::number(custom_rate_.toDouble()); + s = QString::number(custom_rate_.to_double()); } while (true) { @@ -115,24 +115,24 @@ private slots: QLineEdit::Normal, s, &ok); if (ok) { - rational r; + Rational r; // Try converting to double, assuming most users will input frame rates this way double d = s.toDouble(&ok); if (ok) { // Try converting from double - r = rational::fromDouble(d, &ok); + r = Rational::from_double(d, &ok); } else { - // Try converting to rational in case someone formatted that way - r = rational::fromString(s.toStdString(), &ok); + // Try converting to Rational in case someone formatted that way + r = Rational::from_string(s.toStdString(), &ok); } if (ok) { custom_rate_ = r; - emit FrameRateChanged(r); + emit frame_rate_changed(r); old_index_ = index; - RepopulateList(); + repopulate_list(); break; } else { @@ -145,18 +145,18 @@ private slots: } else { // User cancelled, revert to original value - SetInnerIndexWithoutSignal(old_index_); + set_inner_index_without_signal(old_index_); break; } } } else { old_index_ = index; - emit FrameRateChanged(GetFrameRate()); + emit frame_rate_changed(get_frame_rate()); } } private: - void RepopulateList() + void repopulate_list() { int temp_index = inner_->currentIndex(); @@ -164,8 +164,8 @@ private: inner_->clear(); - foreach (const rational &fr, VideoParams::kSupportedFrameRates) { - inner_->addItem(VideoParams::FrameRateToString(fr), + foreach (const Rational &fr, VideoParams::k_supported_frame_rates) { + inner_->addItem(VideoParams::frame_rate_to_string(fr), QVariant::fromValue(fr)); } @@ -174,7 +174,7 @@ private: } else { inner_->addItem( tr("Custom (%1)") - .arg(VideoParams::FrameRateToString(custom_rate_))); + .arg(VideoParams::frame_rate_to_string(custom_rate_))); } // On the first populate there is no current index (-1); select the @@ -184,7 +184,7 @@ private: inner_->blockSignals(false); } - void SetInnerIndexWithoutSignal(int index) + void set_inner_index_without_signal(int index) { inner_->blockSignals(true); inner_->setCurrentIndex(index); @@ -193,11 +193,11 @@ private: QComboBox *inner_; - rational custom_rate_; + Rational custom_rate_; int old_index_; }; } -#endif // FRAMERATECOMBOBOX_H +#endif // OAK_FRAMERATECOMBOBOX_H diff --git a/app/widget/standardcombos/interlacedcombobox.h b/app/widget/standardcombos/interlacedcombobox.h index e6c057a05..c40e02a30 100644 --- a/app/widget/standardcombos/interlacedcombobox.h +++ b/app/widget/standardcombos/interlacedcombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef INTERLACEDCOMBOBOX_H -#define INTERLACEDCOMBOBOX_H +#ifndef OAK_INTERLACEDCOMBOBOX_H +#define OAK_INTERLACEDCOMBOBOX_H #include @@ -41,12 +41,12 @@ public: this->addItem(tr("Bottom-Field First")); } - VideoParams::Interlacing GetInterlaceMode() const + VideoParams::Interlacing get_interlace_mode() const { return static_cast(this->currentIndex()); } - void SetInterlaceMode(VideoParams::Interlacing mode) + void set_interlace_mode(VideoParams::Interlacing mode) { this->setCurrentIndex(mode); } @@ -54,4 +54,4 @@ public: } -#endif // INTERLACEDCOMBOBOX_H +#endif // OAK_INTERLACEDCOMBOBOX_H diff --git a/app/widget/standardcombos/pixelaspectratiocombobox.h b/app/widget/standardcombos/pixelaspectratiocombobox.h index 8ee4f4854..7b8b03642 100644 --- a/app/widget/standardcombos/pixelaspectratiocombobox.h +++ b/app/widget/standardcombos/pixelaspectratiocombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef PIXELASPECTRATIOCOMBOBOX_H -#define PIXELASPECTRATIOCOMBOBOX_H +#ifndef OAK_PIXELASPECTRATIOCOMBOBOX_H +#define OAK_PIXELASPECTRATIOCOMBOBOX_H #include @@ -37,9 +37,9 @@ public: : QComboBox(parent) , dont_prompt_custom_par_(false) { - QStringList par_names = VideoParams::GetStandardPixelAspectRatioNames(); - for (int i = 0; i < VideoParams::kStandardPixelAspects.size(); i++) { - const rational &ratio = VideoParams::kStandardPixelAspects.at(i); + QStringList par_names = VideoParams::get_standard_pixel_aspect_ratio_names(); + for (int i = 0; i < VideoParams::k_standard_pixel_aspects.size(); i++) { + const Rational &ratio = VideoParams::k_standard_pixel_aspects.at(i); this->addItem(par_names.at(i), QVariant::fromValue(ratio)); } @@ -47,39 +47,39 @@ public: // Always add custom item last, much of the logic relies on this. Set this to the current AR so // that if none of the above are ==, it will eventually select this item this->addItem(QString()); - UpdateCustomItem(rational()); + update_custom_item(Rational()); // Pick up index signal to query for custom aspect ratio if requested connect(this, static_cast( &QComboBox::currentIndexChanged), - this, &PixelAspectRatioComboBox::IndexChanged); + this, &PixelAspectRatioComboBox::index_changed); } - rational GetPixelAspectRatio() const + Rational get_pixel_aspect_ratio() const { - return this->currentData().value(); + return this->currentData().value(); } - void SetPixelAspectRatio(const rational &r) + void set_pixel_aspect_ratio(const Rational &r) { // Determine which index to select on startup for (int i = 0; i < this->count(); i++) { - if (this->itemData(i).value() == r) { + if (this->itemData(i).value() == r) { this->setCurrentIndex(i); return; } } // Must not have found the ratio, so it must be custom - UpdateCustomItem(r); + update_custom_item(r); dont_prompt_custom_par_ = true; this->setCurrentIndex(this->count() - 1); dont_prompt_custom_par_ = false; } private slots: - void IndexChanged(int index) + void index_changed(int index) { if (dont_prompt_custom_par_) { return; @@ -90,17 +90,17 @@ private slots: // Query for custom pixel aspect ratio bool ok; - double custom_ratio = GetFloatRatioFromUser( + double custom_ratio = get_float_ratio_from_user( this, tr("Set Custom Pixel Aspect Ratio"), &ok); if (ok) { - UpdateCustomItem(rational::fromDouble(custom_ratio)); + update_custom_item(Rational::from_double(custom_ratio)); } } } private: - void UpdateCustomItem(const rational &ratio) + void update_custom_item(const Rational &ratio) { const int custom_index = this->count() - 1; @@ -108,10 +108,10 @@ private: this->setItemText(custom_index, tr("Custom...")); // Use 1:1 to prevent any real chance of the PAR being set to 0 - this->setItemData(custom_index, QVariant::fromValue(rational(1))); + this->setItemData(custom_index, QVariant::fromValue(Rational(1))); } else { this->setItemText(custom_index, - VideoParams::FormatPixelAspectRatioString( + VideoParams::format_pixel_aspect_ratio_string( tr("Custom (%1)"), ratio)); this->setItemData(custom_index, QVariant::fromValue(ratio)); } @@ -122,4 +122,4 @@ private: } -#endif // PIXELASPECTRATIOCOMBOBOX_H +#endif // OAK_PIXELASPECTRATIOCOMBOBOX_H diff --git a/app/widget/standardcombos/pixelformatcombobox.h b/app/widget/standardcombos/pixelformatcombobox.h index 76fe9594a..4e769e172 100644 --- a/app/widget/standardcombos/pixelformatcombobox.h +++ b/app/widget/standardcombos/pixelformatcombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef PIXELFORMATCOMBOBOX_H -#define PIXELFORMATCOMBOBOX_H +#ifndef OAK_PIXELFORMATCOMBOBOX_H +#define OAK_PIXELFORMATCOMBOBOX_H #include @@ -36,22 +36,22 @@ public: : QComboBox(parent) { // Set up preview formats - for (int i = 0; i < PixelFormat::COUNT; i++) { + for (int i = 0; i < PixelFormat::count; i++) { PixelFormat pix_fmt = static_cast(i); if (!float_only || pix_fmt.is_float()) { - this->addItem(VideoParams::GetFormatName(pix_fmt), + this->addItem(VideoParams::get_format_name(pix_fmt), static_cast(pix_fmt)); } } } - PixelFormat GetPixelFormat() const + PixelFormat get_pixel_format() const { return static_cast(this->currentData().toInt()); } - void SetPixelFormat(PixelFormat fmt) + void set_pixel_format(PixelFormat fmt) { for (int i = 0; i < this->count(); i++) { if (this->itemData(i).toInt() == fmt) { @@ -64,4 +64,4 @@ public: } -#endif // PIXELFORMATCOMBOBOX_H +#endif // OAK_PIXELFORMATCOMBOBOX_H diff --git a/app/widget/standardcombos/sampleformatcombobox.h b/app/widget/standardcombos/sampleformatcombobox.h index 9995abf31..6240ec09a 100644 --- a/app/widget/standardcombos/sampleformatcombobox.h +++ b/app/widget/standardcombos/sampleformatcombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef SAMPLEFORMATCOMBOBOX_H -#define SAMPLEFORMATCOMBOBOX_H +#ifndef OAK_SAMPLEFORMATCOMBOBOX_H +#define OAK_SAMPLEFORMATCOMBOBOX_H #include #include @@ -41,54 +41,54 @@ public: { } - void SetAttemptToRestoreFormat(bool e) + void set_attempt_to_restore_format(bool e) { attempt_to_restore_format_ = e; } - void SetAvailableFormats(const std::vector &formats) + void set_available_formats(const std::vector &formats) { - SampleFormat tmp = SampleFormat::INVALID; + SampleFormat tmp = SampleFormat::invalid; if (attempt_to_restore_format_) { - tmp = GetSampleFormat(); + tmp = get_sample_format(); } clear(); foreach (const SampleFormat &of, formats) { - AddFormatItem(of); + add_format_item(of); } if (attempt_to_restore_format_) { - SetSampleFormat(tmp); + set_sample_format(tmp); } } - void SetPackedFormats() + void set_packed_formats() { - SampleFormat tmp = SampleFormat::INVALID; + SampleFormat tmp = SampleFormat::invalid; if (attempt_to_restore_format_) { - tmp = GetSampleFormat(); + tmp = get_sample_format(); } clear(); - for (int i = SampleFormat::PACKED_START; i < SampleFormat::PACKED_END; + for (int i = SampleFormat::packed_start; i < SampleFormat::packed_end; i++) { - AddFormatItem(static_cast(i)); + add_format_item(static_cast(i)); } if (attempt_to_restore_format_) { - SetSampleFormat(tmp); + set_sample_format(tmp); } } - SampleFormat GetSampleFormat() const + SampleFormat get_sample_format() const { return static_cast(this->currentData().toInt()); } - void SetSampleFormat(SampleFormat fmt) + void set_sample_format(SampleFormat fmt) { for (int i = 0; i < this->count(); i++) { if (this->itemData(i).toInt() == fmt) { @@ -99,9 +99,9 @@ public: } private: - void AddFormatItem(SampleFormat f) + void add_format_item(SampleFormat f) { - this->addItem(HumanStrings::FormatToString(f), + this->addItem(HumanStrings::format_to_string(f), static_cast(f)); } @@ -110,4 +110,4 @@ private: } -#endif // SAMPLEFORMATCOMBOBOX_H +#endif // OAK_SAMPLEFORMATCOMBOBOX_H diff --git a/app/widget/standardcombos/sampleratecombobox.h b/app/widget/standardcombos/sampleratecombobox.h index df3cc5103..79c36776b 100644 --- a/app/widget/standardcombos/sampleratecombobox.h +++ b/app/widget/standardcombos/sampleratecombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef SAMPLERATECOMBOBOX_H -#define SAMPLERATECOMBOBOX_H +#ifndef OAK_SAMPLERATECOMBOBOX_H +#define OAK_SAMPLERATECOMBOBOX_H #include #include @@ -38,17 +38,17 @@ public: SampleRateComboBox(QWidget *parent = nullptr) : QComboBox(parent) { - foreach (int sr, AudioParams::kSupportedSampleRates) { - this->addItem(HumanStrings::SampleRateToString(sr), sr); + foreach (int sr, AudioParams::k_supported_sample_rates) { + this->addItem(HumanStrings::sample_rate_to_string(sr), sr); } } - int GetSampleRate() const + int get_sample_rate() const { return this->currentData().toInt(); } - void SetSampleRate(int rate) + void set_sample_rate(int rate) { for (int i = 0; i < this->count(); i++) { if (this->itemData(i).toInt() == rate) { @@ -61,4 +61,4 @@ public: } -#endif // SAMPLERATECOMBOBOX_H +#endif // OAK_SAMPLERATECOMBOBOX_H diff --git a/app/widget/standardcombos/standardcombos.h b/app/widget/standardcombos/standardcombos.h index f1c94e7c2..bb052c3aa 100644 --- a/app/widget/standardcombos/standardcombos.h +++ b/app/widget/standardcombos/standardcombos.h @@ -18,8 +18,8 @@ ***/ -#ifndef STANDARDCOMBOS_H -#define STANDARDCOMBOS_H +#ifndef OAK_STANDARDCOMBOS_H +#define OAK_STANDARDCOMBOS_H #include "channellayoutcombobox.h" #include "frameratecombobox.h" @@ -30,4 +30,4 @@ #include "sampleratecombobox.h" #include "videodividercombobox.h" -#endif // STANDARDCOMBOS_H +#endif // OAK_STANDARDCOMBOS_H diff --git a/app/widget/standardcombos/videodividercombobox.h b/app/widget/standardcombos/videodividercombobox.h index 5c718ff5c..7f6cdecef 100644 --- a/app/widget/standardcombos/videodividercombobox.h +++ b/app/widget/standardcombos/videodividercombobox.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIDEODIVIDERCOMBOBOX_H -#define VIDEODIVIDERCOMBOBOX_H +#ifndef OAK_VIDEODIVIDERCOMBOBOX_H +#define OAK_VIDEODIVIDERCOMBOBOX_H #include @@ -35,17 +35,17 @@ public: VideoDividerComboBox(QWidget *parent = nullptr) : QComboBox(parent) { - foreach (int d, VideoParams::kSupportedDividers) { - this->addItem(VideoParams::GetNameForDivider(d), d); + foreach (int d, VideoParams::k_supported_dividers) { + this->addItem(VideoParams::get_name_for_divider(d), d); } } - int GetDivider() const + int get_divider() const { return this->currentData().toInt(); } - void SetDivider(int d) + void set_divider(int d) { for (int i = 0; i < this->count(); i++) { if (this->itemData(i).toInt() == d) { @@ -58,4 +58,4 @@ public: } -#endif // VIDEODIVIDERCOMBOBOX_H +#endif // OAK_VIDEODIVIDERCOMBOBOX_H diff --git a/app/widget/taskview/elapsedcounterwidget.cpp b/app/widget/taskview/elapsedcounterwidget.cpp index fdb6e5046..f867bbefa 100644 --- a/app/widget/taskview/elapsedcounterwidget.cpp +++ b/app/widget/taskview/elapsedcounterwidget.cpp @@ -48,34 +48,34 @@ ElapsedCounterWidget::ElapsedCounterWidget(QWidget *parent) elapsed_timer_.setInterval(500); connect(&elapsed_timer_, &QTimer::timeout, this, - &ElapsedCounterWidget::UpdateTimers); - UpdateTimers(); + &ElapsedCounterWidget::update_timers); + update_timers(); } -void ElapsedCounterWidget::SetProgress(double d) +void ElapsedCounterWidget::set_progress(double d) { last_progress_ = d; - UpdateTimers(); + update_timers(); } -void ElapsedCounterWidget::Start() +void ElapsedCounterWidget::start() { - Start(QDateTime::currentMSecsSinceEpoch()); + start(QDateTime::currentMSecsSinceEpoch()); } -void ElapsedCounterWidget::Start(qint64 start_time) +void ElapsedCounterWidget::start(qint64 start_time) { start_time_ = start_time; elapsed_timer_.start(); - UpdateTimers(); + update_timers(); } -void ElapsedCounterWidget::Stop() +void ElapsedCounterWidget::stop() { elapsed_timer_.stop(); } -void ElapsedCounterWidget::UpdateTimers() +void ElapsedCounterWidget::update_timers() { int64_t elapsed_ms, remaining_ms; diff --git a/app/widget/taskview/elapsedcounterwidget.h b/app/widget/taskview/elapsedcounterwidget.h index 3e687c153..dd2e8f4ba 100644 --- a/app/widget/taskview/elapsedcounterwidget.h +++ b/app/widget/taskview/elapsedcounterwidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef ELAPSEDCOUNTERWIDGET_H -#define ELAPSEDCOUNTERWIDGET_H +#ifndef OAK_ELAPSEDCOUNTERWIDGET_H +#define OAK_ELAPSEDCOUNTERWIDGET_H #include #include @@ -36,14 +36,14 @@ class ElapsedCounterWidget : public QWidget { public: ElapsedCounterWidget(QWidget *parent = nullptr); - void SetProgress(double d); + void set_progress(double d); public slots: - void Start(qint64 start_time); - void Start(); + void start(qint64 start_time); + void start(); public slots: - void Stop(); + void stop(); private: QLabel *elapsed_lbl_; @@ -57,9 +57,9 @@ private: qint64 start_time_; private slots: - void UpdateTimers(); + void update_timers(); }; } -#endif // ELAPSEDCOUNTERWIDGET_H +#endif // OAK_ELAPSEDCOUNTERWIDGET_H diff --git a/app/widget/taskview/taskview.cpp b/app/widget/taskview/taskview.cpp index 1a48cd224..b81522da6 100644 --- a/app/widget/taskview/taskview.cpp +++ b/app/widget/taskview/taskview.cpp @@ -45,21 +45,21 @@ TaskView::TaskView(QWidget *parent) layout_->addStretch(); } -void TaskView::AddTask(Task *t) +void TaskView::add_task(Task *t) { // Create TaskViewItem (UI representation of a Task) and connect it TaskViewItem *item = new TaskViewItem(t); - connect(item, &TaskViewItem::TaskCancelled, this, &TaskView::TaskCancelled); + connect(item, &TaskViewItem::task_cancelled, this, &TaskView::task_cancelled); items_.insert(t, item); layout_->insertWidget(layout_->count() - 1, item); } -void TaskView::TaskFailed(Task *t) +void TaskView::task_failed(Task *t) { - items_.value(t)->Failed(); + items_.value(t)->failed(); } -void TaskView::RemoveTask(Task *t) +void TaskView::remove_task(Task *t) { items_.value(t)->deleteLater(); items_.remove(t); diff --git a/app/widget/taskview/taskview.h b/app/widget/taskview/taskview.h index fc208413a..ce2361c41 100644 --- a/app/widget/taskview/taskview.h +++ b/app/widget/taskview/taskview.h @@ -19,8 +19,8 @@ ***/ -#ifndef TASKVIEW_H -#define TASKVIEW_H +#ifndef OAK_TASKVIEW_H +#define OAK_TASKVIEW_H #include #include @@ -44,7 +44,7 @@ public: TaskView(QWidget *parent); signals: - void TaskCancelled(Task *t); + void task_cancelled(Task *t); public slots: /** @@ -52,11 +52,11 @@ public slots: * * Connect this to TaskManager::TaskAdded(). */ - void AddTask(Task *t); + void add_task(Task *t); - void TaskFailed(Task *t); + void task_failed(Task *t); - void RemoveTask(Task *t); + void remove_task(Task *t); private: QWidget *central_widget_; @@ -68,4 +68,4 @@ private: } -#endif // TASKVIEW_H +#endif // OAK_TASKVIEW_H diff --git a/app/widget/taskview/taskviewitem.cpp b/app/widget/taskview/taskviewitem.cpp index 6c46d15a5..e69b8510d 100644 --- a/app/widget/taskview/taskviewitem.cpp +++ b/app/widget/taskview/taskviewitem.cpp @@ -41,7 +41,7 @@ TaskViewItem::TaskViewItem(Task *task, QWidget *parent) // Create header label task_name_lbl_ = new QLabel(this); - task_name_lbl_->setText(task_->GetTitle()); + task_name_lbl_->setText(task_->get_title()); layout->addWidget(task_name_lbl_); // Create center layout (combines progress bar and a cancel button) @@ -55,7 +55,7 @@ TaskViewItem::TaskViewItem(Task *task, QWidget *parent) // Create cancel button cancel_btn_ = new QPushButton(this); - cancel_btn_->setIcon(icon::Error); + cancel_btn_->setIcon(icon::error); middle_layout->addWidget(cancel_btn_); // Create stack with error label and elapsed/remaining time @@ -75,24 +75,24 @@ TaskViewItem::TaskViewItem(Task *task, QWidget *parent) status_stack_->setCurrentWidget(elapsed_timer_lbl_); // Connect to the task - connect(task_, &Task::Started, elapsed_timer_lbl_, - qOverload(&ElapsedCounterWidget::Start)); - connect(task_, &Task::ProgressChanged, this, &TaskViewItem::UpdateProgress); + connect(task_, &Task::started, elapsed_timer_lbl_, + qOverload(&ElapsedCounterWidget::start)); + connect(task_, &Task::progress_changed, this, &TaskViewItem::update_progress); connect(cancel_btn_, &QPushButton::clicked, this, - [this] { emit TaskCancelled(task_); }); + [this] { emit task_cancelled(task_); }); } -void TaskViewItem::Failed() +void TaskViewItem::failed() { status_stack_->setCurrentWidget(task_error_lbl_); task_error_lbl_->setStyleSheet("color: red"); - task_error_lbl_->setText(tr("Error: %1").arg(task_->GetError())); + task_error_lbl_->setText(tr("Error: %1").arg(task_->get_error())); } -void TaskViewItem::UpdateProgress(double d) +void TaskViewItem::update_progress(double d) { progress_bar_->setValue(qRound(100.0 * d)); - elapsed_timer_lbl_->SetProgress(d); + elapsed_timer_lbl_->set_progress(d); } } diff --git a/app/widget/taskview/taskviewitem.h b/app/widget/taskview/taskviewitem.h index 756a7969c..f07302619 100644 --- a/app/widget/taskview/taskviewitem.h +++ b/app/widget/taskview/taskviewitem.h @@ -19,8 +19,8 @@ ***/ -#ifndef TASKVIEWITEM_H -#define TASKVIEWITEM_H +#ifndef OAK_TASKVIEWITEM_H +#define OAK_TASKVIEWITEM_H #include #include @@ -48,10 +48,10 @@ class TaskViewItem : public QFrame { public: TaskViewItem(Task *task, QWidget *parent = nullptr); - void Failed(); + void failed(); signals: - void TaskCancelled(Task *t); + void task_cancelled(Task *t); private: QLabel *task_name_lbl_; @@ -65,9 +65,9 @@ private: Task *task_; private slots: - void UpdateProgress(double d); + void update_progress(double d); }; } -#endif // TASKVIEWITEM_H +#endif // OAK_TASKVIEWITEM_H diff --git a/app/widget/timebased/timebasedview.cpp b/app/widget/timebased/timebasedview.cpp index bcd992311..95d11838a 100644 --- a/app/widget/timebased/timebasedview.cpp +++ b/app/widget/timebased/timebasedview.cpp @@ -46,14 +46,14 @@ TimeBasedView::TimeBasedView(QWidget *parent) setScene(&scene_); // Set default scale (ensures non-zero scale from beginning) - SetScale(1.0); + set_scale(1.0); // Default to no default drag mode - SetDefaultDragMode(NoDrag); + set_default_drag_mode(NoDrag); // Signal to update bounding rect when the scene changes connect(&scene_, &QGraphicsScene::changed, this, - &TimeBasedView::UpdateSceneRect); + &TimeBasedView::update_scene_rect); // Workaround for Qt drawing issues with the default MinimalViewportUpdate. While this might be // slower (Qt documentation says it may actually be faster in some situations), @@ -61,13 +61,13 @@ TimeBasedView::TimeBasedView(QWidget *parent) setViewportUpdateMode(QGraphicsView::FullViewportUpdate); } -void TimeBasedView::TimebaseChangedEvent(const rational &) +void TimeBasedView::TimebaseChangedEvent(const Rational &) { // Timebase influences position/visibility of playhead viewport()->update(); } -void TimeBasedView::EnableSnap(const std::vector &points) +void TimeBasedView::enable_snap(const std::vector &points) { snapped_ = true; snap_time_ = points; @@ -75,14 +75,14 @@ void TimeBasedView::EnableSnap(const std::vector &points) viewport()->update(); } -void TimeBasedView::DisableSnap() +void TimeBasedView::disable_snap() { snapped_ = false; viewport()->update(); } -const double &TimeBasedView::GetYScale() const +const double &TimeBasedView::get_y_scale() const { return y_scale_; } @@ -91,7 +91,7 @@ void TimeBasedView::VerticalScaleChangedEvent(double) { } -void TimeBasedView::ZoomIntoCursorPosition(QWheelEvent *event, +void TimeBasedView::zoom_into_cursor_position(QWheelEvent *event, double scale_multiplier, const QPointF &cursor_pos) { @@ -116,12 +116,12 @@ void TimeBasedView::ZoomIntoCursorPosition(QWheelEvent *event, if (!only_vertical) { double old_scroll = horizontalScrollBar()->value(); - double old_scale = GetScale(); - emit ScaleChanged(old_scale * scale_multiplier); + double old_scale = get_scale(); + emit scale_changed(old_scale * scale_multiplier); // Use GetScale so that if this value was clamped, we don't erroneously use an unclamped value int new_x_scroll = - qRound((cursor_pos.x() + old_scroll) / old_scale * GetScale() - + qRound((cursor_pos.x() + old_scroll) / old_scale * get_scale() - cursor_pos.x()); horizontalScrollBar()->setValue(new_x_scroll); } @@ -129,18 +129,18 @@ void TimeBasedView::ZoomIntoCursorPosition(QWheelEvent *event, if (!only_horizontal) { double old_y_scroll = verticalScrollBar()->value(); - double old_y_scale = GetYScale(); - SetYScale(old_y_scale * scale_multiplier); + double old_y_scale = get_y_scale(); + set_y_scale(old_y_scale * scale_multiplier); // Use GetYScale so that if this value was clamped, we don't erroneously use an unclamped value int new_y_scroll = - qRound((cursor_pos.y() + old_y_scroll) / old_y_scale * GetYScale() - + qRound((cursor_pos.y() + old_y_scroll) / old_y_scale * get_y_scale() - cursor_pos.y()); verticalScrollBar()->setValue(new_y_scroll); } } -void TimeBasedView::SetYScale(const double &y_scale) +void TimeBasedView::set_y_scale(const double &y_scale) { Q_ASSERT(y_scale > 0); @@ -153,29 +153,29 @@ void TimeBasedView::SetYScale(const double &y_scale) } } -void TimeBasedView::SetViewerNode(ViewerOutput *v) +void TimeBasedView::set_viewer_node(ViewerOutput *v) { if (viewer_) { - disconnect(viewer_, &ViewerOutput::PlayheadChanged, viewport(), + disconnect(viewer_, &ViewerOutput::playhead_changed, viewport(), static_cast(&TimeBasedView::update)); } viewer_ = v; if (viewer_) { - connect(viewer_, &ViewerOutput::PlayheadChanged, viewport(), + connect(viewer_, &ViewerOutput::playhead_changed, viewport(), static_cast(&TimeBasedView::update)); } } -QPointF TimeBasedView::ScalePoint(const QPointF &p) const +QPointF TimeBasedView::scale_point(const QPointF &p) const { - return QPointF(p.x() * GetScale(), p.y() * GetYScale()); + return QPointF(p.x() * get_scale(), p.y() * get_y_scale()); } -QPointF TimeBasedView::UnscalePoint(const QPointF &p) const +QPointF TimeBasedView::unscale_point(const QPointF &p) const { - return QPointF(p.x() / GetScale(), p.y() / GetYScale()); + return QPointF(p.x() / get_scale(), p.y() / get_y_scale()); } void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect) @@ -183,9 +183,9 @@ void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect) QGraphicsView::drawForeground(painter, rect); if (!timebase().isNull()) { - double width = TimeToScene(timebase()); + double width = time_to_scene(timebase()); - playhead_scene_left_ = GetPlayheadX(); + playhead_scene_left_ = get_playhead_x(); playhead_scene_right_ = playhead_scene_left_ + width; QRectF playhead_rect(playhead_scene_left_, rect.top(), width, @@ -208,15 +208,15 @@ void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect) if (snapped_) { painter->setPen(palette().text().color()); - foreach (const rational &r, snap_time_) { - double x = TimeToScene(r); + foreach (const Rational &r, snap_time_) { + double x = time_to_scene(r); painter->drawLine(x, rect.top(), x, rect.height()); } } } -bool TimeBasedView::PlayheadPress(QMouseEvent *event) +bool TimeBasedView::playhead_press(QMouseEvent *event) { QPointF scene_pos = mapToScene(event->pos()); @@ -227,7 +227,7 @@ bool TimeBasedView::PlayheadPress(QMouseEvent *event) return dragging_playhead_; } -bool TimeBasedView::PlayheadMove(QMouseEvent *event) +bool TimeBasedView::playhead_move(QMouseEvent *event) { if (!dragging_playhead_) { return false; @@ -235,31 +235,31 @@ bool TimeBasedView::PlayheadMove(QMouseEvent *event) if (viewer_) { QPointF scene_pos = mapToScene(event->pos()); - rational mouse_time = qMax(rational(0), SceneToTime(scene_pos.x())); + Rational mouse_time = qMax(Rational(0), scene_to_time(scene_pos.x())); if (Core::instance()->snapping() && snap_service_) { - rational movement; + Rational movement; - snap_service_->SnapPoint({ mouse_time }, &movement, - TimeBasedWidget::kSnapAll & - ~TimeBasedWidget::kSnapToPlayhead); + snap_service_->snap_point({ mouse_time }, &movement, + TimeBasedWidget::k_snap_all & + ~TimeBasedWidget::k_snap_to_playhead); mouse_time += movement; } - viewer_->SetPlayhead(mouse_time); + viewer_->set_playhead(mouse_time); } return true; } -bool TimeBasedView::PlayheadRelease(QMouseEvent *) +bool TimeBasedView::playhead_release(QMouseEvent *) { if (dragging_playhead_) { dragging_playhead_ = false; if (snap_service_) { - snap_service_->HideSnaps(); + snap_service_->hide_snaps(); } return true; @@ -268,23 +268,23 @@ bool TimeBasedView::PlayheadRelease(QMouseEvent *) return false; } -qreal TimeBasedView::GetPlayheadX() +qreal TimeBasedView::get_playhead_x() { if (viewer_) { - return TimeToScene(viewer_->GetPlayhead()); + return time_to_scene(viewer_->get_playhead()); } else { return 0; } } -void TimeBasedView::SetEndTime(const rational &length) +void TimeBasedView::set_end_time(const Rational &length) { end_time_ = length; - UpdateSceneRect(); + update_scene_rect(); } -void TimeBasedView::UpdateSceneRect() +void TimeBasedView::update_scene_rect() { QRectF bounding_rect = scene_.itemsBoundingRect(); @@ -292,7 +292,7 @@ void TimeBasedView::UpdateSceneRect() bounding_rect.setLeft(0); // Ensure the scene is always the full length of the timeline with a gap at the end to work with - bounding_rect.setRight(TimeToScene(end_time_) + width()); + bounding_rect.setRight(time_to_scene(end_time_) + width()); // Any further rect processing from derivatives can be done here SceneRectUpdateEvent(bounding_rect); @@ -307,7 +307,7 @@ void TimeBasedView::resizeEvent(QResizeEvent *event) { QGraphicsView::resizeEvent(event); - UpdateSceneRect(); + update_scene_rect(); } void TimeBasedView::ScaleChangedEvent(const double &scale) @@ -315,7 +315,7 @@ void TimeBasedView::ScaleChangedEvent(const double &scale) TimeScaledObject::ScaleChangedEvent(scale); // Update scene rect - UpdateSceneRect(); + update_scene_rect(); // Force redraw for playhead if the above function didn't do it viewport()->update(); diff --git a/app/widget/timebased/timebasedview.h b/app/widget/timebased/timebasedview.h index 5108b78b4..12ee01c77 100644 --- a/app/widget/timebased/timebasedview.h +++ b/app/widget/timebased/timebasedview.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEVIEWBASE_H -#define TIMELINEVIEWBASE_H +#ifndef OAK_TIMELINEVIEWBASE_H +#define OAK_TIMELINEVIEWBASE_H #include #include @@ -39,26 +39,26 @@ class TimeBasedView : public HandMovableView, public TimeScaledObject { public: TimeBasedView(QWidget *parent = nullptr); - void EnableSnap(const std::vector &points); - void DisableSnap(); - bool IsSnapped() const + void enable_snap(const std::vector &points); + void disable_snap(); + bool is_snapped() const { return snapped_; } - TimeBasedWidget *GetSnapService() const + TimeBasedWidget *get_snap_service() const { return snap_service_; } - void SetSnapService(TimeBasedWidget *service) + void set_snap_service(TimeBasedWidget *service) { snap_service_ = service; } - const double &GetYScale() const; - void SetYScale(const double &y_scale); + const double &get_y_scale() const; + void set_y_scale(const double &y_scale); - virtual bool IsDraggingPlayhead() const + virtual bool is_dragging_playhead() const { return dragging_playhead_; } @@ -71,26 +71,26 @@ public: { } - ViewerOutput *GetViewerNode() const + ViewerOutput *get_viewer_node() const { return viewer_; } - void SetViewerNode(ViewerOutput *v); + void set_viewer_node(ViewerOutput *v); - QPointF ScalePoint(const QPointF &p) const; - QPointF UnscalePoint(const QPointF &p) const; + QPointF scale_point(const QPointF &p) const; + QPointF unscale_point(const QPointF &p) const; public slots: - void SetEndTime(const rational &length); + void set_end_time(const Rational &length); /** * @brief Slot called whenever the view resizes or the scene contents change to enforce minimum scene sizes */ - void UpdateSceneRect(); + void update_scene_rect(); signals: - void ScaleChanged(double scale); + void scale_changed(double scale); protected: virtual void drawForeground(QPainter *painter, const QRectF &rect) override; @@ -105,27 +105,27 @@ protected: virtual void VerticalScaleChangedEvent(double scale); - virtual void ZoomIntoCursorPosition(QWheelEvent *event, double multiplier, + virtual void zoom_into_cursor_position(QWheelEvent *event, double multiplier, const QPointF &cursor_pos) override; - bool PlayheadPress(QMouseEvent *event); - bool PlayheadMove(QMouseEvent *event); - bool PlayheadRelease(QMouseEvent *event); + bool playhead_press(QMouseEvent *event); + bool playhead_move(QMouseEvent *event); + bool playhead_release(QMouseEvent *event); - virtual void TimebaseChangedEvent(const rational &) override; + virtual void TimebaseChangedEvent(const Rational &) override; - bool IsYAxisEnabled() const + bool is_y_axis_enabled() const { return y_axis_enabled_; } - void SetYAxisEnabled(bool e) + void set_y_axis_enabled(bool e) { y_axis_enabled_ = e; } private: - qreal GetPlayheadX(); + qreal get_playhead_x(); double playhead_scene_left_; double playhead_scene_right_; @@ -135,9 +135,9 @@ private: QGraphicsScene scene_; bool snapped_; - std::vector snap_time_; + std::vector snap_time_; - rational end_time_; + Rational end_time_; TimeBasedWidget *snap_service_; @@ -150,4 +150,4 @@ private: } -#endif // TIMELINEVIEWBASE_H +#endif // OAK_TIMELINEVIEWBASE_H diff --git a/app/widget/timebased/timebasedviewselectionmanager.h b/app/widget/timebased/timebasedviewselectionmanager.h index a6b15659d..94349f2b5 100644 --- a/app/widget/timebased/timebasedviewselectionmanager.h +++ b/app/widget/timebased/timebasedviewselectionmanager.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMEBASEDVIEWSELECTIONMANAGER_H -#define TIMEBASEDVIEWSELECTIONMANAGER_H +#ifndef OAK_TIMEBASEDVIEWSELECTIONMANAGER_H +#define OAK_TIMEBASEDVIEWSELECTIONMANAGER_H #include #include @@ -40,32 +40,32 @@ public: TimeBasedViewSelectionManager(TimeBasedView *view) : view_(view) , rubberband_(nullptr) - , snap_mask_(TimeBasedWidget::kSnapAll) + , snap_mask_(TimeBasedWidget::k_snap_all) { } - void SetSnapMask(TimeBasedWidget::SnapMask e) + void set_snap_mask(TimeBasedWidget::SnapMask e) { snap_mask_ = e; } - void ClearDrawnObjects() + void clear_drawn_objects() { drawn_objects_.clear(); } - void DeclareDrawnObject(T *object, const QRectF &rect) + void declare_drawn_object(T *object, const QRectF &rect) { - QRectF r(view_->UnscalePoint(rect.topLeft()), - view_->UnscalePoint(rect.bottomRight())); + QRectF r(view_->unscale_point(rect.topLeft()), + view_->unscale_point(rect.bottomRight())); drawn_objects_.push_back({ object, r }); } - bool Select(T *key) + bool select(T *key) { Q_ASSERT(key); - if (!IsSelected(key)) { + if (!is_selected(key)) { selected_.push_back(key); return true; } @@ -73,7 +73,7 @@ public: return false; } - bool Deselect(T *key) + bool deselect(T *key) { Q_ASSERT(key); @@ -86,31 +86,31 @@ public: } } - void ClearSelection() + void clear_selection() { selected_.clear(); } - bool IsSelected(T *key) const + bool is_selected(T *key) const { return std::find(selected_.cbegin(), selected_.cend(), key) != selected_.cend(); } - const std::vector &GetSelectedObjects() const + const std::vector &get_selected_objects() const { return selected_; } - void SetTimebase(const rational &tb) + void set_timebase(const Rational &tb) { timebase_ = tb; } - T *GetObjectAtPoint(const QPointF &scene_pt) + T *get_object_at_point(const QPointF &scene_pt) { // Iterate in reverse order because the objects drawn later will appear on top to the user - QPointF unscaled = view_->UnscalePoint(scene_pt); + QPointF unscaled = view_->unscale_point(scene_pt); for (auto it = drawn_objects_.crbegin(); it != drawn_objects_.crend(); it++) { const DrawnObject &kp = *it; @@ -122,36 +122,36 @@ public: return nullptr; } - T *GetObjectAtPoint(const QPoint &pt) + T *get_object_at_point(const QPoint &pt) { - return GetObjectAtPoint(view_->mapToScene(pt)); + return get_object_at_point(view_->mapToScene(pt)); } - T *MousePress(QMouseEvent *event) + T *mouse_press(QMouseEvent *event) { T *key_under_cursor = nullptr; if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) { // See if there's a keyframe in this position - key_under_cursor = GetObjectAtPoint(event->pos()); + key_under_cursor = get_object_at_point(event->pos()); bool holding_shift = event->modifiers() & Qt::ShiftModifier; - if (!key_under_cursor || !IsSelected(key_under_cursor)) { + if (!key_under_cursor || !is_selected(key_under_cursor)) { if (!holding_shift) { // If not already selecting and not holding shift, clear the current selection - ClearSelection(); + clear_selection(); } // Add item to selection, either nothing if shift wasn't held, or the existing selection if (key_under_cursor) { - Select(key_under_cursor); + select(key_under_cursor); view_->SelectionManagerSelectEvent(key_under_cursor); } } else if (holding_shift) { // If selected and holding shift, de-select this item but do nothing else - Deselect(key_under_cursor); + deselect(key_under_cursor); view_->SelectionManagerDeselectEvent(key_under_cursor); key_under_cursor = nullptr; } @@ -160,12 +160,12 @@ public: return key_under_cursor; } - bool IsDragging() const + bool is_dragging() const { return !dragging_.empty(); } - void DragStart(T *initial_item, QMouseEvent *event, + void drag_start(T *initial_item, QMouseEvent *event, TimeTargetObject *target = nullptr) { if (event->button() != Qt::LeftButton) { @@ -202,70 +202,70 @@ public: if (target) { time_targets_[i] = time_targets_[i + selected_.size()] = - QtUtils::GetParentOfType(obj); + QtUtils::get_parent_of_type(obj); } } else { dragging_[i] = obj->time(); snap_points_[i] = obj->time(); if (target) { - time_targets_[i] = QtUtils::GetParentOfType(obj); + time_targets_[i] = QtUtils::get_parent_of_type(obj); } } } drag_mouse_start_ = - view_->UnscalePoint(view_->mapToScene(event->pos())); + view_->unscale_point(view_->mapToScene(event->pos())); } - void SnapPoints(rational *movement) + void snap_points(Rational *movement) { - std::vector copy = snap_points_; + std::vector copy = snap_points_; if (time_target_) { for (size_t i = 0; i < copy.size(); i++) { if (Node *parent = time_targets_[i]) { - copy[i] = time_target_->GetAdjustedTime( - parent, time_target_->GetTimeTarget(), copy[i], - Node::kTransformTowardsOutput); + copy[i] = time_target_->get_adjusted_time( + parent, time_target_->get_time_target(), copy[i], + Node::k_transform_towards_output); } } } - if (Core::instance()->snapping() && view_->GetSnapService()) { - view_->GetSnapService()->SnapPoint(copy, movement, snap_mask_); + if (Core::instance()->snapping() && view_->get_snap_service()) { + view_->get_snap_service()->snap_point(copy, movement, snap_mask_); } } - void Unsnap() + void unsnap() { - if (view_->GetSnapService()) { - view_->GetSnapService()->HideSnaps(); + if (view_->get_snap_service()) { + view_->get_snap_service()->hide_snaps(); } } - void DragMove(const QPoint &local_pos, + void drag_move(const QPoint &local_pos, const QString &tip_format = QString()) { - rational time_diff = - view_->SceneToTimeNoGrid(view_->mapToScene(local_pos).x() - - view_->ScalePoint(drag_mouse_start_).x()); + Rational time_diff = + view_->scene_to_time_no_grid(view_->mapToScene(local_pos).x() - + view_->scale_point(drag_mouse_start_).x()); // Snap points - rational presnap_time_diff = time_diff; - SnapPoints(&time_diff); + Rational presnap_time_diff = time_diff; + snap_points(&time_diff); // Validate snapping - if (Core::instance()->snapping() && view_->GetSnapService()) { + if (Core::instance()->snapping() && view_->get_snap_service()) { for (size_t i = 0; i < selected_.size(); i++) { - rational proposed_time = dragging_.at(i) + time_diff; + Rational proposed_time = dragging_.at(i) + time_diff; T *sel = selected_.at(i); if (sel->has_sibling_at_time(proposed_time)) { // Unsnap time_diff = presnap_time_diff; - if (view_->GetSnapService()) { - view_->GetSnapService()->HideSnaps(); + if (view_->get_snap_service()) { + view_->get_snap_service()->hide_snaps(); } break; } @@ -274,11 +274,11 @@ public: // Validate movement for (size_t i = 0; i < selected_.size(); i++) { - rational proposed_time = dragging_.at(i) + time_diff; + Rational proposed_time = dragging_.at(i) + time_diff; T *sel = selected_.at(i); // Magic number: use interval of 1ms to avoid collisions - rational adj(1, 1000); + Rational adj(1, 1000); if (dragging_.at(i) < proposed_time) { // Negate adjustment value if origin is less than proposed time adj = -adj; @@ -289,13 +289,13 @@ public: loop = false; while (sel->has_sibling_at_time(proposed_time)) { proposed_time += adj; - Unsnap(); + unsnap(); } if (proposed_time < 0) { // Prevent any object from going below zero proposed_time = 0; - Unsnap(); + unsnap(); // Setting our proposed time to zero may (re)introduce a conflict that we just avoided // with the sibling check above, so we request it to happen again. To avoid a negative @@ -315,7 +315,7 @@ public: } // Show information about this keyframe - rational display_time; + Rational display_time; if constexpr (std::is_same_v) { display_time = initial_drag_item_->time().in(); @@ -324,7 +324,7 @@ public: } QString tip = QString::fromStdString(Timecode::time_to_timecode( - display_time, timebase_, Core::instance()->GetTimecodeDisplay(), + display_time, timebase_, Core::instance()->get_timecode_display(), false)); last_used_tip_format_ = tip_format; @@ -336,12 +336,12 @@ public: QToolTip::showText(QCursor::pos(), tip); } - void DragStop(MultiUndoCommand *command) + void drag_stop(MultiUndoCommand *command) { QToolTip::hideText(); for (size_t i = 0; i < selected_.size(); i++) { - rational current; + Rational current; if constexpr (std::is_same_v) { current = selected_.at(i)->time().in(); } else { @@ -352,15 +352,15 @@ public: } dragging_.clear(); - Unsnap(); + unsnap(); } - void RubberBandStart(QMouseEvent *event) + void rubber_band_start(QMouseEvent *event) { if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) { rubberband_scene_start_ = - view_->UnscalePoint(view_->mapToScene(event->pos())); + view_->unscale_point(view_->mapToScene(event->pos())); rubberband_ = new QRubberBand(QRubberBand::Rectangle, view_); rubberband_->setGeometry( @@ -371,49 +371,49 @@ public: } } - void RubberBandMove(const QPoint &pos) + void rubber_band_move(const QPoint &pos) { - if (IsRubberBanding()) { - QRectF band_rect = QRectF(view_->mapFromScene(view_->ScalePoint( + if (is_rubber_banding()) { + QRectF band_rect = QRectF(view_->mapFromScene(view_->scale_point( rubberband_scene_start_)), pos) .normalized(); rubberband_->setGeometry(band_rect.toRect()); - QPointF current = view_->UnscalePoint(view_->mapToScene(pos)); + QPointF current = view_->unscale_point(view_->mapToScene(pos)); QRectF scene_rect = QRectF(rubberband_scene_start_, current).normalized(); selected_ = rubberband_preselected_; foreach (const DrawnObject &kp, drawn_objects_) { if (scene_rect.intersects(kp.second)) { - Select(kp.first); + select(kp.first); } } } } - void RubberBandStop() + void rubber_band_stop() { - if (IsRubberBanding()) { + if (is_rubber_banding()) { delete rubberband_; rubberband_ = nullptr; } } - bool IsRubberBanding() const + bool is_rubber_banding() const { return rubberband_; } - void ForceDragUpdate() + void force_drag_update() { - if (IsRubberBanding() || IsDragging()) { + if (is_rubber_banding() || is_dragging()) { QPoint local_pos = view_->viewport()->mapFromGlobal(QCursor::pos()); - if (IsRubberBanding()) { - RubberBandMove(local_pos); + if (is_rubber_banding()) { + rubber_band_move(local_pos); } else { - DragMove(local_pos, last_used_tip_format_); + drag_move(local_pos, last_used_tip_format_); } } } @@ -421,24 +421,24 @@ public: private: class SetTimeCommand : public UndoCommand { public: - SetTimeCommand(T *key, const rational &time) + SetTimeCommand(T *key, const Rational &time) { key_ = key; new_time_ = time; old_time_ = key_->time(); } - SetTimeCommand(T *key, const rational &new_time, - const rational &old_time) + SetTimeCommand(T *key, const Rational &new_time, + const Rational &old_time) { key_ = key; new_time_ = new_time; old_time_ = old_time; } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { - return Project::GetProjectFromObject(key_); + return Project::get_project_from_object(key_); } protected: @@ -455,8 +455,8 @@ private: private: T *key_; - rational old_time_; - rational new_time_; + Rational old_time_; + Rational new_time_; }; TimeBasedView *view_; @@ -466,15 +466,15 @@ private: std::vector selected_; - std::vector dragging_; - std::vector snap_points_; + std::vector dragging_; + std::vector snap_points_; std::vector time_targets_; T *initial_drag_item_; QPointF drag_mouse_start_; - rational timebase_; + Rational timebase_; QRubberBand *rubberband_; QPointF rubberband_scene_start_; @@ -489,4 +489,4 @@ private: } -#endif // TIMEBASEDVIEWSELECTIONMANAGER_H +#endif // OAK_TIMEBASEDVIEWSELECTIONMANAGER_H diff --git a/app/widget/timebased/timebasedwidget.cpp b/app/widget/timebased/timebasedwidget.cpp index 09b4a1ae1..5c672ecc3 100644 --- a/app/widget/timebased/timebasedwidget.cpp +++ b/app/widget/timebased/timebasedwidget.cpp @@ -27,7 +27,7 @@ #include "common/range.h" #include "config/config.h" #include "core.h" -#include "common/Current.h" +#include "common/current.h" #include "dialog/markerproperties/markerpropertiesdialog.h" #include "node/project/sequence/sequence.h" #include "timeline/timelineundoworkarea.h" @@ -48,43 +48,43 @@ TimeBasedWidget::TimeBasedWidget(bool ruler_text_visible, , markers_(nullptr) { scrollbar_ = new ResizableTimelineScrollBar(Qt::Horizontal, this); - connect(scrollbar_, &ResizableScrollBar::ResizeBegan, this, - &TimeBasedWidget::ScrollBarResizeBegan); - connect(scrollbar_, &ResizableScrollBar::ResizeMoved, this, - &TimeBasedWidget::ScrollBarResizeMoved); + connect(scrollbar_, &ResizableScrollBar::resize_began, this, + &TimeBasedWidget::scroll_bar_resize_began); + connect(scrollbar_, &ResizableScrollBar::resize_moved, this, + &TimeBasedWidget::scroll_bar_resize_moved); ruler_ = new TimeRuler(ruler_text_visible, ruler_cache_status_visible, this); - ConnectTimelineView(ruler_); - ruler()->SetSnapService(this); - connect(ruler(), &TimeRuler::DragMoved, this, + connect_timeline_view(ruler_); + ruler()->set_snap_service(this); + connect(ruler(), &TimeRuler::drag_moved, this, static_cast( - &TimeBasedWidget::SetCatchUpScrollValue)); - connect(ruler(), &TimeRuler::DragReleased, this, + &TimeBasedWidget::set_catch_up_scroll_value)); + connect(ruler(), &TimeRuler::drag_released, this, static_cast( - &TimeBasedWidget::StopCatchUpScrollTimer)); + &TimeBasedWidget::stop_catch_up_scroll_timer)); catchup_scroll_timer_ = new QTimer(this); catchup_scroll_timer_->setInterval(250); // Hardcoded 1/4 scroll limit value connect(catchup_scroll_timer_, &QTimer::timeout, this, - &TimeBasedWidget::CatchUpTimerTimeout); + &TimeBasedWidget::catch_up_timer_timeout); } -void TimeBasedWidget::SetScaleAndCenterOnPlayhead(const double &scale) +void TimeBasedWidget::set_scale_and_center_on_playhead(const double &scale) { SetScale(scale); // Zoom towards the playhead // (using a hacky singleShot so the scroll occurs after the scene and its scrollbars have updated) - QTimer::singleShot(0, this, &TimeBasedWidget::CenterScrollOnPlayhead); + QTimer::singleShot(0, this, &TimeBasedWidget::center_scroll_on_playhead); } -ViewerOutput *TimeBasedWidget::GetConnectedNode() const +ViewerOutput *TimeBasedWidget::get_connected_node() const { return viewer_node_.data(); } -void TimeBasedWidget::ConnectViewerNode(ViewerOutput *node) +void TimeBasedWidget::connect_viewer_node(ViewerOutput *node) { // Ignore no-op if (viewer_node_ == node) { @@ -96,9 +96,9 @@ void TimeBasedWidget::ConnectViewerNode(ViewerOutput *node) viewer_node_ = node; if (viewer_node_) { Current::getInstance().setCurrentVideoParams( - viewer_node_->GetVideoParams()); + viewer_node_->get_video_params()); Current::getInstance().setCurrentAudioParams( - viewer_node_->GetAudioParams()); + viewer_node_->get_audio_params()); } else { Current::getInstance().setCurrentVideoParams(VideoParams()); Current::getInstance().setCurrentAudioParams(AudioParams()); @@ -108,104 +108,104 @@ void TimeBasedWidget::ConnectViewerNode(ViewerOutput *node) DisconnectNodeEvent(old); // Disconnect length changed signal - disconnect(old, &ViewerOutput::LengthChanged, this, - &TimeBasedWidget::UpdateMaximumScroll); - disconnect(old, &ViewerOutput::RemovedFromGraph, this, - &TimeBasedWidget::ConnectedNodeRemovedFromGraph); - disconnect(old, &ViewerOutput::PlayheadChanged, this, - &TimeBasedWidget::PlayheadTimeChanged); + disconnect(old, &ViewerOutput::length_changed, this, + &TimeBasedWidget::update_maximum_scroll); + disconnect(old, &ViewerOutput::removed_from_graph, this, + &TimeBasedWidget::connected_node_removed_from_graph); + disconnect(old, &ViewerOutput::playhead_changed, this, + &TimeBasedWidget::playhead_time_changed); // Disconnect rate change signals if they were connected - disconnect(old, &ViewerOutput::FrameRateChanged, this, - &TimeBasedWidget::AutoUpdateTimebase); - disconnect(old, &ViewerOutput::SampleRateChanged, this, - &TimeBasedWidget::AutoUpdateTimebase); + disconnect(old, &ViewerOutput::frame_rate_changed, this, + &TimeBasedWidget::auto_update_timebase); + disconnect(old, &ViewerOutput::sample_rate_changed, this, + &TimeBasedWidget::auto_update_timebase); // Reset timebase to null - SetTimebase(rational()); + SetTimebase(Rational()); // Disconnect ruler and scrollbar from timeline points - ConnectWorkArea(nullptr); - ConnectMarkers(nullptr); + connect_work_area(nullptr); + connect_markers(nullptr); } // Call derivatives for (TimeBasedView *view : timeline_views_) { - view->SetViewerNode(viewer_node_.data()); + view->set_viewer_node(viewer_node_.data()); } ConnectedNodeChangeEvent(viewer_node_.data()); if (viewer_node_) { // Connect length changed signal - connect(viewer_node_.data(), &ViewerOutput::LengthChanged, this, - &TimeBasedWidget::UpdateMaximumScroll); - connect(viewer_node_.data(), &ViewerOutput::RemovedFromGraph, this, - &TimeBasedWidget::ConnectedNodeRemovedFromGraph); - connect(viewer_node_.data(), &ViewerOutput::PlayheadChanged, this, - &TimeBasedWidget::PlayheadTimeChanged); + connect(viewer_node_.data(), &ViewerOutput::length_changed, this, + &TimeBasedWidget::update_maximum_scroll); + connect(viewer_node_.data(), &ViewerOutput::removed_from_graph, this, + &TimeBasedWidget::connected_node_removed_from_graph); + connect(viewer_node_.data(), &ViewerOutput::playhead_changed, this, + &TimeBasedWidget::playhead_time_changed); // Connect ruler and scrollbar to timeline points - ConnectWorkArea(viewer_node_->GetWorkArea()); - ConnectMarkers(viewer_node_->GetMarkers()); + connect_work_area(viewer_node_->get_work_area()); + connect_markers(viewer_node_->get_markers()); // If we're setting the timebase, set it automatically based on the video and audio parameters if (auto_set_timebase_) { - AutoUpdateTimebase(); - connect(viewer_node_.data(), &ViewerOutput::FrameRateChanged, this, - &TimeBasedWidget::AutoUpdateTimebase); - connect(viewer_node_.data(), &ViewerOutput::SampleRateChanged, this, - &TimeBasedWidget::AutoUpdateTimebase); + auto_update_timebase(); + connect(viewer_node_.data(), &ViewerOutput::frame_rate_changed, this, + &TimeBasedWidget::auto_update_timebase); + connect(viewer_node_.data(), &ViewerOutput::sample_rate_changed, this, + &TimeBasedWidget::auto_update_timebase); } // Call derivatives ConnectNodeEvent(viewer_node_.data()); } - UpdateMaximumScroll(); + update_maximum_scroll(); - emit ConnectedNodeChanged(old, node); + emit connected_node_changed(old, node); } -void TimeBasedWidget::ConnectWorkArea(TimelineWorkArea *workarea) +void TimeBasedWidget::connect_work_area(TimelineWorkArea *workarea) { workarea_ = workarea; - ruler()->SetWorkArea(workarea); - scrollbar_->ConnectWorkArea(workarea); + ruler()->set_work_area(workarea); + scrollbar_->connect_work_area(workarea); } -void TimeBasedWidget::ConnectMarkers(TimelineMarkerList *markers) +void TimeBasedWidget::connect_markers(TimelineMarkerList *markers) { markers_ = markers; - ruler()->SetMarkers(markers); - scrollbar_->ConnectMarkers(markers); + ruler()->set_markers(markers); + scrollbar_->connect_markers(markers); } -void TimeBasedWidget::UpdateMaximumScroll() +void TimeBasedWidget::update_maximum_scroll() { - rational length = (viewer_node_) ? viewer_node_->GetLength() : 0; + Rational length = (viewer_node_) ? viewer_node_->get_length() : 0; if (auto_max_scrollbar_) { scrollbar_->setMaximum( - std::max(0, int(std::ceil(TimeToScene(length)) - width()))); + std::max(0, int(std::ceil(time_to_scene(length)) - width()))); } foreach (TimeBasedView *base, timeline_views_) { - base->SetEndTime(length); + base->set_end_time(length); } } -void TimeBasedWidget::ScrollBarResizeBegan(int current_bar_width, +void TimeBasedWidget::scroll_bar_resize_began(int current_bar_width, bool top_handle) { QScrollBar *bar = static_cast(sender()); scrollbar_start_width_ = current_bar_width; scrollbar_start_value_ = bar->value(); - scrollbar_start_scale_ = GetScale(); + scrollbar_start_scale_ = get_scale(); scrollbar_top_handle_ = top_handle; } -void TimeBasedWidget::ScrollBarResizeMoved(int movement) +void TimeBasedWidget::scroll_bar_resize_moved(int movement) { ResizableScrollBar *bar = static_cast(sender()); @@ -239,34 +239,34 @@ void TimeBasedWidget::ScrollBarResizeMoved(int movement) } } -void TimeBasedWidget::PageScrollToPlayhead() +void TimeBasedWidget::page_scroll_to_playhead() { - if (GetConnectedNode()) { - PageScrollInternal( - qRound(TimeToScene(GetConnectedNode()->GetPlayhead())), true); + if (get_connected_node()) { + page_scroll_internal( + qRound(time_to_scene(get_connected_node()->get_playhead())), true); } } -void TimeBasedWidget::CatchUpScrollToPlayhead() +void TimeBasedWidget::catch_up_scroll_to_playhead() { - if (GetConnectedNode()) { - CatchUpScrollToPoint( - qRound(TimeToScene(GetConnectedNode()->GetPlayhead()))); + if (get_connected_node()) { + catch_up_scroll_to_point( + qRound(time_to_scene(get_connected_node()->get_playhead()))); } } -void TimeBasedWidget::CatchUpScrollToPoint(int point) +void TimeBasedWidget::catch_up_scroll_to_point(int point) { - PageScrollInternal(point, false); + page_scroll_internal(point, false); } -void TimeBasedWidget::CatchUpTimerTimeout() +void TimeBasedWidget::catch_up_timer_timeout() { for (auto it = catchup_scroll_values_.cbegin(); it != catchup_scroll_values_.cend(); it++) { QScrollBar *sb = it.key(); const CatchUpScrollData &d = it.value(); - PageScrollInternal(sb, d.maximum, sb->value() + d.value, false); + page_scroll_internal(sb, d.maximum, sb->value() + d.value, false); } SendCatchUpScrollEvent(); @@ -279,32 +279,32 @@ void TimeBasedWidget::SendCatchUpScrollEvent() } } -void TimeBasedWidget::AutoUpdateTimebase() +void TimeBasedWidget::auto_update_timebase() { if (!viewer_node_) { - SetTimebase(rational()); + SetTimebase(Rational()); return; } - rational video_tb = - viewer_node_->GetVideoParams().frame_rate_as_time_base(); + Rational video_tb = + viewer_node_->get_video_params().frame_rate_as_time_base(); if (!video_tb.isNull()) { SetTimebase(video_tb); } else { - rational audio_tb = - viewer_node_->GetAudioParams().sample_rate_as_time_base(); + Rational audio_tb = + viewer_node_->get_audio_params().sample_rate_as_time_base(); if (!audio_tb.isNull()) { SetTimebase(audio_tb); } else { - SetTimebase(rational()); + SetTimebase(Rational()); } } } -void TimeBasedWidget::ConnectedNodeRemovedFromGraph() +void TimeBasedWidget::connected_node_removed_from_graph() { - ConnectViewerNode(nullptr); + connect_viewer_node(nullptr); } TimeRuler *TimeBasedWidget::ruler() const @@ -317,24 +317,24 @@ ResizableTimelineScrollBar *TimeBasedWidget::scrollbar() const return scrollbar_; } -void TimeBasedWidget::TimebaseChangedEvent(const rational &timebase) +void TimeBasedWidget::TimebaseChangedEvent(const Rational &timebase) { TimelineScaledWidget::TimebaseChangedEvent(timebase); - ruler_->SetTimebase(timebase); - scrollbar_->SetTimebase(timebase); + ruler_->set_timebase(timebase); + scrollbar_->set_timebase(timebase); - emit TimebaseChanged(timebase); + emit timebase_changed(timebase); } void TimeBasedWidget::ScaleChangedEvent(const double &scale) { TimelineScaledWidget::ScaleChangedEvent(scale); - ruler_->SetScale(scale); + ruler_->set_scale(scale); scrollbar_->SetScale(scale); - UpdateMaximumScroll(); + update_maximum_scroll(); QMetaObject::invokeMethod(this, &TimeBasedWidget::SendCatchUpScrollEvent, Qt::QueuedConnection); @@ -342,7 +342,7 @@ void TimeBasedWidget::ScaleChangedEvent(const double &scale) toggle_show_all_ = false; } -void TimeBasedWidget::SetAutoMaxScrollBar(bool e) +void TimeBasedWidget::set_auto_max_scroll_bar(bool e) { auto_max_scrollbar_ = e; } @@ -354,13 +354,13 @@ void TimeBasedWidget::resizeEvent(QResizeEvent *event) // Update horizontal scrollbar's page step to the width of the panel scrollbar()->setPageStep(scrollbar()->width()); - UpdateMaximumScroll(); + update_maximum_scroll(); } -void TimeBasedWidget::ConnectTimelineView(TimeBasedView *base) +void TimeBasedWidget::connect_timeline_view(TimeBasedView *base) { // Connect scale - connect(base, &TimeBasedView::ScaleChanged, this, + connect(base, &TimeBasedView::scale_changed, this, &TimeBasedWidget::SetScale); // Main scrollbar to view scrollbar and vice versa @@ -380,7 +380,7 @@ void TimeBasedWidget::ConnectTimelineView(TimeBasedView *base) timeline_views_.append(base); } -void TimeBasedWidget::SetCatchUpScrollValue(QScrollBar *b, int v, int maximum) +void TimeBasedWidget::set_catch_up_scroll_value(QScrollBar *b, int v, int maximum) { CatchUpScrollData &cudata = catchup_scroll_values_[b]; cudata.value = v; @@ -389,7 +389,7 @@ void TimeBasedWidget::SetCatchUpScrollValue(QScrollBar *b, int v, int maximum) static const qint64 min_cooldown = 100; // Hardcoded 1/10 sec cooldown if (QDateTime::currentMSecsSinceEpoch() - cudata.last_forced >= min_cooldown) { - QMetaObject::invokeMethod(this, &TimeBasedWidget::CatchUpTimerTimeout, + QMetaObject::invokeMethod(this, &TimeBasedWidget::catch_up_timer_timeout, Qt::QueuedConnection); cudata.last_forced = QDateTime::currentMSecsSinceEpoch(); } @@ -399,12 +399,12 @@ void TimeBasedWidget::SetCatchUpScrollValue(QScrollBar *b, int v, int maximum) } } -void TimeBasedWidget::SetCatchUpScrollValue(int v) +void TimeBasedWidget::set_catch_up_scroll_value(int v) { - SetCatchUpScrollValue(scrollbar_, v, ruler()->width()); + set_catch_up_scroll_value(scrollbar_, v, ruler()->width()); } -void TimeBasedWidget::StopCatchUpScrollTimer(QScrollBar *b) +void TimeBasedWidget::stop_catch_up_scroll_timer(QScrollBar *b) { catchup_scroll_values_.remove(b); if (catchup_scroll_values_.empty()) { @@ -412,24 +412,24 @@ void TimeBasedWidget::StopCatchUpScrollTimer(QScrollBar *b) } } -void TimeBasedWidget::PlayheadTimeChanged(const rational &time) +void TimeBasedWidget::playhead_time_changed(const Rational &time) { - if (UserIsDraggingPlayhead()) { + if (user_is_dragging_playhead()) { // If the user is dragging the playhead, we will simply nudge over and not use autoscroll rules. - SetCatchUpScrollValue(qRound(TimeToScene(time)) - scrollbar_->value()); + set_catch_up_scroll_value(qRound(time_to_scene(time)) - scrollbar_->value()); } else { // Otherwise, assume we jumped to this out of nowhere and must now autoscroll switch (static_cast( - OLIVE_CONFIG("Autoscroll").toInt())) { - case AutoScroll::kNone: + OAK_CONFIG("Autoscroll").toInt())) { + case AutoScroll::k_none: // Do nothing break; - case AutoScroll::kPage: - QMetaObject::invokeMethod(this, "PageScrollToPlayhead", + case AutoScroll::k_page: + QMetaObject::invokeMethod(this, "page_scroll_to_playhead", Qt::QueuedConnection); break; - case AutoScroll::kSmooth: - QMetaObject::invokeMethod(this, "CenterScrollOnPlayhead", + case AutoScroll::k_smooth: + QMetaObject::invokeMethod(this, "center_scroll_on_playhead", Qt::QueuedConnection); break; } @@ -438,28 +438,28 @@ void TimeBasedWidget::PlayheadTimeChanged(const rational &time) TimeChangedEvent(time); } -void TimeBasedWidget::SetTimebase(const rational &timebase) +void TimeBasedWidget::SetTimebase(const Rational &timebase) { - TimelineScaledWidget::SetTimebase(timebase); + TimelineScaledWidget::set_timebase(timebase); } void TimeBasedWidget::SetScale(const double &scale) { // Simple QObject slot wrapper around TimelineScaledWidget::SetScale() - TimelineScaledWidget::SetScale(scale); + TimelineScaledWidget::set_scale(scale); } -void TimeBasedWidget::ZoomIn() +void TimeBasedWidget::zoom_in() { - SetScaleAndCenterOnPlayhead(GetScale() * 2); + set_scale_and_center_on_playhead(get_scale() * 2); } -void TimeBasedWidget::ZoomOut() +void TimeBasedWidget::zoom_out() { - SetScaleAndCenterOnPlayhead(GetScale() * 0.5); + set_scale_and_center_on_playhead(get_scale() * 0.5); } -void TimeBasedWidget::GoToPrevCut() +void TimeBasedWidget::go_to_prev_cut() { // Cuts are only possible in sequences Sequence *sequence = dynamic_cast(viewer_node_.data()); @@ -468,17 +468,17 @@ void TimeBasedWidget::GoToPrevCut() return; } - if (GetConnectedNode()->GetPlayhead().isNull()) { + if (get_connected_node()->get_playhead().isNull()) { return; } - rational closest_cut = 0; + Rational closest_cut = 0; - for (Track *track : sequence->GetTracks()) { - rational this_track_closest_cut = 0; + for (Track *track : sequence->get_tracks()) { + Rational this_track_closest_cut = 0; - for (Block *block : track->Blocks()) { - if (block->out() < GetConnectedNode()->GetPlayhead()) { + for (Block *block : track->blocks()) { + if (block->out() < get_connected_node()->get_playhead()) { this_track_closest_cut = block->out(); } else { break; @@ -488,10 +488,10 @@ void TimeBasedWidget::GoToPrevCut() closest_cut = qMax(closest_cut, this_track_closest_cut); } - GetConnectedNode()->SetPlayhead(closest_cut); + get_connected_node()->set_playhead(closest_cut); } -void TimeBasedWidget::GoToNextCut() +void TimeBasedWidget::go_to_next_cut() { // Cuts are only possible in sequences Sequence *sequence = dynamic_cast(viewer_node_.data()); @@ -500,17 +500,17 @@ void TimeBasedWidget::GoToNextCut() return; } - rational closest_cut = RATIONAL_MAX; + Rational closest_cut = RATIONAL_MAX; - for (Track *track : sequence->GetTracks()) { - rational this_track_closest_cut = track->track_length(); + for (Track *track : sequence->get_tracks()) { + Rational this_track_closest_cut = track->track_length(); - if (this_track_closest_cut <= GetConnectedNode()->GetPlayhead()) { + if (this_track_closest_cut <= get_connected_node()->get_playhead()) { this_track_closest_cut = RATIONAL_MAX; } - for (Block *block : track->Blocks()) { - if (block->in() > GetConnectedNode()->GetPlayhead()) { + for (Block *block : track->blocks()) { + if (block->in() > get_connected_node()->get_playhead()) { this_track_closest_cut = block->in(); break; } @@ -520,74 +520,74 @@ void TimeBasedWidget::GoToNextCut() } if (closest_cut < RATIONAL_MAX) { - GetConnectedNode()->SetPlayhead(closest_cut); + get_connected_node()->set_playhead(closest_cut); } } -void TimeBasedWidget::GoToStart() +void TimeBasedWidget::go_to_start() { if (viewer_node_) { - viewer_node_->SetPlayhead(0); + viewer_node_->set_playhead(0); } } -void TimeBasedWidget::PrevFrame() +void TimeBasedWidget::prev_frame() { if (viewer_node_) { - rational proposed_time = Timecode::snap_time_to_timebase( - GetConnectedNode()->GetPlayhead() - timebase(), timebase(), - Timecode::kCeil); - if (proposed_time == GetConnectedNode()->GetPlayhead()) { + Rational proposed_time = Timecode::snap_time_to_timebase( + get_connected_node()->get_playhead() - timebase(), timebase(), + Timecode::k_ceil); + if (proposed_time == get_connected_node()->get_playhead()) { // Catch rounding error, assume this time is snapped and just subtract a timebase proposed_time -= timebase(); } - viewer_node_->SetPlayhead(qMax(rational(0), proposed_time)); + viewer_node_->set_playhead(qMax(Rational(0), proposed_time)); } } -void TimeBasedWidget::NextFrame() +void TimeBasedWidget::next_frame() { if (viewer_node_) { - rational proposed_time = Timecode::snap_time_to_timebase( - GetConnectedNode()->GetPlayhead() + timebase(), timebase(), - Timecode::kFloor); - if (proposed_time == GetConnectedNode()->GetPlayhead()) { + Rational proposed_time = Timecode::snap_time_to_timebase( + get_connected_node()->get_playhead() + timebase(), timebase(), + Timecode::k_floor); + if (proposed_time == get_connected_node()->get_playhead()) { // Catch rounding error, assume this time is snapped and just add a timebase proposed_time += timebase(); } - viewer_node_->SetPlayhead(proposed_time); + viewer_node_->set_playhead(proposed_time); } } -void TimeBasedWidget::GoToEnd() +void TimeBasedWidget::go_to_end() { if (viewer_node_) { - viewer_node_->SetPlayhead(viewer_node_->GetLength()); + viewer_node_->set_playhead(viewer_node_->get_length()); } } -void TimeBasedWidget::CenterScrollOnPlayhead() +void TimeBasedWidget::center_scroll_on_playhead() { - if (GetConnectedNode()) { + if (get_connected_node()) { scrollbar_->setValue( - qRound(TimeToScene(GetConnectedNode()->GetPlayhead())) - + qRound(time_to_scene(get_connected_node()->get_playhead())) - scrollbar_->width() / 2); } } -void TimeBasedWidget::SetAutoSetTimebase(bool e) +void TimeBasedWidget::set_auto_set_timebase(bool e) { auto_set_timebase_ = e; } -void TimeBasedWidget::SetPoint(Timeline::MovementMode m, const rational &time) +void TimeBasedWidget::set_point(Timeline::MovementMode m, const Rational &time) { if (!viewer_node_) { return; } MultiUndoCommand *command = new MultiUndoCommand(); - TimelineWorkArea *points = viewer_node_->GetWorkArea(); + TimelineWorkArea *points = viewer_node_->get_work_area(); // Enable workarea if it isn't already enabled if (!points->enabled()) { @@ -596,13 +596,13 @@ void TimeBasedWidget::SetPoint(Timeline::MovementMode m, const rational &time) } // Determine our new range - rational in_point, out_point; + Rational in_point, out_point; - if (m == Timeline::kTrimIn) { + if (m == Timeline::k_trim_in) { in_point = time; if (!points->enabled() || points->out() < in_point) { - out_point = TimelineWorkArea::kResetOut; + out_point = TimelineWorkArea::k_reset_out; } else { out_point = points->out(); } @@ -610,7 +610,7 @@ void TimeBasedWidget::SetPoint(Timeline::MovementMode m, const rational &time) out_point = time; if (!points->enabled() || points->in() > out_point) { - in_point = TimelineWorkArea::kResetIn; + in_point = TimelineWorkArea::k_reset_in; } else { in_point = points->in(); } @@ -623,13 +623,13 @@ void TimeBasedWidget::SetPoint(Timeline::MovementMode m, const rational &time) Core::instance()->undo_stack()->push(command, tr("Set In/Out Point")); } -void TimeBasedWidget::ResetPoint(Timeline::MovementMode m) +void TimeBasedWidget::reset_point(Timeline::MovementMode m) { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } - TimelineWorkArea *points = GetConnectedNode()->GetWorkArea(); + TimelineWorkArea *points = get_connected_node()->get_work_area(); if (!points->enabled()) { return; @@ -637,17 +637,17 @@ void TimeBasedWidget::ResetPoint(Timeline::MovementMode m) TimeRange r = points->range(); - if (m == Timeline::kTrimIn) { - r.set_in(TimelineWorkArea::kResetIn); + if (m == Timeline::k_trim_in) { + r.set_in(TimelineWorkArea::k_reset_in); } else { - r.set_out(TimelineWorkArea::kResetOut); + r.set_out(TimelineWorkArea::k_reset_out); } Core::instance()->undo_stack()->push(new WorkareaSetRangeCommand(points, r), tr("Reset In/Out Points")); } -void TimeBasedWidget::PageScrollInternal(QScrollBar *bar, int maximum, +void TimeBasedWidget::page_scroll_internal(QScrollBar *bar, int maximum, int screen_position, bool whole_page_scroll) { @@ -672,17 +672,17 @@ void TimeBasedWidget::PageScrollInternal(QScrollBar *bar, int maximum, } } -void TimeBasedWidget::PageScrollInternal(int screen_position, +void TimeBasedWidget::page_scroll_internal(int screen_position, bool whole_page_scroll) { - PageScrollInternal(scrollbar(), ruler()->width(), screen_position, + page_scroll_internal(scrollbar(), ruler()->width(), screen_position, whole_page_scroll); } -bool TimeBasedWidget::UserIsDraggingPlayhead() const +bool TimeBasedWidget::user_is_dragging_playhead() const { foreach (TimeBasedView *view, timeline_views_) { - if (view->IsDraggingPlayhead()) { + if (view->is_dragging_playhead()) { return true; } } @@ -690,68 +690,68 @@ bool TimeBasedWidget::UserIsDraggingPlayhead() const return false; } -void TimeBasedWidget::SetInAtPlayhead() +void TimeBasedWidget::set_in_at_playhead() { - SetPoint(Timeline::kTrimIn, GetConnectedNode()->GetPlayhead()); + set_point(Timeline::k_trim_in, get_connected_node()->get_playhead()); } -void TimeBasedWidget::SetOutAtPlayhead() +void TimeBasedWidget::set_out_at_playhead() { - SetPoint(Timeline::kTrimOut, GetConnectedNode()->GetPlayhead()); + set_point(Timeline::k_trim_out, get_connected_node()->get_playhead()); } -void TimeBasedWidget::ResetIn() +void TimeBasedWidget::reset_in() { - ResetPoint(Timeline::kTrimIn); + reset_point(Timeline::k_trim_in); } -void TimeBasedWidget::ResetOut() +void TimeBasedWidget::reset_out() { - ResetPoint(Timeline::kTrimOut); + reset_point(Timeline::k_trim_out); } -void TimeBasedWidget::ClearInOutPoints() +void TimeBasedWidget::clear_in_out_points() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } Core::instance()->undo_stack()->push( - new WorkareaSetEnabledCommand(GetConnectedNode()->project(), - GetConnectedNode()->GetWorkArea(), false), + new WorkareaSetEnabledCommand(get_connected_node()->project(), + get_connected_node()->get_work_area(), false), tr("Cleared In/Out Points")); } -void TimeBasedWidget::SetMarker() +void TimeBasedWidget::set_marker() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } - TimelineMarkerList *markers = GetConnectedNode()->GetMarkers(); + TimelineMarkerList *markers = get_connected_node()->get_markers(); if (TimelineMarker *existing = - markers->GetMarkerAtTime(GetConnectedNode()->GetPlayhead())) { + markers->get_marker_at_time(get_connected_node()->get_playhead())) { // We already have a marker here, so pop open the edit dialog MarkerPropertiesDialog mpd({ existing }, timebase(), this); mpd.exec(); } else { // Create a new marker and place it here int color; - if (TimelineMarker *closest = markers->GetClosestMarkerToTime( - GetConnectedNode()->GetPlayhead())) { + if (TimelineMarker *closest = markers->get_closest_marker_to_time( + get_connected_node()->get_playhead())) { // Copy color of closest marker to this time color = closest->color(); } else { // Fallback to default color in preferences - color = OLIVE_CONFIG("MarkerColor").toInt(); + color = OAK_CONFIG("MarkerColor").toInt(); } TimelineMarker *marker = new TimelineMarker( - color, TimeRange(GetConnectedNode()->GetPlayhead(), - GetConnectedNode()->GetPlayhead())); + color, TimeRange(get_connected_node()->get_playhead(), + get_connected_node()->get_playhead())); - if (OLIVE_CONFIG("SetNameWithMarker").toBool()) { + if (OAK_CONFIG("SetNameWithMarker").toBool()) { MarkerPropertiesDialog mpd({ marker }, timebase(), this); if (mpd.exec() != QDialog::Accepted) { delete marker; @@ -766,9 +766,9 @@ void TimeBasedWidget::SetMarker() } } -void TimeBasedWidget::ToggleShowAll() +void TimeBasedWidget::toggle_show_all() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } @@ -786,10 +786,10 @@ void TimeBasedWidget::ToggleShowAll() w = timeline_views_.first()->width(); } - toggle_show_all_old_scale_ = GetScale(); + toggle_show_all_old_scale_ = get_scale(); toggle_show_all_old_scroll_ = scrollbar_->value(); - SetScaleFromDimensions(w, GetConnectedNode()->GetLength().toDouble()); + set_scale_from_dimensions(w, get_connected_node()->get_length().to_double()); scrollbar_->setValue(0); // Must explicitly do this because SetScale() will automatically set this to false @@ -797,98 +797,98 @@ void TimeBasedWidget::ToggleShowAll() } } -void TimeBasedWidget::GoToIn() +void TimeBasedWidget::go_to_in() { - if (GetConnectedNode()) { - if (GetConnectedNode()->GetWorkArea()->enabled()) { - GetConnectedNode()->SetPlayhead( - GetConnectedNode()->GetWorkArea()->in()); + if (get_connected_node()) { + if (get_connected_node()->get_work_area()->enabled()) { + get_connected_node()->set_playhead( + get_connected_node()->get_work_area()->in()); } else { - GoToStart(); + go_to_start(); } } } -void TimeBasedWidget::GoToOut() +void TimeBasedWidget::go_to_out() { - if (GetConnectedNode()) { - if (GetConnectedNode()->GetWorkArea()->enabled()) { - GetConnectedNode()->SetPlayhead( - GetConnectedNode()->GetWorkArea()->out()); + if (get_connected_node()) { + if (get_connected_node()->get_work_area()->enabled()) { + get_connected_node()->set_playhead( + get_connected_node()->get_work_area()->out()); } else { - GoToEnd(); + go_to_end(); } } } -void TimeBasedWidget::DeleteSelected() +void TimeBasedWidget::delete_selected() { - if (ruler_->HasItemsSelected()) { - ruler_->DeleteSelected(); + if (ruler_->has_items_selected()) { + ruler_->delete_selected(); } } struct SnapData { - rational time; - rational movement; + Rational time; + Rational movement; }; -void AttemptSnap(std::vector &snap_data, +void attempt_snap(std::vector &snap_data, const std::vector &screen_pt, double compare_pt, - const std::vector &start_times, - const rational &compare_time) + const std::vector &start_times, + const Rational &compare_time) { - const qreal kSnapRange = 10; // FIXME: Hardcoded number + const qreal k_snap_range = 10; // FIXME: Hardcoded number for (size_t i = 0; i < screen_pt.size(); i++) { // Attempt snapping to clip out point - if (InRange(screen_pt.at(i), compare_pt, kSnapRange)) { + if (in_range(screen_pt.at(i), compare_pt, k_snap_range)) { snap_data.push_back( { compare_time, compare_time - start_times.at(i) }); } } } -bool TimeBasedWidget::SnapPoint(const std::vector &start_times, - rational *movement, SnapMask snap_points) +bool TimeBasedWidget::snap_point(const std::vector &start_times, + Rational *movement, SnapMask snap_points) { std::vector screen_pt(start_times.size()); for (size_t i = 0; i < start_times.size(); i++) { - screen_pt[i] = TimeToScene(start_times.at(i) + *movement); + screen_pt[i] = time_to_scene(start_times.at(i) + *movement); } std::vector potential_snaps; - if (snap_points & kSnapToPlayhead) { - rational playhead_abs_time = GetConnectedNode()->GetPlayhead(); - qreal playhead_pos = TimeToScene(playhead_abs_time); - AttemptSnap(potential_snaps, screen_pt, playhead_pos, start_times, + if (snap_points & k_snap_to_playhead) { + Rational playhead_abs_time = get_connected_node()->get_playhead(); + qreal playhead_pos = time_to_scene(playhead_abs_time); + attempt_snap(potential_snaps, screen_pt, playhead_pos, start_times, playhead_abs_time); } - if ((snap_points & kSnapToClips) && GetSnapBlocks()) { - for (auto it = GetSnapBlocks()->cbegin(); it != GetSnapBlocks()->cend(); + if ((snap_points & k_snap_to_clips) && get_snap_blocks()) { + for (auto it = get_snap_blocks()->cbegin(); it != get_snap_blocks()->cend(); it++) { Block *b = *it; - qreal rect_left = TimeToScene(b->in()); - qreal rect_right = TimeToScene(b->out()); + qreal rect_left = time_to_scene(b->in()); + qreal rect_right = time_to_scene(b->out()); // Attempt snapping to clip in point - AttemptSnap(potential_snaps, screen_pt, rect_left, start_times, + attempt_snap(potential_snaps, screen_pt, rect_left, start_times, b->in()); // Attempt snapping to clip out point - AttemptSnap(potential_snaps, screen_pt, rect_right, start_times, + attempt_snap(potential_snaps, screen_pt, rect_right, start_times, b->out()); - if (snap_points & kSnapToMarkers) { + if (snap_points & k_snap_to_markers) { // Snap to clip markers too if (ClipBlock *clip = dynamic_cast(b)) { if (clip->connected_viewer()) { TimelineMarkerList *markers = - clip->connected_viewer()->GetMarkers(); + clip->connected_viewer()->get_markers(); for (auto jt = markers->cbegin(); jt != markers->cend(); jt++) { TimelineMarker *marker = *jt; @@ -897,14 +897,14 @@ bool TimeBasedWidget::SnapPoint(const std::vector &start_times, marker->time() + clip->in() - clip->media_in(); qreal marker_in_screen = - TimeToScene(marker_range.in()); + time_to_scene(marker_range.in()); qreal marker_out_screen = - TimeToScene(marker_range.out()); + time_to_scene(marker_range.out()); - AttemptSnap(potential_snaps, screen_pt, + attempt_snap(potential_snaps, screen_pt, marker_in_screen, start_times, marker_range.in()); - AttemptSnap(potential_snaps, screen_pt, + attempt_snap(potential_snaps, screen_pt, marker_out_screen, start_times, marker_range.out()); } @@ -914,82 +914,82 @@ bool TimeBasedWidget::SnapPoint(const std::vector &start_times, } } - if ((snap_points & kSnapToMarkers) && ruler()->GetMarkers()) { - for (auto it = ruler()->GetMarkers()->cbegin(); - it != ruler()->GetMarkers()->cend(); it++) { + if ((snap_points & k_snap_to_markers) && ruler()->get_markers()) { + for (auto it = ruler()->get_markers()->cbegin(); + it != ruler()->get_markers()->cend(); it++) { TimelineMarker *m = *it; // Ignore selected markers - if (std::find(ruler()->GetSelectedMarkers().cbegin(), - ruler()->GetSelectedMarkers().cend(), - m) != ruler()->GetSelectedMarkers().cend()) { + if (std::find(ruler()->get_selected_markers().cbegin(), + ruler()->get_selected_markers().cend(), + m) != ruler()->get_selected_markers().cend()) { continue; } - qreal marker_pos = TimeToScene(m->time().in()); - AttemptSnap(potential_snaps, screen_pt, marker_pos, start_times, + qreal marker_pos = time_to_scene(m->time().in()); + attempt_snap(potential_snaps, screen_pt, marker_pos, start_times, m->time().in()); if (m->time().in() != m->time().out()) { - marker_pos = TimeToScene(m->time().out()); - AttemptSnap(potential_snaps, screen_pt, marker_pos, start_times, + marker_pos = time_to_scene(m->time().out()); + attempt_snap(potential_snaps, screen_pt, marker_pos, start_times, m->time().out()); } } } - if ((snap_points & kSnapToWorkarea) && ruler()->GetWorkArea() && - ruler()->GetWorkArea()->enabled()) { - const rational &workarea_in = ruler()->GetWorkArea()->in(); - const rational &workarea_out = ruler()->GetWorkArea()->out(); + if ((snap_points & k_snap_to_workarea) && ruler()->get_work_area() && + ruler()->get_work_area()->enabled()) { + const Rational &workarea_in = ruler()->get_work_area()->in(); + const Rational &workarea_out = ruler()->get_work_area()->out(); - AttemptSnap(potential_snaps, screen_pt, TimeToScene(workarea_in), + attempt_snap(potential_snaps, screen_pt, time_to_scene(workarea_in), start_times, workarea_in); - AttemptSnap(potential_snaps, screen_pt, TimeToScene(workarea_out), + attempt_snap(potential_snaps, screen_pt, time_to_scene(workarea_out), start_times, workarea_out); } - if ((snap_points & kSnapToKeyframes) && GetSnapKeyframes()) { - for (auto it = GetSnapKeyframes()->cbegin(); - it != GetSnapKeyframes()->cend(); it++) { - const QVector &keys = (*it)->GetKeyframes(); + if ((snap_points & k_snap_to_keyframes) && get_snap_keyframes()) { + for (auto it = get_snap_keyframes()->cbegin(); + it != get_snap_keyframes()->cend(); it++) { + const QVector &keys = (*it)->get_keyframes(); for (auto jt = keys.cbegin(); jt != keys.cend(); jt++) { NodeKeyframe *key = *jt; - auto ignore = GetSnapIgnoreKeyframes(); + auto ignore = get_snap_ignore_keyframes(); if (ignore && std::find(ignore->cbegin(), ignore->cend(), key) != ignore->cend()) { continue; } - rational time = key->time(); - if (const TimeTargetObject *target = GetKeyframeTimeTarget()) { + Rational time = key->time(); + if (const TimeTargetObject *target = get_keyframe_time_target()) { if (Node *parent = key->parent()) { - time = target->GetAdjustedTime( - parent, target->GetTimeTarget(), time, - Node::kTransformTowardsOutput); + time = target->get_adjusted_time( + parent, target->get_time_target(), time, + Node::k_transform_towards_output); } } - qreal key_scene_pt = TimeToScene(time); + qreal key_scene_pt = time_to_scene(time); - AttemptSnap(potential_snaps, screen_pt, key_scene_pt, + attempt_snap(potential_snaps, screen_pt, key_scene_pt, start_times, time); } } } if (potential_snaps.empty()) { - HideSnaps(); + hide_snaps(); return false; } int closest_snap = 0; - rational closest_diff = qAbs(potential_snaps.at(0).movement - *movement); + Rational closest_diff = qAbs(potential_snaps.at(0).movement - *movement); // Determine which snap point was the closest for (size_t i = 1; i < potential_snaps.size(); i++) { - rational this_diff = qAbs(potential_snaps.at(i).movement - *movement); + Rational this_diff = qAbs(potential_snaps.at(i).movement - *movement); if (this_diff < closest_diff) { closest_snap = i; @@ -1000,44 +1000,44 @@ bool TimeBasedWidget::SnapPoint(const std::vector &start_times, *movement = potential_snaps.at(closest_snap).movement; // Find all points at this movement - std::vector snap_times; + std::vector snap_times; foreach (const SnapData &d, potential_snaps) { if (d.movement == *movement) { snap_times.push_back(d.time); } } - ShowSnaps(snap_times); + show_snaps(snap_times); return true; } -void TimeBasedWidget::ShowSnaps(const std::vector ×) +void TimeBasedWidget::show_snaps(const std::vector ×) { foreach (TimeBasedView *view, timeline_views_) { - view->EnableSnap(times); + view->enable_snap(times); } } -void TimeBasedWidget::HideSnaps() +void TimeBasedWidget::hide_snaps() { foreach (TimeBasedView *view, timeline_views_) { - view->DisableSnap(); + view->disable_snap(); } } -bool TimeBasedWidget::CopySelected(bool cut) +bool TimeBasedWidget::copy_selected(bool cut) { - if (ruler()->CopySelected(cut)) { + if (ruler()->copy_selected(cut)) { return true; } return false; } -bool TimeBasedWidget::Paste() +bool TimeBasedWidget::paste() { - if (ruler()->PasteMarkers()) { + if (ruler()->paste_markers()) { return true; } diff --git a/app/widget/timebased/timebasedwidget.h b/app/widget/timebased/timebasedwidget.h index 212406656..d57388496 100644 --- a/app/widget/timebased/timebasedwidget.h +++ b/app/widget/timebased/timebasedwidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMEBASEDWIDGET_H -#define TIMEBASEDWIDGET_H +#ifndef OAK_TIMEBASEDWIDGET_H +#define OAK_TIMEBASEDWIDGET_H #include #include @@ -45,94 +45,94 @@ public: bool ruler_cache_status_visible = false, QWidget *parent = nullptr); - void ZoomIn(); + void zoom_in(); - void ZoomOut(); + void zoom_out(); - ViewerOutput *GetConnectedNode() const; + ViewerOutput *get_connected_node() const; - void ConnectViewerNode(ViewerOutput *node); + void connect_viewer_node(ViewerOutput *node); - TimelineWorkArea *GetConnectedWorkArea() const + TimelineWorkArea *get_connected_work_area() const { return workarea_; } - TimelineMarkerList *GetConnectedMarkers() const + TimelineMarkerList *get_connected_markers() const { return markers_; } - void ConnectWorkArea(TimelineWorkArea *workarea); - void ConnectMarkers(TimelineMarkerList *markers); + void connect_work_area(TimelineWorkArea *workarea); + void connect_markers(TimelineMarkerList *markers); - void SetScaleAndCenterOnPlayhead(const double &scale); + void set_scale_and_center_on_playhead(const double &scale); TimeRuler *ruler() const; using SnapMask = uint32_t; enum SnapPoints { - kSnapToClips = 0x1, - kSnapToPlayhead = 0x2, - kSnapToMarkers = 0x4, - kSnapToKeyframes = 0x8, - kSnapToWorkarea = 0x10, - kSnapAll = UINT32_MAX + k_snap_to_clips = 0x1, + k_snap_to_playhead = 0x2, + k_snap_to_markers = 0x4, + k_snap_to_keyframes = 0x8, + k_snap_to_workarea = 0x10, + k_snap_all = UINT32_MAX }; /** * @brief Snaps point `start_point` that is moving by `movement` to currently existing clips */ - bool SnapPoint(const std::vector &start_times, rational *movement, - SnapMask snap_points = kSnapAll); - void ShowSnaps(const std::vector ×); - void HideSnaps(); + bool snap_point(const std::vector &start_times, Rational *movement, + SnapMask snap_points = k_snap_all); + void show_snaps(const std::vector ×); + void hide_snaps(); - virtual bool CopySelected(bool cut); + virtual bool copy_selected(bool cut); - virtual bool Paste(); + virtual bool paste(); public slots: - void SetTimebase(const rational &timebase); + void SetTimebase(const Rational &timebase); void SetScale(const double &scale); - void GoToStart(); + void go_to_start(); - void PrevFrame(); + void prev_frame(); - void NextFrame(); + void next_frame(); - void GoToEnd(); + void go_to_end(); - void GoToPrevCut(); + void go_to_prev_cut(); - void GoToNextCut(); + void go_to_next_cut(); - void SetInAtPlayhead(); + void set_in_at_playhead(); - void SetOutAtPlayhead(); + void set_out_at_playhead(); - void ResetIn(); + void reset_in(); - void ResetOut(); + void reset_out(); - void ClearInOutPoints(); + void clear_in_out_points(); - void SetMarker(); + void set_marker(); - void ToggleShowAll(); + void toggle_show_all(); - void GoToIn(); + void go_to_in(); - void GoToOut(); + void go_to_out(); - void DeleteSelected(); + void delete_selected(); protected: ResizableTimelineScrollBar *scrollbar() const; - virtual void TimebaseChangedEvent(const rational &) override; + virtual void TimebaseChangedEvent(const Rational &) override; - virtual void TimeChangedEvent(const rational &) + virtual void TimeChangedEvent(const Rational &) { } @@ -157,33 +157,33 @@ protected: { } - void SetAutoMaxScrollBar(bool e); + void set_auto_max_scroll_bar(bool e); virtual void resizeEvent(QResizeEvent *event) override; - void ConnectTimelineView(TimeBasedView *base); + void connect_timeline_view(TimeBasedView *base); - void SetCatchUpScrollValue(QScrollBar *b, int v, int maximum); - void StopCatchUpScrollTimer(QScrollBar *b); + void set_catch_up_scroll_value(QScrollBar *b, int v, int maximum); + void stop_catch_up_scroll_timer(QScrollBar *b); - virtual const QVector *GetSnapBlocks() const + virtual const QVector *get_snap_blocks() const { return nullptr; } virtual const QVector * - GetSnapKeyframes() const + get_snap_keyframes() const { return nullptr; } - virtual const TimeTargetObject *GetKeyframeTimeTarget() const + virtual const TimeTargetObject *get_keyframe_time_target() const { return nullptr; } - virtual const std::vector *GetSnapIgnoreKeyframes() const + virtual const std::vector *get_snap_ignore_keyframes() const { return nullptr; } - virtual const std::vector *GetSnapIgnoreMarkers() const + virtual const std::vector *get_snap_ignore_markers() const { return nullptr; } @@ -192,28 +192,28 @@ protected slots: /** * @brief Slot to center the horizontal scroll bar on the playhead's current position */ - void CenterScrollOnPlayhead(); + void center_scroll_on_playhead(); /** * @brief By default, TimeBasedWidget will set the timebase to the viewer node's video timebase. * Set this to false if you want to set your own timebase. */ - void SetAutoSetTimebase(bool e); + void set_auto_set_timebase(bool e); - static void PageScrollInternal(QScrollBar *bar, int maximum, + static void page_scroll_internal(QScrollBar *bar, int maximum, int screen_position, bool whole_page_scroll); - void StopCatchUpScrollTimer() + void stop_catch_up_scroll_timer() { - StopCatchUpScrollTimer(scrollbar_); + stop_catch_up_scroll_timer(scrollbar_); } - void SetCatchUpScrollValue(int v); + void set_catch_up_scroll_value(int v); signals: - void TimebaseChanged(const rational &); + void timebase_changed(const Rational &); - void ConnectedNodeChanged(ViewerOutput *old, ViewerOutput *now); + void connected_node_changed(ViewerOutput *old, ViewerOutput *now); protected slots: virtual void SendCatchUpScrollEvent(); @@ -226,7 +226,7 @@ private: * * Set to kTrimIn or kTrimOut for setting the in point or out point respectively. */ - void SetPoint(Timeline::MovementMode m, const rational &time); + void set_point(Timeline::MovementMode m, const Rational &time); /** * @brief Reset either the in or out point @@ -237,11 +237,11 @@ private: * * Set to kTrimIn or kTrimOut for setting the in point or out point respectively. */ - void ResetPoint(Timeline::MovementMode m); + void reset_point(Timeline::MovementMode m); - void PageScrollInternal(int screen_position, bool whole_page_scroll); + void page_scroll_internal(int screen_position, bool whole_page_scroll); - bool UserIsDraggingPlayhead() const; + bool user_is_dragging_playhead() const; QPointer viewer_node_; @@ -277,11 +277,11 @@ private: QMap catchup_scroll_values_; private slots: - void UpdateMaximumScroll(); + void update_maximum_scroll(); - void ScrollBarResizeBegan(int current_bar_width, bool top_handle); + void scroll_bar_resize_began(int current_bar_width, bool top_handle); - void ScrollBarResizeMoved(int new_bar_width); + void scroll_bar_resize_moved(int new_bar_width); /** * @brief Slot to handle page scrolling of the playhead @@ -289,21 +289,21 @@ private slots: * If the playhead is outside the current scroll bounds, this function will scroll to where it is. Otherwise it will * do nothing. */ - void PageScrollToPlayhead(); + void page_scroll_to_playhead(); - void CatchUpScrollToPlayhead(); + void catch_up_scroll_to_playhead(); - void CatchUpScrollToPoint(int point); + void catch_up_scroll_to_point(int point); - void CatchUpTimerTimeout(); + void catch_up_timer_timeout(); - void AutoUpdateTimebase(); + void auto_update_timebase(); - void ConnectedNodeRemovedFromGraph(); + void connected_node_removed_from_graph(); - void PlayheadTimeChanged(const rational &time); + void playhead_time_changed(const Rational &time); }; } -#endif // TIMEBASEDWIDGET_H +#endif // OAK_TIMEBASEDWIDGET_H diff --git a/app/widget/timebased/timescaledobject.cpp b/app/widget/timebased/timescaledobject.cpp index 3703d9b70..171f61106 100644 --- a/app/widget/timebased/timescaledobject.cpp +++ b/app/widget/timebased/timescaledobject.cpp @@ -29,24 +29,24 @@ namespace olive { -const int TimeScaledObject::kCalculateDimensionsPadding = 10; +const int TimeScaledObject::k_calculate_dimensions_padding = 10; TimeScaledObject::TimeScaledObject() : scale_(1.0) , min_scale_(0) - , max_scale_(AudioVisualWaveform::kMaximumSampleRate.toDouble()) + , max_scale_(AudioVisualWaveform::k_maximum_sample_rate.to_double()) { } -void TimeScaledObject::SetTimebase(const rational &timebase) +void TimeScaledObject::set_timebase(const Rational &timebase) { timebase_ = timebase; - timebase_dbl_ = timebase_.toDouble(); + timebase_dbl_ = timebase_.to_double(); TimebaseChangedEvent(timebase); } -const rational &TimeScaledObject::timebase() const +const Rational &TimeScaledObject::timebase() const { return timebase_; } @@ -56,13 +56,13 @@ const double &TimeScaledObject::timebase_dbl() const return timebase_dbl_; } -rational TimeScaledObject::SceneToTime(const double &x, const double &x_scale, - const rational &timebase, bool round) +Rational TimeScaledObject::scene_to_time(const double &x, const double &x_scale, + const Rational &timebase, bool round) { if (timebase.isNull()) { - return rational(); + return Rational(); } - double unscaled_time = x / x_scale / timebase.toDouble(); + double unscaled_time = x / x_scale / timebase.to_double(); // Adjust screen point by scale and timebase qint64 rounded_x_mvmt; @@ -77,66 +77,66 @@ rational TimeScaledObject::SceneToTime(const double &x, const double &x_scale, } // Return a time in the timebase - return rational(rounded_x_mvmt * timebase.numerator(), + return Rational(rounded_x_mvmt * timebase.numerator(), timebase.denominator()); } -rational TimeScaledObject::SceneToTimeNoGrid(const double &x, +Rational TimeScaledObject::scene_to_time_no_grid(const double &x, const double &x_scale) { double unscaled_time = x / x_scale; - return rational::fromDouble(unscaled_time); + return Rational::from_double(unscaled_time); } -double TimeScaledObject::TimeToScene(const rational &time) const +double TimeScaledObject::time_to_scene(const Rational &time) const { if (timebase_.isNull()) { return 0.0; } - return time.toDouble() * scale_; + return time.to_double() * scale_; } -rational TimeScaledObject::SceneToTime(const double &x, bool round) const +Rational TimeScaledObject::scene_to_time(const double &x, bool round) const { if (timebase_.isNull()) { - return rational(); + return Rational(); } - return SceneToTime(x, scale_, timebase_, round); + return scene_to_time(x, scale_, timebase_, round); } -rational TimeScaledObject::SceneToTimeNoGrid(const double &x) const +Rational TimeScaledObject::scene_to_time_no_grid(const double &x) const { if (timebase_.isNull()) { - return rational::fromDouble(x / scale_); + return Rational::from_double(x / scale_); } - return SceneToTimeNoGrid(x, scale_); + return scene_to_time_no_grid(x, scale_); } -void TimeScaledObject::SetMaximumScale(const double &max) +void TimeScaledObject::set_maximum_scale(const double &max) { max_scale_ = max; - if (GetScale() > max_scale_) { - SetScale(max_scale_); + if (get_scale() > max_scale_) { + set_scale(max_scale_); } } -void TimeScaledObject::SetMinimumScale(const double &min) +void TimeScaledObject::set_minimum_scale(const double &min) { min_scale_ = min; - if (GetScale() < min_scale_) { - SetScale(min_scale_); + if (get_scale() < min_scale_) { + set_scale(min_scale_); } } -const double &TimeScaledObject::GetScale() const +const double &TimeScaledObject::get_scale() const { return scale_; } -void TimeScaledObject::SetScale(const double &scale) +void TimeScaledObject::set_scale(const double &scale) { Q_ASSERT(scale > 0); @@ -145,23 +145,23 @@ void TimeScaledObject::SetScale(const double &scale) ScaleChangedEvent(scale_); } -void TimeScaledObject::SetScaleFromDimensions(double viewport_width, +void TimeScaledObject::set_scale_from_dimensions(double viewport_width, double content_width) { - SetScale(CalculateScaleFromDimensions(viewport_width, content_width)); + set_scale(calculate_scale_from_dimensions(viewport_width, content_width)); } -double TimeScaledObject::CalculateScaleFromDimensions(double viewport_sz, +double TimeScaledObject::calculate_scale_from_dimensions(double viewport_sz, double content_sz) { - return static_cast(viewport_sz / kCalculateDimensionsPadding * - (kCalculateDimensionsPadding - 1)) / + return static_cast(viewport_sz / k_calculate_dimensions_padding * + (k_calculate_dimensions_padding - 1)) / static_cast(content_sz); } -double TimeScaledObject::CalculatePaddingFromDimensionScale(double viewport_sz) +double TimeScaledObject::calculate_padding_from_dimension_scale(double viewport_sz) { - return (viewport_sz / (kCalculateDimensionsPadding * 2)); + return (viewport_sz / (k_calculate_dimensions_padding * 2)); } TimelineScaledWidget::TimelineScaledWidget(QWidget *parent) diff --git a/app/widget/timebased/timescaledobject.h b/app/widget/timebased/timescaledobject.h index f0adb1afc..3c7c98bde 100644 --- a/app/widget/timebased/timescaledobject.h +++ b/app/widget/timebased/timescaledobject.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINESCALEDOBJECT_H -#define TIMELINESCALEDOBJECT_H +#ifndef OAK_TIMELINESCALEDOBJECT_H +#define OAK_TIMELINESCALEDOBJECT_H #include #include @@ -38,34 +38,34 @@ public: TimeScaledObject(); virtual ~TimeScaledObject() = default; - void SetTimebase(const rational &timebase); + void set_timebase(const Rational &timebase); - const rational &timebase() const; + const Rational &timebase() const; const double &timebase_dbl() const; - static rational SceneToTime(const double &x, const double &x_scale, - const rational &timebase, bool round = false); - static rational SceneToTimeNoGrid(const double &x, const double &x_scale); + static Rational scene_to_time(const double &x, const double &x_scale, + const Rational &timebase, bool round = false); + static Rational scene_to_time_no_grid(const double &x, const double &x_scale); - const double &GetScale() const; - const double &GetMaximumScale() const + const double &get_scale() const; + const double &get_maximum_scale() const { return max_scale_; } - void SetScale(const double &scale); + void set_scale(const double &scale); - void SetScaleFromDimensions(double viewport_width, double content_width); - static double CalculateScaleFromDimensions(double viewport_sz, + void set_scale_from_dimensions(double viewport_width, double content_width); + static double calculate_scale_from_dimensions(double viewport_sz, double content_sz); - static double CalculatePaddingFromDimensionScale(double viewport_sz); + static double calculate_padding_from_dimension_scale(double viewport_sz); - double TimeToScene(const rational &time) const; - rational SceneToTime(const double &x, bool round = false) const; - rational SceneToTimeNoGrid(const double &x) const; + double time_to_scene(const Rational &time) const; + Rational scene_to_time(const double &x, bool round = false) const; + Rational scene_to_time_no_grid(const double &x) const; protected: - virtual void TimebaseChangedEvent(const rational &) + virtual void TimebaseChangedEvent(const Rational &) { } @@ -73,12 +73,12 @@ protected: { } - void SetMaximumScale(const double &max); + void set_maximum_scale(const double &max); - void SetMinimumScale(const double &min); + void set_minimum_scale(const double &min); private: - rational timebase_; + Rational timebase_; double timebase_dbl_; @@ -88,7 +88,7 @@ private: double max_scale_; - static const int kCalculateDimensionsPadding; + static const int k_calculate_dimensions_padding; }; class TimelineScaledWidget : public QWidget, public TimeScaledObject { @@ -99,4 +99,4 @@ public: } -#endif // TIMELINESCALEDOBJECT_H +#endif // OAK_TIMELINESCALEDOBJECT_H diff --git a/app/widget/timelinewidget/timelineandtrackview.cpp b/app/widget/timelinewidget/timelineandtrackview.cpp index 558c9bbf5..8d9b87583 100644 --- a/app/widget/timelinewidget/timelineandtrackview.cpp +++ b/app/widget/timelinewidget/timelineandtrackview.cpp @@ -46,9 +46,9 @@ TimelineAndTrackView::TimelineAndTrackView(Qt::Alignment vertical_alignment, splitter_->addWidget(view_); connect(view_->verticalScrollBar(), &QScrollBar::valueChanged, this, - &TimelineAndTrackView::ViewValueChanged); + &TimelineAndTrackView::view_value_changed); connect(track_view_->verticalScrollBar(), &QScrollBar::valueChanged, this, - &TimelineAndTrackView::TracksValueChanged); + &TimelineAndTrackView::tracks_value_changed); splitter_->setSizes({ 1, width() }); } @@ -68,13 +68,13 @@ TrackView *TimelineAndTrackView::track_view() const return track_view_; } -void TimelineAndTrackView::ViewValueChanged(int v) +void TimelineAndTrackView::view_value_changed(int v) { track_view_->verticalScrollBar()->setValue( v - view_->verticalScrollBar()->minimum()); } -void TimelineAndTrackView::TracksValueChanged(int v) +void TimelineAndTrackView::tracks_value_changed(int v) { view_->verticalScrollBar()->setValue(view_->verticalScrollBar()->minimum() + v); diff --git a/app/widget/timelinewidget/timelineandtrackview.h b/app/widget/timelinewidget/timelineandtrackview.h index 77a84a03c..7181aebcd 100644 --- a/app/widget/timelinewidget/timelineandtrackview.h +++ b/app/widget/timelinewidget/timelineandtrackview.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEANDTRACKVIEW_H -#define TIMELINEANDTRACKVIEW_H +#ifndef OAK_TIMELINEANDTRACKVIEW_H +#define OAK_TIMELINEANDTRACKVIEW_H #include #include @@ -50,11 +50,11 @@ private: TrackView *track_view_; private slots: - void ViewValueChanged(int v); + void view_value_changed(int v); - void TracksValueChanged(int v); + void tracks_value_changed(int v); }; } -#endif // TIMELINEANDTRACKVIEW_H +#endif // OAK_TIMELINEANDTRACKVIEW_H diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index f91cfb072..3bb32c0a6 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -78,7 +78,7 @@ namespace olive #define super TimeBasedWidget -using namespace TimelineWaveformSync; +using namespace timeline_waveform_sync; namespace { @@ -86,10 +86,10 @@ namespace struct SourceSyncClip { ClipBlock *clip = nullptr; AudioSynchronizer::SourceClip source; - rational source_head; + Rational source_head; }; -bool GetSourceSyncClip(Block *block, SourceSyncClip *out) +bool get_source_sync_clip(Block *block, SourceSyncClip *out) { ClipBlock *clip = dynamic_cast(block); if (!clip) { @@ -97,7 +97,7 @@ bool GetSourceSyncClip(Block *block, SourceSyncClip *out) } Footage *footage = dynamic_cast(clip->connected_viewer()); - if (!footage || !footage->HasSourceStartTime()) { + if (!footage || !footage->has_source_start_time()) { return false; } @@ -110,19 +110,19 @@ bool GetSourceSyncClip(Block *block, SourceSyncClip *out) } QVector -GetSelectedSourceSyncClips(const QVector &blocks) +get_selected_source_sync_clips(const QVector &blocks) { QVector clips; for (Block *block : blocks) { SourceSyncClip sync_clip; - if (GetSourceSyncClip(block, &sync_clip)) { + if (get_source_sync_clip(block, &sync_clip)) { clips.append(sync_clip); } } return clips; } -QVector GetSelectedProxyFootage(const QVector &blocks) +QVector get_selected_proxy_footage(const QVector &blocks) { QVector footage; for (Block *block : blocks) { @@ -132,7 +132,7 @@ QVector GetSelectedProxyFootage(const QVector &blocks) } Footage *candidate = dynamic_cast(clip->connected_viewer()); - if (!candidate || !candidate->GetFirstEnabledVideoStream().is_valid() || + if (!candidate || !candidate->get_first_enabled_video_stream().is_valid() || footage.contains(candidate)) { continue; } @@ -160,10 +160,10 @@ TimelineWidget::TimelineWidget(QWidget *parent) vert_layout->addLayout(ruler_and_time_layout); timecode_label_ = new RationalSlider(); - timecode_label_->SetAlignment(Qt::AlignCenter); - timecode_label_->SetDisplayType(RationalSlider::kTime); + timecode_label_->set_alignment(Qt::AlignCenter); + timecode_label_->set_display_type(RationalSlider::k_time); timecode_label_->setVisible(false); - timecode_label_->SetMinimum(0); + timecode_label_->set_minimum(0); ruler_and_time_layout->addWidget(timecode_label_); ruler_and_time_layout->addWidget(ruler()); @@ -177,30 +177,30 @@ TimelineWidget::TimelineWidget(QWidget *parent) vert_layout->addWidget(view_splitter_); // Video view - views_.append(AddTimelineAndTrackView(Qt::AlignBottom)); + views_.append(add_timeline_and_track_view(Qt::AlignBottom)); // Audio view - views_.append(AddTimelineAndTrackView(Qt::AlignTop)); + views_.append(add_timeline_and_track_view(Qt::AlignTop)); // Subtitle view - views_.append(AddTimelineAndTrackView(Qt::AlignTop)); + views_.append(add_timeline_and_track_view(Qt::AlignTop)); // Create tools - tools_.resize(olive::Tool::kCount); + tools_.resize(olive::Tool::k_count); tools_.fill(nullptr); - tools_.replace(olive::Tool::kPointer, new PointerTool(this)); - tools_.replace(olive::Tool::kTrackSelect, new TrackSelectTool(this)); - tools_.replace(olive::Tool::kEdit, new EditTool(this)); - tools_.replace(olive::Tool::kRipple, new RippleTool(this)); - tools_.replace(olive::Tool::kRolling, new RollingTool(this)); - tools_.replace(olive::Tool::kRazor, new RazorTool(this)); - tools_.replace(olive::Tool::kSlip, new SlipTool(this)); - tools_.replace(olive::Tool::kSlide, new SlideTool(this)); - tools_.replace(olive::Tool::kZoom, new ZoomTool(this)); - tools_.replace(olive::Tool::kTransition, new TransitionTool(this)); - tools_.replace(olive::Tool::kRecord, new RecordTool(this)); - tools_.replace(olive::Tool::kAdd, new AddTool(this)); + tools_.replace(olive::Tool::k_pointer, new PointerTool(this)); + tools_.replace(olive::Tool::k_track_select, new TrackSelectTool(this)); + tools_.replace(olive::Tool::k_edit, new EditTool(this)); + tools_.replace(olive::Tool::k_ripple, new RippleTool(this)); + tools_.replace(olive::Tool::k_rolling, new RollingTool(this)); + tools_.replace(olive::Tool::k_razor, new RazorTool(this)); + tools_.replace(olive::Tool::k_slip, new SlipTool(this)); + tools_.replace(olive::Tool::k_slide, new SlideTool(this)); + tools_.replace(olive::Tool::k_zoom, new ZoomTool(this)); + tools_.replace(olive::Tool::k_transition, new TransitionTool(this)); + tools_.replace(olive::Tool::k_record, new RecordTool(this)); + tools_.replace(olive::Tool::k_add, new AddTool(this)); import_tool_ = new ImportTool(this); @@ -218,36 +218,36 @@ TimelineWidget::TimelineWidget(QWidget *parent) view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - view->SetSnapService(this); - view->SetSelectionList(&selections_); - view->SetGhostList(&ghost_items_); + view->set_snap_service(this); + view->set_selection_list(&selections_); + view->set_ghost_list(&ghost_items_); view_splitter_->addWidget(tview); - ConnectTimelineView(view); + connect_timeline_view(view); connect(view, &TimelineView::customContextMenuRequested, this, - &TimelineWidget::ShowContextMenu); + &TimelineWidget::show_context_menu); - connect(view, &TimelineView::MousePressed, this, - &TimelineWidget::ViewMousePressed); - connect(view, &TimelineView::MouseMoved, this, - &TimelineWidget::ViewMouseMoved); - connect(view, &TimelineView::MouseReleased, this, - &TimelineWidget::ViewMouseReleased); - connect(view, &TimelineView::MouseDoubleClicked, this, - &TimelineWidget::ViewMouseDoubleClicked); - connect(view, &TimelineView::DragEntered, this, - &TimelineWidget::ViewDragEntered); - connect(view, &TimelineView::DragMoved, this, - &TimelineWidget::ViewDragMoved); - connect(view, &TimelineView::DragLeft, this, - &TimelineWidget::ViewDragLeft); - connect(view, &TimelineView::DragDropped, this, - &TimelineWidget::ViewDragDropped); + connect(view, &TimelineView::mouse_pressed, this, + &TimelineWidget::view_mouse_pressed); + connect(view, &TimelineView::mouse_moved, this, + &TimelineWidget::view_mouse_moved); + connect(view, &TimelineView::mouse_released, this, + &TimelineWidget::view_mouse_released); + connect(view, &TimelineView::mouse_double_clicked, this, + &TimelineWidget::view_mouse_double_clicked); + connect(view, &TimelineView::drag_entered, this, + &TimelineWidget::view_drag_entered); + connect(view, &TimelineView::drag_moved, this, + &TimelineWidget::view_drag_moved); + connect(view, &TimelineView::drag_left, this, + &TimelineWidget::view_drag_left); + connect(view, &TimelineView::drag_dropped, this, + &TimelineWidget::view_drag_dropped); connect(tview->splitter(), &QSplitter::splitterMoved, this, - &TimelineWidget::UpdateHorizontalSplitters); + &TimelineWidget::update_horizontal_splitters); } // Split viewer 50/50 @@ -259,19 +259,19 @@ TimelineWidget::TimelineWidget(QWidget *parent) view_splitter_->setSizes(view_sizes); // Video and audio are not collapsible, subtitle is - view_splitter_->setCollapsible(Track::kVideo, false); - view_splitter_->setCollapsible(Track::kAudio, false); - view_splitter_->setCollapsible(Track::kSubtitle, true); + view_splitter_->setCollapsible(Track::k_video, false); + view_splitter_->setCollapsible(Track::k_audio, false); + view_splitter_->setCollapsible(Track::k_subtitle, true); // FIXME: Magic number SetScale(90.0); - SetAutoSetTimebase(false); + set_auto_set_timebase(false); - connect(Core::instance(), &Core::ToolChanged, this, - &TimelineWidget::ToolChanged); - connect(Core::instance(), &Core::AddableObjectChanged, this, - &TimelineWidget::AddableObjectChanged); + connect(Core::instance(), &Core::tool_changed, this, + &TimelineWidget::tool_changed); + connect(Core::instance(), &Core::addable_object_changed, this, + &TimelineWidget::addable_object_changed); signal_block_change_timer_ = new QTimer(this); signal_block_change_timer_->setInterval(1); @@ -279,50 +279,50 @@ TimelineWidget::TimelineWidget(QWidget *parent) connect(signal_block_change_timer_, &QTimer::timeout, this, [this] { signal_block_change_timer_->stop(); - if (OLIVE_CONFIG("SelectAlsoSeeks").toBool()) { - rational start = RATIONAL_MAX; + if (OAK_CONFIG("SelectAlsoSeeks").toBool()) { + Rational start = RATIONAL_MAX; for (Block *b : selected_blocks_) { start = std::min(start, b->in()); } if (start != RATIONAL_MAX) { - GetConnectedNode()->SetPlayhead(start); + get_connected_node()->set_playhead(start); } } - emit BlockSelectionChanged(selected_blocks_); + emit block_selection_changed(selected_blocks_); }); } TimelineWidget::~TimelineWidget() { // Ensure no blocks are selected before any child widgets are destroyed (prevents corrupt ViewSelectionChanged() signal) - ConnectViewerNode(nullptr); + connect_viewer_node(nullptr); - Clear(); + clear(); qDeleteAll(tools_); delete subtitle_show_command_; } -void TimelineWidget::Clear() +void TimelineWidget::clear() { // Emit that we've deselected any selected blocks - SignalDeselectedAllBlocks(); + signal_deselected_all_blocks(); // Set null timebase SetTimebase(0); } -void TimelineWidget::TimebaseChangedEvent(const rational &timebase) +void TimelineWidget::TimebaseChangedEvent(const Rational &timebase) { super::TimebaseChangedEvent(timebase); - timecode_label_->SetTimebase(timebase); + timecode_label_->set_timebase(timebase); timecode_label_->setVisible(!timebase.isNull()); - UpdateViewTimebases(); + update_view_timebases(); } void TimelineWidget::resizeEvent(QResizeEvent *event) @@ -330,36 +330,36 @@ void TimelineWidget::resizeEvent(QResizeEvent *event) super::resizeEvent(event); // Update timecode label size - UpdateTimecodeWidthFromSplitters(views_.first()->splitter()); + update_timecode_width_from_splitters(views_.first()->splitter()); } -void TimelineWidget::TimeChangedEvent(const rational &t) +void TimelineWidget::TimeChangedEvent(const Rational &t) { - if (OLIVE_CONFIG("SeekAlsoSelects").toBool()) { + if (OAK_CONFIG("SeekAlsoSelects").toBool()) { TimelineWidgetSelections sels; QVector new_blocks; - for (auto it = sequence()->GetTracks().cbegin(); - it != sequence()->GetTracks().cend(); it++) { + for (auto it = sequence()->get_tracks().cbegin(); + it != sequence()->get_tracks().cend(); it++) { Track *track = *it; - if (track->IsLocked()) { + if (track->is_locked()) { continue; } - Block *b = track->VisibleBlockAtTime(sequence()->GetPlayhead()); + Block *b = track->visible_block_at_time(sequence()->get_playhead()); if (!b || dynamic_cast(b)) { continue; } new_blocks.push_back(b); - sels[track->ToReference()].insert(b->range()); + sels[track->to_reference()].insert(b->range()); } if (selected_blocks_ != new_blocks) { selected_blocks_ = new_blocks; - SetSelections(sels, false); - SignalBlockSelectionChange(); + set_selections(sels, false); + signal_block_selection_change(); } } } @@ -369,11 +369,11 @@ void TimelineWidget::ScaleChangedEvent(const double &scale) super::ScaleChangedEvent(scale); foreach (TimelineAndTrackView *view, views_) { - view->view()->SetScale(scale); + view->view()->set_scale(scale); } if (rubberband_.isVisible()) { - QMetaObject::invokeMethod(this, &TimelineWidget::ForceUpdateRubberBand, + QMetaObject::invokeMethod(this, &TimelineWidget::force_update_rubber_band, Qt::QueuedConnection); } } @@ -382,22 +382,22 @@ void TimelineWidget::ConnectNodeEvent(ViewerOutput *n) { Sequence *s = static_cast(n); - connect(s, &Sequence::TrackAdded, this, &TimelineWidget::AddTrack); - connect(s, &Sequence::TrackRemoved, this, &TimelineWidget::RemoveTrack); - connect(s, &Sequence::FrameRateChanged, this, - &TimelineWidget::FrameRateChanged); - connect(s, &Sequence::SampleRateChanged, this, - &TimelineWidget::SampleRateChanged); + connect(s, &Sequence::track_added, this, &TimelineWidget::add_track); + connect(s, &Sequence::track_removed, this, &TimelineWidget::remove_track); + connect(s, &Sequence::frame_rate_changed, this, + &TimelineWidget::frame_rate_changed); + connect(s, &Sequence::sample_rate_changed, this, + &TimelineWidget::sample_rate_changed); - connect(timecode_label_, &RationalSlider::ValueChanged, s, - &Sequence::SetPlayhead); - connect(s, &Sequence::PlayheadChanged, timecode_label_, - &RationalSlider::SetValue); - timecode_label_->SetValue(s->GetPlayhead()); + connect(timecode_label_, &RationalSlider::value_changed, s, + &Sequence::set_playhead); + connect(s, &Sequence::playhead_changed, timecode_label_, + &RationalSlider::set_value); + timecode_label_->set_value(s->get_playhead()); - ruler()->SetPlaybackCache(n->video_frame_cache()); + ruler()->set_playback_cache(n->video_frame_cache()); - SetTimebase(n->GetVideoParams().frame_rate_as_time_base()); + SetTimebase(n->get_video_params().frame_rate_as_time_base()); for (int i = 0; i < views_.size(); i++) { Track::Type track_type = static_cast(i); @@ -405,13 +405,13 @@ void TimelineWidget::ConnectNodeEvent(ViewerOutput *n) TrackList *track_list = s->track_list(track_type); TrackView *track_view = views_.at(i)->track_view(); - track_view->ConnectTrackList(track_list); - view->ConnectTrackList(track_list); + track_view->connect_track_list(track_list); + view->connect_track_list(track_list); // Defer to the track to make all the block UI items necessary - const QVector tracks = s->track_list(track_type)->GetTracks(); + const QVector tracks = s->track_list(track_type)->get_tracks(); foreach (Track *track, tracks) { - AddTrack(track); + add_track(track); } } } @@ -420,31 +420,31 @@ void TimelineWidget::DisconnectNodeEvent(ViewerOutput *n) { Sequence *s = static_cast(n); - disconnect(s, &Sequence::TrackAdded, this, &TimelineWidget::AddTrack); - disconnect(s, &Sequence::TrackRemoved, this, &TimelineWidget::RemoveTrack); - disconnect(s, &Sequence::FrameRateChanged, this, - &TimelineWidget::FrameRateChanged); - disconnect(s, &Sequence::SampleRateChanged, this, - &TimelineWidget::SampleRateChanged); + disconnect(s, &Sequence::track_added, this, &TimelineWidget::add_track); + disconnect(s, &Sequence::track_removed, this, &TimelineWidget::remove_track); + disconnect(s, &Sequence::frame_rate_changed, this, + &TimelineWidget::frame_rate_changed); + disconnect(s, &Sequence::sample_rate_changed, this, + &TimelineWidget::sample_rate_changed); - disconnect(timecode_label_, &RationalSlider::ValueChanged, s, - &Sequence::SetPlayhead); + disconnect(timecode_label_, &RationalSlider::value_changed, s, + &Sequence::set_playhead); - DeselectAll(); + deselect_all(); - foreach (Track *track, s->GetTracks()) { - RemoveTrack(track); + foreach (Track *track, s->get_tracks()) { + remove_track(track); } - ruler()->SetPlaybackCache(nullptr); + ruler()->set_playback_cache(nullptr); SetTimebase(0); - Clear(); + clear(); foreach (TimelineAndTrackView *tview, views_) { - tview->track_view()->DisconnectTrackList(); - tview->view()->ConnectTrackList(nullptr); + tview->track_view()->disconnect_track_list(); + tview->view()->connect_track_list(nullptr); } } @@ -453,65 +453,65 @@ void TimelineWidget::SendCatchUpScrollEvent() super::SendCatchUpScrollEvent(); if (rubberband_.isVisible()) { - this->ForceUpdateRubberBand(); + this->force_update_rubber_band(); } } -void TimelineWidget::SelectAll() +void TimelineWidget::select_all() { QVector newly_selected_blocks; foreach (Block *block, added_blocks_) { if (!selected_blocks_.contains(block)) { newly_selected_blocks.append(block); - AddSelection(block); + add_selection(block); } } - SignalSelectedBlocks(newly_selected_blocks, false); + signal_selected_blocks(newly_selected_blocks, false); } -void TimelineWidget::DeselectAll() +void TimelineWidget::deselect_all() { // Clear selections selections_.clear(); // Update all viewports - UpdateViewports(); + update_viewports(); // Clear list and emit signal - SignalDeselectedAllBlocks(); + signal_deselected_all_blocks(); } -void TimelineWidget::RippleToIn() +void TimelineWidget::ripple_to_in() { - RippleTo(Timeline::kTrimIn); + ripple_to(Timeline::k_trim_in); } -void TimelineWidget::RippleToOut() +void TimelineWidget::ripple_to_out() { - RippleTo(Timeline::kTrimOut); + ripple_to(Timeline::k_trim_out); } -void TimelineWidget::EditToIn() +void TimelineWidget::edit_to_in() { - EditTo(Timeline::kTrimIn); + edit_to(Timeline::k_trim_in); } -void TimelineWidget::EditToOut() +void TimelineWidget::edit_to_out() { - EditTo(Timeline::kTrimOut); + edit_to(Timeline::k_trim_out); } -void TimelineWidget::SplitAtPlayhead() +void TimelineWidget::split_at_playhead() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } - const rational &playhead_time = GetConnectedNode()->GetPlayhead(); + const Rational &playhead_time = get_connected_node()->get_playhead(); - QVector selected_blocks = GetSelectedBlocks(); + QVector selected_blocks = get_selected_blocks(); // Prioritize blocks that are selected and overlap the playhead QVector blocks_to_split; @@ -520,12 +520,12 @@ void TimelineWidget::SplitAtPlayhead() bool some_blocks_are_selected = false; // Get all blocks at the playhead - foreach (Track *track, sequence()->GetTracks()) { - if (track->IsLocked()) { + foreach (Track *track, sequence()->get_tracks()) { + if (track->is_locked()) { continue; } - Block *b = track->BlockContainingTime(playhead_time); + Block *b = track->block_containing_time(playhead_time); if (dynamic_cast(b)) { bool selected = false; @@ -563,7 +563,7 @@ void TimelineWidget::SplitAtPlayhead() } } -void TimelineWidget::ReplaceBlocksWithGaps(const QVector &blocks, +void TimelineWidget::replace_blocks_with_gaps(const QVector &blocks, bool remove_from_graph, MultiUndoCommand *command, bool handle_transitions) @@ -589,12 +589,12 @@ void TimelineWidget::ReplaceBlocksWithGaps(const QVector &blocks, void TimelineWidget::DeleteSelected(bool ripple) { - if (ruler()->HasItemsSelected()) { - ruler()->DeleteSelected(); + if (ruler()->has_items_selected()) { + ruler()->delete_selected(); return; } - QVector selected_list = GetSelectedBlocks(); + QVector selected_list = get_selected_blocks(); // No-op if nothing is selected if (selected_list.isEmpty()) { @@ -626,7 +626,7 @@ void TimelineWidget::DeleteSelected(bool ripple) // Remove all selections command->add_child(new SetSelectionsCommand( - this, TimelineWidgetSelections(), GetSelections())); + this, TimelineWidgetSelections(), get_selections())); // For transitions, remove them but extend their attached blocks to fill their place foreach (TransitionBlock *transition, transitions_to_delete) { @@ -640,11 +640,11 @@ void TimelineWidget::DeleteSelected(bool ripple) } // Replace clips with gaps (effectively deleting them) - ReplaceBlocksWithGaps(clips_to_delete, true, command, false); + replace_blocks_with_gaps(clips_to_delete, true, command, false); // Insert ripple command now that it's all cleaned up gaps TimelineRippleDeleteGapsAtRegionsCommand *ripple_command = nullptr; - rational new_playhead = RATIONAL_MAX; + Rational new_playhead = RATIONAL_MAX; if (ripple) { TimelineRippleDeleteGapsAtRegionsCommand::RangeList range_list; @@ -661,73 +661,73 @@ void TimelineWidget::DeleteSelected(bool ripple) Core::instance()->undo_stack()->push(command, tr("Deleted Clips")); // Ensures any current drag operations are cancelled - ClearGhosts(); + clear_ghosts(); - if (ripple_command && ripple_command->HasCommands() && + if (ripple_command && ripple_command->has_commands() && new_playhead != RATIONAL_MAX) { - GetConnectedNode()->SetPlayhead(new_playhead); + get_connected_node()->set_playhead(new_playhead); } } -void TimelineWidget::IncreaseTrackHeight() +void TimelineWidget::increase_track_height() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } // Increase the height of each track by one "unit" - foreach (Track *t, sequence()->GetTracks()) { - t->SetTrackHeight(t->GetTrackHeight() + Track::kTrackHeightInterval); + foreach (Track *t, sequence()->get_tracks()) { + t->set_track_height(t->get_track_height() + Track::k_track_height_interval); } } -void TimelineWidget::DecreaseTrackHeight() +void TimelineWidget::decrease_track_height() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } // Decrease the height of each track by one "unit" - foreach (Track *t, sequence()->GetTracks()) { - t->SetTrackHeight( - qMax(t->GetTrackHeight() - Track::kTrackHeightInterval, - Track::kTrackHeightMinimum)); + foreach (Track *t, sequence()->get_tracks()) { + t->set_track_height( + qMax(t->get_track_height() - Track::k_track_height_interval, + Track::k_track_height_minimum)); } } -void TimelineWidget::InsertFootageAtPlayhead( +void TimelineWidget::insert_footage_at_playhead( const QVector &footage) { auto command = new MultiUndoCommand(); - import_tool_->PlaceAt(footage, GetConnectedNode()->GetPlayhead(), true, + import_tool_->place_at(footage, get_connected_node()->get_playhead(), true, command, 0, true); Core::instance()->undo_stack()->push(command, tr("Inserted Footage At Playhead")); } -void TimelineWidget::OverwriteFootageAtPlayhead( +void TimelineWidget::overwrite_footage_at_playhead( const QVector &footage) { auto command = new MultiUndoCommand(); - import_tool_->PlaceAt(footage, GetConnectedNode()->GetPlayhead(), false, + import_tool_->place_at(footage, get_connected_node()->get_playhead(), false, command, 0, true); Core::instance()->undo_stack()->push(command, tr("Overwrote Footage At Playhead")); } -void TimelineWidget::ToggleLinksOnSelected() +void TimelineWidget::toggle_links_on_selected() { QVector blocks; bool link = true; - foreach (Block *item, GetSelectedBlocks()) { + foreach (Block *item, get_selected_blocks()) { // Only clips can be linked if (!dynamic_cast(item)) { continue; } // Prioritize unlinking, if any block has links, assume we're unlinking - if (link && item->HasLinks()) { + if (link && item->has_links()) { link = false; } @@ -742,11 +742,11 @@ void TimelineWidget::ToggleLinksOnSelected() tr("Linked Clips")); } -void TimelineWidget::AddDefaultTransitionsToSelected() +void TimelineWidget::add_default_transitions_to_selected() { QVector blocks; - foreach (Block *item, GetSelectedBlocks()) { + foreach (Block *item, get_selected_blocks()) { // Only clips can be linked if (ClipBlock *clip = dynamic_cast(item)) { blocks.append(clip); @@ -760,13 +760,13 @@ void TimelineWidget::AddDefaultTransitionsToSelected() } } -bool TimelineWidget::CopySelected(bool cut) +bool TimelineWidget::copy_selected(bool cut) { - if (super::CopySelected(cut)) { + if (super::copy_selected(cut)) { return true; } - if (!GetConnectedNode() || selected_blocks_.isEmpty()) { + if (!get_connected_node() || selected_blocks_.isEmpty()) { return false; } @@ -775,7 +775,7 @@ bool TimelineWidget::CopySelected(bool cut) foreach (Block *block, selected_blocks_) { selected_nodes.append(block); - QVector deps = block->GetDependencies(); + QVector deps = block->get_dependencies(); foreach (Node *d, deps) { if (!selected_nodes.contains(d)) { @@ -784,11 +784,11 @@ bool TimelineWidget::CopySelected(bool cut) } } - ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyClips); - sdata.SetOnlySerializeNodesAndResolveGroups(selected_nodes); + ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_clips); + sdata.set_only_serialize_nodes_and_resolve_groups(selected_nodes); // Cache the earliest in point so all copied clips have a "relative" in point that can be pasted anywhere - rational earliest_in = RATIONAL_MAX; + Rational earliest_in = RATIONAL_MAX; ProjectSerializer::SerializedProperties properties; foreach (Block *block, selected_blocks_) { @@ -797,14 +797,14 @@ bool TimelineWidget::CopySelected(bool cut) foreach (Block *block, selected_blocks_) { properties[block][QStringLiteral("in")] = - QString::fromStdString((block->in() - earliest_in).toString()); + QString::fromStdString((block->in() - earliest_in).to_string()); properties[block][QStringLiteral("track")] = - block->track()->ToReference().ToString(); + block->track()->to_reference().to_string(); } - sdata.SetProperties(properties); + sdata.set_properties(properties); - ProjectSerializer::Copy(sdata); + ProjectSerializer::copy(sdata); if (cut) { DeleteSelected(); @@ -813,37 +813,37 @@ bool TimelineWidget::CopySelected(bool cut) return true; } -bool TimelineWidget::Paste() +bool TimelineWidget::paste() { // TimeRuler gets first chance (markers, etc.) - if (super::Paste()) { + if (super::paste()) { return true; } // Ensure we have a connected node - if (!GetConnectedNode()) { + if (!get_connected_node()) { return false; } // Attempt regular clip pasting - if (PasteInternal(false)) { + if (paste_internal(false)) { return true; } // Give last chance to NodeParamView - return NodeParamView::Paste( - this, std::bind(&TimelineWidget::GenerateExistingPasteMap, this, + return NodeParamView::paste( + this, std::bind(&TimelineWidget::generate_existing_paste_map, this, std::placeholders::_1)); } -void TimelineWidget::PasteInsert() +void TimelineWidget::paste_insert() { - PasteInternal(true); + paste_internal(true); } -void TimelineWidget::DeleteInToOut(bool ripple) +void TimelineWidget::delete_in_to_out(bool ripple) { - if (!GetConnectedNode() || !GetConnectedNode()->GetWorkArea()->enabled()) { + if (!get_connected_node() || !get_connected_node()->get_work_area()->enabled()) { return; } @@ -851,43 +851,43 @@ void TimelineWidget::DeleteInToOut(bool ripple) if (ripple) { command->add_child(new TimelineRippleRemoveAreaCommand( - sequence(), GetConnectedNode()->GetWorkArea()->in(), - GetConnectedNode()->GetWorkArea()->out())); + sequence(), get_connected_node()->get_work_area()->in(), + get_connected_node()->get_work_area()->out())); } else { - QVector unlocked_tracks = sequence()->GetUnlockedTracks(); + QVector unlocked_tracks = sequence()->get_unlocked_tracks(); foreach (Track *track, unlocked_tracks) { GapBlock *gap = new GapBlock(); gap->set_length_and_media_out( - GetConnectedNode()->GetWorkArea()->length()); + get_connected_node()->get_work_area()->length()); command->add_child(new NodeAddCommand( static_cast(track->parent()), gap)); command->add_child(new TrackPlaceBlockCommand( - sequence()->track_list(track->type()), track->Index(), gap, - GetConnectedNode()->GetWorkArea()->in())); + sequence()->track_list(track->type()), track->index(), gap, + get_connected_node()->get_work_area()->in())); } } // Clear workarea after this command->add_child(new WorkareaSetEnabledCommand( - GetConnectedNode()->project(), GetConnectedNode()->GetWorkArea(), + get_connected_node()->project(), get_connected_node()->get_work_area(), false)); if (ripple) { - GetConnectedNode()->SetPlayhead( - GetConnectedNode()->GetWorkArea()->in()); + get_connected_node()->set_playhead( + get_connected_node()->get_work_area()->in()); } Core::instance()->undo_stack()->push(command, tr("Deleted In To Out")); } -void TimelineWidget::ToggleSelectedEnabled() +void TimelineWidget::toggle_selected_enabled() { - QVector items = GetSelectedBlocks(); + QVector items = get_selected_blocks(); if (items.isEmpty()) { return; @@ -902,7 +902,7 @@ void TimelineWidget::ToggleSelectedEnabled() Core::instance()->undo_stack()->push(command, tr("Toggled Clips Enabled")); } -void TimelineWidget::SetColorLabel(int index) +void TimelineWidget::set_color_label(int index) { MultiUndoCommand *command = new MultiUndoCommand(); @@ -914,31 +914,31 @@ void TimelineWidget::SetColorLabel(int index) command, tr("Set Colors of %1 Clips").arg(selected_blocks_.size())); } -void TimelineWidget::NudgeLeft() +void TimelineWidget::nudge_left() { - if (GetConnectedNode()) { - NudgeInternal(-timebase()); + if (get_connected_node()) { + nudge_internal(-timebase()); } } -void TimelineWidget::NudgeRight() +void TimelineWidget::nudge_right() { - if (GetConnectedNode()) { - NudgeInternal(timebase()); + if (get_connected_node()) { + nudge_internal(timebase()); } } -void TimelineWidget::MoveInToPlayhead() +void TimelineWidget::move_in_to_playhead() { - MoveToPlayheadInternal(false); + move_to_playhead_internal(false); } -void TimelineWidget::MoveOutToPlayhead() +void TimelineWidget::move_out_to_playhead() { - MoveToPlayheadInternal(true); + move_to_playhead_internal(true); } -void TimelineWidget::ShowSpeedDurationDialogForSelectedClips() +void TimelineWidget::show_speed_duration_dialog_for_selected_clips() { QVector clips; @@ -955,20 +955,20 @@ void TimelineWidget::ShowSpeedDurationDialogForSelectedClips() } } -void TimelineWidget::SynchronizeSelectedClipsBySourceTime() +void TimelineWidget::synchronize_selected_clips_by_source_time() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } const QVector sync_clips = - GetSelectedSourceSyncClips(GetSelectedBlocks()); + get_selected_source_sync_clips(get_selected_blocks()); if (sync_clips.size() < 2) { return; } SourceSyncClip reference = sync_clips.first(); - rational anchor_timeline_in = sync_clips.first().clip->in(); + Rational anchor_timeline_in = sync_clips.first().clip->in(); for (const SourceSyncClip &sync_clip : sync_clips) { if (sync_clip.source_head < reference.source_head) { reference = sync_clip; @@ -980,13 +980,13 @@ void TimelineWidget::SynchronizeSelectedClipsBySourceTime() struct SyncPlacement { ClipBlock *clip = nullptr; - rational timeline_in; + Rational timeline_in; }; QVector placements; for (const SourceSyncClip &sync_clip : sync_clips) { const AudioSynchronizer::Placement placement = - AudioSynchronizer::PlaceBySourceTime( + AudioSynchronizer::place_by_source_time( reference.source, sync_clip.source, anchor_timeline_in); if (placement.valid) { placements.append({ sync_clip.clip, placement.timeline_in }); @@ -1007,44 +1007,44 @@ void TimelineWidget::SynchronizeSelectedClipsBySourceTime() for (const SyncPlacement &placement : placements) { command->add_child(new TrackPlaceBlockCommand( sequence()->track_list(placement.clip->track()->type()), - placement.clip->track()->Index(), placement.clip, + placement.clip->track()->index(), placement.clip, placement.timeline_in)); - new_selections[placement.clip->track()->ToReference()].insert( + new_selections[placement.clip->track()->to_reference()].insert( TimeRange(placement.timeline_in, placement.timeline_in + placement.clip->length())); } command->add_child( - new SetSelectionsCommand(this, new_selections, GetSelections())); + new SetSelectionsCommand(this, new_selections, get_selections())); Core::instance()->undo_stack()->push( command, tr("Synchronize Clips by Source Time")); } -void TimelineWidget::SynchronizeSelectedClipsByWaveform() +void TimelineWidget::synchronize_selected_clips_by_waveform() { - SynchronizeSelectedClipsByWaveformInternal(false); + synchronize_selected_clips_by_waveform_internal(false); } -void TimelineWidget::SynchronizeSelectedClipsByWaveformWithSpeed() +void TimelineWidget::synchronize_selected_clips_by_waveform_with_speed() { - SynchronizeSelectedClipsByWaveformInternal(true); + synchronize_selected_clips_by_waveform_internal(true); } -void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( +void TimelineWidget::synchronize_selected_clips_by_waveform_internal( bool allow_speed) { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } const QVector sync_clips = - GetSelectedWaveformSyncClips(GetSelectedBlocks()); + get_selected_waveform_sync_clips(get_selected_blocks()); qDebug() << "TimelineWidget::SynchronizeSelectedClipsByWaveform:" << sync_clips.size() << "sync clip(s) selected"; if (sync_clips.size() < 2) { - Core::instance()->ShowStatusBarMessage( + Core::instance()->show_status_bar_message( tr("Select at least 2 clips with cached waveforms to sync by waveform")); return; } @@ -1065,7 +1065,7 @@ void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( max_offset_samples / static_cast(window_samples); QVector reference_valid; - const QVector reference_envelope = ExtractWaveformCacheEnvelope( + const QVector reference_envelope = extract_waveform_cache_envelope( reference, sample_rate, window_samples, &reference_valid); qDebug() << "TimelineWidget::SynchronizeSelectedClipsByWaveform: sample_rate=" @@ -1075,7 +1075,7 @@ void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( struct SyncPlacement { ClipBlock *clip = nullptr; - rational timeline_in; + Rational timeline_in; double speed = 1.0; }; @@ -1087,13 +1087,13 @@ void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( } QVector candidate_valid; - const QVector candidate_envelope = ExtractWaveformCacheEnvelope( + const QVector candidate_envelope = extract_waveform_cache_envelope( sync_clip, sample_rate, window_samples, &candidate_valid); // Skip uncached (zero-filled) windows on both sides so partially // cached waveforms don't drag the correlation down AudioWaveformSync::OffsetResult offset = - AudioWaveformSync::EstimateEnvelopeOffset( + AudioWaveformSync::estimate_envelope_offset( reference_envelope, candidate_envelope, reference_valid, candidate_valid, window_samples, max_offset_windows); @@ -1109,7 +1109,7 @@ void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( (static_cast(sample_rate) * 30) / static_cast(window_samples)); const AudioWaveformSync::StretchOffsetResult stretch = - AudioWaveformSync::EstimateStretchAndOffset( + AudioWaveformSync::estimate_stretch_and_offset( reference_envelope, candidate_envelope, reference_valid, candidate_valid, window_samples, stretch_radius_windows, 0.75, 1.34, 0.005); @@ -1137,11 +1137,11 @@ void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( } const AudioSynchronizer::Placement placement = - AudioSynchronizer::PlaceByWaveformOffset( + AudioSynchronizer::place_by_waveform_offset( reference.clip->in(), offset.offset_samples, sample_rate); qDebug() << "TimelineWidget::SynchronizeSelectedClipsByWaveform: placement" << "valid=" << placement.valid << "timeline_in=" - << placement.timeline_in.toDouble(); + << placement.timeline_in.to_double(); if (placement.valid && placement.timeline_in >= 0) { placements.append({ sync_clip.clip, placement.timeline_in, speed }); } @@ -1150,7 +1150,7 @@ void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( if (placements.size() < 2) { qDebug() << "TimelineWidget::SynchronizeSelectedClipsByWaveform: no usable" << "offsets found"; - Core::instance()->ShowStatusBarMessage( + Core::instance()->show_status_bar_message( tr("Could not find a usable waveform offset for the selected clips")); return; } @@ -1163,7 +1163,7 @@ void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( if (placement.speed != 1.0) { command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(placement.clip, ClipBlock::kSpeedInput)), + NodeInput(placement.clip, ClipBlock::k_speed_input)), placement.clip->speed() * placement.speed)); } } @@ -1172,30 +1172,30 @@ void TimelineWidget::SynchronizeSelectedClipsByWaveformInternal( for (const SyncPlacement &placement : placements) { command->add_child(new TrackPlaceBlockCommand( sequence()->track_list(placement.clip->track()->type()), - placement.clip->track()->Index(), placement.clip, + placement.clip->track()->index(), placement.clip, placement.timeline_in)); // A speed change scales the clip's timeline length accordingly - const rational placed_length = + const Rational placed_length = placement.speed == 1.0 ? placement.clip->length() : - rational::fromDouble(placement.clip->length().toDouble() / + Rational::from_double(placement.clip->length().to_double() / placement.speed); - new_selections[placement.clip->track()->ToReference()].insert( + new_selections[placement.clip->track()->to_reference()].insert( TimeRange(placement.timeline_in, placement.timeline_in + placed_length)); } command->add_child( - new SetSelectionsCommand(this, new_selections, GetSelections())); + new SetSelectionsCommand(this, new_selections, get_selections())); Core::instance()->undo_stack()->push(command, tr("Synchronize Clips by Waveform")); - Core::instance()->ShowStatusBarMessage( + Core::instance()->show_status_bar_message( tr("Synchronized %1 clip(s) by waveform").arg(placements.size())); } -void TimelineWidget::GenerateProxiesForSelectedClips() +void TimelineWidget::generate_proxies_for_selected_clips() { if (!ProxyManager::instance() || !sequence()) { qWarning() @@ -1204,11 +1204,11 @@ void TimelineWidget::GenerateProxiesForSelectedClips() } const QVector footage = - GetSelectedProxyFootage(selected_blocks_); + get_selected_proxy_footage(selected_blocks_); qDebug() << "GenerateProxiesForSelectedClips: starting proxy generation for" << footage.size() << "footage item(s)"; for (Footage *item : footage) { - const VideoParams video = item->GetFirstEnabledVideoStream(); + const VideoParams video = item->get_first_enabled_video_stream(); if (!video.is_valid()) { qWarning() << "GenerateProxiesForSelectedClips: skipping item with no valid video stream" @@ -1216,25 +1216,25 @@ void TimelineWidget::GenerateProxiesForSelectedClips() continue; } - ProxyManager::ProxyParams params = item->GetEffectiveProxyParams(); + ProxyManager::ProxyParams params = item->get_effective_proxy_params(); const ProxyManager::Proxy proxy = - ProxyManager::instance()->GetOrStartProxy( + ProxyManager::instance()->get_or_start_proxy( item->project()->cache_path(), item->filename(), video.stream_index(), params); qDebug() << "GenerateProxiesForSelectedClips: proxy state=" - << ProxyManager::ProxyStateToString(proxy.state) + << ProxyManager::proxy_state_to_string(proxy.state) << "file=" << proxy.filename << "cache=" << item->project()->cache_path(); - item->SetProxy(proxy.filename, proxy.state, video.stream_index(), + item->set_proxy(proxy.filename, proxy.state, video.stream_index(), params.version, true); - item->InvalidateAll(Footage::kFilenameInput); + item->invalidate_all(Footage::k_filename_input); } } -void TimelineWidget::SetSelectedClipsProxyEnabled(bool enabled) +void TimelineWidget::set_selected_clips_proxy_enabled(bool enabled) { const QVector footage = - GetSelectedProxyFootage(selected_blocks_); + get_selected_proxy_footage(selected_blocks_); qDebug() << "TimelineWidget::SetSelectedClipsProxyEnabled:" << enabled << "footage count=" << footage.size(); for (Footage *item : footage) { @@ -1245,14 +1245,14 @@ void TimelineWidget::SetSelectedClipsProxyEnabled(bool enabled) } item->set_proxy_enabled(enabled); - item->InvalidateAll(Footage::kFilenameInput); + item->invalidate_all(Footage::k_filename_input); } } -void TimelineWidget::RevealProxyForSelectedClips() +void TimelineWidget::reveal_proxy_for_selected_clips() { const QVector footage = - GetSelectedProxyFootage(selected_blocks_); + get_selected_proxy_footage(selected_blocks_); for (Footage *item : footage) { if (item->proxy_path().isEmpty()) { continue; @@ -1281,10 +1281,10 @@ void TimelineWidget::RevealProxyForSelectedClips() } } -void TimelineWidget::DeleteProxiesForSelectedClips() +void TimelineWidget::delete_proxies_for_selected_clips() { const QVector footage = - GetSelectedProxyFootage(selected_blocks_); + get_selected_proxy_footage(selected_blocks_); for (Footage *item : footage) { if (item->proxy_path().isEmpty()) { continue; @@ -1292,28 +1292,28 @@ void TimelineWidget::DeleteProxiesForSelectedClips() QFile::remove(item->proxy_path()); QFile::remove( - ProxyManager::GetWorkingProxyFilename(item->proxy_path())); - item->ClearProxy(); - item->InvalidateAll(Footage::kFilenameInput); + ProxyManager::get_working_proxy_filename(item->proxy_path())); + item->clear_proxy(); + item->invalidate_all(Footage::k_filename_input); } } -void TimelineWidget::ShowProxyDialogForSelectedClips() +void TimelineWidget::show_proxy_dialog_for_selected_clips() { - ProxyDialog d(this, GetSelectedProxyFootage(selected_blocks_)); + ProxyDialog d(this, get_selected_proxy_footage(selected_blocks_)); d.exec(); } -void TimelineWidget::RecordingCallback(const QString &filename, +void TimelineWidget::recording_callback(const QString &filename, const TimeRange &time, const Track::Reference &track) { - ProjectImportTask task(GetConnectedNode()->project()->root(), { filename }); - task.Start(); + ProjectImportTask task(get_connected_node()->project()->root(), { filename }); + task.start(); - auto subimport_command = task.GetCommand(); + auto subimport_command = task.get_command(); - if (task.GetImportedFootage().empty()) { + if (task.get_imported_footage().empty()) { qCritical() << "Failed to import recorded audio file" << filename; delete subimport_command; } else { @@ -1322,43 +1322,43 @@ void TimelineWidget::RecordingCallback(const QString &filename, auto import_command = new MultiUndoCommand(); import_command->add_child(subimport_command); - import_tool_->PlaceAt({ task.GetImportedFootage().front() }, time.in(), + import_tool_->place_at({ task.get_imported_footage().front() }, time.in(), false, import_command, track.index()); Core::instance()->undo_stack()->push(import_command, tr("Recorded Audio Clip")); } } -void TimelineWidget::EnableRecordingOverlay(const TimelineCoordinate &coord) +void TimelineWidget::enable_recording_overlay(const TimelineCoordinate &coord) { foreach (TimelineAndTrackView *tview, views_) { - tview->view()->EnableRecordingOverlay(coord); + tview->view()->enable_recording_overlay(coord); } } -void TimelineWidget::DisableRecordingOverlay() +void TimelineWidget::disable_recording_overlay() { foreach (TimelineAndTrackView *tview, views_) { - tview->view()->DisableRecordingOverlay(); + tview->view()->disable_recording_overlay(); } } -void TimelineWidget::AddTentativeSubtitleTrack() +void TimelineWidget::add_tentative_subtitle_track() { if (!subtitle_show_command_) { // Determine if we need to do anything QList sz = view_splitter_->sizes(); - bool should_adjust_splitter = (sz[Track::kSubtitle] == 0); + bool should_adjust_splitter = (sz[Track::k_subtitle] == 0); bool should_add_sub_track = (sequence() && - sequence()->track_list(Track::kSubtitle)->GetTrackCount() == 0); + sequence()->track_list(Track::k_subtitle)->get_track_count() == 0); if (should_adjust_splitter || should_add_sub_track) { // Create command subtitle_show_command_ = new MultiUndoCommand(); if (should_adjust_splitter) { - sz[Track::kSubtitle] = height() / Track::kCount; + sz[Track::k_subtitle] = height() / Track::k_count; subtitle_show_command_->add_child( new SetSplitterSizesCommand(view_splitter_, sz)); } @@ -1366,7 +1366,7 @@ void TimelineWidget::AddTentativeSubtitleTrack() if (should_add_sub_track) { TimelineAddTrackCommand *track_add_cmd = new TimelineAddTrackCommand( - sequence()->track_list(Track::kSubtitle)); + sequence()->track_list(Track::k_subtitle)); subtitle_tentative_track_ = track_add_cmd->track(); subtitle_show_command_->add_child(track_add_cmd); } @@ -1376,9 +1376,9 @@ void TimelineWidget::AddTentativeSubtitleTrack() } } -void TimelineWidget::NestSelectedClips() +void TimelineWidget::nest_selected_clips() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } @@ -1389,13 +1389,13 @@ void TimelineWidget::NestSelectedClips() QVector tracks(blocks.size()); QVector times(blocks.size()); - QVector track_offset(Track::kCount, INT_MAX); - rational start_time = RATIONAL_MAX; - rational end_time = RATIONAL_MIN; + QVector track_offset(Track::k_count, INT_MAX); + Rational start_time = RATIONAL_MAX; + Rational end_time = RATIONAL_MIN; for (int i = 0; i < blocks.size(); i++) { Block *b = blocks.at(i); - Track::Reference tf = b->track()->ToReference(); + Track::Reference tf = b->track()->to_reference(); ; tracks[i] = tf; times[i] = b->range(); @@ -1410,19 +1410,19 @@ void TimelineWidget::NestSelectedClips() auto move_to_nest_command = new MultiUndoCommand(); // Remove blocks from this sequence - ReplaceBlocksWithGaps(blocks, false, move_to_nest_command); + replace_blocks_with_gaps(blocks, false, move_to_nest_command); // Create new sequence - Project *project = this->GetConnectedNode()->project(); + Project *project = this->get_connected_node()->project(); Sequence *nest = - Core::CreateNewSequenceForProject(tr("Nested Sequence %1"), project); - nest->SetVideoParams(GetConnectedNode()->GetVideoParams()); - nest->SetAudioParams(GetConnectedNode()->GetAudioParams()); + Core::create_new_sequence_for_project(tr("Nested Sequence %1"), project); + nest->set_video_params(get_connected_node()->get_video_params()); + nest->set_audio_params(get_connected_node()->get_audio_params()); move_to_nest_command->add_child(new NodeAddCommand(project, nest)); // Add to same folder move_to_nest_command->add_child( - new FolderAddChild(this->GetConnectedNode()->folder(), nest)); + new FolderAddChild(this->get_connected_node()->folder(), nest)); // Place blocks in new sequence for (int i = 0; i < blocks.size(); i++) { @@ -1449,7 +1449,7 @@ void TimelineWidget::NestSelectedClips() while (!empty) { index++; empty = true; - for (int i = 0; i < Track::kCount; i++) { + for (int i = 0; i < Track::k_count; i++) { if (track_offset.at(i) == INT_MAX) { // No clips on this track continue; @@ -1457,8 +1457,8 @@ void TimelineWidget::NestSelectedClips() TrackList *list = sequence()->track_list(static_cast(i)); - if (index < list->GetTrackCount() && - !list->GetTrackAt(index)->IsRangeFree( + if (index < list->get_track_count() && + !list->get_track_at(index)->is_range_free( TimeRange(start_time, end_time))) { empty = false; break; @@ -1467,12 +1467,12 @@ void TimelineWidget::NestSelectedClips() } // Place new sequence in this sequence - import_tool_->PlaceAt({ nest }, start_time, false, meta_command, index); + import_tool_->place_at({ nest }, start_time, false, meta_command, index); Core::instance()->undo_stack()->push(meta_command, tr("Nested Clips")); } -void TimelineWidget::ClearTentativeSubtitleTrack() +void TimelineWidget::clear_tentative_subtitle_track() { if (subtitle_show_command_) { subtitle_show_command_->undo_now(); @@ -1482,38 +1482,38 @@ void TimelineWidget::ClearTentativeSubtitleTrack() } } -void TimelineWidget::InsertGapsAt(const rational &earliest_point, - const rational &insert_length, +void TimelineWidget::insert_gaps_at(const Rational &earliest_point, + const Rational &insert_length, MultiUndoCommand *command) { - for (int i = 0; i < Track::kCount; i++) { + for (int i = 0; i < Track::k_count; i++) { command->add_child(new TrackListInsertGaps( sequence()->track_list(static_cast(i)), earliest_point, insert_length)); } } -Track *TimelineWidget::GetTrackFromReference(const Track::Reference &ref) const +Track *TimelineWidget::get_track_from_reference(const Track::Reference &ref) const { - return sequence()->track_list(ref.type())->GetTrackAt(ref.index()); + return sequence()->track_list(ref.type())->get_track_at(ref.index()); } -int TimelineWidget::GetTrackY(const Track::Reference &ref) +int TimelineWidget::get_track_y(const Track::Reference &ref) { - return views_.at(ref.type())->view()->GetTrackY(ref.index()); + return views_.at(ref.type())->view()->get_track_y(ref.index()); } -int TimelineWidget::GetTrackHeight(const Track::Reference &ref) +int TimelineWidget::get_track_height(const Track::Reference &ref) { - return views_.at(ref.type())->view()->GetTrackHeight(ref.index()); + return views_.at(ref.type())->view()->get_track_height(ref.index()); } -void TimelineWidget::CenterOn(qreal scene_pos) +void TimelineWidget::center_on(qreal scene_pos) { scrollbar()->setValue(qRound(scene_pos - scrollbar()->width() / 2)); } -void TimelineWidget::ClearGhosts() +void TimelineWidget::clear_ghosts() { if (!ghost_items_.isEmpty()) { foreach (TimelineViewGhostItem *ghost, ghost_items_) { @@ -1523,127 +1523,127 @@ void TimelineWidget::ClearGhosts() ghost_items_.clear(); } - HideSnaps(); + hide_snaps(); } -TimelineTool *TimelineWidget::GetActiveTool() +TimelineTool *TimelineWidget::get_active_tool() { return tools_.at(Core::instance()->tool()); } -void TimelineWidget::ViewMousePressed(TimelineViewMouseEvent *event) +void TimelineWidget::view_mouse_pressed(TimelineViewMouseEvent *event) { - active_tool_ = GetActiveTool(); + active_tool_ = get_active_tool(); - if (GetConnectedNode() && active_tool_ != nullptr) { - active_tool_->MousePress(event); - UpdateViewports(); + if (get_connected_node() && active_tool_ != nullptr) { + active_tool_->mouse_press(event); + update_viewports(); } - if (event->GetButton() != Qt::LeftButton) { + if (event->get_button() != Qt::LeftButton) { // Suspend tool immediately if the cursor isn't the primary button - active_tool_->MouseRelease(event); - UpdateViewports(); + active_tool_->mouse_release(event); + update_viewports(); active_tool_ = nullptr; } } -void TimelineWidget::ViewMouseMoved(TimelineViewMouseEvent *event) +void TimelineWidget::view_mouse_moved(TimelineViewMouseEvent *event) { - if (GetConnectedNode()) { + if (get_connected_node()) { if (active_tool_) { - active_tool_->MouseMove(event); + active_tool_->mouse_move(event); - UpdateViewports(); + update_viewports(); - SetCatchUpScrollValue(event->GetScreenPos().x()); + set_catch_up_scroll_value(event->get_screen_pos().x()); } else { // Mouse is not down, attempt a hover event - TimelineTool *hover_tool = GetActiveTool(); + TimelineTool *hover_tool = get_active_tool(); if (hover_tool) { - hover_tool->HoverMove(event); + hover_tool->hover_move(event); } } } } -void TimelineWidget::ViewMouseReleased(TimelineViewMouseEvent *event) +void TimelineWidget::view_mouse_released(TimelineViewMouseEvent *event) { - StopCatchUpScrollTimer(); + stop_catch_up_scroll_timer(); if (active_tool_) { - if (GetConnectedNode()) { - active_tool_->MouseRelease(event); - UpdateViewports(); + if (get_connected_node()) { + active_tool_->mouse_release(event); + update_viewports(); } active_tool_ = nullptr; } } -void TimelineWidget::ViewMouseDoubleClicked(TimelineViewMouseEvent *event) +void TimelineWidget::view_mouse_double_clicked(TimelineViewMouseEvent *event) { // kHand tool will return nullptr - if (!GetActiveTool()) { + if (!get_active_tool()) { // Only kHand should return a nullptr - Q_ASSERT(Core::instance()->tool() == olive::Tool::kHand); + Q_ASSERT(Core::instance()->tool() == olive::Tool::k_hand); return; } - if (GetConnectedNode()) { - GetActiveTool()->MouseDoubleClick(event); - UpdateViewports(); + if (get_connected_node()) { + get_active_tool()->mouse_double_click(event); + update_viewports(); } } -void TimelineWidget::ViewDragEntered(TimelineViewMouseEvent *event) +void TimelineWidget::view_drag_entered(TimelineViewMouseEvent *event) { - import_tool_->DragEnter(event); - UpdateViewports(); + import_tool_->drag_enter(event); + update_viewports(); } -void TimelineWidget::ViewDragMoved(TimelineViewMouseEvent *event) +void TimelineWidget::view_drag_moved(TimelineViewMouseEvent *event) { - import_tool_->DragMove(event); - UpdateViewports(); + import_tool_->drag_move(event); + update_viewports(); - SetCatchUpScrollValue(event->GetScreenPos().x()); + set_catch_up_scroll_value(event->get_screen_pos().x()); } -void TimelineWidget::ViewDragLeft(QDragLeaveEvent *event) +void TimelineWidget::view_drag_left(QDragLeaveEvent *event) { - StopCatchUpScrollTimer(); + stop_catch_up_scroll_timer(); - import_tool_->DragLeave(event); - UpdateViewports(); + import_tool_->drag_leave(event); + update_viewports(); } -void TimelineWidget::ViewDragDropped(TimelineViewMouseEvent *event) +void TimelineWidget::view_drag_dropped(TimelineViewMouseEvent *event) { - StopCatchUpScrollTimer(); + stop_catch_up_scroll_timer(); - import_tool_->DragDrop(event); - UpdateViewports(); + import_tool_->drag_drop(event); + update_viewports(); } -void TimelineWidget::AddBlock(Block *block) +void TimelineWidget::add_block(Block *block) { // Set up clip with view parameters (clip item will automatically size its rect accordingly) if (!added_blocks_.contains(block)) { - connect(block, &Block::LinksChanged, this, - &TimelineWidget::BlockUpdated); - connect(block, &Block::LabelChanged, this, - &TimelineWidget::BlockUpdated); - connect(block, &Block::ColorChanged, this, - &TimelineWidget::BlockUpdated); - connect(block, &Block::EnabledChanged, this, - &TimelineWidget::BlockUpdated); - connect(block, &Block::PreviewChanged, this, - &TimelineWidget::BlockUpdated); + connect(block, &Block::links_changed, this, + &TimelineWidget::block_updated); + connect(block, &Block::label_changed, this, + &TimelineWidget::block_updated); + connect(block, &Block::color_changed, this, + &TimelineWidget::block_updated); + connect(block, &Block::enabled_changed, this, + &TimelineWidget::block_updated); + connect(block, &Block::preview_changed, this, + &TimelineWidget::block_updated); added_blocks_.append(block); - if (selections_[block->track()->ToReference()].contains( + if (selections_[block->track()->to_reference()].contains( block->range()) && !selected_blocks_.contains(block)) { selected_blocks_.append(block); @@ -1651,19 +1651,19 @@ void TimelineWidget::AddBlock(Block *block) } } -void TimelineWidget::RemoveBlock(Block *block) +void TimelineWidget::remove_block(Block *block) { // Disconnect all signals - disconnect(block, &Block::LinksChanged, this, - &TimelineWidget::BlockUpdated); - disconnect(block, &Block::LabelChanged, this, - &TimelineWidget::BlockUpdated); - disconnect(block, &Block::ColorChanged, this, - &TimelineWidget::BlockUpdated); - disconnect(block, &Block::EnabledChanged, this, - &TimelineWidget::BlockUpdated); - disconnect(block, &Block::PreviewChanged, this, - &TimelineWidget::BlockUpdated); + disconnect(block, &Block::links_changed, this, + &TimelineWidget::block_updated); + disconnect(block, &Block::label_changed, this, + &TimelineWidget::block_updated); + disconnect(block, &Block::color_changed, this, + &TimelineWidget::block_updated); + disconnect(block, &Block::enabled_changed, this, + &TimelineWidget::block_updated); + disconnect(block, &Block::preview_changed, this, + &TimelineWidget::block_updated); // Take item from map added_blocks_.removeOne(block); @@ -1672,60 +1672,60 @@ void TimelineWidget::RemoveBlock(Block *block) int select_index = selected_blocks_.indexOf(block); if (select_index > -1) { selected_blocks_.removeAt(select_index); - RemoveSelection(block); + remove_selection(block); - SignalBlockSelectionChange(); + signal_block_selection_change(); } } -void TimelineWidget::AddTrack(Track *track) +void TimelineWidget::add_track(Track *track) { - foreach (Block *b, track->Blocks()) { - AddBlock(b); + foreach (Block *b, track->blocks()) { + add_block(b); } - connect(track, &Track::IndexChanged, this, &TimelineWidget::TrackUpdated); - connect(track, &Track::IndexChanged, this, - &TimelineWidget::TrackIndexChanged); - connect(track, &Track::BlocksRefreshed, this, - &TimelineWidget::TrackUpdated); - connect(track, &Track::TrackHeightChanged, this, - &TimelineWidget::TrackUpdated); - connect(track, &Track::BlockAdded, this, &TimelineWidget::AddBlock); - connect(track, &Track::BlockRemoved, this, &TimelineWidget::RemoveBlock); + connect(track, &Track::index_changed, this, &TimelineWidget::track_updated); + connect(track, &Track::index_changed, this, + &TimelineWidget::track_index_changed); + connect(track, &Track::blocks_refreshed, this, + &TimelineWidget::track_updated); + connect(track, &Track::track_height_changed, this, + &TimelineWidget::track_updated); + connect(track, &Track::block_added, this, &TimelineWidget::add_block); + connect(track, &Track::block_removed, this, &TimelineWidget::remove_block); } -void TimelineWidget::RemoveTrack(Track *track) +void TimelineWidget::remove_track(Track *track) { - disconnect(track, &Track::IndexChanged, this, - &TimelineWidget::TrackUpdated); - disconnect(track, &Track::IndexChanged, this, - &TimelineWidget::TrackIndexChanged); - disconnect(track, &Track::BlocksRefreshed, this, - &TimelineWidget::TrackUpdated); - disconnect(track, &Track::TrackHeightChanged, this, - &TimelineWidget::TrackUpdated); - disconnect(track, &Track::BlockAdded, this, &TimelineWidget::AddBlock); - disconnect(track, &Track::BlockRemoved, this, &TimelineWidget::RemoveBlock); + disconnect(track, &Track::index_changed, this, + &TimelineWidget::track_updated); + disconnect(track, &Track::index_changed, this, + &TimelineWidget::track_index_changed); + disconnect(track, &Track::blocks_refreshed, this, + &TimelineWidget::track_updated); + disconnect(track, &Track::track_height_changed, this, + &TimelineWidget::track_updated); + disconnect(track, &Track::block_added, this, &TimelineWidget::add_block); + disconnect(track, &Track::block_removed, this, &TimelineWidget::remove_block); - RemoveSelection(TimeRange(0, RATIONAL_MAX), track->ToReference()); + remove_selection(TimeRange(0, RATIONAL_MAX), track->to_reference()); - foreach (Block *b, track->Blocks()) { - RemoveBlock(b); + foreach (Block *b, track->blocks()) { + remove_block(b); } } -void TimelineWidget::TrackUpdated() +void TimelineWidget::track_updated() { - UpdateViewports(static_cast(sender())->type()); + update_viewports(static_cast(sender())->type()); } -void TimelineWidget::BlockUpdated() +void TimelineWidget::block_updated() { - UpdateViewports(static_cast(sender())->track()->type()); + update_viewports(static_cast(sender())->track()->type()); } -void TimelineWidget::UpdateHorizontalSplitters() +void TimelineWidget::update_horizontal_splitters() { QSplitter *sender_splitter = static_cast(sender()); @@ -1739,53 +1739,53 @@ void TimelineWidget::UpdateHorizontalSplitters() } } - UpdateTimecodeWidthFromSplitters(sender_splitter); + update_timecode_width_from_splitters(sender_splitter); } -void TimelineWidget::UpdateTimecodeWidthFromSplitters(QSplitter *s) +void TimelineWidget::update_timecode_width_from_splitters(QSplitter *s) { timecode_label_->setFixedWidth(s->sizes().first() + s->handleWidth()); } -void TimelineWidget::ShowContextMenu() +void TimelineWidget::show_context_menu() { Menu menu(this); - QVector selected = GetSelectedBlocks(); + QVector selected = get_selected_blocks(); if (!selected.isEmpty()) { - MenuShared::instance()->AddItemsForEditMenu(&menu, true); + MenuShared::instance()->add_items_for_edit_menu(&menu, true); menu.addSeparator(); - MenuShared::instance()->AddColorCodingMenu(&menu); + MenuShared::instance()->add_color_coding_menu(&menu); menu.addSeparator(); QAction *sync_by_source_time = menu.addAction(tr("Synchronize by Source Time")); sync_by_source_time->setEnabled( - GetSelectedSourceSyncClips(selected).size() >= 2); + get_selected_source_sync_clips(selected).size() >= 2); connect(sync_by_source_time, &QAction::triggered, this, - &TimelineWidget::SynchronizeSelectedClipsBySourceTime); + &TimelineWidget::synchronize_selected_clips_by_source_time); QAction *sync_by_waveform = menu.addAction(tr("Synchronize by Waveform")); sync_by_waveform->setEnabled( - GetSelectedWaveformSyncClips(selected).size() >= 2); + get_selected_waveform_sync_clips(selected).size() >= 2); sync_by_waveform->setShortcut( QKeySequence(QStringLiteral("Ctrl+Shift+W"))); sync_by_waveform->setShortcutContext(Qt::WidgetShortcut); this->addAction(sync_by_waveform); connect(sync_by_waveform, &QAction::triggered, this, - &TimelineWidget::SynchronizeSelectedClipsByWaveform); + &TimelineWidget::synchronize_selected_clips_by_waveform); QAction *sync_by_waveform_speed = menu.addAction(tr("Synchronize by Waveform (Adjust Speed)")); sync_by_waveform_speed->setEnabled( - GetSelectedWaveformSyncClips(selected).size() >= 2); + get_selected_waveform_sync_clips(selected).size() >= 2); connect(sync_by_waveform_speed, &QAction::triggered, this, - &TimelineWidget::SynchronizeSelectedClipsByWaveformWithSpeed); + &TimelineWidget::synchronize_selected_clips_by_waveform_with_speed); menu.addSeparator(); @@ -1797,28 +1797,28 @@ void TimelineWidget::ShowContextMenu() QAction *autocache_action = cache_menu->addAction(tr("Auto-Cache")); autocache_action->setCheckable(true); - autocache_action->setChecked(clip->IsAutocaching()); + autocache_action->setChecked(clip->is_autocaching()); connect(autocache_action, &QAction::triggered, this, - &TimelineWidget::SetSelectedClipsAutocaching); + &TimelineWidget::set_selected_clips_autocaching); cache_menu->addSeparator(); auto cache_clip = cache_menu->addAction(tr("Cache All")); connect(cache_clip, &QAction::triggered, this, - &TimelineWidget::CacheClips); + &TimelineWidget::cache_clips); auto cache_inout = cache_menu->addAction(tr("Cache In/Out")); connect(cache_inout, &QAction::triggered, this, - &TimelineWidget::CacheClipsInOut); + &TimelineWidget::cache_clips_in_out); auto cache_discard = cache_menu->addAction(tr("Discard")); connect(cache_discard, &QAction::triggered, this, - &TimelineWidget::CacheDiscard); + &TimelineWidget::cache_discard); } { const QVector proxy_footage = - GetSelectedProxyFootage(selected); + get_selected_proxy_footage(selected); Menu *proxy_menu = new Menu(tr("Proxy"), &menu); menu.addMenu(proxy_menu); @@ -1826,7 +1826,7 @@ void TimelineWidget::ShowContextMenu() proxy_menu->addAction(tr("Generate Proxy")); generate_proxy->setEnabled(!proxy_footage.isEmpty()); connect(generate_proxy, &QAction::triggered, this, - &TimelineWidget::GenerateProxiesForSelectedClips); + &TimelineWidget::generate_proxies_for_selected_clips); QAction *use_proxy = proxy_menu->addAction(tr("Use Proxy")); use_proxy->setCheckable(true); @@ -1838,7 +1838,7 @@ void TimelineWidget::ShowContextMenu() return footage->proxy_enabled(); })); connect(use_proxy, &QAction::triggered, this, - &TimelineWidget::SetSelectedClipsProxyEnabled); + &TimelineWidget::set_selected_clips_proxy_enabled); QAction *reveal_proxy = proxy_menu->addAction(tr("Reveal Proxy")); @@ -1848,7 +1848,7 @@ void TimelineWidget::ShowContextMenu() return !footage->proxy_path().isEmpty(); })); connect(reveal_proxy, &QAction::triggered, this, - &TimelineWidget::RevealProxyForSelectedClips); + &TimelineWidget::reveal_proxy_for_selected_clips); QAction *delete_proxy = proxy_menu->addAction(tr("Delete Proxy")); @@ -1858,12 +1858,12 @@ void TimelineWidget::ShowContextMenu() return !footage->proxy_path().isEmpty(); })); connect(delete_proxy, &QAction::triggered, this, - &TimelineWidget::DeleteProxiesForSelectedClips); + &TimelineWidget::delete_proxies_for_selected_clips); QAction *proxy_settings = proxy_menu->addAction(tr("Proxy Settings...")); connect(proxy_settings, &QAction::triggered, this, - &TimelineWidget::ShowProxyDialogForSelectedClips); + &TimelineWidget::show_proxy_dialog_for_selected_clips); } if (clip->connected_viewer()) { @@ -1874,14 +1874,14 @@ void TimelineWidget::ShowContextMenu() reveal_in_footage_viewer->setProperty( "range", QVariant::fromValue(clip->media_range())); connect(reveal_in_footage_viewer, &QAction::triggered, this, - &TimelineWidget::RevealInFootageViewer); + &TimelineWidget::reveal_in_footage_viewer); QAction *reveal_in_project = menu.addAction(tr("Reveal in Project")); reveal_in_project->setData( reinterpret_cast(clip->connected_viewer())); connect(reveal_in_project, &QAction::triggered, this, - &TimelineWidget::RevealInProject); + &TimelineWidget::reveal_in_project); if (Sequence *sequence = dynamic_cast(clip->connected_viewer())) { @@ -1889,7 +1889,7 @@ void TimelineWidget::ShowContextMenu() multicam_enabled->setCheckable(true); MultiCamNode *mcn = nullptr; - auto paths = clip->FindWaysNodeArrivesHere(sequence); + auto paths = clip->find_ways_node_arrives_here(sequence); for (const NodeInput &i : paths) { if ((mcn = dynamic_cast(i.node()))) { @@ -1900,7 +1900,7 @@ void TimelineWidget::ShowContextMenu() multicam_enabled->setChecked(mcn); connect(multicam_enabled, &QAction::triggered, this, - &TimelineWidget::MulticamEnabledTriggered); + &TimelineWidget::multicam_enabled_triggered); } } } @@ -1909,7 +1909,7 @@ void TimelineWidget::ShowContextMenu() QAction *properties_action = menu.addAction(tr("Properties")); connect(properties_action, &QAction::triggered, this, - &TimelineWidget::ShowSpeedDurationDialogForSelectedClips); + &TimelineWidget::show_speed_duration_dialog_for_selected_clips); } if (selected.isEmpty()) { @@ -1918,39 +1918,39 @@ void TimelineWidget::ShowContextMenu() toggle_audio_units->setCheckable(true); toggle_audio_units->setChecked(use_audio_time_units_); connect(toggle_audio_units, &QAction::triggered, this, - &TimelineWidget::SetUseAudioTimeUnits); + &TimelineWidget::set_use_audio_time_units); { Menu *thumbnail_menu = new Menu(tr("Show Thumbnails"), &menu); menu.addMenu(thumbnail_menu); - thumbnail_menu->AddActionWithData( - tr("Disabled"), Timeline::kThumbnailOff, - OLIVE_CONFIG("TimelineThumbnailMode")); - thumbnail_menu->AddActionWithData( - tr("Only At In Points"), Timeline::kThumbnailInOut, - OLIVE_CONFIG("TimelineThumbnailMode")); - thumbnail_menu->AddActionWithData( - tr("Enabled"), Timeline::kThumbnailOn, - OLIVE_CONFIG("TimelineThumbnailMode")); + thumbnail_menu->add_action_with_data( + tr("Disabled"), Timeline::k_thumbnail_off, + OAK_CONFIG("TimelineThumbnailMode")); + thumbnail_menu->add_action_with_data( + tr("Only At In Points"), Timeline::k_thumbnail_in_out, + OAK_CONFIG("TimelineThumbnailMode")); + thumbnail_menu->add_action_with_data( + tr("Enabled"), Timeline::k_thumbnail_on, + OAK_CONFIG("TimelineThumbnailMode")); connect(thumbnail_menu, &Menu::triggered, this, - &TimelineWidget::SetViewThumbnailsEnabled); + &TimelineWidget::set_view_thumbnails_enabled); } QAction *show_waveforms = menu.addAction(tr("Show Waveforms")); show_waveforms->setCheckable(true); show_waveforms->setChecked( - OLIVE_CONFIG("TimelineWaveformMode").toInt() == - Timeline::kWaveformsEnabled); + OAK_CONFIG("TimelineWaveformMode").toInt() == + Timeline::k_waveforms_enabled); connect(show_waveforms, &QAction::triggered, this, - &TimelineWidget::SetViewWaveformsEnabled); + &TimelineWidget::set_view_waveforms_enabled); menu.addSeparator(); QAction *properties_action = menu.addAction(tr("Properties")); connect(properties_action, &QAction::triggered, this, - &TimelineWidget::ShowSequenceDialog); + &TimelineWidget::show_sequence_dialog); } menu.exec(QCursor::pos()); @@ -1961,69 +1961,69 @@ void TimelineWidget::DeferredScrollAction() scrollbar()->setValue(deferred_scroll_value_); } -void TimelineWidget::ShowSequenceDialog() +void TimelineWidget::show_sequence_dialog() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } - SequenceDialog sd(sequence(), SequenceDialog::kExisting, this); + SequenceDialog sd(sequence(), SequenceDialog::k_existing, this); sd.exec(); } -void TimelineWidget::SetUseAudioTimeUnits(bool use) +void TimelineWidget::set_use_audio_time_units(bool use) { use_audio_time_units_ = use; // Update timebases - UpdateViewTimebases(); + update_view_timebases(); } -void TimelineWidget::ToolChanged() +void TimelineWidget::tool_changed() { - HideSnaps(); - SetViewBeamCursor(TimelineCoordinate(0, Track::kNone, -1)); - SetViewTransitionOverlay(nullptr, nullptr); + hide_snaps(); + set_view_beam_cursor(TimelineCoordinate(0, Track::k_none, -1)); + set_view_transition_overlay(nullptr, nullptr); - AddableObjectChanged(); + addable_object_changed(); } -void TimelineWidget::AddableObjectChanged() +void TimelineWidget::addable_object_changed() { // Special cast for subtitle adding - ensure section is visible - if (Core::instance()->tool() == Tool::kAdd && - Core::instance()->GetSelectedAddableObject() == - Tool::kAddableSubtitle) { - AddTentativeSubtitleTrack(); + if (Core::instance()->tool() == Tool::k_add && + Core::instance()->get_selected_addable_object() == + Tool::k_addable_subtitle) { + add_tentative_subtitle_track(); } else { - ClearTentativeSubtitleTrack(); + clear_tentative_subtitle_track(); } } -void TimelineWidget::SetViewWaveformsEnabled(bool e) +void TimelineWidget::set_view_waveforms_enabled(bool e) { - OLIVE_CONFIG("TimelineWaveformMode") = e ? Timeline::kWaveformsEnabled : - Timeline::kWaveformsDisabled; - UpdateViewports(); + OAK_CONFIG("TimelineWaveformMode") = e ? Timeline::k_waveforms_enabled : + Timeline::k_waveforms_disabled; + update_viewports(); } -void TimelineWidget::SetViewThumbnailsEnabled(QAction *action) +void TimelineWidget::set_view_thumbnails_enabled(QAction *action) { - OLIVE_CONFIG("TimelineThumbnailMode") = action->data(); - UpdateViewports(); + OAK_CONFIG("TimelineThumbnailMode") = action->data(); + update_viewports(); } -void TimelineWidget::FrameRateChanged() +void TimelineWidget::frame_rate_changed() { - SetTimebase(GetConnectedNode()->GetVideoParams().frame_rate_as_time_base()); + SetTimebase(get_connected_node()->get_video_params().frame_rate_as_time_base()); } -void TimelineWidget::SampleRateChanged() +void TimelineWidget::sample_rate_changed() { - UpdateViewTimebases(); + update_view_timebases(); } -void TimelineWidget::TrackIndexChanged(int old, int now) +void TimelineWidget::track_index_changed(int old, int now) { Track *track = static_cast(sender()); @@ -2036,13 +2036,13 @@ void TimelineWidget::TrackIndexChanged(int old, int now) } } -void TimelineWidget::SignalBlockSelectionChange() +void TimelineWidget::signal_block_selection_change() { signal_block_change_timer_->stop(); signal_block_change_timer_->start(); } -void TimelineWidget::RevealInFootageViewer() +void TimelineWidget::reveal_in_footage_viewer() { QAction *a = static_cast(sender()); @@ -2050,20 +2050,20 @@ void TimelineWidget::RevealInFootageViewer() reinterpret_cast(a->data().value()); TimeRange r = a->property("range").value(); - emit RevealViewerInFootageViewer(item_to_reveal, r); + emit reveal_viewer_in_footage_viewer(item_to_reveal, r); } -void TimelineWidget::RevealInProject() +void TimelineWidget::reveal_in_project() { QAction *a = static_cast(sender()); ViewerOutput *item_to_reveal = reinterpret_cast(a->data().value()); - emit RevealViewerInProject(item_to_reveal); + emit reveal_viewer_in_project(item_to_reveal); } -void TimelineWidget::RenameSelectedBlocks() +void TimelineWidget::rename_selected_blocks() { MultiUndoCommand *command = new MultiUndoCommand(); QVector nodes(selected_blocks_.size()); @@ -2072,23 +2072,23 @@ void TimelineWidget::RenameSelectedBlocks() nodes[i] = selected_blocks_[i]; } - Core::instance()->LabelNodes(nodes); + Core::instance()->label_nodes(nodes); Core::instance()->undo_stack()->push( command, tr("Renamed %1 Clip(s)").arg(nodes.size())); } -void TimelineWidget::TrackAboutToBeDeleted(Track *track) +void TimelineWidget::track_about_to_be_deleted(Track *track) { if (track == subtitle_tentative_track_) { // User is deleting the tentative subtitle track. Technically they shouldn't do this, but they // might if they misinterpret it as permanent. If so, we handle it cleanly by pushing our // command as if the action really were permanent. - Core::instance()->undo_stack()->push(TakeSubtitleSectionCommand(), + Core::instance()->undo_stack()->push(take_subtitle_section_command(), tr("Created Subtitle Track")); } } -void TimelineWidget::SetSelectedClipsAutocaching(bool e) +void TimelineWidget::set_selected_clips_autocaching(bool e) { MultiUndoCommand *command = new MultiUndoCommand(); @@ -2096,7 +2096,7 @@ void TimelineWidget::SetSelectedClipsAutocaching(bool e) if (ClipBlock *clip = dynamic_cast(b)) { command->add_child(new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(clip, ClipBlock::kAutoCacheInput)), + NodeInput(clip, ClipBlock::k_auto_cache_input)), e)); } } @@ -2108,38 +2108,38 @@ void TimelineWidget::SetSelectedClipsAutocaching(bool e) .arg(selected_blocks_.size())); } -void TimelineWidget::CacheClips() +void TimelineWidget::cache_clips() { for (Block *b : selected_blocks_) { if (ClipBlock *clip = dynamic_cast(b)) { - clip->RequestInvalidatedFromConnected(true); + clip->request_invalidated_from_connected(true); } } } -void TimelineWidget::CacheClipsInOut() +void TimelineWidget::cache_clips_in_out() { - if (!this->sequence() || !this->sequence()->GetWorkArea()->enabled()) { + if (!this->sequence() || !this->sequence()->get_work_area()->enabled()) { return; } TimeTargetObject tto; - tto.SetTimeTarget(this->sequence()); + tto.set_time_target(this->sequence()); - const TimeRange &r = this->sequence()->GetWorkArea()->range(); + const TimeRange &r = this->sequence()->get_work_area()->range(); for (Block *b : qAsConst(selected_blocks_)) { if (ClipBlock *clip = dynamic_cast(b)) { - if (Node *connected = clip->GetConnectedOutput(clip->kBufferIn)) { + if (Node *connected = clip->get_connected_output(clip->k_buffer_in)) { TimeRange adjusted = - tto.GetAdjustedTime(this->sequence(), connected, r, - Node::kTransformTowardsInput); - clip->RequestInvalidatedFromConnected(true, adjusted); + tto.get_adjusted_time(this->sequence(), connected, r, + Node::k_transform_towards_input); + clip->request_invalidated_from_connected(true, adjusted); } } } } -void TimelineWidget::CacheDiscard() +void TimelineWidget::cache_discard() { if (QMessageBox::question( this, tr("Discard Cache"), @@ -2150,13 +2150,13 @@ void TimelineWidget::CacheDiscard() QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { for (Block *b : selected_blocks_) { if (ClipBlock *clip = dynamic_cast(b)) { - clip->DiscardCache(); + clip->discard_cache(); } } } } -void TimelineWidget::MulticamEnabledTriggered(bool e) +void TimelineWidget::multicam_enabled_triggered(bool e) { MultiUndoCommand *command = new MultiUndoCommand(); @@ -2167,22 +2167,22 @@ void TimelineWidget::MulticamEnabledTriggered(bool e) // Adding multicams // Create multicam node and add it to the graph MultiCamNode *n = new MultiCamNode(); - n->SetSequenceType(c->GetTrackType()); + n->set_sequence_type(c->get_track_type()); command->add_child(new NodeAddCommand(s->parent(), n)); // For each output the sequence has to this clip, disconnect it and // connect to the multicam instead - QVector inputs = c->FindWaysNodeArrivesHere(s); + QVector inputs = c->find_ways_node_arrives_here(s); for (const NodeInput &i : inputs) { command->add_child(new NodeEdgeRemoveCommand(s, i)); command->add_child(new NodeEdgeAddCommand(n, i)); } command->add_child(new NodeEdgeAddCommand( - s, NodeInput(n, n->kSequenceInput))); + s, NodeInput(n, n->k_sequence_input))); // Move sequence node one unit back, and place multicam in sequence's spot - QPointF sequence_pos = c->GetNodePositionInContext(s); + QPointF sequence_pos = c->get_node_position_in_context(s); command->add_child(new NodeSetPositionCommand( s, c, sequence_pos - QPointF(1, 0))); command->add_child( @@ -2191,7 +2191,7 @@ void TimelineWidget::MulticamEnabledTriggered(bool e) } else { // Removing multicams // Locate first multicam that specifically ends up at this clip - QVector inputs = c->FindWaysNodeArrivesHere(s); + QVector inputs = c->find_ways_node_arrives_here(s); for (const NodeInput &i : inputs) { if (MultiCamNode *mcn = dynamic_cast(i.node())) { @@ -2218,36 +2218,36 @@ void TimelineWidget::MulticamEnabledTriggered(bool e) tr("Multi-Cam Disabled On %1 Clip(s)").arg(selected_blocks_.size())); } -void TimelineWidget::ForceUpdateRubberBand() +void TimelineWidget::force_update_rubber_band() { if (rubberband_.isVisible()) { - this->MoveRubberBandSelect(rubberband_enable_selecting_, + this->move_rubber_band_select(rubberband_enable_selecting_, rubberband_select_links_); } } -void TimelineWidget::AddGhost(TimelineViewGhostItem *ghost) +void TimelineWidget::add_ghost(TimelineViewGhostItem *ghost) { ghost_items_.append(ghost); - UpdateViewports(ghost->GetTrack().type()); + update_viewports(ghost->get_track().type()); } -void TimelineWidget::UpdateViewTimebases() +void TimelineWidget::update_view_timebases() { for (int i = 0; i < views_.size(); i++) { TimelineAndTrackView *view = views_.at(i); - if (GetConnectedNode() && use_audio_time_units_ && i == Track::kAudio) { - view->view()->SetTimebase( - GetConnectedNode()->GetAudioParams().sample_rate_as_time_base()); + if (get_connected_node() && use_audio_time_units_ && i == Track::k_audio) { + view->view()->set_timebase( + get_connected_node()->get_audio_params().sample_rate_as_time_base()); } else { - view->view()->SetTimebase(timebase()); + view->view()->set_timebase(timebase()); } } } -void TimelineWidget::NudgeInternal(rational amount) +void TimelineWidget::nudge_internal(Rational amount) { if (!selected_blocks_.isEmpty()) { // Validate @@ -2270,48 +2270,48 @@ void TimelineWidget::NudgeInternal(rational amount) foreach (Block *b, selected_blocks_) { command->add_child(new TrackPlaceBlockCommand( - sequence()->track_list(b->track()->type()), b->track()->Index(), + sequence()->track_list(b->track()->type()), b->track()->index(), b, b->in() + amount)); } // Nudge selections - TimelineWidgetSelections new_sel = GetSelections(); - new_sel.ShiftTime(amount); + TimelineWidgetSelections new_sel = get_selections(); + new_sel.shift_time(amount); command->add_child(new TimelineWidget::SetSelectionsCommand( - this, new_sel, GetSelections())); + this, new_sel, get_selections())); Core::instance()->undo_stack()->push(command, tr("Nudged Clips")); } } -void TimelineWidget::MoveToPlayheadInternal(bool out) +void TimelineWidget::move_to_playhead_internal(bool out) { - if (GetConnectedNode() && !selected_blocks_.isEmpty()) { + if (get_connected_node() && !selected_blocks_.isEmpty()) { MultiUndoCommand *command = new MultiUndoCommand(); // Remove each block from the graph - QHash earliest_pts; + QHash earliest_pts; foreach (Block *b, selected_blocks_) { command->add_child( new TrackReplaceBlockWithGapCommand(b->track(), b, false)); - rational r = earliest_pts.value(b->track(), + Rational r = earliest_pts.value(b->track(), out ? RATIONAL_MIN : RATIONAL_MAX); - rational compare = out ? b->out() : b->in(); + Rational compare = out ? b->out() : b->in(); if ((compare < r) == !out) { earliest_pts.insert(b->track(), compare); } } foreach (Block *b, selected_blocks_) { - rational shift_amt = GetConnectedNode()->GetPlayhead() - + Rational shift_amt = get_connected_node()->get_playhead() - earliest_pts.value(b->track()); - rational new_in = b->in() + shift_amt; + Rational new_in = b->in() + shift_amt; bool can_shift = true; if (new_in < 0) { // Handle clips threatening to go below 0 - rational new_out = new_in + b->length(); + Rational new_out = new_in + b->length(); if (new_out <= 0) { can_shift = false; } else { @@ -2324,55 +2324,55 @@ void TimelineWidget::MoveToPlayheadInternal(bool out) if (can_shift) { command->add_child(new TrackPlaceBlockCommand( sequence()->track_list(b->track()->type()), - b->track()->Index(), b, new_in)); + b->track()->index(), b, new_in)); } } // Shift selections - TimelineWidgetSelections new_sel = GetSelections(); + TimelineWidgetSelections new_sel = get_selections(); for (auto it = new_sel.begin(); it != new_sel.end(); it++) { - rational track_adj = - GetConnectedNode()->GetPlayhead() - - earliest_pts.value(GetTrackFromReference(it.key()), - GetConnectedNode()->GetPlayhead()); + Rational track_adj = + get_connected_node()->get_playhead() - + earliest_pts.value(get_track_from_reference(it.key()), + get_connected_node()->get_playhead()); if (!track_adj.isNull()) { it.value().shift(track_adj); } } command->add_child( - new SetSelectionsCommand(this, new_sel, GetSelections())); + new SetSelectionsCommand(this, new_sel, get_selections())); Core::instance()->undo_stack()->push(command, tr("Moved Clip(s) To Point")); } } -void TimelineWidget::SetViewBeamCursor(const TimelineCoordinate &coord) +void TimelineWidget::set_view_beam_cursor(const TimelineCoordinate &coord) { foreach (TimelineAndTrackView *tview, views_) { - tview->view()->SetBeamCursor(coord); + tview->view()->set_beam_cursor(coord); } } -void TimelineWidget::SetViewTransitionOverlay(ClipBlock *out, ClipBlock *in) +void TimelineWidget::set_view_transition_overlay(ClipBlock *out, ClipBlock *in) { foreach (TimelineAndTrackView *tview, views_) { - tview->view()->SetTransitionOverlay(out, in); + tview->view()->set_transition_overlay(out, in); } } -void TimelineWidget::SetBlockLinksSelected(ClipBlock *block, bool selected) +void TimelineWidget::set_block_links_selected(ClipBlock *block, bool selected) { foreach (Block *link, block->block_links()) { if (selected) { - AddSelection(link); + add_selection(link); } else { - RemoveSelection(link); + remove_selection(link); } } } -void TimelineWidget::QueueScroll(int value) +void TimelineWidget::queue_scroll(int value) { // (using a hacky singleShot so the scroll occurs after the scene and its scrollbars have updated) deferred_scroll_value_ = value; @@ -2380,22 +2380,22 @@ void TimelineWidget::QueueScroll(int value) QTimer::singleShot(0, this, &TimelineWidget::DeferredScrollAction); } -TimelineView *TimelineWidget::GetFirstTimelineView() +TimelineView *TimelineWidget::get_first_timeline_view() { return views_.first()->view(); } -rational TimelineWidget::GetTimebaseForTrackType(Track::Type type) +Rational TimelineWidget::get_timebase_for_track_type(Track::Type type) { return views_.at(type)->view()->timebase(); } -const QRect &TimelineWidget::GetRubberBandGeometry() const +const QRect &TimelineWidget::get_rubber_band_geometry() const { return rubberband_.geometry(); } -void TimelineWidget::SignalSelectedBlocks(QVector input, bool filter) +void TimelineWidget::signal_selected_blocks(QVector input, bool filter) { if (input.isEmpty()) { return; @@ -2415,10 +2415,10 @@ void TimelineWidget::SignalSelectedBlocks(QVector input, bool filter) selected_blocks_.append(input); - SignalBlockSelectionChange(); + signal_block_selection_change(); } -void TimelineWidget::SignalDeselectedBlocks( +void TimelineWidget::signal_deselected_blocks( const QVector &deselected_blocks) { if (deselected_blocks.isEmpty()) { @@ -2429,23 +2429,23 @@ void TimelineWidget::SignalDeselectedBlocks( selected_blocks_.removeOne(b); } - SignalBlockSelectionChange(); + signal_block_selection_change(); } -void TimelineWidget::SignalDeselectedAllBlocks() +void TimelineWidget::signal_deselected_all_blocks() { if (!selected_blocks_.isEmpty()) { selected_blocks_.clear(); - SignalBlockSelectionChange(); + signal_block_selection_change(); } } QVector -TimelineWidget::GetEditToInfo(const rational &playhead_time, +TimelineWidget::get_edit_to_info(const Rational &playhead_time, Timeline::MovementMode mode) { // Get list of unlocked tracks - QVector tracks = sequence()->GetUnlockedTracks(); + QVector tracks = sequence()->get_unlocked_tracks(); // Create list to cache nearest times and the blocks at this point QVector info_list(tracks.size()); @@ -2460,17 +2460,17 @@ TimelineWidget::GetEditToInfo(const rational &playhead_time, // Determine what block is at this time (for "trim in", we want to catch blocks that start at // the time, for "trim out" we don't) - if (mode == Timeline::kTrimIn) { - b = track->NearestBlockBeforeOrAt(playhead_time); + if (mode == Timeline::k_trim_in) { + b = track->nearest_block_before_or_at(playhead_time); } else { - b = track->NearestBlockBefore(playhead_time); + b = track->nearest_block_before(playhead_time); } // If we have a block here, cache how close it is to the track if (b) { - rational this_track_closest_point; + Rational this_track_closest_point; - if (mode == Timeline::kTrimIn) { + if (mode == Timeline::k_trim_in) { this_track_closest_point = b->in(); } else { this_track_closest_point = b->out(); @@ -2485,27 +2485,27 @@ TimelineWidget::GetEditToInfo(const rational &playhead_time, return info_list; } -void TimelineWidget::RippleTo(Timeline::MovementMode mode) +void TimelineWidget::ripple_to(Timeline::MovementMode mode) { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } - rational playhead_time = GetConnectedNode()->GetPlayhead(); + Rational playhead_time = get_connected_node()->get_playhead(); - QVector tracks = GetEditToInfo(playhead_time, mode); + QVector tracks = get_edit_to_info(playhead_time, mode); if (tracks.isEmpty()) { return; } // Find each track's nearest point and determine the overall timeline's nearest point - rational closest_point_to_playhead = - (mode == Timeline::kTrimIn) ? RATIONAL_MIN : RATIONAL_MAX; + Rational closest_point_to_playhead = + (mode == Timeline::k_trim_in) ? RATIONAL_MIN : RATIONAL_MAX; foreach (const Timeline::EditToInfo &info, tracks) { if (info.nearest_block) { - if (mode == Timeline::kTrimIn) { + if (mode == Timeline::k_trim_in) { closest_point_to_playhead = qMax(info.nearest_time, closest_point_to_playhead); } else { @@ -2524,7 +2524,7 @@ void TimelineWidget::RippleTo(Timeline::MovementMode mode) // If we're not inserting gaps and the edit point is right on the nearest in point, we enter a // single-frame mode where we remove one frame only if (closest_point_to_playhead == playhead_time) { - if (mode == Timeline::kTrimIn) { + if (mode == Timeline::k_trim_in) { playhead_time += timebase(); } else { playhead_time -= timebase(); @@ -2532,8 +2532,8 @@ void TimelineWidget::RippleTo(Timeline::MovementMode mode) } // For standard rippling, we can cache here the region that will be rippled out - rational in_ripple = qMin(closest_point_to_playhead, playhead_time); - rational out_ripple = qMax(closest_point_to_playhead, playhead_time); + Rational in_ripple = qMin(closest_point_to_playhead, playhead_time); + Rational out_ripple = qMax(closest_point_to_playhead, playhead_time); TimelineRippleRemoveAreaCommand *c = new TimelineRippleRemoveAreaCommand(sequence(), in_ripple, out_ripple); @@ -2541,20 +2541,20 @@ void TimelineWidget::RippleTo(Timeline::MovementMode mode) Core::instance()->undo_stack()->push(c, tr("Rippled Clip(s) To Point")); // If we rippled, ump to where new cut is if applicable - if (mode == Timeline::kTrimIn) { - GetConnectedNode()->SetPlayhead(closest_point_to_playhead); - } else if (mode == Timeline::kTrimOut && - closest_point_to_playhead == GetConnectedNode()->GetPlayhead()) { - GetConnectedNode()->SetPlayhead(playhead_time); + if (mode == Timeline::k_trim_in) { + get_connected_node()->set_playhead(closest_point_to_playhead); + } else if (mode == Timeline::k_trim_out && + closest_point_to_playhead == get_connected_node()->get_playhead()) { + get_connected_node()->set_playhead(playhead_time); } } -void TimelineWidget::EditTo(Timeline::MovementMode mode) +void TimelineWidget::edit_to(Timeline::MovementMode mode) { - const rational playhead_time = GetConnectedNode()->GetPlayhead(); + const Rational playhead_time = get_connected_node()->get_playhead(); // Get list of unlocked tracks - QVector tracks = GetEditToInfo(playhead_time, mode); + QVector tracks = get_edit_to_info(playhead_time, mode); if (tracks.isEmpty()) { return; @@ -2566,9 +2566,9 @@ void TimelineWidget::EditTo(Timeline::MovementMode mode) if (info.nearest_block && !dynamic_cast(info.nearest_block) && info.nearest_time != playhead_time) { - rational new_len; + Rational new_len; - if (mode == Timeline::kTrimIn) { + if (mode == Timeline::k_trim_in) { new_len = playhead_time - info.nearest_time; } else { new_len = info.nearest_time - playhead_time; @@ -2583,9 +2583,9 @@ void TimelineWidget::EditTo(Timeline::MovementMode mode) Core::instance()->undo_stack()->push(command, tr("Cut Clip(s) To Point")); } -void TimelineWidget::UpdateViewports(const Track::Type &type) +void TimelineWidget::update_viewports(const Track::Type &type) { - if (type == Track::kNone) { + if (type == Track::k_none) { foreach (TimelineAndTrackView *tview, views_) { tview->view()->viewport()->update(); } @@ -2594,60 +2594,60 @@ void TimelineWidget::UpdateViewports(const Track::Type &type) } } -bool TimelineWidget::PasteInternal(bool insert) +bool TimelineWidget::paste_internal(bool insert) { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return false; } - ProjectSerializer::Result res = ProjectSerializer::Paste( - ProjectSerializer::kOnlyClips, GetConnectedNode()->project()); - if (res.GetLoadData().nodes.isEmpty()) { + ProjectSerializer::Result res = ProjectSerializer::paste( + ProjectSerializer::k_only_clips, get_connected_node()->project()); + if (res.get_load_data().nodes.isEmpty()) { return false; } MultiUndoCommand *command = new MultiUndoCommand(); - Project *project = GetConnectedNode()->project(); - foreach (Node *n, res.GetLoadData().nodes) { + Project *project = get_connected_node()->project(); + foreach (Node *n, res.get_load_data().nodes) { command->add_child(new NodeAddCommand(project, n)); - if (n->IsItem() && !n->folder()) { + if (n->is_item() && !n->folder()) { command->add_child(new FolderAddChild(project->root(), n)); } } - for (auto it = res.GetLoadData().promised_connections.cbegin(); - it != res.GetLoadData().promised_connections.cend(); it++) { + for (auto it = res.get_load_data().promised_connections.cbegin(); + it != res.get_load_data().promised_connections.cend(); it++) { auto oc = *it; command->add_child(new NodeEdgeAddCommand(oc.first, oc.second)); } - rational paste_start = GetConnectedNode()->GetPlayhead(); + Rational paste_start = get_connected_node()->get_playhead(); if (insert) { - rational paste_end = paste_start; + Rational paste_end = paste_start; - for (auto it = res.GetLoadData().properties.cbegin(); - it != res.GetLoadData().properties.cend(); it++) { - rational length = static_cast(it.key())->length(); - rational in = rational::fromString( + for (auto it = res.get_load_data().properties.cbegin(); + it != res.get_load_data().properties.cend(); it++) { + Rational length = static_cast(it.key())->length(); + Rational in = Rational::from_string( it.value()[QStringLiteral("in")].toStdString()); paste_end = qMax(paste_end, paste_start + in + length); } if (paste_end != paste_start) { - InsertGapsAt(paste_start, paste_end - paste_start, command); + insert_gaps_at(paste_start, paste_end - paste_start, command); } } - for (auto it = res.GetLoadData().properties.cbegin(); - it != res.GetLoadData().properties.cend(); it++) { + for (auto it = res.get_load_data().properties.cbegin(); + it != res.get_load_data().properties.cend(); it++) { Block *block = static_cast(it.key()); - rational in = rational::fromString( + Rational in = Rational::from_string( it.value()[QStringLiteral("in")].toStdString()); Track::Reference track = - Track::Reference::FromString(it.value()[QStringLiteral("track")]); + Track::Reference::from_string(it.value()[QStringLiteral("track")]); command->add_child( new TrackPlaceBlockCommand(sequence()->track_list(track.type()), @@ -2656,29 +2656,29 @@ bool TimelineWidget::PasteInternal(bool insert) Core::instance()->undo_stack()->push( command, - tr("Pasted %1 Clip(s)").arg(res.GetLoadData().properties.size())); + tr("Pasted %1 Clip(s)").arg(res.get_load_data().properties.size())); return true; } TimelineAndTrackView * -TimelineWidget::AddTimelineAndTrackView(Qt::Alignment alignment) +TimelineWidget::add_timeline_and_track_view(Qt::Alignment alignment) { TimelineAndTrackView *v = new TimelineAndTrackView(alignment); - connect(v->track_view(), &TrackView::AboutToDeleteTrack, this, - &TimelineWidget::TrackAboutToBeDeleted); + connect(v->track_view(), &TrackView::about_to_delete_track, this, + &TimelineWidget::track_about_to_be_deleted); return v; } QHash -TimelineWidget::GenerateExistingPasteMap(const ProjectSerializer::Result &r) +TimelineWidget::generate_existing_paste_map(const ProjectSerializer::Result &r) { QHash m; - for (Node *n : r.GetLoadData().nodes) { + for (Node *n : r.get_load_data().nodes) { for (Block *b : qAsConst(this->selected_blocks_)) { - for (auto it = b->GetContextPositions().cbegin(); - it != b->GetContextPositions().cend(); it++) { + for (auto it = b->get_context_positions().cbegin(); + it != b->get_context_positions().cend(); it++) { if (it.key()->id() == n->id() && !m.contains(it.key())) { m.insert(it.key(), n); break; @@ -2690,23 +2690,23 @@ TimelineWidget::GenerateExistingPasteMap(const ProjectSerializer::Result &r) return m; } -QByteArray TimelineWidget::SaveSplitterState() const +QByteArray TimelineWidget::save_splitter_state() const { return view_splitter_->saveState(); } -void TimelineWidget::RestoreSplitterState(const QByteArray &state) +void TimelineWidget::restore_splitter_state(const QByteArray &state) { view_splitter_->restoreState(state); } -void TimelineWidget::StartRubberBandSelect(const QPoint &global_cursor_start) +void TimelineWidget::start_rubber_band_select(const QPoint &global_cursor_start) { // Store scene positions for each view rubberband_scene_pos_.resize(views_.size()); for (int i = 0; i < rubberband_scene_pos_.size(); i++) { TimelineView *v = views_.at(i)->view(); - rubberband_scene_pos_[i] = v->UnscalePoint( + rubberband_scene_pos_[i] = v->unscale_point( v->mapToScene(v->mapFromGlobal(global_cursor_start))); } @@ -2717,7 +2717,7 @@ void TimelineWidget::StartRubberBandSelect(const QPoint &global_cursor_start) rubberband_old_selections_ = selections_; } -void TimelineWidget::MoveRubberBandSelect(bool enable_selecting, +void TimelineWidget::move_rubber_band_select(bool enable_selecting, bool select_links) { QPoint rubberband_now = QCursor::pos(); @@ -2725,12 +2725,12 @@ void TimelineWidget::MoveRubberBandSelect(bool enable_selecting, TimelineView *fv = views_.first()->view(); const QPointF &rubberband_scene_start = rubberband_scene_pos_.at(0); QPointF rubberband_now_scaled = - fv->UnscalePoint(fv->mapToScene(fv->mapFromGlobal(rubberband_now))); + fv->unscale_point(fv->mapToScene(fv->mapFromGlobal(rubberband_now))); QPoint rubberband_local_start = fv->mapTo( - this, fv->mapFromScene(fv->ScalePoint(rubberband_scene_start))); + this, fv->mapFromScene(fv->scale_point(rubberband_scene_start))); QPoint rubberband_local_now = fv->mapTo( - this, fv->mapFromScene(fv->ScalePoint(rubberband_now_scaled))); + this, fv->mapFromScene(fv->scale_point(rubberband_now_scaled))); rubberband_.setGeometry( QRect(rubberband_local_start, rubberband_local_now).normalized()); @@ -2747,14 +2747,14 @@ void TimelineWidget::MoveRubberBandSelect(bool enable_selecting, for (int i = 0; i < views_.size(); i++) { TimelineView *v = views_.at(i)->view(); - QRectF r = QRectF(v->ScalePoint(rubberband_scene_pos_.at(i)), + QRectF r = QRectF(v->scale_point(rubberband_scene_pos_.at(i)), v->mapToScene(v->mapFromGlobal(rubberband_now))) .normalized(); - items_in_rubberband.append(v->GetItemsAtSceneRect(r)); + items_in_rubberband.append(v->get_items_at_scene_rect(r)); } // Reset selection to whatever it was before - SetSelections(rubberband_old_selections_, false); + set_selections(rubberband_old_selections_, false); // Add any blocks in rubberband rubberband_now_selected_.clear(); @@ -2765,12 +2765,12 @@ void TimelineWidget::MoveRubberBandSelect(bool enable_selecting, } Track *t = b->track(); - if (t->IsLocked()) { + if (t->is_locked()) { continue; } if (!rubberband_now_selected_.contains(b)) { - AddSelection(b); + add_selection(b); rubberband_now_selected_.append(b); } @@ -2778,7 +2778,7 @@ void TimelineWidget::MoveRubberBandSelect(bool enable_selecting, if (c && select_links) { foreach (Block *link, c->block_links()) { if (!rubberband_now_selected_.contains(link)) { - AddSelection(link); + add_selection(link); rubberband_now_selected_.append(link); } } @@ -2786,55 +2786,55 @@ void TimelineWidget::MoveRubberBandSelect(bool enable_selecting, } } -void TimelineWidget::EndRubberBandSelect() +void TimelineWidget::end_rubber_band_select() { rubberband_.hide(); // Emit any blocks that were newly selected - SignalSelectedBlocks(rubberband_now_selected_); + signal_selected_blocks(rubberband_now_selected_); rubberband_now_selected_.clear(); rubberband_old_selections_.clear(); } -void TimelineWidget::AddSelection(const TimeRange &time, +void TimelineWidget::add_selection(const TimeRange &time, const Track::Reference &track) { selections_[track].insert(time); - UpdateViewports(track.type()); + update_viewports(track.type()); } -void TimelineWidget::AddSelection(Block *item) +void TimelineWidget::add_selection(Block *item) { if (item->track()) { - AddSelection(item->range(), item->track()->ToReference()); + add_selection(item->range(), item->track()->to_reference()); } } -void TimelineWidget::RemoveSelection(const TimeRange &time, +void TimelineWidget::remove_selection(const TimeRange &time, const Track::Reference &track) { selections_[track].remove(time); - UpdateViewports(track.type()); + update_viewports(track.type()); } -void TimelineWidget::RemoveSelection(Block *item) +void TimelineWidget::remove_selection(Block *item) { if (item->track()) { - RemoveSelection(item->range(), item->track()->ToReference()); + remove_selection(item->range(), item->track()->to_reference()); } } -void TimelineWidget::SetSelections(const TimelineWidgetSelections &s, +void TimelineWidget::set_selections(const TimelineWidgetSelections &s, bool process_block_changes) { if (selections_ == s) { return; } - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } @@ -2843,18 +2843,18 @@ void TimelineWidget::SetSelections(const TimelineWidgetSelections &s, QVector selected; foreach (Block *b, selected_blocks_) { - if (!s[b->track()->ToReference()].contains(b->range())) { + if (!s[b->track()->to_reference()].contains(b->range())) { deselected.append(b); } } // NOTE: This loop could do with some optimization for (auto it = s.cbegin(); it != s.cend(); it++) { - Track *track = GetTrackFromReference(it.key()); + Track *track = get_track_from_reference(it.key()); if (track) { const TimeRangeList &ranges = it.value(); - foreach (Block *b, track->Blocks()) { + foreach (Block *b, track->blocks()) { if (!selected_blocks_.contains(b) && ranges.contains(b->range())) { selected.append(b); @@ -2863,20 +2863,20 @@ void TimelineWidget::SetSelections(const TimelineWidgetSelections &s, } } - SignalDeselectedBlocks(deselected); - SignalSelectedBlocks(selected); + signal_deselected_blocks(deselected); + signal_selected_blocks(selected); } selections_ = s; - UpdateViewports(); + update_viewports(); } -Block *TimelineWidget::GetItemAtScenePos(const TimelineCoordinate &coord) +Block *TimelineWidget::get_item_at_scene_pos(const TimelineCoordinate &coord) { - return views_.at(coord.GetTrack().type()) + return views_.at(coord.get_track().type()) ->view() - ->GetItemAtScenePos(coord.GetFrame(), coord.GetTrack().index()); + ->get_item_at_scene_pos(coord.get_frame(), coord.get_track().index()); } void TimelineWidget::SetSplitterSizesCommand::redo() diff --git a/app/widget/timelinewidget/timelinewidget.h b/app/widget/timelinewidget/timelinewidget.h index 268ff6d80..6cd86eeb4 100644 --- a/app/widget/timelinewidget/timelinewidget.h +++ b/app/widget/timelinewidget/timelinewidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEWIDGET_H -#define TIMELINEWIDGET_H +#ifndef OAK_TIMELINEWIDGET_H +#define OAK_TIMELINEWIDGET_H #include #include @@ -53,103 +53,103 @@ public: virtual ~TimelineWidget() override; - void Clear(); + void clear(); - void SelectAll(); + void select_all(); - void DeselectAll(); + void deselect_all(); - void RippleToIn(); + void ripple_to_in(); - void RippleToOut(); + void ripple_to_out(); - void EditToIn(); + void edit_to_in(); - void EditToOut(); + void edit_to_out(); - void SplitAtPlayhead(); + void split_at_playhead(); void DeleteSelected(bool ripple = false); - void IncreaseTrackHeight(); + void increase_track_height(); - void DecreaseTrackHeight(); + void decrease_track_height(); - void InsertFootageAtPlayhead(const QVector &footage); + void insert_footage_at_playhead(const QVector &footage); - void OverwriteFootageAtPlayhead(const QVector &footage); + void overwrite_footage_at_playhead(const QVector &footage); - void ToggleLinksOnSelected(); + void toggle_links_on_selected(); - void AddDefaultTransitionsToSelected(); + void add_default_transitions_to_selected(); - virtual bool CopySelected(bool cut) override; + virtual bool copy_selected(bool cut) override; - virtual bool Paste() override; + virtual bool paste() override; - void PasteInsert(); + void paste_insert(); - void DeleteInToOut(bool ripple); + void delete_in_to_out(bool ripple); - void ToggleSelectedEnabled(); + void toggle_selected_enabled(); - void SetColorLabel(int index); + void set_color_label(int index); - void NudgeLeft(); + void nudge_left(); - void NudgeRight(); + void nudge_right(); - void MoveInToPlayhead(); + void move_in_to_playhead(); - void MoveOutToPlayhead(); + void move_out_to_playhead(); - void ShowSpeedDurationDialogForSelectedClips(); + void show_speed_duration_dialog_for_selected_clips(); - void SynchronizeSelectedClipsBySourceTime(); + void synchronize_selected_clips_by_source_time(); - void SynchronizeSelectedClipsByWaveform(); + void synchronize_selected_clips_by_waveform(); - void SynchronizeSelectedClipsByWaveformWithSpeed(); + void synchronize_selected_clips_by_waveform_with_speed(); - void GenerateProxiesForSelectedClips(); + void generate_proxies_for_selected_clips(); - void SetSelectedClipsProxyEnabled(bool enabled); + void set_selected_clips_proxy_enabled(bool enabled); - void RevealProxyForSelectedClips(); + void reveal_proxy_for_selected_clips(); - void DeleteProxiesForSelectedClips(); + void delete_proxies_for_selected_clips(); - void ShowProxyDialogForSelectedClips(); + void show_proxy_dialog_for_selected_clips(); - void RecordingCallback(const QString &filename, const TimeRange &time, + void recording_callback(const QString &filename, const TimeRange &time, const Track::Reference &track); - void EnableRecordingOverlay(const TimelineCoordinate &coord); + void enable_recording_overlay(const TimelineCoordinate &coord); - void DisableRecordingOverlay(); + void disable_recording_overlay(); - void AddTentativeSubtitleTrack(); + void add_tentative_subtitle_track(); - void NestSelectedClips(); + void nest_selected_clips(); /** * @brief Timelines should always be connected to sequences */ Sequence *sequence() const { - return static_cast(GetConnectedNode()); + return static_cast(get_connected_node()); } - const QVector &GetSelectedBlocks() const + const QVector &get_selected_blocks() const { return selected_blocks_; } - QByteArray SaveSplitterState() const; + QByteArray save_splitter_state() const; - void RestoreSplitterState(const QByteArray &state); + void restore_splitter_state(const QByteArray &state); - static void ReplaceBlocksWithGaps(const QVector &blocks, + static void replace_blocks_with_gaps(const QVector &blocks, bool remove_from_graph, MultiUndoCommand *command, bool handle_transitions = true); @@ -160,65 +160,65 @@ public: * Requires a float-based scene position. If you have a screen position, use GetScenePos() first to convert it to a * scene position */ - Block *GetItemAtScenePos(const TimelineCoordinate &coord); + Block *get_item_at_scene_pos(const TimelineCoordinate &coord); - void AddSelection(const TimeRange &time, const Track::Reference &track); - void AddSelection(Block *item); + void add_selection(const TimeRange &time, const Track::Reference &track); + void add_selection(Block *item); - void RemoveSelection(const TimeRange &time, const Track::Reference &track); - void RemoveSelection(Block *item); + void remove_selection(const TimeRange &time, const Track::Reference &track); + void remove_selection(Block *item); - const TimelineWidgetSelections &GetSelections() const + const TimelineWidgetSelections &get_selections() const { return selections_; } - void SetSelections(const TimelineWidgetSelections &s, + void set_selections(const TimelineWidgetSelections &s, bool process_block_changes); - Track *GetTrackFromReference(const Track::Reference &ref) const; + Track *get_track_from_reference(const Track::Reference &ref) const; - void SetViewBeamCursor(const TimelineCoordinate &coord); - void SetViewTransitionOverlay(ClipBlock *out, ClipBlock *in); + void set_view_beam_cursor(const TimelineCoordinate &coord); + void set_view_transition_overlay(ClipBlock *out, ClipBlock *in); - const QVector &GetGhostItems() const + const QVector &get_ghost_items() const { return ghost_items_; } - void InsertGapsAt(const rational &time, const rational &length, + void insert_gaps_at(const Rational &time, const Rational &length, MultiUndoCommand *command); - void StartRubberBandSelect(const QPoint &global_cursor_start); - void MoveRubberBandSelect(bool enable_selecting, bool select_links); - void EndRubberBandSelect(); + void start_rubber_band_select(const QPoint &global_cursor_start); + void move_rubber_band_select(bool enable_selecting, bool select_links); + void end_rubber_band_select(); - int GetTrackY(const Track::Reference &ref); - int GetTrackHeight(const Track::Reference &ref); + int get_track_y(const Track::Reference &ref); + int get_track_height(const Track::Reference &ref); - void AddGhost(TimelineViewGhostItem *ghost); + void add_ghost(TimelineViewGhostItem *ghost); - void ClearGhosts(); + void clear_ghosts(); - bool HasGhosts() const + bool has_ghosts() const { return !ghost_items_.isEmpty(); } - bool IsBlockSelected(Block *b) const + bool is_block_selected(Block *b) const { return selected_blocks_.contains(b); } - void SetBlockLinksSelected(ClipBlock *block, bool selected); + void set_block_links_selected(ClipBlock *block, bool selected); - void QueueScroll(int value); + void queue_scroll(int value); - TimelineView *GetFirstTimelineView(); + TimelineView *get_first_timeline_view(); - rational GetTimebaseForTrackType(Track::Type type); + Rational get_timebase_for_track_type(Track::Type type); - const QRect &GetRubberBandGeometry() const; + const QRect &get_rubber_band_geometry() const; /** * @brief Track blocks that have newly been selected (this is preferred over emitting BlocksSelected directly) @@ -236,25 +236,25 @@ public: * this is preferable and should only be set to FALSE if the list is guaranteed not to contain * already selected blocks (and therefore filtering can be skipped to save time). */ - void SignalSelectedBlocks(QVector selected_blocks, + void signal_selected_blocks(QVector selected_blocks, bool filter = true); /** * @brief Track blocks that have been newly deselected */ - void SignalDeselectedBlocks(const QVector &deselected_blocks); + void signal_deselected_blocks(const QVector &deselected_blocks); /** * @brief Convenience function to deselect all blocks and signal them */ - void SignalDeselectedAllBlocks(); + void signal_deselected_all_blocks(); - void Refresh() + void refresh() { - UpdateViewports(); + update_viewports(); } - MultiUndoCommand *TakeSubtitleSectionCommand() + MultiUndoCommand *take_subtitle_section_command() { // Copy pointer MultiUndoCommand *c = subtitle_show_command_; @@ -280,7 +280,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nullptr; } @@ -288,12 +288,12 @@ public: protected: virtual void redo() override { - timeline_->SetSelections(now_, process_block_changes_); + timeline_->set_selections(now_, process_block_changes_); } virtual void undo() override { - timeline_->SetSelections(old_, process_block_changes_); + timeline_->set_selections(old_, process_block_changes_); } private: @@ -304,30 +304,30 @@ public: }; public slots: - void ClearTentativeSubtitleTrack(); + void clear_tentative_subtitle_track(); - void RenameSelectedBlocks(); + void rename_selected_blocks(); signals: - void BlockSelectionChanged(const QVector &selected_blocks); + void block_selection_changed(const QVector &selected_blocks); - void RequestCaptureStart(const TimeRange &time, + void request_capture_start(const TimeRange &time, const Track::Reference &track); - void RevealViewerInFootageViewer(ViewerOutput *r, const TimeRange &range); - void RevealViewerInProject(ViewerOutput *r); + void reveal_viewer_in_footage_viewer(ViewerOutput *r, const TimeRange &range); + void reveal_viewer_in_project(ViewerOutput *r); protected: virtual void resizeEvent(QResizeEvent *event) override; - virtual void TimeChangedEvent(const rational &) override; - virtual void TimebaseChangedEvent(const rational &) override; + virtual void TimeChangedEvent(const Rational &) override; + virtual void TimebaseChangedEvent(const Rational &) override; virtual void ScaleChangedEvent(const double &) override; virtual void ConnectNodeEvent(ViewerOutput *n) override; virtual void DisconnectNodeEvent(ViewerOutput *n) override; - virtual const QVector *GetSnapBlocks() const override + virtual const QVector *get_snap_blocks() const override { return &added_blocks_; } @@ -336,23 +336,23 @@ protected slots: virtual void SendCatchUpScrollEvent() override; private: - QVector GetEditToInfo(const rational &playhead_time, + QVector get_edit_to_info(const Rational &playhead_time, Timeline::MovementMode mode); - void RippleTo(Timeline::MovementMode mode); + void ripple_to(Timeline::MovementMode mode); - void EditTo(Timeline::MovementMode mode); + void edit_to(Timeline::MovementMode mode); - void UpdateViewports(const Track::Type &type = Track::kNone); + void update_viewports(const Track::Type &type = Track::k_none); - bool PasteInternal(bool insert); + bool paste_internal(bool insert); - void SynchronizeSelectedClipsByWaveformInternal(bool allow_speed); + void synchronize_selected_clips_by_waveform_internal(bool allow_speed); - TimelineAndTrackView *AddTimelineAndTrackView(Qt::Alignment alignment); + TimelineAndTrackView *add_timeline_and_track_view(Qt::Alignment alignment); QHash - GenerateExistingPasteMap(const ProjectSerializer::Result &r); + generate_existing_paste_map(const ProjectSerializer::Result &r); QRubberBand rubberband_; QVector rubberband_scene_pos_; @@ -363,7 +363,7 @@ private: TimelineWidgetSelections selections_; - TimelineTool *GetActiveTool(); + TimelineTool *get_active_tool(); QVector tools_; @@ -400,7 +400,7 @@ private: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nullptr; } @@ -415,78 +415,78 @@ private: QList old_sizes_; }; - void CenterOn(qreal scene_pos); + void center_on(qreal scene_pos); - void UpdateViewTimebases(); + void update_view_timebases(); - void NudgeInternal(rational amount); + void nudge_internal(Rational amount); - void MoveToPlayheadInternal(bool out); + void move_to_playhead_internal(bool out); private slots: - void ViewMousePressed(TimelineViewMouseEvent *event); - void ViewMouseMoved(TimelineViewMouseEvent *event); - void ViewMouseReleased(TimelineViewMouseEvent *event); - void ViewMouseDoubleClicked(TimelineViewMouseEvent *event); + void view_mouse_pressed(TimelineViewMouseEvent *event); + void view_mouse_moved(TimelineViewMouseEvent *event); + void view_mouse_released(TimelineViewMouseEvent *event); + void view_mouse_double_clicked(TimelineViewMouseEvent *event); - void ViewDragEntered(TimelineViewMouseEvent *event); - void ViewDragMoved(TimelineViewMouseEvent *event); - void ViewDragLeft(QDragLeaveEvent *event); - void ViewDragDropped(TimelineViewMouseEvent *event); + void view_drag_entered(TimelineViewMouseEvent *event); + void view_drag_moved(TimelineViewMouseEvent *event); + void view_drag_left(QDragLeaveEvent *event); + void view_drag_dropped(TimelineViewMouseEvent *event); - void AddBlock(Block *block); - void RemoveBlock(Block *blocks); + void add_block(Block *block); + void remove_block(Block *blocks); - void AddTrack(Track *track); - void RemoveTrack(Track *track); - void TrackUpdated(); + void add_track(Track *track); + void remove_track(Track *track); + void track_updated(); - void BlockUpdated(); + void block_updated(); - void UpdateHorizontalSplitters(); + void update_horizontal_splitters(); - void UpdateTimecodeWidthFromSplitters(QSplitter *s); + void update_timecode_width_from_splitters(QSplitter *s); - void ShowContextMenu(); + void show_context_menu(); void DeferredScrollAction(); - void ShowSequenceDialog(); + void show_sequence_dialog(); - void SetUseAudioTimeUnits(bool use); + void set_use_audio_time_units(bool use); - void ToolChanged(); + void tool_changed(); - void AddableObjectChanged(); + void addable_object_changed(); - void SetViewWaveformsEnabled(bool e); + void set_view_waveforms_enabled(bool e); - void SetViewThumbnailsEnabled(QAction *action); + void set_view_thumbnails_enabled(QAction *action); - void FrameRateChanged(); + void frame_rate_changed(); - void SampleRateChanged(); + void sample_rate_changed(); - void TrackIndexChanged(int old, int now); + void track_index_changed(int old, int now); - void SignalBlockSelectionChange(); + void signal_block_selection_change(); - void RevealInFootageViewer(); - void RevealInProject(); + void reveal_in_footage_viewer(); + void reveal_in_project(); - void TrackAboutToBeDeleted(Track *track); + void track_about_to_be_deleted(Track *track); - void SetSelectedClipsAutocaching(bool e); + void set_selected_clips_autocaching(bool e); - void CacheClips(); - void CacheClipsInOut(); - void CacheDiscard(); + void cache_clips(); + void cache_clips_in_out(); + void cache_discard(); - void MulticamEnabledTriggered(bool e); + void multicam_enabled_triggered(bool e); - void ForceUpdateRubberBand(); + void force_update_rubber_band(); }; } -#endif // TIMELINEWIDGET_H +#endif // OAK_TIMELINEWIDGET_H diff --git a/app/widget/timelinewidget/timelinewidgetselections.cpp b/app/widget/timelinewidget/timelinewidgetselections.cpp index ca24c9a1c..9c5d86aea 100644 --- a/app/widget/timelinewidget/timelinewidgetselections.cpp +++ b/app/widget/timelinewidget/timelinewidgetselections.cpp @@ -24,14 +24,14 @@ namespace olive { -void TimelineWidgetSelections::ShiftTime(const rational &diff) +void TimelineWidgetSelections::shift_time(const Rational &diff) { for (auto it = this->begin(); it != this->end(); it++) { it.value().shift(diff); } } -void TimelineWidgetSelections::ShiftTracks(Track::Type type, int diff) +void TimelineWidgetSelections::shift_tracks(Track::Type type, int diff) { TimelineWidgetSelections cached_selections; @@ -57,21 +57,21 @@ void TimelineWidgetSelections::ShiftTracks(Track::Type type, int diff) } } -void TimelineWidgetSelections::TrimIn(const rational &diff) +void TimelineWidgetSelections::trim_in(const Rational &diff) { for (auto it = this->begin(); it != this->end(); it++) { it.value().trim_in(diff); } } -void TimelineWidgetSelections::TrimOut(const rational &diff) +void TimelineWidgetSelections::trim_out(const Rational &diff) { for (auto it = this->begin(); it != this->end(); it++) { it.value().trim_out(diff); } } -void TimelineWidgetSelections::Subtract( +void TimelineWidgetSelections::subtract( const TimelineWidgetSelections &selections) { for (auto it = selections.cbegin(); it != selections.cend(); it++) { diff --git a/app/widget/timelinewidget/timelinewidgetselections.h b/app/widget/timelinewidget/timelinewidgetselections.h index c0c60755f..6ec72ed5b 100644 --- a/app/widget/timelinewidget/timelinewidgetselections.h +++ b/app/widget/timelinewidget/timelinewidgetselections.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEWIDGETSELECTIONS_H -#define TIMELINEWIDGETSELECTIONS_H +#ifndef OAK_TIMELINEWIDGETSELECTIONS_H +#define OAK_TIMELINEWIDGETSELECTIONS_H #include @@ -33,25 +33,25 @@ class TimelineWidgetSelections : public QHash { public: TimelineWidgetSelections() = default; - void ShiftTime(const rational &diff); + void shift_time(const Rational &diff); - void ShiftTracks(Track::Type type, int diff); + void shift_tracks(Track::Type type, int diff); - void TrimIn(const rational &diff); + void trim_in(const Rational &diff); - void TrimOut(const rational &diff); + void trim_out(const Rational &diff); - void Subtract(const TimelineWidgetSelections &selections); + void subtract(const TimelineWidgetSelections &selections); TimelineWidgetSelections - Subtracted(const TimelineWidgetSelections &selections) const + subtracted(const TimelineWidgetSelections &selections) const { TimelineWidgetSelections copy = *this; - copy.Subtract(selections); + copy.subtract(selections); return copy; } }; } -#endif // TIMELINEWIDGETSELECTIONS_H +#endif // OAK_TIMELINEWIDGETSELECTIONS_H diff --git a/app/widget/timelinewidget/timelinewidgetwaveformsync.cpp b/app/widget/timelinewidget/timelinewidgetwaveformsync.cpp index 07028e420..4233b606b 100644 --- a/app/widget/timelinewidget/timelinewidgetwaveformsync.cpp +++ b/app/widget/timelinewidget/timelinewidgetwaveformsync.cpp @@ -29,10 +29,10 @@ namespace olive { -namespace TimelineWaveformSync +namespace timeline_waveform_sync { -bool GetWaveformSyncClip(Block *block, WaveformSyncClip *out) +bool get_waveform_sync_clip(Block *block, WaveformSyncClip *out) { ClipBlock *clip = dynamic_cast(block); if (!clip || !clip->waveform()) { @@ -45,7 +45,7 @@ bool GetWaveformSyncClip(Block *block, WaveformSyncClip *out) } const AudioWaveformCache *waveform = clip->waveform(); - if (waveform->GetParameters().sample_rate() <= 0) { + if (waveform->get_parameters().sample_rate() <= 0) { return false; } @@ -54,7 +54,7 @@ bool GetWaveformSyncClip(Block *block, WaveformSyncClip *out) // validated makes the menu item stay disabled for long clips and gives // the appearance that "nothing happens" when the user tries to sync. const TimeRangeList validated_ranges = - waveform->GetValidatedRanges().Intersects(media_range); + waveform->get_validated_ranges().intersects(media_range); if (validated_ranges.isEmpty()) { return false; } @@ -62,24 +62,24 @@ bool GetWaveformSyncClip(Block *block, WaveformSyncClip *out) out->clip = clip; out->waveform = waveform; out->media_range = media_range; - out->sample_rate = waveform->GetParameters().sample_rate(); + out->sample_rate = waveform->get_parameters().sample_rate(); return true; } QVector -GetSelectedWaveformSyncClips(const QVector &blocks) +get_selected_waveform_sync_clips(const QVector &blocks) { QVector clips; for (Block *block : blocks) { WaveformSyncClip sync_clip; - if (GetWaveformSyncClip(block, &sync_clip)) { + if (get_waveform_sync_clip(block, &sync_clip)) { clips.append(sync_clip); } } return clips; } -QVector ExtractWaveformCacheEnvelope(const WaveformSyncClip &clip, +QVector extract_waveform_cache_envelope(const WaveformSyncClip &clip, int sample_rate, size_t window_samples, QVector *valid_mask) @@ -93,7 +93,7 @@ QVector ExtractWaveformCacheEnvelope(const WaveformSyncClip &clip, valid_mask->clear(); } - const rational window_time(static_cast(window_samples), sample_rate); + const Rational window_time(static_cast(window_samples), sample_rate); // Only trust regions that have actually been validated. Unvalidated cache // returns zero samples, which both drags the correlation score down and @@ -102,11 +102,11 @@ QVector ExtractWaveformCacheEnvelope(const WaveformSyncClip &clip, // absolute timeline, while the validity mask lets the correlation skip // those placeholders entirely. const TimeRangeList validated_ranges = - clip.waveform->GetValidatedRanges().Intersects(clip.media_range); + clip.waveform->get_validated_ranges().intersects(clip.media_range); - for (rational t = clip.media_range.in(); t < clip.media_range.out(); + for (Rational t = clip.media_range.in(); t < clip.media_range.out(); t += window_time) { - const rational length = qMin(window_time, clip.media_range.out() - t); + const Rational length = qMin(window_time, clip.media_range.out() - t); const TimeRange window(t, t + length); const bool window_valid = validated_ranges.contains(window); @@ -114,7 +114,7 @@ QVector ExtractWaveformCacheEnvelope(const WaveformSyncClip &clip, double peak = 0.0; if (window_valid) { const AudioVisualWaveform::Sample summary = - clip.waveform->GetSummaryFromTime(t, length); + clip.waveform->get_summary_from_time(t, length); for (const AudioVisualWaveform::SamplePerChannel &channel : summary) { diff --git a/app/widget/timelinewidget/timelinewidgetwaveformsync.h b/app/widget/timelinewidget/timelinewidgetwaveformsync.h index 619db973a..19b23dfe2 100644 --- a/app/widget/timelinewidget/timelinewidgetwaveformsync.h +++ b/app/widget/timelinewidget/timelinewidgetwaveformsync.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEWIDGETWAVEFORMSYNC_H -#define TIMELINEWIDGETWAVEFORMSYNC_H +#ifndef OAK_TIMELINEWIDGETWAVEFORMSYNC_H +#define OAK_TIMELINEWIDGETWAVEFORMSYNC_H #include @@ -49,7 +49,7 @@ struct WaveformSyncClip { * * Kept in a separate unit so they can be exercised directly by unit tests. */ -namespace TimelineWaveformSync +namespace timeline_waveform_sync { /** @@ -59,13 +59,13 @@ namespace TimelineWaveformSync * has been validated in the waveform cache. Previously the whole range had to * be validated, which made the context-menu action unavailable for long clips. */ -bool GetWaveformSyncClip(Block *block, WaveformSyncClip *out); +bool get_waveform_sync_clip(Block *block, WaveformSyncClip *out); /** * @brief Return all selected blocks that can be synchronized by waveform. */ QVector -GetSelectedWaveformSyncClips(const QVector &blocks); +get_selected_waveform_sync_clips(const QVector &blocks); /** * @brief Extract a peak envelope from the validated regions of a waveform cache. @@ -76,7 +76,7 @@ GetSelectedWaveformSyncClips(const QVector &blocks); * actually cached, allowing the correlation to skip uncached regions instead * of treating them as silence. */ -QVector ExtractWaveformCacheEnvelope(const WaveformSyncClip &clip, +QVector extract_waveform_cache_envelope(const WaveformSyncClip &clip, int sample_rate, size_t window_samples, QVector *valid_mask = nullptr); @@ -85,4 +85,4 @@ QVector ExtractWaveformCacheEnvelope(const WaveformSyncClip &clip, } // namespace olive -#endif // TIMELINEWIDGETWAVEFORMSYNC_H +#endif // OAK_TIMELINEWIDGETWAVEFORMSYNC_H diff --git a/app/widget/timelinewidget/tool/add.cpp b/app/widget/timelinewidget/tool/add.cpp index a6721471a..996132961 100644 --- a/app/widget/timelinewidget/tool/add.cpp +++ b/app/widget/timelinewidget/tool/add.cpp @@ -39,112 +39,112 @@ AddTool::AddTool(TimelineWidget *parent) { } -void AddTool::MousePress(TimelineViewMouseEvent *event) +void AddTool::mouse_press(TimelineViewMouseEvent *event) { - const Track::Reference &track = event->GetTrack(); + const Track::Reference &track = event->get_track(); // Check if track is locked - Track *t = parent()->GetTrackFromReference(track); - if (t && t->IsLocked()) { + Track *t = parent()->get_track_from_reference(track); + if (t && t->is_locked()) { return; } - Track::Type add_type = Track::kNone; + Track::Type add_type = Track::k_none; - switch (Core::instance()->GetSelectedAddableObject()) { - case Tool::kAddableBars: - case Tool::kAddableSolid: - case Tool::kAddableTitle: - case Tool::kAddableShape: - add_type = Track::kVideo; + switch (Core::instance()->get_selected_addable_object()) { + case Tool::k_addable_bars: + case Tool::k_addable_solid: + case Tool::k_addable_title: + case Tool::k_addable_shape: + add_type = Track::k_video; break; - case Tool::kAddableTone: - add_type = Track::kAudio; + case Tool::k_addable_tone: + add_type = Track::k_audio; break; - case Tool::kAddableSubtitle: - add_type = Track::kSubtitle; + case Tool::k_addable_subtitle: + add_type = Track::k_subtitle; break; - case Tool::kAddableEmpty: + case Tool::k_addable_empty: // Leave as "none", which means this block can be placed on any track break; - case Tool::kAddableCount: + case Tool::k_addable_count: // Return so we do nothing return; } - if (add_type == Track::kNone || add_type == track.type()) { + if (add_type == Track::k_none || add_type == track.type()) { drag_start_point_ = - ValidatedCoordinate(event->GetCoordinates(true)).GetFrame(); + validated_coordinate(event->get_coordinates(true)).get_frame(); ghost_ = new TimelineViewGhostItem(); - ghost_->SetIn(drag_start_point_); - ghost_->SetOut(drag_start_point_); - ghost_->SetTrack(track); - parent()->AddGhost(ghost_); + ghost_->set_in(drag_start_point_); + ghost_->set_out(drag_start_point_); + ghost_->set_track(track); + parent()->add_ghost(ghost_); snap_points_.push_back(drag_start_point_); } } -void AddTool::MouseMove(TimelineViewMouseEvent *event) +void AddTool::mouse_move(TimelineViewMouseEvent *event) { if (!ghost_) { return; } - MouseMoveInternal(event->GetFrame(), - event->GetModifiers() & Qt::AltModifier); + mouse_move_internal(event->get_frame(), + event->get_modifiers() & Qt::AltModifier); } -void AddTool::MouseRelease(TimelineViewMouseEvent *event) +void AddTool::mouse_release(TimelineViewMouseEvent *event) { if (ghost_) { - if (!ghost_->GetAdjustedLength().isNull()) { + if (!ghost_->get_adjusted_length().isNull()) { MultiUndoCommand *command = new MultiUndoCommand(); if (MultiUndoCommand *subtitle_section_command = - parent()->TakeSubtitleSectionCommand()) { + parent()->take_subtitle_section_command()) { command->add_child(subtitle_section_command); } Sequence *s = parent()->sequence(); QRectF r; - if (Core::instance()->GetSelectedAddableObject() == - Tool::kAddableTitle) { - VideoParams svp = s->GetVideoParams(); + if (Core::instance()->get_selected_addable_object() == + Tool::k_addable_title) { + VideoParams svp = s->get_video_params(); r = QRectF(0, 0, svp.width(), svp.height()); r.adjust(svp.width() / 10, svp.height() / 10, -svp.width() / 10, -svp.height() / 10); } - CreateAddableClip(command, s, ghost_->GetTrack(), - ghost_->GetAdjustedIn(), - ghost_->GetAdjustedLength(), r); + create_addable_clip(command, s, ghost_->get_track(), + ghost_->get_adjusted_in(), + ghost_->get_adjusted_length(), r); Core::instance()->undo_stack()->push( command, qApp->translate("AddTool", "Added Clip")); } - parent()->ClearGhosts(); + parent()->clear_ghosts(); snap_points_.clear(); ghost_ = nullptr; } } -Node *AddTool::CreateAddableClip(MultiUndoCommand *command, Sequence *sequence, +Node *AddTool::create_addable_clip(MultiUndoCommand *command, Sequence *sequence, const Track::Reference &track, - const rational &in, const rational &length, + const Rational &in, const Rational &length, const QRectF &rect) { ClipBlock *clip; - if (Core::instance()->GetSelectedAddableObject() == - Tool::kAddableSubtitle) { + if (Core::instance()->get_selected_addable_object() == + Tool::k_addable_subtitle) { clip = new SubtitleBlock(); } else { clip = new ClipBlock(); - clip->SetLabel(olive::Tool::GetAddableObjectName( - Core::instance()->GetSelectedAddableObject())); + clip->set_label(olive::Tool::get_addable_object_name( + Core::instance()->get_selected_addable_object())); } clip->set_length_and_media_out(length); @@ -157,45 +157,45 @@ Node *AddTool::CreateAddableClip(MultiUndoCommand *command, Sequence *sequence, Node *node_to_add = nullptr; - switch (Core::instance()->GetSelectedAddableObject()) { - case Tool::kAddableEmpty: + switch (Core::instance()->get_selected_addable_object()) { + case Tool::k_addable_empty: // Empty, nothing to be done break; - case Tool::kAddableSolid: + case Tool::k_addable_solid: node_to_add = new SolidGenerator(); break; - case Tool::kAddableShape: + case Tool::k_addable_shape: node_to_add = new ShapeNode(); break; - case Tool::kAddableTitle: + case Tool::k_addable_title: node_to_add = new TextGeneratorV3(); break; - case Tool::kAddableBars: - case Tool::kAddableTone: + case Tool::k_addable_bars: + case Tool::k_addable_tone: // Not implemented yet qWarning() << "Unimplemented add object:" - << Core::instance()->GetSelectedAddableObject(); + << Core::instance()->get_selected_addable_object(); break; - case Tool::kAddableSubtitle: + case Tool::k_addable_subtitle: // The block itself is the node we want break; - case Tool::kAddableCount: + case Tool::k_addable_count: // Invalid value, do nothing break; } if (node_to_add) { - QPointF extra_node_offset(kDefaultDistanceFromOutput, 0); + QPointF extra_node_offset(k_default_distance_from_output, 0); command->add_child(new NodeAddCommand(graph, node_to_add)); command->add_child(new NodeEdgeAddCommand( - node_to_add, NodeInput(clip, ClipBlock::kBufferIn))); + node_to_add, NodeInput(clip, ClipBlock::k_buffer_in))); command->add_child( new NodeSetPositionCommand(node_to_add, clip, extra_node_offset)); if (!rect.isNull()) { if (ShapeNodeBase *shape = dynamic_cast(node_to_add)) { - shape->SetRect(rect, sequence->GetVideoParams(), command); + shape->set_rect(rect, sequence->get_video_params(), command); } } } @@ -203,22 +203,22 @@ Node *AddTool::CreateAddableClip(MultiUndoCommand *command, Sequence *sequence, return node_to_add; } -void AddTool::MouseMoveInternal(const rational &cursor_frame, bool outwards) +void AddTool::mouse_move_internal(const Rational &cursor_frame, bool outwards) { // Calculate movement - rational movement = cursor_frame - drag_start_point_; + Rational movement = cursor_frame - drag_start_point_; // Validation: Ensure in point never goes below 0 - if (movement < -ghost_->GetIn() || - (outwards && -movement < -ghost_->GetIn())) { - movement = -ghost_->GetIn(); + if (movement < -ghost_->get_in() || + (outwards && -movement < -ghost_->get_in())) { + movement = -ghost_->get_in(); } // Snap movement bool snapped; if (Core::instance()->snapping()) { - snapped = parent()->SnapPoint(snap_points_, &movement); + snapped = parent()->snap_point(snap_points_, &movement); } else { snapped = false; } @@ -227,20 +227,20 @@ void AddTool::MouseMoveInternal(const rational &cursor_frame, bool outwards) if (!snapped && outwards) { // Snap backwards too movement = -movement; - parent()->SnapPoint(snap_points_, &movement); + parent()->snap_point(snap_points_, &movement); // We don't need to un-neg here because outwards means all future processing will be done both pos and neg } // Make adjustment if (!movement) { - ghost_->SetInAdjustment(0); - ghost_->SetOutAdjustment(0); + ghost_->set_in_adjustment(0); + ghost_->set_out_adjustment(0); } else if (movement > 0) { - ghost_->SetInAdjustment(outwards ? -movement : 0); - ghost_->SetOutAdjustment(movement); + ghost_->set_in_adjustment(outwards ? -movement : 0); + ghost_->set_out_adjustment(movement); } else if (movement < 0) { - ghost_->SetInAdjustment(movement); - ghost_->SetOutAdjustment(outwards ? -movement : 0); + ghost_->set_in_adjustment(movement); + ghost_->set_out_adjustment(outwards ? -movement : 0); } } diff --git a/app/widget/timelinewidget/tool/add.h b/app/widget/timelinewidget/tool/add.h index 8e71ffda7..a9461f167 100644 --- a/app/widget/timelinewidget/tool/add.h +++ b/app/widget/timelinewidget/tool/add.h @@ -19,8 +19,8 @@ ***/ -#ifndef ADDTIMELINETOOL_H -#define ADDTIMELINETOOL_H +#ifndef OAK_ADDTIMELINETOOL_H +#define OAK_ADDTIMELINETOOL_H #include "beam.h" @@ -31,24 +31,24 @@ class AddTool : public BeamTool { public: AddTool(TimelineWidget *parent); - virtual void MousePress(TimelineViewMouseEvent *event) override; - virtual void MouseMove(TimelineViewMouseEvent *event) override; - virtual void MouseRelease(TimelineViewMouseEvent *event) override; + virtual void mouse_press(TimelineViewMouseEvent *event) override; + virtual void mouse_move(TimelineViewMouseEvent *event) override; + virtual void mouse_release(TimelineViewMouseEvent *event) override; - static Node *CreateAddableClip(MultiUndoCommand *command, + static Node *create_addable_clip(MultiUndoCommand *command, Sequence *sequence, const Track::Reference &track, - const rational &in, const rational &length, + const Rational &in, const Rational &length, const QRectF &rect = QRectF()); protected: - void MouseMoveInternal(const rational &cursor_frame, bool outwards); + void mouse_move_internal(const Rational &cursor_frame, bool outwards); TimelineViewGhostItem *ghost_; - rational drag_start_point_; + Rational drag_start_point_; }; } -#endif // ADDTIMELINETOOL_H +#endif // OAK_ADDTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/beam.cpp b/app/widget/timelinewidget/tool/beam.cpp index 23bbaae6e..4106159ed 100644 --- a/app/widget/timelinewidget/tool/beam.cpp +++ b/app/widget/timelinewidget/tool/beam.cpp @@ -30,19 +30,19 @@ BeamTool::BeamTool(TimelineWidget *parent) { } -void BeamTool::HoverMove(TimelineViewMouseEvent *event) +void BeamTool::hover_move(TimelineViewMouseEvent *event) { - parent()->SetViewBeamCursor( - ValidatedCoordinate(event->GetCoordinates(true))); + parent()->set_view_beam_cursor( + validated_coordinate(event->get_coordinates(true))); } -TimelineCoordinate BeamTool::ValidatedCoordinate(TimelineCoordinate coord) +TimelineCoordinate BeamTool::validated_coordinate(TimelineCoordinate coord) { if (Core::instance()->snapping()) { - rational movement; - parent()->SnapPoint({ coord.GetFrame() }, &movement); + Rational movement; + parent()->snap_point({ coord.get_frame() }, &movement); if (!movement.isNull()) { - coord.SetFrame(coord.GetFrame() + movement); + coord.set_frame(coord.get_frame() + movement); } } diff --git a/app/widget/timelinewidget/tool/beam.h b/app/widget/timelinewidget/tool/beam.h index 0e8923a79..ba7daddc6 100644 --- a/app/widget/timelinewidget/tool/beam.h +++ b/app/widget/timelinewidget/tool/beam.h @@ -19,8 +19,8 @@ ***/ -#ifndef BEAMTIMELINETOOL_H -#define BEAMTIMELINETOOL_H +#ifndef OAK_BEAMTIMELINETOOL_H +#define OAK_BEAMTIMELINETOOL_H #include "tool.h" @@ -31,12 +31,12 @@ class BeamTool : public TimelineTool { public: BeamTool(TimelineWidget *parent); - virtual void HoverMove(TimelineViewMouseEvent *event) override; + virtual void hover_move(TimelineViewMouseEvent *event) override; protected: - TimelineCoordinate ValidatedCoordinate(TimelineCoordinate coord); + TimelineCoordinate validated_coordinate(TimelineCoordinate coord); }; } -#endif // BEAMTIMELINETOOL_H +#endif // OAK_BEAMTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/edit.cpp b/app/widget/timelinewidget/tool/edit.cpp index 42f94705d..c006af496 100644 --- a/app/widget/timelinewidget/tool/edit.cpp +++ b/app/widget/timelinewidget/tool/edit.cpp @@ -30,42 +30,42 @@ EditTool::EditTool(TimelineWidget *parent) { } -void EditTool::MousePress(TimelineViewMouseEvent *event) +void EditTool::mouse_press(TimelineViewMouseEvent *event) { - if (!(event->GetModifiers() & Qt::ShiftModifier)) { - parent()->DeselectAll(); + if (!(event->get_modifiers() & Qt::ShiftModifier)) { + parent()->deselect_all(); } } -void EditTool::MouseMove(TimelineViewMouseEvent *event) +void EditTool::mouse_move(TimelineViewMouseEvent *event) { if (dragging_) { - rational end_frame = event->GetFrame(true); + Rational end_frame = event->get_frame(true); if (Core::instance()->snapping()) { - rational movement; - parent()->SnapPoint({ end_frame }, &movement); + Rational movement; + parent()->snap_point({ end_frame }, &movement); if (!movement.isNull()) { end_frame += movement; } } - parent()->SetSelections(start_selections_, false); - parent()->AddSelection(TimeRange(start_coord_.GetFrame(), end_frame), - start_coord_.GetTrack()); + parent()->set_selections(start_selections_, false); + parent()->add_selection(TimeRange(start_coord_.get_frame(), end_frame), + start_coord_.get_track()); } else { - start_selections_ = parent()->GetSelections(); + start_selections_ = parent()->get_selections(); dragging_ = true; - start_coord_ = event->GetCoordinates(true); + start_coord_ = event->get_coordinates(true); // Snap if we're snapping if (Core::instance()->snapping()) { - rational movement; - parent()->SnapPoint({ start_coord_.GetFrame() }, &movement); + Rational movement; + parent()->snap_point({ start_coord_.get_frame() }, &movement); if (!movement.isNull()) { - start_coord_.SetFrame(start_coord_.GetFrame() + movement); + start_coord_.set_frame(start_coord_.get_frame() + movement); } } @@ -73,21 +73,21 @@ void EditTool::MouseMove(TimelineViewMouseEvent *event) } } -void EditTool::MouseRelease(TimelineViewMouseEvent *event) +void EditTool::mouse_release(TimelineViewMouseEvent *event) { - auto current_sel = parent()->GetSelections(); - parent()->SetSelections(start_selections_, false); - parent()->SetSelections(current_sel, true); + auto current_sel = parent()->get_selections(); + parent()->set_selections(start_selections_, false); + parent()->set_selections(current_sel, true); dragging_ = false; } -void EditTool::MouseDoubleClick(TimelineViewMouseEvent *event) +void EditTool::mouse_double_click(TimelineViewMouseEvent *event) { - Block *item = parent()->GetItemAtScenePos(event->GetCoordinates()); + Block *item = parent()->get_item_at_scene_pos(event->get_coordinates()); - if (item && !item->track()->IsLocked()) { - parent()->AddSelection(item); + if (item && !item->track()->is_locked()) { + parent()->add_selection(item); } } diff --git a/app/widget/timelinewidget/tool/edit.h b/app/widget/timelinewidget/tool/edit.h index e347085cb..a073fc076 100644 --- a/app/widget/timelinewidget/tool/edit.h +++ b/app/widget/timelinewidget/tool/edit.h @@ -19,8 +19,8 @@ ***/ -#ifndef EDITTIMELINETOOL_H -#define EDITTIMELINETOOL_H +#ifndef OAK_EDITTIMELINETOOL_H +#define OAK_EDITTIMELINETOOL_H #include "beam.h" #include "tool.h" @@ -33,10 +33,10 @@ class EditTool : public BeamTool { public: EditTool(TimelineWidget *parent); - virtual void MousePress(TimelineViewMouseEvent *event) override; - virtual void MouseMove(TimelineViewMouseEvent *event) override; - virtual void MouseRelease(TimelineViewMouseEvent *event) override; - virtual void MouseDoubleClick(TimelineViewMouseEvent *event) override; + virtual void mouse_press(TimelineViewMouseEvent *event) override; + virtual void mouse_move(TimelineViewMouseEvent *event) override; + virtual void mouse_release(TimelineViewMouseEvent *event) override; + virtual void mouse_double_click(TimelineViewMouseEvent *event) override; private: TimelineWidgetSelections start_selections_; @@ -46,4 +46,4 @@ private: } -#endif // EDITTIMELINETOOL_H +#endif // OAK_EDITTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index de1000bb9..2b1c32851 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -49,18 +49,18 @@ ImportTool::ImportTool(TimelineWidget *parent) { // Calculate width used for importing to give ghosts a slight lead-in so the ghosts aren't right on the cursor import_pre_buffer_ = - QtUtils::QFontMetricsWidth(parent->fontMetrics(), "HHHHHHHH"); + QtUtils::q_font_metrics_width(parent->fontMetrics(), "HHHHHHHH"); } -void ImportTool::DragEnter(TimelineViewMouseEvent *event) +void ImportTool::drag_enter(TimelineViewMouseEvent *event) { - QStringList mime_formats = event->GetMimeData()->formats(); + QStringList mime_formats = event->get_mime_data()->formats(); // Listen for MIME data from a ProjectViewModel - if (mime_formats.contains(Project::kItemMimeType)) { + if (mime_formats.contains(Project::k_item_mime_type)) { // Data is drag/drop data from a ProjectViewModel QByteArray model_data = - event->GetMimeData()->data(Project::kItemMimeType); + event->get_mime_data()->data(Project::k_item_mime_type); // Use QDataStream to deserialize the data QDataStream stream(&model_data, QIODevice::ReadOnly); @@ -70,7 +70,7 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event) QVector enabled_streams; // Set drag start position - drag_start_ = event->GetCoordinates(); + drag_start_ = event->get_coordinates(); snap_points_.clear(); @@ -83,28 +83,28 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event) // Check if Item is Footage ViewerOutput *f = dynamic_cast(item); - if (f && f->GetTotalStreamCount()) { + if (f && f->get_total_stream_count()) { // If the Item is Footage, we can create a Ghost from it dragged_footage_.append({ f, enabled_streams }); } } // Create a reasonable amount of space to inset the cursor by when importing - ghost_offset_ = drag_start_.GetFrame(); + ghost_offset_ = drag_start_.get_frame(); - if (!event->GetBypassImportBuffer()) { - ghost_offset_ -= parent()->SceneToTime(import_pre_buffer_); + if (!event->get_bypass_import_buffer()) { + ghost_offset_ -= parent()->scene_to_time(import_pre_buffer_); } - PrepGhosts(ghost_offset_, drag_start_.GetTrack().index()); + prep_ghosts(ghost_offset_, drag_start_.get_track().index()); - if (parent()->HasGhosts() || !parent()->GetConnectedNode()) { + if (parent()->has_ghosts() || !parent()->get_connected_node()) { // We only clear the tentative track if the mimedata is about to be destroyed (i.e. the drag // is cancelled). If we do this in DragLeave, it leads to undesirable behavior if the cursor // is going between views (subtitle track rapidly appearing and disappearing) - QObject::connect(event->GetMimeData(), &QObject::destroyed, + QObject::connect(event->get_mime_data(), &QObject::destroyed, parent(), - &TimelineWidget::ClearTentativeSubtitleTrack); + &TimelineWidget::clear_tentative_subtitle_track); event->accept(); } else { @@ -116,11 +116,11 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event) } } -void ImportTool::DragMove(TimelineViewMouseEvent *event) +void ImportTool::drag_move(TimelineViewMouseEvent *event) { if (!dragged_footage_.isEmpty()) { - if (parent()->HasGhosts()) { - rational time_movement = event->GetFrame() - drag_start_.GetFrame(); + if (parent()->has_ghosts()) { + Rational time_movement = event->get_frame() - drag_start_.get_frame(); // Keep ghost offset no lower than 0 if (ghost_offset_ + time_movement < 0) { @@ -128,39 +128,39 @@ void ImportTool::DragMove(TimelineViewMouseEvent *event) } int track_movement = - event->GetTrack().index() - drag_start_.GetTrack().index(); + event->get_track().index() - drag_start_.get_track().index(); - time_movement = ValidateTimeMovement(time_movement); - track_movement = ValidateTrackMovement(track_movement, - parent()->GetGhostItems()); + time_movement = validate_time_movement(time_movement); + track_movement = validate_track_movement(track_movement, + parent()->get_ghost_items()); // If snapping is enabled, check for snap points if (Core::instance()->snapping()) { - parent()->SnapPoint(snap_points_, &time_movement); + parent()->snap_point(snap_points_, &time_movement); - time_movement = ValidateTimeMovement(time_movement); - track_movement = ValidateTrackMovement( - track_movement, parent()->GetGhostItems()); + time_movement = validate_time_movement(time_movement); + track_movement = validate_track_movement( + track_movement, parent()->get_ghost_items()); } - rational earliest_ghost = RATIONAL_MAX; + Rational earliest_ghost = RATIONAL_MAX; // Move ghosts to the mouse cursor - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - ghost->SetInAdjustment(time_movement); - ghost->SetOutAdjustment(time_movement); - ghost->SetTrackAdjustment(track_movement); + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + ghost->set_in_adjustment(time_movement); + ghost->set_out_adjustment(time_movement); + ghost->set_track_adjustment(track_movement); - earliest_ghost = qMin(earliest_ghost, ghost->GetAdjustedIn()); + earliest_ghost = qMin(earliest_ghost, ghost->get_adjusted_in()); } // Generate tooltip (showing earliest in point of imported clip) - rational tooltip_timebase = - parent()->GetTimebaseForTrackType(event->GetTrack().type()); + Rational tooltip_timebase = + parent()->get_timebase_for_track_type(event->get_track().type()); QString tooltip_text = QString::fromStdString(Timecode::time_to_timecode( earliest_ghost, tooltip_timebase, - Core::instance()->GetTimecodeDisplay())); + Core::instance()->get_timecode_display())); // Force tooltip to update (otherwise the tooltip won't move as written in the documentation, and could get in the way // of the cursor) @@ -174,10 +174,10 @@ void ImportTool::DragMove(TimelineViewMouseEvent *event) } } -void ImportTool::DragLeave(QDragLeaveEvent *event) +void ImportTool::drag_leave(QDragLeaveEvent *event) { if (!dragged_footage_.isEmpty()) { - parent()->ClearGhosts(); + parent()->clear_ghosts(); dragged_footage_.clear(); event->accept(); @@ -186,11 +186,11 @@ void ImportTool::DragLeave(QDragLeaveEvent *event) } } -void ImportTool::DragDrop(TimelineViewMouseEvent *event) +void ImportTool::drag_drop(TimelineViewMouseEvent *event) { if (!dragged_footage_.isEmpty()) { auto command = new MultiUndoCommand(); - DropGhosts(event->GetModifiers() & Qt::ControlModifier, command); + drop_ghosts(event->get_modifiers() & Qt::ControlModifier, command); Core::instance()->undo_stack()->push( command, qApp->translate("ImportTool", "Dropped Footage Into Sequence")); @@ -201,22 +201,22 @@ void ImportTool::DragDrop(TimelineViewMouseEvent *event) } } -void ImportTool::PlaceAt(const QVector &footage, - const rational &start, bool insert, +void ImportTool::place_at(const QVector &footage, + const Rational &start, bool insert, MultiUndoCommand *command, int track_offset, bool jump_to_end) { DraggedFootageData refs; foreach (ViewerOutput *f, footage) { - refs.append({ f, f->GetEnabledStreamsAsReferences() }); + refs.append({ f, f->get_enabled_streams_as_references() }); } - PlaceAt(refs, start, insert, command, track_offset, jump_to_end); + place_at(refs, start, insert, command, track_offset, jump_to_end); } -void ImportTool::PlaceAt(const DraggedFootageData &footage, - const rational &start, bool insert, +void ImportTool::place_at(const DraggedFootageData &footage, + const Rational &start, bool insert, MultiUndoCommand *command, int track_offset, bool jump_to_end) { @@ -226,60 +226,60 @@ void ImportTool::PlaceAt(const DraggedFootageData &footage, return; } - PrepGhosts(start, track_offset); + prep_ghosts(start, track_offset); - rational max(0); + Rational max(0); if (jump_to_end) { - for (TimelineViewGhostItem *ghost : parent()->GetGhostItems()) { - max = std::max(max, ghost->GetAdjustedOut()); + for (TimelineViewGhostItem *ghost : parent()->get_ghost_items()) { + max = std::max(max, ghost->get_adjusted_out()); } } - DropGhosts(insert, command); + drop_ghosts(insert, command); if (jump_to_end) { - this->sequence()->SetPlayhead(max); + this->sequence()->set_playhead(max); } } -void ImportTool::FootageToGhosts(rational ghost_start, +void ImportTool::footage_to_ghosts(Rational ghost_start, const DraggedFootageData &sorted, - const rational &dest_tb, + const Rational &dest_tb, const int &track_start) { for (auto it = sorted.cbegin(); it != sorted.cend(); it++) { ViewerOutput *footage = it->first; if (footage == sequence() || - (sequence() && footage->InputsFrom(sequence(), true))) { + (sequence() && footage->inputs_from(sequence(), true))) { // Prevent cyclical dependency continue; } // Each stream is offset by one track per track "type", we keep track of them in this vector - QVector track_offsets(Track::kCount); + QVector track_offsets(Track::k_count); track_offsets.fill(track_start); - rational footage_duration; - rational ghost_in; + Rational footage_duration; + Rational ghost_in; - TimelineWorkArea *wk = footage->GetWorkArea(); + TimelineWorkArea *wk = footage->get_work_area(); if (wk->enabled()) { footage_duration = wk->length(); ghost_in = wk->in(); } else { - footage_duration = footage->GetLength(); + footage_duration = footage->get_length(); if (footage_duration.isNull()) { // Fallback to still length if legngth was 0 footage_duration = - OLIVE_CONFIG("DefaultStillLength").value(); + OAK_CONFIG("DefaultStillLength").value(); } } // Snap footage duration to timebase - rational snap_mvmt = - SnapMovementToTimebase(footage_duration, 0, dest_tb); + Rational snap_mvmt = + snap_movement_to_timebase(footage_duration, 0, dest_tb); if (!snap_mvmt.isNull()) { footage_duration += snap_mvmt; } @@ -290,8 +290,8 @@ void ImportTool::FootageToGhosts(rational ghost_start, Track::Reference dest_track(track_type, track_offsets.at(track_type)); - if (track_type == Track::kVideo || track_type == Track::kAudio) { - auto ghost = CreateGhost( + if (track_type == Track::k_video || track_type == Track::k_audio) { + auto ghost = create_ghost( TimeRange(ghost_start, ghost_start + footage_duration), ghost_in, dest_track); @@ -299,21 +299,21 @@ void ImportTool::FootageToGhosts(rational ghost_start, track_offsets[track_type]++; TimelineViewGhostItem::AttachedFootage af = { it->first, - ref.ToString() }; - ghost->SetData(TimelineViewGhostItem::kAttachedFootage, + ref.to_string() }; + ghost->set_data(TimelineViewGhostItem::k_attached_footage, QVariant::fromValue(af)); - } else if (track_type == Track::kSubtitle) { - SubtitleParams sp = footage->GetSubtitleParams(ref.index()); + } else if (track_type == Track::k_subtitle) { + SubtitleParams sp = footage->get_subtitle_params(ref.index()); for (const Subtitle &sub : sp) { auto ghost = - CreateGhost(sub.time() + ghost_start, 0, dest_track); + create_ghost(sub.time() + ghost_start, 0, dest_track); - ghost->SetData(TimelineViewGhostItem::kAttachedFootage, + ghost->set_data(TimelineViewGhostItem::k_attached_footage, QVariant::fromValue(sub)); } - parent()->AddTentativeSubtitleTrack(); + parent()->add_tentative_subtitle_track(); } } @@ -322,21 +322,21 @@ void ImportTool::FootageToGhosts(rational ghost_start, } } -void ImportTool::PrepGhosts(const rational &frame, const int &track_index) +void ImportTool::prep_ghosts(const Rational &frame, const int &track_index) { - if (parent()->GetConnectedNode()) { - FootageToGhosts( + if (parent()->get_connected_node()) { + footage_to_ghosts( frame, dragged_footage_, - parent()->GetConnectedNode()->GetVideoParams().time_base(), + parent()->get_connected_node()->get_video_params().time_base(), track_index); } } -void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) +void ImportTool::drop_ghosts(bool insert, MultiUndoCommand *parent_command) { auto command = new MultiUndoCommand(); - if (MultiUndoCommand *c = parent()->TakeSubtitleSectionCommand()) { + if (MultiUndoCommand *c = parent()->take_subtitle_section_command()) { command->add_child(c); } @@ -351,9 +351,9 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) DropWithoutSequenceBehavior behavior = static_cast( - OLIVE_CONFIG("DropWithoutSequenceBehavior").toInt()); + OAK_CONFIG("DropWithoutSequenceBehavior").toInt()); - if (behavior == kDWSAsk) { + if (behavior == k_dws_ask) { QCheckBox *dont_ask_again_box = new QCheckBox( QCoreApplication::translate("ImportTool", "Don't ask me again")); @@ -382,24 +382,24 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) mbox.exec(); if (mbox.clickedButton() == auto_params_btn) { - behavior = kDWSAuto; + behavior = k_dws_auto; } else if (mbox.clickedButton() == manual_params_btn) { - behavior = kDWSManual; + behavior = k_dws_manual; } else { - behavior = kDWSDisable; + behavior = k_dws_disable; } - if (behavior != kDWSDisable && dont_ask_again_box->isChecked()) { - OLIVE_CONFIG("DropWithoutSequenceBehavior") = behavior; + if (behavior != k_dws_disable && dont_ask_again_box->isChecked()) { + OAK_CONFIG("DropWithoutSequenceBehavior") = behavior; } } - if (behavior != kDWSDisable) { - Project *active_project = Core::instance()->GetActiveProject(); + if (behavior != k_dws_disable) { + Project *active_project = Core::instance()->get_active_project(); if (active_project) { Sequence *new_sequence = - Core::instance()->CreateNewSequenceForProject( + Core::instance()->create_new_sequence_for_project( active_project); new_sequence->set_default_parameters(); @@ -420,10 +420,10 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) new_sequence->set_parameters_from_footage(footage_only); // If the user selected manual, show them a dialog with parameters - if (behavior == kDWSManual) { - SequenceDialog sd(new_sequence, SequenceDialog::kNew, + if (behavior == k_dws_manual) { + SequenceDialog sd(new_sequence, SequenceDialog::k_new, parent()); - sd.SetUndoable(false); + sd.set_undoable(false); if (sd.exec() != QDialog::Accepted) { sequence_is_valid = false; @@ -431,23 +431,23 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) } if (sequence_is_valid) { - dst_graph = Core::instance()->GetActiveProject(); + dst_graph = Core::instance()->get_active_project(); command->add_child( new NodeAddCommand(dst_graph, new_sequence)); command->add_child(new FolderAddChild( - Core::instance()->GetSelectedFolderInActiveProject(), + Core::instance()->get_selected_folder_in_active_project(), new_sequence)); command->add_child(new NodeSetPositionCommand( new_sequence, new_sequence, QPointF(0, 0))); new_sequence->add_default_nodes(command); - FootageToGhosts(0, dragged_footage_, - new_sequence->GetVideoParams().time_base(), + footage_to_ghosts(0, dragged_footage_, + new_sequence->get_video_params().time_base(), 0); if (MultiUndoCommand *c = - parent()->TakeSubtitleSectionCommand()) { + parent()->take_subtitle_section_command()) { command->add_child(c); } @@ -467,33 +467,33 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) std::list imported_clips; if (dst_graph) { - QVector block_items(parent()->GetGhostItems().size()); + QVector block_items(parent()->get_ghost_items().size()); // Check if we're inserting (only valid if we're not creating this sequence ourselves) if (insert && !open_sequence) { - InsertGapsAtGhostDestination(command); + insert_gaps_at_ghost_destination(command); } - for (int i = 0; i < parent()->GetGhostItems().size(); i++) { - TimelineViewGhostItem *ghost = parent()->GetGhostItems().at(i); + for (int i = 0; i < parent()->get_ghost_items().size(); i++) { + TimelineViewGhostItem *ghost = parent()->get_ghost_items().at(i); Block *block = nullptr; - Track::Type track_type = ghost->GetAdjustedTrack().type(); - if (track_type == Track::kVideo || track_type == Track::kAudio) { + Track::Type track_type = ghost->get_adjusted_track().type(); + if (track_type == Track::k_video || track_type == Track::k_audio) { TimelineViewGhostItem::AttachedFootage footage_stream = - ghost->GetData(TimelineViewGhostItem::kAttachedFootage) + ghost->get_data(TimelineViewGhostItem::k_attached_footage) .value(); ClipBlock *clip = new ClipBlock(); block = clip; - clip->set_media_in(ghost->GetMediaIn()); + clip->set_media_in(ghost->get_media_in()); command->add_child(new NodeAddCommand(dst_graph, clip)); // Position clip in its own context command->add_child( new NodeSetPositionCommand(clip, clip, QPointF(0, 0))); - int dep_pos = kDefaultDistanceFromOutput; + int dep_pos = k_default_distance_from_output; // Position footage in its context command->add_child(new NodeSetPositionCommand( @@ -502,43 +502,43 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) dep_pos++; switch ( - Track::Reference::TypeFromString(footage_stream.output)) { - case Track::kVideo: { + Track::Reference::type_from_string(footage_stream.output)) { + case Track::k_video: { TransformDistortNode *transform = new TransformDistortNode(); command->add_child( new NodeAddCommand(dst_graph, transform)); command->add_child(new NodeSetValueHintCommand( - transform, TransformDistortNode::kTextureInput, -1, - Node::ValueHint({ NodeValue::kTexture }, + transform, TransformDistortNode::k_texture_input, -1, + Node::ValueHint({ NodeValue::k_texture }, footage_stream.output))); command->add_child(new NodeEdgeAddCommand( footage_stream.footage, NodeInput(transform, - TransformDistortNode::kTextureInput))); + TransformDistortNode::k_texture_input))); command->add_child(new NodeEdgeAddCommand( - transform, NodeInput(clip, ClipBlock::kBufferIn))); + transform, NodeInput(clip, ClipBlock::k_buffer_in))); command->add_child(new NodeSetPositionCommand( transform, clip, QPointF(dep_pos, 0))); break; } - case Track::kAudio: { + case Track::k_audio: { VolumeNode *volume_node = new VolumeNode(); command->add_child( new NodeAddCommand(dst_graph, volume_node)); command->add_child(new NodeSetValueHintCommand( - volume_node, VolumeNode::kSamplesInput, -1, - Node::ValueHint({ NodeValue::kSamples }, + volume_node, VolumeNode::k_samples_input, -1, + Node::ValueHint({ NodeValue::k_samples }, footage_stream.output))); command->add_child(new NodeEdgeAddCommand( footage_stream.footage, - NodeInput(volume_node, VolumeNode::kSamplesInput))); + NodeInput(volume_node, VolumeNode::k_samples_input))); command->add_child(new NodeEdgeAddCommand( - volume_node, NodeInput(clip, ClipBlock::kBufferIn))); + volume_node, NodeInput(clip, ClipBlock::k_buffer_in))); command->add_child(new NodeSetPositionCommand( volume_node, clip, QPointF(dep_pos, 0))); break; @@ -551,23 +551,23 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) for (int j = 0; j < i; j++) { TimelineViewGhostItem::AttachedFootage footage_compare = parent() - ->GetGhostItems() + ->get_ghost_items() .at(j) - ->GetData(TimelineViewGhostItem::kAttachedFootage) + ->get_data(TimelineViewGhostItem::k_attached_footage) .value(); if (footage_compare.footage == footage_stream.footage) { - Block::Link(block_items.at(j), clip); + Block::link(block_items.at(j), clip); } } imported_clips.push_back(clip); - } else if (track_type == Track::kSubtitle) { + } else if (track_type == Track::k_subtitle) { Subtitle src = - ghost->GetData(TimelineViewGhostItem::kAttachedFootage) + ghost->get_data(TimelineViewGhostItem::k_attached_footage) .value(); SubtitleBlock *sub = new SubtitleBlock(); - sub->SetText(src.text()); + sub->set_text(src.text()); block = sub; command->add_child(new NodeAddCommand(dst_graph, sub)); @@ -575,12 +575,12 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) new NodeSetPositionCommand(sub, sub, QPointF(0, 0))); } - block->set_length_and_media_out(ghost->GetLength()); + block->set_length_and_media_out(ghost->get_length()); command->add_child(new TrackPlaceBlockCommand( - sequence->track_list(ghost->GetAdjustedTrack().type()), - ghost->GetAdjustedTrack().index(), block, - ghost->GetAdjustedIn())); + sequence->track_list(ghost->get_adjusted_track().type()), + ghost->get_adjusted_track().index(), block, + ghost->get_adjusted_in())); block_items.replace(i, block); } @@ -596,31 +596,31 @@ void ImportTool::DropGhosts(bool insert, MultiUndoCommand *parent_command) parent_command->add_child(command); while (!imported_clips.empty()) { - imported_clips.front()->RequestInvalidatedFromConnected(); + imported_clips.front()->request_invalidated_from_connected(); imported_clips.pop_front(); } - parent()->ClearGhosts(); + parent()->clear_ghosts(); dragged_footage_.clear(); } -TimelineViewGhostItem *ImportTool::CreateGhost(const TimeRange &range, - const rational &media_in, +TimelineViewGhostItem *ImportTool::create_ghost(const TimeRange &range, + const Rational &media_in, const Track::Reference &track) { TimelineViewGhostItem *ghost = new TimelineViewGhostItem(); - ghost->SetIn(range.in()); - ghost->SetOut(range.out()); - ghost->SetMediaIn(media_in); - ghost->SetTrack(track); + ghost->set_in(range.in()); + ghost->set_out(range.out()); + ghost->set_media_in(media_in); + ghost->set_track(track); - snap_points_.push_back(ghost->GetIn()); - snap_points_.push_back(ghost->GetOut()); + snap_points_.push_back(ghost->get_in()); + snap_points_.push_back(ghost->get_out()); - ghost->SetMode(Timeline::kMove); + ghost->set_mode(Timeline::k_move); - parent()->AddGhost(ghost); + parent()->add_ghost(ghost); return ghost; } diff --git a/app/widget/timelinewidget/tool/import.h b/app/widget/timelinewidget/tool/import.h index d0c5d272a..6adcf9336 100644 --- a/app/widget/timelinewidget/tool/import.h +++ b/app/widget/timelinewidget/tool/import.h @@ -19,8 +19,8 @@ ***/ -#ifndef IMPORTTIMELINETOOL_H -#define IMPORTTIMELINETOOL_H +#ifndef OAK_IMPORTTIMELINETOOL_H +#define OAK_IMPORTTIMELINETOOL_H #include "tool.h" @@ -31,48 +31,48 @@ class ImportTool : public TimelineTool { public: ImportTool(TimelineWidget *parent); - virtual void DragEnter(TimelineViewMouseEvent *event) override; - virtual void DragMove(TimelineViewMouseEvent *event) override; - virtual void DragLeave(QDragLeaveEvent *event) override; - virtual void DragDrop(TimelineViewMouseEvent *event) override; + virtual void drag_enter(TimelineViewMouseEvent *event) override; + virtual void drag_move(TimelineViewMouseEvent *event) override; + virtual void drag_leave(QDragLeaveEvent *event) override; + virtual void drag_drop(TimelineViewMouseEvent *event) override; using DraggedFootageData = QVector>>; - void PlaceAt(const QVector &footage, const rational &start, + void place_at(const QVector &footage, const Rational &start, bool insert, MultiUndoCommand *command, int track_offset = 0, bool jump_to_end = false); - void PlaceAt(const DraggedFootageData &footage, const rational &start, + void place_at(const DraggedFootageData &footage, const Rational &start, bool insert, MultiUndoCommand *command, int track_offset = 0, bool jump_to_end = false); enum DropWithoutSequenceBehavior { - kDWSAsk, - kDWSAuto, - kDWSManual, - kDWSDisable + k_dws_ask, + k_dws_auto, + k_dws_manual, + k_dws_disable }; private: - void FootageToGhosts(rational ghost_start, + void footage_to_ghosts(Rational ghost_start, const DraggedFootageData &footage, - const rational &dest_tb, const int &track_start); + const Rational &dest_tb, const int &track_start); - void PrepGhosts(const rational &frame, const int &track_index); + void prep_ghosts(const Rational &frame, const int &track_index); - void DropGhosts(bool insert, MultiUndoCommand *parent_command); + void drop_ghosts(bool insert, MultiUndoCommand *parent_command); - TimelineViewGhostItem *CreateGhost(const TimeRange &range, - const rational &media_in, + TimelineViewGhostItem *create_ghost(const TimeRange &range, + const Rational &media_in, const Track::Reference &track); DraggedFootageData dragged_footage_; int import_pre_buffer_; - rational ghost_offset_; + Rational ghost_offset_; }; } -#endif // IMPORTTIMELINETOOL_H +#endif // OAK_IMPORTTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/pointer.cpp b/app/widget/timelinewidget/tool/pointer.cpp index 7c38eae57..c4c800c95 100644 --- a/app/widget/timelinewidget/tool/pointer.cpp +++ b/app/widget/timelinewidget/tool/pointer.cpp @@ -49,19 +49,19 @@ PointerTool::PointerTool(TimelineWidget *parent) { } -void PointerTool::MousePress(TimelineViewMouseEvent *event) +void PointerTool::mouse_press(TimelineViewMouseEvent *event) { - const Track::Reference &track_ref = event->GetTrack(); + const Track::Reference &track_ref = event->get_track(); // Determine if item clicked on is selectable - clicked_item_ = parent()->GetItemAtScenePos(event->GetCoordinates()); + clicked_item_ = parent()->get_item_at_scene_pos(event->get_coordinates()); ClipBlock *clip_clicked_item = dynamic_cast(clicked_item_); can_rubberband_select_ = false; bool selectable_item = (clicked_item_ && - !parent()->GetTrackFromReference(track_ref)->IsLocked()); + !parent()->get_track_from_reference(track_ref)->is_locked()); if (selectable_item) { // Cache the clip's type for use later @@ -69,46 +69,46 @@ void PointerTool::MousePress(TimelineViewMouseEvent *event) // If we haven't started dragging yet, we'll initiate a drag here // Record where the drag started in timeline coordinates - drag_start_ = event->GetCoordinates(); + drag_start_ = event->get_coordinates(); // Determine whether we're trimming or moving based on the position of the cursor drag_movement_mode_ = - IsCursorInTrimHandle(clicked_item_, event->GetSceneX()); + is_cursor_in_trim_handle(clicked_item_, event->get_scene_x()); // If we're not in a trim mode, we must be in a move mode (provided the tool allows movement and // the block is not a gap) - if (drag_movement_mode_ == Timeline::kNone && movement_allowed_ && + if (drag_movement_mode_ == Timeline::k_none && movement_allowed_ && !dynamic_cast(clicked_item_)) { - drag_movement_mode_ = Timeline::kMove; + drag_movement_mode_ = Timeline::k_move; } // If this item is already selected, no further selection needs to be made - if (parent()->IsBlockSelected(clicked_item_)) { + if (parent()->is_block_selected(clicked_item_)) { // Collect item deselections QVector deselected_blocks; // If shift is held, deselect it - if (event->GetModifiers() & Qt::ShiftModifier) { - parent()->RemoveSelection(clicked_item_); + if (event->get_modifiers() & Qt::ShiftModifier) { + parent()->remove_selection(clicked_item_); deselected_blocks.append(clicked_item_); // If not holding alt, deselect all links as well if (clip_clicked_item && - !(event->GetModifiers() & Qt::AltModifier)) { - parent()->SetBlockLinksSelected(clip_clicked_item, false); + !(event->get_modifiers() & Qt::AltModifier)) { + parent()->set_block_links_selected(clip_clicked_item, false); deselected_blocks.append(clip_clicked_item->block_links()); } } - parent()->SignalDeselectedBlocks(deselected_blocks); + parent()->signal_deselected_blocks(deselected_blocks); return; } } // If not holding shift, deselect all clips - if (!(event->GetModifiers() & Qt::ShiftModifier)) { - parent()->DeselectAll(); + if (!(event->get_modifiers() & Qt::ShiftModifier)) { + parent()->deselect_all(); } if (selectable_item) { @@ -116,53 +116,53 @@ void PointerTool::MousePress(TimelineViewMouseEvent *event) QVector selected_blocks; // Select this item - parent()->AddSelection(clicked_item_); + parent()->add_selection(clicked_item_); selected_blocks.append(clicked_item_); // If not holding alt, select all links as well - if (clip_clicked_item && !(event->GetModifiers() & Qt::AltModifier)) { - parent()->SetBlockLinksSelected(clip_clicked_item, true); + if (clip_clicked_item && !(event->get_modifiers() & Qt::AltModifier)) { + parent()->set_block_links_selected(clip_clicked_item, true); selected_blocks.append(clip_clicked_item->block_links()); } - parent()->SignalSelectedBlocks(selected_blocks); + parent()->signal_selected_blocks(selected_blocks); } can_rubberband_select_ = - (event->GetButton() == + (event->get_button() == Qt::LeftButton // Only rubberband select from the primary mouse button && (!selectable_item || drag_movement_mode_ == Timeline:: - kNone)); // And if no item was selected OR the item isn't draggable + k_none)); // And if no item was selected OR the item isn't draggable if (can_rubberband_select_) { drag_global_start_ = QCursor::pos(); } // If we click anywhere other than a marker, deselect all markers - parent()->ruler()->DeselectAllMarkers(); + parent()->ruler()->deselect_all_markers(); } -void PointerTool::MouseMove(TimelineViewMouseEvent *event) +void PointerTool::mouse_move(TimelineViewMouseEvent *event) { if (can_rubberband_select_) { if (!rubberband_selecting_) { // If we clicked an item but are rubberband selecting anyway, deselect it now if (clicked_item_) { - parent()->RemoveSelection(clicked_item_); - parent()->SignalDeselectedBlocks({ clicked_item_ }); + parent()->remove_selection(clicked_item_); + parent()->signal_deselected_blocks({ clicked_item_ }); clicked_item_ = nullptr; } - parent()->StartRubberBandSelect(drag_global_start_); + parent()->start_rubber_band_select(drag_global_start_); rubberband_selecting_ = true; } // Process rubberband select - parent()->MoveRubberBandSelect(true, !(event->GetModifiers() & + parent()->move_rubber_band_select(true, !(event->get_modifiers() & Qt::AltModifier)); } else { @@ -174,58 +174,58 @@ void PointerTool::MouseMove(TimelineViewMouseEvent *event) snap_points_.clear(); // If we're performing an action, we can initiate ghosts - if (drag_movement_mode_ != Timeline::kNone) { - InitiateDrag(clicked_item_, drag_movement_mode_, - event->GetModifiers()); + if (drag_movement_mode_ != Timeline::k_none) { + initiate_drag(clicked_item_, drag_movement_mode_, + event->get_modifiers()); } // Set dragging to true here so no matter what, the drag isn't re-initiated until it's completed dragging_ = true; } - if (dragging_ && !parent()->GetGhostItems().isEmpty()) { + if (dragging_ && !parent()->get_ghost_items().isEmpty()) { // We're already dragging AND we have ghosts to work with - ProcessDrag(event->GetCoordinates()); + process_drag(event->get_coordinates()); } } } -void PointerTool::MouseRelease(TimelineViewMouseEvent *event) +void PointerTool::mouse_release(TimelineViewMouseEvent *event) { if (rubberband_selecting_) { // Finish rubberband select - parent()->EndRubberBandSelect(); + parent()->end_rubber_band_select(); rubberband_selecting_ = false; return; } if (dragging_) { // If we were dragging, process the end of the drag - if (!parent()->GetGhostItems().isEmpty()) { - FinishDrag(event); + if (!parent()->get_ghost_items().isEmpty()) { + finish_drag(event); } // Clean up - parent()->ClearGhosts(); + parent()->clear_ghosts(); snap_points_.clear(); dragging_ = false; } } -void PointerTool::HoverMove(TimelineViewMouseEvent *event) +void PointerTool::hover_move(TimelineViewMouseEvent *event) { if (trimming_allowed_) { // No dragging, but we still want to process cursors Block *block_at_cursor = - parent()->GetItemAtScenePos(event->GetCoordinates()); + parent()->get_item_at_scene_pos(event->get_coordinates()); if (block_at_cursor) { - switch (IsCursorInTrimHandle(block_at_cursor, event->GetSceneX())) { - case Timeline::kTrimIn: + switch (is_cursor_in_trim_handle(block_at_cursor, event->get_scene_x())) { + case Timeline::k_trim_in: parent()->setCursor(Qt::SizeHorCursor); break; - case Timeline::kTrimOut: + case Timeline::k_trim_out: parent()->setCursor(Qt::SizeHorCursor); break; default: @@ -239,13 +239,13 @@ void PointerTool::HoverMove(TimelineViewMouseEvent *event) } } -void SetGhostToSlideMode(TimelineViewGhostItem *g) +void set_ghost_to_slide_mode(TimelineViewGhostItem *g) { - g->SetCanMoveTracks(false); - g->SetData(TimelineViewGhostItem::kGhostIsSliding, true); + g->set_can_move_tracks(false); + g->set_data(TimelineViewGhostItem::k_ghost_is_sliding, true); } -void PointerTool::InitiateDragInternal(Block *clicked_item, +void PointerTool::initiate_drag_internal(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers, bool dont_roll_trims, @@ -253,9 +253,9 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, bool slide_instead_of_moving) { // Get list of selected blocks - QVector clips = parent()->GetSelectedBlocks(); + QVector clips = parent()->get_selected_blocks(); - if (trim_mode == Timeline::kMove) { + if (trim_mode == Timeline::k_move) { // Gaps are not allowed to move, and since we only allow moving one block type at a time, // dragging a gap is a no-op if (dynamic_cast(clicked_item)) { @@ -270,15 +270,15 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, foreach (Block *block, clips) { if (TransitionBlock *transit = dynamic_cast(block)) { - if (!CanTransitionMove(transit, clips)) { + if (!can_transition_move(transit, clips)) { slide_instead_of_moving = true; break; } } else if (ClipBlock *clip = dynamic_cast(block)) { if ((clip->in_transition() && - !CanTransitionMove(clip->in_transition(), clips)) || + !can_transition_move(clip->in_transition(), clips)) || (clip->out_transition() && - !CanTransitionMove(clip->out_transition(), clips))) { + !can_transition_move(clip->out_transition(), clips))) { slide_instead_of_moving = true; break; } @@ -344,15 +344,15 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, } if (earliest->previous() && slide_with_earliest_previous) { - earliest_ghost = AddGhostFromBlock(earliest->previous(), - Timeline::kTrimOut); + earliest_ghost = add_ghost_from_block(earliest->previous(), + Timeline::k_trim_out); } else { - earliest_ghost = AddGhostFromNull(earliest->in(), + earliest_ghost = add_ghost_from_null(earliest->in(), earliest->in(), - track->ToReference(), - Timeline::kTrimOut); + track->to_reference(), + Timeline::k_trim_out); } - SetGhostToSlideMode(earliest_ghost); + set_ghost_to_slide_mode(earliest_ghost); } // Then we add the block that's in trimming, the one after the latest @@ -376,15 +376,15 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, } if (slide_with_latest_next) { - latest_ghost = AddGhostFromBlock(latest->next(), - Timeline::kTrimIn); + latest_ghost = add_ghost_from_block(latest->next(), + Timeline::k_trim_in); } else { - latest_ghost = AddGhostFromNull(latest->out(), + latest_ghost = add_ghost_from_null(latest->out(), latest->out(), - track->ToReference(), - Timeline::kTrimIn); + track->to_reference(), + Timeline::k_trim_in); } - SetGhostToSlideMode(latest_ghost); + set_ghost_to_slide_mode(latest_ghost); } // Finally, we add all of the moving blocks in between @@ -399,8 +399,8 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, } TimelineViewGhostItem *between_ghost = - AddGhostFromBlock(b, Timeline::kMove); - SetGhostToSlideMode(between_ghost); + add_ghost_from_block(b, Timeline::k_move); + set_ghost_to_slide_mode(between_ghost); } while (b != latest); } } else { @@ -411,16 +411,16 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, } // Create ghost for this block - auto ghost = AddGhostFromBlock(block, trim_mode, true); + auto ghost = add_ghost_from_block(block, trim_mode, true); Q_UNUSED(ghost) if (ClipBlock *clip = dynamic_cast(block)) { if (clip->out_transition()) { - AddGhostFromBlock(clip->out_transition(), trim_mode, + add_ghost_from_block(clip->out_transition(), trim_mode, true); } if (clip->in_transition()) { - AddGhostFromBlock(clip->in_transition(), trim_mode, + add_ghost_from_block(clip->in_transition(), trim_mode, true); } } @@ -432,13 +432,13 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, // or latest (for out trimming) clip on each track can be trimmed. Therefore, it's only enabled // if the clicked item is the earliest/latest on its track. bool multitrim_enabled = - IsClipTrimmable(clicked_item, clips, trim_mode); + is_clip_trimmable(clicked_item, clips, trim_mode); // Create ghosts for trimming for (Block *clip_item : clips) { if (clip_item != clicked_item && (!multitrim_enabled || - !IsClipTrimmable(clip_item, clips, trim_mode))) { + !is_clip_trimmable(clip_item, clips, trim_mode))) { // Either multitrim is disabled or this clip is NOT the earliest/latest in its track. We // won't include it. continue; @@ -447,7 +447,7 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, Block *block = clip_item; // Create ghost for this block - TimelineViewGhostItem *ghost = AddGhostFromBlock(block, trim_mode); + TimelineViewGhostItem *ghost = add_ghost_from_block(block, trim_mode); // If this side of the clip has a transition, we treat it more like a slide for that // transition than a trim/roll @@ -459,7 +459,7 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, TransitionBlock *connected_transition; // Get appropriate transition for the side of the clip - if (trim_mode == Timeline::kTrimIn) { + if (trim_mode == Timeline::k_trim_in) { connected_transition = cb->in_transition(); } else { connected_transition = cb->out_transition(); @@ -467,12 +467,12 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, if (connected_transition) { // We found a transition, we'll make this a "slide" action - TimelineViewGhostItem *transition_ghost = AddGhostFromBlock( - connected_transition, Timeline::kMove); + TimelineViewGhostItem *transition_ghost = add_ghost_from_block( + connected_transition, Timeline::k_move); // This will in effect be a slide with the transition moving between two other blocks - SetGhostToSlideMode(ghost); - SetGhostToSlideMode(transition_ghost); + set_ghost_to_slide_mode(ghost); + set_ghost_to_slide_mode(transition_ghost); treat_trim_as_slide = true; // Further processing will apply to this transition rather than the clip @@ -486,7 +486,7 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, Block *adjacent = nullptr; // Determine which block is adjacent - if (trim_mode == Timeline::kTrimIn) { + if (trim_mode == Timeline::k_trim_in) { adjacent = block->previous(); } else { adjacent = block->next(); @@ -496,21 +496,21 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, if (!dynamic_cast(block) && !allow_nongap_rolling && adjacent && !dynamic_cast(adjacent) && !(dynamic_cast(block) && - ((trim_mode == Timeline::kTrimIn && + ((trim_mode == Timeline::k_trim_in && static_cast(block) ->connected_out_block() == adjacent) || - (trim_mode == Timeline::kTrimOut && + (trim_mode == Timeline::k_trim_out && static_cast(block) ->connected_in_block() == adjacent)))) { adjacent = nullptr; } - Timeline::MovementMode flipped_mode = FlipTrimMode(trim_mode); + Timeline::MovementMode flipped_mode = flip_trim_mode(trim_mode); QVector adjacent_ghosts; if (adjacent) { adjacent_ghosts.append( - AddGhostFromBlock(adjacent, flipped_mode)); + add_ghost_from_block(adjacent, flipped_mode)); // Select adjacent's links if applicable // FIXME: The check for `clips.size() == 1` may not be necessary, but I don't know yet. @@ -520,38 +520,38 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, dynamic_cast(adjacent)) { for (Block *adjacent_link : adjacent_clip->block_links()) { - adjacent_ghosts.append(AddGhostFromBlock( + adjacent_ghosts.append(add_ghost_from_block( adjacent_link, flipped_mode)); } } } - } else if (trim_mode == Timeline::kTrimIn || block->next()) { - rational null_ghost_pos = (trim_mode == Timeline::kTrimIn) ? + } else if (trim_mode == Timeline::k_trim_in || block->next()) { + Rational null_ghost_pos = (trim_mode == Timeline::k_trim_in) ? block->in() : block->out(); - adjacent_ghosts.append(AddGhostFromNull( + adjacent_ghosts.append(add_ghost_from_null( null_ghost_pos, null_ghost_pos, - clip_item->track()->ToReference(), flipped_mode)); + clip_item->track()->to_reference(), flipped_mode)); } // If we have an adjacent block (for any reason), this is a roll edit and the adjacent is // expected to fill the remaining space (no gap needs to be created) - ghost->SetData(TimelineViewGhostItem::kTrimIsARollEdit, + ghost->set_data(TimelineViewGhostItem::k_trim_is_a_roll_edit, static_cast(adjacent)); for (TimelineViewGhostItem *adjacent_ghost : adjacent_ghosts) { if (adjacent_ghost) { if (treat_trim_as_slide) { // We're sliding a transition rather than a pure trim/roll - SetGhostToSlideMode(adjacent_ghost); + set_ghost_to_slide_mode(adjacent_ghost); } else if (dynamic_cast(block)) { - ghost->SetData( - TimelineViewGhostItem::kTrimShouldBeIgnored, + ghost->set_data( + TimelineViewGhostItem::k_trim_should_be_ignored, true); } else { - adjacent_ghost->SetData( - TimelineViewGhostItem::kTrimShouldBeIgnored, + adjacent_ghost->set_data( + TimelineViewGhostItem::k_trim_should_be_ignored, true); } } @@ -561,7 +561,7 @@ void PointerTool::InitiateDragInternal(Block *clicked_item, } } -bool PointerTool::CanTransitionMove(TransitionBlock *transit, +bool PointerTool::can_transition_move(TransitionBlock *transit, const QVector &clips) { Block *out = transit->connected_out_block(); @@ -574,66 +574,66 @@ bool PointerTool::CanTransitionMove(TransitionBlock *transit, return true; } -void PointerTool::ProcessDrag(const TimelineCoordinate &mouse_pos) +void PointerTool::process_drag(const TimelineCoordinate &mouse_pos) { // Calculate track movement int track_movement = track_movement_allowed_ ? - mouse_pos.GetTrack().index() - drag_start_.GetTrack().index() : + mouse_pos.get_track().index() - drag_start_.get_track().index() : 0; // Determine frame movement - rational time_movement = mouse_pos.GetFrame() - drag_start_.GetFrame(); + Rational time_movement = mouse_pos.get_frame() - drag_start_.get_frame(); // Validate movement (enforce all ghosts moving in legal ways) - time_movement = ValidateTimeMovement(time_movement); - time_movement = ValidateInTrimming(time_movement); - time_movement = ValidateOutTrimming(time_movement); + time_movement = validate_time_movement(time_movement); + time_movement = validate_in_trimming(time_movement); + time_movement = validate_out_trimming(time_movement); // Perform snapping if enabled (adjusts time_movement if it's close to any potential snap points) if (Core::instance()->snapping()) { - parent()->SnapPoint(snap_points_, &time_movement); + parent()->snap_point(snap_points_, &time_movement); - time_movement = ValidateTimeMovement(time_movement); - time_movement = ValidateInTrimming(time_movement); - time_movement = ValidateOutTrimming(time_movement); + time_movement = validate_time_movement(time_movement); + time_movement = validate_in_trimming(time_movement); + time_movement = validate_out_trimming(time_movement); } // Validate ghosts that are being moved (clips from other track types do NOT get moved) if (track_movement != 0) { QVector validate_track_ghosts = - parent()->GetGhostItems(); + parent()->get_ghost_items(); for (int i = 0; i < validate_track_ghosts.size(); i++) { - if (validate_track_ghosts.at(i)->GetTrack().type() != + if (validate_track_ghosts.at(i)->get_track().type() != drag_track_type_) { validate_track_ghosts.removeAt(i); i--; } } track_movement = - ValidateTrackMovement(track_movement, validate_track_ghosts); + validate_track_movement(track_movement, validate_track_ghosts); } // Perform movement - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - switch (ghost->GetMode()) { - case Timeline::kNone: + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + switch (ghost->get_mode()) { + case Timeline::k_none: break; - case Timeline::kTrimIn: - ghost->SetInAdjustment(time_movement); - ghost->SetMediaInAdjustment(time_movement); + case Timeline::k_trim_in: + ghost->set_in_adjustment(time_movement); + ghost->set_media_in_adjustment(time_movement); break; - case Timeline::kTrimOut: - ghost->SetOutAdjustment(time_movement); + case Timeline::k_trim_out: + ghost->set_out_adjustment(time_movement); break; - case Timeline::kMove: { - ghost->SetInAdjustment(time_movement); - ghost->SetOutAdjustment(time_movement); + case Timeline::k_move: { + ghost->set_in_adjustment(time_movement); + ghost->set_out_adjustment(time_movement); // Track movement is only legal for moving, not for trimming // Also, we only move the clips on the same track type that the drag started from - if (ghost->GetTrack().type() == drag_track_type_) { - ghost->SetTrackAdjustment(track_movement); + if (ghost->get_track().type() == drag_track_type_) { + ghost->set_track_adjustment(track_movement); } break; } @@ -642,13 +642,13 @@ void PointerTool::ProcessDrag(const TimelineCoordinate &mouse_pos) // Regenerate tooltip and force it to update (otherwise the tooltip won't move as written in the // documentation, and could get in the way of the cursor) - rational tooltip_timebase = - parent()->GetTimebaseForTrackType(drag_start_.GetTrack().type()); + Rational tooltip_timebase = + parent()->get_timebase_for_track_type(drag_start_.get_track().type()); QToolTip::hideText(); QToolTip::showText(QCursor::pos(), QString::fromStdString(Timecode::time_to_timecode( time_movement, tooltip_timebase, - Core::instance()->GetTimecodeDisplay(), true)), + Core::instance()->get_timecode_display(), true)), parent()); } @@ -657,23 +657,23 @@ struct GhostBlockPair { Block *block; }; -void PointerTool::FinishDrag(TimelineViewMouseEvent *event) +void PointerTool::finish_drag(TimelineViewMouseEvent *event) { QList blocks_moving; QList blocks_sliding; QList blocks_trimming; // Sort ghosts depending on which ones are trimming, which are moving, and which are sliding - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - if (ghost->HasBeenAdjusted()) { - Block *b = QtUtils::ValueToPtr( - ghost->GetData(TimelineViewGhostItem::kAttachedBlock)); + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + if (ghost->has_been_adjusted()) { + Block *b = QtUtils::value_to_ptr( + ghost->get_data(TimelineViewGhostItem::k_attached_block)); - if (ghost->GetData(TimelineViewGhostItem::kGhostIsSliding).toBool()) { + if (ghost->get_data(TimelineViewGhostItem::k_ghost_is_sliding).toBool()) { blocks_sliding.append({ ghost, b }); - } else if (ghost->GetMode() == Timeline::kMove) { + } else if (ghost->get_mode() == Timeline::k_move) { blocks_moving.append({ ghost, b }); - } else if (Timeline::IsATrimMode(ghost->GetMode())) { + } else if (Timeline::is_a_trim_mode(ghost->get_mode())) { blocks_trimming.append({ ghost, b }); } } @@ -691,18 +691,18 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) foreach (const GhostBlockPair &p, blocks_trimming) { TimelineViewGhostItem *ghost = p.ghost; - if (!ghost->GetData(TimelineViewGhostItem::kTrimShouldBeIgnored) + if (!ghost->get_data(TimelineViewGhostItem::k_trim_should_be_ignored) .toBool()) { // Must be an ordinary trim/roll BlockTrimCommand *c = new BlockTrimCommand( - parent()->GetTrackFromReference(ghost->GetAdjustedTrack()), - p.block, ghost->GetAdjustedLength(), ghost->GetMode()); + parent()->get_track_from_reference(ghost->get_adjusted_track()), + p.block, ghost->get_adjusted_length(), ghost->get_mode()); - if (event->GetModifiers() & Qt::ControlModifier) { + if (event->get_modifiers() & Qt::ControlModifier) { } - c->SetTrimIsARollEdit( - ghost->GetData(TimelineViewGhostItem::kTrimIsARollEdit) + c->set_trim_is_a_roll_edit( + ghost->get_data(TimelineViewGhostItem::k_trim_is_a_roll_edit) .toBool()); command->add_child(c); @@ -711,23 +711,23 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) if (blocks_moving.isEmpty() && blocks_sliding.isEmpty()) { // Trim selections (deferring to moving/sliding blocks when necessary) - TimelineWidgetSelections new_sel = parent()->GetSelections(); + TimelineWidgetSelections new_sel = parent()->get_selections(); TimelineViewGhostItem *reference_ghost = blocks_trimming.first().ghost; - if (reference_ghost->GetMode() == Timeline::kTrimIn) { - new_sel.TrimIn(reference_ghost->GetInAdjustment()); + if (reference_ghost->get_mode() == Timeline::k_trim_in) { + new_sel.trim_in(reference_ghost->get_in_adjustment()); } else { - new_sel.TrimOut(reference_ghost->GetOutAdjustment()); + new_sel.trim_out(reference_ghost->get_out_adjustment()); } command->add_child(new TimelineWidget::SetSelectionsCommand( - parent(), new_sel, parent()->GetSelections())); + parent(), new_sel, parent()->get_selections())); } } if (!blocks_moving.isEmpty()) { // See if we're duplicated because ALT is held (only moved blocks can duplicate) - bool duplicate_clips = (event->GetModifiers() & Qt::AltModifier); - bool inserting = (event->GetModifiers() & Qt::ControlModifier); + bool duplicate_clips = (event->get_modifiers() & Qt::AltModifier); + bool inserting = (event->get_modifiers() & Qt::ControlModifier); // If we're not duplicating, "remove" the clips and replace them with gaps if (!duplicate_clips) { @@ -737,13 +737,13 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) blocks_to_delete[i] = blocks_moving.at(i).block; } - parent()->ReplaceBlocksWithGaps(blocks_to_delete, false, command, + parent()->replace_blocks_with_gaps(blocks_to_delete, false, command, false); } if (inserting) { // If we're inserting, ripple everything at the destination with gaps - InsertGapsAtGhostDestination(command); + insert_gaps_at_ghost_destination(command); } QMap relinks; @@ -756,20 +756,20 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) // Duplicate rather than move // Place the copy instead of the original block Block *new_block = - static_cast(Node::CopyNodeInGraph(block, command)); + static_cast(Node::copy_node_in_graph(block, command)); relinks.insert(block, new_block); block = new_block; if (ClipBlock *new_clip = dynamic_cast(block)) { - new_clip->AddCachePassthroughFrom( + new_clip->add_cache_passthrough_from( static_cast(p.block)); } } - const Track::Reference &track_ref = p.ghost->GetAdjustedTrack(); + const Track::Reference &track_ref = p.ghost->get_adjusted_track(); command->add_child(new TrackPlaceBlockCommand( sequence()->track_list(track_ref.type()), track_ref.index(), - block, p.ghost->GetAdjustedIn())); + block, p.ghost->get_adjusted_in())); } if (!relinks.empty()) { @@ -802,7 +802,7 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) command->add_child(new NodeEdgeAddCommand( cp_clip, NodeInput(cp_in_transition, - TransitionBlock::kInBlockInput))); + TransitionBlock::k_in_block_input))); } if (og_out_transition && @@ -813,19 +813,19 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) command->add_child(new NodeEdgeAddCommand( cp_clip, NodeInput(cp_out_transition, - TransitionBlock::kOutBlockInput))); + TransitionBlock::k_out_block_input))); } } } } // Adjust selections - TimelineWidgetSelections new_sel = parent()->GetSelections(); - new_sel.ShiftTime(blocks_moving.first().ghost->GetInAdjustment()); - new_sel.ShiftTracks(drag_track_type_, - blocks_moving.first().ghost->GetTrackAdjustment()); + TimelineWidgetSelections new_sel = parent()->get_selections(); + new_sel.shift_time(blocks_moving.first().ghost->get_in_adjustment()); + new_sel.shift_tracks(drag_track_type_, + blocks_moving.first().ghost->get_track_adjustment()); command->add_child(new TimelineWidget::SetSelectionsCommand( - parent(), new_sel, parent()->GetSelections())); + parent(), new_sel, parent()->get_selections())); } if (!blocks_sliding.isEmpty()) { @@ -835,17 +835,17 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) QHash> slide_info; QHash in_adjacents; QHash out_adjacents; - rational movement; + Rational movement; foreach (const GhostBlockPair &p, blocks_sliding) { - const Track::Reference &track = p.ghost->GetTrack(); + const Track::Reference &track = p.ghost->get_track(); - switch (p.ghost->GetMode()) { - case Timeline::kNone: + switch (p.ghost->get_mode()) { + case Timeline::k_none: break; - case Timeline::kMove: { + case Timeline::k_move: { // These all should have moved uniformly, so as long as this is set, it should be fine - movement = p.ghost->GetInAdjustment(); + movement = p.ghost->get_in_adjustment(); QList &blocks_on_this_track = slide_info[track]; bool inserted = false; @@ -863,10 +863,10 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) } break; } - case Timeline::kTrimIn: + case Timeline::k_trim_in: out_adjacents.insert(track, p.block); break; - case Timeline::kTrimOut: + case Timeline::k_trim_out: in_adjacents.insert(track, p.block); break; } @@ -876,16 +876,16 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) for (auto i = slide_info.constBegin(); i != slide_info.constEnd(); i++) { command->add_child(new TrackSlideCommand( - parent()->GetTrackFromReference(i.key()), i.value(), + parent()->get_track_from_reference(i.key()), i.value(), in_adjacents.value(i.key()), out_adjacents.value(i.key()), movement)); } // Adjust selections - TimelineWidgetSelections new_sel = parent()->GetSelections(); - new_sel.ShiftTime(movement); + TimelineWidgetSelections new_sel = parent()->get_selections(); + new_sel.shift_time(movement); command->add_child(new TimelineWidget::SetSelectionsCommand( - parent(), new_sel, parent()->GetSelections())); + parent(), new_sel, parent()->get_selections())); } } @@ -893,43 +893,43 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) command, qApp->translate("PointerTool", "Moved Clips")); } -Timeline::MovementMode PointerTool::IsCursorInTrimHandle(Block *block, +Timeline::MovementMode PointerTool::is_cursor_in_trim_handle(Block *block, qreal cursor_x) { - const double kTrimHandle = - QtUtils::QFontMetricsWidth(parent()->fontMetrics(), "H"); + const double k_trim_handle = + QtUtils::q_font_metrics_width(parent()->fontMetrics(), "H"); - double block_left = parent()->TimeToScene(block->in()); - double block_right = parent()->TimeToScene(block->out()); + double block_left = parent()->time_to_scene(block->in()); + double block_right = parent()->time_to_scene(block->out()); double block_width = block_right - block_left; // Block is too narrow, no trimming allowed - if (block_width <= kTrimHandle * 2) { - return Timeline::kNone; + if (block_width <= k_trim_handle * 2) { + return Timeline::k_none; } - if (trimming_allowed_ && cursor_x <= block_left + kTrimHandle) { - return Timeline::kTrimIn; - } else if (trimming_allowed_ && cursor_x >= block_right - kTrimHandle) { - return Timeline::kTrimOut; + if (trimming_allowed_ && cursor_x <= block_left + k_trim_handle) { + return Timeline::k_trim_in; + } else if (trimming_allowed_ && cursor_x >= block_right - k_trim_handle) { + return Timeline::k_trim_out; } else { - return Timeline::kNone; + return Timeline::k_none; } } -void PointerTool::InitiateDrag(Block *clicked_item, +void PointerTool::initiate_drag(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers) { - InitiateDragInternal(clicked_item, trim_mode, modifiers, false, false, + initiate_drag_internal(clicked_item, trim_mode, modifiers, false, false, false); } -TimelineViewGhostItem *PointerTool::GetExistingGhostFromBlock(Block *block) +TimelineViewGhostItem *PointerTool::get_existing_ghost_from_block(Block *block) { - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - if (QtUtils::ValueToPtr(ghost->GetData( - TimelineViewGhostItem::kAttachedBlock)) == block) { + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + if (QtUtils::value_to_ptr(ghost->get_data( + TimelineViewGhostItem::k_attached_block)) == block) { return ghost; } } @@ -940,7 +940,7 @@ TimelineViewGhostItem *PointerTool::GetExistingGhostFromBlock(Block *block) //#define HIDE_GAP_GHOSTS TimelineViewGhostItem * -PointerTool::AddGhostFromBlock(Block *block, Timeline::MovementMode mode, +PointerTool::add_ghost_from_block(Block *block, Timeline::MovementMode mode, bool check_if_exists) { // Ignore null blocks or blocks that aren't attached to a track because there's nothing we can @@ -953,13 +953,13 @@ PointerTool::AddGhostFromBlock(Block *block, Timeline::MovementMode mode, // Check if we've already made a ghost for this block if (check_if_exists) { - if ((ghost = GetExistingGhostFromBlock(block))) { + if ((ghost = get_existing_ghost_from_block(block))) { return ghost; } } // Otherwise, it's time to make a ghost for this block - ghost = TimelineViewGhostItem::FromBlock(block); + ghost = TimelineViewGhostItem::from_block(block); #ifdef HIDE_GAP_GHOSTS if (block->type() == Block::kGap) { @@ -967,62 +967,62 @@ PointerTool::AddGhostFromBlock(Block *block, Timeline::MovementMode mode, } #endif - AddGhostInternal(ghost, mode); + add_ghost_internal(ghost, mode); return ghost; } TimelineViewGhostItem * -PointerTool::AddGhostFromNull(const rational &in, const rational &out, +PointerTool::add_ghost_from_null(const Rational &in, const Rational &out, const Track::Reference &track, Timeline::MovementMode mode) { TimelineViewGhostItem *ghost = new TimelineViewGhostItem(); - ghost->SetIn(in); - ghost->SetOut(out); - ghost->SetTrack(track); + ghost->set_in(in); + ghost->set_out(out); + ghost->set_track(track); #ifdef HIDE_GAP_GHOSTS ghost->SetInvisible(true); #endif - AddGhostInternal(ghost, mode); + add_ghost_internal(ghost, mode); return ghost; } -void PointerTool::AddGhostInternal(TimelineViewGhostItem *ghost, +void PointerTool::add_ghost_internal(TimelineViewGhostItem *ghost, Timeline::MovementMode mode) { - ghost->SetMode(mode); + ghost->set_mode(mode); // Prepare snap points (optimizes snapping for later) switch (mode) { - case Timeline::kMove: - snap_points_.push_back(ghost->GetIn()); - snap_points_.push_back(ghost->GetOut()); + case Timeline::k_move: + snap_points_.push_back(ghost->get_in()); + snap_points_.push_back(ghost->get_out()); break; - case Timeline::kTrimIn: - snap_points_.push_back(ghost->GetIn()); + case Timeline::k_trim_in: + snap_points_.push_back(ghost->get_in()); break; - case Timeline::kTrimOut: - snap_points_.push_back(ghost->GetOut()); + case Timeline::k_trim_out: + snap_points_.push_back(ghost->get_out()); break; default: break; } - parent()->AddGhost(ghost); + parent()->add_ghost(ghost); } -bool PointerTool::IsClipTrimmable(Block *clip, const QVector &items, +bool PointerTool::is_clip_trimmable(Block *clip, const QVector &items, const Timeline::MovementMode &mode) { foreach (Block *compare, items) { if (clip->track() == compare->track() && clip != compare && - ((compare->in() < clip->in() && mode == Timeline::kTrimIn) || - (compare->out() > clip->out() && mode == Timeline::kTrimOut))) { + ((compare->in() < clip->in() && mode == Timeline::k_trim_in) || + (compare->out() > clip->out() && mode == Timeline::k_trim_out))) { return false; } } @@ -1030,36 +1030,36 @@ bool PointerTool::IsClipTrimmable(Block *clip, const QVector &items, return true; } -rational PointerTool::ValidateInTrimming(rational movement) +Rational PointerTool::validate_in_trimming(Rational movement) { bool first_ghost = true; - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - if (ghost->GetMode() != Timeline::kTrimIn) { + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + if (ghost->get_mode() != Timeline::k_trim_in) { continue; } - rational earliest_in = RATIONAL_MIN; - rational latest_in = ghost->GetOut(); + Rational earliest_in = RATIONAL_MIN; + Rational latest_in = ghost->get_out(); - rational ghost_timebase = - parent()->GetTimebaseForTrackType(ghost->GetTrack().type()); + Rational ghost_timebase = + parent()->get_timebase_for_track_type(ghost->get_track().type()); // If the ghost must be at least one frame in size, limit the latest allowed in point - if (!ghost->CanHaveZeroLength()) { + if (!ghost->can_have_zero_length()) { latest_in -= ghost_timebase; } // Clamp adjusted value between the earliest and latest values - rational adjusted = ghost->GetIn() + movement; - rational clamped = std::clamp(adjusted, earliest_in, latest_in); + Rational adjusted = ghost->get_in() + movement; + Rational clamped = std::clamp(adjusted, earliest_in, latest_in); if (clamped != adjusted) { - movement = clamped - ghost->GetIn(); + movement = clamped - ghost->get_in(); } if (first_ghost) { - movement = SnapMovementToTimebase(ghost->GetIn(), movement, + movement = snap_movement_to_timebase(ghost->get_in(), movement, ghost_timebase); first_ghost = false; } @@ -1068,37 +1068,37 @@ rational PointerTool::ValidateInTrimming(rational movement) return movement; } -rational PointerTool::ValidateOutTrimming(rational movement) +Rational PointerTool::validate_out_trimming(Rational movement) { bool first_ghost = true; - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - if (ghost->GetMode() != Timeline::kTrimOut) { + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + if (ghost->get_mode() != Timeline::k_trim_out) { continue; } // Determine earliest and latest out points - rational earliest_out = ghost->GetIn(); + Rational earliest_out = ghost->get_in(); - rational ghost_timebase = - parent()->GetTimebaseForTrackType(ghost->GetTrack().type()); + Rational ghost_timebase = + parent()->get_timebase_for_track_type(ghost->get_track().type()); - if (!ghost->CanHaveZeroLength()) { + if (!ghost->can_have_zero_length()) { earliest_out += ghost_timebase; } - rational latest_out = RATIONAL_MAX; + Rational latest_out = RATIONAL_MAX; // Clamp adjusted value between the earliest and latest values - rational adjusted = ghost->GetOut() + movement; - rational clamped = std::clamp(adjusted, earliest_out, latest_out); + Rational adjusted = ghost->get_out() + movement; + Rational clamped = std::clamp(adjusted, earliest_out, latest_out); if (clamped != adjusted) { - movement = clamped - ghost->GetOut(); + movement = clamped - ghost->get_out(); } if (first_ghost) { - movement = SnapMovementToTimebase(ghost->GetOut(), movement, + movement = snap_movement_to_timebase(ghost->get_out(), movement, ghost_timebase); first_ghost = false; } diff --git a/app/widget/timelinewidget/tool/pointer.h b/app/widget/timelinewidget/tool/pointer.h index 17f05eac7..1b94557ed 100644 --- a/app/widget/timelinewidget/tool/pointer.h +++ b/app/widget/timelinewidget/tool/pointer.h @@ -19,8 +19,8 @@ ***/ -#ifndef POINTERTIMELINETOOL_H -#define POINTERTIMELINETOOL_H +#ifndef OAK_POINTERTIMELINETOOL_H +#define OAK_POINTERTIMELINETOOL_H #include "tool.h" @@ -31,27 +31,27 @@ class PointerTool : public TimelineTool { public: PointerTool(TimelineWidget *parent); - virtual void MousePress(TimelineViewMouseEvent *event) override; - virtual void MouseMove(TimelineViewMouseEvent *event) override; - virtual void MouseRelease(TimelineViewMouseEvent *event) override; + virtual void mouse_press(TimelineViewMouseEvent *event) override; + virtual void mouse_move(TimelineViewMouseEvent *event) override; + virtual void mouse_release(TimelineViewMouseEvent *event) override; - virtual void HoverMove(TimelineViewMouseEvent *event) override; + virtual void hover_move(TimelineViewMouseEvent *event) override; protected: - virtual void FinishDrag(TimelineViewMouseEvent *event); + virtual void finish_drag(TimelineViewMouseEvent *event); - virtual void InitiateDrag(Block *clicked_item, + virtual void initiate_drag(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers); - TimelineViewGhostItem *GetExistingGhostFromBlock(Block *block); + TimelineViewGhostItem *get_existing_ghost_from_block(Block *block); - TimelineViewGhostItem *AddGhostFromBlock(Block *block, + TimelineViewGhostItem *add_ghost_from_block(Block *block, Timeline::MovementMode mode, bool check_if_exists = false); - TimelineViewGhostItem *AddGhostFromNull(const rational &in, - const rational &out, + TimelineViewGhostItem *add_ghost_from_null(const Rational &in, + const Rational &out, const Track::Reference &track, Timeline::MovementMode mode); @@ -61,7 +61,7 @@ protected: * Assumes ghost->data() is a Block. Ensures no Ghost's in point becomes a negative timecode. Also ensures no * Ghost's length becomes 0 or negative. */ - rational ValidateInTrimming(rational movement); + Rational validate_in_trimming(Rational movement); /** * @brief Validates Ghosts that are getting their out points trimmed @@ -69,11 +69,11 @@ protected: * Assumes ghost->data() is a Block. Ensures no Ghost's in point becomes a negative timecode. Also ensures no * Ghost's length becomes 0 or negative. */ - rational ValidateOutTrimming(rational movement); + Rational validate_out_trimming(Rational movement); - virtual void ProcessDrag(const TimelineCoordinate &mouse_pos); + virtual void process_drag(const TimelineCoordinate &mouse_pos); - void InitiateDragInternal(Block *clicked_item, + void initiate_drag_internal(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers, bool dont_roll_trims, bool allow_nongap_rolling, @@ -88,46 +88,46 @@ protected: drag_movement_mode_ = d; } - static bool CanTransitionMove(TransitionBlock *transit, + static bool can_transition_move(TransitionBlock *transit, const QVector &clips); - void SetMovementAllowed(bool e) + void set_movement_allowed(bool e) { movement_allowed_ = e; } - void SetTrimmingAllowed(bool e) + void set_trimming_allowed(bool e) { trimming_allowed_ = e; } - void SetTrackMovementAllowed(bool e) + void set_track_movement_allowed(bool e) { track_movement_allowed_ = e; } - void SetGapTrimmingAllowed(bool e) + void set_gap_trimming_allowed(bool e) { gap_trimming_allowed_ = e; } - void SetClickedItem(Block *b) + void set_clicked_item(Block *b) { clicked_item_ = b; } private: - Timeline::MovementMode IsCursorInTrimHandle(Block *block, qreal cursor_x); + Timeline::MovementMode is_cursor_in_trim_handle(Block *block, qreal cursor_x); - void AddGhostInternal(TimelineViewGhostItem *ghost, + void add_ghost_internal(TimelineViewGhostItem *ghost, Timeline::MovementMode mode); - bool IsClipTrimmable(Block *clip, const QVector &items, + bool is_clip_trimmable(Block *clip, const QVector &items, const Timeline::MovementMode &mode); - void ProcessGhostsForSliding(); + void process_ghosts_for_sliding(); - void ProcessGhostsForRolling(); + void process_ghosts_for_rolling(); bool movement_allowed_; bool trimming_allowed_; @@ -146,4 +146,4 @@ private: } -#endif // POINTERTIMELINETOOL_H +#endif // OAK_POINTERTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/razor.cpp b/app/widget/timelinewidget/tool/razor.cpp index 0b3152c90..234d50bc0 100644 --- a/app/widget/timelinewidget/tool/razor.cpp +++ b/app/widget/timelinewidget/tool/razor.cpp @@ -33,45 +33,45 @@ RazorTool::RazorTool(TimelineWidget *parent) { } -void RazorTool::MousePress(TimelineViewMouseEvent *event) +void RazorTool::mouse_press(TimelineViewMouseEvent *event) { split_tracks_.clear(); - MouseMove(event); + mouse_move(event); } -void RazorTool::MouseMove(TimelineViewMouseEvent *event) +void RazorTool::mouse_move(TimelineViewMouseEvent *event) { if (!dragging_) { - drag_start_ = ValidatedCoordinate(event->GetCoordinates(true)); + drag_start_ = validated_coordinate(event->get_coordinates(true)); dragging_ = true; } // Split at the current cursor track - Track::Reference split_track = event->GetTrack(); + Track::Reference split_track = event->get_track(); if (!split_tracks_.contains(split_track)) { split_tracks_.append(split_track); } } -void RazorTool::MouseRelease(TimelineViewMouseEvent *event) +void RazorTool::mouse_release(TimelineViewMouseEvent *event) { Q_UNUSED(event) // Always split at the same time - rational split_time = drag_start_.GetFrame(); + Rational split_time = drag_start_.get_frame(); QVector blocks_to_split; foreach (const Track::Reference &track_ref, split_tracks_) { - Track *track = parent()->GetTrackFromReference(track_ref); + Track *track = parent()->get_track_from_reference(track_ref); - if (track == nullptr || track->IsLocked()) { + if (track == nullptr || track->is_locked()) { continue; } - Block *block_at_time = track->NearestBlockBefore(split_time); + Block *block_at_time = track->nearest_block_before(split_time); // Ensure there's a valid block here ClipBlock *clip_at_time; @@ -81,7 +81,7 @@ void RazorTool::MouseRelease(TimelineViewMouseEvent *event) blocks_to_split.append(block_at_time); // Add links if no alt is held - if (!(event->GetModifiers() & Qt::AltModifier)) { + if (!(event->get_modifiers() & Qt::AltModifier)) { foreach (Block *link, clip_at_time->block_links()) { if (!blocks_to_split.contains(link)) { blocks_to_split.append(link); diff --git a/app/widget/timelinewidget/tool/razor.h b/app/widget/timelinewidget/tool/razor.h index 66b993d33..3a07829be 100644 --- a/app/widget/timelinewidget/tool/razor.h +++ b/app/widget/timelinewidget/tool/razor.h @@ -19,8 +19,8 @@ ***/ -#ifndef RAZORTIMELINETOOL_H -#define RAZORTIMELINETOOL_H +#ifndef OAK_RAZORTIMELINETOOL_H +#define OAK_RAZORTIMELINETOOL_H #include "beam.h" @@ -31,9 +31,9 @@ class RazorTool : public BeamTool { public: RazorTool(TimelineWidget *parent); - virtual void MousePress(TimelineViewMouseEvent *event) override; - virtual void MouseMove(TimelineViewMouseEvent *event) override; - virtual void MouseRelease(TimelineViewMouseEvent *event) override; + virtual void mouse_press(TimelineViewMouseEvent *event) override; + virtual void mouse_move(TimelineViewMouseEvent *event) override; + virtual void mouse_release(TimelineViewMouseEvent *event) override; private: QVector split_tracks_; @@ -41,4 +41,4 @@ private: } -#endif // RAZORTIMELINETOOL_H +#endif // OAK_RAZORTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/record.cpp b/app/widget/timelinewidget/tool/record.cpp index f194d60b7..7785bbf49 100644 --- a/app/widget/timelinewidget/tool/record.cpp +++ b/app/widget/timelinewidget/tool/record.cpp @@ -29,78 +29,78 @@ RecordTool::RecordTool(TimelineWidget *parent) { } -void RecordTool::MousePress(TimelineViewMouseEvent *event) +void RecordTool::mouse_press(TimelineViewMouseEvent *event) { - const Track::Reference &track = event->GetTrack(); + const Track::Reference &track = event->get_track(); // Check if track is locked - Track *t = parent()->GetTrackFromReference(track); - if (t && t->IsLocked()) { + Track *t = parent()->get_track_from_reference(track); + if (t && t->is_locked()) { return; } - if (t && t->type() != Track::kAudio) { + if (t && t->type() != Track::k_audio) { // We only support audio tracks here return; } drag_start_point_ = - ValidatedCoordinate(event->GetCoordinates(true)).GetFrame(); + validated_coordinate(event->get_coordinates(true)).get_frame(); ghost_ = new TimelineViewGhostItem(); - ghost_->SetIn(drag_start_point_); - ghost_->SetOut(drag_start_point_); - ghost_->SetTrack(track); - parent()->AddGhost(ghost_); + ghost_->set_in(drag_start_point_); + ghost_->set_out(drag_start_point_); + ghost_->set_track(track); + parent()->add_ghost(ghost_); snap_points_.push_back(drag_start_point_); } -void RecordTool::MouseMove(TimelineViewMouseEvent *event) +void RecordTool::mouse_move(TimelineViewMouseEvent *event) { if (!ghost_) { return; } // Calculate movement - rational movement = event->GetFrame() - drag_start_point_; + Rational movement = event->get_frame() - drag_start_point_; // Validation: Ensure in point never goes below 0 - if (movement < -ghost_->GetIn()) { - movement = -ghost_->GetIn(); + if (movement < -ghost_->get_in()) { + movement = -ghost_->get_in(); } // Snap movement bool snapped; if (Core::instance()->snapping()) { - snapped = parent()->SnapPoint(snap_points_, &movement); + snapped = parent()->snap_point(snap_points_, &movement); } else { snapped = false; } // Make adjustment if (!movement) { - ghost_->SetInAdjustment(0); - ghost_->SetOutAdjustment(0); + ghost_->set_in_adjustment(0); + ghost_->set_out_adjustment(0); } else if (movement > 0) { - ghost_->SetInAdjustment(0); - ghost_->SetOutAdjustment(movement); + ghost_->set_in_adjustment(0); + ghost_->set_out_adjustment(movement); } else if (movement < 0) { - ghost_->SetInAdjustment(movement); - ghost_->SetOutAdjustment(0); + ghost_->set_in_adjustment(movement); + ghost_->set_out_adjustment(0); } Q_UNUSED(snapped) } -void RecordTool::MouseRelease(TimelineViewMouseEvent *event) +void RecordTool::mouse_release(TimelineViewMouseEvent *event) { if (ghost_) { - emit parent() -> RequestCaptureStart( - TimeRange(ghost_->GetAdjustedIn(), ghost_->GetAdjustedOut()), - ghost_->GetTrack()); - parent()->ClearGhosts(); + emit parent() -> request_capture_start( + TimeRange(ghost_->get_adjusted_in(), ghost_->get_adjusted_out()), + ghost_->get_track()); + parent()->clear_ghosts(); snap_points_.clear(); ghost_ = nullptr; } diff --git a/app/widget/timelinewidget/tool/record.h b/app/widget/timelinewidget/tool/record.h index de244298a..e5f249a1b 100644 --- a/app/widget/timelinewidget/tool/record.h +++ b/app/widget/timelinewidget/tool/record.h @@ -19,8 +19,8 @@ ***/ -#ifndef RECORDTIMELINETOOL_H -#define RECORDTIMELINETOOL_H +#ifndef OAK_RECORDTIMELINETOOL_H +#define OAK_RECORDTIMELINETOOL_H #include "beam.h" @@ -31,16 +31,16 @@ class RecordTool : public BeamTool { public: RecordTool(TimelineWidget *parent); - virtual void MousePress(TimelineViewMouseEvent *event) override; - virtual void MouseMove(TimelineViewMouseEvent *event) override; - virtual void MouseRelease(TimelineViewMouseEvent *event) override; + virtual void mouse_press(TimelineViewMouseEvent *event) override; + virtual void mouse_move(TimelineViewMouseEvent *event) override; + virtual void mouse_release(TimelineViewMouseEvent *event) override; protected: - void MouseMoveInternal(const rational &cursor_frame, bool outwards); + void mouse_move_internal(const Rational &cursor_frame, bool outwards); TimelineViewGhostItem *ghost_; - rational drag_start_point_; + Rational drag_start_point_; }; } diff --git a/app/widget/timelinewidget/tool/ripple.cpp b/app/widget/timelinewidget/tool/ripple.cpp index 6271496dd..507e18d5c 100644 --- a/app/widget/timelinewidget/tool/ripple.cpp +++ b/app/widget/timelinewidget/tool/ripple.cpp @@ -31,46 +31,46 @@ namespace olive RippleTool::RippleTool(TimelineWidget *parent) : PointerTool(parent) { - SetMovementAllowed(false); - SetGapTrimmingAllowed(true); + set_movement_allowed(false); + set_gap_trimming_allowed(true); } -void RippleTool::InitiateDrag(Block *clicked_item, +void RippleTool::initiate_drag(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers) { - InitiateDragInternal(clicked_item, trim_mode, modifiers, true, true, false); + initiate_drag_internal(clicked_item, trim_mode, modifiers, true, true, false); - if (!parent()->HasGhosts()) { + if (!parent()->has_ghosts()) { return; } // Find the earliest ripple - rational earliest_ripple = RATIONAL_MAX; + Rational earliest_ripple = RATIONAL_MAX; - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - rational ghost_ripple_point; + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + Rational ghost_ripple_point; - if (trim_mode == Timeline::kTrimIn) { - ghost_ripple_point = ghost->GetIn(); + if (trim_mode == Timeline::k_trim_in) { + ghost_ripple_point = ghost->get_in(); } else { - ghost_ripple_point = ghost->GetOut(); + ghost_ripple_point = ghost->get_out(); } earliest_ripple = qMin(earliest_ripple, ghost_ripple_point); } // For each track that does NOT have a ghost, we need to make one for Gaps - foreach (Track *track, sequence()->GetTracks()) { - if (track->IsLocked()) { + foreach (Track *track, sequence()->get_tracks()) { + if (track->is_locked()) { continue; } // Determine if we've already created a ghost on this track bool ghost_on_this_track_exists = false; - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - if (parent()->GetTrackFromReference(ghost->GetTrack()) == track) { + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + if (parent()->get_track_from_reference(ghost->get_track()) == track) { ghost_on_this_track_exists = true; break; } @@ -80,7 +80,7 @@ void RippleTool::InitiateDrag(Block *clicked_item, if (!ghost_on_this_track_exists) { // Find the block that starts just after or at the ripple point Block *block_after_ripple = - track->NearestBlockAfterOrAt(earliest_ripple); + track->nearest_block_after_or_at(earliest_ripple); // Exception for out-transitions, do not create a gap between them if (block_after_ripple) { @@ -98,7 +98,7 @@ void RippleTool::InitiateDrag(Block *clicked_item, if (dynamic_cast(block_after_ripple)) { // If this Block is already a Gap, ghost it now - ghost = AddGhostFromBlock(block_after_ripple, trim_mode); + ghost = add_ghost_from_block(block_after_ripple, trim_mode); } else { // Well we need to ripple SOMETHING, it'll either be the previous block if it's a gap // or we'll have to create a new gap ourselves @@ -106,15 +106,15 @@ void RippleTool::InitiateDrag(Block *clicked_item, if (dynamic_cast(previous)) { // Previous is a gap, that'll make a fine substitute - ghost = AddGhostFromBlock(previous, trim_mode); + ghost = add_ghost_from_block(previous, trim_mode); } else { // Previous is not a gap, we'll have to insert one there ourselves - ghost = AddGhostFromNull(block_after_ripple->in(), + ghost = add_ghost_from_null(block_after_ripple->in(), block_after_ripple->in(), - track->ToReference(), + track->to_reference(), trim_mode); - ghost->SetData(TimelineViewGhostItem::kReferenceBlock, - QtUtils::PtrToValue(block_after_ripple)); + ghost->set_data(TimelineViewGhostItem::k_reference_block, + QtUtils::ptr_to_value(block_after_ripple)); } } } @@ -122,31 +122,31 @@ void RippleTool::InitiateDrag(Block *clicked_item, } } -void RippleTool::FinishDrag(TimelineViewMouseEvent *event) +void RippleTool::finish_drag(TimelineViewMouseEvent *event) { Q_UNUSED(event) - if (parent()->HasGhosts()) { + if (parent()->has_ghosts()) { QVector> - info_list(Track::kCount); + info_list(Track::k_count); - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - if (!ghost->HasBeenAdjusted()) { + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + if (!ghost->has_been_adjusted()) { continue; } - Track *track = parent()->GetTrackFromReference(ghost->GetTrack()); + Track *track = parent()->get_track_from_reference(ghost->get_track()); TrackListRippleToolCommand::RippleInfo info; - Block *b = QtUtils::ValueToPtr( - ghost->GetData(TimelineViewGhostItem::kAttachedBlock)); + Block *b = QtUtils::value_to_ptr( + ghost->get_data(TimelineViewGhostItem::k_attached_block)); if (b) { info.block = b; info.append_gap = false; } else { - info.block = QtUtils::ValueToPtr( - ghost->GetData(TimelineViewGhostItem::kReferenceBlock)); + info.block = QtUtils::value_to_ptr( + ghost->get_data(TimelineViewGhostItem::k_reference_block)); info.append_gap = true; } @@ -155,12 +155,12 @@ void RippleTool::FinishDrag(TimelineViewMouseEvent *event) MultiUndoCommand *command = new MultiUndoCommand(); - rational movement; + Rational movement; - if (drag_movement_mode() == Timeline::kTrimOut) { - movement = parent()->GetGhostItems().first()->GetOutAdjustment(); + if (drag_movement_mode() == Timeline::k_trim_out) { + movement = parent()->get_ghost_items().first()->get_out_adjustment(); } else { - movement = parent()->GetGhostItems().first()->GetInAdjustment(); + movement = parent()->get_ghost_items().first()->get_in_adjustment(); } for (int i = 0; i < info_list.size(); i++) { @@ -172,16 +172,16 @@ void RippleTool::FinishDrag(TimelineViewMouseEvent *event) } if (command->child_count() > 0) { - TimelineWidgetSelections new_sel = parent()->GetSelections(); + TimelineWidgetSelections new_sel = parent()->get_selections(); TimelineViewGhostItem *reference_ghost = - parent()->GetGhostItems().first(); - if (drag_movement_mode() == Timeline::kTrimIn) { - new_sel.TrimOut(-reference_ghost->GetInAdjustment()); + parent()->get_ghost_items().first(); + if (drag_movement_mode() == Timeline::k_trim_in) { + new_sel.trim_out(-reference_ghost->get_in_adjustment()); } else { - new_sel.TrimOut(reference_ghost->GetOutAdjustment()); + new_sel.trim_out(reference_ghost->get_out_adjustment()); } command->add_child(new TimelineWidget::SetSelectionsCommand( - parent(), new_sel, parent()->GetSelections(), false)); + parent(), new_sel, parent()->get_selections(), false)); Core::instance()->undo_stack()->push( command, qApp->translate("RippleTool", "Rippled Clips")); diff --git a/app/widget/timelinewidget/tool/ripple.h b/app/widget/timelinewidget/tool/ripple.h index 5f74f6eb7..80586a0b0 100644 --- a/app/widget/timelinewidget/tool/ripple.h +++ b/app/widget/timelinewidget/tool/ripple.h @@ -19,8 +19,8 @@ ***/ -#ifndef RIPPLETIMELINETOOL_H -#define RIPPLETIMELINETOOL_H +#ifndef OAK_RIPPLETIMELINETOOL_H +#define OAK_RIPPLETIMELINETOOL_H #include "pointer.h" @@ -32,13 +32,13 @@ public: RippleTool(TimelineWidget *parent); protected: - virtual void FinishDrag(TimelineViewMouseEvent *event) override; + virtual void finish_drag(TimelineViewMouseEvent *event) override; - virtual void InitiateDrag(Block *clicked_item, + virtual void initiate_drag(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers) override; }; } -#endif // RIPPLETIMELINETOOL_H +#endif // OAK_RIPPLETIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/rolling.cpp b/app/widget/timelinewidget/tool/rolling.cpp index bad683c57..beec84735 100644 --- a/app/widget/timelinewidget/tool/rolling.cpp +++ b/app/widget/timelinewidget/tool/rolling.cpp @@ -31,15 +31,15 @@ namespace olive RollingTool::RollingTool(TimelineWidget *parent) : PointerTool(parent) { - SetMovementAllowed(false); - SetGapTrimmingAllowed(true); + set_movement_allowed(false); + set_gap_trimming_allowed(true); } -void RollingTool::InitiateDrag(Block *clicked_item, +void RollingTool::initiate_drag(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers) { - InitiateDragInternal(clicked_item, trim_mode, modifiers, false, true, + initiate_drag_internal(clicked_item, trim_mode, modifiers, false, true, false); } diff --git a/app/widget/timelinewidget/tool/rolling.h b/app/widget/timelinewidget/tool/rolling.h index a31cbcd42..a9880d54e 100644 --- a/app/widget/timelinewidget/tool/rolling.h +++ b/app/widget/timelinewidget/tool/rolling.h @@ -19,8 +19,8 @@ ***/ -#ifndef ROLLINGTIMELINETOOL_H -#define ROLLINGTIMELINETOOL_H +#ifndef OAK_ROLLINGTIMELINETOOL_H +#define OAK_ROLLINGTIMELINETOOL_H #include "pointer.h" @@ -32,11 +32,11 @@ public: RollingTool(TimelineWidget *parent); protected: - virtual void InitiateDrag(Block *clicked_item, + virtual void initiate_drag(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers) override; }; } -#endif // ROLLINGTIMELINETOOL_H +#endif // OAK_ROLLINGTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/slide.cpp b/app/widget/timelinewidget/tool/slide.cpp index b7f08c77e..d7ad809e3 100644 --- a/app/widget/timelinewidget/tool/slide.cpp +++ b/app/widget/timelinewidget/tool/slide.cpp @@ -31,16 +31,16 @@ namespace olive SlideTool::SlideTool(TimelineWidget *parent) : PointerTool(parent) { - SetTrimmingAllowed(false); - SetTrackMovementAllowed(false); - SetGapTrimmingAllowed(true); + set_trimming_allowed(false); + set_track_movement_allowed(false); + set_gap_trimming_allowed(true); } -void SlideTool::InitiateDrag(Block *clicked_item, +void SlideTool::initiate_drag(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers) { - InitiateDragInternal(clicked_item, trim_mode, modifiers, false, true, true); + initiate_drag_internal(clicked_item, trim_mode, modifiers, false, true, true); } } diff --git a/app/widget/timelinewidget/tool/slide.h b/app/widget/timelinewidget/tool/slide.h index e299cac1f..be6e8e9e0 100644 --- a/app/widget/timelinewidget/tool/slide.h +++ b/app/widget/timelinewidget/tool/slide.h @@ -19,8 +19,8 @@ ***/ -#ifndef SLIDETIMELINETOOL_H -#define SLIDETIMELINETOOL_H +#ifndef OAK_SLIDETIMELINETOOL_H +#define OAK_SLIDETIMELINETOOL_H #include "pointer.h" @@ -32,11 +32,11 @@ public: SlideTool(TimelineWidget *parent); protected: - virtual void InitiateDrag(Block *clicked_item, + virtual void initiate_drag(Block *clicked_item, Timeline::MovementMode trim_mode, Qt::KeyboardModifiers modifiers) override; }; } -#endif // SLIDETIMELINETOOL_H +#endif // OAK_SLIDETIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/slip.cpp b/app/widget/timelinewidget/tool/slip.cpp index da5a60543..f36e1b000 100644 --- a/app/widget/timelinewidget/tool/slip.cpp +++ b/app/widget/timelinewidget/tool/slip.cpp @@ -33,60 +33,60 @@ namespace olive SlipTool::SlipTool(TimelineWidget *parent) : PointerTool(parent) { - SetTrimmingAllowed(false); - SetTrackMovementAllowed(false); + set_trimming_allowed(false); + set_track_movement_allowed(false); } -void SlipTool::ProcessDrag(const TimelineCoordinate &mouse_pos) +void SlipTool::process_drag(const TimelineCoordinate &mouse_pos) { // Determine frame movement - rational time_movement = drag_start_.GetFrame() - mouse_pos.GetFrame(); + Rational time_movement = drag_start_.get_frame() - mouse_pos.get_frame(); // Validate slip (enforce all ghosts moving in legal ways) - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - if (ghost->GetMediaIn() + time_movement < 0) { - time_movement = -ghost->GetMediaIn(); + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + if (ghost->get_media_in() + time_movement < 0) { + time_movement = -ghost->get_media_in(); } } // Perform slip - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - ghost->SetMediaInAdjustment(time_movement); + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + ghost->set_media_in_adjustment(time_movement); } // Generate tooltip and force it to to update (otherwise the tooltip won't move as written in the // documentation, and could get in the way of the cursor) - rational tooltip_timebase = - parent()->GetTimebaseForTrackType(drag_start_.GetTrack().type()); + Rational tooltip_timebase = + parent()->get_timebase_for_track_type(drag_start_.get_track().type()); QToolTip::hideText(); QToolTip::showText(QCursor::pos(), QString::fromStdString(Timecode::time_to_timecode( time_movement, tooltip_timebase, - Core::instance()->GetTimecodeDisplay(), true)), + Core::instance()->get_timecode_display(), true)), parent()); } -void SlipTool::FinishDrag(TimelineViewMouseEvent *event) +void SlipTool::finish_drag(TimelineViewMouseEvent *event) { Q_UNUSED(event) MultiUndoCommand *command = new MultiUndoCommand(); // Find earliest point to ripple around - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - Block *b = QtUtils::ValueToPtr( - ghost->GetData(TimelineViewGhostItem::kAttachedBlock)); + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + Block *b = QtUtils::value_to_ptr( + ghost->get_data(TimelineViewGhostItem::k_attached_block)); ClipBlock *cb = dynamic_cast(b); if (cb) { command->add_child( - new BlockSetMediaInCommand(cb, ghost->GetAdjustedMediaIn())); + new BlockSetMediaInCommand(cb, ghost->get_adjusted_media_in())); } } Core::instance()->undo_stack()->push( command, qApp->translate("SlipTool", "Slipped %1 Clip(s)") - .arg(parent()->GetGhostItems().size())); + .arg(parent()->get_ghost_items().size())); } } diff --git a/app/widget/timelinewidget/tool/slip.h b/app/widget/timelinewidget/tool/slip.h index 01ccd3650..0be1004df 100644 --- a/app/widget/timelinewidget/tool/slip.h +++ b/app/widget/timelinewidget/tool/slip.h @@ -19,8 +19,8 @@ ***/ -#ifndef SLIPTIMELINETOOL_H -#define SLIPTIMELINETOOL_H +#ifndef OAK_SLIPTIMELINETOOL_H +#define OAK_SLIPTIMELINETOOL_H #include "pointer.h" @@ -32,10 +32,10 @@ public: SlipTool(TimelineWidget *parent); protected: - virtual void ProcessDrag(const TimelineCoordinate &mouse_pos) override; - virtual void FinishDrag(TimelineViewMouseEvent *event) override; + virtual void process_drag(const TimelineCoordinate &mouse_pos) override; + virtual void finish_drag(TimelineViewMouseEvent *event) override; }; } -#endif // SLIPTIMELINETOOL_H +#endif // OAK_SLIPTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/tool.cpp b/app/widget/timelinewidget/tool/tool.cpp index 75e718f20..3afc6dc43 100644 --- a/app/widget/timelinewidget/tool/tool.cpp +++ b/app/widget/timelinewidget/tool/tool.cpp @@ -26,7 +26,7 @@ namespace olive { -const int TimelineTool::kDefaultDistanceFromOutput = -4; +const int TimelineTool::k_default_distance_from_output = -4; TimelineTool::TimelineTool(TimelineWidget *parent) : dragging_(false) @@ -49,25 +49,25 @@ Sequence *TimelineTool::sequence() } Timeline::MovementMode -TimelineTool::FlipTrimMode(const Timeline::MovementMode &trim_mode) +TimelineTool::flip_trim_mode(const Timeline::MovementMode &trim_mode) { - if (trim_mode == Timeline::kTrimIn) { - return Timeline::kTrimOut; + if (trim_mode == Timeline::k_trim_in) { + return Timeline::k_trim_out; } - if (trim_mode == Timeline::kTrimOut) { - return Timeline::kTrimIn; + if (trim_mode == Timeline::k_trim_out) { + return Timeline::k_trim_in; } return trim_mode; } -rational TimelineTool::SnapMovementToTimebase(const rational &start, - rational movement, - const rational &timebase) +Rational TimelineTool::snap_movement_to_timebase(const Rational &start, + Rational movement, + const Rational &timebase) { - rational proposed_position = start + movement; - rational snapped = + Rational proposed_position = start + movement; + Rational snapped = Timecode::snap_time_to_timebase(proposed_position, timebase); if (proposed_position != snapped) { @@ -77,23 +77,23 @@ rational TimelineTool::SnapMovementToTimebase(const rational &start, return movement; } -rational TimelineTool::ValidateTimeMovement(rational movement) +Rational TimelineTool::validate_time_movement(Rational movement) { bool first_ghost = true; - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - if (ghost->GetMode() != Timeline::kMove) { + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + if (ghost->get_mode() != Timeline::k_move) { continue; } // Prevents any ghosts from going below 0:00:00 time - if (ghost->GetIn() + movement < 0) { - movement = -ghost->GetIn(); + if (ghost->get_in() + movement < 0) { + movement = -ghost->get_in(); } else if (first_ghost) { // Ensure ghost is snapped to a grid - movement = SnapMovementToTimebase( - ghost->GetIn(), movement, - parent()->GetTimebaseForTrackType(ghost->GetTrack().type())); + movement = snap_movement_to_timebase( + ghost->get_in(), movement, + parent()->get_timebase_for_track_type(ghost->get_track().type())); first_ghost = false; } @@ -102,35 +102,35 @@ rational TimelineTool::ValidateTimeMovement(rational movement) return movement; } -int TimelineTool::ValidateTrackMovement( +int TimelineTool::validate_track_movement( int movement, const QVector &ghosts) { foreach (TimelineViewGhostItem *ghost, ghosts) { - if (ghost->GetMode() != Timeline::kMove) { + if (ghost->get_mode() != Timeline::k_move) { continue; } - if (!ghost->GetCanMoveTracks()) { + if (!ghost->get_can_move_tracks()) { return 0; - } else if (ghost->GetTrack().index() + movement < 0) { + } else if (ghost->get_track().index() + movement < 0) { // Prevents any ghosts from going to a non-existent negative track - movement = -ghost->GetTrack().index(); + movement = -ghost->get_track().index(); } } return movement; } -void TimelineTool::GetGhostData(rational *earliest_point, - rational *latest_point) +void TimelineTool::get_ghost_data(Rational *earliest_point, + Rational *latest_point) { - rational ep = RATIONAL_MAX; - rational lp = RATIONAL_MIN; + Rational ep = RATIONAL_MAX; + Rational lp = RATIONAL_MIN; - foreach (TimelineViewGhostItem *ghost, parent()->GetGhostItems()) { - ep = qMin(ep, ghost->GetAdjustedIn()); - lp = qMax(lp, ghost->GetAdjustedOut()); + foreach (TimelineViewGhostItem *ghost, parent()->get_ghost_items()) { + ep = qMin(ep, ghost->get_adjusted_in()); + lp = qMax(lp, ghost->get_adjusted_out()); } if (earliest_point) { @@ -142,13 +142,13 @@ void TimelineTool::GetGhostData(rational *earliest_point, } } -void TimelineTool::InsertGapsAtGhostDestination(olive::MultiUndoCommand *command) +void TimelineTool::insert_gaps_at_ghost_destination(olive::MultiUndoCommand *command) { - rational earliest_point, latest_point; + Rational earliest_point, latest_point; - GetGhostData(&earliest_point, &latest_point); + get_ghost_data(&earliest_point, &latest_point); - parent()->InsertGapsAt(earliest_point, latest_point - earliest_point, + parent()->insert_gaps_at(earliest_point, latest_point - earliest_point, command); } diff --git a/app/widget/timelinewidget/tool/tool.h b/app/widget/timelinewidget/tool/tool.h index 78d916bec..b195e2a13 100644 --- a/app/widget/timelinewidget/tool/tool.h +++ b/app/widget/timelinewidget/tool/tool.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINETOOL_H -#define TIMELINETOOL_H +#ifndef OAK_TIMELINETOOL_H +#define OAK_TIMELINETOOL_H #include @@ -37,33 +37,33 @@ public: TimelineTool(TimelineWidget *parent); virtual ~TimelineTool(); - virtual void MousePress(TimelineViewMouseEvent *) + virtual void mouse_press(TimelineViewMouseEvent *) { } - virtual void MouseMove(TimelineViewMouseEvent *) + virtual void mouse_move(TimelineViewMouseEvent *) { } - virtual void MouseRelease(TimelineViewMouseEvent *) + virtual void mouse_release(TimelineViewMouseEvent *) { } - virtual void MouseDoubleClick(TimelineViewMouseEvent *) + virtual void mouse_double_click(TimelineViewMouseEvent *) { } - virtual void HoverMove(TimelineViewMouseEvent *) + virtual void hover_move(TimelineViewMouseEvent *) { } - virtual void DragEnter(TimelineViewMouseEvent *) + virtual void drag_enter(TimelineViewMouseEvent *) { } - virtual void DragMove(TimelineViewMouseEvent *) + virtual void drag_move(TimelineViewMouseEvent *) { } - virtual void DragLeave(QDragLeaveEvent *) + virtual void drag_leave(QDragLeaveEvent *) { } - virtual void DragDrop(TimelineViewMouseEvent *) + virtual void drag_drop(TimelineViewMouseEvent *) { } @@ -72,11 +72,11 @@ public: Sequence *sequence(); static Timeline::MovementMode - FlipTrimMode(const Timeline::MovementMode &trim_mode); + flip_trim_mode(const Timeline::MovementMode &trim_mode); - static rational SnapMovementToTimebase(const rational &start, - rational movement, - const rational &timebase); + static Rational snap_movement_to_timebase(const Rational &start, + Rational movement, + const Rational &timebase); protected: /** @@ -85,27 +85,27 @@ protected: * Validation is the process of ensuring that whatever movements the user is making are "valid" and "legal". This * function's validation ensures that no Ghost's in point ends up in a negative timecode. */ - rational ValidateTimeMovement(rational movement); + Rational validate_time_movement(Rational movement); /** * @brief Validates Ghosts that are moving vertically (track-based) * * This function's validation ensures that no Ghost's track ends up in a negative (non-existent) track. */ - int ValidateTrackMovement(int movement, + int validate_track_movement(int movement, const QVector &ghosts); - void GetGhostData(rational *earliest_point, rational *latest_point); + void get_ghost_data(Rational *earliest_point, Rational *latest_point); - void InsertGapsAtGhostDestination(MultiUndoCommand *command); + void insert_gaps_at_ghost_destination(MultiUndoCommand *command); - std::vector snap_points_; + std::vector snap_points_; bool dragging_; TimelineCoordinate drag_start_; - static const int kDefaultDistanceFromOutput; + static const int k_default_distance_from_output; private: TimelineWidget *parent_; @@ -113,4 +113,4 @@ private: } -#endif // TIMELINETOOL_H +#endif // OAK_TIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/trackselect.cpp b/app/widget/timelinewidget/tool/trackselect.cpp index a8d25ee8b..e527fd588 100644 --- a/app/widget/timelinewidget/tool/trackselect.cpp +++ b/app/widget/timelinewidget/tool/trackselect.cpp @@ -33,60 +33,60 @@ TrackSelectTool::TrackSelectTool(TimelineWidget *parent) { } -void TrackSelectTool::MousePress(TimelineViewMouseEvent *event) +void TrackSelectTool::mouse_press(TimelineViewMouseEvent *event) { QVector blocks; - bool forward = !(event->GetModifiers() & Qt::ControlModifier); + bool forward = !(event->get_modifiers() & Qt::ControlModifier); - parent()->DeselectAll(); + parent()->deselect_all(); - if (event->GetModifiers() & Qt::ShiftModifier) { + if (event->get_modifiers() & Qt::ShiftModifier) { // Track only - Track *track = parent()->GetTrackFromReference(event->GetTrack()); + Track *track = parent()->get_track_from_reference(event->get_track()); if (track) { - SelectBlocksOnTrack(track, event, &blocks, forward); + select_blocks_on_track(track, event, &blocks, forward); } } else { // All tracks - foreach (Track *track, parent()->sequence()->GetTracks()) { - SelectBlocksOnTrack(track, event, &blocks, forward); + foreach (Track *track, parent()->sequence()->get_tracks()) { + select_blocks_on_track(track, event, &blocks, forward); } } if (!blocks.isEmpty()) { - parent()->SignalSelectedBlocks(blocks); - set_drag_movement_mode(Timeline::kMove); - SetClickedItem(blocks.first()); - drag_start_ = event->GetCoordinates(); + parent()->signal_selected_blocks(blocks); + set_drag_movement_mode(Timeline::k_move); + set_clicked_item(blocks.first()); + drag_start_ = event->get_coordinates(); } else { - set_drag_movement_mode(Timeline::kNone); + set_drag_movement_mode(Timeline::k_none); } } -void TrackSelectTool::SelectBlocksOnTrack(Track *track, +void TrackSelectTool::select_blocks_on_track(Track *track, TimelineViewMouseEvent *event, QVector *blocks, bool forward) { - Block *b = track->NearestBlockBeforeOrAt(event->GetFrame()); + Block *b = track->nearest_block_before_or_at(event->get_frame()); - if (!b && !track->Blocks().isEmpty() && !forward) { + if (!b && !track->blocks().isEmpty() && !forward) { // Fallback to first or last block in track - b = track->Blocks().last(); + b = track->blocks().last(); } while (b) { if (!dynamic_cast(b)) { if (!blocks->contains(b)) { - parent()->AddSelection(b); + parent()->add_selection(b); blocks->append(b); } - if (!(event->GetModifiers() & Qt::AltModifier)) { + if (!(event->get_modifiers() & Qt::AltModifier)) { if (ClipBlock *clip = dynamic_cast(b)) { foreach (Block *link, clip->block_links()) { if (!blocks->contains(link)) { - parent()->AddSelection(link); + parent()->add_selection(link); blocks->append(link); } } diff --git a/app/widget/timelinewidget/tool/trackselect.h b/app/widget/timelinewidget/tool/trackselect.h index 619f04b08..247075ad5 100644 --- a/app/widget/timelinewidget/tool/trackselect.h +++ b/app/widget/timelinewidget/tool/trackselect.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRACKSELECTTOOL_H -#define TRACKSELECTTOOL_H +#ifndef OAK_TRACKSELECTTOOL_H +#define OAK_TRACKSELECTTOOL_H #include "pointer.h" @@ -31,13 +31,13 @@ class TrackSelectTool : public PointerTool { public: TrackSelectTool(TimelineWidget *parent); - virtual void MousePress(TimelineViewMouseEvent *event) override; + virtual void mouse_press(TimelineViewMouseEvent *event) override; private: - void SelectBlocksOnTrack(Track *track, TimelineViewMouseEvent *event, + void select_blocks_on_track(Track *track, TimelineViewMouseEvent *event, QVector *blocks, bool forward); }; } -#endif // TRACKSELECTTOOL_H +#endif // OAK_TRACKSELECTTOOL_H diff --git a/app/widget/timelinewidget/tool/transition.cpp b/app/widget/timelinewidget/tool/transition.cpp index 28b1e38d4..8072d462f 100644 --- a/app/widget/timelinewidget/tool/transition.cpp +++ b/app/widget/timelinewidget/tool/transition.cpp @@ -36,139 +36,139 @@ TransitionTool::TransitionTool(TimelineWidget *parent) { } -void TransitionTool::HoverMove(TimelineViewMouseEvent *event) +void TransitionTool::hover_move(TimelineViewMouseEvent *event) { ClipBlock *primary = nullptr; ClipBlock *secondary = nullptr; - Timeline::MovementMode trim_mode = Timeline::kNone; - rational transition_start_point; + Timeline::MovementMode trim_mode = Timeline::k_none; + Rational transition_start_point; - GetBlocksAtCoord(event->GetCoordinates(), &primary, &secondary, &trim_mode, + get_blocks_at_coord(event->get_coordinates(), &primary, &secondary, &trim_mode, &transition_start_point); - if (trim_mode == Timeline::kTrimIn) { + if (trim_mode == Timeline::k_trim_in) { std::swap(primary, secondary); } - parent()->SetViewTransitionOverlay(primary, secondary); + parent()->set_view_transition_overlay(primary, secondary); } -void TransitionTool::MousePress(TimelineViewMouseEvent *event) +void TransitionTool::mouse_press(TimelineViewMouseEvent *event) { ClipBlock *primary, *secondary; Timeline::MovementMode trim_mode; - rational transition_start_point; - if (!GetBlocksAtCoord(event->GetCoordinates(), &primary, &secondary, + Rational transition_start_point; + if (!get_blocks_at_coord(event->get_coordinates(), &primary, &secondary, &trim_mode, &transition_start_point)) { return; } // Create ghost ghost_ = new TimelineViewGhostItem(); - ghost_->SetTrack(event->GetTrack()); - ghost_->SetIn(transition_start_point); - ghost_->SetOut(transition_start_point); - ghost_->SetMode(trim_mode); - ghost_->SetData(TimelineViewGhostItem::kAttachedBlock, - QtUtils::PtrToValue(primary)); + ghost_->set_track(event->get_track()); + ghost_->set_in(transition_start_point); + ghost_->set_out(transition_start_point); + ghost_->set_mode(trim_mode); + ghost_->set_data(TimelineViewGhostItem::k_attached_block, + QtUtils::ptr_to_value(primary)); dual_transition_ = (secondary); if (secondary) - ghost_->SetData(TimelineViewGhostItem::kReferenceBlock, - QtUtils::PtrToValue(secondary)); + ghost_->set_data(TimelineViewGhostItem::k_reference_block, + QtUtils::ptr_to_value(secondary)); - parent()->AddGhost(ghost_); + parent()->add_ghost(ghost_); snap_points_.push_back(transition_start_point); // Set the drag start point - drag_start_point_ = event->GetFrame(); + drag_start_point_ = event->get_frame(); } -void TransitionTool::MouseMove(TimelineViewMouseEvent *event) +void TransitionTool::mouse_move(TimelineViewMouseEvent *event) { if (!ghost_) { return; } - MouseMoveInternal(event->GetFrame(), dual_transition_); + mouse_move_internal(event->get_frame(), dual_transition_); } -void TransitionTool::MouseRelease(TimelineViewMouseEvent *event) +void TransitionTool::mouse_release(TimelineViewMouseEvent *event) { - const Track::Reference &track = ghost_->GetTrack(); + const Track::Reference &track = ghost_->get_track(); if (ghost_) { - if (!ghost_->GetAdjustedLength().isNull()) { + if (!ghost_->get_adjusted_length().isNull()) { TransitionBlock *transition; - if (Core::instance()->GetSelectedTransition().isEmpty()) { + if (Core::instance()->get_selected_transition().isEmpty()) { // Fallback if the user hasn't selected one yet transition = new CrossDissolveTransition(); } else { transition = - static_cast(NodeFactory::CreateFromID( - Core::instance()->GetSelectedTransition())); + static_cast(NodeFactory::create_from_id( + Core::instance()->get_selected_transition())); } // Set transition length - rational len = ghost_->GetAdjustedLength(); + Rational len = ghost_->get_adjusted_length(); transition->set_length_and_media_out(len); MultiUndoCommand *command = new MultiUndoCommand(); // Place transition in place command->add_child(new NodeAddCommand( - parent()->GetConnectedNode()->parent(), transition)); + parent()->get_connected_node()->parent(), transition)); command->add_child(new NodeSetPositionCommand( transition, transition, QPointF(0, 0))); command->add_child(new TrackPlaceBlockCommand( sequence()->track_list(track.type()), track.index(), transition, - ghost_->GetAdjustedIn())); + ghost_->get_adjusted_in())); if (dual_transition_) { // Block mouse is hovering over - Block *active_block = QtUtils::ValueToPtr( - ghost_->GetData(TimelineViewGhostItem::kAttachedBlock)); + Block *active_block = QtUtils::value_to_ptr( + ghost_->get_data(TimelineViewGhostItem::k_attached_block)); // Block mouse is next to - Block *friend_block = QtUtils::ValueToPtr( - ghost_->GetData(TimelineViewGhostItem::kReferenceBlock)); + Block *friend_block = QtUtils::value_to_ptr( + ghost_->get_data(TimelineViewGhostItem::k_reference_block)); // Use ghost mode to determine which block is which - Block *out_block = (ghost_->GetMode() == Timeline::kTrimIn) ? + Block *out_block = (ghost_->get_mode() == Timeline::k_trim_in) ? friend_block : active_block; - Block *in_block = (ghost_->GetMode() == Timeline::kTrimIn) ? + Block *in_block = (ghost_->get_mode() == Timeline::k_trim_in) ? active_block : friend_block; // Connect block to transition command->add_child(new NodeEdgeAddCommand( out_block, - NodeInput(transition, TransitionBlock::kOutBlockInput))); + NodeInput(transition, TransitionBlock::k_out_block_input))); command->add_child(new NodeEdgeAddCommand( in_block, - NodeInput(transition, TransitionBlock::kInBlockInput))); + NodeInput(transition, TransitionBlock::k_in_block_input))); command->add_child(new NodeSetPositionCommand( out_block, transition, QPointF(-1, -0.5))); command->add_child(new NodeSetPositionCommand( in_block, transition, QPointF(-1, 0.5))); } else { - Block *block_to_transition = QtUtils::ValueToPtr( - ghost_->GetData(TimelineViewGhostItem::kAttachedBlock)); + Block *block_to_transition = QtUtils::value_to_ptr( + ghost_->get_data(TimelineViewGhostItem::k_attached_block)); QString transition_input_to_connect; - if (ghost_->GetMode() == Timeline::kTrimIn) { + if (ghost_->get_mode() == Timeline::k_trim_in) { transition_input_to_connect = - TransitionBlock::kInBlockInput; + TransitionBlock::k_in_block_input; } else { transition_input_to_connect = - TransitionBlock::kOutBlockInput; + TransitionBlock::k_out_block_input; } // Connect block to transition @@ -184,38 +184,38 @@ void TransitionTool::MouseRelease(TimelineViewMouseEvent *event) command, qApp->translate("TransitionTool", "Created Transition")); - parent()->SetViewTransitionOverlay(nullptr, nullptr); + parent()->set_view_transition_overlay(nullptr, nullptr); } - parent()->ClearGhosts(); + parent()->clear_ghosts(); snap_points_.clear(); ghost_ = nullptr; } } -bool TransitionTool::GetBlocksAtCoord(const TimelineCoordinate &coord, +bool TransitionTool::get_blocks_at_coord(const TimelineCoordinate &coord, ClipBlock **primary, ClipBlock **secondary, Timeline::MovementMode *ptrim_mode, - rational *start_point) + Rational *start_point) { - const Track::Reference &track = coord.GetTrack(); - Track *t = parent()->GetTrackFromReference(track); - rational cursor_frame = coord.GetFrame(); + const Track::Reference &track = coord.get_track(); + Track *t = parent()->get_track_from_reference(track); + Rational cursor_frame = coord.get_frame(); - if (!t || t->IsLocked()) { + if (!t || t->is_locked()) { return false; } - Block *block_at_time = t->NearestBlockBeforeOrAt(coord.GetFrame()); + Block *block_at_time = t->nearest_block_before_or_at(coord.get_frame()); if (!dynamic_cast(block_at_time)) { return false; } // Determine which side of the clip the transition belongs to - rational transition_start_point; + Rational transition_start_point; Timeline::MovementMode trim_mode; - rational tenth_point = block_at_time->length() / 10; + Rational tenth_point = block_at_time->length() / 10; Block *other_block = nullptr; if (cursor_frame < (block_at_time->in() + block_at_time->length() / 2)) { if (static_cast(block_at_time)->in_transition()) { @@ -230,7 +230,7 @@ bool TransitionTool::GetBlocksAtCoord(const TimelineCoordinate &coord, } transition_start_point = block_at_time->in(); - trim_mode = Timeline::kTrimIn; + trim_mode = Timeline::k_trim_in; if (cursor_frame < (block_at_time->in() + tenth_point) && adjacent) { other_block = adjacent; @@ -247,7 +247,7 @@ bool TransitionTool::GetBlocksAtCoord(const TimelineCoordinate &coord, } transition_start_point = block_at_time->out(); - trim_mode = Timeline::kTrimOut; + trim_mode = Timeline::k_trim_out; if (cursor_frame > block_at_time->out() - tenth_point && adjacent) { other_block = block_at_time->next(); diff --git a/app/widget/timelinewidget/tool/transition.h b/app/widget/timelinewidget/tool/transition.h index 3d21aef69..721481c9b 100644 --- a/app/widget/timelinewidget/tool/transition.h +++ b/app/widget/timelinewidget/tool/transition.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRANSITIONTIMELINETOOL_H -#define TRANSITIONTIMELINETOOL_H +#ifndef OAK_TRANSITIONTIMELINETOOL_H +#define OAK_TRANSITIONTIMELINETOOL_H #include "add.h" @@ -31,21 +31,21 @@ class TransitionTool : public AddTool { public: TransitionTool(TimelineWidget *parent); - virtual void HoverMove(TimelineViewMouseEvent *event) override; + virtual void hover_move(TimelineViewMouseEvent *event) override; - virtual void MousePress(TimelineViewMouseEvent *event) override; - virtual void MouseMove(TimelineViewMouseEvent *event) override; - virtual void MouseRelease(TimelineViewMouseEvent *event) override; + virtual void mouse_press(TimelineViewMouseEvent *event) override; + virtual void mouse_move(TimelineViewMouseEvent *event) override; + virtual void mouse_release(TimelineViewMouseEvent *event) override; private: - bool GetBlocksAtCoord(const TimelineCoordinate &coord, ClipBlock **primary, + bool get_blocks_at_coord(const TimelineCoordinate &coord, ClipBlock **primary, ClipBlock **secondary, Timeline::MovementMode *trim_mode, - rational *start_point); + Rational *start_point); bool dual_transition_; }; } -#endif // TRANSITIONTIMELINETOOL_H +#endif // OAK_TRANSITIONTIMELINETOOL_H diff --git a/app/widget/timelinewidget/tool/zoom.cpp b/app/widget/timelinewidget/tool/zoom.cpp index 0d8580ba6..b016a58e3 100644 --- a/app/widget/timelinewidget/tool/zoom.cpp +++ b/app/widget/timelinewidget/tool/zoom.cpp @@ -30,37 +30,37 @@ ZoomTool::ZoomTool(TimelineWidget *parent) { } -void ZoomTool::MousePress(TimelineViewMouseEvent *event) +void ZoomTool::mouse_press(TimelineViewMouseEvent *event) { Q_UNUSED(event) drag_global_start_ = QCursor::pos(); } -void ZoomTool::MouseMove(TimelineViewMouseEvent *event) +void ZoomTool::mouse_move(TimelineViewMouseEvent *event) { Q_UNUSED(event) if (!dragging_) { - parent()->StartRubberBandSelect(drag_global_start_); + parent()->start_rubber_band_select(drag_global_start_); dragging_ = true; } - parent()->MoveRubberBandSelect(false, false); + parent()->move_rubber_band_select(false, false); } -void ZoomTool::MouseRelease(TimelineViewMouseEvent *event) +void ZoomTool::mouse_release(TimelineViewMouseEvent *event) { int scroll_value; if (dragging_) { // Zoom into the rubberband selection - QRect screen_coords = parent()->GetRubberBandGeometry(); + QRect screen_coords = parent()->get_rubber_band_geometry(); - parent()->EndRubberBandSelect(); + parent()->end_rubber_band_select(); - TimelineView *reference_view = parent()->GetFirstTimelineView(); + TimelineView *reference_view = parent()->get_first_timeline_view(); QPointF scene_topleft = reference_view->mapToScene( reference_view->mapFrom(parent(), screen_coords.topLeft())); QPointF scene_bottomright = reference_view->mapToScene( @@ -70,24 +70,24 @@ void ZoomTool::MouseRelease(TimelineViewMouseEvent *event) double scene_right = scene_bottomright.x(); // Normalize scale to 1.0 scale - double scene_width = (scene_right - scene_left) / parent()->GetScale(); + double scene_width = (scene_right - scene_left) / parent()->get_scale(); double new_scale = - qMin(parent()->GetFirstTimelineView()->GetMaximumScale(), + qMin(parent()->get_first_timeline_view()->get_maximum_scale(), static_cast(reference_view->viewport()->width()) / scene_width); parent()->SetScale(new_scale); scroll_value = - qMax(0, qRound(scene_left / parent()->GetScale() * new_scale)); + qMax(0, qRound(scene_left / parent()->get_scale() * new_scale)); dragging_ = false; } else { // Simple zoom in/out at the cursor position - double scale = parent()->GetScale(); + double scale = parent()->get_scale(); - if (event->GetModifiers() & Qt::AltModifier) { + if (event->get_modifiers() & Qt::AltModifier) { // Zoom out if the user clicks while holding Alt scale *= 0.5; } else { @@ -98,15 +98,15 @@ void ZoomTool::MouseRelease(TimelineViewMouseEvent *event) parent()->SetScale(scale); // Adjust scroll location for new scale - double frame_x = event->GetFrame().toDouble() * scale; + double frame_x = event->get_frame().to_double() * scale; scroll_value = qMax( 0, qRound(frame_x - - parent()->GetFirstTimelineView()->viewport()->width() / 2)); + parent()->get_first_timeline_view()->viewport()->width() / 2)); } - parent()->QueueScroll(scroll_value); + parent()->queue_scroll(scroll_value); } } diff --git a/app/widget/timelinewidget/tool/zoom.h b/app/widget/timelinewidget/tool/zoom.h index 4f1ac7b24..8c74ade20 100644 --- a/app/widget/timelinewidget/tool/zoom.h +++ b/app/widget/timelinewidget/tool/zoom.h @@ -19,8 +19,8 @@ ***/ -#ifndef ZOOMTIMELINETOOL_H -#define ZOOMTIMELINETOOL_H +#ifndef OAK_ZOOMTIMELINETOOL_H +#define OAK_ZOOMTIMELINETOOL_H #include "tool.h" @@ -31,9 +31,9 @@ class ZoomTool : public TimelineTool { public: ZoomTool(TimelineWidget *parent); - virtual void MousePress(TimelineViewMouseEvent *event) override; - virtual void MouseMove(TimelineViewMouseEvent *event) override; - virtual void MouseRelease(TimelineViewMouseEvent *event) override; + virtual void mouse_press(TimelineViewMouseEvent *event) override; + virtual void mouse_move(TimelineViewMouseEvent *event) override; + virtual void mouse_release(TimelineViewMouseEvent *event) override; private: QPoint drag_global_start_; @@ -41,4 +41,4 @@ private: } -#endif // ZOOMTIMELINETOOL_H +#endif // OAK_ZOOMTIMELINETOOL_H diff --git a/app/widget/timelinewidget/trackview/trackview.cpp b/app/widget/timelinewidget/trackview/trackview.cpp index 644308c98..7d96b939b 100644 --- a/app/widget/timelinewidget/trackview/trackview.cpp +++ b/app/widget/timelinewidget/trackview/trackview.cpp @@ -51,7 +51,7 @@ TrackView::TrackView(Qt::Alignment vertical_alignment, QWidget *parent) layout->addStretch(); connect(verticalScrollBar(), &QScrollBar::rangeChanged, this, - &TrackView::ScrollbarRangeChanged); + &TrackView::scrollbar_range_changed); last_scrollbar_max_ = verticalScrollBar()->maximum(); } @@ -63,51 +63,51 @@ TrackView::TrackView(Qt::Alignment vertical_alignment, QWidget *parent) layout->addStretch(); } - connect(splitter_, &TrackViewSplitter::TrackHeightChanged, this, - &TrackView::TrackHeightChanged); + connect(splitter_, &TrackViewSplitter::track_height_changed, this, + &TrackView::track_height_changed); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } -void TrackView::ConnectTrackList(TrackList *list) +void TrackView::connect_track_list(TrackList *list) { if (list_ != nullptr) { // Remove tracks - for (int i = 0; i < list_->GetTrackCount(); i++) { - splitter_->Remove(0); + for (int i = 0; i < list_->get_track_count(); i++) { + splitter_->remove(0); } - disconnect(list_, &TrackList::TrackAdded, this, - &TrackView::InsertTrack); - disconnect(list_, &TrackList::TrackRemoved, this, - &TrackView::RemoveTrack); + disconnect(list_, &TrackList::track_added, this, + &TrackView::insert_track); + disconnect(list_, &TrackList::track_removed, this, + &TrackView::remove_track); } list_ = list; if (list_ != nullptr) { - foreach (Track *track, list_->GetTracks()) { - InsertTrack(track); + foreach (Track *track, list_->get_tracks()) { + insert_track(track); } - connect(list_, &TrackList::TrackAdded, this, &TrackView::InsertTrack); - connect(list_, &TrackList::TrackRemoved, this, &TrackView::RemoveTrack); + connect(list_, &TrackList::track_added, this, &TrackView::insert_track); + connect(list_, &TrackList::track_removed, this, &TrackView::remove_track); } } -void TrackView::DisconnectTrackList() +void TrackView::disconnect_track_list() { - ConnectTrackList(nullptr); + connect_track_list(nullptr); } void TrackView::resizeEvent(QResizeEvent *e) { QScrollArea::resizeEvent(e); - splitter_->SetSpacerHeight(height() / 2); + splitter_->set_spacer_height(height() / 2); } -void TrackView::ScrollbarRangeChanged(int, int max) +void TrackView::scrollbar_range_changed(int, int max) { if (max != last_scrollbar_max_) { int ba_val = last_scrollbar_max_ - verticalScrollBar()->value(); @@ -120,24 +120,24 @@ void TrackView::ScrollbarRangeChanged(int, int max) } } -void TrackView::TrackHeightChanged(int index, int height) +void TrackView::track_height_changed(int index, int height) { - list_->GetTrackAt(index)->SetTrackHeightInPixels(height); + list_->get_track_at(index)->set_track_height_in_pixels(height); } -void TrackView::InsertTrack(Track *track) +void TrackView::insert_track(Track *track) { TrackViewItem *tvi = new TrackViewItem(track); - connect(tvi, &TrackViewItem::AboutToDeleteTrack, this, - &TrackView::AboutToDeleteTrack); + connect(tvi, &TrackViewItem::about_to_delete_track, this, + &TrackView::about_to_delete_track); - splitter_->Insert(track->Index(), track->GetTrackHeightInPixels(), tvi); + splitter_->insert(track->index(), track->get_track_height_in_pixels(), tvi); } -void TrackView::RemoveTrack(Track *track) +void TrackView::remove_track(Track *track) { - splitter_->Remove(track->Index()); + splitter_->remove(track->index()); } } diff --git a/app/widget/timelinewidget/trackview/trackview.h b/app/widget/timelinewidget/trackview/trackview.h index d4610238a..88fa4e19f 100644 --- a/app/widget/timelinewidget/trackview/trackview.h +++ b/app/widget/timelinewidget/trackview/trackview.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRACKVIEW_H -#define TRACKVIEW_H +#ifndef OAK_TRACKVIEW_H +#define OAK_TRACKVIEW_H #include #include @@ -38,11 +38,11 @@ public: TrackView(Qt::Alignment vertical_alignment = Qt::AlignTop, QWidget *parent = nullptr); - void ConnectTrackList(TrackList *list); - void DisconnectTrackList(); + void connect_track_list(TrackList *list); + void disconnect_track_list(); signals: - void AboutToDeleteTrack(Track *track); + void about_to_delete_track(Track *track); protected: virtual void resizeEvent(QResizeEvent *e) override; @@ -57,15 +57,15 @@ private: int last_scrollbar_max_; private slots: - void ScrollbarRangeChanged(int min, int max); + void scrollbar_range_changed(int min, int max); - void TrackHeightChanged(int index, int height); + void track_height_changed(int index, int height); - void InsertTrack(Track *track); + void insert_track(Track *track); - void RemoveTrack(Track *track); + void remove_track(Track *track); }; } -#endif // TRACKVIEW_H +#endif // OAK_TRACKVIEW_H diff --git a/app/widget/timelinewidget/trackview/trackviewitem.cpp b/app/widget/timelinewidget/trackview/trackviewitem.cpp index f318b753f..d1cf2943a 100644 --- a/app/widget/timelinewidget/trackview/trackviewitem.cpp +++ b/app/widget/timelinewidget/trackview/trackviewitem.cpp @@ -48,49 +48,49 @@ TrackViewItem::TrackViewItem(Track *track, QWidget *parent) layout->addWidget(stack_); label_ = new ClickableLabel(); - connect(label_, &ClickableLabel::MouseDoubleClicked, this, - &TrackViewItem::LabelClicked); - connect(track_, &Track::LabelChanged, this, &TrackViewItem::UpdateLabel); - connect(track_, &Track::IndexChanged, this, &TrackViewItem::UpdateLabel); - UpdateLabel(); + connect(label_, &ClickableLabel::mouse_double_clicked, this, + &TrackViewItem::label_clicked); + connect(track_, &Track::label_changed, this, &TrackViewItem::update_label); + connect(track_, &Track::index_changed, this, &TrackViewItem::update_label); + update_label(); stack_->addWidget(label_); line_edit_ = new FocusableLineEdit(); - connect(line_edit_, &FocusableLineEdit::Confirmed, this, - &TrackViewItem::LineEditConfirmed); - connect(line_edit_, &FocusableLineEdit::Cancelled, this, - &TrackViewItem::LineEditCancelled); + connect(line_edit_, &FocusableLineEdit::confirmed, this, + &TrackViewItem::line_edit_confirmed); + connect(line_edit_, &FocusableLineEdit::cancelled, this, + &TrackViewItem::line_edit_cancelled); stack_->addWidget(line_edit_); - mute_button_ = CreateMSLButton(Qt::red); - mute_button_->setChecked(track->IsMuted()); - UpdateMuteButton(track->IsMuted()); - connect(mute_button_, &QPushButton::toggled, track_, &Track::SetMuted); + mute_button_ = create_msl_button(Qt::red); + mute_button_->setChecked(track->is_muted()); + update_mute_button(track->is_muted()); + connect(mute_button_, &QPushButton::toggled, track_, &Track::set_muted); connect(mute_button_, &QPushButton::toggled, this, - &TrackViewItem::UpdateMuteButton); + &TrackViewItem::update_mute_button); layout->addWidget(mute_button_); /*solo_button_ = CreateMSLButton(tr("S"), Qt::yellow); layout->addWidget(solo_button_);*/ - lock_button_ = CreateMSLButton(Qt::gray); - lock_button_->setChecked(track->IsLocked()); - UpdateLockButton(track->IsLocked()); - connect(lock_button_, &QPushButton::toggled, track_, &Track::SetLocked); + lock_button_ = create_msl_button(Qt::gray); + lock_button_->setChecked(track->is_locked()); + update_lock_button(track->is_locked()); + connect(lock_button_, &QPushButton::toggled, track_, &Track::set_locked); connect(lock_button_, &QPushButton::toggled, this, - &TrackViewItem::UpdateLockButton); + &TrackViewItem::update_lock_button); layout->addWidget(lock_button_); setMinimumHeight(mute_button_->height()); setContextMenuPolicy(Qt::CustomContextMenu); - connect(track, &Track::MutedChanged, mute_button_, + connect(track, &Track::muted_changed, mute_button_, &QPushButton::setChecked); connect(this, &QWidget::customContextMenuRequested, this, - &TrackViewItem::ShowContextMenu); + &TrackViewItem::show_context_menu); } -QPushButton *TrackViewItem::CreateMSLButton(const QColor &checked_color) const +QPushButton *TrackViewItem::create_msl_button(const QColor &checked_color) const { QPushButton *button = new QPushButton(); button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); @@ -106,26 +106,26 @@ QPushButton *TrackViewItem::CreateMSLButton(const QColor &checked_color) const return button; } -void TrackViewItem::LabelClicked() +void TrackViewItem::label_clicked() { stack_->setCurrentWidget(line_edit_); line_edit_->setFocus(); line_edit_->selectAll(); } -void TrackViewItem::LineEditConfirmed() +void TrackViewItem::line_edit_confirmed() { line_edit_->blockSignals(true); - track_->SetLabel(line_edit_->text()); - UpdateLabel(); + track_->set_label(line_edit_->text()); + update_label(); stack_->setCurrentWidget(label_); line_edit_->blockSignals(false); } -void TrackViewItem::LineEditCancelled() +void TrackViewItem::line_edit_cancelled() { line_edit_->blockSignals(true); @@ -134,46 +134,46 @@ void TrackViewItem::LineEditCancelled() line_edit_->blockSignals(false); } -void TrackViewItem::UpdateLabel() +void TrackViewItem::update_label() { - label_->setText(track_->GetLabelOrName()); + label_->setText(track_->get_label_or_name()); } -void TrackViewItem::ShowContextMenu(const QPoint &p) +void TrackViewItem::show_context_menu(const QPoint &p) { Menu m(this); QAction *delete_action = m.addAction(tr("&Delete")); connect(delete_action, &QAction::triggered, this, - &TrackViewItem::DeleteTrack, Qt::QueuedConnection); + &TrackViewItem::delete_track, Qt::QueuedConnection); m.addSeparator(); QAction *delete_unused_action = m.addAction(tr("Delete All &Empty")); connect(delete_unused_action, &QAction::triggered, this, - &TrackViewItem::DeleteAllEmptyTracks, Qt::QueuedConnection); + &TrackViewItem::delete_all_empty_tracks, Qt::QueuedConnection); m.exec(mapToGlobal(p)); } -void TrackViewItem::DeleteTrack() +void TrackViewItem::delete_track() { - emit AboutToDeleteTrack(track_); + emit about_to_delete_track(track_); Core::instance()->undo_stack()->push( new TimelineRemoveTrackCommand(track_), - tr("Deleted Track \"%1\"").arg(track_->GetLabelOrName())); + tr("Deleted Track \"%1\"").arg(track_->get_label_or_name())); } -void TrackViewItem::DeleteAllEmptyTracks() +void TrackViewItem::delete_all_empty_tracks() { Sequence *sequence = track_->sequence(); QVector tracks_to_remove; QStringList track_names_to_remove; - foreach (Track *t, sequence->GetTracks()) { - if (t->Blocks().isEmpty()) { + foreach (Track *t, sequence->get_tracks()) { + if (t->blocks().isEmpty()) { tracks_to_remove.append(t); - track_names_to_remove.append(t->GetLabelOrName()); + track_names_to_remove.append(t->get_label_or_name()); } } @@ -196,14 +196,14 @@ void TrackViewItem::DeleteAllEmptyTracks() } } -void TrackViewItem::UpdateMuteButton(bool e) +void TrackViewItem::update_mute_button(bool e) { - mute_button_->setIcon(e ? icon::EyeClosed : icon::EyeOpened); + mute_button_->setIcon(e ? icon::eye_closed : icon::eye_opened); } -void TrackViewItem::UpdateLockButton(bool e) +void TrackViewItem::update_lock_button(bool e) { - lock_button_->setIcon(e ? icon::LockClosed : icon::LockOpened); + lock_button_->setIcon(e ? icon::lock_closed : icon::lock_opened); } } diff --git a/app/widget/timelinewidget/trackview/trackviewitem.h b/app/widget/timelinewidget/trackview/trackviewitem.h index a63929dbb..74cbe787c 100644 --- a/app/widget/timelinewidget/trackview/trackviewitem.h +++ b/app/widget/timelinewidget/trackview/trackviewitem.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRACKVIEWITEM_H -#define TRACKVIEWITEM_H +#ifndef OAK_TRACKVIEWITEM_H +#define OAK_TRACKVIEWITEM_H #include #include @@ -40,10 +40,10 @@ public: TrackViewItem(Track *track, QWidget *parent = nullptr); signals: - void AboutToDeleteTrack(Track *track); + void about_to_delete_track(Track *track); private: - QPushButton *CreateMSLButton(const QColor &checked_color) const; + QPushButton *create_msl_button(const QColor &checked_color) const; QStackedWidget *stack_; @@ -57,25 +57,25 @@ private: Track *track_; private slots: - void LabelClicked(); + void label_clicked(); - void LineEditConfirmed(); + void line_edit_confirmed(); - void LineEditCancelled(); + void line_edit_cancelled(); - void UpdateLabel(); + void update_label(); - void ShowContextMenu(const QPoint &p); + void show_context_menu(const QPoint &p); - void DeleteTrack(); + void delete_track(); - void DeleteAllEmptyTracks(); + void delete_all_empty_tracks(); - void UpdateMuteButton(bool e); + void update_mute_button(bool e); - void UpdateLockButton(bool e); + void update_lock_button(bool e); }; } -#endif // TRACKVIEWITEM_H +#endif // OAK_TRACKVIEWITEM_H diff --git a/app/widget/timelinewidget/trackview/trackviewsplitter.cpp b/app/widget/timelinewidget/trackview/trackviewsplitter.cpp index 1c25b97c3..deb7de025 100644 --- a/app/widget/timelinewidget/trackview/trackviewsplitter.cpp +++ b/app/widget/timelinewidget/trackview/trackviewsplitter.cpp @@ -46,7 +46,7 @@ TrackViewSplitter::TrackViewSplitter(Qt::Alignment vertical_alignment, setFixedHeight(initial_height); } -void TrackViewSplitter::HandleReceiver(TrackViewSplitterHandle *h, int diff) +void TrackViewSplitter::handle_receiver(TrackViewSplitterHandle *h, int diff) { int ele_id = -1; @@ -72,18 +72,18 @@ void TrackViewSplitter::HandleReceiver(TrackViewSplitterHandle *h, int diff) int new_ele_sz = old_ele_sz + diff; // Limit by track minimum height - new_ele_sz = qMax(new_ele_sz, Track::GetMinimumTrackHeightInPixels()); + new_ele_sz = qMax(new_ele_sz, Track::get_minimum_track_height_in_pixels()); if (alignment_ == Qt::AlignBottom) { ele_id = count() - ele_id - 1; } - SetTrackHeight(ele_id, new_ele_sz); + set_track_height(ele_id, new_ele_sz); - emit TrackHeightChanged(ele_id, new_ele_sz); + emit track_height_changed(ele_id, new_ele_sz); } -void TrackViewSplitter::SetTrackHeight(int index, int h) +void TrackViewSplitter::set_track_height(int index, int h) { QList element_sizes = sizes(); @@ -103,7 +103,7 @@ void TrackViewSplitter::SetTrackHeight(int index, int h) setFixedHeight(height() + diff); } -void TrackViewSplitter::SetHeightWithSizes(QList sizes) +void TrackViewSplitter::set_height_with_sizes(QList sizes) { int start_height = 0; @@ -125,7 +125,7 @@ void TrackViewSplitter::SetHeightWithSizes(QList sizes) setSizes(sizes); } -void TrackViewSplitter::Insert(int index, int height, QWidget *item) +void TrackViewSplitter::insert(int index, int height, QWidget *item) { QList sz = sizes(); @@ -136,10 +136,10 @@ void TrackViewSplitter::Insert(int index, int height, QWidget *item) sz.insert(index, height); insertWidget(index, item); - SetHeightWithSizes(sz); + set_height_with_sizes(sz); } -void TrackViewSplitter::Remove(int index) +void TrackViewSplitter::remove(int index) { QList sz = sizes(); @@ -150,13 +150,13 @@ void TrackViewSplitter::Remove(int index) sz.removeAt(index); delete widget(index); - SetHeightWithSizes(sz); + set_height_with_sizes(sz); } -void TrackViewSplitter::SetSpacerHeight(int height) +void TrackViewSplitter::set_spacer_height(int height) { spacer_height_ = height; - SetHeightWithSizes(sizes()); + set_height_with_sizes(sizes()); } QSplitterHandle *TrackViewSplitter::createHandle() @@ -178,7 +178,7 @@ void TrackViewSplitterHandle::mousePressEvent(QMouseEvent *) void TrackViewSplitterHandle::mouseMoveEvent(QMouseEvent *) { if (dragging_) { - static_cast(parent())->HandleReceiver( + static_cast(parent())->handle_receiver( this, QCursor::pos().y() - drag_y_); } diff --git a/app/widget/timelinewidget/trackview/trackviewsplitter.h b/app/widget/timelinewidget/trackview/trackviewsplitter.h index 6ab70fe77..7c7e0e7cf 100644 --- a/app/widget/timelinewidget/trackview/trackviewsplitter.h +++ b/app/widget/timelinewidget/trackview/trackviewsplitter.h @@ -19,8 +19,8 @@ ***/ -#ifndef TRACKVIEWSPLITTER_H -#define TRACKVIEWSPLITTER_H +#ifndef OAK_TRACKVIEWSPLITTER_H +#define OAK_TRACKVIEWSPLITTER_H #include @@ -53,20 +53,20 @@ public: TrackViewSplitter(Qt::Alignment vertical_alignment, QWidget *parent = nullptr); - void HandleReceiver(TrackViewSplitterHandle *h, int diff); + void handle_receiver(TrackViewSplitterHandle *h, int diff); - void SetHeightWithSizes(QList sizes); + void set_height_with_sizes(QList sizes); - void Insert(int index, int height, QWidget *item); - void Remove(int index); + void insert(int index, int height, QWidget *item); + void remove(int index); - void SetSpacerHeight(int height); + void set_spacer_height(int height); public slots: - void SetTrackHeight(int index, int h); + void set_track_height(int index, int h); signals: - void TrackHeightChanged(int index, int height); + void track_height_changed(int index, int height); protected: virtual QSplitterHandle *createHandle() override; @@ -79,4 +79,4 @@ private: } -#endif // TRACKVIEWSPLITTER_H +#endif // OAK_TRACKVIEWSPLITTER_H diff --git a/app/widget/timelinewidget/view/timelineview.cpp b/app/widget/timelinewidget/view/timelineview.cpp index ee573c08c..76f181234 100644 --- a/app/widget/timelinewidget/view/timelineview.cpp +++ b/app/widget/timelinewidget/view/timelineview.cpp @@ -59,7 +59,7 @@ TimelineView::TimelineView(Qt::Alignment vertical_alignment, QWidget *parent) setContextMenuPolicy(Qt::CustomContextMenu); viewport()->setMouseTracking(true); - SetIsTimelineAxes(true); + set_is_timeline_axes(true); } void TimelineView::mousePressEvent(QMouseEvent *event) @@ -69,89 +69,89 @@ void TimelineView::mousePressEvent(QMouseEvent *event) for (auto it = clip_marker_rects_.cbegin(); it != clip_marker_rects_.cend(); it++) { if (it.value().contains(scene_pos)) { - GetViewerNode()->SetPlayhead(it.key()->time().in()); + get_viewer_node()->set_playhead(it.key()->time().in()); break; } } TimelineViewMouseEvent timeline_event = CreateMouseEvent(event); - if (HandPress(event) || - (!GetItemAtScenePos(timeline_event.GetFrame(), - timeline_event.GetTrack().index()) && - Core::instance()->tool() != Tool::kAdd && PlayheadPress(event))) { + if (hand_press(event) || + (!get_item_at_scene_pos(timeline_event.get_frame(), + timeline_event.get_track().index()) && + Core::instance()->tool() != Tool::k_add && playhead_press(event))) { // Let the parent handle this return; } - if (dragMode() != GetDefaultDragMode()) { + if (dragMode() != get_default_drag_mode()) { // Use default behavior when hand dragging for instance super::mousePressEvent(event); return; } - emit MousePressed(&timeline_event); + emit mouse_pressed(&timeline_event); } void TimelineView::mouseMoveEvent(QMouseEvent *event) { TimelineViewMouseEvent timeline_event = CreateMouseEvent(event); - if (HandMove(event) || PlayheadMove(event)) { + if (hand_move(event) || playhead_move(event)) { // Let the parent handle this return; } - if (dragMode() != GetDefaultDragMode()) { + if (dragMode() != get_default_drag_mode()) { super::mouseMoveEvent(event); return; } if (event->buttons() == Qt::NoButton) { - Block *b = GetItemAtScenePos(timeline_event.GetFrame(), - timeline_event.GetTrack().index()); + Block *b = get_item_at_scene_pos(timeline_event.get_frame(), + timeline_event.get_track().index()); if (b) { setToolTip( tr("In: %1\nOut: %2\nDuration: %3") .arg(QString::fromStdString(Timecode::time_to_timecode( b->in(), timebase(), - Core::instance()->GetTimecodeDisplay())), + Core::instance()->get_timecode_display())), QString::fromStdString(Timecode::time_to_timecode( b->out(), timebase(), - Core::instance()->GetTimecodeDisplay())), + Core::instance()->get_timecode_display())), QString::fromStdString(Timecode::time_to_timecode( b->length(), timebase(), - Core::instance()->GetTimecodeDisplay())))); + Core::instance()->get_timecode_display())))); } else { setToolTip(QString()); } } - emit MouseMoved(&timeline_event); + emit mouse_moved(&timeline_event); } void TimelineView::mouseReleaseEvent(QMouseEvent *event) { - if (HandRelease(event) || PlayheadRelease(event)) { + if (hand_release(event) || playhead_release(event)) { // Let the parent handle this return; } - if (dragMode() != GetDefaultDragMode()) { + if (dragMode() != get_default_drag_mode()) { super::mouseReleaseEvent(event); return; } TimelineViewMouseEvent timeline_event = CreateMouseEvent(event); - emit MouseReleased(&timeline_event); + emit mouse_released(&timeline_event); } void TimelineView::mouseDoubleClickEvent(QMouseEvent *event) { TimelineViewMouseEvent timeline_event = CreateMouseEvent(event); - emit MouseDoubleClicked(&timeline_event); + emit mouse_double_clicked(&timeline_event); } void TimelineView::dragEnterEvent(QDragEnterEvent *event) @@ -159,10 +159,10 @@ void TimelineView::dragEnterEvent(QDragEnterEvent *event) TimelineViewMouseEvent timeline_event = CreateMouseEvent( event->pos(), Qt::NoButton, event->keyboardModifiers()); - timeline_event.SetMimeData(event->mimeData()); + timeline_event.set_mime_data(event->mimeData()); timeline_event.SetEvent(event); - emit DragEntered(&timeline_event); + emit drag_entered(&timeline_event); } void TimelineView::dragMoveEvent(QDragMoveEvent *event) @@ -170,15 +170,15 @@ void TimelineView::dragMoveEvent(QDragMoveEvent *event) TimelineViewMouseEvent timeline_event = CreateMouseEvent( event->pos(), Qt::NoButton, event->keyboardModifiers()); - timeline_event.SetMimeData(event->mimeData()); + timeline_event.set_mime_data(event->mimeData()); timeline_event.SetEvent(event); - emit DragMoved(&timeline_event); + emit drag_moved(&timeline_event); } void TimelineView::dragLeaveEvent(QDragLeaveEvent *event) { - emit DragLeft(event); + emit drag_left(event); } void TimelineView::dropEvent(QDropEvent *event) @@ -186,10 +186,10 @@ void TimelineView::dropEvent(QDropEvent *event) TimelineViewMouseEvent timeline_event = CreateMouseEvent( event->pos(), Qt::NoButton, event->keyboardModifiers()); - timeline_event.SetMimeData(event->mimeData()); + timeline_event.set_mime_data(event->mimeData()); timeline_event.SetEvent(event); - emit DragDropped(&timeline_event); + emit drag_dropped(&timeline_event); } void TimelineView::drawBackground(QPainter *painter, const QRectF &rect) @@ -202,8 +202,8 @@ void TimelineView::drawBackground(QPainter *painter, const QRectF &rect) int line_y = 0; - foreach (Track *track, connected_track_list_->GetTracks()) { - line_y += track->GetTrackHeightInPixels(); + foreach (Track *track, connected_track_list_->get_tracks()) { + line_y += track->get_track_height_in_pixels(); // One px gap between tracks line_y++; @@ -228,7 +228,7 @@ void TimelineView::drawForeground(QPainter *painter, const QRectF &rect) } // Draw block backgrounds - DrawBlocks(painter, false); + draw_blocks(painter, false); // Draw selections if (selections_ && !selections_->isEmpty()) { @@ -240,43 +240,43 @@ void TimelineView::drawForeground(QPainter *painter, const QRectF &rect) int track_index = it.key().index(); foreach (const TimeRange &range, it.value()) { - painter->drawRect(TimeToScene(range.in()), - GetTrackY(track_index), - TimeToScene(range.length()), - GetTrackHeight(track_index)); + painter->drawRect(time_to_scene(range.in()), + get_track_y(track_index), + time_to_scene(range.length()), + get_track_height(track_index)); } } } } // Draw block foregrounds - DrawBlocks(painter, true); + draw_blocks(painter, true); // Draw ghosts if (ghosts_ && !ghosts_->isEmpty()) { foreach (TimelineViewGhostItem *ghost, (*ghosts_)) { - if (ghost->GetTrack().type() == connected_track_list_->type() && - !ghost->IsInvisible()) { - int track_index = ghost->GetAdjustedTrack().index(); + if (ghost->get_track().type() == connected_track_list_->type() && + !ghost->is_invisible()) { + int track_index = ghost->get_adjusted_track().index(); - Block *attached = QtUtils::ValueToPtr( - ghost->GetData(TimelineViewGhostItem::kAttachedBlock)); + Block *attached = QtUtils::value_to_ptr( + ghost->get_data(TimelineViewGhostItem::k_attached_block)); if (attached && - OLIVE_CONFIG("ShowClipWhileDragging").toBool()) { - int adj_track = ghost->GetAdjustedTrack().index(); - qreal track_top = GetTrackY(adj_track); - qreal track_height = GetTrackHeight(adj_track); + OAK_CONFIG("ShowClipWhileDragging").toBool()) { + int adj_track = ghost->get_adjusted_track().index(); + qreal track_top = get_track_y(adj_track); + qreal track_height = get_track_height(adj_track); qreal old_opacity = painter->opacity(); painter->setOpacity(0.5); - rational in = ghost->GetAdjustedIn(), - out = ghost->GetAdjustedOut(), - media_in = ghost->GetAdjustedMediaIn(); - DrawBlock(painter, false, attached, track_top, track_height, + Rational in = ghost->get_adjusted_in(), + out = ghost->get_adjusted_out(), + media_in = ghost->get_adjusted_media_in(); + draw_block(painter, false, attached, track_top, track_height, in, out, media_in); - DrawBlock(painter, true, attached, track_top, track_height, + draw_block(painter, true, attached, track_top, track_height, in, out, media_in); painter->setOpacity(old_opacity); @@ -285,37 +285,37 @@ void TimelineView::drawForeground(QPainter *painter, const QRectF &rect) painter->setPen(QPen(Qt::yellow, 2)); painter->setBrush(Qt::NoBrush); - painter->drawRect(TimeToScene(ghost->GetAdjustedIn()), - GetTrackY(track_index), - TimeToScene(ghost->GetAdjustedLength()), - GetTrackHeight(track_index)); + painter->drawRect(time_to_scene(ghost->get_adjusted_in()), + get_track_y(track_index), + time_to_scene(ghost->get_adjusted_length()), + get_track_height(track_index)); } } } // Draw beam cursor if (show_beam_cursor_ && - cursor_coord_.GetTrack().type() == connected_track_list_->type()) { + cursor_coord_.get_track().type() == connected_track_list_->type()) { painter->setPen(Qt::gray); - double cursor_x = TimeToScene(cursor_coord_.GetFrame()); - int track_index = cursor_coord_.GetTrack().index(); - int track_y = GetTrackY(track_index); + double cursor_x = time_to_scene(cursor_coord_.get_frame()); + int track_index = cursor_coord_.get_track().index(); + int track_y = get_track_y(track_index); painter->drawLine(cursor_x, track_y, cursor_x, - track_y + GetTrackHeight(track_index)); + track_y + get_track_height(track_index)); } // Draw recording overlay if (recording_overlay_ && - recording_coord_.GetTrack().type() == connected_track_list_->type()) { + recording_coord_.get_track().type() == connected_track_list_->type()) { painter->setPen(QPen(Qt::red, 2)); painter->setBrush(QColor(255, 128, 128)); - int x = TimeToScene(recording_coord_.GetFrame()); - painter->drawRect(x, GetTrackY(recording_coord_.GetTrack().index()), - TimeToScene(GetViewerNode()->GetPlayhead()) - x, - GetTrackHeight(recording_coord_.GetTrack().index())); + int x = time_to_scene(recording_coord_.get_frame()); + painter->drawRect(x, get_track_y(recording_coord_.get_track().index()), + time_to_scene(get_viewer_node()->get_playhead()) - x, + get_track_height(recording_coord_.get_track().index())); } // Draw standard TimelineViewBase things (such as playhead) @@ -325,19 +325,19 @@ void TimelineView::drawForeground(QPainter *painter, const QRectF &rect) void TimelineView::ToolChangedEvent(Tool::Item tool) { switch (tool) { - case Tool::kRazor: + case Tool::k_razor: setCursor(Qt::SplitHCursor); break; - case Tool::kEdit: + case Tool::k_edit: setCursor(Qt::IBeamCursor); break; - case Tool::kAdd: - case Tool::kTransition: - case Tool::kZoom: - case Tool::kRecord: + case Tool::k_add: + case Tool::k_transition: + case Tool::k_zoom: + case Tool::k_record: setCursor(Qt::CrossCursor); break; - case Tool::kTrackSelect: + case Tool::k_track_select: setCursor(Qt::SizeHorCursor); // FIXME: Not the ideal cursor break; default: @@ -355,32 +355,32 @@ void TimelineView::SceneRectUpdateEvent(QRectF &rect) { if (alignment() & Qt::AlignTop) { rect.setTop(0); - rect.setBottom(GetHeightOfAllTracks() + height() / 2); + rect.setBottom(get_height_of_all_tracks() + height() / 2); } else if (alignment() & Qt::AlignBottom) { rect.setBottom(0); - rect.setTop(GetHeightOfAllTracks() - height() / 2); + rect.setTop(get_height_of_all_tracks() - height() / 2); } } -Track::Type TimelineView::ConnectedTrackType() +Track::Type TimelineView::connected_track_type() { if (connected_track_list_) { return connected_track_list_->type(); } - return Track::kNone; + return Track::k_none; } -TimelineCoordinate TimelineView::ScreenToCoordinate(const QPoint &pt) +TimelineCoordinate TimelineView::screen_to_coordinate(const QPoint &pt) { - return SceneToCoordinate(mapToScene(pt)); + return scene_to_coordinate(mapToScene(pt)); } -TimelineCoordinate TimelineView::SceneToCoordinate(const QPointF &pt) +TimelineCoordinate TimelineView::scene_to_coordinate(const QPointF &pt) { - return TimelineCoordinate(SceneToTime(pt.x()), - Track::Reference(ConnectedTrackType(), - SceneToTrack(pt.y()))); + return TimelineCoordinate(scene_to_time(pt.x()), + Track::Reference(connected_track_type(), + scene_to_track(pt.y()))); } TimelineViewMouseEvent TimelineView::CreateMouseEvent(QMouseEvent *event) @@ -394,26 +394,26 @@ TimelineView::CreateMouseEvent(const QPoint &pos, Qt::MouseButton button, { QPointF scene_pt = mapToScene(pos); - return TimelineViewMouseEvent(scene_pt, pos, GetScale(), timebase(), - Track::Reference(ConnectedTrackType(), - SceneToTrack(scene_pt.y())), + return TimelineViewMouseEvent(scene_pt, pos, get_scale(), timebase(), + Track::Reference(connected_track_type(), + scene_to_track(scene_pt.y())), button, modifiers); } -void TimelineView::DrawBlocks(QPainter *painter, bool foreground) +void TimelineView::draw_blocks(QPainter *painter, bool foreground) { - rational start_time = SceneToTime(GetTimelineLeftBound()); - rational end_time = SceneToTime(GetTimelineRightBound()); + Rational start_time = scene_to_time(get_timeline_left_bound()); + Rational end_time = scene_to_time(get_timeline_right_bound()); - foreach (Track *track, connected_track_list_->GetTracks()) { + foreach (Track *track, connected_track_list_->get_tracks()) { // Get first visible block in this track - Block *block = track->NearestBlockBeforeOrAt(start_time); + Block *block = track->nearest_block_before_or_at(start_time); - qreal track_top = GetTrackY(track->Index()); - qreal track_height = GetTrackHeight(track->Index()); + qreal track_top = get_track_y(track->index()); + qreal track_height = get_track_height(track->index()); while (block) { - DrawBlock(painter, foreground, block, track_top, track_height); + draw_block(painter, foreground, block, track_top, track_height); if (block->out() >= end_time) { // Rest of the clips are offscreen, can break loop now @@ -425,28 +425,28 @@ void TimelineView::DrawBlocks(QPainter *painter, bool foreground) } } -void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, +void TimelineView::draw_block(QPainter *painter, bool foreground, Block *block, qreal block_top, qreal block_height, - const rational &in, const rational &out, - const rational &media_in) + const Rational &in, const Rational &out, + const Rational &media_in) { if (dynamic_cast(block) || dynamic_cast(block)) { - qreal block_in = TimeToScene(in); + qreal block_in = time_to_scene(in); - qreal block_left = qMax(GetTimelineLeftBound(), block_in); - qreal block_right = qMin(GetTimelineRightBound(), TimeToScene(out)) - 1; + qreal block_left = qMax(get_timeline_left_bound(), block_in); + qreal block_right = qMin(get_timeline_right_bound(), time_to_scene(out)) - 1; QRectF r(block_left, block_top, block_right - block_left, block_height); QColor shadow_color = block->is_enabled() ? - QtUtils::toQColor(block->color()).darker() : + QtUtils::to_q_color(block->color()).darker() : QColor(Qt::darkGray).darker(); - const qreal MINIMUM_RECT_WIDTH = 2; - const qreal MINIMUM_DETAIL_WIDTH = 8; + const qreal minimum_rect_width = 2; + const qreal minimum_detail_width = 8; - if (r.width() <= MINIMUM_RECT_WIDTH) { + if (r.width() <= minimum_rect_width) { if (!foreground) { // Just draw a green background // Width is likely fractional, so we ceil it and add 1 to ensure the entire width of the @@ -465,22 +465,22 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, if (foreground) { painter->setBrush(Qt::NoBrush); - if (r.width() > MINIMUM_DETAIL_WIDTH) { - QString using_label = block->GetLabelOrName(); + if (r.width() > minimum_detail_width) { + QString using_label = block->get_label_or_name(); QRectF text_rect = r.adjusted(text_padding, text_padding, -text_padding, -text_padding); painter->setPen( block->is_enabled() ? - ColorCoding::GetUISelectorColor(block->color()) : + ColorCoding::get_ui_selector_color(block->color()) : Qt::lightGray); painter->drawText(text_rect, Qt::AlignLeft | Qt::AlignTop, using_label); - if (block->HasLinks()) { + if (block->has_links()) { int text_width = qMin(qRound(text_rect.width()), - QtUtils::QFontMetricsWidth(fm, using_label)); + QtUtils::q_font_metrics_width(fm, using_label)); int underline_y = text_rect.y() + text_height; @@ -511,14 +511,14 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, Qt::gray); painter->drawRect(r); - if (r.width() > MINIMUM_DETAIL_WIDTH) { + if (r.width() > minimum_detail_width) { if (ClipBlock *clip = dynamic_cast(block)) { QRect preview_rect = r.toRect(); // Draw clip thumbnails - if (clip->GetTrackType() == Track::kVideo && - OLIVE_CONFIG("TimelineThumbnailMode").toInt() != - Timeline::kThumbnailOff) { + if (clip->get_track_type() == Track::k_video && + OAK_CONFIG("TimelineThumbnailMode").toInt() != + Timeline::k_thumbnail_off) { // Start thumbnails underneath clip name preview_rect.adjust(0, text_total_height, 0, 0); @@ -530,12 +530,12 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, QPainter::SmoothPixmapTransform); painter->setClipRect(preview_rect); - if (OLIVE_CONFIG("TimelineThumbnailMode") == - Timeline::kThumbnailOn) { + if (OAK_CONFIG("TimelineThumbnailMode") == + Timeline::k_thumbnail_on) { Sequence *s = clip->track()->sequence(); - int width = s->GetVideoParams().width(); + int width = s->get_video_params().width(); int height = - s->GetVideoParams().height(); + s->get_video_params().height(); int start; if (height > 0) { // Prevent divide by zero/invalid params @@ -555,27 +555,27 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, for (int i = start; i < preview_rect.right(); i += thumb_rect.width() + 1) { - rational time_here = - SceneToTime( - i - block_in, GetScale(), + Rational time_here = + scene_to_time( + i - block_in, get_scale(), connected_track_list_ ->parent() - ->GetVideoParams() + ->get_video_params() .frame_rate_as_time_base()) + media_in; - DrawThumbnail(painter, thumbs, + draw_thumbnail(painter, thumbs, time_here, i, preview_rect, &thumb_rect); } } else { - rational time = + Rational time = clip->media_range().in(); time = Timecode::snap_time_to_timebase( - time, thumbs->GetTimebase(), - Timecode::kFloor); - DrawThumbnail(painter, thumbs, time, + time, thumbs->get_timebase(), + Timecode::k_floor); + draw_thumbnail(painter, thumbs, time, block_left, preview_rect, &thumb_rect); } @@ -586,58 +586,58 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, } // Draw waveform - if (clip->GetTrackType() == Track::kAudio && - OLIVE_CONFIG("TimelineWaveformMode").toInt() == - Timeline::kWaveformsEnabled) { + if (clip->get_track_type() == Track::k_audio && + OAK_CONFIG("TimelineWaveformMode").toInt() == + Timeline::k_waveforms_enabled) { if (const AudioWaveformCache *wave = clip->waveform()) { - rational waveform_start = - SceneToTime( - block_left - block_in, GetScale(), + Rational waveform_start = + scene_to_time( + block_left - block_in, get_scale(), connected_track_list_->parent() - ->GetAudioParams() + ->get_audio_params() .sample_rate_as_time_base()) + media_in; painter->setPen(shadow_color); wave->Draw(painter, preview_rect, - this->GetScale(), waveform_start); + this->get_scale(), waveform_start); } } // Draw zebra stripes and markers if (clip->connected_viewer()) { - if (!clip->connected_viewer()->GetLength().isNull()) { + if (!clip->connected_viewer()->get_length().isNull()) { painter->setPen(shadow_color); if (clip->media_in() < 0) { - qreal zebra_right = TimeToScene( + qreal zebra_right = time_to_scene( clip->in() - clip->media_in()); switch (clip->loop_mode()) { - case LoopMode::kLoopModeOff: + case LoopMode::k_loop_mode_off: // Draw stripes for sections of clip < 0 if (zebra_right > - GetTimelineLeftBound()) { - DrawZebraStripes( + get_timeline_left_bound()) { + draw_zebra_stripes( painter, QRectF(block_left, block_top, zebra_right - block_left, block_height)); } break; - case LoopMode::kLoopModeLoop: + case LoopMode::k_loop_mode_loop: for (qreal i = zebra_right; i > block_left; - i -= TimeToScene( + i -= time_to_scene( clip->connected_viewer() - ->GetLength())) { + ->get_length())) { painter->drawLine(i, block_top, i, block_top + block_height); } break; - case LoopMode::kLoopModeClamp: + case LoopMode::k_loop_mode_clamp: painter->drawLine( zebra_right, block_top, zebra_right, block_top + block_height); @@ -646,35 +646,35 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, } if (clip->length() + clip->media_in() > - clip->connected_viewer()->GetLength()) { - qreal zebra_left = TimeToScene( + clip->connected_viewer()->get_length()) { + qreal zebra_left = time_to_scene( clip->out() - (clip->media_in() + clip->length() - - clip->connected_viewer()->GetLength())); + clip->connected_viewer()->get_length())); switch (clip->loop_mode()) { - case LoopMode::kLoopModeOff: + case LoopMode::k_loop_mode_off: // Draw stripes for sections for clip > clip length if (zebra_left < - GetTimelineRightBound()) { - DrawZebraStripes( + get_timeline_right_bound()) { + draw_zebra_stripes( painter, QRectF(zebra_left, block_top, block_right - zebra_left, block_height)); } break; - case LoopMode::kLoopModeLoop: + case LoopMode::k_loop_mode_loop: for (qreal i = zebra_left; i < block_right; - i += TimeToScene( + i += time_to_scene( clip->connected_viewer() - ->GetLength())) { + ->get_length())) { painter->drawLine(i, block_top, i, block_top + block_height); } break; - case LoopMode::kLoopModeClamp: + case LoopMode::k_loop_mode_clamp: painter->drawLine( zebra_left, block_top, zebra_left, block_top + block_height); @@ -684,7 +684,7 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, } TimelineMarkerList *marker_list = - clip->connected_viewer()->GetMarkers(); + clip->connected_viewer()->get_markers(); if (!marker_list->empty()) { clip_marker_rects_.clear(); @@ -697,14 +697,14 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, marker->time().out() <= clip->media_in() + clip->length()) { QPoint marker_pt( - TimeToScene(clip->in() - + time_to_scene(clip->in() - clip->media_in() + marker->time().in()), block_top + block_height); painter->setClipRect(r); QRect marker_rect = - marker->Draw(painter, marker_pt, -1, - GetScale(), false); + marker->draw(painter, marker_pt, -1, + get_scale(), false); clip_marker_rects_.insert(marker, marker_rect); painter->setClipping(false); @@ -715,17 +715,17 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, if (const FrameHashCache *cache = clip->connected_video_cache()) { - if (cache->HasValidatedRanges()) { + if (cache->has_validated_ranges()) { QRect cache_rect = r.adjusted( 0, r.height() - PlaybackCache:: - GetCacheIndicatorHeight(), + get_cache_indicator_height(), 0, 0) .toRect(); - cache->Draw(painter, clip->media_in(), - GetScale(), cache_rect); + cache->draw(painter, clip->media_in(), + get_scale(), cache_rect); } } } @@ -752,7 +752,7 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, QRectF transition_overlay_rect = r; qreal transition_overlay_width = - TimeToScene(block->length()) * 0.5; + time_to_scene(block->length()) * 0.5; if (transition_overlay_out_ && transition_overlay_in_) { // This is a dual transition, use the smallest width Block *other_block = @@ -761,7 +761,7 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, transition_overlay_out_; qreal other_width = - TimeToScene(other_block->length()) * 0.5; + time_to_scene(other_block->length()) * 0.5; transition_overlay_width = qMin(transition_overlay_width, other_width); @@ -788,7 +788,7 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, } } -void TimelineView::DrawZebraStripes(QPainter *painter, const QRectF &r) +void TimelineView::draw_zebra_stripes(QPainter *painter, const QRectF &r) { int zebra_interval = fontMetrics().height(); @@ -810,36 +810,36 @@ void TimelineView::DrawZebraStripes(QPainter *painter, const QRectF &r) painter->setClipping(false); } -int TimelineView::GetHeightOfAllTracks() const +int TimelineView::get_height_of_all_tracks() const { if (connected_track_list_) { if (alignment() & Qt::AlignTop) { - return GetTrackY(connected_track_list_->GetTrackCount()); + return get_track_y(connected_track_list_->get_track_count()); } else { - return GetTrackY(connected_track_list_->GetTrackCount() - 1); + return get_track_y(connected_track_list_->get_track_count() - 1); } } else { return 0; } } -qreal TimelineView::GetTimelineLeftBound() const +qreal TimelineView::get_timeline_left_bound() const { return horizontalScrollBar()->value(); } -qreal TimelineView::GetTimelineRightBound() const +qreal TimelineView::get_timeline_right_bound() const { - return GetTimelineLeftBound() + viewport()->width(); + return get_timeline_left_bound() + viewport()->width(); } -void TimelineView::DrawThumbnail(QPainter *painter, +void TimelineView::draw_thumbnail(QPainter *painter, const FrameHashCache *thumbs, - const rational &time, int x, + const Rational &time, int x, const QRect &preview_rect, QRect *thumb_rect) const { - QString thumbnail = thumbs->GetValidCacheFilename(time); + QString thumbnail = thumbs->get_valid_cache_filename(time); if (!thumbnail.isEmpty()) { QImage img; @@ -852,9 +852,9 @@ void TimelineView::DrawThumbnail(QPainter *painter, } } -int TimelineView::GetTrackY(int track_index) const +int TimelineView::get_track_y(int track_index) const { - if (!connected_track_list_ || !connected_track_list_->GetTrackCount()) { + if (!connected_track_list_ || !connected_track_list_->get_track_count()) { return 0; } @@ -865,7 +865,7 @@ int TimelineView::GetTrackY(int track_index) const } for (int i = 0; i < track_index; i++) { - y += GetTrackHeight(i); + y += get_track_height(i); // One px line between each track y++; @@ -878,69 +878,69 @@ int TimelineView::GetTrackY(int track_index) const return y; } -int TimelineView::GetTrackHeight(int track_index) const +int TimelineView::get_track_height(int track_index) const { - if (!connected_track_list_ || connected_track_list_->GetTrackCount() == 0) { + if (!connected_track_list_ || connected_track_list_->get_track_count() == 0) { // Handle null or empty track list - return Track::GetDefaultTrackHeightInPixels(); + return Track::get_default_track_height_in_pixels(); } - if (track_index >= connected_track_list_->GetTrackCount()) { + if (track_index >= connected_track_list_->get_track_count()) { // Handle new track at the end of the list return connected_track_list_ - ->GetTrackAt(connected_track_list_->GetTrackCount() - 1) - ->GetTrackHeightInPixels(); + ->get_track_at(connected_track_list_->get_track_count() - 1) + ->get_track_height_in_pixels(); } if (track_index < 0) { // Handle new track at the beginning of the list - return connected_track_list_->GetTrackAt(0)->GetTrackHeightInPixels(); + return connected_track_list_->get_track_at(0)->get_track_height_in_pixels(); } // Track definitely exists, return its actual height - return connected_track_list_->GetTrackAt(track_index) - ->GetTrackHeightInPixels(); + return connected_track_list_->get_track_at(track_index) + ->get_track_height_in_pixels(); } -QPoint TimelineView::GetScrollCoordinates() const +QPoint TimelineView::get_scroll_coordinates() const { return QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value()); } -void TimelineView::SetScrollCoordinates(const QPoint &pt) +void TimelineView::set_scroll_coordinates(const QPoint &pt) { horizontalScrollBar()->setValue(pt.x()); verticalScrollBar()->setValue(pt.y()); } -void TimelineView::ConnectTrackList(TrackList *list) +void TimelineView::connect_track_list(TrackList *list) { if (connected_track_list_) { - disconnect(connected_track_list_, &TrackList::TrackListChanged, this, - &TimelineView::TrackListChanged); - disconnect(connected_track_list_, &TrackList::TrackHeightChanged, this, - &TimelineView::TrackListChanged); + disconnect(connected_track_list_, &TrackList::track_list_changed, this, + &TimelineView::track_list_changed); + disconnect(connected_track_list_, &TrackList::track_height_changed, this, + &TimelineView::track_list_changed); } connected_track_list_ = list; if (connected_track_list_) { - connect(connected_track_list_, &TrackList::TrackListChanged, this, - &TimelineView::TrackListChanged); - connect(connected_track_list_, &TrackList::TrackHeightChanged, this, - &TimelineView::TrackListChanged); + connect(connected_track_list_, &TrackList::track_list_changed, this, + &TimelineView::track_list_changed); + connect(connected_track_list_, &TrackList::track_height_changed, this, + &TimelineView::track_list_changed); } } -void TimelineView::SetBeamCursor(const TimelineCoordinate &coord) +void TimelineView::set_beam_cursor(const TimelineCoordinate &coord) { if (!connected_track_list_) { return; } bool update_required = - coord.GetTrack().type() == connected_track_list_->type() || - cursor_coord_.GetTrack().type() == connected_track_list_->type(); + coord.get_track().type() == connected_track_list_->type() || + cursor_coord_.get_track().type() == connected_track_list_->type(); show_beam_cursor_ = true; cursor_coord_ = coord; @@ -950,10 +950,10 @@ void TimelineView::SetBeamCursor(const TimelineCoordinate &coord) } } -void TimelineView::SetTransitionOverlay(ClipBlock *out, ClipBlock *in) +void TimelineView::set_transition_overlay(ClipBlock *out, ClipBlock *in) { if (transition_overlay_out_ != out || transition_overlay_in_ != in) { - Track::Type type = Track::kNone; + Track::Type type = Track::k_none; if (out) { type = out->track()->type(); @@ -973,20 +973,20 @@ void TimelineView::SetTransitionOverlay(ClipBlock *out, ClipBlock *in) } } -void TimelineView::EnableRecordingOverlay(const TimelineCoordinate &coord) +void TimelineView::enable_recording_overlay(const TimelineCoordinate &coord) { recording_overlay_ = true; recording_coord_ = coord; viewport()->update(); } -void TimelineView::DisableRecordingOverlay() +void TimelineView::disable_recording_overlay() { recording_overlay_ = false; viewport()->update(); } -int TimelineView::SceneToTrack(double y) +int TimelineView::scene_to_track(double y) { int track = -1; int heights = 0; @@ -997,20 +997,20 @@ int TimelineView::SceneToTrack(double y) do { track++; - heights += GetTrackHeight(track); + heights += get_track_height(track); } while (y > heights); return track; } -Block *TimelineView::GetItemAtScenePos(const rational &time, +Block *TimelineView::get_item_at_scene_pos(const Rational &time, int track_index) const { if (connected_track_list_) { - Track *track = connected_track_list_->GetTrackAt(track_index); + Track *track = connected_track_list_->get_track_at(track_index); if (track) { - foreach (Block *b, track->Blocks()) { + foreach (Block *b, track->blocks()) { if (b->in() <= time && b->out() > time) { return b; } @@ -1021,22 +1021,22 @@ Block *TimelineView::GetItemAtScenePos(const rational &time, return nullptr; } -QVector TimelineView::GetItemsAtSceneRect(const QRectF &rect) const +QVector TimelineView::get_items_at_scene_rect(const QRectF &rect) const { QVector list; if (connected_track_list_) { - rational start = this->SceneToTime(rect.left()); - rational end = this->SceneToTime(rect.right()); + Rational start = this->scene_to_time(rect.left()); + Rational end = this->scene_to_time(rect.right()); - for (int i = 0; i < connected_track_list_->GetTrackCount(); i++) { - Track *track = connected_track_list_->GetTrackAt(i); - int track_top = GetTrackY(i); - int track_bottom = track_top + GetTrackHeight(i); + for (int i = 0; i < connected_track_list_->get_track_count(); i++) { + Track *track = connected_track_list_->get_track_at(i); + int track_top = get_track_y(i); + int track_bottom = track_top + get_track_height(i); if (track) { if (!(track_bottom < rect.top() || track_top > rect.bottom())) { - Block *b = track->NearestBlockBeforeOrAt(start); + Block *b = track->nearest_block_before_or_at(start); while (b && b->in() < end) { list.append(b); b = b->next(); @@ -1049,9 +1049,9 @@ QVector TimelineView::GetItemsAtSceneRect(const QRectF &rect) const return list; } -void TimelineView::TrackListChanged() +void TimelineView::track_list_changed() { - UpdateSceneRect(); + update_scene_rect(); viewport()->update(); } diff --git a/app/widget/timelinewidget/view/timelineview.h b/app/widget/timelinewidget/view/timelineview.h index 21c5c3ab2..d1711075c 100644 --- a/app/widget/timelinewidget/view/timelineview.h +++ b/app/widget/timelinewidget/view/timelineview.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEVIEW_H -#define TIMELINEVIEW_H +#ifndef OAK_TIMELINEVIEW_H +#define OAK_TIMELINEVIEW_H #include #include @@ -47,45 +47,45 @@ public: TimelineView(Qt::Alignment vertical_alignment = Qt::AlignTop, QWidget *parent = nullptr); - int GetTrackY(int track_index) const; - int GetTrackHeight(int track_index) const; + int get_track_y(int track_index) const; + int get_track_height(int track_index) const; - QPoint GetScrollCoordinates() const; - void SetScrollCoordinates(const QPoint &pt); + QPoint get_scroll_coordinates() const; + void set_scroll_coordinates(const QPoint &pt); - void ConnectTrackList(TrackList *list); + void connect_track_list(TrackList *list); - void SetBeamCursor(const TimelineCoordinate &coord); - void SetTransitionOverlay(ClipBlock *out, ClipBlock *in); - void EnableRecordingOverlay(const TimelineCoordinate &coord); - void DisableRecordingOverlay(); + void set_beam_cursor(const TimelineCoordinate &coord); + void set_transition_overlay(ClipBlock *out, ClipBlock *in); + void enable_recording_overlay(const TimelineCoordinate &coord); + void disable_recording_overlay(); - void SetSelectionList(QHash *s) + void set_selection_list(QHash *s) { selections_ = s; } - void SetGhostList(QVector *ghosts) + void set_ghost_list(QVector *ghosts) { ghosts_ = ghosts; } - int SceneToTrack(double y); + int scene_to_track(double y); - Block *GetItemAtScenePos(const rational &time, int track_index) const; + Block *get_item_at_scene_pos(const Rational &time, int track_index) const; - QVector GetItemsAtSceneRect(const QRectF &rect) const; + QVector get_items_at_scene_rect(const QRectF &rect) const; signals: - void MousePressed(TimelineViewMouseEvent *event); - void MouseMoved(TimelineViewMouseEvent *event); - void MouseReleased(TimelineViewMouseEvent *event); - void MouseDoubleClicked(TimelineViewMouseEvent *event); + void mouse_pressed(TimelineViewMouseEvent *event); + void mouse_moved(TimelineViewMouseEvent *event); + void mouse_released(TimelineViewMouseEvent *event); + void mouse_double_clicked(TimelineViewMouseEvent *event); - void DragEntered(TimelineViewMouseEvent *event); - void DragMoved(TimelineViewMouseEvent *event); - void DragLeft(QDragLeaveEvent *event); - void DragDropped(TimelineViewMouseEvent *event); + void drag_entered(TimelineViewMouseEvent *event); + void drag_moved(TimelineViewMouseEvent *event); + void drag_left(QDragLeaveEvent *event); + void drag_dropped(TimelineViewMouseEvent *event); protected: virtual void mousePressEvent(QMouseEvent *event) override; @@ -106,41 +106,41 @@ protected: virtual void SceneRectUpdateEvent(QRectF &rect) override; private: - Track::Type ConnectedTrackType(); + Track::Type connected_track_type(); - TimelineCoordinate ScreenToCoordinate(const QPoint &pt); - TimelineCoordinate SceneToCoordinate(const QPointF &pt); + TimelineCoordinate screen_to_coordinate(const QPoint &pt); + TimelineCoordinate scene_to_coordinate(const QPointF &pt); TimelineViewMouseEvent CreateMouseEvent(QMouseEvent *event); TimelineViewMouseEvent CreateMouseEvent(const QPoint &pos, Qt::MouseButton button, Qt::KeyboardModifiers modifiers); - void DrawBlocks(QPainter *painter, bool foreground); + void draw_blocks(QPainter *painter, bool foreground); - void DrawBlock(QPainter *painter, bool foreground, Block *block, qreal top, - qreal height, const rational &in, const rational &out, - const rational &media_in); - void DrawBlock(QPainter *painter, bool foreground, Block *block, qreal top, + void draw_block(QPainter *painter, bool foreground, Block *block, qreal top, + qreal height, const Rational &in, const Rational &out, + const Rational &media_in); + void draw_block(QPainter *painter, bool foreground, Block *block, qreal top, qreal height) { ClipBlock *cb = dynamic_cast(block); - return DrawBlock(painter, foreground, block, top, height, block->in(), + return draw_block(painter, foreground, block, top, height, block->in(), block->out(), cb ? cb->media_in() : 0); } - void DrawZebraStripes(QPainter *painter, const QRectF &r); + void draw_zebra_stripes(QPainter *painter, const QRectF &r); - int GetHeightOfAllTracks() const; + int get_height_of_all_tracks() const; - void UpdatePlayheadRect(); + void update_playhead_rect(); - qreal GetTimelineLeftBound() const; + qreal get_timeline_left_bound() const; - qreal GetTimelineRightBound() const; + qreal get_timeline_right_bound() const; - void DrawThumbnail(QPainter *painter, const FrameHashCache *thumbs, - const rational &time, int x, const QRect &preview_rect, + void draw_thumbnail(QPainter *painter, const FrameHashCache *thumbs, + const Rational &time, int x, const QRect &preview_rect, QRect *thumb_rect) const; QHash *selections_; @@ -162,9 +162,9 @@ private: TimelineCoordinate recording_coord_; private slots: - void TrackListChanged(); + void track_list_changed(); }; } -#endif // TIMELINEVIEW_H +#endif // OAK_TIMELINEVIEW_H diff --git a/app/widget/timelinewidget/view/timelineviewghostitem.h b/app/widget/timelinewidget/view/timelineviewghostitem.h index 030050b4b..c0595d925 100644 --- a/app/widget/timelinewidget/view/timelineviewghostitem.h +++ b/app/widget/timelinewidget/view/timelineviewghostitem.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEVIEWGHOSTITEM_H -#define TIMELINEVIEWGHOSTITEM_H +#ifndef OAK_TIMELINEVIEWGHOSTITEM_H +#define OAK_TIMELINEVIEWGHOSTITEM_H #include @@ -38,12 +38,12 @@ namespace olive class TimelineViewGhostItem { public: enum DataType { - kAttachedBlock, - kReferenceBlock, - kAttachedFootage, - kGhostIsSliding, - kTrimIsARollEdit, - kTrimShouldBeIgnored + k_attached_block, + k_reference_block, + k_attached_footage, + k_ghost_is_sliding, + k_trim_is_a_roll_edit, + k_trim_should_be_ignored }; struct AttachedFootage { @@ -53,24 +53,24 @@ public: TimelineViewGhostItem() : track_adj_(0) - , mode_(Timeline::kNone) + , mode_(Timeline::k_none) , can_have_zero_length_(true) , can_move_tracks_(true) , invisible_(false) { } - static TimelineViewGhostItem *FromBlock(Block *block) + static TimelineViewGhostItem *from_block(Block *block) { TimelineViewGhostItem *ghost = new TimelineViewGhostItem(); - ghost->SetIn(block->in()); - ghost->SetOut(block->out()); + ghost->set_in(block->in()); + ghost->set_out(block->out()); if (dynamic_cast(block)) { - ghost->SetMediaIn(static_cast(block)->media_in()); + ghost->set_media_in(static_cast(block)->media_in()); } - ghost->SetTrack(block->track()->ToReference()); - ghost->SetData(kAttachedBlock, QtUtils::PtrToValue(block)); + ghost->set_track(block->track()->to_reference()); + ghost->set_data(k_attached_block, QtUtils::ptr_to_value(block)); if (dynamic_cast(block)) { ghost->can_have_zero_length_ = false; @@ -81,176 +81,176 @@ public: return ghost; } - bool CanHaveZeroLength() const + bool can_have_zero_length() const { return can_have_zero_length_; } - bool GetCanMoveTracks() const + bool get_can_move_tracks() const { return can_move_tracks_; } - void SetCanMoveTracks(bool e) + void set_can_move_tracks(bool e) { can_move_tracks_ = e; } - const rational &GetIn() const + const Rational &get_in() const { return in_; } - const rational &GetOut() const + const Rational &get_out() const { return out_; } - const rational &GetMediaIn() const + const Rational &get_media_in() const { return media_in_; } - rational GetLength() const + Rational get_length() const { return out_ - in_; } - rational GetAdjustedLength() const + Rational get_adjusted_length() const { - return GetAdjustedOut() - GetAdjustedIn(); + return get_adjusted_out() - get_adjusted_in(); } - void SetIn(const rational &in) + void set_in(const Rational &in) { in_ = in; } - void SetOut(const rational &out) + void set_out(const Rational &out) { out_ = out; } - void SetMediaIn(const rational &media_in) + void set_media_in(const Rational &media_in) { media_in_ = media_in; } - void SetInAdjustment(const rational &in_adj) + void set_in_adjustment(const Rational &in_adj) { in_adj_ = in_adj; } - void SetOutAdjustment(const rational &out_adj) + void set_out_adjustment(const Rational &out_adj) { out_adj_ = out_adj; } - void SetTrackAdjustment(const int &track_adj) + void set_track_adjustment(const int &track_adj) { track_adj_ = track_adj; } - void SetMediaInAdjustment(const rational &media_in_adj) + void set_media_in_adjustment(const Rational &media_in_adj) { media_in_adj_ = media_in_adj; } - const rational &GetInAdjustment() const + const Rational &get_in_adjustment() const { return in_adj_; } - const rational &GetOutAdjustment() const + const Rational &get_out_adjustment() const { return out_adj_; } - const rational &GetMediaInAdjustment() const + const Rational &get_media_in_adjustment() const { return media_in_adj_; } - const int &GetTrackAdjustment() const + const int &get_track_adjustment() const { return track_adj_; } - rational GetAdjustedIn() const + Rational get_adjusted_in() const { return in_ + in_adj_; } - rational GetAdjustedOut() const + Rational get_adjusted_out() const { return out_ + out_adj_; } - rational GetAdjustedMediaIn() const + Rational get_adjusted_media_in() const { return media_in_ + media_in_adj_; } - Track::Reference GetAdjustedTrack() const + Track::Reference get_adjusted_track() const { return Track::Reference(track_.type(), track_.index() + track_adj_); } - const Timeline::MovementMode &GetMode() const + const Timeline::MovementMode &get_mode() const { return mode_; } - void SetMode(const Timeline::MovementMode &mode) + void set_mode(const Timeline::MovementMode &mode) { mode_ = mode; } - bool HasBeenAdjusted() const + bool has_been_adjusted() const { - return GetInAdjustment() != 0 || GetOutAdjustment() != 0 || - GetMediaInAdjustment() != 0 || GetTrackAdjustment() != 0; + return get_in_adjustment() != 0 || get_out_adjustment() != 0 || + get_media_in_adjustment() != 0 || get_track_adjustment() != 0; } - QVariant GetData(int key) const + QVariant get_data(int key) const { return data_.value(key); } - void SetData(int key, const QVariant &value) + void set_data(int key, const QVariant &value) { data_.insert(key, value); } - const Track::Reference &GetTrack() const + const Track::Reference &get_track() const { return track_; } - void SetTrack(const Track::Reference &track) + void set_track(const Track::Reference &track) { track_ = track; } - bool IsInvisible() const + bool is_invisible() const { return invisible_; } - void SetInvisible(bool e) + void set_invisible(bool e) { invisible_ = e; } protected: private: - rational in_; - rational out_; - rational media_in_; + Rational in_; + Rational out_; + Rational media_in_; - rational in_adj_; - rational out_adj_; - rational media_in_adj_; + Rational in_adj_; + Rational out_adj_; + Rational media_in_adj_; int track_adj_; @@ -270,4 +270,4 @@ private: Q_DECLARE_METATYPE(olive::TimelineViewGhostItem::AttachedFootage) -#endif // TIMELINEVIEWGHOSTITEM_H +#endif // OAK_TIMELINEVIEWGHOSTITEM_H diff --git a/app/widget/timelinewidget/view/timelineviewmouseevent.h b/app/widget/timelinewidget/view/timelineviewmouseevent.h index 9f670d5d5..257281195 100644 --- a/app/widget/timelinewidget/view/timelineviewmouseevent.h +++ b/app/widget/timelinewidget/view/timelineviewmouseevent.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMELINEVIEWMOUSEEVENT_H -#define TIMELINEVIEWMOUSEEVENT_H +#ifndef OAK_TIMELINEVIEWMOUSEEVENT_H +#define OAK_TIMELINEVIEWMOUSEEVENT_H #include #include @@ -37,7 +37,7 @@ class TimelineViewMouseEvent { public: TimelineViewMouseEvent( const QPointF &scene_pos, const QPoint &screen_pos, - const double &scale_x, const rational &timebase, + const double &scale_x, const Rational &timebase, const Track::Reference &track, const Qt::MouseButton &button, const Qt::KeyboardModifiers &modifiers = Qt::NoModifier) : scene_pos_(scene_pos) @@ -53,12 +53,12 @@ public: { } - TimelineCoordinate GetCoordinates(bool round_time = false) const + TimelineCoordinate get_coordinates(bool round_time = false) const { - return TimelineCoordinate(GetFrame(round_time), track_); + return TimelineCoordinate(get_frame(round_time), track_); } - const Qt::KeyboardModifiers &GetModifiers() const + const Qt::KeyboardModifiers &get_modifiers() const { return modifiers_; } @@ -72,23 +72,23 @@ public: * always to the left of the cursor. The former behavior is better for clicking between frames (e.g. razor tool) and * the latter is better for clicking directly on frames (e.g. pointer tool). */ - rational GetFrame(bool round = false) const + Rational get_frame(bool round = false) const { - return TimeScaledObject::SceneToTime(GetSceneX(), scale_x_, timebase_, + return TimeScaledObject::scene_to_time(get_scene_x(), scale_x_, timebase_, round); } - const Track::Reference &GetTrack() const + const Track::Reference &get_track() const { return track_; } - const QMimeData *GetMimeData() + const QMimeData *get_mime_data() { return mime_data_; } - void SetMimeData(const QMimeData *data) + void set_mime_data(const QMimeData *data) { mime_data_ = data; } @@ -98,21 +98,21 @@ public: source_event_ = event; } - qreal GetSceneX() const + qreal get_scene_x() const { return scene_pos_.x(); } - const QPointF &GetScenePos() const + const QPointF &get_scene_pos() const { return scene_pos_; } - const QPoint &GetScreenPos() const + const QPoint &get_screen_pos() const { return screen_pos_; } - const Qt::MouseButton &GetButton() const + const Qt::MouseButton &get_button() const { return button_; } @@ -129,11 +129,11 @@ public: source_event_->ignore(); } - bool GetBypassImportBuffer() const + bool get_bypass_import_buffer() const { return bypass_import_buffer_; } - void SetBypassImportBuffer(bool e) + void set_bypass_import_buffer(bool e) { bypass_import_buffer_ = e; } @@ -142,7 +142,7 @@ private: QPointF scene_pos_; QPoint screen_pos_; double scale_x_; - rational timebase_; + Rational timebase_; Track::Reference track_; @@ -159,4 +159,4 @@ private: } -#endif // TIMELINEVIEWMOUSEEVENT_H +#endif // OAK_TIMELINEVIEWMOUSEEVENT_H diff --git a/app/widget/timeruler/seekablewidget.cpp b/app/widget/timeruler/seekablewidget.cpp index 859d2824d..631a4d8d2 100644 --- a/app/widget/timeruler/seekablewidget.cpp +++ b/app/widget/timeruler/seekablewidget.cpp @@ -58,93 +58,93 @@ SeekableWidget::SeekableWidget(QWidget *parent) text_height_ = fm.height(); // Set width of playhead marker - playhead_width_ = QtUtils::QFontMetricsWidth(fm, "H"); + playhead_width_ = QtUtils::q_font_metrics_width(fm, "H"); setContextMenuPolicy(Qt::CustomContextMenu); setFocusPolicy(Qt::ClickFocus); setMouseTracking(true); - selection_manager_.SetSnapMask(TimeBasedWidget::kSnapAll); + selection_manager_.set_snap_mask(TimeBasedWidget::k_snap_all); - SetIsTimelineAxes(true); + set_is_timeline_axes(true); } -void SeekableWidget::SetMarkers(TimelineMarkerList *markers) +void SeekableWidget::set_markers(TimelineMarkerList *markers) { if (markers_) { - selection_manager_.ClearSelection(); + selection_manager_.clear_selection(); - disconnect(markers_, &TimelineMarkerList::MarkerAdded, viewport(), + disconnect(markers_, &TimelineMarkerList::marker_added, viewport(), static_cast(&QWidget::update)); - disconnect(markers_, &TimelineMarkerList::MarkerRemoved, viewport(), + disconnect(markers_, &TimelineMarkerList::marker_removed, viewport(), static_cast(&QWidget::update)); - disconnect(markers_, &TimelineMarkerList::MarkerModified, viewport(), + disconnect(markers_, &TimelineMarkerList::marker_modified, viewport(), static_cast(&QWidget::update)); } markers_ = markers; if (markers_) { - connect(markers_, &TimelineMarkerList::MarkerAdded, viewport(), + connect(markers_, &TimelineMarkerList::marker_added, viewport(), static_cast(&QWidget::update)); - connect(markers_, &TimelineMarkerList::MarkerRemoved, viewport(), + connect(markers_, &TimelineMarkerList::marker_removed, viewport(), static_cast(&QWidget::update)); - connect(markers_, &TimelineMarkerList::MarkerModified, viewport(), + connect(markers_, &TimelineMarkerList::marker_modified, viewport(), static_cast(&QWidget::update)); } viewport()->update(); } -void SeekableWidget::SetWorkArea(TimelineWorkArea *workarea) +void SeekableWidget::set_work_area(TimelineWorkArea *workarea) { if (workarea_) { - selection_manager_.ClearSelection(); + selection_manager_.clear_selection(); - disconnect(workarea_, &TimelineWorkArea::RangeChanged, viewport(), + disconnect(workarea_, &TimelineWorkArea::range_changed, viewport(), static_cast(&QWidget::update)); - disconnect(workarea_, &TimelineWorkArea::EnabledChanged, viewport(), + disconnect(workarea_, &TimelineWorkArea::enabled_changed, viewport(), static_cast(&QWidget::update)); } workarea_ = workarea; if (workarea_) { - connect(workarea_, &TimelineWorkArea::RangeChanged, viewport(), + connect(workarea_, &TimelineWorkArea::range_changed, viewport(), static_cast(&QWidget::update)); - connect(workarea_, &TimelineWorkArea::EnabledChanged, viewport(), + connect(workarea_, &TimelineWorkArea::enabled_changed, viewport(), static_cast(&QWidget::update)); } viewport()->update(); } -void SeekableWidget::DeleteSelected() +void SeekableWidget::delete_selected() { - if (!selection_manager_.IsDragging()) { + if (!selection_manager_.is_dragging()) { MultiUndoCommand *command = new MultiUndoCommand(); foreach (TimelineMarker *marker, - selection_manager_.GetSelectedObjects()) { + selection_manager_.get_selected_objects()) { command->add_child(new MarkerRemoveCommand(marker)); } Core::instance()->undo_stack()->push( command, tr("Deleted %1 Marker(s)") - .arg(selection_manager_.GetSelectedObjects().size())); + .arg(selection_manager_.get_selected_objects().size())); } } -bool SeekableWidget::CopySelected(bool cut) +bool SeekableWidget::copy_selected(bool cut) { - if (!selection_manager_.GetSelectedObjects().empty()) { - ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyMarkers); - sdata.SetOnlySerializeMarkers(selection_manager_.GetSelectedObjects()); + if (!selection_manager_.get_selected_objects().empty()) { + ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_markers); + sdata.set_only_serialize_markers(selection_manager_.get_selected_objects()); - ProjectSerializer::Copy(sdata); + ProjectSerializer::copy(sdata); if (cut) { - DeleteSelected(); + delete_selected(); } return true; @@ -153,22 +153,22 @@ bool SeekableWidget::CopySelected(bool cut) } } -bool SeekableWidget::PasteMarkers() +bool SeekableWidget::paste_markers() { ProjectSerializer::Result res = - ProjectSerializer::Paste(ProjectSerializer::kOnlyMarkers); - if (res == ProjectSerializer::kSuccess) { + ProjectSerializer::paste(ProjectSerializer::k_only_markers); + if (res == ProjectSerializer::k_success) { const std::vector &markers = - res.GetLoadData().markers; + res.get_load_data().markers; if (!markers.empty()) { MultiUndoCommand *command = new MultiUndoCommand(); // Normalize markers to start at playhead - rational min = RATIONAL_MAX; + Rational min = RATIONAL_MAX; for (auto it = markers.cbegin(); it != markers.cend(); it++) { min = std::min(min, (*it)->time().in()); } - min -= GetViewerNode()->GetPlayhead(); + min -= get_viewer_node()->get_playhead(); for (auto it = markers.cbegin(); it != markers.cend(); it++) { TimelineMarker *m = *it; @@ -176,7 +176,7 @@ bool SeekableWidget::PasteMarkers() m->set_time(m->time().in() - min); if (TimelineMarker *existing = - markers_->GetMarkerAtTime(m->time().in())) { + markers_->get_marker_at_time(m->time().in())) { command->add_child(new MarkerRemoveCommand(existing)); } @@ -196,106 +196,106 @@ void SeekableWidget::mousePressEvent(QMouseEvent *event) { TimelineMarker *initial; - if (HandPress(event)) { + if (hand_press(event)) { return; } else if (event->modifiers() & Qt::ControlModifier) { - selection_manager_.RubberBandStart(event); + selection_manager_.rubber_band_start(event); } else if (marker_editing_enabled_ && - (initial = selection_manager_.MousePress(event))) { - selection_manager_.DragStart(initial, event); + (initial = selection_manager_.mouse_press(event))) { + selection_manager_.drag_start(initial, event); } else if (resize_item_) { // Handle selection, even though we won't be using it for dragging if (!(event->modifiers() & Qt::ShiftModifier)) { - selection_manager_.ClearSelection(); + selection_manager_.clear_selection(); } if (TimelineMarker *m = dynamic_cast(resize_item_)) { - selection_manager_.Select(m); + selection_manager_.select(m); } dragging_ = true; resize_start_ = mapToScene(event->pos()); - } else if (!selection_manager_.GetObjectAtPoint(event->pos()) && + } else if (!selection_manager_.get_object_at_point(event->pos()) && event->button() == Qt::LeftButton) { - SeekToScenePoint(mapToScene(event->pos()).x()); + seek_to_scene_point(mapToScene(event->pos()).x()); dragging_ = true; - DeselectAllMarkers(); + deselect_all_markers(); } } void SeekableWidget::mouseMoveEvent(QMouseEvent *event) { - if (HandMove(event)) { + if (hand_move(event)) { return; - } else if (selection_manager_.IsRubberBanding()) { - selection_manager_.RubberBandMove(event->pos()); + } else if (selection_manager_.is_rubber_banding()) { + selection_manager_.rubber_band_move(event->pos()); viewport()->update(); - } else if (selection_manager_.IsDragging()) { - selection_manager_.DragMove(event->pos()); + } else if (selection_manager_.is_dragging()) { + selection_manager_.drag_move(event->pos()); } else if (dragging_) { QPointF scene = mapToScene(event->pos()); if (resize_item_) { - DragResizeHandle(scene); + drag_resize_handle(scene); } else { - SeekToScenePoint(scene.x()); + seek_to_scene_point(scene.x()); } } else { // Look for resize points if (!last_playhead_shape_.containsPoint(event->pos(), Qt::OddEvenFill) && - !selection_manager_.GetObjectAtPoint(event->pos()) && - FindResizeHandle(event)) { + !selection_manager_.get_object_at_point(event->pos()) && + find_resize_handle(event)) { setCursor(Qt::SizeHorCursor); } else { unsetCursor(); - ClearResizeHandle(); + clear_resize_handle(); } } if (event->buttons()) { // Signal cursor pos in case we should scroll to catch up to it - emit DragMoved(event->pos().x(), event->pos().y()); + emit drag_moved(event->pos().x(), event->pos().y()); } } void SeekableWidget::mouseReleaseEvent(QMouseEvent *event) { - if (HandRelease(event)) { + if (hand_release(event)) { return; } - if (selection_manager_.IsRubberBanding()) { - selection_manager_.RubberBandStop(); + if (selection_manager_.is_rubber_banding()) { + selection_manager_.rubber_band_stop(); return; } - if (selection_manager_.IsDragging()) { + if (selection_manager_.is_dragging()) { MultiUndoCommand *command = new MultiUndoCommand(); - selection_manager_.DragStop(command); + selection_manager_.drag_stop(command); Core::instance()->undo_stack()->push( command, tr("Moved %1 Marker(s)") - .arg(selection_manager_.GetSelectedObjects().size())); + .arg(selection_manager_.get_selected_objects().size())); } - if (GetSnapService()) { - GetSnapService()->HideSnaps(); + if (get_snap_service()) { + get_snap_service()->hide_snaps(); } if (resize_item_) { - CommitResizeHandle(); + commit_resize_handle(); resize_item_ = nullptr; } dragging_ = false; - emit DragReleased(); + emit drag_released(); } void SeekableWidget::mouseDoubleClickEvent(QMouseEvent *event) { super::mouseDoubleClickEvent(event); - if (selection_manager_.GetObjectAtPoint(event->pos()) && - !selection_manager_.GetSelectedObjects().empty()) { - ShowMarkerProperties(); + if (selection_manager_.get_object_at_point(event->pos()) && + !selection_manager_.get_selected_objects().empty()) { + show_marker_properties(); } } @@ -307,28 +307,28 @@ void SeekableWidget::focusOutEvent(QFocusEvent *event) ignore_next_focus_out_ = false; } else { // Deselect everything when we lose focus - DeselectAllMarkers(); + deselect_all_markers(); } } -void SeekableWidget::DrawMarkers(QPainter *p, int marker_bottom) +void SeekableWidget::draw_markers(QPainter *p, int marker_bottom) { - selection_manager_.ClearDrawnObjects(); + selection_manager_.clear_drawn_objects(); // Draw markers if (markers_ && !markers_->empty() && marker_bottom > 0) { - int lim_left = GetLeftLimit(); - int lim_right = GetRightLimit(); + int lim_left = get_left_limit(); + int lim_right = get_right_limit(); for (auto it = markers_->cbegin(); it != markers_->cend(); it++) { TimelineMarker *marker = *it; - int marker_right = TimeToScene(marker->time().out()); + int marker_right = time_to_scene(marker->time().out()); if (marker_right < lim_left) { continue; } - int marker_left = TimeToScene(marker->time().in()); + int marker_left = time_to_scene(marker->time().in()); if (marker_left >= lim_right) { break; } @@ -341,36 +341,36 @@ void SeekableWidget::DrawMarkers(QPainter *p, int marker_bottom) if (next != markers_->cend()) { max_marker_right = std::min(max_marker_right, - int(TimeToScene((*next)->time().in()))); + int(time_to_scene((*next)->time().in()))); } } - QRect marker_rect = marker->Draw( + QRect marker_rect = marker->draw( p, QPoint(marker_left, marker_bottom), max_marker_right, - GetScale(), selection_manager_.IsSelected(marker)); + get_scale(), selection_manager_.is_selected(marker)); marker_top_ = marker_rect.top(); - selection_manager_.DeclareDrawnObject(marker, marker_rect); + selection_manager_.declare_drawn_object(marker, marker_rect); } } marker_bottom_ = marker_bottom; } -void SeekableWidget::DrawWorkArea(QPainter *p) +void SeekableWidget::draw_work_area(QPainter *p) { // Draw in/out workarea if (workarea_ && workarea_->enabled()) { - int lim_left = GetLeftLimit(); - int lim_right = GetRightLimit(); + int lim_left = get_left_limit(); + int lim_right = get_right_limit(); - int workarea_left = qMax(qreal(lim_left), TimeToScene(workarea_->in())); + int workarea_left = qMax(qreal(lim_left), time_to_scene(workarea_->in())); int workarea_right; - if (workarea_->out() == TimelineWorkArea::kResetOut) { + if (workarea_->out() == TimelineWorkArea::k_reset_out) { workarea_right = lim_right; } else { workarea_right = - qMin(qreal(lim_right), TimeToScene(workarea_->out())); + qMin(qreal(lim_right), time_to_scene(workarea_->out())); } QColor translucent_highlight = palette().highlight().color(); @@ -380,62 +380,62 @@ void SeekableWidget::DrawWorkArea(QPainter *p) } } -void SeekableWidget::DeselectAllMarkers() +void SeekableWidget::deselect_all_markers() { - selection_manager_.ClearSelection(); + selection_manager_.clear_selection(); viewport()->update(); } -void SeekableWidget::SetMarkerColor(int c) +void SeekableWidget::set_marker_color(int c) { MultiUndoCommand *command = new MultiUndoCommand(); - foreach (TimelineMarker *marker, selection_manager_.GetSelectedObjects()) { + foreach (TimelineMarker *marker, selection_manager_.get_selected_objects()) { command->add_child(new MarkerChangeColorCommand(marker, c)); } Core::instance()->undo_stack()->push( command, tr("Changed Color of %1 Marker(s)") - .arg(selection_manager_.GetSelectedObjects().size())); + .arg(selection_manager_.get_selected_objects().size())); } -void SeekableWidget::ShowMarkerProperties() +void SeekableWidget::show_marker_properties() { - MarkerPropertiesDialog mpd(selection_manager_.GetSelectedObjects(), + MarkerPropertiesDialog mpd(selection_manager_.get_selected_objects(), timebase(), this); ignore_next_focus_out_ = true; mpd.exec(); } -void SeekableWidget::TimebaseChangedEvent(const rational &t) +void SeekableWidget::TimebaseChangedEvent(const Rational &t) { super::TimebaseChangedEvent(t); - selection_manager_.SetTimebase(t); + selection_manager_.set_timebase(t); } -void SeekableWidget::SeekToScenePoint(qreal scene) +void SeekableWidget::seek_to_scene_point(qreal scene) { if (timebase().isNull()) { return; } - rational playhead_time = qMax(rational(0), SceneToTime(scene)); + Rational playhead_time = qMax(Rational(0), scene_to_time(scene)); - if (Core::instance()->snapping() && GetSnapService()) { - rational movement; + if (Core::instance()->snapping() && get_snap_service()) { + Rational movement; - GetSnapService()->SnapPoint({ playhead_time }, &movement, - TimeBasedWidget::kSnapAll & - ~TimeBasedWidget::kSnapToPlayhead); + get_snap_service()->snap_point({ playhead_time }, &movement, + TimeBasedWidget::k_snap_all & + ~TimeBasedWidget::k_snap_to_playhead); playhead_time += movement; } - ViewerOutput *viewer = GetViewerNode(); - if (viewer && playhead_time != viewer->GetPlayhead()) { - viewer->SetPlayhead(playhead_time); + ViewerOutput *viewer = get_viewer_node(); + if (viewer && playhead_time != viewer->get_playhead()) { + viewer->set_playhead(playhead_time); } } @@ -457,15 +457,15 @@ void SeekableWidget::CatchUpScrollEvent() { super::CatchUpScrollEvent(); - this->selection_manager_.ForceDragUpdate(); + this->selection_manager_.force_drag_update(); } -void SeekableWidget::DrawPlayhead(QPainter *p, int x, int y) +void SeekableWidget::draw_playhead(QPainter *p, int x, int y) { int half_width = playhead_width_ / 2; { - int test = x - this->GetScroll(); + int test = x - this->get_scroll(); if (test + half_width < 0 || test - half_width > width()) { return; } @@ -489,37 +489,37 @@ void SeekableWidget::DrawPlayhead(QPainter *p, int x, int y) p->setRenderHint(QPainter::Antialiasing, false); } -int SeekableWidget::GetLeftLimit() const +int SeekableWidget::get_left_limit() const { - return GetScroll(); + return get_scroll(); } -int SeekableWidget::GetRightLimit() const +int SeekableWidget::get_right_limit() const { - return GetLeftLimit() + width(); + return get_left_limit() + width(); } -bool SeekableWidget::ShowContextMenu(const QPoint &p) +bool SeekableWidget::show_context_menu(const QPoint &p) { - if (marker_editing_enabled_ && selection_manager_.GetObjectAtPoint(p) && - !selection_manager_.GetSelectedObjects().empty()) { + if (marker_editing_enabled_ && selection_manager_.get_object_at_point(p) && + !selection_manager_.get_selected_objects().empty()) { // Show marker-specific menu Menu m; ColorLabelMenu color_coding_menu; - connect(&color_coding_menu, &ColorLabelMenu::ColorSelected, this, - &SeekableWidget::SetMarkerColor); + connect(&color_coding_menu, &ColorLabelMenu::color_selected, this, + &SeekableWidget::set_marker_color); m.addMenu(&color_coding_menu); m.addSeparator(); - MenuShared::instance()->AddItemsForEditMenu(&m, false); + MenuShared::instance()->add_items_for_edit_menu(&m, false); m.addSeparator(); QAction *properties_action = m.addAction(tr("Properties")); connect(properties_action, &QAction::triggered, this, - &SeekableWidget::ShowMarkerProperties); + &SeekableWidget::show_marker_properties); ignore_next_focus_out_ = true; m.exec(mapToGlobal(p)); @@ -529,34 +529,34 @@ bool SeekableWidget::ShowContextMenu(const QPoint &p) } } -bool SeekableWidget::FindResizeHandle(QMouseEvent *event) +bool SeekableWidget::find_resize_handle(QMouseEvent *event) { if (!marker_editing_enabled_) { return false; } - ClearResizeHandle(); + clear_resize_handle(); QPointF scene = mapToScene(event->pos()); const int border = 10; - rational min = SceneToTimeNoGrid(scene.x() - border); - rational max = SceneToTimeNoGrid(scene.x() + border); + Rational min = scene_to_time_no_grid(scene.x() - border); + Rational max = scene_to_time_no_grid(scene.x() + border); // Test for workarea if (workarea_ && workarea_->enabled()) { if (workarea_->in() >= min && workarea_->in() < max) { - resize_mode_ = kResizeIn; + resize_mode_ = k_resize_in; } else if (workarea_->out() >= min && workarea_->out() < max) { - resize_mode_ = kResizeOut; + resize_mode_ = k_resize_out; } } - if (resize_mode_ != kResizeNone) { + if (resize_mode_ != k_resize_none) { if (workarea_) { resize_item_ = workarea_; resize_item_range_ = workarea_->range(); - resize_snap_mask_ = TimeBasedWidget::kSnapAll & - ~TimeBasedWidget::kSnapToWorkarea; + resize_snap_mask_ = TimeBasedWidget::k_snap_all & + ~TimeBasedWidget::k_snap_to_workarea; } } else if (event->pos().y() >= marker_top_ && event->pos().y() < marker_bottom_) { @@ -566,16 +566,16 @@ bool SeekableWidget::FindResizeHandle(QMouseEvent *event) TimelineMarker *m = *it; if (m->time().in() != m->time().out()) { if (m->time().in() >= min && m->time().in() < max) { - resize_mode_ = kResizeIn; + resize_mode_ = k_resize_in; } else if (m->time().out() >= min && m->time().out() < max) { - resize_mode_ = kResizeOut; + resize_mode_ = k_resize_out; } - if (resize_mode_ != kResizeNone) { + if (resize_mode_ != k_resize_none) { resize_item_ = m; resize_item_range_ = m->time(); - resize_snap_mask_ = TimeBasedWidget::kSnapAll; + resize_snap_mask_ = TimeBasedWidget::k_snap_all; break; } } @@ -586,41 +586,41 @@ bool SeekableWidget::FindResizeHandle(QMouseEvent *event) return resize_item_; } -void SeekableWidget::ClearResizeHandle() +void SeekableWidget::clear_resize_handle() { resize_item_ = nullptr; - resize_mode_ = kResizeNone; + resize_mode_ = k_resize_none; } -void SeekableWidget::DragResizeHandle(const QPointF &scene) +void SeekableWidget::drag_resize_handle(const QPointF &scene) { qreal diff = scene.x() - resize_start_.x(); - rational proposed_time; + Rational proposed_time; - if (resize_mode_ == kResizeIn) { - proposed_time = qMax(rational(0), qMin(resize_item_range_.out(), + if (resize_mode_ == k_resize_in) { + proposed_time = qMax(Rational(0), qMin(resize_item_range_.out(), resize_item_range_.in() + - SceneToTimeNoGrid(diff))); + scene_to_time_no_grid(diff))); } else { proposed_time = qMax(resize_item_range_.in(), - resize_item_range_.out() + SceneToTimeNoGrid(diff)); + resize_item_range_.out() + scene_to_time_no_grid(diff)); } - rational presnap_time = proposed_time; + Rational presnap_time = proposed_time; - if (Core::instance()->snapping() && GetSnapService()) { - rational movement; + if (Core::instance()->snapping() && get_snap_service()) { + Rational movement; - GetSnapService()->SnapPoint({ proposed_time }, &movement, + get_snap_service()->snap_point({ proposed_time }, &movement, resize_snap_mask_); proposed_time += movement; } TimeRange new_range = resize_item_range_; - if (resize_mode_ == kResizeIn) { + if (resize_mode_ == k_resize_in) { // Markers should not have the same time as anything else // NOTE: This code is largely duplicated from TimeBasedViewSelectionManager::DragMove. Not ideal, // but I'm not sure if there's a good way to re-use that code @@ -629,13 +629,13 @@ void SeekableWidget::DragResizeHandle(const QPointF &scene) if (marker->has_sibling_at_time(proposed_time)) { proposed_time = presnap_time; - if (GetSnapService()) { - GetSnapService()->HideSnaps(); + if (get_snap_service()) { + get_snap_service()->hide_snaps(); } } while (marker->has_sibling_at_time(proposed_time)) { - proposed_time += rational(1, 1000); + proposed_time += Rational(1, 1000); } } @@ -652,7 +652,7 @@ void SeekableWidget::DragResizeHandle(const QPointF &scene) } } -void SeekableWidget::CommitResizeHandle() +void SeekableWidget::commit_resize_handle() { MultiUndoCommand *command = new MultiUndoCommand(); diff --git a/app/widget/timeruler/seekablewidget.h b/app/widget/timeruler/seekablewidget.h index c17dec9b0..9216be593 100644 --- a/app/widget/timeruler/seekablewidget.h +++ b/app/widget/timeruler/seekablewidget.h @@ -19,8 +19,8 @@ ***/ -#ifndef SEEKABLEWIDGET_H -#define SEEKABLEWIDGET_H +#ifndef OAK_SEEKABLEWIDGET_H +#define OAK_SEEKABLEWIDGET_H #include #include @@ -36,55 +36,55 @@ class SeekableWidget : public TimeBasedView { public: SeekableWidget(QWidget *parent = nullptr); - int GetScroll() const + int get_scroll() const { return horizontalScrollBar()->value(); } - TimelineMarkerList *GetMarkers() const + TimelineMarkerList *get_markers() const { return markers_; } - TimelineWorkArea *GetWorkArea() const + TimelineWorkArea *get_work_area() const { return workarea_; } - void SetMarkers(TimelineMarkerList *markers); - void SetWorkArea(TimelineWorkArea *workarea); + void set_markers(TimelineMarkerList *markers); + void set_work_area(TimelineWorkArea *workarea); - virtual bool IsDraggingPlayhead() const override + virtual bool is_dragging_playhead() const override { return dragging_; } - bool IsMarkerEditingEnabled() const + bool is_marker_editing_enabled() const { return marker_editing_enabled_; } - void SetMarkerEditingEnabled(bool e) + void set_marker_editing_enabled(bool e) { marker_editing_enabled_ = e; } - void DeleteSelected(); + void delete_selected(); - bool CopySelected(bool cut); + bool copy_selected(bool cut); - bool PasteMarkers(); + bool paste_markers(); - void DeselectAllMarkers(); + void deselect_all_markers(); - void SeekToScenePoint(qreal scene); + void seek_to_scene_point(qreal scene); - bool HasItemsSelected() const + bool has_items_selected() const { - return !selection_manager_.GetSelectedObjects().empty(); + return !selection_manager_.get_selected_objects().empty(); } - const std::vector &GetSelectedMarkers() const + const std::vector &get_selected_markers() const { - return selection_manager_.GetSelectedObjects(); + return selection_manager_.get_selected_objects(); } virtual void SelectionManagerSelectEvent(void *obj) override; @@ -93,17 +93,17 @@ public: virtual void CatchUpScrollEvent() override; public slots: - void SetScroll(int i) + void set_scroll(int i) { horizontalScrollBar()->setValue(i); } - virtual void TimebaseChangedEvent(const rational &) override; + virtual void TimebaseChangedEvent(const Rational &) override; signals: - void DragMoved(int x, int y); + void drag_moved(int x, int y); - void DragReleased(); + void drag_released(); protected: virtual void mousePressEvent(QMouseEvent *event) override; @@ -113,10 +113,10 @@ protected: virtual void focusOutEvent(QFocusEvent *event) override; - void DrawMarkers(QPainter *p, int marker_bottom = 0); - void DrawWorkArea(QPainter *p); + void draw_markers(QPainter *p, int marker_bottom = 0); + void draw_work_area(QPainter *p); - void DrawPlayhead(QPainter *p, int x, int y); + void draw_playhead(QPainter *p, int x, int y); inline const int &text_height() const { @@ -128,22 +128,22 @@ protected: return playhead_width_; } - int GetLeftLimit() const; - int GetRightLimit() const; + int get_left_limit() const; + int get_right_limit() const; protected slots: - virtual bool ShowContextMenu(const QPoint &p); + virtual bool show_context_menu(const QPoint &p); private: - enum ResizeMode { kResizeNone, kResizeIn, kResizeOut }; + enum ResizeMode { k_resize_none, k_resize_in, k_resize_out }; - bool FindResizeHandle(QMouseEvent *event); + bool find_resize_handle(QMouseEvent *event); - void ClearResizeHandle(); + void clear_resize_handle(); - void DragResizeHandle(const QPointF &scene_pos); + void drag_resize_handle(const QPointF &scene_pos); - void CommitResizeHandle(); + void commit_resize_handle(); TimelineMarkerList *markers_; TimelineWorkArea *workarea_; @@ -172,11 +172,11 @@ private: QPolygon last_playhead_shape_; private slots: - void SetMarkerColor(int c); + void set_marker_color(int c); - void ShowMarkerProperties(); + void show_marker_properties(); }; } -#endif // SEEKABLEWIDGET_H +#endif // OAK_SEEKABLEWIDGET_H diff --git a/app/widget/timeruler/timeruler.cpp b/app/widget/timeruler/timeruler.cpp index cb2d3b02f..7958990f6 100644 --- a/app/widget/timeruler/timeruler.cpp +++ b/app/widget/timeruler/timeruler.cpp @@ -51,18 +51,18 @@ TimeRuler::TimeRuler(bool text_visible, bool cache_status_visible, // Get the "minimum" space allowed between two line markers on the ruler (in screen pixels) // Mediocre but reliable way of scaling UI objects by font/DPI size - minimum_gap_between_lines_ = QtUtils::QFontMetricsWidth(fm, "H"); + minimum_gap_between_lines_ = QtUtils::q_font_metrics_width(fm, "H"); // Text visibility affects height, so we set that here - UpdateHeight(); + update_height(); // Force update if the default timecode display mode changes - connect(Core::instance(), &Core::TimecodeDisplayChanged, this, + connect(Core::instance(), &Core::timecode_display_changed, this, static_cast(&TimeRuler::update)); // Connect context menu connect(this, &TimeRuler::customContextMenuRequested, this, - &TimeRuler::ShowContextMenu); + &TimeRuler::show_context_menu); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //horizontalScrollBar()->setVisible(false); @@ -76,32 +76,32 @@ TimeRuler::TimeRuler(bool text_visible, bool cache_status_visible, setAlignment(Qt::AlignLeft | Qt::AlignTop); } -void TimeRuler::SetCenteredText(bool c) +void TimeRuler::set_centered_text(bool c) { centered_text_ = c; update(); } -void TimeRuler::SetPlaybackCache(PlaybackCache *cache) +void TimeRuler::set_playback_cache(PlaybackCache *cache) { if (!show_cache_status_) { return; } if (playback_cache_) { - disconnect(playback_cache_, &PlaybackCache::Invalidated, viewport(), + disconnect(playback_cache_, &PlaybackCache::invalidated, viewport(), static_cast(&QWidget::update)); - disconnect(playback_cache_, &PlaybackCache::Validated, viewport(), + disconnect(playback_cache_, &PlaybackCache::validated, viewport(), static_cast(&QWidget::update)); } playback_cache_ = cache; if (playback_cache_) { - connect(playback_cache_, &PlaybackCache::Invalidated, viewport(), + connect(playback_cache_, &PlaybackCache::invalidated, viewport(), static_cast(&QWidget::update)); - connect(playback_cache_, &PlaybackCache::Validated, viewport(), + connect(playback_cache_, &PlaybackCache::validated, viewport(), static_cast(&QWidget::update)); } @@ -116,16 +116,16 @@ void TimeRuler::drawForeground(QPainter *p, const QRectF &rect) } // Draw timeline points if connected - int marker_height = TimelineMarker::GetMarkerHeight(p->fontMetrics()); - DrawWorkArea(p); - DrawMarkers(p, marker_height); + int marker_height = TimelineMarker::get_marker_height(p->fontMetrics()); + draw_work_area(p); + draw_markers(p, marker_height); - double width_of_frame = timebase_dbl() * GetScale(); + double width_of_frame = timebase_dbl() * get_scale(); double width_of_second = 0; do { width_of_second += timebase_dbl(); } while (width_of_second < 1.0); - width_of_second *= GetScale(); + width_of_second *= get_scale(); double width_of_minute = width_of_second * 60; double width_of_hour = width_of_minute * 60; double width_of_day = width_of_hour * 24; @@ -195,7 +195,7 @@ void TimeRuler::drawForeground(QPainter *p, const QRectF &rect) int line_bottom = height(); if (show_cache_status_) { - line_bottom -= PlaybackCache::GetCacheIndicatorHeight(); + line_bottom -= PlaybackCache::get_cache_indicator_height(); } int long_height = fm.height(); @@ -209,10 +209,10 @@ void TimeRuler::drawForeground(QPainter *p, const QRectF &rect) int last_text_draw = INT_MIN; // FIXME: Hardcoded number - const int kAverageTextWidth = 200; + const int k_average_text_width = 200; - for (int i = GetScroll() - kAverageTextWidth; - i < GetScroll() + width() + kAverageTextWidth; i++) { + for (int i = get_scroll() - k_average_text_width; + i < get_scroll() + width() + k_average_text_width; i++) { double screen_pt = static_cast(i); if (long_interval > -1) { @@ -225,20 +225,20 @@ void TimeRuler::drawForeground(QPainter *p, const QRectF &rect) Qt::Alignment text_align; QString timecode_str = QString::fromStdString(Timecode::time_to_timecode( - SceneToTime(i), timebase(), - Core::instance()->GetTimecodeDisplay())); + scene_to_time(i), timebase(), + Core::instance()->get_timecode_display())); int timecode_width = - QtUtils::QFontMetricsWidth(fm, timecode_str); + QtUtils::q_font_metrics_width(fm, timecode_str); int timecode_left; if (centered_text_) { - text_rect = QRect(i - kAverageTextWidth / 2, - marker_height, kAverageTextWidth, + text_rect = QRect(i - k_average_text_width / 2, + marker_height, k_average_text_width, fm.height()); text_align = Qt::AlignCenter; timecode_left = i - timecode_width / 2; } else { - text_rect = QRect(i, marker_height, kAverageTextWidth, + text_rect = QRect(i, marker_height, k_average_text_width, fm.height()); text_align = Qt::AlignLeft | Qt::AlignVCenter; timecode_left = i; @@ -275,53 +275,53 @@ void TimeRuler::drawForeground(QPainter *p, const QRectF &rect) // If cache status is enabled if (show_cache_status_ && playback_cache_ && - playback_cache_->HasValidatedRanges()) { + playback_cache_->has_validated_ranges()) { // FIXME: Hardcoded to get video length, if we ever need audio length, this will have to change - int h = PlaybackCache::GetCacheIndicatorHeight(); + int h = PlaybackCache::get_cache_indicator_height(); QRect cache_rect(0, height() - h, width(), h); if (ViewerOutput *viewer = dynamic_cast(playback_cache_->parent())) { - int right = TimeToScene(viewer->GetVideoLength()); + int right = time_to_scene(viewer->get_video_length()); cache_rect.setWidth(std::max(0, right)); } if (cache_rect.width() > 0) { - playback_cache_->Draw(p, SceneToTime(GetScroll()), GetScale(), + playback_cache_->draw(p, scene_to_time(get_scroll()), get_scale(), cache_rect); } } // Draw the playhead if it's on screen at the moment - int playhead_pos = TimeToScene(GetViewerNode()->GetPlayhead()); + int playhead_pos = time_to_scene(get_viewer_node()->get_playhead()); p->setPen(Qt::NoPen); p->setBrush(PLAYHEAD_COLOR); - DrawPlayhead(p, playhead_pos, line_bottom); + draw_playhead(p, playhead_pos, line_bottom); } -void TimeRuler::TimebaseChangedEvent(const rational &tb) +void TimeRuler::TimebaseChangedEvent(const Rational &tb) { super::TimebaseChangedEvent(tb); - timebase_flipped_dbl_ = tb.flipped().toDouble(); + timebase_flipped_dbl_ = tb.flipped().to_double(); update(); } -int TimeRuler::CacheStatusHeight() const +int TimeRuler::cache_status_height() const { return fontMetrics().height() / 4; } -bool TimeRuler::ShowContextMenu(const QPoint &p) +bool TimeRuler::show_context_menu(const QPoint &p) { - if (super::ShowContextMenu(p)) { + if (super::show_context_menu(p)) { return true; } else { Menu m(this); - MenuShared::instance()->AddItemsForTimeRulerMenu(&m); - MenuShared::instance()->AboutToShowTimeRulerActions(timebase()); + MenuShared::instance()->add_items_for_time_ruler_menu(&m); + MenuShared::instance()->about_to_show_time_ruler_actions(timebase()); m.exec(mapToGlobal(p)); @@ -329,7 +329,7 @@ bool TimeRuler::ShowContextMenu(const QPoint &p) } } -void TimeRuler::UpdateHeight() +void TimeRuler::update_height() { int height = text_height(); @@ -340,11 +340,11 @@ void TimeRuler::UpdateHeight() // Add cache status height if (show_cache_status_) { - height += PlaybackCache::GetCacheIndicatorHeight(); + height += PlaybackCache::get_cache_indicator_height(); } // Add marker height - height += TimelineMarker::GetMarkerHeight(fontMetrics()); + height += TimelineMarker::get_marker_height(fontMetrics()); setFixedHeight(height); } diff --git a/app/widget/timeruler/timeruler.h b/app/widget/timeruler/timeruler.h index 796f4dc4c..c57a3e077 100644 --- a/app/widget/timeruler/timeruler.h +++ b/app/widget/timeruler/timeruler.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMERULER_H -#define TIMERULER_H +#ifndef OAK_TIMERULER_H +#define OAK_TIMERULER_H #include #include @@ -37,22 +37,22 @@ public: TimeRuler(bool text_visible = true, bool cache_status_visible = false, QWidget *parent = nullptr); - void SetCenteredText(bool c); + void set_centered_text(bool c); - void SetPlaybackCache(PlaybackCache *cache); + void set_playback_cache(PlaybackCache *cache); protected: virtual void drawForeground(QPainter *painter, const QRectF &rect) override; - virtual void TimebaseChangedEvent(const rational &tb) override; + virtual void TimebaseChangedEvent(const Rational &tb) override; protected slots: - virtual bool ShowContextMenu(const QPoint &p) override; + virtual bool show_context_menu(const QPoint &p) override; private: - void UpdateHeight(); + void update_height(); - int CacheStatusHeight() const; + int cache_status_height() const; int minimum_gap_between_lines_; @@ -69,4 +69,4 @@ private: } -#endif // TIMERULER_H +#endif // OAK_TIMERULER_H diff --git a/app/widget/timetarget/timetarget.cpp b/app/widget/timetarget/timetarget.cpp index 6ab4f6e72..d85b4068c 100644 --- a/app/widget/timetarget/timetarget.cpp +++ b/app/widget/timetarget/timetarget.cpp @@ -30,12 +30,12 @@ TimeTargetObject::TimeTargetObject() { } -ViewerOutput *TimeTargetObject::GetTimeTarget() const +ViewerOutput *TimeTargetObject::get_time_target() const { return time_target_; } -void TimeTargetObject::SetTimeTarget(ViewerOutput *target) +void TimeTargetObject::set_time_target(ViewerOutput *target) { if (time_target_) { TimeTargetDisconnectEvent(time_target_); @@ -49,31 +49,31 @@ void TimeTargetObject::SetTimeTarget(ViewerOutput *target) } } -void TimeTargetObject::SetPathIndex(int index) +void TimeTargetObject::set_path_index(int index) { path_index_ = index; } -rational -TimeTargetObject::GetAdjustedTime(Node *from, Node *to, const rational &r, +Rational +TimeTargetObject::get_adjusted_time(Node *from, Node *to, const Rational &r, Node::TransformTimeDirection dir) const { if (!from || !to) { return r; } - return GetAdjustedTime(from, to, TimeRange(r, r), dir).in(); + return get_adjusted_time(from, to, TimeRange(r, r), dir).in(); } TimeRange -TimeTargetObject::GetAdjustedTime(Node *from, Node *to, const TimeRange &r, +TimeTargetObject::get_adjusted_time(Node *from, Node *to, const TimeRange &r, Node::TransformTimeDirection dir) const { if (!from || !to) { return r; } - return from->TransformTimeTo(r, to, dir, path_index_); + return from->transform_time_to(r, to, dir, path_index_); } /*int TimeTargetObject::GetNumberOfPathAdjustments(Node* from, NodeParam::Type direction) const diff --git a/app/widget/timetarget/timetarget.h b/app/widget/timetarget/timetarget.h index b303193a5..ace120983 100644 --- a/app/widget/timetarget/timetarget.h +++ b/app/widget/timetarget/timetarget.h @@ -19,8 +19,8 @@ ***/ -#ifndef TIMETARGETOBJECT_H -#define TIMETARGETOBJECT_H +#ifndef OAK_TIMETARGETOBJECT_H +#define OAK_TIMETARGETOBJECT_H #include "node/output/viewer/viewer.h" @@ -31,14 +31,14 @@ class TimeTargetObject { public: TimeTargetObject(); - ViewerOutput *GetTimeTarget() const; - void SetTimeTarget(ViewerOutput *target); + ViewerOutput *get_time_target() const; + void set_time_target(ViewerOutput *target); - void SetPathIndex(int index); + void set_path_index(int index); - rational GetAdjustedTime(Node *from, Node *to, const rational &r, + Rational get_adjusted_time(Node *from, Node *to, const Rational &r, Node::TransformTimeDirection dir) const; - TimeRange GetAdjustedTime(Node *from, Node *to, const TimeRange &r, + TimeRange get_adjusted_time(Node *from, Node *to, const TimeRange &r, Node::TransformTimeDirection dir) const; //int GetNumberOfPathAdjustments(Node* from, NodeParam::Type direction) const; @@ -62,4 +62,4 @@ private: } -#endif // TIMETARGETOBJECT_H +#endif // OAK_TIMETARGETOBJECT_H diff --git a/app/widget/toolbar/toolbar.cpp b/app/widget/toolbar/toolbar.cpp index 5c487496a..32d4f61b0 100644 --- a/app/widget/toolbar/toolbar.cpp +++ b/app/widget/toolbar/toolbar.cpp @@ -44,37 +44,37 @@ Toolbar::Toolbar(QWidget *parent) layout_->setContentsMargins(0, 0, 0, 0); // Create standard tool buttons - btn_pointer_tool_ = CreateToolButton(Tool::kPointer); - btn_trackselect_tool_ = CreateToolButton(Tool::kTrackSelect); - btn_edit_tool_ = CreateToolButton(Tool::kEdit); - btn_ripple_tool_ = CreateToolButton(Tool::kRipple); - btn_rolling_tool_ = CreateToolButton(Tool::kRolling); - btn_razor_tool_ = CreateToolButton(Tool::kRazor); - btn_slip_tool_ = CreateToolButton(Tool::kSlip); - btn_slide_tool_ = CreateToolButton(Tool::kSlide); - btn_hand_tool_ = CreateToolButton(Tool::kHand); - btn_zoom_tool_ = CreateToolButton(Tool::kZoom); - btn_record_ = CreateToolButton(Tool::kRecord); - btn_transition_tool_ = CreateToolButton(Tool::kTransition); - btn_add_ = CreateToolButton(Tool::kAdd); + btn_pointer_tool_ = create_tool_button(Tool::k_pointer); + btn_trackselect_tool_ = create_tool_button(Tool::k_track_select); + btn_edit_tool_ = create_tool_button(Tool::k_edit); + btn_ripple_tool_ = create_tool_button(Tool::k_ripple); + btn_rolling_tool_ = create_tool_button(Tool::k_rolling); + btn_razor_tool_ = create_tool_button(Tool::k_razor); + btn_slip_tool_ = create_tool_button(Tool::k_slip); + btn_slide_tool_ = create_tool_button(Tool::k_slide); + btn_hand_tool_ = create_tool_button(Tool::k_hand); + btn_zoom_tool_ = create_tool_button(Tool::k_zoom); + btn_record_ = create_tool_button(Tool::k_record); + btn_transition_tool_ = create_tool_button(Tool::k_transition); + btn_add_ = create_tool_button(Tool::k_add); // Create snapping button, which is not actually a tool, it's a toggle option - btn_snapping_toggle_ = CreateNonToolButton(); + btn_snapping_toggle_ = create_non_tool_button(); connect(btn_snapping_toggle_, &QPushButton::clicked, this, - &Toolbar::SnappingButtonClicked); + &Toolbar::snapping_button_clicked); // Connect transition button to menu signal connect(btn_transition_tool_, &QPushButton::clicked, this, - &Toolbar::TransitionButtonClicked); + &Toolbar::transition_button_clicked); // Connect add button to menu signal - connect(btn_add_, &QPushButton::clicked, this, &Toolbar::AddButtonClicked); + connect(btn_add_, &QPushButton::clicked, this, &Toolbar::add_button_clicked); - Retranslate(); - UpdateIcons(); + retranslate(); + update_icons(); } -void Toolbar::SetTool(const Tool::Item &tool) +void Toolbar::set_tool(const Tool::Item &tool) { // For each tool, set the "checked" state to whether the button's tool is the current tool for (int i = 0; i < toolbar_btns_.size(); i++) { @@ -84,7 +84,7 @@ void Toolbar::SetTool(const Tool::Item &tool) } } -void Toolbar::SetSnapping(const bool &snapping) +void Toolbar::set_snapping(const bool &snapping) { // Set checked state of snapping toggle btn_snapping_toggle_->setChecked(snapping); @@ -93,9 +93,9 @@ void Toolbar::SetSnapping(const bool &snapping) void Toolbar::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } else if (e->type() == QEvent::StyleChange) { - UpdateIcons(); + update_icons(); } super::changeEvent(e); } @@ -105,15 +105,15 @@ void Toolbar::resizeEvent(QResizeEvent *e) super::resizeEvent(e); int min_height = toolbar_btns_.size() * toolbar_btns_.first()->height() + - (toolbar_btns_.size() - 1) * layout_->verticalSpacing(); + (toolbar_btns_.size() - 1) * layout_->vertical_spacing(); int new_height = e->size().height(); int columns_required = min_height / new_height + (min_height % new_height != 0); setMinimumWidth(toolbar_btns_.first()->width() * columns_required + - layout_->horizontalSpacing() * (columns_required - 1) + 1); + layout_->horizontal_spacing() * (columns_required - 1) + 1); } -void Toolbar::Retranslate() +void Toolbar::retranslate() { btn_pointer_tool_->setToolTip(tr("Pointer Tool")); btn_trackselect_tool_->setToolTip(tr("Track Select Tool")); @@ -131,25 +131,25 @@ void Toolbar::Retranslate() btn_snapping_toggle_->setToolTip(tr("Toggle Snapping")); } -void Toolbar::UpdateIcons() +void Toolbar::update_icons() { - btn_pointer_tool_->setIcon(icon::ToolPointer); - btn_trackselect_tool_->setIcon(icon::ToolTrackSelect); - btn_edit_tool_->setIcon(icon::ToolEdit); - btn_ripple_tool_->setIcon(icon::ToolRipple); - btn_rolling_tool_->setIcon(icon::ToolRolling); - btn_razor_tool_->setIcon(icon::ToolRazor); - btn_slip_tool_->setIcon(icon::ToolSlip); - btn_slide_tool_->setIcon(icon::ToolSlide); - btn_hand_tool_->setIcon(icon::ToolHand); - btn_zoom_tool_->setIcon(icon::ZoomIn); - btn_record_->setIcon(icon::Record); - btn_transition_tool_->setIcon(icon::ToolTransition); - btn_add_->setIcon(icon::Add); - btn_snapping_toggle_->setIcon(icon::Snapping); + btn_pointer_tool_->setIcon(icon::tool_pointer); + btn_trackselect_tool_->setIcon(icon::tool_track_select); + btn_edit_tool_->setIcon(icon::tool_edit); + btn_ripple_tool_->setIcon(icon::tool_ripple); + btn_rolling_tool_->setIcon(icon::tool_rolling); + btn_razor_tool_->setIcon(icon::tool_razor); + btn_slip_tool_->setIcon(icon::tool_slip); + btn_slide_tool_->setIcon(icon::tool_slide); + btn_hand_tool_->setIcon(icon::tool_hand); + btn_zoom_tool_->setIcon(icon::zoom_in); + btn_record_->setIcon(icon::record); + btn_transition_tool_->setIcon(icon::tool_transition); + btn_add_->setIcon(icon::add); + btn_snapping_toggle_->setIcon(icon::snapping); } -ToolbarButton *Toolbar::CreateToolButton(const Tool::Item &tool) +ToolbarButton *Toolbar::create_tool_button(const Tool::Item &tool) { // Create a ToolbarButton object ToolbarButton *b = new ToolbarButton(this, tool); @@ -161,15 +161,15 @@ ToolbarButton *Toolbar::CreateToolButton(const Tool::Item &tool) toolbar_btns_.append(b); // Connect it to the tool button click handler - connect(b, SIGNAL(clicked(bool)), this, SLOT(ToolButtonClicked())); + connect(b, SIGNAL(clicked(bool)), this, SLOT(tool_button_clicked())); return b; } -ToolbarButton *Toolbar::CreateNonToolButton() +ToolbarButton *Toolbar::create_non_tool_button() { // Create a ToolbarButton object - ToolbarButton *b = new ToolbarButton(this, Tool::kNone); + ToolbarButton *b = new ToolbarButton(this, Tool::k_none); // Add it to the layout layout_->addWidget(b); @@ -177,7 +177,7 @@ ToolbarButton *Toolbar::CreateNonToolButton() return b; } -void Toolbar::ToolButtonClicked() +void Toolbar::tool_button_clicked() { // Get new tool from ToolbarButton object Tool::Item new_tool = static_cast(sender())->tool(); @@ -187,37 +187,37 @@ void Toolbar::ToolButtonClicked() //SetTool(new_tool); // Emit signal that the tool just changed - emit ToolChanged(new_tool); + emit tool_changed(new_tool); } -void Toolbar::SnappingButtonClicked(bool b) +void Toolbar::snapping_button_clicked(bool b) { - emit SnappingChanged(b); + emit snapping_changed(b); } -void Toolbar::AddButtonClicked() +void Toolbar::add_button_clicked() { Menu m(this); - MenuShared::instance()->AddItemsForAddableObjectsMenu(&m); + MenuShared::instance()->add_items_for_addable_objects_menu(&m); m.exec(QCursor::pos()); } -void Toolbar::TransitionButtonClicked() +void Toolbar::transition_button_clicked() { - Menu *m = NodeFactory::CreateMenu(this, false, Node::kCategoryTransition); + Menu *m = NodeFactory::create_menu(this, false, Node::k_category_transition); - connect(m, &QMenu::triggered, this, &Toolbar::TransitionMenuItemTriggered); + connect(m, &QMenu::triggered, this, &Toolbar::transition_menu_item_triggered); m->exec(QCursor::pos()); delete m; } -void Toolbar::TransitionMenuItemTriggered(QAction *a) +void Toolbar::transition_menu_item_triggered(QAction *a) { - emit SelectedTransitionChanged(NodeFactory::GetIDFromMenuAction(a)); + emit selected_transition_changed(NodeFactory::GetIDFromMenuAction(a)); } } diff --git a/app/widget/toolbar/toolbar.h b/app/widget/toolbar/toolbar.h index 96ddc5ac5..3721e345d 100644 --- a/app/widget/toolbar/toolbar.h +++ b/app/widget/toolbar/toolbar.h @@ -19,8 +19,8 @@ ***/ -#ifndef TOOLBAR_H -#define TOOLBAR_H +#ifndef OAK_TOOLBAR_H +#define OAK_TOOLBAR_H #include @@ -37,8 +37,8 @@ namespace olive * Buttons are displayed in a FlowLayout that * adjusts and wraps (like text) depending on the widget's size. * - * By default, this Toolbar is not connected to anything. It's recommended to connect SLOT(SetTool()) and - * SIGNAL(ToolChanged()) to Core (corresponding SIGNAL(ToolChanged()) and SLOT(SetTool()) respectively) so that the + * By default, this Toolbar is not connected to anything. It's recommended to connect SLOT(set_tool()) and + * SIGNAL(tool_changed()) to Core (corresponding SIGNAL(tool_changed()) and SLOT(set_tool()) respectively) so that the * Toolbar updates the current tool application-wide, and is also automatically updated when the tool is changed * elsewhere. */ @@ -68,7 +68,7 @@ public slots: * * Tool to show as selected */ - void SetTool(const Tool::Item &tool); + void set_tool(const Tool::Item &tool); /** * @brief Set snapping checked value @@ -78,7 +78,7 @@ public slots: * * @param snapping */ - void SetSnapping(const bool &snapping); + void set_snapping(const bool &snapping); protected: /** @@ -100,7 +100,7 @@ signals: * * Tool that was selected */ - void ToolChanged(const Tool::Item &t); + void tool_changed(const Tool::Item &t); /** * @brief Emitted whenever the snapping setting is changed @@ -109,23 +109,23 @@ signals: * * New snapping enabled setting */ - void SnappingChanged(const bool &b); + void snapping_changed(const bool &b); /** * @brief Emitted when the selected transition is changed from the transition tool menu */ - void SelectedTransitionChanged(const QString &id); + void selected_transition_changed(const QString &id); private: /** * @brief Reset all strings based on the currently selected language */ - void Retranslate(); + void retranslate(); /** * @brief Update icons after a style change */ - void UpdateIcons(); + void update_icons(); /** * @brief Internal convenience function for creating tool buttons quickly @@ -140,7 +140,7 @@ private: * * The created ToolbarButton. The button parent is automatically set to `this`. */ - ToolbarButton *CreateToolButton(const Tool::Item &tool); + ToolbarButton *create_tool_button(const Tool::Item &tool); /** * @brief Internal convenience function for creating buttons quickly @@ -153,7 +153,7 @@ private: * * The created ToolbarButton. The button parent is automatically set to `this`. */ - ToolbarButton *CreateNonToolButton(); + ToolbarButton *create_non_tool_button(); /** * @brief Internal layout used for buttons @@ -193,7 +193,7 @@ private slots: * and emit a signal indicating that the tool has changed to the newly selected tool. This function static_casts * the sender to ToolbarButton so you should not connect any other class type to this slot. */ - void ToolButtonClicked(); + void tool_button_clicked(); /** * @brief Receiver for the snapping toggle button @@ -205,28 +205,28 @@ private slots: * * The new snapping value received from the sender's clicked signal */ - void SnappingButtonClicked(bool b); + void snapping_button_clicked(bool b); /** * @brief Receiver for the add button * * The add button pops up a list for which object to create. */ - void AddButtonClicked(); + void add_button_clicked(); /** * @brief Receiver for the transition button * * The transition button pops up a list for which transition to create. */ - void TransitionButtonClicked(); + void transition_button_clicked(); /** * @brief Receiver for the menu created by TransitionButtonClicked() */ - void TransitionMenuItemTriggered(QAction *a); + void transition_menu_item_triggered(QAction *a); }; } -#endif // TOOLBAR_H +#endif // OAK_TOOLBAR_H diff --git a/app/widget/toolbar/toolbarbutton.h b/app/widget/toolbar/toolbarbutton.h index f4fe97cbe..5ec7f5271 100644 --- a/app/widget/toolbar/toolbarbutton.h +++ b/app/widget/toolbar/toolbarbutton.h @@ -19,8 +19,8 @@ ***/ -#ifndef TOOLBARBUTTON_H -#define TOOLBARBUTTON_H +#ifndef OAK_TOOLBARBUTTON_H +#define OAK_TOOLBARBUTTON_H #include @@ -63,4 +63,4 @@ private: } -#endif // TOOLBARBUTTON_H +#endif // OAK_TOOLBARBUTTON_H diff --git a/app/widget/viewer/audiowaveformview.cpp b/app/widget/viewer/audiowaveformview.cpp index 42f3cdd5a..1d9d61e9f 100644 --- a/app/widget/viewer/audiowaveformview.cpp +++ b/app/widget/viewer/audiowaveformview.cpp @@ -48,33 +48,33 @@ AudioWaveformView::AudioWaveformView(QWidget *parent) setAlignment(Qt::AlignLeft | Qt::AlignTop); } -void AudioWaveformView::SetViewer(ViewerOutput *playback) +void AudioWaveformView::set_viewer(ViewerOutput *playback) { if (playback_) { pool_.clear(); pool_.waitForDone(); - disconnect(playback_, &ViewerOutput::ConnectedWaveformChanged, + disconnect(playback_, &ViewerOutput::connected_waveform_changed, viewport(), static_cast(&QWidget::update)); - SetTimebase(0); + set_timebase(0); } playback_ = playback; if (playback_) { - connect(playback_, &ViewerOutput::ConnectedWaveformChanged, viewport(), + connect(playback_, &ViewerOutput::connected_waveform_changed, viewport(), static_cast(&QWidget::update)); - rational tb = playback_->GetVideoParams().frame_rate_as_time_base(); + Rational tb = playback_->get_video_params().frame_rate_as_time_base(); if (tb.isNull()) { - tb = OLIVE_CONFIG("DefaultSequenceFrameRate") - .value() + tb = OAK_CONFIG("DefaultSequenceFrameRate") + .value() .flipped(); } - SetTimebase(tb); - UpdateSceneRect(); + set_timebase(tb); + update_scene_rect(); } } @@ -86,28 +86,28 @@ void AudioWaveformView::drawForeground(QPainter *p, const QRectF &rect) return; } - const AudioWaveformCache *wave = playback_->GetConnectedWaveform(); + const AudioWaveformCache *wave = playback_->get_connected_waveform(); if (!wave) { return; } - const AudioParams ¶ms = wave->GetParameters(); + const AudioParams ¶ms = wave->get_parameters(); if (!params.is_valid()) { return; } // Draw in/out points - DrawWorkArea(p); - DrawMarkers(p); + draw_work_area(p); + draw_markers(p); // Draw waveform p->setPen(QColor(64, 255, 160)); // FIXME: Hardcoded color - wave->Draw(p, rect.toRect(), GetScale(), SceneToTime(GetScroll())); + wave->Draw(p, rect.toRect(), get_scale(), scene_to_time(get_scroll())); // Draw playhead p->setPen(PLAYHEAD_COLOR); - int playhead_x = TimeToScene(GetViewerNode()->GetPlayhead()); + int playhead_x = time_to_scene(get_viewer_node()->get_playhead()); p->drawLine(playhead_x, 0, playhead_x, height()); } diff --git a/app/widget/viewer/audiowaveformview.h b/app/widget/viewer/audiowaveformview.h index 316fbf448..782a27826 100644 --- a/app/widget/viewer/audiowaveformview.h +++ b/app/widget/viewer/audiowaveformview.h @@ -19,8 +19,8 @@ ***/ -#ifndef AUDIOWAVEFORMVIEW_H -#define AUDIOWAVEFORMVIEW_H +#ifndef OAK_AUDIOWAVEFORMVIEW_H +#define OAK_AUDIOWAVEFORMVIEW_H #include #include @@ -36,7 +36,7 @@ class AudioWaveformView : public SeekableWidget { public: AudioWaveformView(QWidget *parent = nullptr); - void SetViewer(ViewerOutput *playback); + void set_viewer(ViewerOutput *playback); protected: virtual void drawForeground(QPainter *painter, const QRectF &rect) override; @@ -49,4 +49,4 @@ private: } -#endif // AUDIOWAVEFORMVIEW_H +#endif // OAK_AUDIOWAVEFORMVIEW_H diff --git a/app/widget/viewer/footageviewer.cpp b/app/widget/viewer/footageviewer.cpp index 82c8e4e22..a964fbfed 100644 --- a/app/widget/viewer/footageviewer.cpp +++ b/app/widget/viewer/footageviewer.cpp @@ -35,41 +35,41 @@ namespace olive FootageViewerWidget::FootageViewerWidget(QWidget *parent) : super(parent) { - connect(display_widget(), &ViewerDisplayWidget::DragStarted, this, - &FootageViewerWidget::StartFootageDrag); + connect(display_widget(), &ViewerDisplayWidget::drag_started, this, + &FootageViewerWidget::start_footage_drag); - controls_->SetAudioVideoDragButtonsVisible(true); - connect(controls_, &PlaybackControls::VideoClicked, this, - &FootageViewerWidget::VideoButtonClicked); - connect(controls_, &PlaybackControls::AudioClicked, this, - &FootageViewerWidget::AudioButtonClicked); - connect(controls_, &PlaybackControls::VideoDragged, this, - &FootageViewerWidget::StartVideoDrag); - connect(controls_, &PlaybackControls::AudioDragged, this, - &FootageViewerWidget::StartAudioDrag); + controls_->set_audio_video_drag_buttons_visible(true); + connect(controls_, &PlaybackControls::video_clicked, this, + &FootageViewerWidget::video_button_clicked); + connect(controls_, &PlaybackControls::audio_clicked, this, + &FootageViewerWidget::audio_button_clicked); + connect(controls_, &PlaybackControls::video_dragged, this, + &FootageViewerWidget::start_video_drag); + connect(controls_, &PlaybackControls::audio_dragged, this, + &FootageViewerWidget::start_audio_drag); override_workarea_ = new TimelineWorkArea(this); } -void FootageViewerWidget::OverrideWorkArea(const TimeRange &r) +void FootageViewerWidget::override_work_area(const TimeRange &r) { override_workarea_->set_enabled(true); override_workarea_->set_range(r); - this->ConnectWorkArea(override_workarea_); + this->connect_work_area(override_workarea_); } -void FootageViewerWidget::ResetWorkArea() +void FootageViewerWidget::reset_work_area() { - if (GetConnectedWorkArea() == override_workarea_) { - this->ConnectWorkArea( - GetConnectedNode() ? GetConnectedNode()->GetWorkArea() : nullptr); + if (get_connected_work_area() == override_workarea_) { + this->connect_work_area( + get_connected_node() ? get_connected_node()->get_work_area() : nullptr); } } -void FootageViewerWidget::StartFootageDragInternal(bool enable_video, +void FootageViewerWidget::start_footage_drag_internal(bool enable_video, bool enable_audio) { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } @@ -80,15 +80,15 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, QDataStream data_stream(&encoded_data, QIODevice::WriteOnly); QVector streams = - GetConnectedNode()->GetEnabledStreamsAsReferences(); + get_connected_node()->get_enabled_streams_as_references(); // Disable streams that have been disabled if (!enable_video || !enable_audio) { for (int i = 0; i < streams.size(); i++) { const Track::Reference &ref = streams.at(i); - if ((ref.type() == Track::kVideo && !enable_video) || - (ref.type() == Track::kAudio && !enable_audio)) { + if ((ref.type() == Track::k_video && !enable_video) || + (ref.type() == Track::k_audio && !enable_audio)) { streams.removeAt(i); i--; } @@ -97,38 +97,38 @@ void FootageViewerWidget::StartFootageDragInternal(bool enable_video, if (!streams.isEmpty()) { data_stream << streams - << reinterpret_cast(GetConnectedNode()); + << reinterpret_cast(get_connected_node()); - mimedata->setData(Project::kItemMimeType, encoded_data); + mimedata->setData(Project::k_item_mime_type, encoded_data); drag->setMimeData(mimedata); drag->exec(); } } -void FootageViewerWidget::StartFootageDrag() +void FootageViewerWidget::start_footage_drag() { - StartFootageDragInternal(true, true); + start_footage_drag_internal(true, true); } -void FootageViewerWidget::StartVideoDrag() +void FootageViewerWidget::start_video_drag() { - StartFootageDragInternal(true, false); + start_footage_drag_internal(true, false); } -void FootageViewerWidget::StartAudioDrag() +void FootageViewerWidget::start_audio_drag() { - StartFootageDragInternal(false, true); + start_footage_drag_internal(false, true); } -void FootageViewerWidget::VideoButtonClicked() +void FootageViewerWidget::video_button_clicked() { - this->SetWaveformMode(kWFAutomatic); + this->set_waveform_mode(k_wf_automatic); } -void FootageViewerWidget::AudioButtonClicked() +void FootageViewerWidget::audio_button_clicked() { - this->SetWaveformMode(kWFWaveformOnly); + this->set_waveform_mode(k_wf_waveform_only); } } diff --git a/app/widget/viewer/footageviewer.h b/app/widget/viewer/footageviewer.h index e6a5f9d59..233caa1a8 100644 --- a/app/widget/viewer/footageviewer.h +++ b/app/widget/viewer/footageviewer.h @@ -19,8 +19,8 @@ ***/ -#ifndef FOOTAGEVIEWERWIDGET_H -#define FOOTAGEVIEWERWIDGET_H +#ifndef OAK_FOOTAGEVIEWERWIDGET_H +#define OAK_FOOTAGEVIEWERWIDGET_H #include "node/output/viewer/viewer.h" #include "viewer.h" @@ -33,26 +33,26 @@ class FootageViewerWidget : public ViewerWidget { public: FootageViewerWidget(QWidget *parent = nullptr); - void OverrideWorkArea(const TimeRange &r); - void ResetWorkArea(); + void override_work_area(const TimeRange &r); + void reset_work_area(); private: - void StartFootageDragInternal(bool enable_video, bool enable_audio); + void start_footage_drag_internal(bool enable_video, bool enable_audio); TimelineWorkArea *override_workarea_; private slots: - void StartFootageDrag(); + void start_footage_drag(); - void StartVideoDrag(); + void start_video_drag(); - void StartAudioDrag(); + void start_audio_drag(); - void VideoButtonClicked(); + void video_button_clicked(); - void AudioButtonClicked(); + void audio_button_clicked(); }; } -#endif // FOOTAGEVIEWERWIDGET_H +#endif // OAK_FOOTAGEVIEWERWIDGET_H diff --git a/app/widget/viewer/viewer.cpp b/app/widget/viewer/viewer.cpp index 9da974e23..96f9f6b5b 100644 --- a/app/widget/viewer/viewer.cpp +++ b/app/widget/viewer/viewer.cpp @@ -55,15 +55,15 @@ namespace olive #define super TimeBasedWidget -QVector ViewerWidget::instances_; +QVector ViewerWidget::instances; // NOTE: Hardcoded interval of size of audio chunk to render and send to the output at a time. // We want this to be as long as possible so the code has plenty of time to send the audio // while also being as short as possible so users get relatively immediate feedback when // changing values. 1/4 second seems to be a good middleground. -const rational ViewerWidget::kAudioPlaybackInterval = rational(1, 4); +const Rational ViewerWidget::k_audio_playback_interval = Rational(1, 4); -const rational kVideoPlaybackInterval = rational(1, 10); +const Rational k_video_playback_interval = Rational(1, 10); ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) : super(false, true, parent) @@ -76,7 +76,7 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) , recording_(false) , first_requeue_watcher_(nullptr) , enable_audio_scrubbing_(true) - , waveform_mode_(kWFAutomatic) + , waveform_mode_(k_wf_automatic) , ignore_scrub_(0) , multicam_panel_(nullptr) { @@ -89,43 +89,43 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) layout->addWidget(sizer_); display_widget_ = display; - display_widget_->SetShowWidgetBackground(true); + display_widget_->set_show_widget_background(true); playback_devices_.append(display_widget_); connect(display_widget_, &ViewerDisplayWidget::customContextMenuRequested, - this, &ViewerWidget::ShowContextMenu); - connect(display_widget_, &ViewerDisplayWidget::CursorColor, this, - &ViewerWidget::CursorColor); - connect(display_widget_, &ViewerDisplayWidget::ColorProcessorChanged, this, - &ViewerWidget::ColorProcessorChanged); + this, &ViewerWidget::show_context_menu); + connect(display_widget_, &ViewerDisplayWidget::cursor_color, this, + &ViewerWidget::cursor_color); + connect(display_widget_, &ViewerDisplayWidget::color_processor_changed, this, + &ViewerWidget::color_processor_changed); connect( - display_widget_, &ViewerDisplayWidget::ColorProcessorChanged, this, + display_widget_, &ViewerDisplayWidget::color_processor_changed, this, [](ColorProcessorPtr processor) { - RenderManager::instance()->GetCacher()->SetDisplayColorProcessor( + RenderManager::instance()->get_cacher()->set_display_color_processor( processor); }); - RenderManager::instance()->GetCacher()->SetDisplayColorProcessor( - display_widget_->GetCurrentColorProcessor()); - connect(display_widget_, &ViewerDisplayWidget::ColorManagerChanged, this, - &ViewerWidget::ColorManagerChanged); - connect(display_widget_, &ViewerDisplayWidget::DragEntered, this, - &ViewerWidget::DragEntered); - connect(display_widget_, &ViewerDisplayWidget::Dropped, this, - &ViewerWidget::Dropped); - connect(display_widget_, &ViewerDisplayWidget::TextureChanged, this, - &ViewerWidget::TextureChanged); - connect(display_widget_, &ViewerDisplayWidget::QueueStarved, this, - &ViewerWidget::QueueStarved); - connect(display_widget_, &ViewerDisplayWidget::QueueNoLongerStarved, this, - &ViewerWidget::QueueNoLongerStarved); - connect(display_widget_, &ViewerDisplayWidget::CreateAddableAt, this, - &ViewerWidget::CreateAddableAt); - connect(sizer_, &ViewerSizer::RequestScale, display_widget_, - &ViewerDisplayWidget::SetMatrixZoom); - connect(sizer_, &ViewerSizer::RequestTranslate, display_widget_, - &ViewerDisplayWidget::SetMatrixTranslate); - connect(display_widget_, &ViewerDisplayWidget::HandDragMoved, sizer_, - &ViewerSizer::HandDragMove); - sizer_->SetWidget(display_widget_); + RenderManager::instance()->get_cacher()->set_display_color_processor( + display_widget_->get_current_color_processor()); + connect(display_widget_, &ViewerDisplayWidget::color_manager_changed, this, + &ViewerWidget::color_manager_changed); + connect(display_widget_, &ViewerDisplayWidget::drag_entered, this, + &ViewerWidget::drag_entered); + connect(display_widget_, &ViewerDisplayWidget::dropped, this, + &ViewerWidget::dropped); + connect(display_widget_, &ViewerDisplayWidget::texture_changed, this, + &ViewerWidget::texture_changed); + connect(display_widget_, &ViewerDisplayWidget::queue_starved, this, + &ViewerWidget::queue_starved); + connect(display_widget_, &ViewerDisplayWidget::queue_no_longer_starved, this, + &ViewerWidget::queue_no_longer_starved); + connect(display_widget_, &ViewerDisplayWidget::create_addable_at, this, + &ViewerWidget::create_addable_at); + connect(sizer_, &ViewerSizer::request_scale, display_widget_, + &ViewerDisplayWidget::set_matrix_zoom); + connect(sizer_, &ViewerSizer::request_translate, display_widget_, + &ViewerDisplayWidget::set_matrix_translate); + connect(display_widget_, &ViewerDisplayWidget::hand_drag_moved, sizer_, + &ViewerSizer::hand_drag_move); + sizer_->set_widget(display_widget_); // Make the display widget the first tabbable widget. While the viewer display cannot actually // be interacted with by tabbing, it prevents the actual first tabbable widget (the playhead @@ -134,7 +134,7 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) // Create waveform view when audio is connected and video isn't waveform_view_ = new AudioWaveformView(); - ConnectTimelineView(waveform_view_); + connect_timeline_view(waveform_view_); layout->addWidget(waveform_view_); // Create time ruler @@ -145,20 +145,20 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) // Create lower controls controls_ = new PlaybackControls(); - controls_->SetTimecodeEnabled(true); + controls_->set_timecode_enabled(true); controls_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - connect(controls_, &PlaybackControls::PlayClicked, this, - static_cast(&ViewerWidget::Play)); - connect(controls_, &PlaybackControls::PauseClicked, this, - &ViewerWidget::Pause); - connect(controls_, &PlaybackControls::PrevFrameClicked, this, - &ViewerWidget::PrevFrame); - connect(controls_, &PlaybackControls::NextFrameClicked, this, - &ViewerWidget::NextFrame); - connect(controls_, &PlaybackControls::BeginClicked, this, - &ViewerWidget::GoToStart); - connect(controls_, &PlaybackControls::EndClicked, this, - &ViewerWidget::GoToEnd); + connect(controls_, &PlaybackControls::play_clicked, this, + static_cast(&ViewerWidget::play)); + connect(controls_, &PlaybackControls::pause_clicked, this, + &ViewerWidget::pause); + connect(controls_, &PlaybackControls::prev_frame_clicked, this, + &ViewerWidget::prev_frame); + connect(controls_, &PlaybackControls::next_frame_clicked, this, + &ViewerWidget::next_frame); + connect(controls_, &PlaybackControls::begin_clicked, this, + &ViewerWidget::go_to_start); + connect(controls_, &PlaybackControls::end_clicked, this, + &ViewerWidget::go_to_end); layout->addWidget(controls_); // FIXME: Magic number @@ -166,28 +166,28 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) // Ensures that seeking on the waveform view updates the time as expected connect(waveform_view_, &AudioWaveformView::customContextMenuRequested, - this, &ViewerWidget::ShowContextMenu); + this, &ViewerWidget::show_context_menu); connect(&playback_backup_timer_, &QTimer::timeout, this, - &ViewerWidget::PlaybackTimerUpdate); + &ViewerWidget::playback_timer_update); - SetAutoMaxScrollBar(true); + set_auto_max_scroll_bar(true); - instances_.append(this); + instances.append(this); - UpdateWaveformViewFromMode(); + update_waveform_view_from_mode(); - connect(Core::instance(), &Core::ColorPickerEnabled, this, - &ViewerWidget::SetSignalCursorColorEnabled); - connect(this, &ViewerWidget::CursorColor, Core::instance(), - &Core::ColorPickerColorEmitted); - connect(AudioManager::instance(), &AudioManager::OutputParamsChanged, this, - &ViewerWidget::UpdateAudioProcessor); + connect(Core::instance(), &Core::color_picker_enabled, this, + &ViewerWidget::set_signal_cursor_color_enabled); + connect(this, &ViewerWidget::cursor_color, Core::instance(), + &Core::color_picker_color_emitted); + connect(AudioManager::instance(), &AudioManager::output_params_changed, this, + &ViewerWidget::update_audio_processor); } ViewerWidget::~ViewerWidget() { - instances_.removeOne(this); + instances.removeOne(this); auto windows = windows_; @@ -199,214 +199,214 @@ ViewerWidget::~ViewerWidget() display_widget_ = nullptr; } -void ViewerWidget::TimeChangedEvent(const rational &time) +void ViewerWidget::TimeChangedEvent(const Rational &time) { if (!time_changed_from_timer_) { - PauseInternal(); + pause_internal(); } if (record_armed_) { - DisarmRecording(); + disarm_recording(); } - controls_->SetTime(time); + controls_->set_time(time); - if (GetConnectedNode() && last_time_ != time) { - if (!IsPlaying()) { - UpdateTextureFromNode(); + if (get_connected_node() && last_time_ != time) { + if (!is_playing()) { + update_texture_from_node(); - PushScrubbedAudio(); + push_scrubbed_audio(); // We don't clear the FPS timer on pause in case users want to see it immediately after, but by // the time a new texture is drawn, assume that the FPS no longer needs to be shown. - display_widget_->ResetFPSTimer(); + display_widget_->reset_fps_timer(); } - display_widget_->SetTime(time); + display_widget_->set_time(time); } // Send time to auto-cacher - RenderManager::instance()->GetCacher()->SetPlayhead(time); + RenderManager::instance()->get_cacher()->set_playhead(time); last_time_ = time; } void ViewerWidget::ConnectNodeEvent(ViewerOutput *n) { - connect(n, &ViewerOutput::SizeChanged, this, - &ViewerWidget::SetViewerResolution); - connect(n, &ViewerOutput::PixelAspectChanged, this, - &ViewerWidget::SetViewerPixelAspect); - connect(n, &ViewerOutput::LengthChanged, this, - &ViewerWidget::LengthChangedSlot); - connect(n, &ViewerOutput::InterlacingChanged, this, - &ViewerWidget::InterlacingChangedSlot); - connect(n, &ViewerOutput::VideoParamsChanged, this, - &ViewerWidget::UpdateRendererVideoParameters); - connect(n, &ViewerOutput::VideoParamsChanged, this, - &ViewerWidget::UpdateTextureFromNode, Qt::QueuedConnection); - connect(n, &ViewerOutput::AudioParamsChanged, this, - &ViewerWidget::UpdateRendererAudioParameters); + connect(n, &ViewerOutput::size_changed, this, + &ViewerWidget::set_viewer_resolution); + connect(n, &ViewerOutput::pixel_aspect_changed, this, + &ViewerWidget::set_viewer_pixel_aspect); + connect(n, &ViewerOutput::length_changed, this, + &ViewerWidget::length_changed_slot); + connect(n, &ViewerOutput::interlacing_changed, this, + &ViewerWidget::interlacing_changed_slot); + connect(n, &ViewerOutput::video_params_changed, this, + &ViewerWidget::update_renderer_video_parameters); + connect(n, &ViewerOutput::video_params_changed, this, + &ViewerWidget::update_texture_from_node, Qt::QueuedConnection); + connect(n, &ViewerOutput::audio_params_changed, this, + &ViewerWidget::update_renderer_audio_parameters); if (FrameHashCache *cache = n->video_frame_cache()) { - connect(cache, &FrameHashCache::Invalidated, this, - &ViewerWidget::ViewerInvalidatedVideoRange); + connect(cache, &FrameHashCache::invalidated, this, + &ViewerWidget::viewer_invalidated_video_range); } - connect(n, &ViewerOutput::TextureInputChanged, this, - &ViewerWidget::UpdateWaveformViewFromMode); + connect(n, &ViewerOutput::texture_input_changed, this, + &ViewerWidget::update_waveform_view_from_mode); - connect(controls_, &PlaybackControls::TimeChanged, n, - &ViewerOutput::SetPlayhead); + connect(controls_, &PlaybackControls::time_changed, n, + &ViewerOutput::set_playhead); - VideoParams vp = n->GetVideoParams(); + VideoParams vp = n->get_video_params(); - InterlacingChangedSlot(vp.interlacing()); + interlacing_changed_slot(vp.interlacing()); - ruler()->SetPlaybackCache(n->video_frame_cache()); + ruler()->set_playback_cache(n->video_frame_cache()); - SetViewerResolution(vp.width(), vp.height()); - SetViewerPixelAspect(vp.pixel_aspect_ratio()); + set_viewer_resolution(vp.width(), vp.height()); + set_viewer_pixel_aspect(vp.pixel_aspect_ratio()); last_length_ = 0; - LengthChangedSlot(n->GetLength()); + length_changed_slot(n->get_length()); - UpdateAudioProcessor(); + update_audio_processor(); ColorManager *color_manager = n->project()->color_manager(); foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->ConnectColorManager(color_manager); + dw->connect_color_manager(color_manager); } - UpdateWaveformViewFromMode(); + update_waveform_view_from_mode(); - waveform_view_->SetViewer(GetConnectedNode()); + waveform_view_->set_viewer(get_connected_node()); - UpdateRendererVideoParameters(); - UpdateRendererAudioParameters(); + update_renderer_video_parameters(); + update_renderer_audio_parameters(); // Set texture to new texture (or null if no viewer node is available) - UpdateTextureFromNode(); + update_texture_from_node(); } void ViewerWidget::DisconnectNodeEvent(ViewerOutput *n) { - PauseInternal(); + pause_internal(); - disconnect(n, &ViewerOutput::SizeChanged, this, - &ViewerWidget::SetViewerResolution); - disconnect(n, &ViewerOutput::PixelAspectChanged, this, - &ViewerWidget::SetViewerPixelAspect); - disconnect(n, &ViewerOutput::LengthChanged, this, - &ViewerWidget::LengthChangedSlot); - disconnect(n, &ViewerOutput::InterlacingChanged, this, - &ViewerWidget::InterlacingChangedSlot); - disconnect(n, &ViewerOutput::VideoParamsChanged, this, - &ViewerWidget::UpdateRendererVideoParameters); - disconnect(n, &ViewerOutput::VideoParamsChanged, this, - &ViewerWidget::UpdateTextureFromNode); - disconnect(n, &ViewerOutput::AudioParamsChanged, this, - &ViewerWidget::UpdateRendererAudioParameters); + disconnect(n, &ViewerOutput::size_changed, this, + &ViewerWidget::set_viewer_resolution); + disconnect(n, &ViewerOutput::pixel_aspect_changed, this, + &ViewerWidget::set_viewer_pixel_aspect); + disconnect(n, &ViewerOutput::length_changed, this, + &ViewerWidget::length_changed_slot); + disconnect(n, &ViewerOutput::interlacing_changed, this, + &ViewerWidget::interlacing_changed_slot); + disconnect(n, &ViewerOutput::video_params_changed, this, + &ViewerWidget::update_renderer_video_parameters); + disconnect(n, &ViewerOutput::video_params_changed, this, + &ViewerWidget::update_texture_from_node); + disconnect(n, &ViewerOutput::audio_params_changed, this, + &ViewerWidget::update_renderer_audio_parameters); if (FrameHashCache *cache = n->video_frame_cache()) { - disconnect(cache, &FrameHashCache::Invalidated, this, - &ViewerWidget::ViewerInvalidatedVideoRange); + disconnect(cache, &FrameHashCache::invalidated, this, + &ViewerWidget::viewer_invalidated_video_range); } - disconnect(n, &ViewerOutput::TextureInputChanged, this, - &ViewerWidget::UpdateWaveformViewFromMode); + disconnect(n, &ViewerOutput::texture_input_changed, this, + &ViewerWidget::update_waveform_view_from_mode); - disconnect(controls_, &PlaybackControls::TimeChanged, n, - &ViewerOutput::SetPlayhead); + disconnect(controls_, &PlaybackControls::time_changed, n, + &ViewerOutput::set_playhead); timeline_selected_blocks_.clear(); node_view_selected_.clear(); if (multicam_panel_) { - multicam_panel_->SetMulticamNode(nullptr, nullptr, nullptr, - rational::NaN); + multicam_panel_->set_multicam_node(nullptr, nullptr, nullptr, + Rational::na_n); } - CloseAudioProcessor(); + close_audio_processor(); audio_scrub_watchers_.clear(); - SetDisplayImage(nullptr); + set_display_image(nullptr); - ruler()->SetPlaybackCache(nullptr); + ruler()->set_playback_cache(nullptr); // Effectively disables the viewer and clears the state - SetViewerResolution(0, 0); + set_viewer_resolution(0, 0); foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->DisconnectColorManager(); + dw->disconnect_color_manager(); } - waveform_view_->SetViewer(nullptr); + waveform_view_->set_viewer(nullptr); // Queue an UpdateStack so that when it runs, the viewer node will be fully disconnected - QMetaObject::invokeMethod(this, &ViewerWidget::UpdateWaveformViewFromMode, + QMetaObject::invokeMethod(this, &ViewerWidget::update_waveform_view_from_mode, Qt::QueuedConnection); - SetGizmos(nullptr); + set_gizmos(nullptr); } void ViewerWidget::ConnectedNodeChangeEvent(ViewerOutput *n) { - display_widget_->SetSubtitleTracks(dynamic_cast(n)); + display_widget_->set_subtitle_tracks(dynamic_cast(n)); } void ViewerWidget::ConnectedWorkAreaChangeEvent(TimelineWorkArea *workarea) { - waveform_view_->SetWorkArea(workarea); + waveform_view_->set_work_area(workarea); } void ViewerWidget::ConnectedMarkersChangeEvent(TimelineMarkerList *markers) { - waveform_view_->SetMarkers(markers); + waveform_view_->set_markers(markers); } void ViewerWidget::ScaleChangedEvent(const double &s) { super::ScaleChangedEvent(s); - waveform_view_->SetScale(s); + waveform_view_->set_scale(s); } void ViewerWidget::resizeEvent(QResizeEvent *event) { super::resizeEvent(event); - UpdateMinimumScale(); + update_minimum_scale(); } -RenderTicketPtr ViewerWidget::GetSingleFrame(const rational &t, bool dry) +RenderTicketPtr ViewerWidget::get_single_frame(const Rational &t, bool dry) { - return RenderManager::instance()->GetCacher()->GetSingleFrame( - this->GetConnectedNode(), t, dry); + return RenderManager::instance()->get_cacher()->get_single_frame( + this->get_connected_node(), t, dry); } -void ViewerWidget::TogglePlayPause() +void ViewerWidget::toggle_play_pause() { - if (IsPlaying()) { - Pause(); + if (is_playing()) { + pause(); } else { - Play(); + play(); } } -bool ViewerWidget::IsPlaying() const +bool ViewerWidget::is_playing() const { return playback_speed_ != 0; } -void ViewerWidget::SetColorMenuEnabled(bool enabled) +void ViewerWidget::set_color_menu_enabled(bool enabled) { color_menu_enabled_ = enabled; } -void ViewerWidget::SetMatrix(const QMatrix4x4 &mat) +void ViewerWidget::set_matrix(const QMatrix4x4 &mat) { foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->SetMatrixCrop(mat); + dw->set_matrix_crop(mat); } } -void ViewerWidget::SetFullScreen(QScreen *screen) +void ViewerWidget::set_full_screen(QScreen *screen) { if (!screen) { // Try to find the screen that contains the mouse cursor currently @@ -433,44 +433,44 @@ void ViewerWidget::SetFullScreen(QScreen *screen) vw->setGeometry(screen->geometry()); vw->showFullScreen(); - vw->display_widget()->ConnectColorManager(color_manager()); + vw->display_widget()->connect_color_manager(color_manager()); connect(vw, &ViewerWindow::destroyed, this, - &ViewerWidget::WindowAboutToClose); + &ViewerWidget::window_about_to_close); connect(vw->display_widget(), &ViewerDisplayWidget::customContextMenuRequested, this, - &ViewerWidget::ShowContextMenu); + &ViewerWidget::show_context_menu); - if (GetConnectedNode()) { - vw->SetVideoParams(GetConnectedNode()->GetVideoParams()); - vw->display_widget()->SetDeinterlacing( - vw->display_widget()->IsDeinterlacing()); + if (get_connected_node()) { + vw->set_video_params(get_connected_node()->get_video_params()); + vw->display_widget()->set_deinterlacing( + vw->display_widget()->is_deinterlacing()); } - vw->display_widget()->SetImage( - QVariant::fromValue(display_widget()->GetCurrentTexture())); + vw->display_widget()->set_image( + QVariant::fromValue(display_widget()->get_current_texture())); playback_devices_.append(vw->display_widget()); (*vw->display_widget()->queue()) = *playback_devices_.first()->queue(); - if (IsPlaying()) { - vw->display_widget()->Play(GetTimestamp(), playback_speed_, timebase(), + if (is_playing()) { + vw->display_widget()->play(get_timestamp(), playback_speed_, timebase(), true); } windows_.insert(screen, vw); } -void ViewerWidget::CacheEntireSequence() +void ViewerWidget::cache_entire_sequence() { - RenderManager::instance()->GetCacher()->ForceCacheRange( - GetConnectedNode(), TimeRange(0, GetConnectedNode()->GetVideoLength())); + RenderManager::instance()->get_cacher()->force_cache_range( + get_connected_node(), TimeRange(0, get_connected_node()->get_video_length())); } -void ViewerWidget::CacheSequenceInOut() +void ViewerWidget::cache_sequence_in_out() { - if (GetConnectedNode() && GetConnectedNode()->GetWorkArea()->enabled()) { - RenderManager::instance()->GetCacher()->ForceCacheRange( - GetConnectedNode(), GetConnectedNode()->GetWorkArea()->range()); + if (get_connected_node() && get_connected_node()->get_work_area()->enabled()) { + RenderManager::instance()->get_cacher()->force_cache_range( + get_connected_node(), get_connected_node()->get_work_area()->range()); } else { QMessageBox::warning(this, tr("Error"), tr("No in or out points are set to cache."), @@ -478,43 +478,43 @@ void ViewerWidget::CacheSequenceInOut() } } -void ViewerWidget::SetGizmos(Node *node) +void ViewerWidget::set_gizmos(Node *node) { - display_widget_->SetTimeTarget(GetConnectedNode()); - display_widget_->SetGizmos(node); + display_widget_->set_time_target(get_connected_node()); + display_widget_->set_gizmos(node); } -void ViewerWidget::StartCapture(TimelineWidget *source, const TimeRange &time, +void ViewerWidget::start_capture(TimelineWidget *source, const TimeRange &time, const Track::Reference &track) { - GetConnectedNode()->SetPlayhead(time.in()); - ArmForRecording(); + get_connected_node()->set_playhead(time.in()); + arm_for_recording(); recording_callback_ = source; recording_range_ = time; recording_track_ = track; } -void ViewerWidget::ConnectMulticamWidget(MulticamWidget *p) +void ViewerWidget::connect_multicam_widget(MulticamWidget *p) { if (multicam_panel_) { - disconnect(multicam_panel_, &MulticamWidget::Switched, this, - &ViewerWidget::DetectMulticamNodeNow); + disconnect(multicam_panel_, &MulticamWidget::switched, this, + &ViewerWidget::detect_multicam_node_now); } multicam_panel_ = p; if (multicam_panel_) { - connect(multicam_panel_, &MulticamWidget::Switched, this, - &ViewerWidget::DetectMulticamNodeNow); + connect(multicam_panel_, &MulticamWidget::switched, this, + &ViewerWidget::detect_multicam_node_now); } } -FramePtr ViewerWidget::DecodeCachedImage(const QString &cache_path, +FramePtr ViewerWidget::decode_cached_image(const QString &cache_path, const QUuid &cache_id, const int64_t &time) { - FramePtr frame = FrameHashCache::LoadCacheFrame(cache_path, cache_id, time); + FramePtr frame = FrameHashCache::load_cache_frame(cache_path, cache_id, time); if (frame) { frame->set_timestamp(time); @@ -525,79 +525,79 @@ FramePtr ViewerWidget::DecodeCachedImage(const QString &cache_path, return frame; } -void ViewerWidget::DecodeCachedImage(RenderTicketPtr ticket, +void ViewerWidget::decode_cached_image(RenderTicketPtr ticket, const QString &cache_path, const QUuid &cache_id, const int64_t &time) { - ticket->Start(); + ticket->start(); - FramePtr f = DecodeCachedImage(cache_path, cache_id, time); + FramePtr f = decode_cached_image(cache_path, cache_id, time); if (f) { - ticket->Finish(QVariant::fromValue(f)); + ticket->finish(QVariant::fromValue(f)); } else { - ticket->Finish(); + ticket->finish(); } } -bool ViewerWidget::ShouldForceWaveform() const +bool ViewerWidget::should_force_waveform() const { - return GetConnectedNode() && - !GetConnectedNode()->GetConnectedTextureOutput() && - GetConnectedNode()->GetConnectedSampleOutput(); + return get_connected_node() && + !get_connected_node()->get_connected_texture_output() && + get_connected_node()->get_connected_sample_output(); } -void ViewerWidget::SetEmptyImage() +void ViewerWidget::set_empty_image() { foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->SetBlank(); + dw->set_blank(); } } -void ViewerWidget::UpdateAutoCacher() +void ViewerWidget::update_auto_cacher() { - RenderManager::instance()->GetCacher()->SetPlayhead( - GetConnectedNode()->GetPlayhead()); + RenderManager::instance()->get_cacher()->set_playhead( + get_connected_node()->get_playhead()); } -void ViewerWidget::DecrementPrequeuedAudio() +void ViewerWidget::decrement_prequeued_audio() { prequeuing_audio_--; if (!prequeuing_audio_) { - FinishPlayPreprocess(); + finish_play_preprocess(); } } -void ViewerWidget::ArmForRecording() +void ViewerWidget::arm_for_recording() { - controls_->StartPlayBlink(); + controls_->start_play_blink(); record_armed_ = true; } -void ViewerWidget::DisarmRecording() +void ViewerWidget::disarm_recording() { - controls_->StopPlayBlink(); + controls_->stop_play_blink(); record_armed_ = false; } -void ViewerWidget::UpdateAudioProcessor() +void ViewerWidget::update_audio_processor() { - if (GetConnectedNode()) { - CloseAudioProcessor(); + if (get_connected_node()) { + close_audio_processor(); - AudioParams ap = GetConnectedNode()->GetAudioParams(); + AudioParams ap = get_connected_node()->get_audio_params(); if (ap.sample_rate() <= 0 || ap.channel_count() <= 0) { ap = AudioParams( - OLIVE_CONFIG("DefaultSequenceAudioFrequency").toInt(), - OLIVE_CONFIG("DefaultSequenceAudioLayout").toULongLong(), - ViewerOutput::kDefaultSampleFormat); + OAK_CONFIG("DefaultSequenceAudioFrequency").toInt(), + OAK_CONFIG("DefaultSequenceAudioLayout").toULongLong(), + ViewerOutput::k_default_sample_format); } - ap.set_format(ViewerOutput::kDefaultSampleFormat); + ap.set_format(ViewerOutput::k_default_sample_format); AudioParams packed( - OLIVE_CONFIG("AudioOutputSampleRate").toInt(), - OLIVE_CONFIG("AudioOutputChannelLayout").toULongLong(), - SampleFormat::from_string(OLIVE_CONFIG("AudioOutputSampleFormat") + OAK_CONFIG("AudioOutputSampleRate").toInt(), + OAK_CONFIG("AudioOutputChannelLayout").toULongLong(), + SampleFormat::from_string(OAK_CONFIG("AudioOutputSampleFormat") .toString() .toStdString())); @@ -609,55 +609,55 @@ void ViewerWidget::UpdateAudioProcessor() << "layout_mask=0x" << packed.channel_layout() << Qt::dec; - audio_processor_.Open( + audio_processor_.open( ap, packed, (playback_speed_ == 0) ? 1 : std::abs(playback_speed_)); } } -void ViewerWidget::CreateAddableAt(const QRectF &f) +void ViewerWidget::create_addable_at(const QRectF &f) { - if (Sequence *s = dynamic_cast(GetConnectedNode())) { - Track::Type type = Track::kVideo; + if (Sequence *s = dynamic_cast(get_connected_node())) { + Track::Type type = Track::k_video; int track_index = -1; TrackList *list = s->track_list(type); - const rational &in = GetConnectedNode()->GetPlayhead(); - rational length = OLIVE_CONFIG("DefaultStillLength").value(); - rational out = in + length; + const Rational &in = get_connected_node()->get_playhead(); + Rational length = OAK_CONFIG("DefaultStillLength").value(); + Rational out = in + length; // Find a free track where we won't overwrite anything while (true) { track_index++; - if (track_index >= list->GetTrackCount()) { + if (track_index >= list->get_track_count()) { // Just create a new track break; } - Track *track = list->GetTrackAt(track_index); - if (track->IsLocked()) { + Track *track = list->get_track_at(track_index); + if (track->is_locked()) { continue; } - Block *b = track->NearestBlockBeforeOrAt(in); + Block *b = track->nearest_block_before_or_at(in); if (!b || (dynamic_cast(b) && b->out() >= out)) { break; } } MultiUndoCommand *command = new MultiUndoCommand(); - Node *clip = AddTool::CreateAddableClip( + Node *clip = AddTool::create_addable_clip( command, s, Track::Reference(type, track_index), in, length); if (ShapeNodeBase *shape = dynamic_cast(clip)) { - shape->SetRect(f, s->GetVideoParams(), command); + shape->set_rect(f, s->get_video_params(), command); } Core::instance()->undo_stack()->push(command, tr("Created Shape")); - SetGizmos(clip); + set_gizmos(clip); } } -void ViewerWidget::HandleFirstRequeueDestroy() +void ViewerWidget::handle_first_requeue_destroy() { // Extra protection to ensure we don't reference a destroyed object if (first_requeue_watcher_ == sender()) { @@ -665,48 +665,48 @@ void ViewerWidget::HandleFirstRequeueDestroy() } } -void ViewerWidget::ShowSubtitleProperties() +void ViewerWidget::show_subtitle_properties() { - QFont f(OLIVE_CONFIG("DefaultSubtitleFamily").toString(), - OLIVE_CONFIG("DefaultSubtitleSize").toInt(), - OLIVE_CONFIG("DefaultSubtitleWeight").toInt()); + QFont f(OAK_CONFIG("DefaultSubtitleFamily").toString(), + OAK_CONFIG("DefaultSubtitleSize").toInt(), + OAK_CONFIG("DefaultSubtitleWeight").toInt()); QFontDialog fd(f, this); if (fd.exec() == QDialog::Accepted) { f = fd.selectedFont(); - OLIVE_CONFIG("DefaultSubtitleSize") = f.pointSize(); - OLIVE_CONFIG("DefaultSubtitleFamily") = f.family(); - OLIVE_CONFIG("DefaultSubtitleWeight") = f.weight(); + OAK_CONFIG("DefaultSubtitleSize") = f.pointSize(); + OAK_CONFIG("DefaultSubtitleFamily") = f.family(); + OAK_CONFIG("DefaultSubtitleWeight") = f.weight(); display_widget_->update(); } } -void ViewerWidget::DryRunFinished() +void ViewerWidget::dry_run_finished() { RenderTicketWatcher *w = static_cast(sender()); if (dry_run_watchers_.contains(w)) { - RequestNextDryRun(); + request_next_dry_run(); } delete w; } -void ViewerWidget::RequestNextDryRun() +void ViewerWidget::request_next_dry_run() { - if (IsPlaying()) { - rational next_time = + if (is_playing()) { + Rational next_time = Timecode::timestamp_to_time(dry_run_next_frame_, timebase()); - if (FrameExistsAtTime(next_time)) { - if (next_time > GetConnectedNode()->GetPlayhead() + - RenderManager::kDryRunInterval) { - QTimer::singleShot(timebase().toDouble() / playback_speed_, - this, &ViewerWidget::RequestNextDryRun); + if (frame_exists_at_time(next_time)) { + if (next_time > get_connected_node()->get_playhead() + + RenderManager::k_dry_run_interval) { + QTimer::singleShot(timebase().to_double() / playback_speed_, + this, &ViewerWidget::request_next_dry_run); } else { RenderTicketWatcher *watcher = new RenderTicketWatcher(this); - connect(watcher, &RenderTicketWatcher::Finished, this, - &ViewerWidget::DryRunFinished); - watcher->SetTicket(GetSingleFrame(next_time, true)); + connect(watcher, &RenderTicketWatcher::finished, this, + &ViewerWidget::dry_run_finished); + watcher->set_ticket(get_single_frame(next_time, true)); dry_run_next_frame_ += playback_speed_; dry_run_watchers_.append(watcher); } @@ -714,30 +714,30 @@ void ViewerWidget::RequestNextDryRun() } } -void ViewerWidget::SaveFrameAsImage() +void ViewerWidget::save_frame_as_image() { - Core::instance()->OpenExportDialogForViewer(GetConnectedNode(), true); + Core::instance()->open_export_dialog_for_viewer(get_connected_node(), true); } -void ViewerWidget::DetectMulticamNodeNow() +void ViewerWidget::detect_multicam_node_now() { - if (GetConnectedNode()) { - DetectMulticamNode(GetConnectedNode()->GetPlayhead()); + if (get_connected_node()) { + detect_multicam_node(get_connected_node()->get_playhead()); } } -void ViewerWidget::CloseAudioProcessor() +void ViewerWidget::close_audio_processor() { - audio_processor_.Close(); + audio_processor_.close(); } -void ViewerWidget::SetWaveformMode(WaveformMode wf) +void ViewerWidget::set_waveform_mode(WaveformMode wf) { waveform_mode_ = wf; - UpdateWaveformViewFromMode(); + update_waveform_view_from_mode(); } -void ViewerWidget::DetectMulticamNode(const rational &time) +void ViewerWidget::detect_multicam_node(const Rational &time) { // Look for multicam node MultiCamNode *multicam = nullptr; @@ -745,15 +745,15 @@ void ViewerWidget::DetectMulticamNode(const rational &time) // Faster way to do this if (multicam_panel_ && multicam_panel_->isVisible()) { - if (Sequence *s = dynamic_cast(GetConnectedNode())) { + if (Sequence *s = dynamic_cast(get_connected_node())) { // Prefer selected nodes for (Node *n : qAsConst(node_view_selected_)) { if ((multicam = dynamic_cast(n))) { // Found multicam, now try to find corresponding clip from selected timeline blocks for (Block *b : qAsConst(timeline_selected_blocks_)) { if (ClipBlock *c = dynamic_cast(b)) { - if (c->range().Contains(time) && - c->ContextContainsNode(multicam)) { + if (c->range().contains(time) && + c->context_contains_node(multicam)) { clip = c; break; } @@ -766,9 +766,9 @@ void ViewerWidget::DetectMulticamNode(const rational &time) // Next, prefer multicam from selected block if (!multicam) { for (Block *b : qAsConst(timeline_selected_blocks_)) { - if (b->range().Contains(time)) { + if (b->range().contains(time)) { if ((clip = dynamic_cast(b))) { - if ((multicam = clip->FindMulticam())) { + if ((multicam = clip->find_multicam())) { break; } } @@ -777,15 +777,15 @@ void ViewerWidget::DetectMulticamNode(const rational &time) } if (!multicam) { - const QVector &tracks = s->GetTracks(); + const QVector &tracks = s->get_tracks(); for (Track *t : tracks) { - if (t->IsLocked()) { + if (t->is_locked()) { continue; } - Block *b = t->NearestBlockBeforeOrAt(time); + Block *b = t->nearest_block_before_or_at(time); if ((clip = dynamic_cast(b))) { - if ((multicam = clip->FindMulticam())) { + if ((multicam = clip->find_multicam())) { break; } } @@ -796,90 +796,90 @@ void ViewerWidget::DetectMulticamNode(const rational &time) if (multicam) { if (multicam_panel_) { - multicam_panel_->SetMulticamNode(GetConnectedNode(), multicam, clip, + multicam_panel_->set_multicam_node(get_connected_node(), multicam, clip, time); } // FIXME: Really dirty - RenderManager::instance()->GetCacher()->SetMulticamNode(multicam); + RenderManager::instance()->get_cacher()->set_multicam_node(multicam); } else { - RenderManager::instance()->GetCacher()->SetMulticamNode(nullptr); + RenderManager::instance()->get_cacher()->set_multicam_node(nullptr); if (multicam_panel_) { - multicam_panel_->SetMulticamNode(nullptr, nullptr, nullptr, time); + multicam_panel_->set_multicam_node(nullptr, nullptr, nullptr, time); } } } -bool ViewerWidget::IsVideoVisible() const +bool ViewerWidget::is_video_visible() const { - return GetConnectedNode()->GetVideoParams().video_type() != - VideoParams::kVideoTypeStill && + return get_connected_node()->get_video_params().video_type() != + VideoParams::k_video_type_still && (display_widget_->isVisible() || !windows_.isEmpty()); } -void ViewerWidget::UpdateWaveformViewFromMode() +void ViewerWidget::update_waveform_view_from_mode() { - bool prefer_waveform = ShouldForceWaveform(); + bool prefer_waveform = should_force_waveform(); - sizer_->setVisible(waveform_mode_ == kWFViewerAndWaveform || - waveform_mode_ == kWFViewerOnly || - (waveform_mode_ == kWFAutomatic && !prefer_waveform)); + sizer_->setVisible(waveform_mode_ == k_wf_viewer_and_waveform || + waveform_mode_ == k_wf_viewer_only || + (waveform_mode_ == k_wf_automatic && !prefer_waveform)); waveform_view_->setVisible( - waveform_mode_ == kWFViewerAndWaveform || - waveform_mode_ == kWFWaveformOnly || - (waveform_mode_ == kWFAutomatic && prefer_waveform)); + waveform_mode_ == k_wf_viewer_and_waveform || + waveform_mode_ == k_wf_waveform_only || + (waveform_mode_ == k_wf_automatic && prefer_waveform)); waveform_view_->setSizePolicy(QSizePolicy::Expanding, - waveform_mode_ == kWFViewerAndWaveform ? + waveform_mode_ == k_wf_viewer_and_waveform ? QSizePolicy::Maximum : QSizePolicy::Expanding); - if (GetConnectedNode()) { - GetConnectedNode()->SetWaveformEnabled(waveform_view_->isVisible()); + if (get_connected_node()) { + get_connected_node()->set_waveform_enabled(waveform_view_->isVisible()); if (waveform_view_->isVisible()) { - waveform_view_->SetViewer(GetConnectedNode()); + waveform_view_->set_viewer(get_connected_node()); } else { - waveform_view_->SetViewer(nullptr); + waveform_view_->set_viewer(nullptr); } } } -void ViewerWidget::QueueNextAudioBuffer() +void ViewerWidget::queue_next_audio_buffer() { - rational queue_end = - audio_playback_queue_time_ + (kAudioPlaybackInterval * playback_speed_); + Rational queue_end = + audio_playback_queue_time_ + (k_audio_playback_interval * playback_speed_); // Clamp queue end by zero and the audio length - queue_end = std::clamp(queue_end, rational(0), - GetConnectedNode()->GetAudioLength()); + queue_end = std::clamp(queue_end, Rational(0), + get_connected_node()->get_audio_length()); if ((playback_speed_ > 0 && queue_end <= audio_playback_queue_time_) || (playback_speed_ < 0 && queue_end >= audio_playback_queue_time_)) { // This will queue nothing, so stop the loop here if (prequeuing_audio_) { - DecrementPrequeuedAudio(); + decrement_prequeued_audio(); } return; } RenderTicketWatcher *watcher = new RenderTicketWatcher(this); - connect(watcher, &RenderTicketWatcher::Finished, this, - &ViewerWidget::ReceivedAudioBufferForPlayback); + connect(watcher, &RenderTicketWatcher::finished, this, + &ViewerWidget::received_audio_buffer_for_playback); audio_playback_queue_.push_back(watcher); - watcher->SetTicket(RenderManager::instance()->GetCacher()->GetRangeOfAudio( - GetConnectedNode(), TimeRange(audio_playback_queue_time_, queue_end))); + watcher->set_ticket(RenderManager::instance()->get_cacher()->get_range_of_audio( + get_connected_node(), TimeRange(audio_playback_queue_time_, queue_end))); audio_playback_queue_time_ = queue_end; } -void ViewerWidget::ReceivedAudioBufferForPlayback() +void ViewerWidget::received_audio_buffer_for_playback() { while (!audio_playback_queue_.empty() && - audio_playback_queue_.front()->HasResult()) { + audio_playback_queue_.front()->has_result()) { RenderTicketWatcher *watcher = audio_playback_queue_.front(); audio_playback_queue_.pop_front(); - if (watcher->HasResult()) { - SampleBuffer samples = watcher->Get().value(); + if (watcher->has_result()) { + SampleBuffer samples = watcher->get().value(); if (samples.is_allocated()) { // If the samples must be reversed, reverse them now if (playback_speed_ < 0) { @@ -888,7 +888,7 @@ void ViewerWidget::ReceivedAudioBufferForPlayback() // Convert to packed data for audio output AudioProcessor::Buffer buf; - int r = audio_processor_.Convert(samples.to_raw_ptrs().data(), + int r = audio_processor_.convert(samples.to_raw_ptrs().data(), samples.sample_count(), &buf); // TempoProcessor may have emptied the array @@ -900,7 +900,7 @@ void ViewerWidget::ReceivedAudioBufferForPlayback() prequeued_audio_.append(pack); } else { // Push directly to audio manager - AudioManager::instance()->PushToOutput( + AudioManager::instance()->push_to_output( audio_processor_.to(), pack); } } @@ -911,14 +911,14 @@ void ViewerWidget::ReceivedAudioBufferForPlayback() } if (prequeuing_audio_) { - DecrementPrequeuedAudio(); + decrement_prequeued_audio(); } delete watcher; } } -void ViewerWidget::ReceivedAudioBufferForScrubbing() +void ViewerWidget::received_audio_buffer_for_scrubbing() { RenderTicketWatcher *watcher = static_cast(sender()); @@ -928,26 +928,26 @@ void ViewerWidget::ReceivedAudioBufferForScrubbing() } if (!audio_scrub_watchers_.empty()) { - if (watcher->HasResult()) { - SampleBuffer samples = watcher->Get().value(); + if (watcher->has_result()) { + SampleBuffer samples = watcher->get().value(); if (samples.is_allocated()) { if (samples.audio_params().channel_count() > 0) { AudioProcessor::Buffer buf; int r = - audio_processor_.Convert(samples.to_raw_ptrs().data(), + audio_processor_.convert(samples.to_raw_ptrs().data(), samples.sample_count(), &buf); if (r >= 0) { if (!buf.empty()) { QString error; const QByteArray &packed = buf.at(0); - AudioManager::instance()->ClearBufferedOutput(); - if (!AudioManager::instance()->PushToOutput( + AudioManager::instance()->clear_buffered_output(); + if (!AudioManager::instance()->push_to_output( audio_processor_.to(), packed, &error)) { - Core::instance()->ShowStatusBarMessage( + Core::instance()->show_status_bar_message( tr("Audio scrubbing failed: %1").arg(error)); } - AudioMonitor::PushSampleBufferOnAll(samples); + AudioMonitor::push_sample_buffer_on_all(samples); } } else { qCritical() @@ -961,113 +961,113 @@ void ViewerWidget::ReceivedAudioBufferForScrubbing() delete watcher; } -void ViewerWidget::QueueStarved() +void ViewerWidget::queue_starved() { - static const int kMaximumWaitTimeMs = 250; - static const rational kMaximumWaitTime(kMaximumWaitTimeMs, 1000); + static const int k_maximum_wait_time_ms = 250; + static const Rational k_maximum_wait_time(k_maximum_wait_time_ms, 1000); qint64 now = QDateTime::currentMSecsSinceEpoch(); if (!queue_starved_start_) { queue_starved_start_ = now; - } else if (now > queue_starved_start_ + kMaximumWaitTimeMs) { + } else if (now > queue_starved_start_ + k_maximum_wait_time_ms) { if (first_requeue_watcher_) { - if (GetConnectedNode()->GetPlayhead() + kMaximumWaitTime < - first_requeue_watcher_->property("time").value()) { + if (get_connected_node()->get_playhead() + k_maximum_wait_time < + first_requeue_watcher_->property("time").value()) { // We still have time return; } } - ForceRequeueFromCurrentTime(); + force_requeue_from_current_time(); queue_starved_start_ = 0; } } -void ViewerWidget::QueueNoLongerStarved() +void ViewerWidget::queue_no_longer_starved() { queue_starved_start_ = 0; } -void ViewerWidget::ForceRequeueFromCurrentTime() +void ViewerWidget::force_requeue_from_current_time() { // Defer the requeue to the next event-loop iteration. This function is often // called from paintEvent paths (QueueStarved) where synchronously cancelling // watchers can re-enter the same RenderTicket mutex and deadlock. QMetaObject::invokeMethod( - this, [this]() { ForceRequeueFromCurrentTimeInternal(); }, + this, [this]() { force_requeue_from_current_time_internal(); }, Qt::QueuedConnection); } -void ViewerWidget::ForceRequeueFromCurrentTimeInternal() +void ViewerWidget::force_requeue_from_current_time_internal() { // Allow half a second for requeue to complete - static const rational kRequeueWaitTime(1); + static const Rational k_requeue_wait_time(1); - RenderManager::instance()->GetCacher()->ClearSingleFrameRenders(); + RenderManager::instance()->get_cacher()->clear_single_frame_renders(); queue_watchers_.clear(); - int queue = DeterminePlaybackQueueSize(); + int queue = determine_playback_queue_size(); playback_queue_next_frame_ = - GetTimestamp() + + get_timestamp() + playback_speed_ * Timecode::time_to_timestamp( - kRequeueWaitTime, timebase(), Timecode::kFloor); + k_requeue_wait_time, timebase(), Timecode::k_floor); ; first_requeue_watcher_ = nullptr; for (int i = 0; i < queue; i++) { - RenderTicketWatcher *watcher = RequestNextFrameForQueue(); + RenderTicketWatcher *watcher = request_next_frame_for_queue(); if (!first_requeue_watcher_) { first_requeue_watcher_ = watcher; connect(first_requeue_watcher_, &RenderTicketWatcher::destroyed, - this, &ViewerWidget::HandleFirstRequeueDestroy); + this, &ViewerWidget::handle_first_requeue_destroy); } } } -void ViewerWidget::UpdateTextureFromNode() +void ViewerWidget::update_texture_from_node() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } - if (IsPlaying()) { + if (is_playing()) { qWarning() << "UpdateTextureFromNode called while playing"; return; } - rational time = GetConnectedNode()->GetPlayhead(); - bool frame_exists_at_time = FrameExistsAtTime(time); - bool frame_might_be_still = ViewerMightBeAStill(); + Rational time = get_connected_node()->get_playhead(); + bool frame_exists = frame_exists_at_time(time); + bool frame_might_be_still = viewer_might_be_a_still(); - if (frame_exists_at_time || frame_might_be_still) { + if (frame_exists || frame_might_be_still) { // Frame was not in queue, will require rendering or decoding from cache // Not playing, run a task to get the frame either from the cache or the renderer RenderTicketWatcher *watcher = new RenderTicketWatcher(); watcher->setProperty("start", QDateTime::currentMSecsSinceEpoch()); watcher->setProperty("time", QVariant::fromValue(time)); - connect(watcher, &RenderTicketWatcher::Finished, this, - &ViewerWidget::RendererGeneratedFrame); + connect(watcher, &RenderTicketWatcher::finished, this, + &ViewerWidget::renderer_generated_frame); nonqueue_watchers_.append(watcher); // Clear queue because we want this frame more than any others RenderManager::instance() - ->GetCacher() - ->ClearSingleFrameRendersThatArentRunning(); + ->get_cacher() + ->clear_single_frame_renders_that_arent_running(); - DetectMulticamNode(time); + detect_multicam_node(time); - watcher->SetTicket(GetFrame(time)); + watcher->set_ticket(get_frame(time)); } else { // There is definitely no frame here, we can immediately flip to showing nothing nonqueue_watchers_.clear(); - SetEmptyImage(); + set_empty_image(); return; } } -void ViewerWidget::PlayInternal(int speed, bool in_to_out_only) +void ViewerWidget::play_internal(int speed, bool in_to_out_only) { Q_ASSERT(speed != 0); - if (!GetConnectedNode()) { + if (!get_connected_node()) { // Do nothing if no viewer node is attached return; } @@ -1078,29 +1078,29 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only) } // Kindly tell all viewers to stop playing and caching so all resources can be used for playback - foreach (ViewerWidget *viewer, instances_) { + foreach (ViewerWidget *viewer, instances) { if (viewer != this) { - viewer->PauseInternal(); + viewer->pause_internal(); } } - RenderManager::instance()->GetCacher()->SetThumbnailsPaused(true); + RenderManager::instance()->get_cacher()->set_thumbnails_paused(true); - RenderManager::instance()->SetAggressiveGarbageCollection(true); + RenderManager::instance()->set_aggressive_garbage_collection(true); // Disarm recording if armed if (record_armed_) { - DisarmRecording(); + disarm_recording(); } // If the playhead is beyond the end, restart at 0 if (!recording_) { - rational last_frame = GetConnectedNode()->GetLength() - timebase(); + Rational last_frame = get_connected_node()->get_length() - timebase(); if (!in_to_out_only && - GetConnectedNode()->GetPlayhead() >= last_frame) { + get_connected_node()->get_playhead() >= last_frame) { if (speed > 0) { - GetConnectedNode()->SetPlayhead(0); + get_connected_node()->set_playhead(0); } else { - GetConnectedNode()->SetPlayhead(last_frame); + get_connected_node()->set_playhead(last_frame); } } } @@ -1108,34 +1108,34 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only) playback_speed_ = speed; play_in_to_out_only_ = in_to_out_only; - playback_queue_next_frame_ = GetTimestamp() + playback_speed_; + playback_queue_next_frame_ = get_timestamp() + playback_speed_; - controls_->ShowPauseButton(); + controls_->show_pause_button(); queue_starved_start_ = 0; // Attempt to fill playback queue - if (IsVideoVisible()) { - prequeue_length_ = DeterminePlaybackQueueSize(); + if (is_video_visible()) { + prequeue_length_ = determine_playback_queue_size(); if (prequeue_length_ > 0) { prequeuing_video_ = true; prequeue_count_ = 0; for (int i = 0; i < prequeue_length_; i++) { - RequestNextFrameForQueue(); + request_next_frame_for_queue(); } dry_run_next_frame_ = playback_queue_next_frame_; - RequestNextDryRun(); + request_next_dry_run(); } } - AudioParams ap = GetConnectedNode()->GetAudioParams(); + AudioParams ap = get_connected_node()->get_audio_params(); qDebug() << "ViewerWidget::PlayInternal: audio params valid=" << ap.is_valid() << "channel_count=" << ap.channel_count(); if (ap.is_valid() && ap.channel_count() != 0) { - UpdateAudioProcessor(); + update_audio_processor(); // Verify audio processor output params are valid before using them AudioParams output_params = audio_processor_.to(); @@ -1145,19 +1145,19 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only) qWarning() << "Audio processor output params are invalid, skipping audio playback"; } else { - AudioManager::instance()->SetOutputNotifyInterval( - output_params.time_to_bytes(kAudioPlaybackInterval)); - connect(AudioManager::instance(), &AudioManager::OutputNotify, this, - &ViewerWidget::QueueNextAudioBuffer); + AudioManager::instance()->set_output_notify_interval( + output_params.time_to_bytes(k_audio_playback_interval)); + connect(AudioManager::instance(), &AudioManager::output_notify, this, + &ViewerWidget::queue_next_audio_buffer); static const int prequeue_count = 2; prequeuing_audio_ = prequeue_count; // Queue two buffers ahead of time - audio_playback_queue_time_ = GetConnectedNode()->GetPlayhead(); + audio_playback_queue_time_ = get_connected_node()->get_playhead(); qDebug() << "ViewerWidget::PlayInternal: prequeuing audio start time=" - << audio_playback_queue_time_.toDouble(); + << audio_playback_queue_time_.to_double(); for (int i = 0; i < prequeue_count; i++) { - QueueNextAudioBuffer(); + queue_next_audio_buffer(); } } } @@ -1165,60 +1165,60 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only) // If there's nothing to prequeue, start playback immediately so the // playhead advances even when only the audio waveform is visible. if (!prequeuing_video_ && !prequeuing_audio_) { - FinishPlayPreprocess(); + finish_play_preprocess(); } // Force screen to stay awake - PreventSleep(true); + prevent_sleep(true); } -void ViewerWidget::PauseInternal() +void ViewerWidget::pause_internal() { if (recording_) { - AudioManager::instance()->StopRecording(); + AudioManager::instance()->stop_recording(); recording_ = false; - controls_->SetPauseButtonRecordingState(false); + controls_->set_pause_button_recording_state(false); - recording_callback_->DisableRecordingOverlay(); - recording_callback_->RecordingCallback( + recording_callback_->disable_recording_overlay(); + recording_callback_->recording_callback( recording_filename_, recording_range_, recording_track_); } - if (IsPlaying()) { + if (is_playing()) { playback_speed_ = 0; - controls_->ShowPlayButton(); + controls_->show_play_button(); foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->Pause(); + dw->pause(); } // Cancel in-flight render tickets before deleting watchers, // otherwise the render thread keeps working on stale frames // and blocks the single-frame render requested by UpdateTextureFromNode(). foreach (RenderTicketWatcher *watcher, queue_watchers_) { - watcher->Cancel(); + watcher->cancel(); } qDeleteAll(queue_watchers_); queue_watchers_.clear(); - RenderManager::instance()->GetCacher()->ClearSingleFrameRenders(); + RenderManager::instance()->get_cacher()->clear_single_frame_renders(); playback_backup_timer_.stop(); // Handle audio - AudioManager::instance()->StopOutput(); - AudioMonitor::StopOnAll(); + AudioManager::instance()->stop_output(); + AudioMonitor::stop_on_all(); prequeued_audio_.clear(); - disconnect(AudioManager::instance(), &AudioManager::OutputNotify, this, - &ViewerWidget::QueueNextAudioBuffer); + disconnect(AudioManager::instance(), &AudioManager::output_notify, this, + &ViewerWidget::queue_next_audio_buffer); qDeleteAll(audio_playback_queue_); audio_playback_queue_.clear(); - UpdateAudioProcessor(); + update_audio_processor(); - RenderManager::instance()->GetCacher()->SetThumbnailsPaused(false); + RenderManager::instance()->get_cacher()->set_thumbnails_paused(false); - UpdateTextureFromNode(); + update_texture_from_node(); - RenderManager::instance()->SetAggressiveGarbageCollection(false); + RenderManager::instance()->set_aggressive_garbage_collection(false); } prequeuing_video_ = false; @@ -1226,88 +1226,88 @@ void ViewerWidget::PauseInternal() dry_run_watchers_.clear(); // Reset screen timeout timer - PreventSleep(false); + prevent_sleep(false); } -void ViewerWidget::PushScrubbedAudio() +void ViewerWidget::push_scrubbed_audio() { - if (!IsPlaying() && GetConnectedNode() && - OLIVE_CONFIG("AudioScrubbing").toBool() && enable_audio_scrubbing_) { + if (!is_playing() && get_connected_node() && + OAK_CONFIG("AudioScrubbing").toBool() && enable_audio_scrubbing_) { if (ignore_scrub_ > 0) { ignore_scrub_--; } if (ignore_scrub_ == 0) { // Get audio src device from renderer - const AudioParams ¶ms = GetConnectedNode()->GetAudioParams(); + const AudioParams ¶ms = get_connected_node()->get_audio_params(); if (params.is_valid()) { // NOTE: Hardcoded scrubbing interval (20ms) - rational interval = rational(20, 1000); + Rational interval = Rational(20, 1000); RenderTicketWatcher *watcher = new RenderTicketWatcher(); - connect(watcher, &RenderTicketWatcher::Finished, this, - &ViewerWidget::ReceivedAudioBufferForScrubbing); + connect(watcher, &RenderTicketWatcher::finished, this, + &ViewerWidget::received_audio_buffer_for_scrubbing); audio_scrub_watchers_.push_back(watcher); - watcher->SetTicket( - RenderManager::instance()->GetCacher()->GetRangeOfAudio( - GetConnectedNode(), - TimeRange(GetConnectedNode()->GetPlayhead(), - GetConnectedNode()->GetPlayhead() + + watcher->set_ticket( + RenderManager::instance()->get_cacher()->get_range_of_audio( + get_connected_node(), + TimeRange(get_connected_node()->get_playhead(), + get_connected_node()->get_playhead() + interval))); } } } } -void ViewerWidget::UpdateMinimumScale() +void ViewerWidget::update_minimum_scale() { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } - if (GetConnectedNode()->GetLength().isNull()) { + if (get_connected_node()->get_length().isNull()) { // Avoids divide by zero - SetMinimumScale(0); + set_minimum_scale(0); } else { double min_scale = static_cast(ruler()->width()) / - GetConnectedNode()->GetLength().toDouble(); + get_connected_node()->get_length().to_double(); // Ensure min_scale doesn't exceed max_scale to prevent crash - min_scale = qMin(min_scale, GetMaximumScale()); - SetMinimumScale(min_scale); + min_scale = qMin(min_scale, get_maximum_scale()); + set_minimum_scale(min_scale); } } -void ViewerWidget::SetColorTransform(const ColorTransform &transform, +void ViewerWidget::set_color_transform(const ColorTransform &transform, ViewerDisplayWidget *sender) { - sender->SetColorTransform(transform); + sender->set_color_transform(transform); } -QString ViewerWidget::GetCachedFilenameFromTime(const rational &time) +QString ViewerWidget::get_cached_filename_from_time(const Rational &time) { - if (FrameExistsAtTime(time)) { - return GetConnectedNode()->video_frame_cache()->GetValidCacheFilename( + if (frame_exists_at_time(time)) { + return get_connected_node()->video_frame_cache()->get_valid_cache_filename( time); } return QString(); } -bool ViewerWidget::FrameExistsAtTime(const rational &time) +bool ViewerWidget::frame_exists_at_time(const Rational &time) { - return GetConnectedNode() && time >= 0 && - time < GetConnectedNode()->GetVideoLength(); + return get_connected_node() && time >= 0 && + time < get_connected_node()->get_video_length(); } -bool ViewerWidget::ViewerMightBeAStill() +bool ViewerWidget::viewer_might_be_a_still() { - return GetConnectedNode() && - GetConnectedNode()->GetConnectedTextureOutput() && - GetConnectedNode()->GetVideoLength().isNull(); + return get_connected_node() && + get_connected_node()->get_connected_texture_output() && + get_connected_node()->get_video_length().isNull(); } -void ViewerWidget::SetDisplayImage(RenderTicketPtr ticket) +void ViewerWidget::set_display_image(RenderTicketPtr ticket) { foreach (ViewerDisplayWidget *dw, playback_devices_) { QVariant push; @@ -1315,21 +1315,21 @@ void ViewerWidget::SetDisplayImage(RenderTicketPtr ticket) if (dynamic_cast(dw)) { push = ticket->property("multicam_output"); } else { - push = ticket->Get(); + push = ticket->get(); } } - dw->SetImage(push); + dw->set_image(push); } } -RenderTicketWatcher *ViewerWidget::RequestNextFrameForQueue(bool increment) +RenderTicketWatcher *ViewerWidget::request_next_frame_for_queue(bool increment) { RenderTicketWatcher *watcher = nullptr; - rational next_time = + Rational next_time = Timecode::timestamp_to_time(playback_queue_next_frame_, timebase()); - if (FrameExistsAtTime(next_time) || ViewerMightBeAStill()) { + if (frame_exists_at_time(next_time) || viewer_might_be_a_still()) { if (increment) { playback_queue_next_frame_ += playback_speed_; } @@ -1337,28 +1337,28 @@ RenderTicketWatcher *ViewerWidget::RequestNextFrameForQueue(bool increment) watcher = new RenderTicketWatcher(); watcher->setProperty("start", QDateTime::currentMSecsSinceEpoch()); watcher->setProperty("time", QVariant::fromValue(next_time)); - DetectMulticamNode(next_time); - connect(watcher, &RenderTicketWatcher::Finished, this, - &ViewerWidget::RendererGeneratedFrameForQueue); + detect_multicam_node(next_time); + connect(watcher, &RenderTicketWatcher::finished, this, + &ViewerWidget::renderer_generated_frame_for_queue); queue_watchers_.append(watcher); - watcher->SetTicket(GetFrame(next_time)); + watcher->set_ticket(get_frame(next_time)); } return watcher; } -RenderTicketPtr ViewerWidget::GetFrame(const rational &t) +RenderTicketPtr ViewerWidget::get_frame(const Rational &t) { - if (IsPlaying() || prequeuing_video_) { - return GetSingleFrame(t); + if (is_playing() || prequeuing_video_) { + return get_single_frame(t); } QString cache_fn = - GetConnectedNode()->video_frame_cache()->GetValidCacheFilename(t); + get_connected_node()->video_frame_cache()->get_valid_cache_filename(t); if (!QFileInfo::exists(cache_fn)) { // Frame hasn't been cached, start render job - return GetSingleFrame(t); + return get_single_frame(t); } else { // Frame has been cached, grab the frame RenderTicketPtr ticket = std::make_shared(); @@ -1366,28 +1366,28 @@ RenderTicketPtr ViewerWidget::GetFrame(const rational &t) QtConcurrent::run( static_cast( - ViewerWidget::DecodeCachedImage), + ViewerWidget::decode_cached_image), ticket, - GetConnectedNode()->video_frame_cache()->GetCacheDirectory(), - GetConnectedNode()->video_frame_cache()->GetUuid(), - Timecode::time_to_timestamp(t, timebase(), Timecode::kFloor)); + get_connected_node()->video_frame_cache()->get_cache_directory(), + get_connected_node()->video_frame_cache()->get_uuid(), + Timecode::time_to_timestamp(t, timebase(), Timecode::k_floor)); return ticket; } } -void ViewerWidget::FinishPlayPreprocess() +void ViewerWidget::finish_play_preprocess() { // Check if we're still waiting for video or audio respectively if (prequeuing_video_ || prequeuing_audio_) { return; } - int64_t playback_start_time = GetTimestamp(); + int64_t playback_start_time = get_timestamp(); // Start audio waveform playback if (!prequeued_audio_.isEmpty()) { QString error; - if (!AudioManager::instance()->PushToOutput(audio_processor_.to(), + if (!AudioManager::instance()->push_to_output(audio_processor_.to(), prequeued_audio_, &error)) { QMessageBox::critical( this, tr("Audio Error"), @@ -1397,16 +1397,16 @@ void ViewerWidget::FinishPlayPreprocess() } prequeued_audio_.clear(); - AudioMonitor::StartWaveformOnAll( - GetConnectedNode()->GetConnectedWaveform(), - GetConnectedNode()->GetPlayhead(), playback_speed_); + AudioMonitor::start_waveform_on_all( + get_connected_node()->get_connected_waveform(), + get_connected_node()->get_playhead(), playback_speed_); } - display_widget_->ResetFPSTimer(); + display_widget_->reset_fps_timer(); foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->Play(playback_start_time, playback_speed_, timebase(), - IsVideoVisible()); + dw->play(playback_start_time, playback_speed_, timebase(), + is_video_visible()); } // This is our timer for loading the queue and setting the time @@ -1414,10 +1414,10 @@ void ViewerWidget::FinishPlayPreprocess() qMax(1, qFloor(timebase_dbl() * 1000.0))); playback_backup_timer_.start(); - PlaybackTimerUpdate(); + playback_timer_update(); } -int ViewerWidget::DeterminePlaybackQueueSize() +int ViewerWidget::determine_playback_queue_size() { if (playback_speed_ == 0) { return 0; @@ -1427,69 +1427,69 @@ int ViewerWidget::DeterminePlaybackQueueSize() if (playback_speed_ > 0) { end_ts = Timecode::time_to_timestamp( - GetConnectedNode()->GetVideoLength(), timebase()); + get_connected_node()->get_video_length(), timebase()); } else { end_ts = 0; } - int remaining_frames = (end_ts - GetTimestamp() - 1) / playback_speed_; + int remaining_frames = (end_ts - get_timestamp() - 1) / playback_speed_; // Generate maximum queue int max_frames = - qCeil(kVideoPlaybackInterval.toDouble() / timebase().toDouble()); + qCeil(k_video_playback_interval.to_double() / timebase().to_double()); return qMin(max_frames, remaining_frames); } -void ViewerWidget::ContextMenuSetFullScreen(QAction *action) +void ViewerWidget::context_menu_set_full_screen(QAction *action) { - SetFullScreen(QGuiApplication::screens().at(action->data().toInt())); + set_full_screen(QGuiApplication::screens().at(action->data().toInt())); } -void ViewerWidget::ContextMenuSetPlaybackRes(QAction *action) +void ViewerWidget::context_menu_set_playback_res(QAction *action) { int div = action->data().toInt(); - auto vp = GetConnectedNode()->GetVideoParams(); + auto vp = get_connected_node()->get_video_params(); vp.set_divider(div); auto c = new NodeParamSetStandardValueCommand( NodeKeyframeTrackReference( - NodeInput(GetConnectedNode(), ViewerOutput::kVideoParamsInput, 0)), + NodeInput(get_connected_node(), ViewerOutput::k_video_params_input, 0)), QVariant::fromValue(vp)); Core::instance()->undo_stack()->push(c, tr("Changed Playback Resolution")); } -void ViewerWidget::ContextMenuDisableSafeMargins() +void ViewerWidget::context_menu_disable_safe_margins() { - context_menu_widget_->SetSafeMargins(ViewerSafeMarginInfo(false)); + context_menu_widget_->set_safe_margins(ViewerSafeMarginInfo(false)); } -void ViewerWidget::ContextMenuSetSafeMargins() +void ViewerWidget::context_menu_set_safe_margins() { - context_menu_widget_->SetSafeMargins(ViewerSafeMarginInfo(true)); + context_menu_widget_->set_safe_margins(ViewerSafeMarginInfo(true)); } -void ViewerWidget::ContextMenuSetCustomSafeMargins() +void ViewerWidget::context_menu_set_custom_safe_margins() { bool ok; - double new_ratio = GetFloatRatioFromUser(this, tr("Safe Margins"), &ok); + double new_ratio = get_float_ratio_from_user(this, tr("Safe Margins"), &ok); if (ok) { - context_menu_widget_->SetSafeMargins( + context_menu_widget_->set_safe_margins( ViewerSafeMarginInfo(true, new_ratio)); } } -void ViewerWidget::WindowAboutToClose() +void ViewerWidget::window_about_to_close() { ViewerWindow *vw = static_cast(sender()); windows_.remove(windows_.key(vw)); playback_devices_.removeOne(vw->display_widget()); } -void ViewerWidget::RendererGeneratedFrame() +void ViewerWidget::renderer_generated_frame() { RenderTicketWatcher *ticket = static_cast(sender()); @@ -1501,32 +1501,32 @@ void ViewerWidget::RendererGeneratedFrame() } } - if (ticket->HasResult()) { - SetDisplayImage(ticket->GetTicket()); + if (ticket->has_result()) { + set_display_image(ticket->get_ticket()); } } delete ticket; } -void ViewerWidget::RendererGeneratedFrameForQueue() +void ViewerWidget::renderer_generated_frame_for_queue() { RenderTicketWatcher *watcher = static_cast(sender()); if (queue_watchers_.contains(watcher)) { queue_watchers_.removeOne(watcher); - if (watcher->HasResult()) { - QVariant frame = watcher->Get(); + if (watcher->has_result()) { + QVariant frame = watcher->get(); bool drop_frame = false; // Ignore this signal if we've paused now - if (IsPlaying() || prequeuing_video_) { + if (is_playing() || prequeuing_video_) { const qint64 start_ms = watcher->property("start").toLongLong(); const qint64 now_ms = QDateTime::currentMSecsSinceEpoch(); const int playback_step = qMax(1, qAbs(playback_speed_)); const double frame_interval_ms = - qMax(1.0, timebase().toDouble() * 1000.0 / + qMax(1.0, timebase().to_double() * 1000.0 / static_cast(playback_step)); if (start_ms > 0 && (now_ms - start_ms) > frame_interval_ms) { // If the queue is nearly empty, keep the frame anyway @@ -1537,7 +1537,7 @@ void ViewerWidget::RendererGeneratedFrameForQueue() } } - rational ts = watcher->property("time").value(); + Rational ts = watcher->property("time").value(); if (!drop_frame) { foreach (ViewerDisplayWidget *dw, playback_devices_) { @@ -1545,7 +1545,7 @@ void ViewerWidget::RendererGeneratedFrameForQueue() dynamic_cast(dw); QVariant push; if (is_multicam) { - push = watcher->GetTicket()->property( + push = watcher->get_ticket()->property( "multicam_output"); if (!push.isValid() || push.isNull()) { // Fall back to the primary frame when multicam isn't available. @@ -1555,7 +1555,7 @@ void ViewerWidget::RendererGeneratedFrameForQueue() push = frame; } - dw->queue()->AppendTimewise({ ts, push }, + dw->queue()->append_timewise({ ts, push }, playback_speed_); } } @@ -1565,7 +1565,7 @@ void ViewerWidget::RendererGeneratedFrameForQueue() if (prequeue_count_ == prequeue_length_) { prequeuing_video_ = false; - FinishPlayPreprocess(); + finish_play_preprocess(); } else { // This call was mostly necessary to keep the threads busy between prequeue and playback. // If we only have a single render thread, it's no longer necessary. @@ -1583,9 +1583,9 @@ void ViewerWidget::RendererGeneratedFrameForQueue() delete watcher; } -void ViewerWidget::ShowContextMenu(const QPoint &pos) +void ViewerWidget::show_context_menu(const QPoint &pos) { - if (!GetConnectedNode()) { + if (!get_connected_node()) { return; } @@ -1599,23 +1599,23 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) if (context_menu_widget_->color_manager() && color_menu_enabled_) { { Menu *ocio_colorspace_menu = - context_menu_widget_->GetColorSpaceMenu(&menu); + context_menu_widget_->get_color_space_menu(&menu); menu.addMenu(ocio_colorspace_menu); } { Menu *ocio_display_menu = - context_menu_widget_->GetDisplayMenu(&menu); + context_menu_widget_->get_display_menu(&menu); menu.addMenu(ocio_display_menu); } { - Menu *ocio_view_menu = context_menu_widget_->GetViewMenu(&menu); + Menu *ocio_view_menu = context_menu_widget_->get_view_menu(&menu); menu.addMenu(ocio_view_menu); } { - Menu *ocio_look_menu = context_menu_widget_->GetLookMenu(&menu); + Menu *ocio_look_menu = context_menu_widget_->get_look_menu(&menu); menu.addMenu(ocio_look_menu); } @@ -1628,13 +1628,13 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) menu.addMenu(zoom_menu); zoom_menu->addAction(tr("Fit"))->setData(-1); - for (int i = 0; i < ViewerSizer::kZoomLevelCount; i++) { - double z = ViewerSizer::kZoomLevels[i]; + for (int i = 0; i < ViewerSizer::k_zoom_level_count; i++) { + double z = ViewerSizer::k_zoom_levels[i]; zoom_menu->addAction(tr("%1%").arg(z * 100.0))->setData(z); } connect(zoom_menu, &QMenu::triggered, this, - &ViewerWidget::SetZoomFromMenu); + &ViewerWidget::set_zoom_from_menu); } { @@ -1658,7 +1658,7 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) } connect(full_screen_menu, &QMenu::triggered, this, - &ViewerWidget::ContextMenuSetFullScreen); + &ViewerWidget::context_menu_set_full_screen); } { @@ -1667,27 +1667,27 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) new Menu(tr("Playback Resolution"), &menu); menu.addMenu(playback_res_menu); - for (int d : VideoParams::kSupportedDividers) { - playback_res_menu->AddActionWithData( - VideoParams::GetNameForDivider(d), d, - GetConnectedNode()->GetVideoParams().divider()); + for (int d : VideoParams::k_supported_dividers) { + playback_res_menu->add_action_with_data( + VideoParams::get_name_for_divider(d), d, + get_connected_node()->get_video_params().divider()); } connect(playback_res_menu, &QMenu::triggered, this, - &ViewerWidget::ContextMenuSetPlaybackRes); + &ViewerWidget::context_menu_set_playback_res); } { // Deinterlace Option - if (GetConnectedNode()->GetVideoParams().interlacing() != - VideoParams::kInterlaceNone) { + if (get_connected_node()->get_video_params().interlacing() != + VideoParams::k_interlace_none) { QAction *deinterlace_action = menu.addAction(tr("Deinterlace")); deinterlace_action->setCheckable(true); deinterlace_action->setChecked( - display_widget_->IsDeinterlacing()); + display_widget_->is_deinterlacing()); connect(deinterlace_action, &QAction::triggered, display_widget_, - &ViewerDisplayWidget::SetDeinterlacing); + &ViewerDisplayWidget::set_deinterlacing); } } @@ -1717,26 +1717,26 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) QAction *safe_margin_off = safe_margin_menu->addAction(tr("Off")); safe_margin_off->setCheckable(true); safe_margin_off->setChecked( - !context_menu_widget_->GetSafeMargin().is_enabled()); + !context_menu_widget_->get_safe_margin().is_enabled()); connect(safe_margin_off, &QAction::triggered, this, - &ViewerWidget::ContextMenuDisableSafeMargins); + &ViewerWidget::context_menu_disable_safe_margins); QAction *safe_margin_on = safe_margin_menu->addAction(tr("On")); safe_margin_on->setCheckable(true); safe_margin_on->setChecked( - context_menu_widget_->GetSafeMargin().is_enabled() && - !context_menu_widget_->GetSafeMargin().custom_ratio()); + context_menu_widget_->get_safe_margin().is_enabled() && + !context_menu_widget_->get_safe_margin().custom_ratio()); connect(safe_margin_on, &QAction::triggered, this, - &ViewerWidget::ContextMenuSetSafeMargins); + &ViewerWidget::context_menu_set_safe_margins); QAction *safe_margin_custom = safe_margin_menu->addAction(tr("Custom Aspect")); safe_margin_custom->setCheckable(true); safe_margin_custom->setChecked( - context_menu_widget_->GetSafeMargin().is_enabled() && - context_menu_widget_->GetSafeMargin().custom_ratio()); + context_menu_widget_->get_safe_margin().is_enabled() && + context_menu_widget_->get_safe_margin().custom_ratio()); connect(safe_margin_custom, &QAction::triggered, this, - &ViewerWidget::ContextMenuSetCustomSafeMargins); + &ViewerWidget::context_menu_set_custom_safe_margins); } menu.addSeparator(); @@ -1747,9 +1747,9 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) menu.addAction(tr("Stop Playback On Last Frame")); stop_playback_on_last_frame->setCheckable(true); stop_playback_on_last_frame->setChecked( - OLIVE_CONFIG("StopPlaybackOnLastFrame").toBool()); + OAK_CONFIG("StopPlaybackOnLastFrame").toBool()); connect(stop_playback_on_last_frame, &QAction::triggered, this, - [](bool e) { OLIVE_CONFIG("StopPlaybackOnLastFrame") = e; }); + [](bool e) { OAK_CONFIG("StopPlaybackOnLastFrame") = e; }); menu.addSeparator(); } @@ -1758,23 +1758,23 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) auto waveform_menu = new Menu(tr("Audio Waveform"), &menu); menu.addMenu(waveform_menu); - waveform_menu->AddActionWithData(tr("Automatically Show/Hide"), - kWFAutomatic, waveform_mode_); - waveform_menu->AddActionWithData(tr("Show Waveform Only"), - kWFWaveformOnly, waveform_mode_); - waveform_menu->AddActionWithData(tr("Show Both Viewer And Waveform"), - kWFViewerAndWaveform, waveform_mode_); + waveform_menu->add_action_with_data(tr("Automatically Show/Hide"), + k_wf_automatic, waveform_mode_); + waveform_menu->add_action_with_data(tr("Show Waveform Only"), + k_wf_waveform_only, waveform_mode_); + waveform_menu->add_action_with_data(tr("Show Both Viewer And Waveform"), + k_wf_viewer_and_waveform, waveform_mode_); connect(waveform_menu, &Menu::triggered, this, - &ViewerWidget::UpdateWaveformModeFromMenu); + &ViewerWidget::update_waveform_mode_from_menu); } { QAction *show_fps_action = menu.addAction(tr("Show FPS")); show_fps_action->setCheckable(true); - show_fps_action->setChecked(display_widget_->GetShowFPS()); + show_fps_action->setChecked(display_widget_->get_show_fps()); connect(show_fps_action, &QAction::triggered, display_widget_, - &ViewerDisplayWidget::SetShowFPS); + &ViewerDisplayWidget::set_show_fps); } if (context_menu_widget_ == display_widget_) { @@ -1784,24 +1784,24 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) QAction *show_subtitles_action = subtitle_menu->addAction(tr("Show Subtitles")); show_subtitles_action->setCheckable(true); - show_subtitles_action->setChecked(display_widget_->GetShowSubtitles()); + show_subtitles_action->setChecked(display_widget_->get_show_subtitles()); connect(show_subtitles_action, &QAction::triggered, display_widget_, - &ViewerDisplayWidget::SetShowSubtitles); + &ViewerDisplayWidget::set_show_subtitles); subtitle_menu->addSeparator(); auto subtitle_font_properties = subtitle_menu->addAction(tr("Subtitle Properties")); connect(subtitle_font_properties, &QAction::triggered, this, - &ViewerWidget::ShowSubtitleProperties); + &ViewerWidget::show_subtitle_properties); auto subtitle_antialias = subtitle_menu->addAction(tr("Use Anti-aliasing")); subtitle_antialias->setCheckable(true); subtitle_antialias->setChecked( - OLIVE_CONFIG("AntialiasSubtitles").toBool()); + OAK_CONFIG("AntialiasSubtitles").toBool()); connect(subtitle_antialias, &QAction::triggered, this, [this](bool e) { - OLIVE_CONFIG("AntialiasSubtitles") = e; + OAK_CONFIG("AntialiasSubtitles") = e; display_widget_->update(); }); } @@ -1810,33 +1810,33 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos) auto save_frame_as_image = menu.addAction(tr("Save Frame As Image")); connect(save_frame_as_image, &QAction::triggered, this, - &ViewerWidget::SaveFrameAsImage); + &ViewerWidget::save_frame_as_image); menu.exec(static_cast(sender())->mapToGlobal(pos)); } -void ViewerWidget::Play(bool in_to_out_only) +void ViewerWidget::play(bool in_to_out_only) { if (in_to_out_only) { - if (GetConnectedNode() && - GetConnectedNode()->GetWorkArea()->enabled()) { + if (get_connected_node() && + get_connected_node()->get_work_area()->enabled()) { // Jump to in point - GetConnectedNode()->SetPlayhead( - GetConnectedNode()->GetWorkArea()->in()); + get_connected_node()->set_playhead( + get_connected_node()->get_work_area()->in()); } else { in_to_out_only = false; } } else if (record_armed_) { - DisarmRecording(); + disarm_recording(); - if (GetConnectedNode()->project()->filename().isEmpty()) { + if (get_connected_node()->project()->filename().isEmpty()) { QMessageBox::critical( this, tr("Audio Recording"), tr("Project must be saved before you can record audio.")); return; } - QDir audio_path(QFileInfo(GetConnectedNode()->project()->filename()) + QDir audio_path(QFileInfo(get_connected_node()->project()->filename()) .dir() .filePath(tr("audio"))); if (!audio_path.exists()) { @@ -1845,29 +1845,29 @@ void ViewerWidget::Play(bool in_to_out_only) recording_filename_ = audio_path.filePath(QStringLiteral("%1.%2").arg( QDateTime::currentDateTime().toString("yyyy-MM-dd hh-mm-ss"), - ExportFormat::GetExtension(static_cast( - OLIVE_CONFIG("AudioRecordingFormat").toInt())))); + ExportFormat::get_extension(static_cast( + OAK_CONFIG("AudioRecordingFormat").toInt())))); AudioParams ap( - OLIVE_CONFIG("AudioRecordingSampleRate").toInt(), - OLIVE_CONFIG("AudioRecordingChannelLayout").toULongLong(), - SampleFormat::from_string(OLIVE_CONFIG("AudioRecordingSampleFormat") + OAK_CONFIG("AudioRecordingSampleRate").toInt(), + OAK_CONFIG("AudioRecordingChannelLayout").toULongLong(), + SampleFormat::from_string(OAK_CONFIG("AudioRecordingSampleFormat") .toString() .toStdString())); EncodingParams encode_param; - encode_param.EnableAudio( + encode_param.enable_audio( ap, static_cast( - OLIVE_CONFIG("AudioRecordingCodec").toInt())); - encode_param.SetFilename(recording_filename_); + OAK_CONFIG("AudioRecordingCodec").toInt())); + encode_param.set_filename(recording_filename_); encode_param.set_audio_bit_rate( - OLIVE_CONFIG("AudioRecordingBitRate").toInt() * 1000); + OAK_CONFIG("AudioRecordingBitRate").toInt() * 1000); QString error; - if (AudioManager::instance()->StartRecording(encode_param, &error)) { + if (AudioManager::instance()->start_recording(encode_param, &error)) { recording_ = true; - controls_->SetPauseButtonRecordingState(true); - recording_callback_->EnableRecordingOverlay( + controls_->set_pause_button_recording_state(true); + recording_callback_->enable_recording_overlay( TimelineCoordinate(recording_range_.in(), recording_track_)); } else { QMessageBox::critical( @@ -1877,25 +1877,25 @@ void ViewerWidget::Play(bool in_to_out_only) } } - PlayInternal(1, in_to_out_only); + play_internal(1, in_to_out_only); } -void ViewerWidget::Play() +void ViewerWidget::play() { - Play(false); + play(false); } -void ViewerWidget::Pause() +void ViewerWidget::pause() { - PauseInternal(); + pause_internal(); } -void ViewerWidget::ShuttleLeft() +void ViewerWidget::shuttle_left() { int current_speed = playback_speed_; if (current_speed != 0) { - PauseInternal(); + pause_internal(); } current_speed--; @@ -1904,20 +1904,20 @@ void ViewerWidget::ShuttleLeft() current_speed--; } - PlayInternal(current_speed, false); + play_internal(current_speed, false); } -void ViewerWidget::ShuttleStop() +void ViewerWidget::shuttle_stop() { - Pause(); + pause(); } -void ViewerWidget::ShuttleRight() +void ViewerWidget::shuttle_right() { int current_speed = playback_speed_; if (current_speed != 0) { - PauseInternal(); + pause_internal(); } current_speed++; @@ -1926,40 +1926,40 @@ void ViewerWidget::ShuttleRight() current_speed++; } - PlayInternal(current_speed, false); + play_internal(current_speed, false); } -void ViewerWidget::SetColorTransform(const ColorTransform &transform) +void ViewerWidget::set_color_transform(const ColorTransform &transform) { - SetColorTransform(transform, display_widget_); + set_color_transform(transform, display_widget_); } -void ViewerWidget::SetSignalCursorColorEnabled(bool e) +void ViewerWidget::set_signal_cursor_color_enabled(bool e) { foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->SetSignalCursorColorEnabled(e); + dw->set_signal_cursor_color_enabled(e); } } -void ViewerWidget::TimebaseChangedEvent(const rational &timebase) +void ViewerWidget::TimebaseChangedEvent(const Rational &timebase) { super::TimebaseChangedEvent(timebase); - controls_->SetTimebase(timebase); + controls_->set_timebase(timebase); - controls_->SetTime(GetConnectedNode() ? GetConnectedNode()->GetPlayhead() : + controls_->set_time(get_connected_node() ? get_connected_node()->get_playhead() : 0); - LengthChangedSlot(GetConnectedNode() ? GetConnectedNode()->GetLength() : 0); + length_changed_slot(get_connected_node() ? get_connected_node()->get_length() : 0); } -void ViewerWidget::PlaybackTimerUpdate() +void ViewerWidget::playback_timer_update() { Q_ASSERT(playback_speed_ != 0); - rational current_time = Timecode::timestamp_to_time( - display_widget_->timer()->GetTimestampNow(), timebase()); + Rational current_time = Timecode::timestamp_to_time( + display_widget_->timer()->get_timestamp_now(), timebase()); - rational min_time, max_time; + Rational min_time, max_time; if (recording_ && recording_range_.out() != recording_range_.in()) { // Limit recording range if applicable @@ -1967,24 +1967,24 @@ void ViewerWidget::PlaybackTimerUpdate() max_time = recording_range_.out(); } else if (play_in_to_out_only_ && - GetConnectedNode()->GetWorkArea()->enabled()) { + get_connected_node()->get_work_area()->enabled()) { // If "play in to out" is enabled or we're looping AND we have a workarea, only play the workarea - min_time = GetConnectedNode()->GetWorkArea()->in(); - max_time = GetConnectedNode()->GetWorkArea()->out(); + min_time = get_connected_node()->get_work_area()->in(); + max_time = get_connected_node()->get_work_area()->out(); } else { // Otherwise set the bounds to the range of the sequence min_time = 0; - max_time = GetConnectedNode()->GetLength(); + max_time = get_connected_node()->get_length(); } // If we're stopping playback on the last frame rather than after it, subtract our max time // by one timebase unit - if (OLIVE_CONFIG("StopPlaybackOnLastFrame").toBool()) { + if (OAK_CONFIG("StopPlaybackOnLastFrame").toBool()) { max_time = qMax(min_time, max_time - timebase()); } - rational time_to_set; + Rational time_to_set; bool end_of_line = false; bool play_after_pause = false; @@ -1992,7 +1992,7 @@ void ViewerWidget::PlaybackTimerUpdate() ((playback_speed_ < 0 && current_time <= min_time) || (playback_speed_ > 0 && current_time >= max_time))) { // Determine which timestamp we tripped - rational tripped_time; + Rational tripped_time; if (current_time <= min_time) { tripped_time = min_time; @@ -2004,7 +2004,7 @@ void ViewerWidget::PlaybackTimerUpdate() // or restart playback end_of_line = true; - if (OLIVE_CONFIG("Loop").toBool() && !recording_) { + if (OAK_CONFIG("Loop").toBool() && !recording_) { // If we're looping, jump to the other side of the workarea and continue time_to_set = (tripped_time == min_time) ? max_time : min_time; @@ -2025,22 +2025,22 @@ void ViewerWidget::PlaybackTimerUpdate() // pausing. Even if we pause it later with `end_of_line`, we prefer pausing after setting the time // so that an audio scrub event, etc. isn't sent. time_changed_from_timer_ = true; - GetConnectedNode()->SetPlayhead(time_to_set); + get_connected_node()->set_playhead(time_to_set); time_changed_from_timer_ = false; if (end_of_line) { // Cache the current speed int current_speed = playback_speed_; - PauseInternal(); + pause_internal(); if (play_after_pause) { - PlayInternal(current_speed, play_in_to_out_only_); + play_internal(current_speed, play_in_to_out_only_); } } - if (IsPlaying() && IsVideoVisible()) { + if (is_playing() && is_video_visible()) { while ((int(display_widget_->queue()->size()) + - queue_watchers_.size()) < DeterminePlaybackQueueSize()) { - if (!RequestNextFrameForQueue()) { + queue_watchers_.size()) < determine_playback_queue_size()) { + if (!request_next_frame_for_queue()) { // Prevent infinite loop break; } @@ -2048,106 +2048,106 @@ void ViewerWidget::PlaybackTimerUpdate() } foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->queue()->PurgeBefore(current_time, playback_speed_); + dw->queue()->purge_before(current_time, playback_speed_); } } -void ViewerWidget::SetViewerResolution(int width, int height) +void ViewerWidget::set_viewer_resolution(int width, int height) { - sizer_->SetChildSize(width, height); + sizer_->set_child_size(width, height); foreach (ViewerWindow *vw, windows_) { - vw->SetResolution(width, height); + vw->set_resolution(width, height); } } -void ViewerWidget::SetViewerPixelAspect(const rational &ratio) +void ViewerWidget::set_viewer_pixel_aspect(const Rational &ratio) { - sizer_->SetPixelAspectRatio(ratio); + sizer_->set_pixel_aspect_ratio(ratio); foreach (ViewerWindow *vw, windows_) { - vw->SetPixelAspectRatio(ratio); + vw->set_pixel_aspect_ratio(ratio); } } -void ViewerWidget::LengthChangedSlot(const rational &length) +void ViewerWidget::length_changed_slot(const Rational &length) { if (last_length_ != length) { - controls_->SetEndTime(length); - UpdateMinimumScale(); + controls_->set_end_time(length); + update_minimum_scale(); - if (GetConnectedNode() && length < last_length_ && - GetConnectedNode()->GetPlayhead() >= length) { - UpdateTextureFromNode(); + if (get_connected_node() && length < last_length_ && + get_connected_node()->get_playhead() >= length) { + update_texture_from_node(); } last_length_ = length; } } -void ViewerWidget::InterlacingChangedSlot(VideoParams::Interlacing interlacing) +void ViewerWidget::interlacing_changed_slot(VideoParams::Interlacing interlacing) { // Automatically set a "sane" deinterlacing option - bool deint = interlacing != VideoParams::kInterlaceNone; + bool deint = interlacing != VideoParams::k_interlace_none; foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->SetDeinterlacing(deint); + dw->set_deinterlacing(deint); } } -void ViewerWidget::UpdateRendererVideoParameters() +void ViewerWidget::update_renderer_video_parameters() { - VideoParams vp = GetConnectedNode()->GetVideoParams(); + VideoParams vp = get_connected_node()->get_video_params(); foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->SetVideoParams(vp); + dw->set_video_params(vp); } } -void ViewerWidget::UpdateRendererAudioParameters() +void ViewerWidget::update_renderer_audio_parameters() { - AudioParams ap = GetConnectedNode()->GetAudioParams(); + AudioParams ap = get_connected_node()->get_audio_params(); - UpdateAudioProcessor(); + update_audio_processor(); foreach (ViewerDisplayWidget *dw, playback_devices_) { - dw->SetAudioParams(ap); + dw->set_audio_params(ap); } } -void ViewerWidget::SetZoomFromMenu(QAction *action) +void ViewerWidget::set_zoom_from_menu(QAction *action) { - auto s = sizer_->GetContainerSize(); - sizer_->SetZoomAnchored(action->data().toDouble(), s.width() / 2, + auto s = sizer_->get_container_size(); + sizer_->set_zoom_anchored(action->data().toDouble(), s.width() / 2, s.height() / 2); } -void ViewerWidget::ViewerInvalidatedVideoRange(const TimeRange &range) +void ViewerWidget::viewer_invalidated_video_range(const TimeRange &range) { // If our current frame is within this range, we need to update - if (!IsPlaying() && GetConnectedNode()->GetPlayhead() >= range.in() && - (GetConnectedNode()->GetPlayhead() < range.out() || + if (!is_playing() && get_connected_node()->get_playhead() >= range.in() && + (get_connected_node()->get_playhead() < range.out() || range.in() == range.out())) { - QMetaObject::invokeMethod(this, &ViewerWidget::UpdateTextureFromNode, + QMetaObject::invokeMethod(this, &ViewerWidget::update_texture_from_node, Qt::QueuedConnection); } } -void ViewerWidget::UpdateWaveformModeFromMenu(QAction *a) +void ViewerWidget::update_waveform_mode_from_menu(QAction *a) { - SetWaveformMode(static_cast(a->data().toInt())); + set_waveform_mode(static_cast(a->data().toInt())); } -void ViewerWidget::DragEntered(QDragEnterEvent *event) +void ViewerWidget::drag_entered(QDragEnterEvent *event) { - if (event->mimeData()->formats().contains(Project::kItemMimeType)) { + if (event->mimeData()->formats().contains(Project::k_item_mime_type)) { event->accept(); } } -void ViewerWidget::Dropped(QDropEvent *event) +void ViewerWidget::dropped(QDropEvent *event) { - QByteArray mimedata = event->mimeData()->data(Project::kItemMimeType); + QByteArray mimedata = event->mimeData()->data(Project::k_item_mime_type); QDataStream stream(&mimedata, QIODevice::ReadOnly); // Variables to deserialize into @@ -2166,7 +2166,7 @@ void ViewerWidget::Dropped(QDropEvent *event) ViewerOutput *viewer = dynamic_cast(item); if (viewer) { - ConnectViewerNode(viewer); + connect_viewer_node(viewer); } } } diff --git a/app/widget/viewer/viewer.h b/app/widget/viewer/viewer.h index 9e528d64c..c7a939b08 100644 --- a/app/widget/viewer/viewer.h +++ b/app/widget/viewer/viewer.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWER_WIDGET_H -#define VIEWER_WIDGET_H +#ifndef OAK_VIEWER_WIDGET_H +#define OAK_VIEWER_WIDGET_H #include #include @@ -53,10 +53,10 @@ class ViewerWidget : public TimeBasedWidget { Q_OBJECT public: enum WaveformMode { - kWFAutomatic, - kWFViewerOnly, - kWFWaveformOnly, - kWFViewerAndWaveform + k_wf_automatic, + k_wf_viewer_only, + k_wf_waveform_only, + k_wf_viewer_and_waveform }; ViewerWidget(QWidget *parent = nullptr) @@ -66,13 +66,13 @@ public: virtual ~ViewerWidget() override; - void SetPlaybackControlsEnabled(bool enabled); + void set_playback_controls_enabled(bool enabled); - void SetTimeRulerEnabled(bool enabled); + void set_time_ruler_enabled(bool enabled); - void TogglePlayPause(); + void toggle_play_pause(); - bool IsPlaying() const; + bool is_playing() const; /** * @brief Enable or disable the color management menu @@ -80,122 +80,122 @@ public: * While the Viewer is _always_ color managed, In some contexts, the color management may be controlled from an * external UI making the menu unnecessary. */ - void SetColorMenuEnabled(bool enabled); + void set_color_menu_enabled(bool enabled); - void SetMatrix(const QMatrix4x4 &mat); + void set_matrix(const QMatrix4x4 &mat); /** * @brief Creates a ViewerWindow widget and places it full screen on another screen * * If `screen` is nullptr, the screen will be automatically selected as whichever one contains the mouse cursor. */ - void SetFullScreen(QScreen *screen = nullptr); + void set_full_screen(QScreen *screen = nullptr); ColorManager *color_manager() const { return display_widget_->color_manager(); } - void SetGizmos(Node *node); + void set_gizmos(Node *node); - void StartCapture(TimelineWidget *source, const TimeRange &time, + void start_capture(TimelineWidget *source, const TimeRange &time, const Track::Reference &track); - void SetAudioScrubbingEnabled(bool e) + void set_audio_scrubbing_enabled(bool e) { enable_audio_scrubbing_ = e; } - void AddPlaybackDevice(ViewerDisplayWidget *vw) + void add_playback_device(ViewerDisplayWidget *vw) { playback_devices_.push_back(vw); } - void SetTimelineSelectedBlocks(const QVector &b) + void set_timeline_selected_blocks(const QVector &b) { timeline_selected_blocks_ = b; - if (!IsPlaying()) { + if (!is_playing()) { // If is playing, this will happen by the next frame automatically - DetectMulticamNodeNow(); - UpdateTextureFromNode(); + detect_multicam_node_now(); + update_texture_from_node(); } } - void SetNodeViewSelections(const QVector &n) + void set_node_view_selections(const QVector &n) { node_view_selected_ = n; - if (!IsPlaying()) { + if (!is_playing()) { // If is playing, this will happen by the next frame automatically - DetectMulticamNodeNow(); - UpdateTextureFromNode(); + detect_multicam_node_now(); + update_texture_from_node(); } } - void ConnectMulticamWidget(MulticamWidget *p); + void connect_multicam_widget(MulticamWidget *p); public slots: - void Play(bool in_to_out_only); + void play(bool in_to_out_only); - void Play(); + void play(); - void Pause(); + void pause(); - void ShuttleLeft(); + void shuttle_left(); - void ShuttleStop(); + void shuttle_stop(); - void ShuttleRight(); + void shuttle_right(); - void SetColorTransform(const ColorTransform &transform); + void set_color_transform(const ColorTransform &transform); /** * @brief Wrapper for ViewerGLWidget::SetSignalCursorColorEnabled() */ - void SetSignalCursorColorEnabled(bool e); + void set_signal_cursor_color_enabled(bool e); - void CacheEntireSequence(); + void cache_entire_sequence(); - void CacheSequenceInOut(); + void cache_sequence_in_out(); - void SetViewerResolution(int width, int height); + void set_viewer_resolution(int width, int height); - void SetViewerPixelAspect(const rational &ratio); + void set_viewer_pixel_aspect(const Rational &ratio); - void UpdateTextureFromNode(); + void update_texture_from_node(); - void RequestStartEditingText() + void request_start_editing_text() { - display_widget_->RequestStartEditingText(); + display_widget_->request_start_editing_text(); } signals: /** * @brief Wrapper for ViewerGLWidget::CursorColor() */ - void CursorColor(const Color &reference, const Color &display); + void cursor_color(const Color &reference, const Color &display); /** * @brief Signal emitted when a new frame is loaded */ - void TextureChanged(TexturePtr t); + void texture_changed(TexturePtr t); /** * @brief Wrapper for ViewerGLWidget::ColorProcessorChanged() */ - void ColorProcessorChanged(ColorProcessorPtr processor); + void color_processor_changed(ColorProcessorPtr processor); /** * @brief Wrapper for ViewerGLWidget::ColorManagerChanged() */ - void ColorManagerChanged(ColorManager *color_manager); + void color_manager_changed(ColorManager *color_manager); protected: ViewerWidget(ViewerDisplayWidget *display, QWidget *parent = nullptr); - virtual void TimebaseChangedEvent(const rational &) override; - virtual void TimeChangedEvent(const rational &time) override; + virtual void TimebaseChangedEvent(const Rational &) override; + virtual void TimeChangedEvent(const Rational &time) override; virtual void ConnectNodeEvent(ViewerOutput *) override; virtual void DisconnectNodeEvent(ViewerOutput *) override; @@ -219,77 +219,77 @@ protected: ignore_scrub_++; } - RenderTicketPtr GetSingleFrame(const rational &t, bool dry = false); + RenderTicketPtr get_single_frame(const Rational &t, bool dry = false); - void SetWaveformMode(WaveformMode wf); + void set_waveform_mode(WaveformMode wf); private: - int64_t GetTimestamp() const + int64_t get_timestamp() const { - return Timecode::time_to_timestamp(GetConnectedNode()->GetPlayhead(), - timebase(), Timecode::kFloor); + return Timecode::time_to_timestamp(get_connected_node()->get_playhead(), + timebase(), Timecode::k_floor); } - void UpdateTimeInternal(int64_t i); + void update_time_internal(int64_t i); - void PlayInternal(int speed, bool in_to_out_only); + void play_internal(int speed, bool in_to_out_only); - void PauseInternal(); + void pause_internal(); - void PushScrubbedAudio(); + void push_scrubbed_audio(); - void UpdateMinimumScale(); + void update_minimum_scale(); - void SetColorTransform(const ColorTransform &transform, + void set_color_transform(const ColorTransform &transform, ViewerDisplayWidget *sender); - QString GetCachedFilenameFromTime(const rational &time); + QString get_cached_filename_from_time(const Rational &time); - bool FrameExistsAtTime(const rational &time); + bool frame_exists_at_time(const Rational &time); - bool ViewerMightBeAStill(); + bool viewer_might_be_a_still(); - void SetDisplayImage(RenderTicketPtr ticket); + void set_display_image(RenderTicketPtr ticket); - RenderTicketWatcher *RequestNextFrameForQueue(bool increment = true); + RenderTicketWatcher *request_next_frame_for_queue(bool increment = true); - RenderTicketPtr GetFrame(const rational &t); + RenderTicketPtr get_frame(const Rational &t); - void FinishPlayPreprocess(); + void finish_play_preprocess(); - int DeterminePlaybackQueueSize(); + int determine_playback_queue_size(); - static FramePtr DecodeCachedImage(const QString &cache_path, + static FramePtr decode_cached_image(const QString &cache_path, const QUuid &cache_id, const int64_t &time); - static void DecodeCachedImage(RenderTicketPtr ticket, + static void decode_cached_image(RenderTicketPtr ticket, const QString &cache_path, const QUuid &cache_id, const int64_t &time); - bool ShouldForceWaveform() const; + bool should_force_waveform() const; - void SetEmptyImage(); + void set_empty_image(); - void UpdateAutoCacher(); + void update_auto_cacher(); - void DecrementPrequeuedAudio(); + void decrement_prequeued_audio(); - void ArmForRecording(); + void arm_for_recording(); - void DisarmRecording(); + void disarm_recording(); - void CloseAudioProcessor(); + void close_audio_processor(); - void DetectMulticamNode(const rational &time); + void detect_multicam_node(const Rational &time); - bool IsVideoVisible() const; + bool is_video_visible() const; ViewerSizer *sizer_; int playback_speed_; - rational last_time_; + Rational last_time_; bool color_menu_enabled_; @@ -316,7 +316,7 @@ private: QList nonqueue_watchers_; - rational last_length_; + Rational last_length_; int prequeue_length_; int prequeue_count_; @@ -324,12 +324,12 @@ private: QVector queue_watchers_; std::list audio_playback_queue_; - rational audio_playback_queue_time_; + Rational audio_playback_queue_time_; AudioProcessor audio_processor_; QByteArray prequeued_audio_; - static const rational kAudioPlaybackInterval; + static const Rational k_audio_playback_interval; - static QVector instances_; + static QVector instances; std::list audio_scrub_watchers_; @@ -357,75 +357,75 @@ private: MulticamWidget *multicam_panel_; private slots: - void PlaybackTimerUpdate(); + void playback_timer_update(); - void LengthChangedSlot(const rational &length); + void length_changed_slot(const Rational &length); - void InterlacingChangedSlot(VideoParams::Interlacing interlacing); + void interlacing_changed_slot(VideoParams::Interlacing interlacing); - void UpdateRendererVideoParameters(); + void update_renderer_video_parameters(); - void UpdateRendererAudioParameters(); + void update_renderer_audio_parameters(); - void ShowContextMenu(const QPoint &pos); + void show_context_menu(const QPoint &pos); - void SetZoomFromMenu(QAction *action); + void set_zoom_from_menu(QAction *action); - void UpdateWaveformViewFromMode(); + void update_waveform_view_from_mode(); - void ContextMenuSetFullScreen(QAction *action); + void context_menu_set_full_screen(QAction *action); - void ContextMenuSetPlaybackRes(QAction *action); + void context_menu_set_playback_res(QAction *action); - void ContextMenuDisableSafeMargins(); + void context_menu_disable_safe_margins(); - void ContextMenuSetSafeMargins(); + void context_menu_set_safe_margins(); - void ContextMenuSetCustomSafeMargins(); + void context_menu_set_custom_safe_margins(); - void WindowAboutToClose(); + void window_about_to_close(); - void RendererGeneratedFrame(); + void renderer_generated_frame(); - void RendererGeneratedFrameForQueue(); + void renderer_generated_frame_for_queue(); - void ViewerInvalidatedVideoRange(const olive::TimeRange &range); + void viewer_invalidated_video_range(const olive::TimeRange &range); - void UpdateWaveformModeFromMenu(QAction *a); + void update_waveform_mode_from_menu(QAction *a); - void DragEntered(QDragEnterEvent *event); + void drag_entered(QDragEnterEvent *event); - void Dropped(QDropEvent *event); + void dropped(QDropEvent *event); - void QueueNextAudioBuffer(); + void queue_next_audio_buffer(); - void ReceivedAudioBufferForPlayback(); + void received_audio_buffer_for_playback(); - void ReceivedAudioBufferForScrubbing(); + void received_audio_buffer_for_scrubbing(); - void QueueStarved(); - void QueueNoLongerStarved(); + void queue_starved(); + void queue_no_longer_starved(); - void ForceRequeueFromCurrentTime(); - void ForceRequeueFromCurrentTimeInternal(); + void force_requeue_from_current_time(); + void force_requeue_from_current_time_internal(); - void UpdateAudioProcessor(); + void update_audio_processor(); - void CreateAddableAt(const QRectF &f); + void create_addable_at(const QRectF &f); - void HandleFirstRequeueDestroy(); + void handle_first_requeue_destroy(); - void ShowSubtitleProperties(); + void show_subtitle_properties(); - void DryRunFinished(); + void dry_run_finished(); - void RequestNextDryRun(); + void request_next_dry_run(); - void SaveFrameAsImage(); + void save_frame_as_image(); - void DetectMulticamNodeNow(); + void detect_multicam_node_now(); }; } -#endif // VIEWER_WIDGET_H +#endif // OAK_VIEWER_WIDGET_H diff --git a/app/widget/viewer/viewerdisplay.cpp b/app/widget/viewer/viewerdisplay.cpp index 65193cee5..769bb530f 100644 --- a/app/widget/viewer/viewerdisplay.cpp +++ b/app/widget/viewer/viewerdisplay.cpp @@ -68,19 +68,19 @@ ViewerDisplayWidget::ViewerDisplayWidget(QWidget *parent) , frames_skipped_(0) , show_widget_background_(false) , playback_speed_(0) - , push_mode_(kPushNull) + , push_mode_(k_push_null) , add_band_(false) , queue_starved_(false) , text_edit_(nullptr) { - connect(Core::instance(), &Core::ToolChanged, this, - &ViewerDisplayWidget::ToolChanged); + connect(Core::instance(), &Core::tool_changed, this, + &ViewerDisplayWidget::tool_changed); // Initializes cursor based on tool - UpdateCursor(); + update_cursor(); - const int kFrameRateAverageCount = 8; - frame_rate_averages_.resize(kFrameRateAverageCount); + const int k_frame_rate_average_count = 8; + frame_rate_averages_.resize(k_frame_rate_average_count); inner_widget()->setAcceptDrops(true); } @@ -92,76 +92,76 @@ ViewerDisplayWidget::~ViewerDisplayWidget() MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR_INNER; } -void ViewerDisplayWidget::SetMatrixTranslate(const QMatrix4x4 &mat) +void ViewerDisplayWidget::set_matrix_translate(const QMatrix4x4 &mat) { translate_matrix_ = mat; - UpdateMatrix(); + update_matrix(); } -void ViewerDisplayWidget::SetMatrixZoom(const QMatrix4x4 &mat) +void ViewerDisplayWidget::set_matrix_zoom(const QMatrix4x4 &mat) { scale_matrix_ = mat; - UpdateMatrix(); + update_matrix(); } -void ViewerDisplayWidget::SetMatrixCrop(const QMatrix4x4 &mat) +void ViewerDisplayWidget::set_matrix_crop(const QMatrix4x4 &mat) { crop_matrix_ = mat; update(); } -void ViewerDisplayWidget::UpdateCursor() +void ViewerDisplayWidget::update_cursor() { - if (Core::instance()->tool() == Tool::kHand) { + if (Core::instance()->tool() == Tool::k_hand) { this->inner_widget()->setCursor(Qt::OpenHandCursor); - } else if (Core::instance()->tool() == Tool::kAdd) { + } else if (Core::instance()->tool() == Tool::k_add) { this->inner_widget()->setCursor(Qt::CrossCursor); } else { this->inner_widget()->unsetCursor(); } } -void ViewerDisplayWidget::SetSignalCursorColorEnabled(bool e) +void ViewerDisplayWidget::set_signal_cursor_color_enabled(bool e) { signal_cursor_color_ = e; - SetInnerMouseTracking(e); + set_inner_mouse_tracking(e); } -void ViewerDisplayWidget::SetImage(const QVariant &buffer) +void ViewerDisplayWidget::set_image(const QVariant &buffer) { load_frame_ = buffer; if (load_frame_.isNull()) { - push_mode_ = kPushNull; + push_mode_ = k_push_null; } else { - push_mode_ = kPushFrame; + push_mode_ = k_push_frame; } update(); } -void ViewerDisplayWidget::SetBlank() +void ViewerDisplayWidget::set_blank() { - push_mode_ = kPushBlank; + push_mode_ = k_push_blank; update(); } -void ViewerDisplayWidget::ToolChanged() +void ViewerDisplayWidget::tool_changed() { - UpdateCursor(); + update_cursor(); } -void ViewerDisplayWidget::SetDeinterlacing(bool e) +void ViewerDisplayWidget::set_deinterlacing(bool e) { deinterlace_ = e; if (!deinterlace_) { if (!deinterlace_shader_.isNull()) { - renderer()->DestroyNativeShader(deinterlace_shader_); + renderer()->destroy_native_shader(deinterlace_shader_); deinterlace_shader_.clear(); } deinterlace_texture_ = nullptr; @@ -170,12 +170,12 @@ void ViewerDisplayWidget::SetDeinterlacing(bool e) update(); } -const ViewerSafeMarginInfo &ViewerDisplayWidget::GetSafeMargin() const +const ViewerSafeMarginInfo &ViewerDisplayWidget::get_safe_margin() const { return safe_margin_; } -void ViewerDisplayWidget::SetSafeMargins(const ViewerSafeMarginInfo &safe_margin) +void ViewerDisplayWidget::set_safe_margins(const ViewerSafeMarginInfo &safe_margin) { if (safe_margin_ != safe_margin) { safe_margin_ = safe_margin; @@ -184,7 +184,7 @@ void ViewerDisplayWidget::SetSafeMargins(const ViewerSafeMarginInfo &safe_margin } } -void ViewerDisplayWidget::SetGizmos(Node *node) +void ViewerDisplayWidget::set_gizmos(Node *node) { if (gizmos_ != node) { gizmos_ = node; @@ -193,7 +193,7 @@ void ViewerDisplayWidget::SetGizmos(Node *node) } } -void ViewerDisplayWidget::SetVideoParams(const VideoParams ¶ms) +void ViewerDisplayWidget::set_video_params(const VideoParams ¶ms) { gizmo_params_ = params; @@ -202,7 +202,7 @@ void ViewerDisplayWidget::SetVideoParams(const VideoParams ¶ms) } } -void ViewerDisplayWidget::SetAudioParams(const AudioParams ¶ms) +void ViewerDisplayWidget::set_audio_params(const AudioParams ¶ms) { gizmo_audio_params_ = params; @@ -211,7 +211,7 @@ void ViewerDisplayWidget::SetAudioParams(const AudioParams ¶ms) } } -void ViewerDisplayWidget::SetTime(const rational &time) +void ViewerDisplayWidget::set_time(const Rational &time) { time_ = time; @@ -220,48 +220,48 @@ void ViewerDisplayWidget::SetTime(const rational &time) } } -void ViewerDisplayWidget::SetSubtitleTracks(Sequence *list) +void ViewerDisplayWidget::set_subtitle_tracks(Sequence *list) { if (subtitle_tracks_) { - disconnect(subtitle_tracks_, &Sequence::SubtitlesChanged, this, - &ViewerDisplayWidget::SubtitlesChanged); + disconnect(subtitle_tracks_, &Sequence::subtitles_changed, this, + &ViewerDisplayWidget::subtitles_changed); } subtitle_tracks_ = list; if (subtitle_tracks_) { - connect(subtitle_tracks_, &Sequence::SubtitlesChanged, this, - &ViewerDisplayWidget::SubtitlesChanged); + connect(subtitle_tracks_, &Sequence::subtitles_changed, this, + &ViewerDisplayWidget::subtitles_changed); } update(); } QPointF -ViewerDisplayWidget::TransformViewerSpaceToBufferSpace(const QPointF &pos) +ViewerDisplayWidget::transform_viewer_space_to_buffer_space(const QPointF &pos) { /* * Inversion will only fail if the viewer has been scaled by 0 in any direction * which I think should never happen. */ - return pos * GenerateDisplayTransform().inverted(); + return pos * generate_display_transform().inverted(); } -void ViewerDisplayWidget::ResetFPSTimer() +void ViewerDisplayWidget::reset_fps_timer() { fps_timer_start_ = QDateTime::currentMSecsSinceEpoch(); fps_timer_update_count_ = 0; frames_skipped_ = 0; frame_rate_average_count_ = 0; - Core::instance()->ClearStatusBarMessage(); + Core::instance()->clear_status_bar_message(); } -void ViewerDisplayWidget::IncrementSkippedFrames() +void ViewerDisplayWidget::increment_skipped_frames() { frames_skipped_++; - Core::instance()->ShowStatusBarMessage( + Core::instance()->show_status_bar_message( tr("%n skipped frame(s) detected during playback", nullptr, frames_skipped_), 10000); @@ -274,45 +274,45 @@ bool ViewerDisplayWidget::eventFilter(QObject *o, QEvent *e) case QEvent::MouseButtonPress: { QMouseEvent *mouse = static_cast(e); if (!(mouse->flags() & Qt::MouseEventCreatedDoubleClick)) { - if (OnMousePress(mouse)) { + if (on_mouse_press(mouse)) { return true; } } break; } case QEvent::MouseMove: - EmitColorAtCursor(static_cast(e)); - if (OnMouseMove(static_cast(e))) { + emit_color_at_cursor(static_cast(e)); + if (on_mouse_move(static_cast(e))) { return true; } break; case QEvent::MouseButtonRelease: - if (OnMouseRelease(static_cast(e))) { + if (on_mouse_release(static_cast(e))) { return true; } break; case QEvent::MouseButtonDblClick: - if (OnMouseDoubleClick(static_cast(e))) { + if (on_mouse_double_click(static_cast(e))) { return true; } break; case QEvent::ShortcutOverride: case QEvent::KeyPress: - if (OnKeyPress(static_cast(e))) { + if (on_key_press(static_cast(e))) { return true; } break; case QEvent::KeyRelease: - if (OnKeyRelease(static_cast(e))) { + if (on_key_release(static_cast(e))) { return true; } break; case QEvent::DragEnter: { auto drag_enter = static_cast(e); if (text_edit_) { - ForwardDragEventToTextEdit(drag_enter); + forward_drag_event_to_text_edit(drag_enter); } else { - emit DragEntered(drag_enter); + emit drag_entered(drag_enter); } if (drag_enter->isAccepted()) { @@ -323,7 +323,7 @@ bool ViewerDisplayWidget::eventFilter(QObject *o, QEvent *e) case QEvent::DragMove: { auto drag_move = static_cast(e); if (text_edit_) { - ForwardDragEventToTextEdit(drag_move); + forward_drag_event_to_text_edit(drag_move); } if (drag_move->isAccepted()) { @@ -334,9 +334,9 @@ bool ViewerDisplayWidget::eventFilter(QObject *o, QEvent *e) case QEvent::DragLeave: { auto drag_leave = static_cast(e); if (text_edit_) { - ForwardDragEventToTextEdit(drag_leave); + forward_drag_event_to_text_edit(drag_leave); } else { - emit DragLeft(drag_leave); + emit drag_left(drag_leave); } if (drag_leave->isAccepted()) { @@ -347,9 +347,9 @@ bool ViewerDisplayWidget::eventFilter(QObject *o, QEvent *e) case QEvent::Drop: { auto drop = static_cast(e); if (text_edit_) { - ForwardDragEventToTextEdit(drop); + forward_drag_event_to_text_edit(drop); } else { - emit Dropped(drop); + emit dropped(drop); } if (drop->isAccepted()) { @@ -373,9 +373,9 @@ bool ViewerDisplayWidget::eventFilter(QObject *o, QEvent *e) return super::eventFilter(o, e); } -void ViewerDisplayWidget::OnPaint() +void ViewerDisplayWidget::on_paint() { - const bool backend_neutral = IsBackendNeutral(); + const bool backend_neutral = is_backend_neutral(); QPainter bg_painter; bool bg_painter_active = false; @@ -385,14 +385,14 @@ void ViewerDisplayWidget::OnPaint() // image itself will be rendered offscreen, downloaded, and painted below. bg_painter.begin(paint_device()); bg_painter_active = true; - bg_painter.fillRect(GetInnerRect(), show_widget_background_ ? + bg_painter.fillRect(get_inner_rect(), show_widget_background_ ? palette().window().color() : Qt::black); } else { // Clear background to empty QColor bg_color = show_widget_background_ ? palette().window().color() : Qt::black; - renderer()->ClearDestination(nullptr, bg_color.redF(), + renderer()->clear_destination(nullptr, bg_color.redF(), bg_color.greenF(), bg_color.blueF()); } @@ -401,13 +401,13 @@ void ViewerDisplayWidget::OnPaint() bool have_ctj = false; // We only draw if we have a pipeline - if (push_mode_ != kPushNull) { + if (push_mode_ != k_push_null) { // Draw texture through color transform - device_params = GetViewportParams(); + device_params = get_viewport_params(); - if (push_mode_ == kPushBlank) { + if (push_mode_ == k_push_blank) { if (!backend_neutral) { - DrawBlank(device_params); + draw_blank(device_params); } } else if (color_service()) { bool drew_backend_neutral_frame = false; @@ -420,18 +420,18 @@ void ViewerDisplayWidget::OnPaint() texture_->height() != frame->height() || texture_->format() != frame->format() || texture_->channel_count() != frame->channel_count())) { - texture_ = renderer()->CreateTexture( + texture_ = renderer()->create_texture( frame->video_params(), frame->data(), frame->linesize_pixels()); } else if (!drew_backend_neutral_frame) { - texture_->Upload(frame->data(), frame->linesize_pixels()); + texture_->upload(frame->data(), frame->linesize_pixels()); } } else if (TexturePtr texture = load_frame_.value()) { // This is a GPU texture, switch to it directly when possible. if (!drew_backend_neutral_frame && texture && texture->renderer() && texture->renderer() != renderer()) { - if (texture->renderer()->IsOpenGL() && - renderer()->IsOpenGL()) { + if (texture->renderer()->is_open_gl() && + renderer()->is_open_gl()) { // Shared OpenGL contexts can display the producer texture // directly. Avoid readback here because the producer // renderer may belong to a render thread whose context @@ -439,13 +439,13 @@ void ViewerDisplayWidget::OnPaint() texture_ = texture; } else { // Cross-backend texture: download and re-upload - FramePtr frame = Frame::Create(); + FramePtr frame = Frame::create(); frame->set_video_params(texture->params()); if (frame->allocate()) { - texture->renderer()->DownloadFromTexture( + texture->renderer()->download_from_texture( texture->id(), texture->params(), frame->data(), frame->linesize_pixels()); - texture_ = renderer()->CreateTexture( + texture_ = renderer()->create_texture( frame->video_params(), frame->data(), frame->linesize_pixels()); } else { @@ -456,30 +456,30 @@ void ViewerDisplayWidget::OnPaint() texture_ = texture; } } else { - texture_ = LoadCustomTextureFromFrame(load_frame_); + texture_ = load_custom_texture_from_frame(load_frame_); } if (drew_backend_neutral_frame) { texture_ = nullptr; } - emit TextureChanged(texture_); + emit texture_changed(texture_); - push_mode_ = kPushUnnecessary; + push_mode_ = k_push_unnecessary; if (!drew_backend_neutral_frame) { TexturePtr texture_to_draw = texture_; - if (!texture_to_draw || texture_to_draw->IsDummy()) { + if (!texture_to_draw || texture_to_draw->is_dummy()) { if (!backend_neutral) { - DrawBlank(device_params); + draw_blank(device_params); } } else { if (deinterlace_) { if (deinterlace_shader_.isNull()) { deinterlace_shader_ = - renderer()->CreateNativeShader( - ShaderCode(FileFunctions::ReadFileAsString( + renderer()->create_native_shader( + ShaderCode(FileFunctions::read_file_as_string( QStringLiteral( ":/shaders/deinterlace.frag")))); } @@ -488,37 +488,37 @@ void ViewerDisplayWidget::OnPaint() deinterlace_texture_->params() != texture_to_draw->params()) { // (Re)create texture - deinterlace_texture_ = renderer()->CreateTexture( + deinterlace_texture_ = renderer()->create_texture( texture_to_draw->params()); } ShaderJob job; - job.Insert( + job.insert( QStringLiteral("resolution_in"), - NodeValue(NodeValue::kVec2, + NodeValue(NodeValue::k_vec2, QVector2D(texture_to_draw->width(), texture_to_draw->height()))); - job.Insert( + job.insert( QStringLiteral("ove_maintex"), - NodeValue(NodeValue::kTexture, + NodeValue(NodeValue::k_texture, QVariant::fromValue(texture_to_draw))); - renderer()->BlitToTexture(deinterlace_shader_, job, + renderer()->blit_to_texture(deinterlace_shader_, job, deinterlace_texture_.get()); texture_to_draw = deinterlace_texture_; } - ctj.SetColorProcessor(color_service()); - ctj.SetInputTexture(texture_to_draw); - ctj.SetInputAlphaAssociation( - OLIVE_CONFIG("ReassocLinToNonLin").toBool() ? - kAlphaAssociated : - kAlphaNone); - ctj.SetClearDestinationEnabled(false); - ctj.SetTransformMatrix(combined_matrix_flipped_); - ctj.SetCropMatrix(crop_matrix_); - ctj.SetForceOpaque(true); + ctj.set_color_processor(color_service()); + ctj.set_input_texture(texture_to_draw); + ctj.set_input_alpha_association( + OAK_CONFIG("ReassocLinToNonLin").toBool() ? + k_alpha_associated : + k_alpha_none); + ctj.set_clear_destination_enabled(false); + ctj.set_transform_matrix(combined_matrix_flipped_); + ctj.set_crop_matrix(crop_matrix_); + ctj.set_force_opaque(true); have_ctj = true; } @@ -529,9 +529,9 @@ void ViewerDisplayWidget::OnPaint() if (have_ctj) { if (backend_neutral) { - DrawBackendNeutral(ctj, &bg_painter); + draw_backend_neutral(ctj, &bg_painter); } else { - renderer()->BlitColorManaged(ctj, device_params); + renderer()->blit_color_managed(ctj, device_params); } } @@ -543,16 +543,16 @@ void ViewerDisplayWidget::OnPaint() if (gizmos_) { QPainter p(paint_device()); - GenerateGizmoTransforms(); + generate_gizmo_transforms(); p.setWorldTransform(gizmo_last_draw_transform_); - gizmos_->UpdateGizmoPositions( + gizmos_->update_gizmo_positions( gizmo_db_, NodeGlobals(gizmo_params_, gizmo_audio_params_, - gizmo_draw_time_, LoopMode::kLoopModeOff)); - foreach (NodeGizmo *gizmo, gizmos_->GetGizmos()) { - if (gizmo->IsVisible()) { - gizmo->Draw(&p); + gizmo_draw_time_, LoopMode::k_loop_mode_off)); + foreach (NodeGizmo *gizmo, gizmos_->get_gizmos()) { + if (gizmo->is_visible()) { + gizmo->draw(&p); } } @@ -561,8 +561,8 @@ void ViewerDisplayWidget::OnPaint() pm.fill(Qt::transparent); QPainter pixp(&pm); - text_edit_->Paint(&pixp, - active_text_gizmo_->GetVerticalAlignment()); + text_edit_->paint(&pixp, + active_text_gizmo_->get_vertical_alignment()); p.drawPixmap(text_edit_pos_, pm); } @@ -571,7 +571,7 @@ void ViewerDisplayWidget::OnPaint() // Draw action/title safe areas if (safe_margin_.is_enabled()) { QPainter p(paint_device()); - p.setWorldTransform(GenerateWorldTransform()); + p.setWorldTransform(generate_world_transform()); p.setPen(QPen(Qt::lightGray, 0)); p.setBrush(Qt::NoBrush); @@ -635,21 +635,21 @@ void ViewerDisplayWidget::OnPaint() } average /= double(frame_rate_averages_.size()); - DrawTextWithCrudeShadow( - &p, GetInnerRect(), + draw_text_with_crude_shadow( + &p, get_inner_rect(), tr("%1 FPS").arg(QString::number(average, 'f', 1))); if (frames_skipped_ > 0) { - DrawTextWithCrudeShadow( + draw_text_with_crude_shadow( &p, - GetInnerRect().adjusted(0, p.fontMetrics().height(), 0, 0), + get_inner_rect().adjusted(0, p.fontMetrics().height(), 0, 0), tr("%1 frames skipped").arg(frames_skipped_)); } } } // Extraordinarily basic subtitle renderer. Hoping to swap this out with libass at some point. - DrawSubtitleTracks(); + draw_subtitle_tracks(); if (add_band_) { QPainter p(paint_device()); @@ -664,22 +664,22 @@ void ViewerDisplayWidget::OnPaint() // emit frameSwapped automatically. Emit it ourselves so the playback queue // keeps advancing (UpdateFromQueue is connected to it during Play()). if (backend_neutral) { - emit frameSwapped(); + emit frame_swapped(); } } -void ViewerDisplayWidget::OnDestroy() +void ViewerDisplayWidget::on_destroy() { if (!deinterlace_shader_.isNull()) { - renderer()->DestroyNativeShader(deinterlace_shader_); + renderer()->destroy_native_shader(deinterlace_shader_); deinterlace_shader_.clear(); } if (!blank_shader_.isNull()) { - renderer()->DestroyNativeShader(blank_shader_); + renderer()->destroy_native_shader(blank_shader_); blank_shader_.clear(); } - super::OnDestroy(); + super::on_destroy(); texture_ = nullptr; deinterlace_texture_ = nullptr; @@ -691,29 +691,29 @@ void ViewerDisplayWidget::OnDestroy() backend_neutral_cpu_source_texture_.reset(); backend_neutral_cpu_color_id_.clear(); if (load_frame_.isNull()) { - push_mode_ = kPushNull; + push_mode_ = k_push_null; } else { - push_mode_ = kPushFrame; + push_mode_ = k_push_frame; } } -QPointF ViewerDisplayWidget::GetTexturePosition(const QPoint &screen_pos) +QPointF ViewerDisplayWidget::get_texture_position(const QPoint &screen_pos) { - return GetTexturePosition(screen_pos.x(), screen_pos.y()); + return get_texture_position(screen_pos.x(), screen_pos.y()); } -QPointF ViewerDisplayWidget::GetTexturePosition(const QSize &size) +QPointF ViewerDisplayWidget::get_texture_position(const QSize &size) { - return GetTexturePosition(size.width(), size.height()); + return get_texture_position(size.width(), size.height()); } -QPointF ViewerDisplayWidget::GetTexturePosition(const double &x, +QPointF ViewerDisplayWidget::get_texture_position(const double &x, const double &y) { return QPointF(x / gizmo_params_.width(), y / gizmo_params_.height()); } -void ViewerDisplayWidget::DrawTextWithCrudeShadow(QPainter *painter, +void ViewerDisplayWidget::draw_text_with_crude_shadow(QPainter *painter, const QRect &rect, const QString &text, const QTextOption &opt) @@ -724,19 +724,19 @@ void ViewerDisplayWidget::DrawTextWithCrudeShadow(QPainter *painter, painter->drawText(rect, text, opt); } -rational ViewerDisplayWidget::GetGizmoTime() +Rational ViewerDisplayWidget::get_gizmo_time() { - return GetAdjustedTime(GetTimeTarget(), gizmos_, time_, - Node::kTransformTowardsInput); + return get_adjusted_time(get_time_target(), gizmos_, time_, + Node::k_transform_towards_input); } -bool ViewerDisplayWidget::IsHandDrag(QMouseEvent *event) const +bool ViewerDisplayWidget::is_hand_drag(QMouseEvent *event) const { return event->button() == Qt::MiddleButton || - Core::instance()->tool() == Tool::kHand; + Core::instance()->tool() == Tool::k_hand; } -void ViewerDisplayWidget::UpdateMatrix() +void ViewerDisplayWidget::update_matrix() { combined_matrix_ = scale_matrix_ * translate_matrix_; @@ -746,7 +746,7 @@ void ViewerDisplayWidget::UpdateMatrix() // up. Vulkan's framebuffer and texture coordinate origins are both top-left, // so the same flip would invert the image. Default to the OpenGL flip when // no renderer is available yet. - if (!renderer() || !renderer()->IsVulkan()) { + if (!renderer() || !renderer()->is_vulkan()) { QMatrix4x4 flip; flip.scale(1.0f, -1.0f, 1.0f); combined_matrix_flipped_ = flip * combined_matrix_flipped_; @@ -755,7 +755,7 @@ void ViewerDisplayWidget::UpdateMatrix() update(); } -QTransform ViewerDisplayWidget::GenerateWorldTransform() +QTransform ViewerDisplayWidget::generate_world_transform() { /* * Get matrix elements (roughly) as below in column major order @@ -779,30 +779,30 @@ QTransform ViewerDisplayWidget::GenerateWorldTransform() return world; } -QTransform ViewerDisplayWidget::GenerateDisplayTransform() +QTransform ViewerDisplayWidget::generate_display_transform() { - QVector2D viewer_scale(GetTexturePosition(size())); - QTransform gizmo_transform = GenerateWorldTransform(); + QVector2D viewer_scale(get_texture_position(size())); + QTransform gizmo_transform = generate_world_transform(); gizmo_transform.scale(viewer_scale.x(), viewer_scale.y()); gizmo_transform.scale( - gizmo_params_.pixel_aspect_ratio().flipped().toDouble(), 1); + gizmo_params_.pixel_aspect_ratio().flipped().to_double(), 1); return gizmo_transform; } -QTransform ViewerDisplayWidget::GenerateGizmoTransform(NodeTraverser >, +QTransform ViewerDisplayWidget::generate_gizmo_transform(NodeTraverser >, const TimeRange &range) { - QTransform t = GenerateDisplayTransform(); - if (GetTimeTarget()) { - Node *target = GetTimeTarget(); + QTransform t = generate_display_transform(); + if (get_time_target()) { + Node *target = get_time_target(); if (ViewerOutput *v = dynamic_cast(target)) { - if (Node *n = v->GetConnectedTextureOutput()) { + if (Node *n = v->get_connected_texture_output()) { target = n; } } QTransform nt; - gt.Transform(&nt, gizmos_, target, range); + gt.transform(&nt, gizmos_, target, range); t.translate(gizmo_params_.width() * 0.5, gizmo_params_.height() * 0.5); t.scale(gizmo_params_.width(), gizmo_params_.height()); @@ -817,29 +817,29 @@ QTransform ViewerDisplayWidget::GenerateGizmoTransform(NodeTraverser >, return t; } -NodeGizmo *ViewerDisplayWidget::TryGizmoPress(const NodeValueRow &row, +NodeGizmo *ViewerDisplayWidget::try_gizmo_press(const NodeValueRow &row, const QPointF &p) { if (!gizmos_) { return nullptr; } - for (auto it = gizmos_->GetGizmos().crbegin(); - it != gizmos_->GetGizmos().crend(); it++) { + for (auto it = gizmos_->get_gizmos().crbegin(); + it != gizmos_->get_gizmos().crend(); it++) { NodeGizmo *gizmo = *it; - if (gizmo->IsVisible()) { + if (gizmo->is_visible()) { if (PointGizmo *point = dynamic_cast(gizmo)) { - if (point->GetClickingRect(gizmo_last_draw_transform_) + if (point->get_clicking_rect(gizmo_last_draw_transform_) .contains(p)) { return point; } } else if (PolygonGizmo *poly = dynamic_cast(gizmo)) { - if (poly->GetPolygon().containsPoint(p, Qt::OddEvenFill)) { + if (poly->get_polygon().containsPoint(p, Qt::OddEvenFill)) { return poly; } } else if (PathGizmo *path = dynamic_cast(gizmo)) { - if (path->GetPath().contains(p)) { + if (path->get_path().contains(p)) { return path; } } else if (ScreenGizmo *screen = @@ -853,17 +853,17 @@ NodeGizmo *ViewerDisplayWidget::TryGizmoPress(const NodeValueRow &row, return nullptr; } -void ViewerDisplayWidget::OpenTextGizmo(TextGizmo *text, QMouseEvent *event) +void ViewerDisplayWidget::open_text_gizmo(TextGizmo *text, QMouseEvent *event) { - GenerateGizmoTransforms(); - gizmos_->UpdateGizmoPositions( + generate_gizmo_transforms(); + gizmos_->update_gizmo_positions( gizmo_db_, NodeGlobals(gizmo_params_, gizmo_audio_params_, - gizmo_draw_time_, LoopMode::kLoopModeOff)); + gizmo_draw_time_, LoopMode::k_loop_mode_off)); active_text_gizmo_ = text; - connect(active_text_gizmo_, &TextGizmo::RectChanged, this, - &ViewerDisplayWidget::UpdateActiveTextGizmoSize); - text_transform_ = GenerateGizmoTransform(); + connect(active_text_gizmo_, &TextGizmo::rect_changed, this, + &ViewerDisplayWidget::update_active_text_gizmo_size); + text_transform_ = generate_gizmo_transform(); text_transform_inverted_ = text_transform_.inverted(); // Create text editor @@ -885,31 +885,31 @@ void ViewerDisplayWidget::OpenTextGizmo(TextGizmo *text, QMouseEvent *event) text_edit_->show(); // Convert HTML to Qt document - Html::HtmlToDoc(text_edit_->document(), text->GetHtml()); + Html::html_to_doc(text_edit_->document(), text->get_html()); // Connect text change event to propagate back to node connect(text_edit_, &ViewerTextEditor::textChanged, this, - &ViewerDisplayWidget::TextEditChanged); + &ViewerDisplayWidget::text_edit_changed); // Connect destroyed signal to cleanup after destruction connect(text_edit_, &ViewerTextEditor::destroyed, this, - &ViewerDisplayWidget::TextEditDestroyed); + &ViewerDisplayWidget::text_edit_destroyed); // Set text editor's size to logical size - QRectF text_rect = UpdateActiveTextGizmoSize(); + QRectF text_rect = update_active_text_gizmo_size(); // Emit text gizmo activation signal - emit text->Activated(); + emit text->activated(); // Create toolbar text_toolbar_ = new ViewerTextEditorToolBar(text_edit_); text_toolbar_->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); - connect(text_toolbar_, &ViewerTextEditorToolBar::VerticalAlignmentChanged, - text, &TextGizmo::SetVerticalAlignment); - connect(text, &TextGizmo::VerticalAlignmentChanged, text_toolbar_, - &ViewerTextEditorToolBar::SetVerticalAlignment); - text_toolbar_->SetVerticalAlignment(text->GetVerticalAlignment()); - text_edit_->ConnectToolBar(text_toolbar_); + connect(text_toolbar_, &ViewerTextEditorToolBar::vertical_alignment_changed, + text, &TextGizmo::set_vertical_alignment); + connect(text, &TextGizmo::vertical_alignment_changed, text_toolbar_, + &ViewerTextEditorToolBar::set_vertical_alignment); + text_toolbar_->set_vertical_alignment(text->get_vertical_alignment()); + text_edit_->connect_tool_bar(text_toolbar_); QPoint toolbar_pos = mapToGlobal(text_transform_.map(text_edit_pos_).toPoint()); @@ -950,7 +950,7 @@ void ViewerDisplayWidget::OpenTextGizmo(TextGizmo *text, QMouseEvent *event) inner_widget()->setMouseTracking(true); connect(qApp, &QApplication::focusChanged, this, - &ViewerDisplayWidget::FocusChanged); + &ViewerDisplayWidget::focus_changed); // Start text cursor where the user clicked if (event) { @@ -960,49 +960,49 @@ void ViewerDisplayWidget::OpenTextGizmo(TextGizmo *text, QMouseEvent *event) } // Grab focus back from the toolbar - connect(text_toolbar_, &ViewerTextEditorToolBar::FirstPaint, this, [this] { + connect(text_toolbar_, &ViewerTextEditorToolBar::first_paint, this, [this] { Core::instance()->main_window()->activateWindow(); inner_widget()->setFocus(); }); } -bool ViewerDisplayWidget::OnMousePress(QMouseEvent *event) +bool ViewerDisplayWidget::on_mouse_press(QMouseEvent *event) { - if (IsHandDrag(event)) { + if (is_hand_drag(event)) { // Handle hand drag hand_last_drag_pos_ = event->pos(); hand_dragging_ = true; - emit HandDragStarted(); + emit hand_drag_started(); inner_widget()->setCursor(Qt::ClosedHandCursor); return true; - } else if (text_edit_ && ForwardMouseEventToTextEdit(event, true)) { + } else if (text_edit_ && forward_mouse_event_to_text_edit(event, true)) { return true; } else if (event->button() == Qt::LeftButton) { - if (Core::instance()->tool() == Tool::kAdd && - (Core::instance()->GetSelectedAddableObject() == - Tool::kAddableShape || - Core::instance()->GetSelectedAddableObject() == - Tool::kAddableTitle)) { + if (Core::instance()->tool() == Tool::k_add && + (Core::instance()->get_selected_addable_object() == + Tool::k_addable_shape || + Core::instance()->get_selected_addable_object() == + Tool::k_addable_title)) { add_band_start_ = event->pos(); add_band_end_ = add_band_start_; add_band_ = true; - } else if ((current_gizmo_ = TryGizmoPress( + } else if ((current_gizmo_ = try_gizmo_press( gizmo_db_, gizmo_last_draw_transform_inverted_.map( event->pos())))) { // Handle gizmo click gizmo_start_drag_ = event->pos(); gizmo_last_drag_ = gizmo_start_drag_; - current_gizmo_->SetGlobals( + current_gizmo_->set_globals( NodeGlobals(gizmo_params_, gizmo_audio_params_, - GenerateGizmoTime(), LoopMode::kLoopModeOff)); + generate_gizmo_time(), LoopMode::k_loop_mode_off)); } else { // Handle standard drag - emit DragStarted(event->pos()); + emit drag_started(event->pos()); } return true; @@ -1011,19 +1011,19 @@ bool ViewerDisplayWidget::OnMousePress(QMouseEvent *event) return false; } -bool ViewerDisplayWidget::OnMouseMove(QMouseEvent *event) +bool ViewerDisplayWidget::on_mouse_move(QMouseEvent *event) { // Handle hand dragging if (hand_dragging_) { // Emit movement - emit HandDragMoved(event->x() - hand_last_drag_pos_.x(), + emit hand_drag_moved(event->x() - hand_last_drag_pos_.x(), event->y() - hand_last_drag_pos_.y()); hand_last_drag_pos_ = event->pos(); return true; - } else if (text_edit_ && ForwardMouseEventToTextEdit(event)) { + } else if (text_edit_ && forward_mouse_event_to_text_edit(event)) { return true; } else if (add_band_) { @@ -1036,37 +1036,37 @@ bool ViewerDisplayWidget::OnMouseMove(QMouseEvent *event) if (DraggableGizmo *draggable = dynamic_cast(current_gizmo_)) { if (!gizmo_drag_started_) { - QPointF start = ScreenToScenePoint(gizmo_start_drag_); + QPointF start = screen_to_scene_point(gizmo_start_drag_); - rational gizmo_time = GetGizmoTime(); + Rational gizmo_time = get_gizmo_time(); NodeTraverser t; - t.SetCacheVideoParams(gizmo_params_); - t.SetCacheAudioParams(gizmo_audio_params_); - NodeValueRow row = t.GenerateRow( + t.set_cache_video_params(gizmo_params_); + t.set_cache_audio_params(gizmo_audio_params_); + NodeValueRow row = t.generate_row( gizmos_, TimeRange(gizmo_time, gizmo_time + gizmo_params_.frame_rate_as_time_base())); - draggable->DragStart(row, start.x(), start.y(), gizmo_time); + draggable->drag_start(row, start.x(), start.y(), gizmo_time); gizmo_drag_started_ = true; } - QPointF v = ScreenToScenePoint(event->pos()); - switch (draggable->GetDragValueBehavior()) { - case DraggableGizmo::kAbsolute: + QPointF v = screen_to_scene_point(event->pos()); + switch (draggable->get_drag_value_behavior()) { + case DraggableGizmo::k_absolute: // Above value is correct break; - case DraggableGizmo::kDeltaFromPrevious: - v -= ScreenToScenePoint(gizmo_last_drag_); + case DraggableGizmo::k_delta_from_previous: + v -= screen_to_scene_point(gizmo_last_drag_); gizmo_last_drag_ = event->pos(); break; - case DraggableGizmo::kDeltaFromStart: - v -= ScreenToScenePoint(gizmo_start_drag_); + case DraggableGizmo::k_delta_from_start: + v -= screen_to_scene_point(gizmo_start_drag_); break; } - draggable->DragMove(v.x(), v.y(), event->modifiers()); + draggable->drag_move(v.x(), v.y(), event->modifiers()); return true; } @@ -1075,24 +1075,24 @@ bool ViewerDisplayWidget::OnMouseMove(QMouseEvent *event) return false; } -bool ViewerDisplayWidget::OnMouseRelease(QMouseEvent *e) +bool ViewerDisplayWidget::on_mouse_release(QMouseEvent *e) { if (hand_dragging_) { // Handle hand drag - emit HandDragEnded(); + emit hand_drag_ended(); hand_dragging_ = false; - UpdateCursor(); + update_cursor(); return true; - } else if (text_edit_ && ForwardMouseEventToTextEdit(e)) { + } else if (text_edit_ && forward_mouse_event_to_text_edit(e)) { return true; } else if (add_band_) { QRect band_rect = QRect(add_band_start_, add_band_end_).normalized(); if (band_rect.width() > 1 && band_rect.height() > 1) { - QRectF r = GenerateDisplayTransform().inverted().mapRect(band_rect); - emit CreateAddableAt(r); + QRectF r = generate_display_transform().inverted().mapRect(band_rect); + emit create_addable_at(r); } add_band_ = false; @@ -1104,7 +1104,7 @@ bool ViewerDisplayWidget::OnMouseRelease(QMouseEvent *e) MultiUndoCommand *command = new MultiUndoCommand(); if (DraggableGizmo *draggable = dynamic_cast(current_gizmo_)) { - draggable->DragEnd(command); + draggable->drag_end(command); } Core::instance()->undo_stack()->push(command, tr("Dragged Gizmo")); gizmo_drag_started_ = false; @@ -1117,16 +1117,16 @@ bool ViewerDisplayWidget::OnMouseRelease(QMouseEvent *e) return false; } -bool ViewerDisplayWidget::OnMouseDoubleClick(QMouseEvent *event) +bool ViewerDisplayWidget::on_mouse_double_click(QMouseEvent *event) { - if (text_edit_ && ForwardMouseEventToTextEdit(event)) { + if (text_edit_ && forward_mouse_event_to_text_edit(event)) { return true; } else if (event->button() == Qt::LeftButton && gizmos_) { - QPointF ptr = TransformViewerSpaceToBufferSpace(event->pos()); - foreach (NodeGizmo *g, gizmos_->GetGizmos()) { + QPointF ptr = transform_viewer_space_to_buffer_space(event->pos()); + foreach (NodeGizmo *g, gizmos_->get_gizmos()) { if (TextGizmo *text = dynamic_cast(g)) { - if (text->GetRect().contains(ptr)) { - OpenTextGizmo(text, event); + if (text->get_rect().contains(ptr)) { + open_text_gizmo(text, event); return true; } } @@ -1136,28 +1136,28 @@ bool ViewerDisplayWidget::OnMouseDoubleClick(QMouseEvent *event) return false; } -bool ViewerDisplayWidget::OnKeyPress(QKeyEvent *e) +bool ViewerDisplayWidget::on_key_press(QKeyEvent *e) { if (text_edit_) { if (e->key() == Qt::Key_Escape) { - CloseTextEditor(); + close_text_editor(); return true; } else { - return ForwardEventToTextEdit(e); + return forward_event_to_text_edit(e); } } return false; } -bool ViewerDisplayWidget::OnKeyRelease(QKeyEvent *e) +bool ViewerDisplayWidget::on_key_release(QKeyEvent *e) { if (text_edit_) { - return ForwardEventToTextEdit(e); + return forward_event_to_text_edit(e); } return false; } -void ViewerDisplayWidget::EmitColorAtCursor(QMouseEvent *e) +void ViewerDisplayWidget::emit_color_at_cursor(QMouseEvent *e) { // Do this no matter what, emits signal to any pixel samplers if (signal_cursor_color_) { @@ -1165,39 +1165,39 @@ void ViewerDisplayWidget::EmitColorAtCursor(QMouseEvent *e) if (texture_) { QPointF pixel_pos = - GenerateDisplayTransform().inverted().map(e->pos()); + generate_display_transform().inverted().map(e->pos()); pixel_pos /= texture_->params().divider(); - makeCurrent(); + make_current(); reference = - renderer()->GetPixelFromTexture(texture_.get(), pixel_pos); + renderer()->get_pixel_from_texture(texture_.get(), pixel_pos); if (color_service()) { - display = color_service()->ConvertColor(reference); + display = color_service()->convert_color(reference); } else { display = reference; } } - emit CursorColor(reference, display); + emit cursor_color(reference, display); } } -void ViewerDisplayWidget::DrawSubtitleTracks() +void ViewerDisplayWidget::draw_subtitle_tracks() { if (!show_subtitles_ || !subtitle_tracks_) { return; } const QVector &subtitle_tracklist = - subtitle_tracks_->track_list(Track::kSubtitle)->GetTracks(); + subtitle_tracks_->track_list(Track::k_subtitle)->get_tracks(); if (subtitle_tracklist.empty()) { return; } // Scale font size by transform - QTransform display_transform = GenerateDisplayTransform(); - qreal font_sz = OLIVE_CONFIG("DefaultSubtitleSize").toInt(); + QTransform display_transform = generate_display_transform(); + qreal font_sz = OAK_CONFIG("DefaultSubtitleSize").toInt(); font_sz *= display_transform.m11(); if (qIsNaN(font_sz)) { return; @@ -1205,19 +1205,19 @@ void ViewerDisplayWidget::DrawSubtitleTracks() QPainterPath path; - QTransform transform = GenerateWorldTransform(); + QTransform transform = generate_world_transform(); QRect bounding_box = transform.mapRect(rect()); QFont f; f.setPointSizeF(font_sz); - QString family = OLIVE_CONFIG("DefaultSubtitleFamily").toString(); + QString family = OAK_CONFIG("DefaultSubtitleFamily").toString(); if (!family.isEmpty()) { f.setFamily(family); } f.setWeight(static_cast( - OLIVE_CONFIG("DefaultSubtitleWeight").toInt())); + OAK_CONFIG("DefaultSubtitleWeight").toInt())); bounding_box.adjust(bounding_box.width() / 10, bounding_box.height() / 10, -bounding_box.width() / 10, @@ -1227,15 +1227,15 @@ void ViewerDisplayWidget::DrawSubtitleTracks() for (int j = subtitle_tracklist.size() - 1; j >= 0; j--) { Track *sub_track = subtitle_tracklist.at(j); - if (!sub_track->IsMuted()) { + if (!sub_track->is_muted()) { if (SubtitleBlock *sub = dynamic_cast( - sub_track->VisibleBlockAtTime(time_))) { + sub_track->visible_block_at_time(time_))) { // Split into lines - QStringList list = QtUtils::WordWrapString( - sub->GetText(), fm, bounding_box.width()); + QStringList list = QtUtils::word_wrap_string( + sub->get_text(), fm, bounding_box.width()); for (int i = list.size() - 1; i >= 0; i--) { - int w = QtUtils::QFontMetricsWidth(fm, list.at(i)); + int w = QtUtils::q_font_metrics_width(fm, list.at(i)); path.addText(bounding_box.width() / 2 - w / 2, bounding_box.height() - fm.height() * (list.size() - i) + @@ -1246,7 +1246,7 @@ void ViewerDisplayWidget::DrawSubtitleTracks() } } - bool antialias = OLIVE_CONFIG("AntialiasSubtitles").toBool(); + bool antialias = OAK_CONFIG("AntialiasSubtitles").toBool(); QPixmap *aa_pixmap; QPainter *text_painter; @@ -1280,7 +1280,7 @@ void ViewerDisplayWidget::DrawSubtitleTracks() } } -template void ViewerDisplayWidget::ForwardDragEventToTextEdit(T *e) +template void ViewerDisplayWidget::forward_drag_event_to_text_edit(T *e) { // HACK: Absolutely filthy hack. We need to be able to transform the mouse coordinates for our // proxied QTextEdit, however unlike QMouseEvents, Qt's drag events don't allow modifying @@ -1295,7 +1295,7 @@ template void ViewerDisplayWidget::ForwardDragEventToTextEdit(T *e) if constexpr (std::is_same_v) { text_edit_->dragLeaveEvent(e); } else { - T relay(AdjustPosByVAlign(GetVirtualPosForTextEdit(e->pos())).toPoint(), + T relay(adjust_pos_by_v_align(get_virtual_pos_for_text_edit(e->pos())).toPoint(), e->possibleActions(), e->mimeData(), e->mouseButtons(), e->keyboardModifiers()); @@ -1313,7 +1313,7 @@ template void ViewerDisplayWidget::ForwardDragEventToTextEdit(T *e) } } -bool ViewerDisplayWidget::ForwardMouseEventToTextEdit(QMouseEvent *event, +bool ViewerDisplayWidget::forward_mouse_event_to_text_edit(QMouseEvent *event, bool check_if_outside) { if (current_gizmo_) { @@ -1321,7 +1321,7 @@ bool ViewerDisplayWidget::ForwardMouseEventToTextEdit(QMouseEvent *event, } // Transform screen mouse coords to world mouse coords - QPointF local_pos = GetVirtualPosForTextEdit(event->pos()); + QPointF local_pos = get_virtual_pos_for_text_edit(event->pos()); if (event->type() == QEvent::MouseMove && event->buttons() == Qt::NoButton) { @@ -1340,26 +1340,26 @@ bool ViewerDisplayWidget::ForwardMouseEventToTextEdit(QMouseEvent *event, if (local_pos.x() < 0 || local_pos.x() >= text_edit_->width() || local_pos.y() < 0 || local_pos.y() >= text_edit_->height()) { // Allow clicking other gizmos so the user can resize while the text editor is active - if ((current_gizmo_ = TryGizmoPress( + if ((current_gizmo_ = try_gizmo_press( gizmo_db_, gizmo_last_draw_transform_inverted_.map(event->pos())))) { return false; } else { - CloseTextEditor(); + close_text_editor(); return true; } } } - local_pos = AdjustPosByVAlign(local_pos); + local_pos = adjust_pos_by_v_align(local_pos); QMouseEvent derived(event->type(), local_pos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers(), event->source()); - return ForwardEventToTextEdit(&derived); + return forward_event_to_text_edit(&derived); } -bool ViewerDisplayWidget::ForwardEventToTextEdit(QEvent *event) +bool ViewerDisplayWidget::forward_event_to_text_edit(QEvent *event) { qApp->sendEvent(text_edit_->viewport(), event); bool e = event->isAccepted(); @@ -1369,9 +1369,9 @@ bool ViewerDisplayWidget::ForwardEventToTextEdit(QEvent *event) return e; } -QPointF ViewerDisplayWidget::AdjustPosByVAlign(QPointF p) +QPointF ViewerDisplayWidget::adjust_pos_by_v_align(QPointF p) { - switch (active_text_gizmo_->GetVerticalAlignment()) { + switch (active_text_gizmo_->get_vertical_alignment()) { case Qt::AlignTop: // Do nothing break; @@ -1388,48 +1388,48 @@ QPointF ViewerDisplayWidget::AdjustPosByVAlign(QPointF p) return p; } -void ViewerDisplayWidget::CloseTextEditor() +void ViewerDisplayWidget::close_text_editor() { text_edit_->deleteLater(); text_edit_ = nullptr; - disconnect(active_text_gizmo_, &TextGizmo::RectChanged, this, - &ViewerDisplayWidget::UpdateActiveTextGizmoSize); + disconnect(active_text_gizmo_, &TextGizmo::rect_changed, this, + &ViewerDisplayWidget::update_active_text_gizmo_size); active_text_gizmo_ = nullptr; } -void ViewerDisplayWidget::GenerateGizmoTransforms() +void ViewerDisplayWidget::generate_gizmo_transforms() { NodeTraverser gt; - gt.SetCacheVideoParams(gizmo_params_); - gt.SetCacheAudioParams(gizmo_audio_params_); + gt.set_cache_video_params(gizmo_params_); + gt.set_cache_audio_params(gizmo_audio_params_); - gizmo_draw_time_ = GenerateGizmoTime(); + gizmo_draw_time_ = generate_gizmo_time(); if (gizmos_) { - gizmo_db_ = gt.GenerateRow(gizmos_, gizmo_draw_time_); + gizmo_db_ = gt.generate_row(gizmos_, gizmo_draw_time_); } - gizmo_last_draw_transform_ = GenerateGizmoTransform(gt, gizmo_draw_time_); + gizmo_last_draw_transform_ = generate_gizmo_transform(gt, gizmo_draw_time_); gizmo_last_draw_transform_inverted_ = gizmo_last_draw_transform_.inverted(); } -void ViewerDisplayWidget::DrawBlank(const VideoParams &device_params) +void ViewerDisplayWidget::draw_blank(const VideoParams &device_params) { if (blank_shader_.isNull()) { - blank_shader_ = renderer()->CreateNativeShader(ShaderCode()); + blank_shader_ = renderer()->create_native_shader(ShaderCode()); } ShaderJob job; - job.Insert(QStringLiteral("ove_mvpmat"), - NodeValue(NodeValue::kMatrix, combined_matrix_flipped_)); - job.Insert(QStringLiteral("ove_cropmatrix"), - NodeValue(NodeValue::kMatrix, crop_matrix_)); + job.insert(QStringLiteral("ove_mvpmat"), + NodeValue(NodeValue::k_matrix, combined_matrix_flipped_)); + job.insert(QStringLiteral("ove_cropmatrix"), + NodeValue(NodeValue::k_matrix, crop_matrix_)); - renderer()->Blit(blank_shader_, job, device_params, false); + renderer()->blit(blank_shader_, job, device_params, false); } -bool ViewerDisplayWidget::DrawBackendNeutralFrame(const FramePtr &frame, +bool ViewerDisplayWidget::draw_backend_neutral_frame(const FramePtr &frame, QPainter *painter) { if (!frame || !frame->is_allocated() || !painter || !painter->isActive() || @@ -1443,7 +1443,7 @@ bool ViewerDisplayWidget::DrawBackendNeutralFrame(const FramePtr &frame, !backend_neutral_cpu_image_.isNull()) { painter->save(); painter->setRenderHint(QPainter::SmoothPixmapTransform, true); - painter->setWorldTransform(GenerateWorldTransform(), false); + painter->setWorldTransform(generate_world_transform(), false); painter->drawImage(rect(), backend_neutral_cpu_image_); painter->restore(); return true; @@ -1456,17 +1456,17 @@ bool ViewerDisplayWidget::DrawBackendNeutralFrame(const FramePtr &frame, FramePtr display_frame = frame; QImage source_image; - if (display_frame->format() == PixelFormat::U8 && - display_frame->channel_count() == VideoParams::kRGBAChannelCount) { + if (display_frame->format() == PixelFormat::u8 && + display_frame->channel_count() == VideoParams::k_rgba_channel_count) { backend_neutral_cpu_display_frame_ = display_frame; backend_neutral_cpu_image_ = QImage(reinterpret_cast(display_frame->const_data()), display_frame->width(), display_frame->height(), display_frame->linesize_bytes(), QImage::Format_RGBA8888); source_image = backend_neutral_cpu_image_; - } else if (display_frame->format() == PixelFormat::U8 && + } else if (display_frame->format() == PixelFormat::u8 && display_frame->channel_count() == - VideoParams::kRGBChannelCount) { + VideoParams::k_rgb_channel_count) { backend_neutral_cpu_display_frame_ = display_frame; backend_neutral_cpu_image_ = QImage(reinterpret_cast(display_frame->const_data()), @@ -1476,7 +1476,7 @@ bool ViewerDisplayWidget::DrawBackendNeutralFrame(const FramePtr &frame, } else { backend_neutral_cpu_display_frame_.reset(); const int bytes_per_pixel = - display_frame->video_params().GetBytesPerPixel(); + display_frame->video_params().get_bytes_per_pixel(); if (backend_neutral_cpu_image_.size() != QSize(display_frame->width(), display_frame->height()) || backend_neutral_cpu_image_.format() != QImage::Format_RGBA8888) { @@ -1509,16 +1509,16 @@ bool ViewerDisplayWidget::DrawBackendNeutralFrame(const FramePtr &frame, painter->save(); painter->setRenderHint(QPainter::SmoothPixmapTransform, true); - painter->setWorldTransform(GenerateWorldTransform(), false); + painter->setWorldTransform(generate_world_transform(), false); painter->drawImage(rect(), source_image); painter->restore(); return true; } -bool ViewerDisplayWidget::DrawBackendNeutralTexture(const TexturePtr &texture, +bool ViewerDisplayWidget::draw_backend_neutral_texture(const TexturePtr &texture, QPainter *painter) { - if (!texture || texture->IsDummy() || !texture->renderer() || !painter || + if (!texture || texture->is_dummy() || !texture->renderer() || !painter || !painter->isActive() || !color_service()) { return false; } @@ -1529,21 +1529,21 @@ bool ViewerDisplayWidget::DrawBackendNeutralTexture(const TexturePtr &texture, !backend_neutral_cpu_image_.isNull()) { painter->save(); painter->setRenderHint(QPainter::SmoothPixmapTransform, true); - painter->setWorldTransform(GenerateWorldTransform(), false); + painter->setWorldTransform(generate_world_transform(), false); painter->drawImage(rect(), backend_neutral_cpu_image_); painter->restore(); return true; } - FramePtr frame = Frame::Create(); + FramePtr frame = Frame::create(); frame->set_video_params(texture->params()); if (!frame->allocate()) { return false; } - texture->Download(frame->data(), frame->linesize_pixels()); + texture->download(frame->data(), frame->linesize_pixels()); - if (!DrawBackendNeutralFrame(frame, painter)) { + if (!draw_backend_neutral_frame(frame, painter)) { return false; } @@ -1554,7 +1554,7 @@ bool ViewerDisplayWidget::DrawBackendNeutralTexture(const TexturePtr &texture, // Renders a backend-neutral frame by drawing into an offscreen backend texture, // downloading it to CPU memory, then painting that image with QPainter. -void ViewerDisplayWidget::DrawBackendNeutral(const ColorTransformJob &ctj, +void ViewerDisplayWidget::draw_backend_neutral(const ColorTransformJob &ctj, QPainter *painter) { if (!painter || !painter->isActive()) { @@ -1565,35 +1565,35 @@ void ViewerDisplayWidget::DrawBackendNeutral(const ColorTransformJob &ctj, const int texture_height = static_cast(height() * devicePixelRatioF()); const VideoParams offscreen_params(texture_width, texture_height, - PixelFormat::U8, - VideoParams::kRGBAChannelCount); + PixelFormat::u8, + VideoParams::k_rgba_channel_count); if (!backend_neutral_texture_ || backend_neutral_texture_->params() != offscreen_params) { // The offscreen texture is sized in device pixels so high-DPI widgets // draw one downloaded pixel per device pixel after setDevicePixelRatio(). - backend_neutral_texture_ = renderer()->CreateTexture(offscreen_params); + backend_neutral_texture_ = renderer()->create_texture(offscreen_params); backend_neutral_buffer_.resize( texture_width * texture_height * - VideoParams::GetBytesPerPixel(PixelFormat::U8, - VideoParams::kRGBAChannelCount)); + VideoParams::get_bytes_per_pixel(PixelFormat::u8, + VideoParams::k_rgba_channel_count)); } - if (!backend_neutral_texture_ || backend_neutral_texture_->IsDummy()) { + if (!backend_neutral_texture_ || backend_neutral_texture_->is_dummy()) { return; } ColorTransformJob local_ctj = ctj; - local_ctj.SetClearDestinationEnabled(true); + local_ctj.set_clear_destination_enabled(true); // Reuse the normal color-management shader path, but render into a texture // instead of an OpenGL widget framebuffer. - renderer()->BlitColorManaged(local_ctj, backend_neutral_texture_.get()); + renderer()->blit_color_managed(local_ctj, backend_neutral_texture_.get()); - backend_neutral_texture_->Download(backend_neutral_buffer_.data(), 0); + backend_neutral_texture_->download(backend_neutral_buffer_.data(), 0); - const int bytes_per_pixel = VideoParams::GetBytesPerPixel( - PixelFormat::U8, VideoParams::kRGBAChannelCount); + const int bytes_per_pixel = VideoParams::get_bytes_per_pixel( + PixelFormat::u8, VideoParams::k_rgba_channel_count); QImage img( reinterpret_cast(backend_neutral_buffer_.constData()), @@ -1606,82 +1606,82 @@ void ViewerDisplayWidget::DrawBackendNeutral(const ColorTransformJob &ctj, painter->drawImage(QPoint(0, 0), img); } -void ViewerDisplayWidget::SetShowFPS(bool e) +void ViewerDisplayWidget::set_show_fps(bool e) { show_fps_ = e; update(); } -void ViewerDisplayWidget::RequestStartEditingText() +void ViewerDisplayWidget::request_start_editing_text() { if (gizmos_) { - foreach (NodeGizmo *gizmo, gizmos_->GetGizmos()) { + foreach (NodeGizmo *gizmo, gizmos_->get_gizmos()) { if (TextGizmo *text = dynamic_cast(gizmo)) { - OpenTextGizmo(text); + open_text_gizmo(text); break; } } } } -void ViewerDisplayWidget::Play(const int64_t &start_timestamp, +void ViewerDisplayWidget::play(const int64_t &start_timestamp, const int &playback_speed, - const rational &timebase, bool start_updating) + const Rational &timebase, bool start_updating) { playback_timebase_ = timebase; playback_speed_ = playback_speed; - timer_.Start(start_timestamp, playback_speed, timebase.toDouble()); + timer_.start(start_timestamp, playback_speed, timebase.to_double()); if (start_updating) { - connect(this, &ViewerDisplayWidget::frameSwapped, this, - &ViewerDisplayWidget::UpdateFromQueue); + connect(this, &ViewerDisplayWidget::frame_swapped, this, + &ViewerDisplayWidget::update_from_queue); update(); } } -void ViewerDisplayWidget::Pause() +void ViewerDisplayWidget::pause() { - disconnect(this, &ViewerDisplayWidget::frameSwapped, this, - &ViewerDisplayWidget::UpdateFromQueue); + disconnect(this, &ViewerDisplayWidget::frame_swapped, this, + &ViewerDisplayWidget::update_from_queue); queue_.clear(); queue_starved_ = false; } -QPointF ViewerDisplayWidget::ScreenToScenePoint(const QPoint &p) +QPointF ViewerDisplayWidget::screen_to_scene_point(const QPoint &p) { if (gizmo_last_draw_transform_.isIdentity()) { - GenerateGizmoTransforms(); + generate_gizmo_transforms(); } return p * gizmo_last_draw_transform_inverted_; } -void ViewerDisplayWidget::UpdateFromQueue() +void ViewerDisplayWidget::update_from_queue() { - int64_t t = timer_.GetTimestampNow(); + int64_t t = timer_.get_timestamp_now(); - rational time = Timecode::timestamp_to_time(t, playback_timebase_); + Rational time = Timecode::timestamp_to_time(t, playback_timebase_); bool popped = false; if (queue_.empty()) { queue_starved_ = true; - emit QueueStarved(); + emit queue_starved(); } else { while (!queue_.empty()) { const ViewerPlaybackFrame &pf = queue_.front(); if (pf.timestamp == time) { // Frame was in queue, no need to decode anything - SetImage(pf.frame); + set_image(pf.frame); if (queue_starved_) { queue_starved_ = false; - emit QueueNoLongerStarved(); + emit queue_no_longer_starved(); } return; @@ -1695,16 +1695,16 @@ void ViewerDisplayWidget::UpdateFromQueue() if (popped) { // We've already popped a frame in this loop, meaning a frame has been skipped - IncrementSkippedFrames(); + increment_skipped_frames(); } else { // Shown a frame and progressed to the next one - IncrementFrameCount(); + increment_frame_count(); popped = true; } if (queue_.empty()) { queue_starved_ = true; - emit QueueStarved(); + emit queue_starved(); break; } } @@ -1714,39 +1714,39 @@ void ViewerDisplayWidget::UpdateFromQueue() update(); } -void ViewerDisplayWidget::TextEditChanged() +void ViewerDisplayWidget::text_edit_changed() { ViewerTextEditor *editor = static_cast(sender()); TextGizmo *gizmo = reinterpret_cast( editor->property("gizmo").value()); - QString html = Html::DocToHtml(editor->document()); - gizmo->UpdateInputHtml(html, GetGizmoTime()); + QString html = Html::doc_to_html(editor->document()); + gizmo->update_input_html(html, get_gizmo_time()); } -void ViewerDisplayWidget::TextEditDestroyed() +void ViewerDisplayWidget::text_edit_destroyed() { TextGizmo *gizmo = reinterpret_cast( sender()->property("gizmo").value()); - emit gizmo->Deactivated(); + emit gizmo->deactivated(); text_edit_ = nullptr; text_toolbar_ = nullptr; inner_widget()->setMouseTracking(false); inner_widget()->setFocusPolicy(Qt::NoFocus); - UpdateCursor(); + update_cursor(); disconnect(qApp, &QApplication::focusChanged, this, - &ViewerDisplayWidget::FocusChanged); + &ViewerDisplayWidget::focus_changed); } -void ViewerDisplayWidget::SubtitlesChanged(const TimeRange &r) +void ViewerDisplayWidget::subtitles_changed(const TimeRange &r) { if (time_ >= r.in() && time_ < r.out()) { update(); } } -void ViewerDisplayWidget::FocusChanged(QWidget *old, QWidget *now) +void ViewerDisplayWidget::focus_changed(QWidget *old, QWidget *now) { if (!now) { // Ignore this @@ -1765,13 +1765,13 @@ void ViewerDisplayWidget::FocusChanged(QWidget *old, QWidget *now) } if (unfocused) { - CloseTextEditor(); + close_text_editor(); } } -QRectF ViewerDisplayWidget::UpdateActiveTextGizmoSize() +QRectF ViewerDisplayWidget::update_active_text_gizmo_size() { - QRectF text_rect = active_text_gizmo_->GetRect(); + QRectF text_rect = active_text_gizmo_->get_rect(); text_edit_pos_ = text_rect.topLeft(); text_edit_->setGeometry(text_rect.toRect()); return text_rect; diff --git a/app/widget/viewer/viewerdisplay.h b/app/widget/viewer/viewerdisplay.h index 291d95708..6a0d0161f 100644 --- a/app/widget/viewer/viewerdisplay.h +++ b/app/widget/viewer/viewerdisplay.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWERGLWIDGET_H -#define VIEWERGLWIDGET_H +#ifndef OAK_VIEWERGLWIDGET_H +#define OAK_VIEWERGLWIDGET_H #include #include @@ -73,27 +73,27 @@ public: virtual ~ViewerDisplayWidget() override; - const ViewerSafeMarginInfo &GetSafeMargin() const; - void SetSafeMargins(const ViewerSafeMarginInfo &safe_margin); + const ViewerSafeMarginInfo &get_safe_margin() const; + void set_safe_margins(const ViewerSafeMarginInfo &safe_margin); - void SetGizmos(Node *node); + void set_gizmos(Node *node); - const VideoParams &GetVideoParams() const + const VideoParams &get_video_params() const { return gizmo_params_; } - void SetVideoParams(const VideoParams ¶ms); + void set_video_params(const VideoParams ¶ms); - const AudioParams &GetAudioParams() const + const AudioParams &get_audio_params() const { return gizmo_audio_params_; } - void SetAudioParams(const AudioParams &p); + void set_audio_params(const AudioParams &p); - void SetTime(const rational &time); - void SetSubtitleTracks(Sequence *list); + void set_time(const Rational &time); + void set_subtitle_tracks(Sequence *list); - void SetShowWidgetBackground(bool e) + void set_show_widget_background(bool e) { show_widget_background_ = e; update(); @@ -103,51 +103,51 @@ public: * @brief Transform a point from viewer space to the buffer space. * Multiplies by the inverted transform matrix to undo the scaling and translation. */ - QPointF TransformViewerSpaceToBufferSpace(const QPointF &pos); + QPointF transform_viewer_space_to_buffer_space(const QPointF &pos); - bool IsDeinterlacing() const + bool is_deinterlacing() const { return deinterlace_; } - void ResetFPSTimer(); + void reset_fps_timer(); - bool GetShowFPS() const + bool get_show_fps() const { return show_fps_; } - bool GetShowSubtitles() const + bool get_show_subtitles() const { return show_subtitles_; } - void SetShowSubtitles(bool e) + void set_show_subtitles(bool e) { show_subtitles_ = e; update(); } - void IncrementSkippedFrames(); + void increment_skipped_frames(); - void IncrementFrameCount() + void increment_frame_count() { fps_timer_update_count_++; } - TexturePtr GetCurrentTexture() const + TexturePtr get_current_texture() const { return texture_; } - ColorProcessorPtr GetCurrentColorProcessor() + ColorProcessorPtr get_current_color_processor() { return color_service(); } - void Play(const int64_t &start_timestamp, const int &playback_speed, - const rational &timebase, bool start_updating); + void play(const int64_t &start_timestamp, const int &playback_speed, + const Rational &timebase, bool start_updating); - void Pause(); + void pause(); ViewerQueue *queue() { @@ -159,7 +159,7 @@ public: return &timer_; } - QPointF ScreenToScenePoint(const QPoint &p); + QPointF screen_to_scene_point(const QPoint &p); virtual bool eventFilter(QObject *o, QEvent *e) override; @@ -169,14 +169,14 @@ public slots: * * Set this if you want the drawing to pass through some sort of transform (most of the time you won't want this). */ - void SetMatrixTranslate(const QMatrix4x4 &mat); + void set_matrix_translate(const QMatrix4x4 &mat); /** * @brief Set the scale matrix. */ - void SetMatrixZoom(const QMatrix4x4 &mat); + void set_matrix_zoom(const QMatrix4x4 &mat); - void SetMatrixCrop(const QMatrix4x4 &mat); + void set_matrix_crop(const QMatrix4x4 &mat); /** * @brief Enables or disables whether this color at the cursor should be emitted @@ -185,91 +185,91 @@ public slots: * have an option for it. Ideally, this should be connected to a PixelSamplerPanel::visibilityChanged signal so that * it can automatically be enabled when the user is pixel sampling and disabled for optimization when they're not. */ - void SetSignalCursorColorEnabled(bool e); + void set_signal_cursor_color_enabled(bool e); - void SetImage(const QVariant &buffer); + void set_image(const QVariant &buffer); - void SetBlank(); + void set_blank(); /** * @brief Changes the pointer type if the tool is changed to the hand tool. Otherwise resets the pointer to it's * normal type. */ - void UpdateCursor(); + void update_cursor(); - void ToolChanged(); + void tool_changed(); /** * @brief Enables/disables a basic deinterlace on the viewer */ - void SetDeinterlacing(bool e); + void set_deinterlacing(bool e); - void SetShowFPS(bool e); + void set_show_fps(bool e); - void RequestStartEditingText(); + void request_start_editing_text(); signals: /** * @brief Signal emitted when the user starts dragging from the viewer */ - void DragStarted(const QPoint &p); + void drag_started(const QPoint &p); /** * @brief Signal emitted when a hand drag starts */ - void HandDragStarted(); + void hand_drag_started(); /** * @brief Signal emitted when a hand drag moves */ - void HandDragMoved(int x, int y); + void hand_drag_moved(int x, int y); /** * @brief Signal emitted when a hand drag ends */ - void HandDragEnded(); + void hand_drag_ended(); /** * @brief Signal emitted when cursor color is enabled and the user's mouse position changes */ - void CursorColor(const Color &reference, const Color &display); + void cursor_color(const Color &reference, const Color &display); - void DragEntered(QDragEnterEvent *event); + void drag_entered(QDragEnterEvent *event); - void DragLeft(QDragLeaveEvent *event); + void drag_left(QDragLeaveEvent *event); - void Dropped(QDropEvent *event); + void dropped(QDropEvent *event); - void TextureChanged(TexturePtr texture); + void texture_changed(TexturePtr texture); - void QueueStarved(); + void queue_starved(); - void QueueNoLongerStarved(); + void queue_no_longer_starved(); - void CreateAddableAt(const QRectF &rect); + void create_addable_at(const QRectF &rect); protected: - QTransform GenerateWorldTransform(); + QTransform generate_world_transform(); - QTransform GenerateDisplayTransform(); + QTransform generate_display_transform(); - QTransform GenerateGizmoTransform(NodeTraverser >, + QTransform generate_gizmo_transform(NodeTraverser >, const TimeRange &range); - QTransform GenerateGizmoTransform() + QTransform generate_gizmo_transform() { NodeTraverser t; - t.SetCacheVideoParams(gizmo_params_); - return GenerateGizmoTransform(t, GenerateGizmoTime()); + t.set_cache_video_params(gizmo_params_); + return generate_gizmo_transform(t, generate_gizmo_time()); } - TimeRange GenerateGizmoTime() + TimeRange generate_gizmo_time() { - rational node_time = GetGizmoTime(); + Rational node_time = get_gizmo_time(); return TimeRange(node_time, node_time + gizmo_params_.frame_rate_as_time_base()); } - virtual TexturePtr LoadCustomTextureFromFrame(const QVariant &v) + virtual TexturePtr load_custom_texture_from_frame(const QVariant &v) { return nullptr; } @@ -280,63 +280,63 @@ protected slots: * * Simple OpenGL drawing function for painting the texture on screen. Standardized around OpenGL ES 3.2 Core. */ - virtual void OnPaint() override; + virtual void on_paint() override; - virtual void OnDestroy() override; + virtual void on_destroy() override; private: - QPointF GetTexturePosition(const QPoint &screen_pos); - QPointF GetTexturePosition(const QSize &size); - QPointF GetTexturePosition(const double &x, const double &y); + QPointF get_texture_position(const QPoint &screen_pos); + QPointF get_texture_position(const QSize &size); + QPointF get_texture_position(const double &x, const double &y); - static void DrawTextWithCrudeShadow(QPainter *painter, const QRect &rect, + static void draw_text_with_crude_shadow(QPainter *painter, const QRect &rect, const QString &text, const QTextOption &opt = QTextOption()); - rational GetGizmoTime(); + Rational get_gizmo_time(); - bool IsHandDrag(QMouseEvent *event) const; + bool is_hand_drag(QMouseEvent *event) const; - void UpdateMatrix(); + void update_matrix(); - NodeGizmo *TryGizmoPress(const NodeValueRow &row, const QPointF &p); + NodeGizmo *try_gizmo_press(const NodeValueRow &row, const QPointF &p); - void OpenTextGizmo(TextGizmo *text, QMouseEvent *event = nullptr); + void open_text_gizmo(TextGizmo *text, QMouseEvent *event = nullptr); - bool OnMousePress(QMouseEvent *e); - bool OnMouseMove(QMouseEvent *e); - bool OnMouseRelease(QMouseEvent *e); - bool OnMouseDoubleClick(QMouseEvent *e); + bool on_mouse_press(QMouseEvent *e); + bool on_mouse_move(QMouseEvent *e); + bool on_mouse_release(QMouseEvent *e); + bool on_mouse_double_click(QMouseEvent *e); - bool OnKeyPress(QKeyEvent *e); - bool OnKeyRelease(QKeyEvent *e); + bool on_key_press(QKeyEvent *e); + bool on_key_release(QKeyEvent *e); - void EmitColorAtCursor(QMouseEvent *e); + void emit_color_at_cursor(QMouseEvent *e); - void DrawSubtitleTracks(); + void draw_subtitle_tracks(); - QPointF GetVirtualPosForTextEdit(const QPointF &p) + QPointF get_virtual_pos_for_text_edit(const QPointF &p) { return text_transform_inverted_.map(p) - text_edit_pos_; } - template void ForwardDragEventToTextEdit(T *event); + template void forward_drag_event_to_text_edit(T *event); - bool ForwardMouseEventToTextEdit(QMouseEvent *event, + bool forward_mouse_event_to_text_edit(QMouseEvent *event, bool check_if_outside = false); - bool ForwardEventToTextEdit(QEvent *event); + bool forward_event_to_text_edit(QEvent *event); - QPointF AdjustPosByVAlign(QPointF p); + QPointF adjust_pos_by_v_align(QPointF p); - void CloseTextEditor(); + void close_text_editor(); - void GenerateGizmoTransforms(); + void generate_gizmo_transforms(); - void DrawBlank(const VideoParams &device_params); + void draw_blank(const VideoParams &device_params); - void DrawBackendNeutral(const ColorTransformJob &ctj, QPainter *painter); - bool DrawBackendNeutralFrame(const FramePtr &frame, QPainter *painter); - bool DrawBackendNeutralTexture(const TexturePtr &texture, + void draw_backend_neutral(const ColorTransformJob &ctj, QPainter *painter); + bool draw_backend_neutral_frame(const FramePtr &frame, QPainter *painter); + bool draw_backend_neutral_texture(const TexturePtr &texture, QPainter *painter); /** @@ -417,7 +417,7 @@ private: bool show_subtitles_; Sequence *subtitle_tracks_; - rational time_; + Rational time_; /** * @brief Position of mouse to calculate delta from. @@ -444,16 +444,16 @@ private: enum PushMode { /// New frame to push to internal texture - kPushFrame, + k_push_frame, /// Internal texture reference is up to date, keep showing it - kPushUnnecessary, + k_push_unnecessary, /// Draw blank/black screen - kPushBlank, + k_push_blank, /// Draw nothing (not even a black frame) - kPushNull, + k_push_null, }; PushMode push_mode_; @@ -463,7 +463,7 @@ private: ViewerPlaybackTimer timer_; - rational playback_timebase_; + Rational playback_timebase_; bool add_band_; QPoint add_band_start_; @@ -479,18 +479,18 @@ private: QTransform text_transform_inverted_; private slots: - void UpdateFromQueue(); + void update_from_queue(); - void TextEditChanged(); - void TextEditDestroyed(); + void text_edit_changed(); + void text_edit_destroyed(); - void SubtitlesChanged(const TimeRange &r); + void subtitles_changed(const TimeRange &r); - void FocusChanged(QWidget *old, QWidget *now); + void focus_changed(QWidget *old, QWidget *now); - QRectF UpdateActiveTextGizmoSize(); + QRectF update_active_text_gizmo_size(); }; } -#endif // VIEWERGLWIDGET_H +#endif // OAK_VIEWERGLWIDGET_H diff --git a/app/widget/viewer/viewerplaybacktimer.cpp b/app/widget/viewer/viewerplaybacktimer.cpp index cbd143379..2b7357318 100644 --- a/app/widget/viewer/viewerplaybacktimer.cpp +++ b/app/widget/viewer/viewerplaybacktimer.cpp @@ -26,7 +26,7 @@ namespace olive { -void ViewerPlaybackTimer::Start(const int64_t &start_timestamp, +void ViewerPlaybackTimer::start(const int64_t &start_timestamp, const int &playback_speed, const double &timebase) { @@ -36,7 +36,7 @@ void ViewerPlaybackTimer::Start(const int64_t &start_timestamp, timebase_ = timebase * 1000; } -int64_t ViewerPlaybackTimer::GetTimestampNow() const +int64_t ViewerPlaybackTimer::get_timestamp_now() const { int64_t real_time = timer_.elapsed(); diff --git a/app/widget/viewer/viewerplaybacktimer.h b/app/widget/viewer/viewerplaybacktimer.h index 56f8e2594..1f87d1340 100644 --- a/app/widget/viewer/viewerplaybacktimer.h +++ b/app/widget/viewer/viewerplaybacktimer.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWERPLAYBACKTIMER_H -#define VIEWERPLAYBACKTIMER_H +#ifndef OAK_VIEWERPLAYBACKTIMER_H +#define OAK_VIEWERPLAYBACKTIMER_H #include #include @@ -32,10 +32,10 @@ namespace olive class ViewerPlaybackTimer { public: - void Start(const int64_t &start_timestamp, const int &playback_speed, + void start(const int64_t &start_timestamp, const int &playback_speed, const double &timebase); - int64_t GetTimestampNow() const; + int64_t get_timestamp_now() const; private: QElapsedTimer timer_; @@ -48,4 +48,4 @@ private: } -#endif // VIEWERPLAYBACKTIMER_H +#endif // OAK_VIEWERPLAYBACKTIMER_H diff --git a/app/widget/viewer/viewerpreventsleep.cpp b/app/widget/viewer/viewerpreventsleep.cpp index 48d1e6786..8e8018ee4 100644 --- a/app/widget/viewer/viewerpreventsleep.cpp +++ b/app/widget/viewer/viewerpreventsleep.cpp @@ -37,7 +37,7 @@ IOPMAssertionID assertionID = 0; #endif -void PreventSleep(bool on) +void prevent_sleep(bool on) { #if defined(Q_OS_WINDOWS) SetThreadExecutionState(on ? ES_DISPLAY_REQUIRED | ES_CONTINUOUS : diff --git a/app/widget/viewer/viewerpreventsleep.h b/app/widget/viewer/viewerpreventsleep.h index fba8bb5ed..34a532192 100644 --- a/app/widget/viewer/viewerpreventsleep.h +++ b/app/widget/viewer/viewerpreventsleep.h @@ -16,14 +16,14 @@ * along with this program. If not, see . */ -#ifndef VIEWERPREVENTSLEEP_H -#define VIEWERPREVENTSLEEP_H +#ifndef OAK_VIEWERPREVENTSLEEP_H +#define OAK_VIEWERPREVENTSLEEP_H namespace olive { -void PreventSleep(bool on); +void prevent_sleep(bool on); } -#endif // VIEWERPREVENTSLEEP_H +#endif // OAK_VIEWERPREVENTSLEEP_H diff --git a/app/widget/viewer/viewerqueue.h b/app/widget/viewer/viewerqueue.h index 33ea2fbe4..abdb22745 100644 --- a/app/widget/viewer/viewerqueue.h +++ b/app/widget/viewer/viewerqueue.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWERQUEUE_H -#define VIEWERQUEUE_H +#ifndef OAK_VIEWERQUEUE_H +#define OAK_VIEWERQUEUE_H #include #include @@ -32,7 +32,7 @@ namespace olive { struct ViewerPlaybackFrame { - rational timestamp; + Rational timestamp; QVariant frame; }; @@ -57,7 +57,7 @@ public: return *this; } - void AppendTimewise(const ViewerPlaybackFrame &f, int playback_speed) + void append_timewise(const ViewerPlaybackFrame &f, int playback_speed) { QMutexLocker locker(mutex_); if (this->empty() || @@ -73,7 +73,7 @@ public: } } - void PurgeBefore(const rational &time, int playback_speed) + void purge_before(const Rational &time, int playback_speed) { QMutexLocker locker(mutex_); while (!this->empty() && @@ -91,4 +91,4 @@ private: Q_DECLARE_METATYPE(olive::ViewerPlaybackFrame) -#endif // VIEWERQUEUE_H +#endif // OAK_VIEWERQUEUE_H diff --git a/app/widget/viewer/viewersafemargininfo.h b/app/widget/viewer/viewersafemargininfo.h index 4a9ce292d..6920fc1d1 100644 --- a/app/widget/viewer/viewersafemargininfo.h +++ b/app/widget/viewer/viewersafemargininfo.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWERSAFEMARGININFO_H -#define VIEWERSAFEMARGININFO_H +#ifndef OAK_VIEWERSAFEMARGININFO_H +#define OAK_VIEWERSAFEMARGININFO_H #include @@ -76,4 +76,4 @@ private: } -#endif // VIEWERSAFEMARGININFO_H +#endif // OAK_VIEWERSAFEMARGININFO_H diff --git a/app/widget/viewer/viewersizer.cpp b/app/widget/viewer/viewersizer.cpp index 79bd3eaab..783d3ec67 100644 --- a/app/widget/viewer/viewersizer.cpp +++ b/app/widget/viewer/viewersizer.cpp @@ -43,17 +43,17 @@ ViewerSizer::ViewerSizer(QWidget *parent) horiz_scrollbar_ = new QScrollBar(Qt::Horizontal, this); horiz_scrollbar_->setVisible(false); connect(horiz_scrollbar_, &QScrollBar::valueChanged, this, - &ViewerSizer::ScrollBarMoved); + &ViewerSizer::scroll_bar_moved); vert_scrollbar_ = new QScrollBar(Qt::Vertical, this); vert_scrollbar_->setVisible(false); connect(vert_scrollbar_, &QScrollBar::valueChanged, this, - &ViewerSizer::ScrollBarMoved); + &ViewerSizer::scroll_bar_moved); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } -void ViewerSizer::SetWidget(QWidget *widget) +void ViewerSizer::set_widget(QWidget *widget) { // Delete any previous widgets occupying this space delete widget_; @@ -64,50 +64,50 @@ void ViewerSizer::SetWidget(QWidget *widget) widget_->setParent(this); widget_->installEventFilter(this); - UpdateSize(); + update_size(); } } -QSize ViewerSizer::GetContainerSize() const +QSize ViewerSizer::get_container_size() const { - double s = GetRealCurrentZoom(); + double s = get_real_current_zoom(); return QSize(std::min(this->width(), int(width_ * s)) - vert_scrollbar_->width(), std::min(int(height_ * s), this->height()) - horiz_scrollbar_->height()); } -void ViewerSizer::SetChildSize(int width, int height) +void ViewerSizer::set_child_size(int width, int height) { width_ = width; height_ = height; - UpdateSize(); + update_size(); } -void ViewerSizer::SetPixelAspectRatio(const rational &pixel_aspect) +void ViewerSizer::set_pixel_aspect_ratio(const Rational &pixel_aspect) { pixel_aspect_ = pixel_aspect; - UpdateSize(); + update_size(); } -void ViewerSizer::SetZoom(double percent) +void ViewerSizer::set_zoom(double percent) { zoom_ = percent; - UpdateSize(); + update_size(); } -void ViewerSizer::SetZoomAnchored(double next_scale, double cursor_x, +void ViewerSizer::set_zoom_anchored(double next_scale, double cursor_x, double cursor_y) { if (next_scale > 0) { - double cur_scale = GetRealCurrentZoom(); + double cur_scale = get_real_current_zoom(); // Clamp scale within safe values - next_scale = std::clamp(next_scale, kZoomLevels[0], - kZoomLevels[kZoomLevelCount - 1]); + next_scale = std::clamp(next_scale, k_zoom_levels[0], + k_zoom_levels[k_zoom_level_count - 1]); int anchor_x = qRound(double(cursor_x + horiz_scrollbar_->value()) / cur_scale * next_scale - @@ -116,19 +116,19 @@ void ViewerSizer::SetZoomAnchored(double next_scale, double cursor_x, cur_scale * next_scale - cursor_y); - SetZoom(next_scale); + set_zoom(next_scale); horiz_scrollbar_->setValue(anchor_x); vert_scrollbar_->setValue(anchor_y); } else { - SetZoom(-1); + set_zoom(-1); horiz_scrollbar_->setValue(0); vert_scrollbar_->setValue(0); } } -void ViewerSizer::HandDragMove(int x, int y) +void ViewerSizer::hand_drag_move(int x, int y) { if (horiz_scrollbar_->isVisible()) { horiz_scrollbar_->setValue(horiz_scrollbar_->value() - x); @@ -146,10 +146,10 @@ bool ViewerSizer::eventFilter(QObject *watched, QEvent *event) QWheelEvent *w = static_cast(event); if (HandMovableView::WheelEventIsAZoomEvent(w)) { - double next_scale = GetRealCurrentZoom() * - HandMovableView::GetScrollZoomMultiplier(w); + double next_scale = get_real_current_zoom() * + HandMovableView::get_scroll_zoom_multiplier(w); QPointF cursor_pos = w->position(); - SetZoomAnchored(next_scale, cursor_pos.x(), cursor_pos.y()); + set_zoom_anchored(next_scale, cursor_pos.x(), cursor_pos.y()); } else { // Pass scroll values to scrollbars QPoint p = w->pixelDelta(); @@ -167,10 +167,10 @@ void ViewerSizer::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); - UpdateSize(); + update_size(); } -void ViewerSizer::UpdateSize() +void ViewerSizer::update_size() { if (widget_ == nullptr) { return; @@ -189,9 +189,9 @@ void ViewerSizer::UpdateSize() // Determine if we need scrollbars for the zoom we want horiz_scrollbar_->setVisible(zoom_ > 0 && - GetZoomedValue(width_) > available_width); + get_zoomed_value(width_) > available_width); vert_scrollbar_->setVisible(zoom_ > 0 && - GetZoomedValue(height_) > available_height); + get_zoomed_value(height_) > available_height); // Horizontal scrollbar will reduce the available height if (horiz_scrollbar_->isVisible()) { @@ -209,7 +209,7 @@ void ViewerSizer::UpdateSize() horiz_scrollbar_->sizeHint().height()); horiz_scrollbar_->move(0, this->height() - horiz_scrollbar_->height() - 1); - horiz_scrollbar_->setMaximum(GetZoomedValue(width_) - available_width); + horiz_scrollbar_->setMaximum(get_zoomed_value(width_) - available_width); horiz_scrollbar_->setPageStep(available_width); } @@ -218,7 +218,7 @@ void ViewerSizer::UpdateSize() vert_scrollbar_->resize(vert_scrollbar_->sizeHint().width(), available_height); vert_scrollbar_->move(this->width() - vert_scrollbar_->width() - 1, 0); - vert_scrollbar_->setMaximum(GetZoomedValue(height_) - available_height); + vert_scrollbar_->setMaximum(get_zoomed_value(height_) - available_height); vert_scrollbar_->setPageStep(available_height); } @@ -227,7 +227,7 @@ void ViewerSizer::UpdateSize() // Adjust to aspect ratio double sequence_aspect_ratio = - double(width_) / double(height_) * pixel_aspect_.toDouble(); + double(width_) / double(height_) * pixel_aspect_.to_double(); double our_aspect_ratio = double(available_width) / double(available_height); @@ -253,17 +253,17 @@ void ViewerSizer::UpdateSize() child_matrix.scale(zoom_diff, zoom_diff, 1.0); } - emit RequestScale(child_matrix); + emit request_scale(child_matrix); - ScrollBarMoved(); + scroll_bar_moved(); } -int ViewerSizer::GetZoomedValue(int value) +int ViewerSizer::get_zoomed_value(int value) { return qRound(value * zoom_); } -double ViewerSizer::GetRealCurrentZoom() const +double ViewerSizer::get_real_current_zoom() const { if (zoom_ < 0) { // Currently set to "fit" @@ -274,14 +274,14 @@ double ViewerSizer::GetRealCurrentZoom() const } } -void ViewerSizer::ScrollBarMoved() +void ViewerSizer::scroll_bar_moved() { QMatrix4x4 mat; float x_scroll, y_scroll; if (horiz_scrollbar_->isVisible()) { - int zoomed_width = GetZoomedValue(width_); + int zoomed_width = get_zoomed_value(width_); x_scroll = (zoomed_width / 2 - horiz_scrollbar_->value() - widget_->width() / 2) * (2.0 / zoomed_width); @@ -290,7 +290,7 @@ void ViewerSizer::ScrollBarMoved() } if (vert_scrollbar_->isVisible()) { - int zoomed_height = GetZoomedValue(height_); + int zoomed_height = get_zoomed_value(height_); y_scroll = (zoomed_height / 2 - vert_scrollbar_->value() - widget_->height() / 2) * (2.0 / zoomed_height); @@ -301,7 +301,7 @@ void ViewerSizer::ScrollBarMoved() // Zero translate is centered, so we need to determine how much "off center" we are mat.translate(x_scroll, y_scroll); - emit RequestTranslate(mat); + emit request_translate(mat); } } diff --git a/app/widget/viewer/viewersizer.h b/app/widget/viewer/viewersizer.h index b731aff4f..a0ca0438f 100644 --- a/app/widget/viewer/viewersizer.h +++ b/app/widget/viewer/viewersizer.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWERSIZER_H -#define VIEWERSIZER_H +#ifndef OAK_VIEWERSIZER_H +#define OAK_VIEWERSIZER_H #include #include @@ -50,12 +50,12 @@ public: * * ViewerSizer takes ownership of this widget. If a widget was previously set, it is destroyed. */ - void SetWidget(QWidget *widget); + void set_widget(QWidget *widget); - QSize GetContainerSize() const; + QSize get_container_size() const; - static constexpr int kZoomLevelCount = 10; - static constexpr double kZoomLevels[kZoomLevelCount] = { + static constexpr int k_zoom_level_count = 10; + static constexpr double k_zoom_levels[k_zoom_level_count] = { 0.05, 0.1, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 4.0, 8.0 }; @@ -65,29 +65,29 @@ public slots: * * This is not the actual resolution of the viewer, it's used to calculate the aspect ratio */ - void SetChildSize(int width, int height); + void set_child_size(int width, int height); /** * @brief Set pixel aspect ratio */ - void SetPixelAspectRatio(const rational &pixel_aspect); + void set_pixel_aspect_ratio(const Rational &pixel_aspect); /** * @brief Set the zoom value of the child widget * * The number is an integer percentage (100 = 100%). Set to 0 to auto-fit. */ - void SetZoom(double percent); - void SetZoomAnchored(double percent, double cursor_x, double cursor_y); + void set_zoom(double percent); + void set_zoom_anchored(double percent, double cursor_x, double cursor_y); - void HandDragMove(int x, int y); + void hand_drag_move(int x, int y); virtual bool eventFilter(QObject *watched, QEvent *event) override; signals: - void RequestScale(const QMatrix4x4 &matrix); + void request_scale(const QMatrix4x4 &matrix); - void RequestTranslate(const QMatrix4x4 &matrix); + void request_translate(const QMatrix4x4 &matrix); protected: /** @@ -99,11 +99,11 @@ private: /** * @brief Main sizing function, resizes widget_ to fit aspect_ratio_ (or hides if aspect ratio is 0) */ - void UpdateSize(); + void update_size(); - int GetZoomedValue(int value); + int get_zoomed_value(int value); - double GetRealCurrentZoom() const; + double get_real_current_zoom() const; /** * @brief Reference to widget @@ -118,7 +118,7 @@ private: int width_; int height_; - rational pixel_aspect_; + Rational pixel_aspect_; /** * @brief Internal zoom value @@ -130,9 +130,9 @@ private: QScrollBar *vert_scrollbar_; private slots: - void ScrollBarMoved(); + void scroll_bar_moved(); }; } -#endif // VIEWERSIZER_H +#endif // OAK_VIEWERSIZER_H diff --git a/app/widget/viewer/viewertexteditor.cpp b/app/widget/viewer/viewertexteditor.cpp index e58cf5b63..fb34290d8 100644 --- a/app/widget/viewer/viewertexteditor.cpp +++ b/app/widget/viewer/viewertexteditor.cpp @@ -58,9 +58,9 @@ ViewerTextEditor::ViewerTextEditor(double scale, QWidget *parent) setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); connect(horizontalScrollBar(), &QScrollBar::rangeChanged, this, - &ViewerTextEditor::LockScrollBarMaximumToZero); + &ViewerTextEditor::lock_scroll_bar_maximum_to_zero); connect(verticalScrollBar(), &QScrollBar::rangeChanged, this, - &ViewerTextEditor::LockScrollBarMaximumToZero); + &ViewerTextEditor::lock_scroll_bar_maximum_to_zero); // Force DPI to the same one that we're using in the actual render dpi_force_ = QImage(1, 1, QImage::Format_RGBA8888_Premultiplied); @@ -71,51 +71,51 @@ ViewerTextEditor::ViewerTextEditor(double scale, QWidget *parent) document()->documentLayout()->setPaintDevice(&dpi_force_); connect(this, &QTextEdit::currentCharFormatChanged, this, - &ViewerTextEditor::FormatChanged); + &ViewerTextEditor::format_changed); connect(document(), &QTextDocument::contentsChanged, this, - &ViewerTextEditor::DocumentChanged, Qt::QueuedConnection); + &ViewerTextEditor::document_changed, Qt::QueuedConnection); setAcceptRichText(false); } -void ViewerTextEditor::ConnectToolBar(ViewerTextEditorToolBar *toolbar) +void ViewerTextEditor::connect_tool_bar(ViewerTextEditorToolBar *toolbar) { - connect(toolbar, &ViewerTextEditorToolBar::FamilyChanged, this, - &ViewerTextEditor::SetFamily); - connect(toolbar, &ViewerTextEditorToolBar::SizeChanged, this, + connect(toolbar, &ViewerTextEditorToolBar::family_changed, this, + &ViewerTextEditor::set_family); + connect(toolbar, &ViewerTextEditorToolBar::size_changed, this, &ViewerTextEditor::setFontPointSize); - connect(toolbar, &ViewerTextEditorToolBar::StyleChanged, this, - &ViewerTextEditor::SetStyle); - connect(toolbar, &ViewerTextEditorToolBar::UnderlineChanged, this, + connect(toolbar, &ViewerTextEditorToolBar::style_changed, this, + &ViewerTextEditor::set_style); + connect(toolbar, &ViewerTextEditorToolBar::underline_changed, this, &ViewerTextEditor::setFontUnderline); - connect(toolbar, &ViewerTextEditorToolBar::StrikethroughChanged, this, - &ViewerTextEditor::SetFontStrikethrough); - connect(toolbar, &ViewerTextEditorToolBar::ColorChanged, this, + connect(toolbar, &ViewerTextEditorToolBar::strikethrough_changed, this, + &ViewerTextEditor::set_font_strikethrough); + connect(toolbar, &ViewerTextEditorToolBar::color_changed, this, &ViewerTextEditor::setTextColor); - connect(toolbar, &ViewerTextEditorToolBar::SmallCapsChanged, this, - &ViewerTextEditor::SetSmallCaps); - connect(toolbar, &ViewerTextEditorToolBar::StretchChanged, this, - &ViewerTextEditor::SetFontStretch); - connect(toolbar, &ViewerTextEditorToolBar::KerningChanged, this, - &ViewerTextEditor::SetFontKerning); - connect(toolbar, &ViewerTextEditorToolBar::LineHeightChanged, this, - &ViewerTextEditor::SetLineHeight); - connect(toolbar, &ViewerTextEditorToolBar::AlignmentChanged, this, + connect(toolbar, &ViewerTextEditorToolBar::small_caps_changed, this, + &ViewerTextEditor::set_small_caps); + connect(toolbar, &ViewerTextEditorToolBar::stretch_changed, this, + &ViewerTextEditor::set_font_stretch); + connect(toolbar, &ViewerTextEditorToolBar::kerning_changed, this, + &ViewerTextEditor::set_font_kerning); + connect(toolbar, &ViewerTextEditorToolBar::line_height_changed, this, + &ViewerTextEditor::set_line_height); + connect(toolbar, &ViewerTextEditorToolBar::alignment_changed, this, [this](Qt::Alignment a) { this->setAlignment(a); // Ensure no buttons are checked that shouldn't be - static_cast(sender())->SetAlignment( + static_cast(sender())->set_alignment( a); }); - UpdateToolBar(toolbar, this->currentCharFormat(), + update_tool_bar(toolbar, this->currentCharFormat(), this->textCursor().blockFormat(), this->alignment()); toolbars_.append(toolbar); } -void ViewerTextEditor::Paint(QPainter *p, Qt::Alignment valign) +void ViewerTextEditor::paint(QPainter *p, Qt::Alignment valign) { QAbstractTextDocumentLayout::PaintContext ctx; @@ -171,7 +171,7 @@ void ViewerTextEditor::paintEvent(QPaintEvent *e) // Disable painting } -void ViewerTextEditor::UpdateToolBar(ViewerTextEditorToolBar *toolbar, +void ViewerTextEditor::update_tool_bar(ViewerTextEditorToolBar *toolbar, const QTextCharFormat &f, const QTextBlockFormat &b, Qt::Alignment alignment) @@ -201,25 +201,25 @@ void ViewerTextEditor::UpdateToolBar(ViewerTextEditorToolBar *toolbar, } } - toolbar->SetFontFamily(family); - toolbar->SetFontSize(f.fontPointSize()); - toolbar->SetStyle(style); - toolbar->SetUnderline(f.fontUnderline()); - toolbar->SetStrikethrough(f.fontStrikeOut()); - toolbar->SetAlignment(alignment); - toolbar->SetColor(f.foreground().color()); - toolbar->SetSmallCaps(f.fontCapitalization() == QFont::SmallCaps); - toolbar->SetStretch(f.fontStretch() == 0 ? 100 : f.fontStretch()); - toolbar->SetKerning(f.fontLetterSpacing() == 0.0 ? 100 : + toolbar->set_font_family(family); + toolbar->set_font_size(f.fontPointSize()); + toolbar->set_style(style); + toolbar->set_underline(f.fontUnderline()); + toolbar->set_strikethrough(f.fontStrikeOut()); + toolbar->set_alignment(alignment); + toolbar->set_color(f.foreground().color()); + toolbar->set_small_caps(f.fontCapitalization() == QFont::SmallCaps); + toolbar->set_stretch(f.fontStretch() == 0 ? 100 : f.fontStretch()); + toolbar->set_kerning(f.fontLetterSpacing() == 0.0 ? 100 : f.fontLetterSpacing()); - toolbar->SetLineHeight(b.lineHeight() == 0.0 ? 100 : b.lineHeight()); + toolbar->set_line_height(b.lineHeight() == 0.0 ? 100 : b.lineHeight()); } -void ViewerTextEditor::FormatChanged(const QTextCharFormat &f) +void ViewerTextEditor::format_changed(const QTextCharFormat &f) { if (!block_update_toolbar_signal_) { foreach (ViewerTextEditorToolBar *toolbar, toolbars_) { - UpdateToolBar(toolbar, f, textCursor().blockFormat(), + update_tool_bar(toolbar, f, textCursor().blockFormat(), this->alignment()); } } @@ -230,7 +230,7 @@ void ViewerTextEditor::FormatChanged(const QTextCharFormat &f) } } -void ViewerTextEditor::SetFamily(const QString &s) +void ViewerTextEditor::set_family(const QString &s) { ViewerTextEditorToolBar *toolbar = static_cast(sender()); @@ -238,52 +238,52 @@ void ViewerTextEditor::SetFamily(const QString &s) QTextCharFormat f; f.setFontFamilies({ s }); - ApplyStyle(&f, s, toolbar->GetFontStyleName()); + apply_style(&f, s, toolbar->get_font_style_name()); - MergeCharFormat(f); + merge_char_format(f); } -void ViewerTextEditor::SetStyle(const QString &s) +void ViewerTextEditor::set_style(const QString &s) { ViewerTextEditorToolBar *toolbar = static_cast(sender()); QTextCharFormat f; - ApplyStyle(&f, toolbar->GetFontFamily(), s); + apply_style(&f, toolbar->get_font_family(), s); - MergeCharFormat(f); + merge_char_format(f); } -void ViewerTextEditor::SetFontStrikethrough(bool e) +void ViewerTextEditor::set_font_strikethrough(bool e) { QTextCharFormat f; f.setFontStrikeOut(e); - MergeCharFormat(f); + merge_char_format(f); } -void ViewerTextEditor::SetSmallCaps(bool e) +void ViewerTextEditor::set_small_caps(bool e) { QTextCharFormat f; f.setFontCapitalization(e ? QFont::SmallCaps : QFont::MixedCase); - MergeCharFormat(f); + merge_char_format(f); } -void ViewerTextEditor::SetFontStretch(int i) +void ViewerTextEditor::set_font_stretch(int i) { QTextCharFormat f; f.setFontStretch(i); - MergeCharFormat(f); + merge_char_format(f); } -void ViewerTextEditor::SetFontKerning(qreal i) +void ViewerTextEditor::set_font_kerning(qreal i) { QTextCharFormat f; f.setFontLetterSpacing(i); - MergeCharFormat(f); + merge_char_format(f); } -void ViewerTextEditor::MergeCharFormat(const QTextCharFormat &fmt) +void ViewerTextEditor::merge_char_format(const QTextCharFormat &fmt) { // mergeCurrentCharFormat throws a currentCharFormatChanged signal that updates the toolbar, // this can be undesirable if the user is currently typing a font @@ -293,7 +293,7 @@ void ViewerTextEditor::MergeCharFormat(const QTextCharFormat &fmt) block_update_toolbar_signal_ = false; } -void ViewerTextEditor::ApplyStyle(QTextCharFormat *format, +void ViewerTextEditor::apply_style(QTextCharFormat *format, const QString &family, const QString &style) { // NOTE: Windows appears to require setting weight and italic manually, while macOS and Linux are @@ -304,19 +304,19 @@ void ViewerTextEditor::ApplyStyle(QTextCharFormat *format, format->setFontStyleName(style); } -void ViewerTextEditor::SetLineHeight(qreal i) +void ViewerTextEditor::set_line_height(qreal i) { QTextBlockFormat f = this->textCursor().blockFormat(); f.setLineHeight(i, QTextBlockFormat::ProportionalHeight); this->textCursor().setBlockFormat(f); } -void ViewerTextEditor::LockScrollBarMaximumToZero() +void ViewerTextEditor::lock_scroll_bar_maximum_to_zero() { static_cast(sender())->setMaximum(0); } -void ViewerTextEditor::DocumentChanged() +void ViewerTextEditor::document_changed() { if (document()->blockCount() == 1 && document()->firstBlock().text().isEmpty()) { @@ -363,7 +363,7 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent) QVBoxLayout *outer_layout = new QVBoxLayout(this); const int advanced_slider_width = - QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("9999.9%")); + QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("9999.9%")); { QHBoxLayout *row_layout = new QHBoxLayout(); @@ -373,40 +373,40 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent) font_combo_ = new QFontComboBox(); connect( font_combo_, &QFontComboBox::currentTextChanged, this, - &ViewerTextEditorToolBar::UpdateFontStyleListAndEmitFamilyChanged); + &ViewerTextEditorToolBar::update_font_style_list_and_emit_family_changed); row_layout->addWidget(font_combo_); font_sz_slider_ = new FloatSlider(); - font_sz_slider_->SetMinimum(0.1); - font_sz_slider_->SetMaximum(9999.9); - font_sz_slider_->SetDecimalPlaces(1); - font_sz_slider_->SetAlignment(Qt::AlignCenter); + font_sz_slider_->set_minimum(0.1); + font_sz_slider_->set_maximum(9999.9); + font_sz_slider_->set_decimal_places(1); + font_sz_slider_->set_alignment(Qt::AlignCenter); font_sz_slider_->setFixedWidth(advanced_slider_width); - connect(font_sz_slider_, &FloatSlider::ValueChanged, this, - &ViewerTextEditorToolBar::SizeChanged); - font_sz_slider_->SetLadderElementCount(2); + connect(font_sz_slider_, &FloatSlider::value_changed, this, + &ViewerTextEditorToolBar::size_changed); + font_sz_slider_->set_ladder_element_count(2); row_layout->addWidget(font_sz_slider_); style_combo_ = new QComboBox(); connect(style_combo_, &QComboBox::currentTextChanged, this, - &ViewerTextEditorToolBar::StyleChanged); + &ViewerTextEditorToolBar::style_changed); row_layout->addWidget(style_combo_); underline_btn_ = new QPushButton(); connect(underline_btn_, &QPushButton::clicked, this, - &ViewerTextEditorToolBar::UnderlineChanged); + &ViewerTextEditorToolBar::underline_changed); underline_btn_->setCheckable(true); - underline_btn_->setIcon(icon::TextUnderline); + underline_btn_->setIcon(icon::text_underline); row_layout->addWidget(underline_btn_); strikethrough_btn_ = new QPushButton(); connect(strikethrough_btn_, &QPushButton::clicked, this, - &ViewerTextEditorToolBar::StrikethroughChanged); + &ViewerTextEditorToolBar::strikethrough_changed); strikethrough_btn_->setCheckable(true); - strikethrough_btn_->setIcon(icon::TextStrikethrough); + strikethrough_btn_->setIcon(icon::text_strikethrough); row_layout->addWidget(strikethrough_btn_); - AddSpacer(row_layout); + add_spacer(row_layout); color_btn_ = new QPushButton(); color_btn_->setAutoFillBackground(true); @@ -416,8 +416,8 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent) QColorDialog cd(c, this); if (cd.exec() == QDialog::Accepted) { c = cd.selectedColor(); - SetColor(c); - emit ColorChanged(c); + set_color(c); + emit color_changed(c); } }); row_layout->addWidget(color_btn_); @@ -432,102 +432,102 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent) align_left_btn_ = new QPushButton(); align_left_btn_->setCheckable(true); - align_left_btn_->setIcon(icon::TextAlignLeft); + align_left_btn_->setIcon(icon::text_align_left); connect(align_left_btn_, &QPushButton::clicked, this, - [this] { emit AlignmentChanged(Qt::AlignLeft); }); + [this] { emit alignment_changed(Qt::AlignLeft); }); row_layout->addWidget(align_left_btn_); align_center_btn_ = new QPushButton(); align_center_btn_->setCheckable(true); - align_center_btn_->setIcon(icon::TextAlignCenter); + align_center_btn_->setIcon(icon::text_align_center); connect(align_center_btn_, &QPushButton::clicked, this, - [this] { emit AlignmentChanged(Qt::AlignHCenter); }); + [this] { emit alignment_changed(Qt::AlignHCenter); }); row_layout->addWidget(align_center_btn_); align_right_btn_ = new QPushButton(); align_right_btn_->setCheckable(true); - align_right_btn_->setIcon(icon::TextAlignRight); + align_right_btn_->setIcon(icon::text_align_right); connect(align_right_btn_, &QPushButton::clicked, this, - [this] { emit AlignmentChanged(Qt::AlignRight); }); + [this] { emit alignment_changed(Qt::AlignRight); }); row_layout->addWidget(align_right_btn_); align_justify_btn_ = new QPushButton(); align_justify_btn_->setCheckable(true); - align_justify_btn_->setIcon(icon::TextAlignJustify); + align_justify_btn_->setIcon(icon::text_align_justify); connect(align_justify_btn_, &QPushButton::clicked, this, - [this] { emit AlignmentChanged(Qt::AlignJustify); }); + [this] { emit alignment_changed(Qt::AlignJustify); }); row_layout->addWidget(align_justify_btn_); - AddSpacer(row_layout); + add_spacer(row_layout); align_top_btn_ = new QPushButton(); align_top_btn_->setCheckable(true); - align_top_btn_->setIcon(icon::TextAlignTop); + align_top_btn_->setIcon(icon::text_align_top); connect(align_top_btn_, &QPushButton::clicked, this, - [this] { emit VerticalAlignmentChanged(Qt::AlignTop); }); + [this] { emit vertical_alignment_changed(Qt::AlignTop); }); row_layout->addWidget(align_top_btn_); align_middle_btn_ = new QPushButton(); align_middle_btn_->setCheckable(true); - align_middle_btn_->setIcon(icon::TextAlignMiddle); + align_middle_btn_->setIcon(icon::text_align_middle); connect(align_middle_btn_, &QPushButton::clicked, this, - [this] { emit VerticalAlignmentChanged(Qt::AlignVCenter); }); + [this] { emit vertical_alignment_changed(Qt::AlignVCenter); }); row_layout->addWidget(align_middle_btn_); align_bottom_btn_ = new QPushButton(); align_bottom_btn_->setCheckable(true); - align_bottom_btn_->setIcon(icon::TextAlignBottom); + align_bottom_btn_->setIcon(icon::text_align_bottom); connect(align_bottom_btn_, &QPushButton::clicked, this, - [this] { emit VerticalAlignmentChanged(Qt::AlignBottom); }); + [this] { emit vertical_alignment_changed(Qt::AlignBottom); }); row_layout->addWidget(align_bottom_btn_); - AddSpacer(row_layout); + add_spacer(row_layout); small_caps_btn_ = new QPushButton(); - small_caps_btn_->setIcon(icon::TextSmallCaps); + small_caps_btn_->setIcon(icon::text_small_caps); small_caps_btn_->setCheckable(true); connect(small_caps_btn_, &QPushButton::clicked, this, - &ViewerTextEditorToolBar::SmallCapsChanged); + &ViewerTextEditorToolBar::small_caps_changed); row_layout->addWidget(small_caps_btn_); - AddSpacer(row_layout); + add_spacer(row_layout); row_layout->addWidget( new QLabel(tr("Stretch: "))); // FIXME: Procure icon stretch_slider_ = new IntegerSlider(); - stretch_slider_->SetMinimum(0); + stretch_slider_->set_minimum(0); stretch_slider_->SetDefaultValue(100); stretch_slider_->setFixedWidth(advanced_slider_width); - stretch_slider_->SetFormat(tr("%1%")); - connect(stretch_slider_, &IntegerSlider::ValueChanged, this, - &ViewerTextEditorToolBar::StretchChanged); + stretch_slider_->set_format(tr("%1%")); + connect(stretch_slider_, &IntegerSlider::value_changed, this, + &ViewerTextEditorToolBar::stretch_changed); row_layout->addWidget(stretch_slider_); row_layout->addWidget( new QLabel(tr("Kerning: "))); // FIXME: Procure icon kerning_slider_ = new FloatSlider(); - kerning_slider_->SetMinimum(0); + kerning_slider_->set_minimum(0); kerning_slider_->SetDefaultValue(100); - kerning_slider_->SetDecimalPlaces(1); + kerning_slider_->set_decimal_places(1); kerning_slider_->setFixedWidth(advanced_slider_width); - kerning_slider_->SetFormat(tr("%1%")); - connect(kerning_slider_, &FloatSlider::ValueChanged, this, - &ViewerTextEditorToolBar::KerningChanged); + kerning_slider_->set_format(tr("%1%")); + connect(kerning_slider_, &FloatSlider::value_changed, this, + &ViewerTextEditorToolBar::kerning_changed); row_layout->addWidget(kerning_slider_); row_layout->addWidget( new QLabel(tr("Line Height: "))); // FIXME: Procure icon line_height_slider_ = new FloatSlider(); - line_height_slider_->SetMinimum(0); + line_height_slider_->set_minimum(0); line_height_slider_->SetDefaultValue(100); - line_height_slider_->SetDecimalPlaces(1); + line_height_slider_->set_decimal_places(1); line_height_slider_->setFixedWidth(advanced_slider_width); - line_height_slider_->SetFormat(tr("%1%")); - connect(line_height_slider_, &FloatSlider::ValueChanged, this, - &ViewerTextEditorToolBar::LineHeightChanged); + line_height_slider_->set_format(tr("%1%")); + connect(line_height_slider_, &FloatSlider::value_changed, this, + &ViewerTextEditorToolBar::line_height_changed); row_layout->addWidget(line_height_slider_); row_layout->addStretch(); @@ -538,7 +538,7 @@ ViewerTextEditorToolBar::ViewerTextEditorToolBar(QWidget *parent) resize(sizeHint()); } -void ViewerTextEditorToolBar::SetAlignment(Qt::Alignment a) +void ViewerTextEditorToolBar::set_alignment(Qt::Alignment a) { align_left_btn_->setChecked(a == Qt::AlignLeft); align_center_btn_->setChecked(a == Qt::AlignHCenter); @@ -546,14 +546,14 @@ void ViewerTextEditorToolBar::SetAlignment(Qt::Alignment a) align_justify_btn_->setChecked(a == Qt::AlignJustify); } -void ViewerTextEditorToolBar::SetVerticalAlignment(Qt::Alignment a) +void ViewerTextEditorToolBar::set_vertical_alignment(Qt::Alignment a) { align_top_btn_->setChecked(a == Qt::AlignTop); align_middle_btn_->setChecked(a == Qt::AlignVCenter); align_bottom_btn_->setChecked(a == Qt::AlignBottom); } -void ViewerTextEditorToolBar::SetColor(const QColor &c) +void ViewerTextEditorToolBar::set_color(const QColor &c) { color_btn_->setProperty("color", c); color_btn_->setStyleSheet( @@ -568,27 +568,27 @@ void ViewerTextEditorToolBar::closeEvent(QCloseEvent *event) void ViewerTextEditorToolBar::paintEvent(QPaintEvent *event) { if (!painted_) { - emit FirstPaint(); + emit first_paint(); painted_ = true; } QWidget::paintEvent(event); } -void ViewerTextEditorToolBar::AddSpacer(QLayout *l) +void ViewerTextEditorToolBar::add_spacer(QLayout *l) { const int spacing = this->fontMetrics().height() / 4; QWidget *a = new QWidget(); a->setFixedSize(spacing, 1); l->addWidget(a); - l->addWidget(QtUtils::CreateVerticalLine()); + l->addWidget(QtUtils::create_vertical_line()); QWidget *b = new QWidget(); b->setFixedSize(spacing, 1); l->addWidget(b); } -void ViewerTextEditorToolBar::UpdateFontStyleList(const QString &family) +void ViewerTextEditorToolBar::update_font_style_list(const QString &family) { QString temp = style_combo_->currentText(); @@ -602,12 +602,12 @@ void ViewerTextEditorToolBar::UpdateFontStyleList(const QString &family) style_combo_->blockSignals(false); } -void ViewerTextEditorToolBar::UpdateFontStyleListAndEmitFamilyChanged( +void ViewerTextEditorToolBar::update_font_style_list_and_emit_family_changed( const QString &family) { // Ensures correct ordering of commands - UpdateFontStyleList(family); - emit FamilyChanged(family); + update_font_style_list(family); + emit family_changed(family); } void ViewerTextEditorToolBar::mousePressEvent(QMouseEvent *event) diff --git a/app/widget/viewer/viewertexteditor.h b/app/widget/viewer/viewertexteditor.h index a1de854ab..6b853cbe7 100644 --- a/app/widget/viewer/viewertexteditor.h +++ b/app/widget/viewer/viewertexteditor.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWERTEXTEDITOR_H -#define VIEWERTEXTEDITOR_H +#ifndef OAK_VIEWERTEXTEDITOR_H +#define OAK_VIEWERTEXTEDITOR_H #include #include @@ -39,79 +39,79 @@ class ViewerTextEditorToolBar : public QWidget { public: ViewerTextEditorToolBar(QWidget *parent = nullptr); - QString GetFontFamily() const + QString get_font_family() const { return font_combo_->currentText(); } - QString GetFontStyleName() const + QString get_font_style_name() const { return style_combo_->currentText(); } public slots: - void SetFontFamily(QString s) + void set_font_family(QString s) { font_combo_->blockSignals(true); font_combo_->setCurrentFont(s); - UpdateFontStyleList(s); + update_font_style_list(s); font_combo_->blockSignals(false); } - void SetStyle(QString style) + void set_style(QString style) { style_combo_->blockSignals(true); style_combo_->setCurrentText(style); style_combo_->blockSignals(false); } - void SetFontSize(double d) + void set_font_size(double d) { - font_sz_slider_->SetValue(d); + font_sz_slider_->set_value(d); } - void SetUnderline(bool e) + void set_underline(bool e) { underline_btn_->setChecked(e); } - void SetStrikethrough(bool e) + void set_strikethrough(bool e) { strikethrough_btn_->setChecked(e); } - void SetAlignment(Qt::Alignment a); - void SetVerticalAlignment(Qt::Alignment a); - void SetColor(const QColor &c); - void SetSmallCaps(bool e) + void set_alignment(Qt::Alignment a); + void set_vertical_alignment(Qt::Alignment a); + void set_color(const QColor &c); + void set_small_caps(bool e) { small_caps_btn_->setChecked(e); } - void SetStretch(int i) + void set_stretch(int i) { - stretch_slider_->SetValue(i); + stretch_slider_->set_value(i); } - void SetKerning(qreal i) + void set_kerning(qreal i) { - kerning_slider_->SetValue(i); + kerning_slider_->set_value(i); } - void SetLineHeight(qreal i) + void set_line_height(qreal i) { - line_height_slider_->SetValue(i); + line_height_slider_->set_value(i); } signals: - void FamilyChanged(const QString &s); - void SizeChanged(double d); - void StyleChanged(const QString &s); - void UnderlineChanged(bool e); - void StrikethroughChanged(bool e); - void AlignmentChanged(Qt::Alignment alignment); - void VerticalAlignmentChanged(Qt::Alignment alignment); - void ColorChanged(const QColor &c); - void SmallCapsChanged(bool e); - void StretchChanged(int i); - void KerningChanged(qreal i); - void LineHeightChanged(qreal i); + void family_changed(const QString &s); + void size_changed(double d); + void style_changed(const QString &s); + void underline_changed(bool e); + void strikethrough_changed(bool e); + void alignment_changed(Qt::Alignment alignment); + void vertical_alignment_changed(Qt::Alignment alignment); + void color_changed(const QColor &c); + void small_caps_changed(bool e); + void stretch_changed(int i); + void kerning_changed(qreal i); + void line_height_changed(qreal i); - void FirstPaint(); + void first_paint(); protected: virtual void mousePressEvent(QMouseEvent *event) override; @@ -125,7 +125,7 @@ protected: virtual void paintEvent(QPaintEvent *event) override; private: - void AddSpacer(QLayout *l); + void add_spacer(QLayout *l); QPoint drag_anchor_; @@ -159,9 +159,9 @@ private: bool drag_enabled_; private slots: - void UpdateFontStyleList(const QString &family); + void update_font_style_list(const QString &family); - void UpdateFontStyleListAndEmitFamilyChanged(const QString &family); + void update_font_style_list_and_emit_family_changed(const QString &family); }; class ViewerTextEditor : public QTextEdit { @@ -169,9 +169,9 @@ class ViewerTextEditor : public QTextEdit { public: ViewerTextEditor(double scale, QWidget *parent = nullptr); - void ConnectToolBar(ViewerTextEditorToolBar *toolbar); + void connect_tool_bar(ViewerTextEditorToolBar *toolbar); - void Paint(QPainter *p, Qt::Alignment valign); + void paint(QPainter *p, Qt::Alignment valign); virtual void dragEnterEvent(QDragEnterEvent *e) override { @@ -194,14 +194,14 @@ protected: virtual void paintEvent(QPaintEvent *event) override; private: - static void UpdateToolBar(ViewerTextEditorToolBar *toolbar, + static void update_tool_bar(ViewerTextEditorToolBar *toolbar, const QTextCharFormat &f, const QTextBlockFormat &b, Qt::Alignment alignment); - void MergeCharFormat(const QTextCharFormat &fmt); + void merge_char_format(const QTextCharFormat &fmt); - void ApplyStyle(QTextCharFormat *format, const QString &family, + void apply_style(QTextCharFormat *format, const QString &family, const QString &style); QVector toolbars_; @@ -216,27 +216,27 @@ private: QTextCharFormat default_fmt_; private slots: - void FormatChanged(const QTextCharFormat &f); + void format_changed(const QTextCharFormat &f); - void SetFamily(const QString &s); + void set_family(const QString &s); - void SetStyle(const QString &s); + void set_style(const QString &s); - void SetFontStrikethrough(bool e); + void set_font_strikethrough(bool e); - void SetSmallCaps(bool e); + void set_small_caps(bool e); - void SetFontStretch(int i); + void set_font_stretch(int i); - void SetFontKerning(qreal i); + void set_font_kerning(qreal i); - void SetLineHeight(qreal i); + void set_line_height(qreal i); - void LockScrollBarMaximumToZero(); + void lock_scroll_bar_maximum_to_zero(); - void DocumentChanged(); + void document_changed(); }; } -#endif // VIEWERTEXTEDITOR_H +#endif // OAK_VIEWERTEXTEDITOR_H diff --git a/app/widget/viewer/viewerwindow.cpp b/app/widget/viewer/viewerwindow.cpp index 49eb583d6..080de1189 100644 --- a/app/widget/viewer/viewerwindow.cpp +++ b/app/widget/viewer/viewerwindow.cpp @@ -44,28 +44,28 @@ ViewerDisplayWidget *ViewerWindow::display_widget() const return display_widget_; } -void ViewerWindow::SetVideoParams(const VideoParams ¶ms) +void ViewerWindow::set_video_params(const VideoParams ¶ms) { width_ = params.width(); height_ = params.height(); pixel_aspect_ = params.pixel_aspect_ratio(); - UpdateMatrix(); + update_matrix(); } -void ViewerWindow::SetResolution(int width, int height) +void ViewerWindow::set_resolution(int width, int height) { width_ = width; height_ = height; - UpdateMatrix(); + update_matrix(); } -void ViewerWindow::SetPixelAspectRatio(const rational &pixel_aspect) +void ViewerWindow::set_pixel_aspect_ratio(const Rational &pixel_aspect) { pixel_aspect_ = pixel_aspect; - UpdateMatrix(); + update_matrix(); } void ViewerWindow::keyPressEvent(QKeyEvent *e) @@ -84,13 +84,13 @@ void ViewerWindow::closeEvent(QCloseEvent *e) deleteLater(); } -void ViewerWindow::UpdateMatrix() +void ViewerWindow::update_matrix() { // Set GL widget matrix to maintain this texture's aspect ratio double window_ar = static_cast(this->width()) / static_cast(this->height()); double image_ar = static_cast(width_) / - static_cast(height_) * pixel_aspect_.toDouble(); + static_cast(height_) * pixel_aspect_.to_double(); QMatrix4x4 mat; @@ -102,7 +102,7 @@ void ViewerWindow::UpdateMatrix() mat.scale(1.0f, window_ar / image_ar, 1.0f); } - display_widget_->SetMatrixZoom(mat); + display_widget_->set_matrix_zoom(mat); } } diff --git a/app/widget/viewer/viewerwindow.h b/app/widget/viewer/viewerwindow.h index 9c77c8b69..512e68033 100644 --- a/app/widget/viewer/viewerwindow.h +++ b/app/widget/viewer/viewerwindow.h @@ -19,8 +19,8 @@ ***/ -#ifndef VIEWERWINDOW_H -#define VIEWERWINDOW_H +#ifndef OAK_VIEWERWINDOW_H +#define OAK_VIEWERWINDOW_H #include @@ -41,17 +41,17 @@ public: * Equivalent to calling SetResolution and SetPixelAspectRatio, just slightly faster since we * only calculate the matrix once rather than twice. */ - void SetVideoParams(const VideoParams ¶ms); + void set_video_params(const VideoParams ¶ms); /** * @brief Used to adjust resulting picture to be the right aspect ratio */ - void SetResolution(int width, int height); + void set_resolution(int width, int height); /** * @brief Used to adjust resulting picture to be the right aspect ratio */ - void SetPixelAspectRatio(const rational &pixel_aspect); + void set_pixel_aspect_ratio(const Rational &pixel_aspect); protected: virtual void keyPressEvent(QKeyEvent *e) override; @@ -59,7 +59,7 @@ protected: virtual void closeEvent(QCloseEvent *e) override; private: - void UpdateMatrix(); + void update_matrix(); int width_; @@ -67,9 +67,9 @@ private: ViewerDisplayWidget *display_widget_; - rational pixel_aspect_; + Rational pixel_aspect_; }; } -#endif // VIEWERWINDOW_H +#endif // OAK_VIEWERWINDOW_H diff --git a/app/window/mainwindow/mainmenu.cpp b/app/window/mainwindow/mainmenu.cpp index 3de2d1173..51dcf10ff 100644 --- a/app/window/mainwindow/mainmenu.cpp +++ b/app/window/mainwindow/mainmenu.cpp @@ -48,36 +48,36 @@ MainMenu::MainMenu(MainWindow *parent) // // FILE MENU // - file_menu_ = new Menu(this, this, &MainMenu::FileMenuAboutToShow); + file_menu_ = new Menu(this, this, &MainMenu::file_menu_about_to_show); file_new_menu_ = new Menu(file_menu_); - MenuShared::instance()->AddItemsForNewMenu(file_new_menu_); - file_open_item_ = file_menu_->AddItem("openproj", Core::instance(), - &Core::OpenProject, tr("Ctrl+O")); + MenuShared::instance()->add_items_for_new_menu(file_new_menu_); + file_open_item_ = file_menu_->add_item("openproj", Core::instance(), + &Core::open_project, tr("Ctrl+O")); file_open_recent_menu_ = new Menu(file_menu_); file_open_recent_separator_ = file_open_recent_menu_->addSeparator(); - file_open_recent_clear_item_ = file_open_recent_menu_->AddItem( - "clearopenrecent", Core::instance(), &Core::ClearOpenRecentList); - file_save_item_ = file_menu_->AddItem("saveproj", Core::instance(), - &Core::SaveProject, tr("Ctrl+S")); - file_save_as_item_ = file_menu_->AddItem("saveprojas", Core::instance(), - &Core::SaveProjectAs, + file_open_recent_clear_item_ = file_open_recent_menu_->add_item( + "clearopenrecent", Core::instance(), &Core::clear_open_recent_list); + file_save_item_ = file_menu_->add_item("saveproj", Core::instance(), + &Core::save_project, tr("Ctrl+S")); + file_save_as_item_ = file_menu_->add_item("saveprojas", Core::instance(), + &Core::save_project_as, tr("Ctrl+Shift+S")); file_menu_->addSeparator(); - file_revert_item_ = file_menu_->AddItem("revert", Core::instance(), - &Core::RevertProject, tr("F12")); + file_revert_item_ = file_menu_->add_item("revert", Core::instance(), + &Core::revert_project, tr("F12")); file_menu_->addSeparator(); - file_import_item_ = file_menu_->AddItem( - "import", Core::instance(), &Core::DialogImportShow, tr("Ctrl+I")); + file_import_item_ = file_menu_->add_item( + "import", Core::instance(), &Core::dialog_import_show, tr("Ctrl+I")); file_menu_->addSeparator(); file_export_menu_ = new Menu(file_menu_); - file_export_media_item_ = file_export_menu_->AddItem( - "export", Core::instance(), &Core::DialogExportShow, tr("Ctrl+M")); + file_export_media_item_ = file_export_menu_->add_item( + "export", Core::instance(), &Core::dialog_export_show, tr("Ctrl+M")); file_menu_->addSeparator(); - file_project_properties_item_ = file_menu_->AddItem( + file_project_properties_item_ = file_menu_->add_item( "projectproperties", Core::instance(), - &Core::DialogProjectPropertiesShow, tr("Shift+F10")); + &Core::dialog_project_properties_show, tr("Shift+F10")); file_menu_->addSeparator(); - file_exit_item_ = file_menu_->AddItem("exit", parent, &MainWindow::close); + file_exit_item_ = file_menu_->add_item("exit", parent, &MainWindow::close); // // EDIT MENU @@ -85,25 +85,25 @@ MainMenu::MainMenu(MainWindow *parent) edit_menu_ = new Menu(this); connect(edit_menu_, &Menu::aboutToShow, this, - &MainMenu::EditMenuAboutToShow); + &MainMenu::edit_menu_about_to_show); connect(edit_menu_, &Menu::aboutToHide, this, - &MainMenu::EditMenuAboutToHide); + &MainMenu::edit_menu_about_to_hide); edit_undo_item_ = Core::instance()->undo_stack()->GetUndoAction(); - Menu::ConformItem(edit_undo_item_, "undo", tr("Ctrl+Z")); + Menu::conform_item(edit_undo_item_, "undo", tr("Ctrl+Z")); edit_menu_->addAction(edit_undo_item_); edit_redo_item_ = Core::instance()->undo_stack()->GetRedoAction(); - Menu::ConformItem(edit_redo_item_, "redo", tr("Ctrl+Shift+Z")); + Menu::conform_item(edit_redo_item_, "redo", tr("Ctrl+Shift+Z")); edit_menu_->addAction(edit_redo_item_); edit_menu_->addSeparator(); - MenuShared::instance()->AddItemsForEditMenu(edit_menu_, true); + MenuShared::instance()->add_items_for_edit_menu(edit_menu_, true); { // Create "alternate delete" action so we can pick up backspace as well as delete while still // keeping them configurable edit_delete2_item_ = new QAction(); - Menu::ConformItem(edit_delete2_item_, "delete2", MenuShared::instance(), - &MenuShared::DeleteSelectedTriggered, + Menu::conform_item(edit_delete2_item_, "delete2", MenuShared::instance(), + &MenuShared::delete_selected_triggered, tr("Backspace")); auto actions = edit_menu_->actions(); edit_menu_->insertAction( @@ -113,136 +113,136 @@ MainMenu::MainMenu(MainWindow *parent) edit_delete2_item_); } edit_menu_->addSeparator(); - edit_select_all_item_ = edit_menu_->AddItem( - "selectall", this, &MainMenu::SelectAllTriggered, tr("Ctrl+A")); - edit_deselect_all_item_ = edit_menu_->AddItem( - "deselectall", this, &MainMenu::DeselectAllTriggered, + edit_select_all_item_ = edit_menu_->add_item( + "selectall", this, &MainMenu::select_all_triggered, tr("Ctrl+A")); + edit_deselect_all_item_ = edit_menu_->add_item( + "deselectall", this, &MainMenu::deselect_all_triggered, tr("Ctrl+Shift+A")); edit_menu_->addSeparator(); - MenuShared::instance()->AddItemsForClipEditMenu(edit_menu_); + MenuShared::instance()->add_items_for_clip_edit_menu(edit_menu_); edit_menu_->addSeparator(); - edit_insert_item_ = edit_menu_->AddItem( - "insert", this, &MainMenu::InsertTriggered, tr(",")); - edit_overwrite_item_ = edit_menu_->AddItem( - "overwrite", this, &MainMenu::OverwriteTriggered, tr(".")); + edit_insert_item_ = edit_menu_->add_item( + "insert", this, &MainMenu::insert_triggered, tr(",")); + edit_overwrite_item_ = edit_menu_->add_item( + "overwrite", this, &MainMenu::overwrite_triggered, tr(".")); edit_menu_->addSeparator(); - edit_ripple_to_in_item_ = edit_menu_->AddItem( - "rippletoin", this, &MainMenu::RippleToInTriggered, tr("Q")); - edit_ripple_to_out_item_ = edit_menu_->AddItem( - "rippletoout", this, &MainMenu::RippleToOutTriggered, tr("W")); - edit_edit_to_in_item_ = edit_menu_->AddItem( - "edittoin", this, &MainMenu::EditToInTriggered, tr("Ctrl+Alt+Q")); - edit_edit_to_out_item_ = edit_menu_->AddItem( - "edittoout", this, &MainMenu::EditToOutTriggered, tr("Ctrl+Alt+W")); + edit_ripple_to_in_item_ = edit_menu_->add_item( + "rippletoin", this, &MainMenu::ripple_to_in_triggered, tr("Q")); + edit_ripple_to_out_item_ = edit_menu_->add_item( + "rippletoout", this, &MainMenu::ripple_to_out_triggered, tr("W")); + edit_edit_to_in_item_ = edit_menu_->add_item( + "edittoin", this, &MainMenu::edit_to_in_triggered, tr("Ctrl+Alt+Q")); + edit_edit_to_out_item_ = edit_menu_->add_item( + "edittoout", this, &MainMenu::edit_to_out_triggered, tr("Ctrl+Alt+W")); edit_menu_->addSeparator(); - edit_nudge_left_item_ = edit_menu_->AddItem( - "nudgeleft", this, &MainMenu::NudgeLeftTriggered, tr("Alt+Left")); - edit_nudge_right_item_ = edit_menu_->AddItem( - "nudgeright", this, &MainMenu::NudgeRightTriggered, tr("Alt+Right")); + edit_nudge_left_item_ = edit_menu_->add_item( + "nudgeleft", this, &MainMenu::nudge_left_triggered, tr("Alt+Left")); + edit_nudge_right_item_ = edit_menu_->add_item( + "nudgeright", this, &MainMenu::nudge_right_triggered, tr("Alt+Right")); edit_move_in_to_playhead_item_ = - edit_menu_->AddItem("moveintoplayhead", this, - &MainMenu::MoveInToPlayheadTriggered, tr("[")); + edit_menu_->add_item("moveintoplayhead", this, + &MainMenu::move_in_to_playhead_triggered, tr("[")); edit_move_out_to_playhead_item_ = - edit_menu_->AddItem("moveouttoplayhead", this, - &MainMenu::MoveOutToPlayheadTriggered, tr("]")); + edit_menu_->add_item("moveouttoplayhead", this, + &MainMenu::move_out_to_playhead_triggered, tr("]")); edit_menu_->addSeparator(); - MenuShared::instance()->AddItemsForInOutMenu(edit_menu_); - edit_delete_inout_item_ = edit_menu_->AddItem( - "deleteinout", this, &MainMenu::DeleteInOutTriggered, tr(";")); + MenuShared::instance()->add_items_for_in_out_menu(edit_menu_); + edit_delete_inout_item_ = edit_menu_->add_item( + "deleteinout", this, &MainMenu::delete_in_out_triggered, tr(";")); edit_ripple_delete_inout_item_ = - edit_menu_->AddItem("rippledeleteinout", this, - &MainMenu::RippleDeleteInOutTriggered, tr("'")); + edit_menu_->add_item("rippledeleteinout", this, + &MainMenu::ripple_delete_in_out_triggered, tr("'")); edit_menu_->addSeparator(); - edit_set_marker_item_ = edit_menu_->AddItem( - "marker", this, &MainMenu::SetMarkerTriggered, tr("M")); + edit_set_marker_item_ = edit_menu_->add_item( + "marker", this, &MainMenu::set_marker_triggered, tr("M")); // // VIEW MENU // - view_menu_ = new Menu(this, this, &MainMenu::ViewMenuAboutToShow); - view_zoom_in_item_ = view_menu_->AddItem( - "zoomin", this, &MainMenu::ZoomInTriggered, tr("=")); - view_zoom_out_item_ = view_menu_->AddItem( - "zoomout", this, &MainMenu::ZoomOutTriggered, tr("-")); - view_increase_track_height_item_ = view_menu_->AddItem( - "vzoomin", this, &MainMenu::IncreaseTrackHeightTriggered, tr("Ctrl+=")); - view_decrease_track_height_item_ = view_menu_->AddItem( - "vzoomout", this, &MainMenu::DecreaseTrackHeightTriggered, + view_menu_ = new Menu(this, this, &MainMenu::view_menu_about_to_show); + view_zoom_in_item_ = view_menu_->add_item( + "zoomin", this, &MainMenu::zoom_in_triggered, tr("=")); + view_zoom_out_item_ = view_menu_->add_item( + "zoomout", this, &MainMenu::zoom_out_triggered, tr("-")); + view_increase_track_height_item_ = view_menu_->add_item( + "vzoomin", this, &MainMenu::increase_track_height_triggered, tr("Ctrl+=")); + view_decrease_track_height_item_ = view_menu_->add_item( + "vzoomout", this, &MainMenu::decrease_track_height_triggered, tr("Ctrl+-")); - view_show_all_item_ = view_menu_->AddItem( - "showall", this, &MainMenu::ToggleShowAllTriggered, tr("\\")); + view_show_all_item_ = view_menu_->add_item( + "showall", this, &MainMenu::toggle_show_all_triggered, tr("\\")); view_show_all_item_->setCheckable(true); view_menu_->addSeparator(); - view_full_screen_item_ = view_menu_->AddItem( - "fullscreen", parent, &MainWindow::SetFullscreen, tr("F11")); + view_full_screen_item_ = view_menu_->add_item( + "fullscreen", parent, &MainWindow::set_fullscreen, tr("F11")); view_full_screen_item_->setCheckable(true); - view_full_screen_viewer_item_ = view_menu_->AddItem( - "fullscreenviewer", this, &MainMenu::FullScreenViewerTriggered); + view_full_screen_viewer_item_ = view_menu_->add_item( + "fullscreenviewer", this, &MainMenu::full_screen_viewer_triggered); // // PLAYBACK MENU // - playback_menu_ = new Menu(this, this, &MainMenu::PlaybackMenuAboutToShow); - playback_gotostart_item_ = playback_menu_->AddItem( - "gotostart", this, &MainMenu::GoToStartTriggered, tr("Home")); - playback_prevframe_item_ = playback_menu_->AddItem( - "prevframe", this, &MainMenu::PrevFrameTriggered, tr("Left")); - playback_playpause_item_ = playback_menu_->AddItem( - "playpause", this, &MainMenu::PlayPauseTriggered, tr("Space")); - playback_playinout_item_ = playback_menu_->AddItem( - "playintoout", this, &MainMenu::PlayInToOutTriggered, + playback_menu_ = new Menu(this, this, &MainMenu::playback_menu_about_to_show); + playback_gotostart_item_ = playback_menu_->add_item( + "gotostart", this, &MainMenu::go_to_start_triggered, tr("Home")); + playback_prevframe_item_ = playback_menu_->add_item( + "prevframe", this, &MainMenu::prev_frame_triggered, tr("Left")); + playback_playpause_item_ = playback_menu_->add_item( + "playpause", this, &MainMenu::play_pause_triggered, tr("Space")); + playback_playinout_item_ = playback_menu_->add_item( + "playintoout", this, &MainMenu::play_in_to_out_triggered, tr("Shift+Space")); - playback_nextframe_item_ = playback_menu_->AddItem( - "nextframe", this, &MainMenu::NextFrameTriggered, tr("Right")); - playback_gotoend_item_ = playback_menu_->AddItem( - "gotoend", this, &MainMenu::GoToEndTriggered, tr("End")); + playback_nextframe_item_ = playback_menu_->add_item( + "nextframe", this, &MainMenu::next_frame_triggered, tr("Right")); + playback_gotoend_item_ = playback_menu_->add_item( + "gotoend", this, &MainMenu::go_to_end_triggered, tr("End")); playback_menu_->addSeparator(); - playback_prevcut_item_ = playback_menu_->AddItem( - "prevcut", this, &MainMenu::GoToPrevCutTriggered, tr("Up")); - playback_nextcut_item_ = playback_menu_->AddItem( - "nextcut", this, &MainMenu::GoToNextCutTriggered, tr("Down")); + playback_prevcut_item_ = playback_menu_->add_item( + "prevcut", this, &MainMenu::go_to_prev_cut_triggered, tr("Up")); + playback_nextcut_item_ = playback_menu_->add_item( + "nextcut", this, &MainMenu::go_to_next_cut_triggered, tr("Down")); playback_menu_->addSeparator(); - playback_gotoin_item_ = playback_menu_->AddItem( - "gotoin", this, &MainMenu::GoToInTriggered, tr("Shift+I")); - playback_gotoout_item_ = playback_menu_->AddItem( - "gotoout", this, &MainMenu::GoToOutTriggered, tr("Shift+O")); + playback_gotoin_item_ = playback_menu_->add_item( + "gotoin", this, &MainMenu::go_to_in_triggered, tr("Shift+I")); + playback_gotoout_item_ = playback_menu_->add_item( + "gotoout", this, &MainMenu::go_to_out_triggered, tr("Shift+O")); playback_menu_->addSeparator(); - playback_shuttleleft_item_ = playback_menu_->AddItem( - "decspeed", this, &MainMenu::ShuttleLeftTriggered, tr("J")); - playback_shuttlestop_item_ = playback_menu_->AddItem( - "pause", this, &MainMenu::ShuttleStopTriggered, tr("K")); - playback_shuttleright_item_ = playback_menu_->AddItem( - "incspeed", this, &MainMenu::ShuttleRightTriggered, tr("L")); + playback_shuttleleft_item_ = playback_menu_->add_item( + "decspeed", this, &MainMenu::shuttle_left_triggered, tr("J")); + playback_shuttlestop_item_ = playback_menu_->add_item( + "pause", this, &MainMenu::shuttle_stop_triggered, tr("K")); + playback_shuttleright_item_ = playback_menu_->add_item( + "incspeed", this, &MainMenu::shuttle_right_triggered, tr("L")); playback_menu_->addSeparator(); playback_loop_item_ = - playback_menu_->AddItem("loop", this, &MainMenu::LoopTriggered); + playback_menu_->add_item("loop", this, &MainMenu::loop_triggered); playback_loop_item_->setCheckable(true); // // SEQUENCE MENU // - sequence_menu_ = new Menu(this, this, &MainMenu::SequenceMenuAboutToShow); - sequence_cache_item_ = sequence_menu_->AddItem( - "seqcache", this, &MainMenu::SequenceCacheTriggered); - sequence_cache_in_to_out_item_ = sequence_menu_->AddItem( - "seqcacheinout", this, &MainMenu::SequenceCacheInOutTriggered); + sequence_menu_ = new Menu(this, this, &MainMenu::sequence_menu_about_to_show); + sequence_cache_item_ = sequence_menu_->add_item( + "seqcache", this, &MainMenu::sequence_cache_triggered); + sequence_cache_in_to_out_item_ = sequence_menu_->add_item( + "seqcacheinout", this, &MainMenu::sequence_cache_in_out_triggered); sequence_menu_->addSeparator(); - sequence_disk_cache_clear_item_ = sequence_menu_->AddItem( - "seqcacheclear", this, &MainMenu::SequenceCacheClearTriggered); + sequence_disk_cache_clear_item_ = sequence_menu_->add_item( + "seqcacheclear", this, &MainMenu::sequence_cache_clear_triggered); // TEMP: Hide sequence cache items for now. Want to see if clip caching will supersede it. sequence_cache_item_->setVisible(false); @@ -251,98 +251,98 @@ MainMenu::MainMenu(MainWindow *parent) // // WINDOW MENU // - window_menu_ = new Menu(this, this, &MainMenu::WindowMenuAboutToShow); + window_menu_ = new Menu(this, this, &MainMenu::window_menu_about_to_show); window_menu_separator_ = window_menu_->addSeparator(); - window_maximize_panel_item_ = window_menu_->AddItem( - "maximizepanel", parent, &MainWindow::ToggleMaximizedPanel, tr("`")); + window_maximize_panel_item_ = window_menu_->add_item( + "maximizepanel", parent, &MainWindow::toggle_maximized_panel, tr("`")); window_menu_->addSeparator(); - window_reset_layout_item_ = window_menu_->AddItem( - "resetdefaultlayout", parent, &MainWindow::SetDefaultLayout); + window_reset_layout_item_ = window_menu_->add_item( + "resetdefaultlayout", parent, &MainWindow::set_default_layout); // // TOOLS MENU // - tools_menu_ = new Menu(this, this, &MainMenu::ToolsMenuAboutToShow); + tools_menu_ = new Menu(this, this, &MainMenu::tools_menu_about_to_show); tools_menu_->setToolTipsVisible(true); tools_group_ = new QActionGroup(this); - tools_pointer_item_ = tools_menu_->AddItem( - "pointertool", this, &MainMenu::ToolItemTriggered, tr("V")); + tools_pointer_item_ = tools_menu_->add_item( + "pointertool", this, &MainMenu::tool_item_triggered, tr("V")); tools_pointer_item_->setCheckable(true); - tools_pointer_item_->setData(Tool::kPointer); + tools_pointer_item_->setData(Tool::k_pointer); tools_group_->addAction(tools_pointer_item_); - tools_trackselect_item_ = tools_menu_->AddItem( - "trackselecttool", this, &MainMenu::ToolItemTriggered, tr("D")); + tools_trackselect_item_ = tools_menu_->add_item( + "trackselecttool", this, &MainMenu::tool_item_triggered, tr("D")); tools_trackselect_item_->setCheckable(true); - tools_trackselect_item_->setData(Tool::kTrackSelect); + tools_trackselect_item_->setData(Tool::k_track_select); tools_group_->addAction(tools_trackselect_item_); - tools_edit_item_ = tools_menu_->AddItem( - "edittool", this, &MainMenu::ToolItemTriggered, tr("X")); + tools_edit_item_ = tools_menu_->add_item( + "edittool", this, &MainMenu::tool_item_triggered, tr("X")); tools_edit_item_->setCheckable(true); - tools_edit_item_->setData(Tool::kEdit); + tools_edit_item_->setData(Tool::k_edit); tools_group_->addAction(tools_edit_item_); - tools_ripple_item_ = tools_menu_->AddItem( - "rippletool", this, &MainMenu::ToolItemTriggered, tr("B")); + tools_ripple_item_ = tools_menu_->add_item( + "rippletool", this, &MainMenu::tool_item_triggered, tr("B")); tools_ripple_item_->setCheckable(true); - tools_ripple_item_->setData(Tool::kRipple); + tools_ripple_item_->setData(Tool::k_ripple); tools_group_->addAction(tools_ripple_item_); - tools_rolling_item_ = tools_menu_->AddItem( - "rollingtool", this, &MainMenu::ToolItemTriggered, tr("N")); + tools_rolling_item_ = tools_menu_->add_item( + "rollingtool", this, &MainMenu::tool_item_triggered, tr("N")); tools_rolling_item_->setCheckable(true); - tools_rolling_item_->setData(Tool::kRolling); + tools_rolling_item_->setData(Tool::k_rolling); tools_group_->addAction(tools_rolling_item_); - tools_razor_item_ = tools_menu_->AddItem( - "razortool", this, &MainMenu::ToolItemTriggered, tr("C")); + tools_razor_item_ = tools_menu_->add_item( + "razortool", this, &MainMenu::tool_item_triggered, tr("C")); tools_razor_item_->setCheckable(true); - tools_razor_item_->setData(Tool::kRazor); + tools_razor_item_->setData(Tool::k_razor); tools_group_->addAction(tools_razor_item_); - tools_slip_item_ = tools_menu_->AddItem( - "sliptool", this, &MainMenu::ToolItemTriggered, tr("Y")); + tools_slip_item_ = tools_menu_->add_item( + "sliptool", this, &MainMenu::tool_item_triggered, tr("Y")); tools_slip_item_->setCheckable(true); - tools_slip_item_->setData(Tool::kSlip); + tools_slip_item_->setData(Tool::k_slip); tools_group_->addAction(tools_slip_item_); - tools_slide_item_ = tools_menu_->AddItem( - "slidetool", this, &MainMenu::ToolItemTriggered, tr("U")); + tools_slide_item_ = tools_menu_->add_item( + "slidetool", this, &MainMenu::tool_item_triggered, tr("U")); tools_slide_item_->setCheckable(true); - tools_slide_item_->setData(Tool::kSlide); + tools_slide_item_->setData(Tool::k_slide); tools_group_->addAction(tools_slide_item_); - tools_hand_item_ = tools_menu_->AddItem( - "handtool", this, &MainMenu::ToolItemTriggered, tr("H")); + tools_hand_item_ = tools_menu_->add_item( + "handtool", this, &MainMenu::tool_item_triggered, tr("H")); tools_hand_item_->setCheckable(true); - tools_hand_item_->setData(Tool::kHand); + tools_hand_item_->setData(Tool::k_hand); tools_group_->addAction(tools_hand_item_); - tools_zoom_item_ = tools_menu_->AddItem( - "zoomtool", this, &MainMenu::ToolItemTriggered, tr("Z")); + tools_zoom_item_ = tools_menu_->add_item( + "zoomtool", this, &MainMenu::tool_item_triggered, tr("Z")); tools_zoom_item_->setCheckable(true); - tools_zoom_item_->setData(Tool::kZoom); + tools_zoom_item_->setData(Tool::k_zoom); tools_group_->addAction(tools_zoom_item_); - tools_transition_item_ = tools_menu_->AddItem( - "transitiontool", this, &MainMenu::ToolItemTriggered, tr("T")); + tools_transition_item_ = tools_menu_->add_item( + "transitiontool", this, &MainMenu::tool_item_triggered, tr("T")); tools_transition_item_->setCheckable(true); - tools_transition_item_->setData(Tool::kTransition); + tools_transition_item_->setData(Tool::k_transition); tools_group_->addAction(tools_transition_item_); - tools_add_item_ = tools_menu_->AddItem( - "addtool", this, &MainMenu::ToolItemTriggered, tr("A")); + tools_add_item_ = tools_menu_->add_item( + "addtool", this, &MainMenu::tool_item_triggered, tr("A")); tools_add_item_->setCheckable(true); - tools_add_item_->setData(Tool::kAdd); + tools_add_item_->setData(Tool::k_add); tools_group_->addAction(tools_add_item_); - tools_record_item_ = tools_menu_->AddItem( - "recordtool", this, &MainMenu::ToolItemTriggered, tr("R")); + tools_record_item_ = tools_menu_->add_item( + "recordtool", this, &MainMenu::tool_item_triggered, tr("R")); tools_record_item_->setCheckable(true); - tools_record_item_->setData(Tool::kRecord); + tools_record_item_->setData(Tool::k_record); tools_group_->addAction(tools_record_item_); tools_menu_->addSeparator(); @@ -350,27 +350,27 @@ MainMenu::MainMenu(MainWindow *parent) tools_add_item_menu_ = new Menu(tools_menu_); tools_menu_->addMenu(tools_add_item_menu_); - MenuShared::instance()->AddItemsForAddableObjectsMenu(tools_add_item_menu_); + MenuShared::instance()->add_items_for_addable_objects_menu(tools_add_item_menu_); tools_menu_->addSeparator(); - tools_snapping_item_ = tools_menu_->AddItem("snapping", Core::instance(), - &Core::SetSnapping, tr("S")); + tools_snapping_item_ = tools_menu_->add_item("snapping", Core::instance(), + &Core::set_snapping, tr("S")); tools_snapping_item_->setCheckable(true); tools_snapping_item_->setChecked(Core::instance()->snapping()); tools_menu_->addSeparator(); tools_proxy_settings_item_ = new QAction(this); - Menu::ConformItem(tools_proxy_settings_item_, "proxysettings"); + Menu::conform_item(tools_proxy_settings_item_, "proxysettings"); connect(tools_proxy_settings_item_, &QAction::triggered, this, [this]() { ProxyDialog d(this); d.exec(); }); tools_menu_->addAction(tools_proxy_settings_item_); - tools_preferences_item_ = tools_menu_->AddItem( - "prefs", Core::instance(), &Core::DialogPreferencesShow, tr("Ctrl+,")); + tools_preferences_item_ = tools_menu_->add_item( + "prefs", Core::instance(), &Core::dialog_preferences_show, tr("Ctrl+,")); // On macOS, Qt's text heuristic would relocate an English "Preferences" // action to the application menu, making it disappear from the Tools menu. // Pin it to this menu on all platforms. @@ -378,7 +378,7 @@ MainMenu::MainMenu(MainWindow *parent) #ifndef NDEBUG tools_magic_item_ = - tools_menu_->AddItem("magic", Core::instance(), &Core::SetMagic); + tools_menu_->add_item("magic", Core::instance(), &Core::set_magic); tools_magic_item_->setCheckable(true); #endif @@ -386,31 +386,31 @@ MainMenu::MainMenu(MainWindow *parent) // HELP MENU // help_menu_ = new Menu(this); - help_action_search_item_ = help_menu_->AddItem( - "actionsearch", this, &MainMenu::ActionSearchTriggered, tr("/")); + help_action_search_item_ = help_menu_->add_item( + "actionsearch", this, &MainMenu::action_search_triggered, tr("/")); help_menu_->addSeparator(); help_feedback_item_ = - help_menu_->AddItem("feedback", this, &MainMenu::HelpFeedbackTriggered); + help_menu_->add_item("feedback", this, &MainMenu::help_feedback_triggered); help_menu_->addSeparator(); help_about_item_ = - help_menu_->AddItem("about", Core::instance(), &Core::DialogAboutShow); + help_menu_->add_item("about", Core::instance(), &Core::dialog_about_show); - connect(Core::instance(), &Core::OpenRecentListChanged, this, - &MainMenu::RepopulateOpenRecent); - PopulateOpenRecent(); + connect(Core::instance(), &Core::open_recent_list_changed, this, + &MainMenu::repopulate_open_recent); + populate_open_recent(); - Retranslate(); + retranslate(); } void MainMenu::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { - Retranslate(); + retranslate(); } QMenuBar::changeEvent(e); } -void MainMenu::ToolItemTriggered() +void MainMenu::tool_item_triggered() { // Assume the sender is a QAction QAction *action = static_cast(sender()); @@ -419,12 +419,12 @@ void MainMenu::ToolItemTriggered() Tool::Item tool = static_cast(action->data().toInt()); // Set the Tool in Core - Core::instance()->SetTool(tool); + Core::instance()->set_tool(tool); } -void MainMenu::FileMenuAboutToShow() +void MainMenu::file_menu_about_to_show() { - Project *active_project = Core::instance()->GetActiveProject(); + Project *active_project = Core::instance()->get_active_project(); file_save_item_->setEnabled(active_project); file_save_as_item_->setEnabled(active_project); @@ -439,36 +439,36 @@ void MainMenu::FileMenuAboutToShow() } } -void MainMenu::EditMenuAboutToShow() +void MainMenu::edit_menu_about_to_show() { edit_delete2_item_->setVisible(false); } -void MainMenu::EditMenuAboutToHide() +void MainMenu::edit_menu_about_to_hide() { edit_delete2_item_->setVisible(true); } -void MainMenu::ViewMenuAboutToShow() +void MainMenu::view_menu_about_to_show() { // Parent is QMainWindow view_full_screen_item_->setChecked(parentWidget()->isFullScreen()); // Make sure we're displaying the correct options for the timebase TimeBasedPanel *p = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); if (p) { if (p->timebase().denominator() != 0) { view_menu_->addSeparator(); - MenuShared::instance()->AddItemsForTimeRulerMenu(view_menu_); + MenuShared::instance()->add_items_for_time_ruler_menu(view_menu_); } } // Ensure checked timecode display mode is correct - MenuShared::instance()->AboutToShowTimeRulerActions(p->timebase()); + MenuShared::instance()->about_to_show_time_ruler_actions(p->timebase()); } -void MainMenu::ToolsMenuAboutToShow() +void MainMenu::tools_menu_about_to_show() { // Ensure checked Tool is correct QList tool_actions = tools_group_->actions(); @@ -483,23 +483,23 @@ void MainMenu::ToolsMenuAboutToShow() tools_snapping_item_->setChecked(Core::instance()->snapping()); } -void MainMenu::PlaybackMenuAboutToShow() +void MainMenu::playback_menu_about_to_show() { - playback_loop_item_->setChecked(OLIVE_CONFIG("Loop").toBool()); + playback_loop_item_->setChecked(OAK_CONFIG("Loop").toBool()); } -void MainMenu::SequenceMenuAboutToShow() +void MainMenu::sequence_menu_about_to_show() { TimeBasedPanel *p = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); - bool can_cache_sequence = (p && p->GetConnectedViewer()); + bool can_cache_sequence = (p && p->get_connected_viewer()); sequence_cache_item_->setEnabled(can_cache_sequence); sequence_cache_in_to_out_item_->setEnabled(can_cache_sequence); } -void MainMenu::WindowMenuAboutToShow() +void MainMenu::window_menu_about_to_show() { // Remove any previous items while (window_menu_->actions().first() != window_menu_separator_) { @@ -532,9 +532,9 @@ void MainMenu::WindowMenuAboutToShow() window_menu_->insertActions(window_menu_separator_, panel_actions); } -void MainMenu::PopulateOpenRecent() +void MainMenu::populate_open_recent() { - if (Core::instance()->GetRecentProjects().isEmpty()) { + if (Core::instance()->get_recent_projects().isEmpty()) { // Insert dummy/disabled action to show there's nothing QAction *a = new QAction(tr("(None)")); a->setEnabled(false); @@ -542,25 +542,25 @@ void MainMenu::PopulateOpenRecent() } else { // Populate menu with recently opened projects - for (int i = 0; i < Core::instance()->GetRecentProjects().size(); i++) { + for (int i = 0; i < Core::instance()->get_recent_projects().size(); i++) { QAction *a = - new QAction(Core::instance()->GetRecentProjects().at(i)); + new QAction(Core::instance()->get_recent_projects().at(i)); a->setData(i); connect(a, &QAction::triggered, this, - &MainMenu::OpenRecentItemTriggered); + &MainMenu::open_recent_item_triggered); file_open_recent_menu_->insertAction(file_open_recent_separator_, a); } } } -void MainMenu::RepopulateOpenRecent() +void MainMenu::repopulate_open_recent() { - CloseOpenRecentMenu(); - PopulateOpenRecent(); + close_open_recent_menu(); + populate_open_recent(); } -void MainMenu::CloseOpenRecentMenu() +void MainMenu::close_open_recent_menu() { while (file_open_recent_menu_->actions().first() != file_open_recent_separator_) { @@ -569,239 +569,239 @@ void MainMenu::CloseOpenRecentMenu() } } -void MainMenu::ZoomInTriggered() +void MainMenu::zoom_in_triggered() { - PanelManager::instance()->CurrentlyFocused()->ZoomIn(); + PanelManager::instance()->currently_focused()->zoom_in(); } -void MainMenu::ZoomOutTriggered() +void MainMenu::zoom_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->ZoomOut(); + PanelManager::instance()->currently_focused()->zoom_out(); } -void MainMenu::IncreaseTrackHeightTriggered() +void MainMenu::increase_track_height_triggered() { - PanelManager::instance()->CurrentlyFocused()->IncreaseTrackHeight(); + PanelManager::instance()->currently_focused()->increase_track_height(); } -void MainMenu::DecreaseTrackHeightTriggered() +void MainMenu::decrease_track_height_triggered() { - PanelManager::instance()->CurrentlyFocused()->DecreaseTrackHeight(); + PanelManager::instance()->currently_focused()->decrease_track_height(); } -void MainMenu::GoToStartTriggered() +void MainMenu::go_to_start_triggered() { - PanelManager::instance()->CurrentlyFocused()->GoToStart(); + PanelManager::instance()->currently_focused()->go_to_start(); } -void MainMenu::PrevFrameTriggered() +void MainMenu::prev_frame_triggered() { - PanelManager::instance()->CurrentlyFocused()->PrevFrame(); + PanelManager::instance()->currently_focused()->prev_frame(); } -void MainMenu::PlayPauseTriggered() +void MainMenu::play_pause_triggered() { - PanelManager::instance()->CurrentlyFocused()->PlayPause(); + PanelManager::instance()->currently_focused()->play_pause(); } -void MainMenu::PlayInToOutTriggered() +void MainMenu::play_in_to_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->PlayInToOut(); + PanelManager::instance()->currently_focused()->play_in_to_out(); } -void MainMenu::LoopTriggered(bool enabled) +void MainMenu::loop_triggered(bool enabled) { - OLIVE_CONFIG("Loop") = enabled; + OAK_CONFIG("Loop") = enabled; } -void MainMenu::NextFrameTriggered() +void MainMenu::next_frame_triggered() { - PanelManager::instance()->CurrentlyFocused()->NextFrame(); + PanelManager::instance()->currently_focused()->next_frame(); } -void MainMenu::GoToEndTriggered() +void MainMenu::go_to_end_triggered() { - PanelManager::instance()->CurrentlyFocused()->GoToEnd(); + PanelManager::instance()->currently_focused()->go_to_end(); } -void MainMenu::SelectAllTriggered() +void MainMenu::select_all_triggered() { - PanelManager::instance()->CurrentlyFocused()->SelectAll(); + PanelManager::instance()->currently_focused()->select_all(); } -void MainMenu::DeselectAllTriggered() +void MainMenu::deselect_all_triggered() { - PanelManager::instance()->CurrentlyFocused()->DeselectAll(); + PanelManager::instance()->currently_focused()->deselect_all(); } -void MainMenu::InsertTriggered() +void MainMenu::insert_triggered() { FootageManagementPanel *project_panel = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); TimelinePanel *timeline_panel = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); if (project_panel && timeline_panel) { - timeline_panel->InsertFootageAtPlayhead( - project_panel->GetSelectedFootage()); + timeline_panel->insert_footage_at_playhead( + project_panel->get_selected_footage()); } } -void MainMenu::OverwriteTriggered() +void MainMenu::overwrite_triggered() { FootageManagementPanel *project_panel = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); TimelinePanel *timeline_panel = - PanelManager::instance()->MostRecentlyFocused(); + PanelManager::instance()->most_recently_focused(); if (project_panel && timeline_panel) { - timeline_panel->OverwriteFootageAtPlayhead( - project_panel->GetSelectedFootage()); + timeline_panel->overwrite_footage_at_playhead( + project_panel->get_selected_footage()); } } -void MainMenu::RippleToInTriggered() +void MainMenu::ripple_to_in_triggered() { - PanelManager::instance()->CurrentlyFocused()->RippleToIn(); + PanelManager::instance()->currently_focused()->ripple_to_in(); } -void MainMenu::RippleToOutTriggered() +void MainMenu::ripple_to_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->RippleToOut(); + PanelManager::instance()->currently_focused()->ripple_to_out(); } -void MainMenu::EditToInTriggered() +void MainMenu::edit_to_in_triggered() { - PanelManager::instance()->CurrentlyFocused()->EditToIn(); + PanelManager::instance()->currently_focused()->edit_to_in(); } -void MainMenu::EditToOutTriggered() +void MainMenu::edit_to_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->EditToOut(); + PanelManager::instance()->currently_focused()->edit_to_out(); } -void MainMenu::NudgeLeftTriggered() +void MainMenu::nudge_left_triggered() { - PanelManager::instance()->CurrentlyFocused()->NudgeLeft(); + PanelManager::instance()->currently_focused()->nudge_left(); } -void MainMenu::NudgeRightTriggered() +void MainMenu::nudge_right_triggered() { - PanelManager::instance()->CurrentlyFocused()->NudgeRight(); + PanelManager::instance()->currently_focused()->nudge_right(); } -void MainMenu::MoveInToPlayheadTriggered() +void MainMenu::move_in_to_playhead_triggered() { - PanelManager::instance()->CurrentlyFocused()->MoveInToPlayhead(); + PanelManager::instance()->currently_focused()->move_in_to_playhead(); } -void MainMenu::MoveOutToPlayheadTriggered() +void MainMenu::move_out_to_playhead_triggered() { - PanelManager::instance()->CurrentlyFocused()->MoveOutToPlayhead(); + PanelManager::instance()->currently_focused()->move_out_to_playhead(); } -void MainMenu::ActionSearchTriggered() +void MainMenu::action_search_triggered() { ActionSearch as(parentWidget()); - as.SetMenuBar(this); + as.set_menu_bar(this); as.exec(); } -void MainMenu::ShuttleLeftTriggered() +void MainMenu::shuttle_left_triggered() { - PanelManager::instance()->CurrentlyFocused()->ShuttleLeft(); + PanelManager::instance()->currently_focused()->shuttle_left(); } -void MainMenu::ShuttleStopTriggered() +void MainMenu::shuttle_stop_triggered() { - PanelManager::instance()->CurrentlyFocused()->ShuttleStop(); + PanelManager::instance()->currently_focused()->shuttle_stop(); } -void MainMenu::ShuttleRightTriggered() +void MainMenu::shuttle_right_triggered() { - PanelManager::instance()->CurrentlyFocused()->ShuttleRight(); + PanelManager::instance()->currently_focused()->shuttle_right(); } -void MainMenu::GoToPrevCutTriggered() +void MainMenu::go_to_prev_cut_triggered() { - PanelManager::instance()->CurrentlyFocused()->GoToPrevCut(); + PanelManager::instance()->currently_focused()->go_to_prev_cut(); } -void MainMenu::GoToNextCutTriggered() +void MainMenu::go_to_next_cut_triggered() { - PanelManager::instance()->CurrentlyFocused()->GoToNextCut(); + PanelManager::instance()->currently_focused()->go_to_next_cut(); } -void MainMenu::SetMarkerTriggered() +void MainMenu::set_marker_triggered() { - PanelManager::instance()->CurrentlyFocused()->SetMarker(); + PanelManager::instance()->currently_focused()->set_marker(); } -void MainMenu::FullScreenViewerTriggered() +void MainMenu::full_screen_viewer_triggered() { PanelManager::instance() - ->MostRecentlyFocused() - ->SetFullScreen(); + ->most_recently_focused() + ->set_full_screen(); } -void MainMenu::ToggleShowAllTriggered() +void MainMenu::toggle_show_all_triggered() { - PanelManager::instance()->CurrentlyFocused()->ToggleShowAll(); + PanelManager::instance()->currently_focused()->toggle_show_all(); } -void MainMenu::DeleteInOutTriggered() +void MainMenu::delete_in_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->DeleteInToOut(); + PanelManager::instance()->currently_focused()->delete_in_to_out(); } -void MainMenu::RippleDeleteInOutTriggered() +void MainMenu::ripple_delete_in_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->RippleDeleteInToOut(); + PanelManager::instance()->currently_focused()->ripple_delete_in_to_out(); } -void MainMenu::GoToInTriggered() +void MainMenu::go_to_in_triggered() { - PanelManager::instance()->CurrentlyFocused()->GoToIn(); + PanelManager::instance()->currently_focused()->go_to_in(); } -void MainMenu::GoToOutTriggered() +void MainMenu::go_to_out_triggered() { - PanelManager::instance()->CurrentlyFocused()->GoToOut(); + PanelManager::instance()->currently_focused()->go_to_out(); } -void MainMenu::OpenRecentItemTriggered() +void MainMenu::open_recent_item_triggered() { - Core::instance()->OpenProjectFromRecentList( + Core::instance()->open_project_from_recent_list( static_cast(sender())->data().toInt()); } -void MainMenu::SequenceCacheTriggered() +void MainMenu::sequence_cache_triggered() { - Core::instance()->CacheActiveSequence(false); + Core::instance()->cache_active_sequence(false); } -void MainMenu::SequenceCacheInOutTriggered() +void MainMenu::sequence_cache_in_out_triggered() { - Core::instance()->CacheActiveSequence(true); + Core::instance()->cache_active_sequence(true); } -void MainMenu::SequenceCacheClearTriggered() +void MainMenu::sequence_cache_clear_triggered() { - DiskCacheDialog::ClearDiskCache( - Core::instance()->GetActiveProject()->cache_path(), + DiskCacheDialog::clear_disk_cache( + Core::instance()->get_active_project()->cache_path(), Core::instance()->main_window()); } -void MainMenu::HelpFeedbackTriggered() +void MainMenu::help_feedback_triggered() { QDesktopServices::openUrl(QStringLiteral( "https://github.com/OakVideoEditorCommunity/oak/issues")); } -void MainMenu::Retranslate() +void MainMenu::retranslate() { // MenuShared is not a QWidget and therefore does not receive a LanguageEvent, we use MainMenu's to update it - MenuShared::instance()->Retranslate(); + MenuShared::instance()->retranslate(); // File menu file_menu_->setTitle(tr("&File")); @@ -818,7 +818,7 @@ void MainMenu::Retranslate() // Edit menu edit_menu_->setTitle(tr("&Edit")); - Core::instance()->undo_stack()->UpdateActions(); // Update undo and redo + Core::instance()->undo_stack()->update_actions(); // Update undo and redo edit_delete2_item_->setText(tr("Delete (alt)")); edit_insert_item_->setText(tr("Insert")); edit_overwrite_item_->setText(tr("Overwrite")); diff --git a/app/window/mainwindow/mainmenu.h b/app/window/mainwindow/mainmenu.h index cade486ab..a33e03270 100644 --- a/app/window/mainwindow/mainmenu.h +++ b/app/window/mainwindow/mainmenu.h @@ -19,8 +19,8 @@ ***/ -#ifndef MAINMENU_H -#define MAINMENU_H +#ifndef OAK_MAINMENU_H +#define OAK_MAINMENU_H #include #include @@ -60,140 +60,140 @@ private slots: * Assumes a QAction* sender() and its data() is a member of enum Tool::Item. Uses the data() to signal a * Tool change throughout the rest of the application. */ - void ToolItemTriggered(); + void tool_item_triggered(); /** * @brief Slot triggered just before the File menu shows */ - void FileMenuAboutToShow(); + void file_menu_about_to_show(); /** * @brief Slot triggered just before the Edit menu shows */ - void EditMenuAboutToShow(); - void EditMenuAboutToHide(); + void edit_menu_about_to_show(); + void edit_menu_about_to_hide(); /** * @brief Slot triggered just before the View menu shows */ - void ViewMenuAboutToShow(); + void view_menu_about_to_show(); /** * @brief Slot triggered just before the Tools menu shows */ - void ToolsMenuAboutToShow(); + void tools_menu_about_to_show(); /** * @brief Slot triggered just before the Playback menu shows */ - void PlaybackMenuAboutToShow(); + void playback_menu_about_to_show(); /** * @brief Slot triggered just before the Sequence menu shows */ - void SequenceMenuAboutToShow(); + void sequence_menu_about_to_show(); /** * @brief Slot triggered just before the Window menu shows */ - void WindowMenuAboutToShow(); + void window_menu_about_to_show(); /** * @brief Adds items to open recent menu */ - void PopulateOpenRecent(); + void populate_open_recent(); - void RepopulateOpenRecent(); + void repopulate_open_recent(); /** * @brief Clears open recent items when menu closes */ - void CloseOpenRecentMenu(); + void close_open_recent_menu(); /** * @brief Slot for zooming in * * Finds the currently focused panel and sends it a "zoom in" signal */ - void ZoomInTriggered(); + void zoom_in_triggered(); /** * @brief Slot for zooming out * * Finds the currently focused panel and sends it a "zoom out" signal */ - void ZoomOutTriggered(); + void zoom_out_triggered(); - void IncreaseTrackHeightTriggered(); - void DecreaseTrackHeightTriggered(); + void increase_track_height_triggered(); + void decrease_track_height_triggered(); - void GoToStartTriggered(); - void PrevFrameTriggered(); + void go_to_start_triggered(); + void prev_frame_triggered(); /** * @brief Slot for play/pause * * Finds the currently focused panel and sends it a "play/pause" signal */ - void PlayPauseTriggered(); + void play_pause_triggered(); - void PlayInToOutTriggered(); + void play_in_to_out_triggered(); - void LoopTriggered(bool enabled); + void loop_triggered(bool enabled); - void NextFrameTriggered(); - void GoToEndTriggered(); + void next_frame_triggered(); + void go_to_end_triggered(); - void SelectAllTriggered(); - void DeselectAllTriggered(); + void select_all_triggered(); + void deselect_all_triggered(); - void InsertTriggered(); - void OverwriteTriggered(); + void insert_triggered(); + void overwrite_triggered(); - void RippleToInTriggered(); - void RippleToOutTriggered(); - void EditToInTriggered(); - void EditToOutTriggered(); + void ripple_to_in_triggered(); + void ripple_to_out_triggered(); + void edit_to_in_triggered(); + void edit_to_out_triggered(); - void NudgeLeftTriggered(); - void NudgeRightTriggered(); - void MoveInToPlayheadTriggered(); - void MoveOutToPlayheadTriggered(); + void nudge_left_triggered(); + void nudge_right_triggered(); + void move_in_to_playhead_triggered(); + void move_out_to_playhead_triggered(); - void ActionSearchTriggered(); + void action_search_triggered(); - void ShuttleLeftTriggered(); - void ShuttleStopTriggered(); - void ShuttleRightTriggered(); + void shuttle_left_triggered(); + void shuttle_stop_triggered(); + void shuttle_right_triggered(); - void GoToPrevCutTriggered(); - void GoToNextCutTriggered(); + void go_to_prev_cut_triggered(); + void go_to_next_cut_triggered(); - void SetMarkerTriggered(); + void set_marker_triggered(); - void FullScreenViewerTriggered(); + void full_screen_viewer_triggered(); - void ToggleShowAllTriggered(); + void toggle_show_all_triggered(); - void DeleteInOutTriggered(); - void RippleDeleteInOutTriggered(); + void delete_in_out_triggered(); + void ripple_delete_in_out_triggered(); - void GoToInTriggered(); - void GoToOutTriggered(); + void go_to_in_triggered(); + void go_to_out_triggered(); - void OpenRecentItemTriggered(); + void open_recent_item_triggered(); - void SequenceCacheTriggered(); - void SequenceCacheInOutTriggered(); - void SequenceCacheClearTriggered(); + void sequence_cache_triggered(); + void sequence_cache_in_out_triggered(); + void sequence_cache_clear_triggered(); - void HelpFeedbackTriggered(); + void help_feedback_triggered(); private: /** * @brief Set strings based on the current application language. */ - void Retranslate(); + void retranslate(); Menu *file_menu_; Menu *file_new_menu_; @@ -297,4 +297,4 @@ private: } -#endif // MAINMENU_H +#endif // OAK_MAINMENU_H diff --git a/app/window/mainwindow/mainstatusbar.cpp b/app/window/mainwindow/mainstatusbar.cpp index ad16b0edf..0a6e258a7 100644 --- a/app/window/mainwindow/mainstatusbar.cpp +++ b/app/window/mainwindow/mainstatusbar.cpp @@ -46,64 +46,64 @@ MainStatusBar::MainStatusBar(QWidget *parent) 10000); } -void MainStatusBar::ConnectTaskManager(TaskManager *manager) +void MainStatusBar::connect_task_manager(TaskManager *manager) { if (manager_) { - disconnect(manager_, &TaskManager::TaskListChanged, this, - &MainStatusBar::UpdateStatus); + disconnect(manager_, &TaskManager::task_list_changed, this, + &MainStatusBar::update_status); } manager_ = manager; if (manager_) { - connect(manager_, &TaskManager::TaskListChanged, this, - &MainStatusBar::UpdateStatus); + connect(manager_, &TaskManager::task_list_changed, this, + &MainStatusBar::update_status); } } -void MainStatusBar::UpdateStatus() +void MainStatusBar::update_status() { if (!manager_) { return; } - if (manager_->GetTaskCount() == 0) { + if (manager_->get_task_count() == 0) { clearMessage(); bar_->setVisible(false); bar_->setValue(0); } else { - Task *t = manager_->GetFirstTask(); + Task *t = manager_->get_first_task(); - if (manager_->GetTaskCount() == 1) { - showMessage(t->GetTitle()); + if (manager_->get_task_count() == 1) { + showMessage(t->get_title()); } else { showMessage(tr("Running %n background task(s)", nullptr, - manager_->GetTaskCount())); + manager_->get_task_count())); } bar_->setVisible(true); if (connected_task_) { - disconnect(connected_task_, &Task::ProgressChanged, this, - &MainStatusBar::SetProgressBarValue); + disconnect(connected_task_, &Task::progress_changed, this, + &MainStatusBar::set_progress_bar_value); disconnect(connected_task_, &Task::destroyed, this, - &MainStatusBar::ConnectedTaskDeleted); + &MainStatusBar::connected_task_deleted); } connected_task_ = t; - connect(connected_task_, &Task::ProgressChanged, this, - &MainStatusBar::SetProgressBarValue); + connect(connected_task_, &Task::progress_changed, this, + &MainStatusBar::set_progress_bar_value); connect(connected_task_, &Task::destroyed, this, - &MainStatusBar::ConnectedTaskDeleted); + &MainStatusBar::connected_task_deleted); } } -void MainStatusBar::SetProgressBarValue(double d) +void MainStatusBar::set_progress_bar_value(double d) { bar_->setValue(qRound(100.0 * d)); } -void MainStatusBar::ConnectedTaskDeleted() +void MainStatusBar::connected_task_deleted() { connected_task_ = nullptr; } @@ -112,7 +112,7 @@ void MainStatusBar::mouseDoubleClickEvent(QMouseEvent *e) { QStatusBar::mouseDoubleClickEvent(e); - emit DoubleClicked(); + emit double_clicked(); } } diff --git a/app/window/mainwindow/mainstatusbar.h b/app/window/mainwindow/mainstatusbar.h index e08dad895..ce2e905e1 100644 --- a/app/window/mainwindow/mainstatusbar.h +++ b/app/window/mainwindow/mainstatusbar.h @@ -19,8 +19,8 @@ ***/ -#ifndef MAINSTATUSBAR_H -#define MAINSTATUSBAR_H +#ifndef OAK_MAINSTATUSBAR_H +#define OAK_MAINSTATUSBAR_H #include #include @@ -38,20 +38,20 @@ class MainStatusBar : public QStatusBar { public: MainStatusBar(QWidget *parent = nullptr); - void ConnectTaskManager(TaskManager *manager); + void connect_task_manager(TaskManager *manager); signals: - void DoubleClicked(); + void double_clicked(); protected: virtual void mouseDoubleClickEvent(QMouseEvent *e) override; private slots: - void UpdateStatus(); + void update_status(); - void SetProgressBarValue(double d); + void set_progress_bar_value(double d); - void ConnectedTaskDeleted(); + void connected_task_deleted(); private: TaskManager *manager_; @@ -63,4 +63,4 @@ private: } -#endif // MAINSTATUSBAR_H +#endif // OAK_MAINSTATUSBAR_H diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 0778b04db..85ab07a33 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -68,13 +68,13 @@ MainWindow::MainWindow(QWidget *parent) MainMenu *main_menu = new MainMenu(this); setMenuBar(main_menu); - LoadCustomShortcuts(); + load_custom_shortcuts(); // Create and set status bar MainStatusBar *status_bar = new MainStatusBar(this); - status_bar->ConnectTaskManager(TaskManager::instance()); - connect(status_bar, &MainStatusBar::DoubleClicked, this, - &MainWindow::StatusBarDoubleClicked); + status_bar->connect_task_manager(TaskManager::instance()); + connect(status_bar, &MainStatusBar::double_clicked, this, + &MainWindow::status_bar_double_clicked); setStatusBar(status_bar); // Create standard panels @@ -88,7 +88,7 @@ MainWindow::MainWindow(QWidget *parent) project_panel_ = new ProjectPanel(QStringLiteral("ProjectPanel")); tool_panel_ = new ToolPanel(); task_man_panel_ = new TaskManagerPanel(); - AppendTimelinePanel(); + append_timeline_panel(); audio_monitor_panel_ = new AudioMonitorPanel(); scope_panel_ = new ScopePanel(); history_panel_ = new HistoryPanel(); @@ -101,44 +101,44 @@ MainWindow::MainWindow(QWidget *parent) emit pixel_sampler_panel_->shown(Qt::OtherFocusReason); // Make node-related connections - connect(node_panel_, &NodePanel::NodeSelectionChangedWithContexts, - param_panel_, &ParamPanel::SetSelectedNodes); - connect(node_panel_, &NodePanel::NodeGroupOpened, this, - &MainWindow::NodePanelGroupOpenedOrClosed); - connect(node_panel_, &NodePanel::NodeGroupClosed, this, - &MainWindow::NodePanelGroupOpenedOrClosed); - connect(param_panel_, &ParamPanel::FocusedNodeChanged, - sequence_viewer_panel_, &ViewerPanel::SetGizmos); - connect(param_panel_, &ParamPanel::RequestViewerToStartEditingText, - sequence_viewer_panel_, &ViewerPanel::RequestStartEditingText); - connect(param_panel_, &ParamPanel::FocusedNodeChanged, curve_panel_, - &CurvePanel::SetNode); - connect(param_panel_, &ParamPanel::SelectedNodesChanged, node_panel_, - &NodePanel::Select); - connect(project_panel_, &ProjectPanel::ProjectNameChanged, this, - &MainWindow::UpdateTitle); + connect(node_panel_, &NodePanel::node_selection_changed_with_contexts, + param_panel_, &ParamPanel::set_selected_nodes); + connect(node_panel_, &NodePanel::node_group_opened, this, + &MainWindow::node_panel_group_opened_or_closed); + connect(node_panel_, &NodePanel::node_group_closed, this, + &MainWindow::node_panel_group_opened_or_closed); + connect(param_panel_, &ParamPanel::focused_node_changed, + sequence_viewer_panel_, &ViewerPanel::set_gizmos); + connect(param_panel_, &ParamPanel::request_viewer_to_start_editing_text, + sequence_viewer_panel_, &ViewerPanel::request_start_editing_text); + connect(param_panel_, &ParamPanel::focused_node_changed, curve_panel_, + &CurvePanel::set_node); + connect(param_panel_, &ParamPanel::selected_nodes_changed, node_panel_, + &NodePanel::select); + connect(project_panel_, &ProjectPanel::project_name_changed, this, + &MainWindow::update_title); - connect(node_panel_, &NodePanel::NodeSelectionChanged, - sequence_viewer_panel_, &ViewerPanel::SetNodeViewSelections); + connect(node_panel_, &NodePanel::node_selection_changed, + sequence_viewer_panel_, &ViewerPanel::set_node_view_selections); // Route play/pause/shuttle commands from these panels to the sequence viewer - sequence_viewer_panel_->ConnectTimeBasedPanel(param_panel_); - sequence_viewer_panel_->ConnectTimeBasedPanel(curve_panel_); - sequence_viewer_panel_->ConnectTimeBasedPanel(multicam_panel_); + sequence_viewer_panel_->connect_time_based_panel(param_panel_); + sequence_viewer_panel_->connect_time_based_panel(curve_panel_); + sequence_viewer_panel_->connect_time_based_panel(multicam_panel_); - connect(PanelManager::instance(), &PanelManager::FocusedPanelChanged, this, - &MainWindow::FocusedPanelChanged); + connect(PanelManager::instance(), &PanelManager::focused_panel_changed, this, + &MainWindow::focused_panel_changed); - sequence_viewer_panel_->AddPlaybackDevice( - multicam_panel_->GetMulticamWidget()->GetDisplayWidget()); - sequence_viewer_panel_->ConnectMulticamWidget( - multicam_panel_->GetMulticamWidget()); + sequence_viewer_panel_->add_playback_device( + multicam_panel_->get_multicam_widget()->get_display_widget()); + sequence_viewer_panel_->connect_multicam_widget( + multicam_panel_->get_multicam_widget()); - scope_panel_->SetViewerPanel(sequence_viewer_panel_); + scope_panel_->set_viewer_panel(sequence_viewer_panel_); - UpdateTitle(); + update_title(); - QMetaObject::invokeMethod(this, &MainWindow::SetDefaultLayout, + QMetaObject::invokeMethod(this, &MainWindow::set_default_layout, Qt::QueuedConnection); } @@ -151,49 +151,49 @@ MainWindow::~MainWindow() #endif } -void MainWindow::LoadLayout(const MainWindowLayoutInfo &info) +void MainWindow::load_layout(const MainWindowLayoutInfo &info) { foreach (Folder *folder, info.open_folders()) { - OpenFolder(folder, true); + open_folder(folder, true); } foreach (Sequence *sequence, info.open_sequences()) { - OpenSequence(sequence, info.open_sequences().size() == 1); + open_sequence(sequence, info.open_sequences().size() == 1); } foreach (ViewerOutput *viewer, info.open_viewers()) { - OpenNodeInViewer(viewer); + open_node_in_viewer(viewer); } for (auto it = info.panel_data().cbegin(); it != info.panel_data().cend(); it++) { // Find panel with this ID if (PanelWidget *panel = - PanelManager::instance()->GetPanelWithName(it->first)) { - panel->LoadData(it->second); + PanelManager::instance()->get_panel_with_name(it->first)) { + panel->load_data(it->second); } } KDDockWidgets::LayoutSaver().restoreLayout(qUncompress(info.state())); } -QString TransformNameForSerialization(const QString &unique, int i) +QString transform_name_for_serialization(const QString &unique, int i) { return QStringLiteral("%1:%2").arg(unique.split(':').at(0), QString::number(i)); } -void CorrectPanelDataIfNecessary(const QString &unique_name, int index, +void correct_panel_data_if_necessary(const QString &unique_name, int index, MainWindowLayoutInfo &info, QByteArray &layout) { - QString corrected = TransformNameForSerialization(unique_name, index); + QString corrected = transform_name_for_serialization(unique_name, index); if (corrected != unique_name) { info.move_panel_data(unique_name, corrected); layout.replace(unique_name.toUtf8(), corrected.toUtf8()); } } -MainWindowLayoutInfo MainWindow::SaveLayout() const +MainWindowLayoutInfo MainWindow::save_layout() const { MainWindowLayoutInfo info; @@ -202,25 +202,25 @@ MainWindowLayoutInfo MainWindow::SaveLayout() const premaximized_state_; foreach (PanelWidget *panel, PanelManager::instance()->panels()) { - info.set_panel_data(panel->uniqueName(), panel->SaveData()); + info.set_panel_data(panel->uniqueName(), panel->save_data()); } for (int i = 0; i < folder_panels_.size(); i++) { auto panel = folder_panels_.at(i); info.add_folder(panel->get_root()); - CorrectPanelDataIfNecessary(panel->uniqueName(), i, info, layout); + correct_panel_data_if_necessary(panel->uniqueName(), i, info, layout); } for (int i = 0; i < timeline_panels_.size(); i++) { auto panel = timeline_panels_.at(i); - info.add_sequence(panel->GetSequence()); - CorrectPanelDataIfNecessary(panel->uniqueName(), i, info, layout); + info.add_sequence(panel->get_sequence()); + correct_panel_data_if_necessary(panel->uniqueName(), i, info, layout); } for (int i = 0; i < viewer_panels_.size(); i++) { auto panel = viewer_panels_.at(i); - info.add_viewer(panel->GetConnectedViewer()); - CorrectPanelDataIfNecessary(panel->uniqueName(), i, info, layout); + info.add_viewer(panel->get_connected_viewer()); + correct_panel_data_if_necessary(panel->uniqueName(), i, info, layout); } info.set_state(qCompress(layout)); @@ -228,11 +228,11 @@ MainWindowLayoutInfo MainWindow::SaveLayout() const return info; } -TimelinePanel *MainWindow::OpenSequence(Sequence *sequence, bool enable_focus) +TimelinePanel *MainWindow::open_sequence(Sequence *sequence, bool enable_focus) { // See if this sequence is already open, and switch to it if so foreach (TimelinePanel *tl, timeline_panels_) { - if (tl->GetConnectedViewer() == sequence) { + if (tl->get_connected_viewer() == sequence) { tl->raise(); return tl; } @@ -241,40 +241,40 @@ TimelinePanel *MainWindow::OpenSequence(Sequence *sequence, bool enable_focus) // See if we have any sequences open or not TimelinePanel *panel; - if (!timeline_panels_.first()->GetConnectedViewer()) { + if (!timeline_panels_.first()->get_connected_viewer()) { panel = timeline_panels_.first(); } else { - panel = AppendTimelinePanel(); + panel = append_timeline_panel(); //enable_focus = false; } - panel->ConnectViewerNode(sequence); + panel->connect_viewer_node(sequence); if (enable_focus) { - TimelineFocused(sequence); - UpdateAudioMonitorParams(sequence); + timeline_focused(sequence); + update_audio_monitor_params(sequence); } return panel; } -void MainWindow::CloseSequence(Sequence *sequence) +void MainWindow::close_sequence(Sequence *sequence) { // We defer to RemoveTimelinePanel() to close the panels, which may delete and remove indices from timeline_panels_. // We make a copy so that our array here doesn't get ruined by what RemoveTimelinePanel() does QList copy = timeline_panels_; foreach (TimelinePanel *tp, copy) { - if (tp->GetConnectedViewer() == sequence) { - RemoveTimelinePanel(tp); + if (tp->get_connected_viewer() == sequence) { + remove_timeline_panel(tp); } } } -bool MainWindow::IsSequenceOpen(Sequence *sequence) const +bool MainWindow::is_sequence_open(Sequence *sequence) const { foreach (TimelinePanel *tp, timeline_panels_) { - if (tp->GetConnectedViewer() == sequence) { + if (tp->get_connected_viewer() == sequence) { return true; } } @@ -282,10 +282,10 @@ bool MainWindow::IsSequenceOpen(Sequence *sequence) const return false; } -void MainWindow::OpenFolder(Folder *i, bool floating) +void MainWindow::open_folder(Folder *i, bool floating) { ProjectPanel *panel = - AppendPanelInternal(QStringLiteral("FolderPanel"), folder_panels_); + append_panel_internal(QStringLiteral("FolderPanel"), folder_panels_); panel->set_project(i->project()); panel->set_root(i); @@ -297,17 +297,17 @@ void MainWindow::OpenFolder(Folder *i, bool floating) } // If the panel is closed, just destroy it - connect(panel, &ProjectPanel::CloseRequested, this, - &MainWindow::FolderPanelCloseRequested); + connect(panel, &ProjectPanel::close_requested, this, + &MainWindow::folder_panel_close_requested); } -void MainWindow::OpenNodeInViewer(ViewerOutput *node) +void MainWindow::open_node_in_viewer(ViewerOutput *node) { ViewerPanel *existing = nullptr; for (auto it = viewer_panels_.cbegin(); it != viewer_panels_.cend(); it++) { ViewerPanel *it2 = (*it); - if (it2->GetConnectedViewer() == node) { + if (it2->get_connected_viewer() == node) { existing = it2; break; } @@ -319,18 +319,18 @@ void MainWindow::OpenNodeInViewer(ViewerOutput *node) } else { // Create a viewer for this node ViewerPanel *viewer = - AppendPanelInternal(QStringLiteral("ViewerPanel"), viewer_panels_); + append_panel_internal(QStringLiteral("ViewerPanel"), viewer_panels_); - viewer->ConnectViewerNode(node); + viewer->connect_viewer_node(node); - connect(viewer, &ViewerPanel::CloseRequested, this, - &MainWindow::ViewerCloseRequested); - connect(node, &ViewerOutput::RemovedFromGraph, this, - &MainWindow::ViewerWithPanelRemovedFromGraph); + connect(viewer, &ViewerPanel::close_requested, this, + &MainWindow::viewer_close_requested); + connect(node, &ViewerOutput::removed_from_graph, this, + &MainWindow::viewer_with_panel_removed_from_graph); } } -void MainWindow::SetFullscreen(bool fullscreen) +void MainWindow::set_fullscreen(bool fullscreen) { if (fullscreen) { setWindowState(windowState() | Qt::WindowFullScreen); @@ -339,7 +339,7 @@ void MainWindow::SetFullscreen(bool fullscreen) } } -void MainWindow::ToggleMaximizedPanel() +void MainWindow::toggle_maximized_panel() { KDDockWidgets::LayoutSaver saver; @@ -348,11 +348,11 @@ void MainWindow::ToggleMaximizedPanel() // Find the currently focused panel PanelWidget *currently_hovered = - PanelManager::instance()->CurrentlyHovered(); + PanelManager::instance()->currently_hovered(); // If no panel is hovered, fallback to the currently active panel if (!currently_hovered) { - currently_hovered = PanelManager::instance()->CurrentlyFocused(); + currently_hovered = PanelManager::instance()->currently_focused(); // If no panel is hovered or focused, do nothing if (!currently_hovered) { @@ -377,21 +377,21 @@ void MainWindow::ToggleMaximizedPanel() } else { // Preserve currently focused panel auto currently_focused_panel = - PanelManager::instance()->CurrentlyFocused(false); + PanelManager::instance()->currently_focused(false); // Assume we are currently maximized, restore the state - PanelManager::instance()->SetSuppressChangedSignal(true); + PanelManager::instance()->set_suppress_changed_signal(true); saver.restoreLayout(premaximized_state_); premaximized_state_.clear(); currently_focused_panel->raise(); currently_focused_panel->setFocus(Qt::ActiveWindowFocusReason); - PanelManager::instance()->SetSuppressChangedSignal(false); + PanelManager::instance()->set_suppress_changed_signal(false); } } -void MainWindow::SetProject(Project *p) +void MainWindow::set_project(Project *p) { if (project_ == p) { return; @@ -399,21 +399,21 @@ void MainWindow::SetProject(Project *p) if (project_) { // Clear all data - param_panel_->SetContexts(QVector()); - node_panel_->SetContexts(QVector()); + param_panel_->set_contexts(QVector()); + node_panel_->set_contexts(QVector()); // Close any nodes open in TimeBasedWidgets foreach (PanelWidget *panel, PanelManager::instance()->panels()) { TimeBasedPanel *tbp = dynamic_cast(panel); - if (tbp && tbp->GetConnectedViewer() && - tbp->GetConnectedViewer()->project() == project_) { + if (tbp && tbp->get_connected_viewer() && + tbp->get_connected_viewer()->project() == project_) { if (dynamic_cast(tbp)) { // Prefer our CloseSequence function which will delete any unnecessary timeline panels - CloseSequence( - static_cast(tbp->GetConnectedViewer())); + close_sequence( + static_cast(tbp->get_connected_viewer())); } else { - tbp->DisconnectViewerNode(); + tbp->disconnect_viewer_node(); } } } @@ -437,7 +437,7 @@ void MainWindow::SetProject(Project *p) } } -void MainWindow::SetApplicationProgressStatus(ProgressStatus status) +void MainWindow::set_application_progress_status(ProgressStatus status) { #if defined(Q_OS_WINDOWS) if (taskbar_interface_) { @@ -461,7 +461,7 @@ void MainWindow::SetApplicationProgressStatus(ProgressStatus status) #endif } -void MainWindow::SetApplicationProgressValue(int value) +void MainWindow::set_application_progress_value(int value) { #if defined(Q_OS_WINDOWS) if (taskbar_interface_) { @@ -472,27 +472,27 @@ void MainWindow::SetApplicationProgressValue(int value) #endif } -void MainWindow::SelectFootage(const QVector &e) +void MainWindow::select_footage(const QVector &e) { - SelectFootageForProjectPanel(e, project_panel_); + select_footage_for_project_panel(e, project_panel_); for (ProjectPanel *p : folder_panels_) { - SelectFootageForProjectPanel(e, p); + select_footage_for_project_panel(e, p); } } void MainWindow::closeEvent(QCloseEvent *e) { // Try to close all projects (this will return false if the user chooses not to close) - if (!Core::instance()->CloseProject(false)) { + if (!Core::instance()->close_project(false)) { e->ignore(); return; } - scope_panel_->SetViewerPanel(nullptr); + scope_panel_->set_viewer_panel(nullptr); - PanelManager::instance()->DeleteAllPanels(); + PanelManager::instance()->delete_all_panels(); - SaveCustomShortcuts(); + save_custom_shortcuts(); QMainWindow::closeEvent(e); } @@ -526,66 +526,66 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, } #endif -void MainWindow::StatusBarDoubleClicked() +void MainWindow::status_bar_double_clicked() { task_man_panel_->show(); task_man_panel_->raise(); } -void MainWindow::NodePanelGroupOpenedOrClosed() +void MainWindow::node_panel_group_opened_or_closed() { NodePanel *p = static_cast(sender()); - param_panel_->SetContexts(p->GetContexts()); + param_panel_->set_contexts(p->get_contexts()); } -void MainWindow::TimelinePanelSelectionChanged(const QVector &blocks) +void MainWindow::timeline_panel_selection_changed(const QVector &blocks) { TimelinePanel *panel = static_cast(sender()); - if (PanelManager::instance()->CurrentlyFocused(false) == panel) { - UpdateNodePanelContextFromTimelinePanel(panel); - sequence_viewer_panel_->SetTimelineSelectedBlocks(blocks); + if (PanelManager::instance()->currently_focused(false) == panel) { + update_node_panel_context_from_timeline_panel(panel); + sequence_viewer_panel_->set_timeline_selected_blocks(blocks); } } -void MainWindow::ShowWelcomeDialog() +void MainWindow::show_welcome_dialog() { - if (OLIVE_CONFIG("ShowWelcomeDialog").toBool()) { + if (OAK_CONFIG("show_welcome_dialog").toBool()) { AboutDialog ad(true, this); ad.exec(); } } -void MainWindow::RevealViewerInProject(ViewerOutput *r) +void MainWindow::reveal_viewer_in_project(ViewerOutput *r) { // Rather than just using the resident ProjectPanel, find the most recently focused one since // that's probably the one people will want - auto panels = PanelManager::instance()->GetPanelsOfType(); + auto panels = PanelManager::instance()->get_panels_of_type(); foreach (ProjectPanel *p, panels) { - if (p->SelectItem(r)) { + if (p->select_item(r)) { break; } } } -void MainWindow::RevealViewerInFootageViewer(ViewerOutput *r, +void MainWindow::reveal_viewer_in_footage_viewer(ViewerOutput *r, const TimeRange &range) { - footage_viewer_panel_->ConnectViewerNode(r); + footage_viewer_panel_->connect_viewer_node(r); auto command = new MultiUndoCommand(); - if (!r->GetWorkArea()->enabled()) { + if (!r->get_work_area()->enabled()) { command->add_child(new WorkareaSetEnabledCommand( - r->project(), r->GetWorkArea(), true)); + r->project(), r->get_work_area(), true)); } - command->add_child(new WorkareaSetRangeCommand(r->GetWorkArea(), range)); + command->add_child(new WorkareaSetRangeCommand(r->get_work_area(), range)); Core::instance()->undo_stack()->push(command, tr("Set Footage Workarea")); - r->SetPlayhead(range.in()); + r->set_playhead(range.in()); } #ifdef Q_OS_LINUX -void MainWindow::ShowNouveauWarning() +void MainWindow::show_nouveau_warning() { QMessageBox::warning( this, tr("Driver Warning"), @@ -596,14 +596,14 @@ void MainWindow::ShowNouveauWarning() } #endif -void MainWindow::UpdateTitle() +void MainWindow::update_title() { - if (Core::instance()->GetActiveProject()) { + if (Core::instance()->get_active_project()) { setWindowTitle( QStringLiteral("%1 %2 - [*]%3") .arg(QApplication::applicationName(), QApplication::applicationVersion(), - Core::instance()->GetActiveProject()->pretty_filename())); + Core::instance()->get_active_project()->pretty_filename())); } else { setWindowTitle( QStringLiteral("%1 %2").arg(QApplication::applicationName(), @@ -611,53 +611,53 @@ void MainWindow::UpdateTitle() } } -void MainWindow::TimelineCloseRequested() +void MainWindow::timeline_close_requested() { TimelinePanel *t = static_cast(sender()); - RemoveTimelinePanel(t); + remove_timeline_panel(t); } -void MainWindow::ViewerCloseRequested() +void MainWindow::viewer_close_requested() { ViewerPanel *panel = static_cast(sender()); - if (panel == scope_panel_->GetConnectedViewerPanel()) { - scope_panel_->SetViewerPanel(sequence_viewer_panel_); + if (panel == scope_panel_->get_connected_viewer_panel()) { + scope_panel_->set_viewer_panel(sequence_viewer_panel_); } - RemovePanelInternal(viewer_panels_, panel); + remove_panel_internal(viewer_panels_, panel); panel->deleteLater(); } -void MainWindow::ViewerWithPanelRemovedFromGraph() +void MainWindow::viewer_with_panel_removed_from_graph() { ViewerOutput *vo = static_cast(sender()); ViewerPanel *panel = nullptr; foreach (ViewerPanel *p, viewer_panels_) { - if (p->GetConnectedViewer() == vo) { + if (p->get_connected_viewer() == vo) { panel = p; break; } } if (panel) { - RemovePanelInternal(viewer_panels_, panel); + remove_panel_internal(viewer_panels_, panel); panel->deleteLater(); - disconnect(vo, &ViewerOutput::RemovedFromGraph, this, - &MainWindow::ViewerWithPanelRemovedFromGraph); + disconnect(vo, &ViewerOutput::removed_from_graph, this, + &MainWindow::viewer_with_panel_removed_from_graph); } } -void MainWindow::FolderPanelCloseRequested() +void MainWindow::folder_panel_close_requested() { ProjectPanel *panel = static_cast(sender()); - RemovePanelInternal(folder_panels_, panel); + remove_panel_internal(folder_panels_, panel); panel->deleteLater(); } -TimelinePanel *MainWindow::AppendTimelinePanel() +TimelinePanel *MainWindow::append_timeline_panel() { TimelinePanel *previous = nullptr; if (!timeline_panels_.empty()) { @@ -665,64 +665,64 @@ TimelinePanel *MainWindow::AppendTimelinePanel() } TimelinePanel *panel = - AppendPanelInternal(QStringLiteral("TimelinePanel"), timeline_panels_); + append_panel_internal(QStringLiteral("TimelinePanel"), timeline_panels_); if (previous) { previous->addDockWidgetAsTab(panel); } else { - panel->SetSignalInsteadOfClose(false); + panel->set_signal_instead_of_close(false); } - connect(panel, &PanelWidget::CloseRequested, this, - &MainWindow::TimelineCloseRequested); - connect(panel, &TimelinePanel::RequestCaptureStart, sequence_viewer_panel_, - &SequenceViewerPanel::StartCapture); - connect(panel, &TimelinePanel::BlockSelectionChanged, this, - &MainWindow::TimelinePanelSelectionChanged); - connect(panel, &TimelinePanel::RevealViewerInProject, this, - &MainWindow::RevealViewerInProject); - connect(panel, &TimelinePanel::RevealViewerInFootageViewer, this, - &MainWindow::RevealViewerInFootageViewer); + connect(panel, &PanelWidget::close_requested, this, + &MainWindow::timeline_close_requested); + connect(panel, &TimelinePanel::request_capture_start, sequence_viewer_panel_, + &SequenceViewerPanel::start_capture); + connect(panel, &TimelinePanel::block_selection_changed, this, + &MainWindow::timeline_panel_selection_changed); + connect(panel, &TimelinePanel::reveal_viewer_in_project, this, + &MainWindow::reveal_viewer_in_project); + connect(panel, &TimelinePanel::reveal_viewer_in_footage_viewer, this, + &MainWindow::reveal_viewer_in_footage_viewer); - sequence_viewer_panel_->ConnectTimeBasedPanel(panel); + sequence_viewer_panel_->connect_time_based_panel(panel); return panel; } -void MainWindow::RemoveTimelinePanel(TimelinePanel *panel) +void MainWindow::remove_timeline_panel(TimelinePanel *panel) { // Stop showing this timeline in the viewer - TimelineFocused(nullptr); - panel->ConnectViewerNode(nullptr); + timeline_focused(nullptr); + panel->connect_viewer_node(nullptr); if (timeline_panels_.size() != 1) { - RemovePanelInternal(timeline_panels_, panel); + remove_panel_internal(timeline_panels_, panel); panel->deleteLater(); } } -void MainWindow::TimelineFocused(ViewerOutput *viewer) +void MainWindow::timeline_focused(ViewerOutput *viewer) { - sequence_viewer_panel_->ConnectViewerNode(viewer); - multicam_panel_->ConnectViewerNode(viewer); - param_panel_->ConnectViewerNode(viewer); - curve_panel_->ConnectViewerNode(viewer); + sequence_viewer_panel_->connect_viewer_node(viewer); + multicam_panel_->connect_viewer_node(viewer); + param_panel_->connect_viewer_node(viewer); + curve_panel_->connect_viewer_node(viewer); } -QString MainWindow::GetCustomShortcutsFile() +QString MainWindow::get_custom_shortcuts_file() { - return QDir(FileFunctions::GetConfigurationLocation()) + return QDir(FileFunctions::get_configuration_location()) .filePath(QStringLiteral("shortcuts")); } -void LoadCustomShortcutsInternal(QMenu *menu, +void load_custom_shortcuts_internal(QMenu *menu, const QMap &shortcuts) { QList actions = menu->actions(); foreach (QAction *a, actions) { if (a->menu()) { - LoadCustomShortcutsInternal(a->menu(), shortcuts); + load_custom_shortcuts_internal(a->menu(), shortcuts); } else if (!a->isSeparator()) { QString action_id = a->property("id").toString(); @@ -733,9 +733,9 @@ void LoadCustomShortcutsInternal(QMenu *menu, } } -void MainWindow::LoadCustomShortcuts() +void MainWindow::load_custom_shortcuts() { - QFile shortcut_file(GetCustomShortcutsFile()); + QFile shortcut_file(get_custom_shortcuts_file()); if (shortcut_file.exists() && shortcut_file.open(QFile::ReadOnly)) { QMap shortcuts; @@ -756,19 +756,19 @@ void MainWindow::LoadCustomShortcuts() QList menus = menuBar()->actions(); foreach (QAction *menu, menus) { - LoadCustomShortcutsInternal(menu->menu(), shortcuts); + load_custom_shortcuts_internal(menu->menu(), shortcuts); } } } } -void SaveCustomShortcutsInternal(QMenu *menu, QMap *shortcuts) +void save_custom_shortcuts_internal(QMenu *menu, QMap *shortcuts) { QList actions = menu->actions(); foreach (QAction *a, actions) { if (a->menu()) { - SaveCustomShortcutsInternal(a->menu(), shortcuts); + save_custom_shortcuts_internal(a->menu(), shortcuts); } else if (!a->isSeparator()) { QString default_shortcut = a->property("keydefault").value().toString(); @@ -781,16 +781,16 @@ void SaveCustomShortcutsInternal(QMenu *menu, QMap *shortcuts) } } -void MainWindow::SaveCustomShortcuts() +void MainWindow::save_custom_shortcuts() { QMap shortcuts; QList menus = menuBar()->actions(); foreach (QAction *menu, menus) { - SaveCustomShortcutsInternal(menu->menu(), &shortcuts); + save_custom_shortcuts_internal(menu->menu(), &shortcuts); } - QFile shortcut_file(GetCustomShortcutsFile()); + QFile shortcut_file(get_custom_shortcuts_file()); if (shortcuts.isEmpty()) { if (shortcut_file.exists()) { // No custom shortcuts, remove any existing file @@ -812,75 +812,75 @@ void MainWindow::SaveCustomShortcuts() } } -void MainWindow::UpdateAudioMonitorParams(ViewerOutput *viewer) +void MainWindow::update_audio_monitor_params(ViewerOutput *viewer) { - if (!audio_monitor_panel_->IsPlaying()) { - audio_monitor_panel_->SetParams(viewer ? viewer->GetAudioParams() : + if (!audio_monitor_panel_->is_playing()) { + audio_monitor_panel_->set_params(viewer ? viewer->get_audio_params() : AudioParams()); } } -void MainWindow::UpdateNodePanelContextFromTimelinePanel(TimelinePanel *panel) +void MainWindow::update_node_panel_context_from_timeline_panel(TimelinePanel *panel) { // Add selected blocks (if any) - const QVector &blocks = panel->GetSelectedBlocks(); + const QVector &blocks = panel->get_selected_blocks(); QVector context(blocks.size()); for (int i = 0; i < blocks.size(); i++) { context[i] = blocks.at(i); } // If no selected blocks, set the context to the sequence - ViewerOutput *viewer = panel->GetConnectedViewer(); + ViewerOutput *viewer = panel->get_connected_viewer(); if (viewer && context.isEmpty()) { context.append(viewer); } - node_panel_->SetContexts(context); - param_panel_->SetContexts(context); + node_panel_->set_contexts(context); + param_panel_->set_contexts(context); } -void MainWindow::SelectFootageForProjectPanel(const QVector &e, +void MainWindow::select_footage_for_project_panel(const QVector &e, ProjectPanel *p) { - p->DeselectAll(); + p->deselect_all(); for (Footage *f : e) { - if (p->get_root()->HasChildRecursive(f)) { - p->SelectItem(f, false); + if (p->get_root()->has_child_recursive(f)) { + p->select_item(f, false); } } } -void MainWindow::FocusedPanelChanged(PanelWidget *panel) +void MainWindow::focused_panel_changed(PanelWidget *panel) { // Update audio monitor panel if (TimeBasedPanel *tbp = dynamic_cast(panel)) { - UpdateAudioMonitorParams(tbp->GetConnectedViewer()); + update_audio_monitor_params(tbp->get_connected_viewer()); } if (NodePanel *node_panel = dynamic_cast(panel)) { // Set param view contexts to these - const QVector &new_ctxs = node_panel->GetContexts(); + const QVector &new_ctxs = node_panel->get_contexts(); - if (new_ctxs != param_panel_->GetContexts()) { - param_panel_->SetContexts(new_ctxs); + if (new_ctxs != param_panel_->get_contexts()) { + param_panel_->set_contexts(new_ctxs); } } else if (TimelinePanel *timeline = dynamic_cast(panel)) { // Signal timeline focus - TimelineFocused(timeline->GetConnectedViewer()); + timeline_focused(timeline->get_connected_viewer()); - UpdateNodePanelContextFromTimelinePanel(timeline); + update_node_panel_context_from_timeline_panel(timeline); } else if (ProjectPanel *project = dynamic_cast(panel)) { // Signal project panel focus Q_UNUSED(project) - UpdateTitle(); + update_title(); } else if (ViewerPanelBase *viewer = dynamic_cast(panel)) { // Update scopes for viewer - scope_panel_->SetViewerPanel(viewer); + scope_panel_->set_viewer_panel(viewer); } } -void MainWindow::SetDefaultLayout() +void MainWindow::set_default_layout() { KDDockWidgets::InitialOption o; o.preferredSize = QSize(0, centralAreaGeometry().height()); @@ -943,7 +943,7 @@ void MainWindow::showEvent(QShowEvent *e) QMainWindow::showEvent(e); if (first_show_) { - QMetaObject::invokeMethod(Core::instance(), "CheckForAutoRecoveries", + QMetaObject::invokeMethod(Core::instance(), "check_for_auto_recoveries", Qt::QueuedConnection); #ifdef Q_OS_LINUX @@ -957,12 +957,12 @@ void MainWindow::showEvent(QShowEvent *e) context.functions()->glGetString(GL_VENDOR)); qDebug() << "Using graphics driver:" << vendor; if (!strcmp(vendor, "nouveau")) { - QMetaObject::invokeMethod(this, "ShowNouveauWarning", + QMetaObject::invokeMethod(this, "show_nouveau_warning", Qt::QueuedConnection); } #endif - QMetaObject::invokeMethod(this, "ShowWelcomeDialog", + QMetaObject::invokeMethod(this, "show_welcome_dialog", Qt::QueuedConnection); first_show_ = false; @@ -970,9 +970,9 @@ void MainWindow::showEvent(QShowEvent *e) } template -T *MainWindow::AppendPanelInternal(const QString &panel_name, QList &list) +T *MainWindow::append_panel_internal(const QString &panel_name, QList &list) { - T *panel = new T(TransformNameForSerialization(panel_name, list.size())); + T *panel = new T(transform_name_for_serialization(panel_name, list.size())); // For some reason raise() on its own doesn't do anything, we need both panel->show(); @@ -981,13 +981,13 @@ T *MainWindow::AppendPanelInternal(const QString &panel_name, QList &list) list.append(panel); // Let us handle the panel closing rather than the panel itself - panel->SetSignalInsteadOfClose(true); + panel->set_signal_instead_of_close(true); return panel; } template -void MainWindow::RemovePanelInternal(QList &list, T *panel) +void MainWindow::remove_panel_internal(QList &list, T *panel) { list.removeOne(panel); } diff --git a/app/window/mainwindow/mainwindow.h b/app/window/mainwindow/mainwindow.h index c4ae592e7..da4485b17 100644 --- a/app/window/mainwindow/mainwindow.h +++ b/app/window/mainwindow/mainwindow.h @@ -19,8 +19,8 @@ ***/ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H +#ifndef OAK_MAINWINDOW_H +#define OAK_MAINWINDOW_H #include #include @@ -61,21 +61,21 @@ public: virtual ~MainWindow() override; - void LoadLayout(const MainWindowLayoutInfo &info); + void load_layout(const MainWindowLayoutInfo &info); - MainWindowLayoutInfo SaveLayout() const; + MainWindowLayoutInfo save_layout() const; - TimelinePanel *OpenSequence(Sequence *sequence, bool enable_focus = true); + TimelinePanel *open_sequence(Sequence *sequence, bool enable_focus = true); - void CloseSequence(Sequence *sequence); + void close_sequence(Sequence *sequence); - bool IsSequenceOpen(Sequence *sequence) const; + bool is_sequence_open(Sequence *sequence) const; - void OpenFolder(Folder *i, bool floating); + void open_folder(Folder *i, bool floating); - void OpenNodeInViewer(ViewerOutput *node); + void open_node_in_viewer(ViewerOutput *node); - enum ProgressStatus { kProgressNone, kProgressShow, kProgressError }; + enum ProgressStatus { k_progress_none, k_progress_show, k_progress_error }; /** * @brief Where applicable, show progress on an operating system level @@ -83,25 +83,25 @@ public: * * For Windows, this is shown as progress in the taskbar. * * For macOS, this is shown as progress in the dock. */ - void SetApplicationProgressStatus(ProgressStatus status); + void set_application_progress_status(ProgressStatus status); /** * @brief If SetApplicationProgressStatus is set to kShowProgress, set the value with this * * Expects a percentage (0-100 inclusive). */ - void SetApplicationProgressValue(int value); + void set_application_progress_value(int value); - void SelectFootage(const QVector &e); + void select_footage(const QVector &e); public slots: - void SetProject(Project *p); + void set_project(Project *p); - void SetFullscreen(bool fullscreen); + void set_fullscreen(bool fullscreen); - void ToggleMaximizedPanel(); + void toggle_maximized_panel(); - void SetDefaultLayout(); + void set_default_layout(); protected: virtual void showEvent(QShowEvent *e) override; @@ -119,28 +119,28 @@ protected: #endif private: - TimelinePanel *AppendTimelinePanel(); + TimelinePanel *append_timeline_panel(); template - T *AppendPanelInternal(const QString &panel_name, QList &list); + T *append_panel_internal(const QString &panel_name, QList &list); - template void RemovePanelInternal(QList &list, T *panel); + template void remove_panel_internal(QList &list, T *panel); - void RemoveTimelinePanel(TimelinePanel *panel); + void remove_timeline_panel(TimelinePanel *panel); - void TimelineFocused(ViewerOutput *viewer); + void timeline_focused(ViewerOutput *viewer); - static QString GetCustomShortcutsFile(); + static QString get_custom_shortcuts_file(); - void LoadCustomShortcuts(); + void load_custom_shortcuts(); - void SaveCustomShortcuts(); + void save_custom_shortcuts(); - void UpdateAudioMonitorParams(ViewerOutput *viewer); + void update_audio_monitor_params(ViewerOutput *viewer); - void UpdateNodePanelContextFromTimelinePanel(TimelinePanel *panel); + void update_node_panel_context_from_timeline_panel(TimelinePanel *panel); - void SelectFootageForProjectPanel(const QVector &e, + void select_footage_for_project_panel(const QVector &e, ProjectPanel *p); QByteArray premaximized_state_; @@ -174,32 +174,32 @@ private: Project *project_; private slots: - void FocusedPanelChanged(PanelWidget *panel); + void focused_panel_changed(PanelWidget *panel); - void UpdateTitle(); + void update_title(); - void TimelineCloseRequested(); + void timeline_close_requested(); - void ViewerCloseRequested(); + void viewer_close_requested(); - void ViewerWithPanelRemovedFromGraph(); + void viewer_with_panel_removed_from_graph(); - void FolderPanelCloseRequested(); + void folder_panel_close_requested(); - void StatusBarDoubleClicked(); + void status_bar_double_clicked(); - void NodePanelGroupOpenedOrClosed(); + void node_panel_group_opened_or_closed(); #ifdef Q_OS_LINUX - void ShowNouveauWarning(); + void show_nouveau_warning(); #endif - void TimelinePanelSelectionChanged(const QVector &blocks); + void timeline_panel_selection_changed(const QVector &blocks); - void ShowWelcomeDialog(); + void show_welcome_dialog(); - void RevealViewerInProject(ViewerOutput *r); - void RevealViewerInFootageViewer(ViewerOutput *r, const TimeRange &range); + void reveal_viewer_in_project(ViewerOutput *r); + void reveal_viewer_in_footage_viewer(ViewerOutput *r, const TimeRange &range); }; } diff --git a/app/window/mainwindow/mainwindowlayoutinfo.cpp b/app/window/mainwindow/mainwindowlayoutinfo.cpp index 7486cca30..a72b3fe82 100644 --- a/app/window/mainwindow/mainwindowlayoutinfo.cpp +++ b/app/window/mainwindow/mainwindowlayoutinfo.cpp @@ -21,10 +21,10 @@ namespace olive { -void MainWindowLayoutInfo::toXml(QXmlStreamWriter *writer) const +void MainWindowLayoutInfo::to_xml(QXmlStreamWriter *writer) const { writer->writeAttribute(QStringLiteral("version"), - QString::number(kVersion)); + QString::number(k_version)); writer->writeStartElement(QStringLiteral("folders")); @@ -84,7 +84,7 @@ void MainWindowLayoutInfo::toXml(QXmlStreamWriter *writer) const } MainWindowLayoutInfo -MainWindowLayoutInfo::fromXml(QXmlStreamReader *reader, +MainWindowLayoutInfo::from_xml(QXmlStreamReader *reader, const QHash &node_ptrs) { MainWindowLayoutInfo info; @@ -99,12 +99,12 @@ MainWindowLayoutInfo::fromXml(QXmlStreamReader *reader, } // Really basic version checking, in the future we may use this to parse multiple versions - if (file_version != kVersion) { + if (file_version != k_version) { } - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("folders")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("folder")) { quintptr item_id = reader->readElementText().toULongLong(); @@ -117,7 +117,7 @@ MainWindowLayoutInfo::fromXml(QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("timeline")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("sequence")) { quintptr item_id = reader->readElementText().toULongLong(); @@ -130,7 +130,7 @@ MainWindowLayoutInfo::fromXml(QXmlStreamReader *reader, } } else if (reader->name() == QStringLiteral("viewers")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("viewer")) { quintptr item_id = reader->readElementText().toULongLong(); @@ -147,7 +147,7 @@ MainWindowLayoutInfo::fromXml(QXmlStreamReader *reader, QByteArray::fromBase64(reader->readElementText().toLatin1()); } else if (reader->name() == QStringLiteral("data")) { - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("panel")) { QString id; XMLAttributeLoop(reader, attr) @@ -160,7 +160,7 @@ MainWindowLayoutInfo::fromXml(QXmlStreamReader *reader, if (!id.isEmpty()) { PanelWidget::Info i; - while (XMLReadNextStartElement(reader)) { + while (xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("option")) { QString name; diff --git a/app/window/mainwindow/mainwindowlayoutinfo.h b/app/window/mainwindow/mainwindowlayoutinfo.h index a0ab80ff7..14aa7d1c1 100644 --- a/app/window/mainwindow/mainwindowlayoutinfo.h +++ b/app/window/mainwindow/mainwindowlayoutinfo.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef MAINWINDOWLAYOUTINFO_H -#define MAINWINDOWLAYOUTINFO_H +#ifndef OAK_MAINWINDOWLAYOUTINFO_H +#define OAK_MAINWINDOWLAYOUTINFO_H #include "node/project/folder/folder.h" #include "node/project/sequence/sequence.h" @@ -30,10 +30,10 @@ class MainWindowLayoutInfo { public: MainWindowLayoutInfo() = default; - void toXml(QXmlStreamWriter *writer) const; + void to_xml(QXmlStreamWriter *writer) const; static MainWindowLayoutInfo - fromXml(QXmlStreamReader *reader, const QHash &node_map); + from_xml(QXmlStreamReader *reader, const QHash &node_map); void add_folder(Folder *f); @@ -83,11 +83,11 @@ private: std::map panel_data_; - static const unsigned int kVersion = 1; + static const unsigned int k_version = 1; }; } Q_DECLARE_METATYPE(olive::MainWindowLayoutInfo) -#endif // MAINWINDOWLAYOUTINFO_H +#endif // OAK_MAINWINDOWLAYOUTINFO_H diff --git a/app/window/mainwindow/mainwindowundo.cpp b/app/window/mainwindow/mainwindowundo.cpp index 051083933..c3b7dc2db 100644 --- a/app/window/mainwindow/mainwindowundo.cpp +++ b/app/window/mainwindow/mainwindowundo.cpp @@ -29,22 +29,22 @@ namespace olive void OpenSequenceCommand::redo() { - Core::instance()->main_window()->OpenSequence(sequence_); + Core::instance()->main_window()->open_sequence(sequence_); } void OpenSequenceCommand::undo() { - Core::instance()->main_window()->CloseSequence(sequence_); + Core::instance()->main_window()->close_sequence(sequence_); } void CloseSequenceCommand::redo() { - Core::instance()->main_window()->CloseSequence(sequence_); + Core::instance()->main_window()->close_sequence(sequence_); } void CloseSequenceCommand::undo() { - Core::instance()->main_window()->OpenSequence(sequence_); + Core::instance()->main_window()->open_sequence(sequence_); } } diff --git a/app/window/mainwindow/mainwindowundo.h b/app/window/mainwindow/mainwindowundo.h index b0f2aa290..8daca4887 100644 --- a/app/window/mainwindow/mainwindowundo.h +++ b/app/window/mainwindow/mainwindowundo.h @@ -19,8 +19,8 @@ ***/ -#ifndef MAINWINDOWUNDO_H -#define MAINWINDOWUNDO_H +#ifndef OAK_MAINWINDOWUNDO_H +#define OAK_MAINWINDOWUNDO_H #include "node/project/sequence/sequence.h" @@ -34,7 +34,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nullptr; } @@ -55,7 +55,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nullptr; } @@ -71,4 +71,4 @@ private: } -#endif // MAINWINDOWUNDO_H +#endif // OAK_MAINWINDOWUNDO_H diff --git a/core/include/olive/core/core.h b/core/include/olive/core/core.h index ee62cf567..7d948523c 100644 --- a/core/include/olive/core/core.h +++ b/core/include/olive/core/core.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef LIBOLIVECORE_H -#define LIBOLIVECORE_H +#ifndef OAK_LIBOLIVECORE_H +#define OAK_LIBOLIVECORE_H #include "render/audioparams.h" #include "render/pixelformat.h" @@ -35,4 +35,4 @@ #include "util/timerange.h" #include "util/value.h" -#endif // LIBOLIVECORE_H +#endif // OAK_LIBOLIVECORE_H diff --git a/core/include/olive/core/render/audioparams.h b/core/include/olive/core/render/audioparams.h index 961885744..f4854fcd3 100644 --- a/core/include/olive/core/render/audioparams.h +++ b/core/include/olive/core/render/audioparams.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_AUDIOPARAMS_H -#define LIBOLIVECORE_AUDIOPARAMS_H +#ifndef OAK_LIBOLIVECORE_AUDIOPARAMS_H +#define OAK_LIBOLIVECORE_AUDIOPARAMS_H #include #include @@ -50,7 +50,7 @@ public: : sample_rate_(0) , channel_layout_mask_(0) , channel_count_(0) - , format_(SampleFormat::INVALID) + , format_(SampleFormat::invalid) { set_default_footage_parameters(); } @@ -99,19 +99,19 @@ public: channel_layout_mask_ = mask; calculate_channel_count(); } - rational time_base() const + Rational time_base() const { return timebase_; } - void set_time_base(const rational &timebase) + void set_time_base(const Rational &timebase) { timebase_ = timebase; } - rational sample_rate_as_time_base() const + Rational sample_rate_as_time_base() const { - return rational(1, sample_rate()); + return Rational(1, sample_rate()); } SampleFormat format() const @@ -155,17 +155,17 @@ public: } int64_t time_to_bytes(const double &time) const; - int64_t time_to_bytes(const rational &time) const; + int64_t time_to_bytes(const Rational &time) const; int64_t time_to_bytes_per_channel(const double &time) const; - int64_t time_to_bytes_per_channel(const rational &time) const; + int64_t time_to_bytes_per_channel(const Rational &time) const; int64_t time_to_samples(const double &time) const; - int64_t time_to_samples(const rational &time) const; + int64_t time_to_samples(const Rational &time) const; int64_t samples_to_bytes(const int64_t &samples) const; int64_t samples_to_bytes_per_channel(const int64_t &samples) const; - rational samples_to_time(const int64_t &samples) const; + Rational samples_to_time(const int64_t &samples) const; int64_t bytes_to_samples(const int64_t &bytes) const; - rational bytes_to_time(const int64_t &bytes) const; - rational bytes_per_channel_to_time(const int64_t &bytes) const; + Rational bytes_to_time(const int64_t &bytes) const; + Rational bytes_per_channel_to_time(const int64_t &bytes) const; int channel_count() const; int bytes_per_sample_per_channel() const; int bits_per_sample() const; @@ -174,8 +174,8 @@ public: bool operator==(const AudioParams &other) const; bool operator!=(const AudioParams &other) const; - static const std::vector kSupportedChannelLayouts; - static const std::vector kSupportedSampleRates; + static const std::vector k_supported_channel_layouts; + static const std::vector k_supported_sample_rates; private: void set_default_footage_parameters() @@ -209,9 +209,9 @@ private: int enabled_; // Using int instead of bool fixes GCC 11 stringop-overflow issue (byte alignment) int stream_index_; ///< Index in the source file's stream list int64_t duration_; ///< Stream duration in timebase units - rational timebase_; ///< Timebase for this audio stream + Rational timebase_; ///< Timebase for this audio stream }; } -#endif // LIBOLIVECORE_AUDIOPARAMS_H +#endif // OAK_LIBOLIVECORE_AUDIOPARAMS_H diff --git a/core/include/olive/core/render/channellayout.h b/core/include/olive/core/render/channellayout.h index 7e4c2ab40..ff2b0a607 100644 --- a/core/include/olive/core/render/channellayout.h +++ b/core/include/olive/core/render/channellayout.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_CHANNELLAYOUT_H -#define LIBOLIVECORE_CHANNELLAYOUT_H +#ifndef OAK_LIBOLIVECORE_CHANNELLAYOUT_H +#define OAK_LIBOLIVECORE_CHANNELLAYOUT_H #include @@ -35,16 +35,16 @@ namespace olive::core * straight through to the FFmpeg bridge library; the bridge unit tests * static_assert each value against the real FFmpeg headers. */ -inline constexpr uint64_t kChannelLayoutMono = 0x4; ///< AV_CH_LAYOUT_MONO -inline constexpr uint64_t kChannelLayoutStereo = 0x3; ///< AV_CH_LAYOUT_STEREO -inline constexpr uint64_t kChannelLayout2_1 = 0x103; ///< AV_CH_LAYOUT_2_1 -inline constexpr uint64_t kChannelLayout5Point1 = 0x60F; ///< AV_CH_LAYOUT_5POINT1 -inline constexpr uint64_t kChannelLayout7Point1 = 0x63F; ///< AV_CH_LAYOUT_7POINT1 +inline constexpr uint64_t k_channel_layout_mono = 0x4; ///< AV_CH_LAYOUT_MONO +inline constexpr uint64_t k_channel_layout_stereo = 0x3; ///< AV_CH_LAYOUT_STEREO +inline constexpr uint64_t k_channel_layout2_1 = 0x103; ///< AV_CH_LAYOUT_2_1 +inline constexpr uint64_t k_channel_layout5_point1 = 0x60F; ///< AV_CH_LAYOUT_5POINT1 +inline constexpr uint64_t k_channel_layout7_point1 = 0x63F; ///< AV_CH_LAYOUT_7POINT1 /** * @brief Number of channels in a layout mask (population count) */ -inline int ChannelLayoutMaskChannelCount(uint64_t mask) +inline int channel_layout_mask_channel_count(uint64_t mask) { #if defined(__GNUC__) || defined(__clang__) return __builtin_popcountll(mask); @@ -60,4 +60,4 @@ inline int ChannelLayoutMaskChannelCount(uint64_t mask) } -#endif // LIBOLIVECORE_CHANNELLAYOUT_H +#endif // OAK_LIBOLIVECORE_CHANNELLAYOUT_H diff --git a/core/include/olive/core/render/pixelformat.h b/core/include/olive/core/render/pixelformat.h index 52550399a..64dbe8e8d 100644 --- a/core/include/olive/core/render/pixelformat.h +++ b/core/include/olive/core/render/pixelformat.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_PIXELFORMAT_H -#define LIBOLIVECORE_PIXELFORMAT_H +#ifndef OAK_LIBOLIVECORE_PIXELFORMAT_H +#define OAK_LIBOLIVECORE_PIXELFORMAT_H #include "ofxCore.h" #include namespace olive::core @@ -28,9 +28,9 @@ namespace olive::core class PixelFormat { public: - enum Format { INVALID = -1, U8, U10, U16, F16, F32, COUNT }; + enum Format { invalid = -1, u8, u10, u16, f16, f32, count }; - PixelFormat(Format f = INVALID) + PixelFormat(Format f = invalid) { f_ = f; } @@ -40,35 +40,35 @@ public: return f_; } - static PixelFormat from_ofx(std::string ofxFormat){ - if(ofxFormat == kOfxBitDepthByte){ - return PixelFormat::U8; + static PixelFormat from_ofx(std::string ofx_format){ + if(ofx_format == kOfxBitDepthByte){ + return PixelFormat::u8; } - else if (ofxFormat == kOfxBitDepthShort){ - return PixelFormat::U16; + else if (ofx_format == kOfxBitDepthShort){ + return PixelFormat::u16; } - else if(ofxFormat == kOfxBitDepthHalf){ - return PixelFormat::F16; + else if(ofx_format == kOfxBitDepthHalf){ + return PixelFormat::f16; } - else if(ofxFormat == kOfxBitDepthFloat){ - return PixelFormat::F32; + else if(ofx_format == kOfxBitDepthFloat){ + return PixelFormat::f32; } - return PixelFormat::INVALID; + return PixelFormat::invalid; } static int byte_count(Format f) { switch (f) { - case INVALID: - case COUNT: + case invalid: + case count: break; - case U8: + case u8: return 1; - case U10: + case u10: return 4; // packed RGBA10A2, treated as 4 bytes per pixel - case U16: - case F16: + case u16: + case f16: return 2; - case F32: + case f32: return 4; } @@ -78,18 +78,18 @@ public: const char *to_string() const { switch (f_) { - case U8: + case u8: return "u8"; - case U10: + case u10: return "u10"; - case U16: + case u16: return "u16"; - case F16: + case f16: return "f16"; - case F32: + case f32: return "f32"; - case INVALID: - case COUNT: + case invalid: + case count: break; } @@ -104,14 +104,14 @@ public: static bool is_float(Format f) { switch (f) { - case INVALID: - case COUNT: - case U8: - case U10: - case U16: + case invalid: + case count: + case u8: + case u10: + case u16: break; - case F16: - case F32: + case f16: + case f32: return true; } @@ -129,4 +129,4 @@ private: } -#endif // LIBOLIVECORE_PIXELFORMAT_H +#endif // OAK_LIBOLIVECORE_PIXELFORMAT_H diff --git a/core/include/olive/core/render/samplebuffer.h b/core/include/olive/core/render/samplebuffer.h index f8ac1a70c..179913d68 100644 --- a/core/include/olive/core/render/samplebuffer.h +++ b/core/include/olive/core/render/samplebuffer.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_SAMPLEBUFFER_H -#define LIBOLIVECORE_SAMPLEBUFFER_H +#ifndef OAK_LIBOLIVECORE_SAMPLEBUFFER_H +#define OAK_LIBOLIVECORE_SAMPLEBUFFER_H #include #include @@ -42,7 +42,7 @@ namespace olive::core class SampleBuffer { public: SampleBuffer(); - SampleBuffer(const AudioParams &audio_params, const rational &length); + SampleBuffer(const AudioParams &audio_params, const Rational &length); SampleBuffer(const AudioParams &audio_params, size_t samples_per_channel); SampleBuffer rip_channel(int channel) const; @@ -56,7 +56,7 @@ public: return sample_count_per_channel_; } void set_sample_count(const size_t &sample_count); - void set_sample_count(const rational &length) + void set_sample_count(const Rational &length) { set_sample_count(audio_params_.time_to_samples(length)); } @@ -134,4 +134,4 @@ private: } -#endif // LIBOLIVECORE_SAMPLEBUFFER_H +#endif // OAK_LIBOLIVECORE_SAMPLEBUFFER_H diff --git a/core/include/olive/core/render/sampleformat.h b/core/include/olive/core/render/sampleformat.h index e96d482a6..a1c6f466b 100644 --- a/core/include/olive/core/render/sampleformat.h +++ b/core/include/olive/core/render/sampleformat.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_SAMPLEFORMAT_H -#define LIBOLIVECORE_SAMPLEFORMAT_H +#ifndef OAK_LIBOLIVECORE_SAMPLEFORMAT_H +#define OAK_LIBOLIVECORE_SAMPLEFORMAT_H #include #include @@ -31,31 +31,31 @@ namespace olive::core class SampleFormat { public: enum Format { - INVALID = -1, + invalid = -1, - U8P, - S16P, - S32P, - S64P, - F32P, - F64P, + u8_p, + s16_p, + s32_p, + s64_p, + f32_p, + f64_p, - U8, - S16, - S32, - S64, - F32, - F64, + u8, + s16, + s32, + s64, + f32, + f64, - COUNT, + count, - PLANAR_START = U8P, - PACKED_START = U8, - PLANAR_END = PACKED_START, - PACKED_END = COUNT, + planar_start = u8_p, + packed_start = u8, + planar_end = packed_start, + packed_end = count, }; - SampleFormat(Format f = INVALID) + SampleFormat(Format f = invalid) { f_ = f; } @@ -68,24 +68,24 @@ public: static int byte_count(Format f) { switch (f) { - case U8: - case U8P: + case u8: + case u8_p: return 1; - case S16: - case S16P: + case s16: + case s16_p: return 2; - case S32: - case F32: - case S32P: - case F32P: + case s32: + case f32: + case s32_p: + case f32_p: return 4; - case S64: - case F64: - case S64P: - case F64P: + case s64: + case f64: + case s64_p: + case f64_p: return 8; - case INVALID: - case COUNT: + case invalid: + case count: break; } @@ -100,32 +100,32 @@ public: static std::string to_string(Format f) { switch (f) { - case INVALID: - case COUNT: + case invalid: + case count: break; - case U8: + case u8: return "u8"; - case S16: + case s16: return "s16"; - case S32: + case s32: return "s32"; - case S64: + case s64: return "s64"; - case F32: + case f32: return "f32"; - case F64: + case f64: return "f64"; - case U8P: + case u8_p: return "u8p"; - case S16P: + case s16_p: return "s16p"; - case S32P: + case s32_p: return "s32p"; - case S64P: + case s64_p: return "s64p"; - case F32P: + case f32_p: return "f32p"; - case F64P: + case f64_p: return "f64p"; } @@ -140,50 +140,50 @@ public: static SampleFormat from_string(const std::string &s) { if (s.empty()) { - return INVALID; + return invalid; } else if (s == "u8") { - return U8; + return u8; } else if (s == "s16") { - return S16; + return s16; } else if (s == "s32") { - return S32; + return s32; } else if (s == "s64") { - return S64; + return s64; } else if (s == "f32") { - return F32; + return f32; } else if (s == "f64") { - return F64; + return f64; } else if (s == "u8p") { - return U8P; + return u8_p; } else if (s == "s16p") { - return S16P; + return s16_p; } else if (s == "s32p") { - return S32P; + return s32_p; } else if (s == "s64p") { - return S64P; + return s64_p; } else if (s == "f32p") { - return F32P; + return f32_p; } else if (s == "f64p") { - return F64P; + return f64_p; } else { // Deprecated: sample formats used to be serialized as an integer. Handle that here, but we'll // probably remove that eventually. try { int i = std::stoi(s); - if (i > INVALID && i < COUNT) { + if (i > invalid && i < count) { return static_cast(i); } } catch (const std::invalid_argument &e) { } // Failed to deserialize from string - return INVALID; + return invalid; } } static bool is_packed(Format f) { - return f >= PACKED_START && f < PACKED_END; + return f >= packed_start && f < packed_end; } bool is_packed() const @@ -193,7 +193,7 @@ public: static bool is_planar(Format f) { - return f >= PLANAR_START && f < PLANAR_END; + return f >= planar_start && f < planar_end; } bool is_planar() const @@ -205,34 +205,34 @@ public: { switch (fmt) { // For packed input, just return input - case U8: - case S16: - case S32: - case S64: - case F32: - case F64: + case u8: + case s16: + case s32: + case s64: + case f32: + case f64: return fmt; // Convert to packed - case U8P: - return U8; - case S16P: - return S16; - case S32P: - return S32; - case S64P: - return S64; - case F32P: - return F32; - case F64P: - return F64; + case u8_p: + return u8; + case s16_p: + return s16; + case s32_p: + return s32; + case s64_p: + return s64; + case f32_p: + return f32; + case f64_p: + return f64; - case INVALID: - case COUNT: + case invalid: + case count: break; } - return INVALID; + return invalid; } SampleFormat to_packed_equivalent() const @@ -244,34 +244,34 @@ public: { switch (fmt) { // Convert to planar - case U8: - return U8P; - case S16: - return S16P; - case S32: - return S32P; - case S64: - return S64P; - case F32: - return F32P; - case F64: - return F64P; + case u8: + return u8_p; + case s16: + return s16_p; + case s32: + return s32_p; + case s64: + return s64_p; + case f32: + return f32_p; + case f64: + return f64_p; // For planar input, just return input - case U8P: - case S16P: - case S32P: - case S64P: - case F32P: - case F64P: + case u8_p: + case s16_p: + case s32_p: + case s64_p: + case f32_p: + case f64_p: return fmt; - case INVALID: - case COUNT: + case invalid: + case count: break; } - return INVALID; + return invalid; } SampleFormat to_planar_equivalent() const @@ -285,4 +285,4 @@ private: } -#endif // LIBOLIVECORE_SAMPLEFORMAT_H +#endif // OAK_LIBOLIVECORE_SAMPLEFORMAT_H diff --git a/core/include/olive/core/util/bezier.h b/core/include/olive/core/util/bezier.h index c5e140e74..43fd07561 100644 --- a/core/include/olive/core/util/bezier.h +++ b/core/include/olive/core/util/bezier.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_BEZIER_H -#define LIBOLIVECORE_BEZIER_H +#ifndef OAK_LIBOLIVECORE_BEZIER_H +#define OAK_LIBOLIVECORE_BEZIER_H #include @@ -99,28 +99,28 @@ public: cp2_y_ = cp2_y; } - static double QuadraticXtoT(double x, double a, double b, double c); + static double quadratic_xto_t(double x, double a, double b, double c); - static double QuadraticTtoY(double a, double b, double c, double t); + static double quadratic_tto_y(double a, double b, double c, double t); - static double QuadraticXtoY(double x, const Imath::V2d &a, + static double quadratic_xto_y(double x, const Imath::V2d &a, const Imath::V2d &b, const Imath::V2d &c) { - return QuadraticTtoY(a.y, b.y, c.y, QuadraticXtoT(x, a.x, b.x, c.x)); + return quadratic_tto_y(a.y, b.y, c.y, quadratic_xto_t(x, a.x, b.x, c.x)); } - static double CubicXtoT(double x, double a, double b, double c, double d); + static double cubic_xto_t(double x, double a, double b, double c, double d); - static double CubicTtoY(double a, double b, double c, double d, double t); + static double cubic_tto_y(double a, double b, double c, double d, double t); - static double CubicXtoY(double x, const Imath::V2d &a, const Imath::V2d &b, + static double cubic_xto_y(double x, const Imath::V2d &a, const Imath::V2d &b, const Imath::V2d &c, const Imath::V2d &d) { - return CubicTtoY(a.y, b.y, c.y, d.y, CubicXtoT(x, a.x, b.x, c.x, d.x)); + return cubic_tto_y(a.y, b.y, c.y, d.y, cubic_xto_t(x, a.x, b.x, c.x, d.x)); } private: - static double CalculateTFromX(bool cubic, double x, double a, double b, + static double calculate_t_from_x(bool cubic, double x, double a, double b, double c, double d); double x_; @@ -135,4 +135,4 @@ private: } -#endif // LIBOLIVECORE_BEZIER_H +#endif // OAK_LIBOLIVECORE_BEZIER_H diff --git a/core/include/olive/core/util/color.h b/core/include/olive/core/util/color.h index d5fef8c1b..6101de2fe 100644 --- a/core/include/olive/core/util/color.h +++ b/core/include/olive/core/util/color.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_COLOR_H -#define LIBOLIVECORE_COLOR_H +#ifndef OAK_LIBOLIVECORE_COLOR_H +#define OAK_LIBOLIVECORE_COLOR_H #include "../render/pixelformat.h" @@ -33,11 +33,11 @@ namespace olive::core class Color { public: using DataType = float; - static constexpr unsigned int RGBA = 4; + static constexpr unsigned int rgba = 4; Color() { - for (unsigned int i = 0; i < RGBA; i++) { + for (unsigned int i = 0; i < rgba; i++) { data_[i] = 0.0; } } @@ -58,7 +58,7 @@ public: * * Hue expects a value between 0.0 and 360.0. Saturation and Value expect a value between 0.0 and 1.0. */ - static Color fromHsv(const DataType &h, const DataType &s, + static Color from_hsv(const DataType &h, const DataType &s, const DataType &v); const DataType &red() const @@ -78,12 +78,12 @@ public: return data_[3]; } - void toHsv(DataType *hue, DataType *sat, DataType *val) const; + void to_hsv(DataType *hue, DataType *sat, DataType *val) const; DataType hsv_hue() const; DataType hsv_saturation() const; DataType value() const; - void toHsl(DataType *hue, DataType *sat, DataType *lightness) const; + void to_hsl(DataType *hue, DataType *sat, DataType *lightness) const; DataType hsl_hue() const; DataType hsl_saturation() const; DataType lightness() const; @@ -114,15 +114,15 @@ public: return data_; } - void toData(char *out, const PixelFormat &format, + void to_data(char *out, const PixelFormat &format, unsigned int nb_channels) const; - static Color fromData(const char *in, const PixelFormat &format, + static Color from_data(const char *in, const PixelFormat &format, unsigned int nb_channels); // Suuuuper rough luminance value mostly used for UI (determining whether to overlay with black // or white text) - DataType GetRoughLuminance() const; + DataType get_rough_luminance() const; // Assignment math operators Color &operator+=(const Color &rhs); @@ -176,9 +176,9 @@ public: } private: - DataType data_[RGBA]; + DataType data_[rgba]; }; } -#endif // LIBOLIVECORE_COLOR_H +#endif // OAK_LIBOLIVECORE_COLOR_H diff --git a/core/include/olive/core/util/cpuoptimize.h b/core/include/olive/core/util/cpuoptimize.h index 9e4234994..965153a33 100644 --- a/core/include/olive/core/util/cpuoptimize.h +++ b/core/include/olive/core/util/cpuoptimize.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef LIBOLIVECORE_CPUOPTIMIZE_H -#define LIBOLIVECORE_CPUOPTIMIZE_H +#ifndef OAK_LIBOLIVECORE_CPUOPTIMIZE_H +#define OAK_LIBOLIVECORE_CPUOPTIMIZE_H #if defined(__x86_64__) || defined(__i386__) #define OLIVE_PROCESSOR_X86 @@ -27,4 +27,4 @@ #include "sse2neon.h" #endif -#endif // LIBOLIVECORE_CPUOPTIMIZE_H +#endif // OAK_LIBOLIVECORE_CPUOPTIMIZE_H diff --git a/core/include/olive/core/util/fractionutils.h b/core/include/olive/core/util/fractionutils.h index 70fee45c8..77b2ece9e 100644 --- a/core/include/olive/core/util/fractionutils.h +++ b/core/include/olive/core/util/fractionutils.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_FRACTIONUTILS_H -#define LIBOLIVECORE_FRACTIONUTILS_H +#ifndef OAK_LIBOLIVECORE_FRACTIONUTILS_H +#define OAK_LIBOLIVECORE_FRACTIONUTILS_H #include @@ -38,12 +38,12 @@ enum class FractionRounding { * Round to the nearest value; halfway cases are rounded away from zero. * Equivalent to FFmpeg's AV_ROUND_NEAR_INF. */ - kNearInf, + k_near_inf, /** * Round toward positive infinity. Equivalent to FFmpeg's AV_ROUND_UP. */ - kUp + k_up }; /** @@ -55,7 +55,7 @@ enum class FractionRounding { * * A zero denominator is preserved (with the numerator set to zero). */ -void ReduceFraction(int64_t &num, int64_t &den, int64_t max); +void reduce_fraction(int64_t &num, int64_t &den, int64_t max); /** * @brief Compare two fractions @@ -64,7 +64,7 @@ void ReduceFraction(int64_t &num, int64_t &den, int64_t max); * 0 if a == b, 1 if a > b, and INT_MIN when the comparison is meaningless * (degenerate zero-denominator fractions). */ -int CompareFractions(int an, int ad, int bn, int bd); +int compare_fractions(int an, int ad, int bn, int bd); /** * @brief Rescale `a` by the fraction b/c: returns a * b / c @@ -73,8 +73,8 @@ int CompareFractions(int an, int ad, int bn, int bd); * product is computed with 128-bit arithmetic where available so that no * precision is lost for large timestamps. */ -int64_t RescaleRnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd); +int64_t rescale_rnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd); } -#endif // LIBOLIVECORE_FRACTIONUTILS_H +#endif // OAK_LIBOLIVECORE_FRACTIONUTILS_H diff --git a/core/include/olive/core/util/log.h b/core/include/olive/core/util/log.h index 65f71cac0..712b17e75 100644 --- a/core/include/olive/core/util/log.h +++ b/core/include/olive/core/util/log.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef LOG_H -#define LOG_H +#ifndef OAK_LOG_H +#define OAK_LOG_H #include @@ -42,22 +42,22 @@ public: return *this; } - static Log Debug() + static Log debug() { return Log("DEBUG"); } - static Log Info() + static Log info() { return Log("INFO"); } - static Log Warning() + static Log warning() { return Log("WARNING"); } - static Log Error() + static Log error() { return Log("ERROR"); } @@ -65,4 +65,4 @@ public: } -#endif // LOG_H +#endif // OAK_LOG_H diff --git a/core/include/olive/core/util/math.h b/core/include/olive/core/util/math.h index bb15b122d..366d7ccf8 100644 --- a/core/include/olive/core/util/math.h +++ b/core/include/olive/core/util/math.h @@ -19,12 +19,12 @@ ***/ -#ifndef LIBOLIVECORE_MATH_H -#define LIBOLIVECORE_MATH_H +#ifndef OAK_LIBOLIVECORE_MATH_H +#define OAK_LIBOLIVECORE_MATH_H namespace olive::core { } -#endif // LIBOLIVECORE_MATH_H +#endif // OAK_LIBOLIVECORE_MATH_H diff --git a/core/include/olive/core/util/rational.h b/core/include/olive/core/util/rational.h index 523209c6f..9b705dbae 100644 --- a/core/include/olive/core/util/rational.h +++ b/core/include/olive/core/util/rational.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_RATIONAL_H -#define LIBOLIVECORE_RATIONAL_H +#ifndef OAK_LIBOLIVECORE_RATIONAL_H +#define OAK_LIBOLIVECORE_RATIONAL_H #include #include @@ -32,15 +32,15 @@ namespace olive::core { -class rational { +class Rational { public: - rational(const int &numerator = 0) + Rational(const int &numerator = 0) { num_ = numerator; den_ = 1; } - rational(const int &numerator, const int &denominator) + Rational(const int &numerator, const int &denominator) { num_ = numerator; den_ = denominator; @@ -49,42 +49,42 @@ public: reduce(); } - rational(const rational &rhs) = default; + Rational(const Rational &rhs) = default; - static rational fromDouble(const double &flt, bool *ok = nullptr); - static rational fromString(const std::string &str, bool *ok = nullptr); + static Rational from_double(const double &flt, bool *ok = nullptr); + static Rational from_string(const std::string &str, bool *ok = nullptr); - static const rational NaN; + static const Rational na_n; //Assignment Operators - const rational &operator=(const rational &rhs); - const rational &operator+=(const rational &rhs); - const rational &operator-=(const rational &rhs); - const rational &operator/=(const rational &rhs); - const rational &operator*=(const rational &rhs); + const Rational &operator=(const Rational &rhs); + const Rational &operator+=(const Rational &rhs); + const Rational &operator-=(const Rational &rhs); + const Rational &operator/=(const Rational &rhs); + const Rational &operator*=(const Rational &rhs); //Binary math operators - rational operator+(const rational &rhs) const; - rational operator-(const rational &rhs) const; - rational operator/(const rational &rhs) const; - rational operator*(const rational &rhs) const; + Rational operator+(const Rational &rhs) const; + Rational operator-(const Rational &rhs) const; + Rational operator/(const Rational &rhs) const; + Rational operator*(const Rational &rhs) const; //Relational and equality operators - bool operator<(const rational &rhs) const; - bool operator<=(const rational &rhs) const; - bool operator>(const rational &rhs) const; - bool operator>=(const rational &rhs) const; - bool operator==(const rational &rhs) const; - bool operator!=(const rational &rhs) const; + bool operator<(const Rational &rhs) const; + bool operator<=(const Rational &rhs) const; + bool operator>(const Rational &rhs) const; + bool operator>=(const Rational &rhs) const; + bool operator==(const Rational &rhs) const; + bool operator!=(const Rational &rhs) const; //Unary operators - const rational &operator+() const + const Rational &operator+() const { return *this; } - rational operator-() const + Rational operator-() const { - return rational(num_, -den_); + return Rational(num_, -den_); } bool operator!() const { @@ -92,10 +92,10 @@ public: } //Function: convert to double - double toDouble() const; + double to_double() const; #ifdef USE_OTIO - static rational fromRationalTime(const opentime::RationalTime &t) + static Rational fromRationalTime(const opentime::RationalTime &t) { // Is this the best way to do this? return fromDouble(t.to_seconds()); @@ -106,10 +106,10 @@ public: #endif // Produce "flipped" version - rational flipped() const; + Rational flipped() const; void flip(); - // Returns whether the rational is valid but equal to zero or not + // Returns whether the Rational is valid but equal to zero or not // // A NaN is always a null, but a null is not always a NaN bool isNull() const @@ -117,7 +117,7 @@ public: return num_ == 0; } - // Returns whether this rational is not a valid number (denominator == 0) + // Returns whether this Rational is not a valid number (denominator == 0) bool isNaN() const { return den_ == 0; @@ -132,9 +132,9 @@ public: return den_; } - std::string toString() const; + std::string to_string() const; - friend std::ostream &operator<<(std::ostream &out, const rational &value) + friend std::ostream &operator<<(std::ostream &out, const Rational &value) { out << value.num_ << '/' << value.den_; @@ -149,9 +149,9 @@ private: int den_; }; -#define RATIONAL_MIN rational(INT_MIN) -#define RATIONAL_MAX rational(INT_MAX) +#define RATIONAL_MIN Rational(INT_MIN) +#define RATIONAL_MAX Rational(INT_MAX) } -#endif // LIBOLIVECORE_RATIONAL_H +#endif // OAK_LIBOLIVECORE_RATIONAL_H diff --git a/core/include/olive/core/util/sse2neon.h b/core/include/olive/core/util/sse2neon.h index 62338db9d..93e43d9bf 100644 --- a/core/include/olive/core/util/sse2neon.h +++ b/core/include/olive/core/util/sse2neon.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef SSE2NEON_H -#define SSE2NEON_H +#ifndef OAK_SSE2NEON_H +#define OAK_SSE2NEON_H // This header file provides a simple API translation layer // between SSE intrinsics to their corresponding Arm/Aarch64 NEON versions diff --git a/core/include/olive/core/util/stringutils.h b/core/include/olive/core/util/stringutils.h index 8ac0dad97..5277aa759 100644 --- a/core/include/olive/core/util/stringutils.h +++ b/core/include/olive/core/util/stringutils.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_STRINGUTILS_H -#define LIBOLIVECORE_STRINGUTILS_H +#ifndef OAK_LIBOLIVECORE_STRINGUTILS_H +#define OAK_LIBOLIVECORE_STRINGUTILS_H #include #include @@ -208,4 +208,4 @@ public: } -#endif // LIBOLIVECORE_STRINGUTILS_H +#endif // OAK_LIBOLIVECORE_STRINGUTILS_H diff --git a/core/include/olive/core/util/tests.h b/core/include/olive/core/util/tests.h index 09296aff4..61fae1240 100644 --- a/core/include/olive/core/util/tests.h +++ b/core/include/olive/core/util/tests.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_TESTS_H -#define LIBOLIVECORE_TESTS_H +#ifndef OAK_LIBOLIVECORE_TESTS_H +#define OAK_LIBOLIVECORE_TESTS_H #include @@ -59,4 +59,4 @@ private: } -#endif // LIBOLIVECORE_TESTS_H +#endif // OAK_LIBOLIVECORE_TESTS_H diff --git a/core/include/olive/core/util/timecodefunctions.h b/core/include/olive/core/util/timecodefunctions.h index 0e4b4dde6..1f532665a 100644 --- a/core/include/olive/core/util/timecodefunctions.h +++ b/core/include/olive/core/util/timecodefunctions.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_TIMECODEFUNCTIONS_H -#define LIBOLIVECORE_TIMECODEFUNCTIONS_H +#ifndef OAK_LIBOLIVECORE_TIMECODEFUNCTIONS_H +#define OAK_LIBOLIVECORE_TIMECODEFUNCTIONS_H #include "rational.h" @@ -34,7 +34,7 @@ namespace olive::core * * Olive uses the following terminology through its code: * - * `time` - time in seconds presented in a rational form + * `time` - time in seconds presented in a Rational form * `timebase` - the base time unit of an audio/video stream in seconds * `timestamp` - an integer representation of a time in timebase units (in many cases is used like a frame number) * `timecode` a user-friendly string representation of a time according to Timecode::Display @@ -42,52 +42,52 @@ namespace olive::core class Timecode { public: enum Display { - kTimecodeDropFrame, - kTimecodeNonDropFrame, - kTimecodeSeconds, - kFrames, - kMilliseconds + k_timecode_drop_frame, + k_timecode_non_drop_frame, + k_timecode_seconds, + k_frames, + k_milliseconds }; - enum Rounding { kCeil, kFloor, kRound }; + enum Rounding { k_ceil, k_floor, k_round }; /** - * @brief Convert a timestamp (according to a rational timebase) to a user-friendly string representation + * @brief Convert a timestamp (according to a Rational timebase) to a user-friendly string representation */ - static std::string time_to_timecode(const rational &time, - const rational &timebase, + static std::string time_to_timecode(const Rational &time, + const Rational &timebase, const Display &display, bool show_plus_if_positive = false); - static rational timecode_to_time(std::string timecode, - const rational &timebase, + static Rational timecode_to_time(std::string timecode, + const Rational &timebase, const Display &display, bool *ok = nullptr); static std::string time_to_string(int64_t ms); - static rational snap_time_to_timebase(const rational &time, - const rational &timebase, - Rounding floor = kRound); + static Rational snap_time_to_timebase(const Rational &time, + const Rational &timebase, + Rounding floor = k_round); - static int64_t time_to_timestamp(const rational &time, - const rational &timebase, - Rounding floor = kRound); + static int64_t time_to_timestamp(const Rational &time, + const Rational &timebase, + Rounding floor = k_round); static int64_t time_to_timestamp(const double &time, - const rational &timebase, - Rounding floor = kRound); + const Rational &timebase, + Rounding floor = k_round); - static int64_t rescale_timestamp(const int64_t &ts, const rational &source, - const rational &dest); + static int64_t rescale_timestamp(const int64_t &ts, const Rational &source, + const Rational &dest); static int64_t rescale_timestamp_ceil(const int64_t &ts, - const rational &source, - const rational &dest); + const Rational &source, + const Rational &dest); - static rational timestamp_to_time(const int64_t ×tamp, - const rational &timebase); + static Rational timestamp_to_time(const int64_t ×tamp, + const Rational &timebase); - static bool timebase_is_drop_frame(const rational &timebase); + static bool timebase_is_drop_frame(const Rational &timebase); }; } -#endif // LIBOLIVECORE_TIMECODEFUNCTIONS_H +#endif // OAK_LIBOLIVECORE_TIMECODEFUNCTIONS_H diff --git a/core/include/olive/core/util/timerange.h b/core/include/olive/core/util/timerange.h index 72918d90c..68cbd87bc 100644 --- a/core/include/olive/core/util/timerange.h +++ b/core/include/olive/core/util/timerange.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_TIMERANGE_H -#define LIBOLIVECORE_TIMERANGE_H +#ifndef OAK_LIBOLIVECORE_TIMERANGE_H +#define OAK_LIBOLIVECORE_TIMERANGE_H #include #include @@ -33,7 +33,7 @@ namespace olive::core class TimeRange { public: TimeRange() = default; - TimeRange(const rational &in, const rational &out); + TimeRange(const Rational &in, const Rational &out); TimeRange(const TimeRange &r) : TimeRange(r.in(), r.out()) { @@ -45,42 +45,42 @@ public: return *this; } - const rational &in() const; - const rational &out() const; - const rational &length() const; + const Rational &in() const; + const Rational &out() const; + const Rational &length() const; - void set_in(const rational &in); - void set_out(const rational &out); - void set_range(const rational &in, const rational &out); + void set_in(const Rational &in); + void set_out(const Rational &out); + void set_range(const Rational &in, const Rational &out); bool operator==(const TimeRange &r) const; bool operator!=(const TimeRange &r) const; - bool OverlapsWith(const TimeRange &a, bool in_inclusive = true, + bool overlaps_with(const TimeRange &a, bool in_inclusive = true, bool out_inclusive = true) const; - bool Contains(const TimeRange &a, bool in_inclusive = true, + bool contains(const TimeRange &a, bool in_inclusive = true, bool out_inclusive = true) const; - bool Contains(const rational &r) const; + bool contains(const Rational &r) const; - TimeRange Combined(const TimeRange &a) const; - static TimeRange Combine(const TimeRange &a, const TimeRange &b); - TimeRange Intersected(const TimeRange &a) const; - static TimeRange Intersect(const TimeRange &a, const TimeRange &b); + TimeRange combined(const TimeRange &a) const; + static TimeRange combine(const TimeRange &a, const TimeRange &b); + TimeRange intersected(const TimeRange &a) const; + static TimeRange intersect(const TimeRange &a, const TimeRange &b); - TimeRange operator+(const rational &rhs) const; - TimeRange operator-(const rational &rhs) const; + TimeRange operator+(const Rational &rhs) const; + TimeRange operator-(const Rational &rhs) const; - const TimeRange &operator+=(const rational &rhs); - const TimeRange &operator-=(const rational &rhs); + const TimeRange &operator+=(const Rational &rhs); + const TimeRange &operator-=(const Rational &rhs); - std::list Split(const int &chunk_size) const; + std::list split(const int &chunk_size) const; private: void normalize(); - rational in_; - rational out_; - rational length_; + Rational in_; + Rational out_; + Rational length_; }; class TimeRangeList { @@ -106,11 +106,11 @@ public: for (auto it = list->begin(); it != list->end();) { T &compare = *it; - if (remove.Contains(compare)) { + if (remove.contains(compare)) { // This element is entirely encompassed in this range, remove it it = list->erase(it); } else { - if (compare.Contains(remove, false, false)) { + if (compare.contains(remove, false, false)) { // The remove range is within this element, only choice is to split the element into two T new_range = compare; new_range.set_in(remove.out()); @@ -140,10 +140,10 @@ public: bool contains(const TimeRange &range, bool in_inclusive = true, bool out_inclusive = true) const; - bool contains(const rational &r) const + bool contains(const Rational &r) const { for (const TimeRange &range : array_) { - if (range.Contains(r)) { + if (range.contains(r)) { return true; } } @@ -151,11 +151,11 @@ public: return false; } - bool OverlapsWith(const TimeRange &r, bool in_inclusive = true, + bool overlaps_with(const TimeRange &r, bool in_inclusive = true, bool out_inclusive = true) const { for (const TimeRange &range : array_) { - if (range.OverlapsWith(r, in_inclusive, out_inclusive)) { + if (range.overlaps_with(r, in_inclusive, out_inclusive)) { return true; } } @@ -178,13 +178,13 @@ public: return array_.size(); } - void shift(const rational &diff); + void shift(const Rational &diff); - void trim_in(const rational &diff); + void trim_in(const Rational &diff); - void trim_out(const rational &diff); + void trim_out(const Rational &diff); - TimeRangeList Intersects(const TimeRange &range) const; + TimeRangeList intersects(const TimeRange &range) const; using const_iterator = std::vector::const_iterator; @@ -241,20 +241,20 @@ class TimeRangeListFrameIterator { public: TimeRangeListFrameIterator(); TimeRangeListFrameIterator(const TimeRangeList &list, - const rational &timebase); + const Rational &timebase); - rational Snap(const rational &r) const; + Rational snap(const Rational &r) const; - bool GetNext(rational *out); + bool get_next(Rational *out); - bool HasNext() const; + bool has_next() const; - std::vector ToVector() const + std::vector to_vector() const { TimeRangeListFrameIterator copy(list_, timebase_); - std::vector times; - rational r; - while (copy.GetNext(&r)) { + std::vector times; + Rational r; + while (copy.get_next(&r)) { times.push_back(r); } return times; @@ -277,12 +277,12 @@ public: list_.insert(list); } - bool IsCustomRange() const + bool is_custom_range() const { return custom_range_; } - void SetCustomRange(bool e) + void set_custom_range(bool e) { custom_range_ = e; } @@ -293,13 +293,13 @@ public: } private: - void UpdateIndexIfNecessary(); + void update_index_if_necessary(); TimeRangeList list_; - rational timebase_; + Rational timebase_; - rational current_; + Rational current_; int range_index_; @@ -312,4 +312,4 @@ private: } -#endif // LIBOLIVECORE_TIMERANGE_H +#endif // OAK_LIBOLIVECORE_TIMERANGE_H diff --git a/core/include/olive/core/util/value.h b/core/include/olive/core/util/value.h index bb9023544..e449753bf 100644 --- a/core/include/olive/core/util/value.h +++ b/core/include/olive/core/util/value.h @@ -19,8 +19,8 @@ ***/ -#ifndef LIBOLIVECORE_VALUE_H -#define LIBOLIVECORE_VALUE_H +#ifndef OAK_LIBOLIVECORE_VALUE_H +#define OAK_LIBOLIVECORE_VALUE_H #include #include @@ -38,7 +38,7 @@ class Value { public: enum Type { /// Null/no data - NONE, + none, /// Signed int64 INT, @@ -47,12 +47,12 @@ public: FLOAT, /// UTF-8 string - STRING + string }; Value() { - type_ = NONE; + type_ = none; } Value(int64_t v) @@ -74,14 +74,14 @@ public: size_t sz = strlen(s); data_.resize(sz); memcpy(data_.data(), s, sz); - type_ = STRING; + type_ = string; } Value(const std::string &s) { data_.resize(s.size()); memcpy(data_.data(), s.data(), data_.size()); - type_ = STRING; + type_ = string; } private: @@ -93,4 +93,4 @@ using ValueMap = std::map; } -#endif // LIBOLIVECORE_VALUE_H +#endif // OAK_LIBOLIVECORE_VALUE_H diff --git a/core/src/render/audioparams.cpp b/core/src/render/audioparams.cpp index b0de3826a..a81a48743 100644 --- a/core/src/render/audioparams.cpp +++ b/core/src/render/audioparams.cpp @@ -26,7 +26,7 @@ namespace olive::core { -const std::vector AudioParams::kSupportedSampleRates = { +const std::vector AudioParams::k_supported_sample_rates = { 8000, // 8000 Hz 11025, // 11025 Hz 16000, // 16000 Hz @@ -39,9 +39,9 @@ const std::vector AudioParams::kSupportedSampleRates = { 96000 // 96000 Hz }; -const std::vector AudioParams::kSupportedChannelLayouts = { - kChannelLayoutMono, kChannelLayoutStereo, kChannelLayout2_1, - kChannelLayout5Point1, kChannelLayout7Point1 +const std::vector AudioParams::k_supported_channel_layouts = { + k_channel_layout_mono, k_channel_layout_stereo, k_channel_layout2_1, + k_channel_layout5_point1, k_channel_layout7_point1 }; bool AudioParams::operator==(const AudioParams &other) const @@ -61,9 +61,9 @@ int64_t AudioParams::time_to_bytes(const double &time) const return time_to_bytes_per_channel(time) * channel_count(); } -int64_t AudioParams::time_to_bytes(const rational &time) const +int64_t AudioParams::time_to_bytes(const Rational &time) const { - return time_to_bytes(time.toDouble()); + return time_to_bytes(time.to_double()); } int64_t AudioParams::time_to_bytes_per_channel(const double &time) const @@ -73,9 +73,9 @@ int64_t AudioParams::time_to_bytes_per_channel(const double &time) const return int64_t(time_to_samples(time)) * bytes_per_sample_per_channel(); } -int64_t AudioParams::time_to_bytes_per_channel(const rational &time) const +int64_t AudioParams::time_to_bytes_per_channel(const Rational &time) const { - return time_to_bytes_per_channel(time.toDouble()); + return time_to_bytes_per_channel(time.to_double()); } int64_t AudioParams::time_to_samples(const double &time) const @@ -85,9 +85,9 @@ int64_t AudioParams::time_to_samples(const double &time) const return std::round(double(sample_rate()) * time); } -int64_t AudioParams::time_to_samples(const rational &time) const +int64_t AudioParams::time_to_samples(const Rational &time) const { - return time_to_samples(time.toDouble()); + return time_to_samples(time.to_double()); } int64_t AudioParams::samples_to_bytes(const int64_t &samples) const @@ -104,7 +104,7 @@ int64_t AudioParams::samples_to_bytes_per_channel(const int64_t &samples) const return samples * bytes_per_sample_per_channel(); } -rational AudioParams::samples_to_time(const int64_t &samples) const +Rational AudioParams::samples_to_time(const int64_t &samples) const { return sample_rate_as_time_base() * samples; } @@ -116,12 +116,12 @@ int64_t AudioParams::bytes_to_samples(const int64_t &bytes) const return bytes / (channel_count() * bytes_per_sample_per_channel()); } -rational AudioParams::bytes_to_time(const int64_t &bytes) const +Rational AudioParams::bytes_to_time(const int64_t &bytes) const { return samples_to_time(bytes_to_samples(bytes)); } -rational AudioParams::bytes_per_channel_to_time(const int64_t &bytes) const +Rational AudioParams::bytes_per_channel_to_time(const int64_t &bytes) const { return samples_to_time(bytes_to_samples(bytes * channel_count())); } @@ -144,12 +144,12 @@ int AudioParams::bits_per_sample() const bool AudioParams::is_valid() const { return (!time_base().isNull() && channel_layout_mask_ != 0 && - format_ > SampleFormat::INVALID && format_ < SampleFormat::COUNT); + format_ > SampleFormat::invalid && format_ < SampleFormat::count); } void AudioParams::calculate_channel_count() { - channel_count_ = ChannelLayoutMaskChannelCount(channel_layout_mask_); + channel_count_ = channel_layout_mask_channel_count(channel_layout_mask_); } } diff --git a/core/src/render/samplebuffer.cpp b/core/src/render/samplebuffer.cpp index 2c237eba1..9faaf8471 100644 --- a/core/src/render/samplebuffer.cpp +++ b/core/src/render/samplebuffer.cpp @@ -38,7 +38,7 @@ SampleBuffer::SampleBuffer() } SampleBuffer::SampleBuffer(const AudioParams &audio_params, - const rational &length) + const Rational &length) : audio_params_(audio_params) { sample_count_per_channel_ = audio_params_.time_to_samples(length); @@ -56,7 +56,7 @@ SampleBuffer::SampleBuffer(const AudioParams &audio_params, SampleBuffer SampleBuffer::rip_channel(int channel) const { AudioParams p = this->audio_params_; - p.set_channel_layout(kChannelLayoutMono); + p.set_channel_layout(k_channel_layout_mono); SampleBuffer b(p, this->sample_count_per_channel_); b.fast_set(*this, 0, channel); @@ -76,7 +76,7 @@ const AudioParams &SampleBuffer::audio_params() const void SampleBuffer::set_audio_params(const AudioParams ¶ms) { if (is_allocated()) { - Log::Warning() << "Tried to set parameters on allocated sample buffer"; + Log::warning() << "Tried to set parameters on allocated sample buffer"; return; } @@ -86,7 +86,7 @@ void SampleBuffer::set_audio_params(const AudioParams ¶ms) void SampleBuffer::set_sample_count(const size_t &sample_count) { if (is_allocated()) { - Log::Warning() + Log::warning() << "Tried to set sample count on allocated sample buffer"; return; } @@ -97,19 +97,19 @@ void SampleBuffer::set_sample_count(const size_t &sample_count) void SampleBuffer::allocate() { if (!audio_params_.is_valid()) { - Log::Warning() + Log::warning() << "Tried to allocate sample buffer with invalid audio parameters"; return; } if (!sample_count_per_channel_) { - Log::Warning() + Log::warning() << "Tried to allocate sample buffer with zero sample count"; return; } if (is_allocated()) { - Log::Warning() << "Tried to allocate already allocated sample buffer"; + Log::warning() << "Tried to allocate already allocated sample buffer"; return; } @@ -127,7 +127,7 @@ void SampleBuffer::destroy() void SampleBuffer::reverse() { if (!is_allocated()) { - Log::Warning() << "Tried to reverse an unallocated sample buffer"; + Log::warning() << "Tried to reverse an unallocated sample buffer"; return; } @@ -145,7 +145,7 @@ void SampleBuffer::reverse() void SampleBuffer::speed(double speed) { if (!is_allocated()) { - Log::Warning() << "Tried to speed an unallocated sample buffer"; + Log::warning() << "Tried to speed an unallocated sample buffer"; return; } @@ -256,7 +256,7 @@ void SampleBuffer::silence(size_t start_sample, size_t end_sample) void SampleBuffer::silence_bytes(size_t start_byte, size_t end_byte) { if (!is_allocated()) { - Log::Warning() << "Tried to fill an unallocated sample buffer"; + Log::warning() << "Tried to fill an unallocated sample buffer"; return; } @@ -270,7 +270,7 @@ void SampleBuffer::set(int channel, const float *data, size_t sample_offset, size_t sample_length) { if (!is_allocated()) { - Log::Warning() << "Tried to fill an unallocated sample buffer"; + Log::warning() << "Tried to fill an unallocated sample buffer"; return; } diff --git a/core/src/util/bezier.cpp b/core/src/util/bezier.cpp index 6182a93b4..2124d743a 100644 --- a/core/src/util/bezier.cpp +++ b/core/src/util/bezier.cpp @@ -57,35 +57,35 @@ Bezier::Bezier(double x, double y, double cp1_x, double cp1_y, double cp2_x, { } -double Bezier::QuadraticXtoT(double x, double a, double b, double c) +double Bezier::quadratic_xto_t(double x, double a, double b, double c) { // Clamp to prevent infinite loop x = std::clamp(x, a, c); - return CalculateTFromX(false, x, a, b, c, 0); + return calculate_t_from_x(false, x, a, b, c, 0); } -double Bezier::QuadraticTtoY(double a, double b, double c, double t) +double Bezier::quadratic_tto_y(double a, double b, double c, double t) { return std::pow(1.0 - t, 2) * a + 2 * (1.0 - t) * t * b + std::pow(t, 2) * c; } -double Bezier::CubicXtoT(double x, double a, double b, double c, double d) +double Bezier::cubic_xto_t(double x, double a, double b, double c, double d) { // Clamp to prevent infinite loop x = std::clamp(x, a, d); - return CalculateTFromX(true, x, a, b, c, d); + return calculate_t_from_x(true, x, a, b, c, d); } -double Bezier::CubicTtoY(double a, double b, double c, double d, double t) +double Bezier::cubic_tto_y(double a, double b, double c, double d, double t) { return std::pow(1.0 - t, 3) * a + 3 * std::pow(1.0 - t, 2) * t * b + 3 * (1.0 - t) * std::pow(t, 2) * c + std::pow(t, 3) * d; } -double Bezier::CalculateTFromX(bool cubic, double x, double a, double b, +double Bezier::calculate_t_from_x(bool cubic, double x, double a, double b, double c, double d) { double bottom = 0.0; @@ -97,8 +97,8 @@ double Bezier::CalculateTFromX(bool cubic, double x, double a, double b, } double mid = (bottom + top) * 0.5; - double test = cubic ? CubicTtoY(a, b, c, d, mid) : - QuadraticTtoY(a, b, c, mid); + double test = cubic ? cubic_tto_y(a, b, c, d, mid) : + quadratic_tto_y(a, b, c, mid); if (std::abs(test - x) < 0.000001) { return mid; diff --git a/core/src/util/color.cpp b/core/src/util/color.cpp index eda50d67c..301ddfaf6 100644 --- a/core/src/util/color.cpp +++ b/core/src/util/color.cpp @@ -30,73 +30,73 @@ namespace olive::core { -Color Color::fromHsv(const DataType &h, const DataType &s, const DataType &v) +Color Color::from_hsv(const DataType &h, const DataType &s, const DataType &v) { - DataType C = s * v; - DataType X = C * (1.0 - std::abs(std::fmod(h / 60.0, 2.0) - 1.0)); - DataType m = v - C; - DataType Rs, Gs, Bs; + DataType c = s * v; + DataType x = c * (1.0 - std::abs(std::fmod(h / 60.0, 2.0) - 1.0)); + DataType m = v - c; + DataType rs, gs, bs; if (h >= 0.0 && h < 60.0) { - Rs = C; - Gs = X; - Bs = 0.0; + rs = c; + gs = x; + bs = 0.0; } else if (h >= 60.0 && h < 120.0) { - Rs = X; - Gs = C; - Bs = 0.0; + rs = x; + gs = c; + bs = 0.0; } else if (h >= 120.0 && h < 180.0) { - Rs = 0.0; - Gs = C; - Bs = X; + rs = 0.0; + gs = c; + bs = x; } else if (h >= 180.0 && h < 240.0) { - Rs = 0.0; - Gs = X; - Bs = C; + rs = 0.0; + gs = x; + bs = c; } else if (h >= 240.0 && h < 300.0) { - Rs = X; - Gs = 0.0; - Bs = C; + rs = x; + gs = 0.0; + bs = c; } else { - Rs = C; - Gs = 0.0; - Bs = X; + rs = c; + gs = 0.0; + bs = x; } - return Color(Rs + m, Gs + m, Bs + m); + return Color(rs + m, gs + m, bs + m); } Color::Color(const char *data, const PixelFormat &format, int ch_layout) { - *this = fromData(data, format, ch_layout); + *this = from_data(data, format, ch_layout); } -void Color::toHsv(DataType *hue, DataType *sat, DataType *val) const +void Color::to_hsv(DataType *hue, DataType *sat, DataType *val) const { - DataType fCMax = std::max(std::max(red(), green()), blue()); - DataType fCMin = std::min(std::min(red(), green()), blue()); - DataType fDelta = fCMax - fCMin; + DataType f_c_max = std::max(std::max(red(), green()), blue()); + DataType f_c_min = std::min(std::min(red(), green()), blue()); + DataType f_delta = f_c_max - f_c_min; - if (fDelta > 0) { - if (fCMax == red()) { - *hue = 60 * (fmod(((green() - blue()) / fDelta), 6)); - } else if (fCMax == green()) { - *hue = 60 * (((blue() - red()) / fDelta) + 2); - } else if (fCMax == blue()) { - *hue = 60 * (((red() - green()) / fDelta) + 4); + if (f_delta > 0) { + if (f_c_max == red()) { + *hue = 60 * (fmod(((green() - blue()) / f_delta), 6)); + } else if (f_c_max == green()) { + *hue = 60 * (((blue() - red()) / f_delta) + 2); + } else if (f_c_max == blue()) { + *hue = 60 * (((red() - green()) / f_delta) + 4); } - if (fCMax > 0) { - *sat = fDelta / fCMax; + if (f_c_max > 0) { + *sat = f_delta / f_c_max; } else { *sat = 0; } - *val = fCMax; + *val = f_c_max; } else { *hue = 0; *sat = 0; - *val = fCMax; + *val = f_c_max; } if (*hue < 0) { @@ -107,50 +107,50 @@ void Color::toHsv(DataType *hue, DataType *sat, DataType *val) const Color::DataType Color::hsv_hue() const { DataType h, s, v; - toHsv(&h, &s, &v); + to_hsv(&h, &s, &v); return h; } Color::DataType Color::hsv_saturation() const { DataType h, s, v; - toHsv(&h, &s, &v); + to_hsv(&h, &s, &v); return s; } Color::DataType Color::value() const { DataType h, s, v; - toHsv(&h, &s, &v); + to_hsv(&h, &s, &v); return v; } -void Color::toHsl(DataType *hue, DataType *sat, DataType *lightness) const +void Color::to_hsl(DataType *hue, DataType *sat, DataType *lightness) const { - DataType fCMin = std::min(red(), std::min(green(), blue())); - DataType fCMax = std::max(red(), std::max(green(), blue())); + DataType f_c_min = std::min(red(), std::min(green(), blue())); + DataType f_c_max = std::max(red(), std::max(green(), blue())); - *lightness = 0.5 * (fCMin + fCMax); + *lightness = 0.5 * (f_c_min + f_c_max); - if (fCMin == fCMax) { + if (f_c_min == f_c_max) { *sat = 0; *hue = 0; return; } else if (*lightness < 0.5) { - *sat = (fCMax - fCMin) / (fCMax + fCMin); + *sat = (f_c_max - f_c_min) / (f_c_max + f_c_min); } else { - *sat = (fCMax - fCMin) / (2.0 - fCMax - fCMin); + *sat = (f_c_max - f_c_min) / (2.0 - f_c_max - f_c_min); } - if (fCMax == red()) { - *hue = 60 * (green() - blue()) / (fCMax - fCMin); + if (f_c_max == red()) { + *hue = 60 * (green() - blue()) / (f_c_max - f_c_min); } - if (fCMax == green()) { - *hue = 60 * (blue() - red()) / (fCMax - fCMin) + 120; + if (f_c_max == green()) { + *hue = 60 * (blue() - red()) / (f_c_max - f_c_min) + 120; } - if (fCMax == blue()) { - *hue = 60 * (red() - green()) / (fCMax - fCMin) + 240; + if (f_c_max == blue()) { + *hue = 60 * (red() - green()) / (f_c_max - f_c_min) + 240; } if (*hue < 0) { *hue = *hue + 360; @@ -160,30 +160,30 @@ void Color::toHsl(DataType *hue, DataType *sat, DataType *lightness) const Color::DataType Color::hsl_hue() const { DataType h, s, l; - toHsl(&h, &s, &l); + to_hsl(&h, &s, &l); return h; } Color::DataType Color::hsl_saturation() const { DataType h, s, l; - toHsl(&h, &s, &l); + to_hsl(&h, &s, &l); return s; } Color::DataType Color::lightness() const { DataType h, s, l; - toHsl(&h, &s, &l); + to_hsl(&h, &s, &l); return l; } -void Color::toData(char *out, const PixelFormat &format, +void Color::to_data(char *out, const PixelFormat &format, unsigned int nb_channels) const { - unsigned int count = std::min(RGBA, nb_channels); + unsigned int count = std::min(rgba, nb_channels); - if (format == PixelFormat::U10 && count == 4) { + if (format == PixelFormat::u10 && count == 4) { const uint32_t r = static_cast(std::clamp(data_[0], DataType(0.0), DataType(1.0)) * 1023.0 + 0.5); const uint32_t g = static_cast(std::clamp(data_[1], DataType(0.0), DataType(1.0)) * 1023.0 + 0.5); const uint32_t b = static_cast(std::clamp(data_[2], DataType(0.0), DataType(1.0)) * 1023.0 + 0.5); @@ -196,36 +196,36 @@ void Color::toData(char *out, const PixelFormat &format, DataType f = data_[i]; switch (format) { - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; - case PixelFormat::U8: + case PixelFormat::u8: reinterpret_cast(out)[i] = f * 255.0; break; - case PixelFormat::U10: + case PixelFormat::u10: // handled above break; - case PixelFormat::U16: + case PixelFormat::u16: reinterpret_cast(out)[i] = f * 65535.0; break; - case PixelFormat::F16: + case PixelFormat::f16: reinterpret_cast(out)[i] = f; break; - case PixelFormat::F32: + case PixelFormat::f32: reinterpret_cast(out)[i] = f; break; } } } -Color Color::fromData(const char *in, const PixelFormat &format, +Color Color::from_data(const char *in, const PixelFormat &format, unsigned int nb_channels) { Color c; - unsigned int count = std::min(RGBA, nb_channels); + unsigned int count = std::min(rgba, nb_channels); - if (format == PixelFormat::U10 && count == 4) { + if (format == PixelFormat::u10 && count == 4) { const uint32_t word = reinterpret_cast(in)[0]; c.data_[0] = DataType((word & 0x3ff) / 1023.0); c.data_[1] = DataType(((word >> 10) & 0x3ff) / 1023.0); @@ -238,22 +238,22 @@ Color Color::fromData(const char *in, const PixelFormat &format, DataType &f = c.data_[i]; switch (format) { - case PixelFormat::INVALID: - case PixelFormat::COUNT: + case PixelFormat::invalid: + case PixelFormat::count: break; - case PixelFormat::U8: + case PixelFormat::u8: f = DataType(reinterpret_cast(in)[i]) / 255.0; break; - case PixelFormat::U10: + case PixelFormat::u10: // handled above break; - case PixelFormat::U16: + case PixelFormat::u16: f = DataType(reinterpret_cast(in)[i]) / 65535.0; break; - case PixelFormat::F16: + case PixelFormat::f16: f = DataType(reinterpret_cast(in)[i]); break; - case PixelFormat::F32: + case PixelFormat::f32: f = DataType(reinterpret_cast(in)[i]); break; } @@ -262,14 +262,14 @@ Color Color::fromData(const char *in, const PixelFormat &format, return c; } -Color::DataType Color::GetRoughLuminance() const +Color::DataType Color::get_rough_luminance() const { return (2 * red() + blue() + 3 * green()) / 6.0; } Color &Color::operator+=(const Color &rhs) { - for (int i = 0; i < RGBA; i++) { + for (int i = 0; i < rgba; i++) { data_[i] += rhs.data_[i]; } @@ -278,7 +278,7 @@ Color &Color::operator+=(const Color &rhs) Color &Color::operator-=(const Color &rhs) { - for (int i = 0; i < RGBA; i++) { + for (int i = 0; i < rgba; i++) { data_[i] -= rhs.data_[i]; } @@ -287,7 +287,7 @@ Color &Color::operator-=(const Color &rhs) Color &Color::operator+=(const DataType &rhs) { - for (int i = 0; i < RGBA; i++) { + for (int i = 0; i < rgba; i++) { data_[i] += rhs; } @@ -296,7 +296,7 @@ Color &Color::operator+=(const DataType &rhs) Color &Color::operator-=(const DataType &rhs) { - for (int i = 0; i < RGBA; i++) { + for (int i = 0; i < rgba; i++) { data_[i] -= rhs; } @@ -305,7 +305,7 @@ Color &Color::operator-=(const DataType &rhs) Color &Color::operator*=(const DataType &rhs) { - for (int i = 0; i < RGBA; i++) { + for (int i = 0; i < rgba; i++) { data_[i] *= rhs; } @@ -314,7 +314,7 @@ Color &Color::operator*=(const DataType &rhs) Color &Color::operator/=(const DataType &rhs) { - for (int i = 0; i < RGBA; i++) { + for (int i = 0; i < rgba; i++) { data_[i] /= rhs; } diff --git a/core/src/util/fractionutils.cpp b/core/src/util/fractionutils.cpp index 5f05163a8..fa16b0674 100644 --- a/core/src/util/fractionutils.cpp +++ b/core/src/util/fractionutils.cpp @@ -53,7 +53,7 @@ int64_t i64_gcd(int64_t a, int64_t b) } // namespace -void ReduceFraction(int64_t &num, int64_t &den, int64_t max) +void reduce_fraction(int64_t &num, int64_t &den, int64_t max) { if (den == 0) { num = 0; @@ -110,7 +110,7 @@ void ReduceFraction(int64_t &num, int64_t &den, int64_t max) den = a1d; } -int CompareFractions(int an, int ad, int bn, int bd) +int compare_fractions(int an, int ad, int bn, int bd) { const int64_t tmp = an * int64_t(bd) - bn * int64_t(ad); @@ -125,7 +125,7 @@ int CompareFractions(int an, int ad, int bn, int bd) return INT_MIN; } -int64_t RescaleRnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd) +int64_t rescale_rnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd) { // Normalize so that the divisor is positive; the sign is carried by the // dividend instead. @@ -142,7 +142,7 @@ int64_t RescaleRnd(int64_t a, int64_t b, int64_t c, FractionRounding rnd) unsigned __int128 uc = static_cast(c); unsigned __int128 q; - if (rnd == FractionRounding::kNearInf) { + if (rnd == FractionRounding::k_near_inf) { // Round to nearest, ties away from zero q = (ur + uc / 2) / uc; } else { diff --git a/core/src/util/rational.cpp b/core/src/util/rational.cpp index f4040638c..c80bab7ba 100644 --- a/core/src/util/rational.cpp +++ b/core/src/util/rational.cpp @@ -34,23 +34,23 @@ namespace olive::core { -const rational rational::NaN = rational(0, 0); +const Rational Rational::na_n = Rational(0, 0); -rational rational::fromDouble(const double &flt, bool *ok) +Rational Rational::from_double(const double &flt, bool *ok) { if (isnan(flt)) { - // Return NaN rational + // Return NaN Rational if (ok) *ok = false; - return NaN; + return na_n; } if (fabs(flt) > double(INT_MAX) + 3.0) { - // Value is out of range for a rational, return NaN + // Value is out of range for a Rational, return NaN if (ok) { *ok = false; } - return NaN; + return na_n; } // Continued fraction conversion (ported from FFmpeg's av_d2q) @@ -61,53 +61,53 @@ rational rational::fromDouble(const double &flt, bool *ok) int64_t num = int64_t(floor(flt * den + 0.5)); int64_t rnum = num, rden = den; - ReduceFraction(rnum, rden, INT_MAX); + reduce_fraction(rnum, rden, INT_MAX); if ((!rnum || !rden) && flt) { // Value was too small to represent above, retry with maximum precision rnum = int64_t(flt * double(INT64_MAX)); rden = INT64_MAX; - ReduceFraction(rnum, rden, INT_MAX); + reduce_fraction(rnum, rden, INT_MAX); } if (rden == 0) { - // If den == 0, we were unable to convert to a rational + // If den == 0, we were unable to convert to a Rational if (ok) { *ok = false; } - return NaN; + return na_n; } - // Otherwise, assume we received a real rational + // Otherwise, assume we received a real Rational if (ok) { *ok = true; } - return rational(int(rnum), int(rden)); + return Rational(int(rnum), int(rden)); } -rational rational::fromString(const std::string &str, bool *ok) +Rational Rational::from_string(const std::string &str, bool *ok) { std::vector elements = StringUtils::split(str, '/'); switch (elements.size()) { case 1: - return rational(StringUtils::to_int(elements.front(), ok)); + return Rational(StringUtils::to_int(elements.front(), ok)); case 2: - return rational(StringUtils::to_int(elements.at(0), ok), + return Rational(StringUtils::to_int(elements.at(0), ok), StringUtils::to_int(elements.at(1), ok)); default: // Returns NaN with ok set to false if (ok) { *ok = false; } - return NaN; + return na_n; } } //Function: convert to double -double rational::toDouble() const +double Rational::to_double() const { if (den_ != 0) { return double(num_) / double(den_); @@ -117,7 +117,7 @@ double rational::toDouble() const } #ifdef USE_OTIO -opentime::RationalTime rational::toRationalTime(double framerate) const +opentime::RationalTime Rational::toRationalTime(double framerate) const { // Is this the best way of doing this? // Olive can store rationals as 0/0 which causes errors in OTIO @@ -127,14 +127,14 @@ opentime::RationalTime rational::toRationalTime(double framerate) const } #endif -rational rational::flipped() const +Rational Rational::flipped() const { - rational r = *this; + Rational r = *this; r.flip(); return r; } -void rational::flip() +void Rational::flip() { if (!isNull()) { std::swap(den_, num_); @@ -142,12 +142,12 @@ void rational::flip() } } -std::string rational::toString() const +std::string Rational::to_string() const { return StringUtils::format("%d/%d", num_, den_); } -void rational::fix_signs() +void Rational::fix_signs() { if (den_ < 0) { // Normalize so that denominator is always positive @@ -162,35 +162,35 @@ void rational::fix_signs() } } -void rational::reduce() +void Rational::reduce() { int64_t n = num_, d = den_; - ReduceFraction(n, d, INT_MAX); + reduce_fraction(n, d, INT_MAX); num_ = int(n); den_ = int(d); } //Assignment Operators -const rational &rational::operator=(const rational &rhs) +const Rational &Rational::operator=(const Rational &rhs) { num_ = rhs.num_; den_ = rhs.den_; return *this; } -const rational &rational::operator+=(const rational &rhs) +const Rational &Rational::operator+=(const Rational &rhs) { if (*this == RATIONAL_MIN || *this == RATIONAL_MAX || rhs == RATIONAL_MIN || rhs == RATIONAL_MAX) { - *this = NaN; + *this = na_n; } else if (!isNaN()) { if (rhs.isNaN()) { - *this = NaN; + *this = na_n; } else { int64_t n = num_ * int64_t(rhs.den_) + rhs.num_ * int64_t(den_); int64_t d = den_ * int64_t(rhs.den_); - ReduceFraction(n, d, INT_MAX); + reduce_fraction(n, d, INT_MAX); num_ = int(n); den_ = int(d); fix_signs(); @@ -200,18 +200,18 @@ const rational &rational::operator+=(const rational &rhs) return *this; } -const rational &rational::operator-=(const rational &rhs) +const Rational &Rational::operator-=(const Rational &rhs) { if (*this == RATIONAL_MIN || *this == RATIONAL_MAX || rhs == RATIONAL_MIN || rhs == RATIONAL_MAX) { - *this = NaN; + *this = na_n; } else if (!isNaN()) { if (rhs.isNaN()) { - *this = NaN; + *this = na_n; } else { int64_t n = num_ * int64_t(rhs.den_) - rhs.num_ * int64_t(den_); int64_t d = den_ * int64_t(rhs.den_); - ReduceFraction(n, d, INT_MAX); + reduce_fraction(n, d, INT_MAX); num_ = int(n); den_ = int(d); fix_signs(); @@ -221,18 +221,18 @@ const rational &rational::operator-=(const rational &rhs) return *this; } -const rational &rational::operator*=(const rational &rhs) +const Rational &Rational::operator*=(const Rational &rhs) { if (*this == RATIONAL_MIN || *this == RATIONAL_MAX || rhs == RATIONAL_MIN || rhs == RATIONAL_MAX) { - *this = NaN; + *this = na_n; } else if (!isNaN()) { if (rhs.isNaN()) { - *this = NaN; + *this = na_n; } else { int64_t n = num_ * int64_t(rhs.num_); int64_t d = den_ * int64_t(rhs.den_); - ReduceFraction(n, d, INT_MAX); + reduce_fraction(n, d, INT_MAX); num_ = int(n); den_ = int(d); fix_signs(); @@ -242,18 +242,18 @@ const rational &rational::operator*=(const rational &rhs) return *this; } -const rational &rational::operator/=(const rational &rhs) +const Rational &Rational::operator/=(const Rational &rhs) { if (*this == RATIONAL_MIN || *this == RATIONAL_MAX || rhs == RATIONAL_MIN || rhs == RATIONAL_MAX) { - *this = NaN; + *this = na_n; } else if (!isNaN()) { if (rhs.isNaN()) { - *this = NaN; + *this = na_n; } else { int64_t n = num_ * int64_t(rhs.den_); int64_t d = den_ * int64_t(rhs.num_); - ReduceFraction(n, d, INT_MAX); + reduce_fraction(n, d, INT_MAX); num_ = int(n); den_ = int(d); fix_signs(); @@ -265,64 +265,64 @@ const rational &rational::operator/=(const rational &rhs) //Binary math operators -rational rational::operator+(const rational &rhs) const +Rational Rational::operator+(const Rational &rhs) const { - rational answer(*this); + Rational answer(*this); answer += rhs; return answer; } -rational rational::operator-(const rational &rhs) const +Rational Rational::operator-(const Rational &rhs) const { - rational answer(*this); + Rational answer(*this); answer -= rhs; return answer; } -rational rational::operator/(const rational &rhs) const +Rational Rational::operator/(const Rational &rhs) const { - rational answer(*this); + Rational answer(*this); answer /= rhs; return answer; } -rational rational::operator*(const rational &rhs) const +Rational Rational::operator*(const Rational &rhs) const { - rational answer(*this); + Rational answer(*this); answer *= rhs; return answer; } //Relational and equality operators -bool rational::operator<(const rational &rhs) const +bool Rational::operator<(const Rational &rhs) const { - return CompareFractions(num_, den_, rhs.num_, rhs.den_) == -1; + return compare_fractions(num_, den_, rhs.num_, rhs.den_) == -1; } -bool rational::operator<=(const rational &rhs) const +bool Rational::operator<=(const Rational &rhs) const { - int cmp = CompareFractions(num_, den_, rhs.num_, rhs.den_); + int cmp = compare_fractions(num_, den_, rhs.num_, rhs.den_); return cmp == 0 || cmp == -1; } -bool rational::operator>(const rational &rhs) const +bool Rational::operator>(const Rational &rhs) const { - return CompareFractions(num_, den_, rhs.num_, rhs.den_) == 1; + return compare_fractions(num_, den_, rhs.num_, rhs.den_) == 1; } -bool rational::operator>=(const rational &rhs) const +bool Rational::operator>=(const Rational &rhs) const { - int cmp = CompareFractions(num_, den_, rhs.num_, rhs.den_); + int cmp = compare_fractions(num_, den_, rhs.num_, rhs.den_); return cmp == 0 || cmp == 1; } -bool rational::operator==(const rational &rhs) const +bool Rational::operator==(const Rational &rhs) const { - return CompareFractions(num_, den_, rhs.num_, rhs.den_) == 0; + return compare_fractions(num_, den_, rhs.num_, rhs.den_) == 0; } -bool rational::operator!=(const rational &rhs) const +bool Rational::operator!=(const Rational &rhs) const { return !(*this == rhs); } diff --git a/core/src/util/timecodefunctions.cpp b/core/src/util/timecodefunctions.cpp index 3a0933eba..629dbf3cf 100644 --- a/core/src/util/timecodefunctions.cpp +++ b/core/src/util/timecodefunctions.cpp @@ -30,21 +30,21 @@ namespace olive::core { -std::string Timecode::time_to_timecode(const rational &time, - const rational &timebase, +std::string Timecode::time_to_timecode(const Rational &time, + const Rational &timebase, const Timecode::Display &display, bool show_plus_if_positive) { - if (timebase.isNull() || timebase.flipped().toDouble() < 1) { + if (timebase.isNull() || timebase.flipped().to_double() < 1) { return "INVALID TIMEBASE"; } - double time_dbl = time.toDouble(); + double time_dbl = time.to_double(); switch (display) { - case kTimecodeNonDropFrame: - case kTimecodeDropFrame: - case kTimecodeSeconds: { + case k_timecode_non_drop_frame: + case k_timecode_drop_frame: + case k_timecode_seconds: { const char *prefix = ""; if (time_dbl < 0) { @@ -53,7 +53,7 @@ std::string Timecode::time_to_timecode(const rational &time, prefix = "+"; } - if (display == kTimecodeSeconds) { + if (display == k_timecode_seconds) { time_dbl = std::abs(time_dbl); int64_t total_seconds = std::floor(time_dbl); @@ -73,12 +73,12 @@ std::string Timecode::time_to_timecode(const rational &time, } else { // Determine what symbol to separate frames (";" is used for drop frame, ":" is non-drop frame) const char *frame_token; - double frame_rate = timebase.flipped().toDouble(); + double frame_rate = timebase.flipped().to_double(); int rounded_frame_rate = std::llround(frame_rate); int64_t frames, secs, mins, hours; int64_t f = std::abs(time_to_timestamp(time, timebase)); - if (display == kTimecodeDropFrame && + if (display == k_timecode_drop_frame && timebase_is_drop_frame(timebase)) { frame_token = ";"; @@ -94,19 +94,19 @@ std::string Timecode::time_to_timecode(const rational &time, f %= (std::llround(frame_rate * 3600) * 24); // Number of frames per ten minutes - int64_t framesPer10Minutes = std::llround(frame_rate * 600); - int64_t d = f / framesPer10Minutes; - int64_t m = f % framesPer10Minutes; + int64_t frames_per10_minutes = std::llround(frame_rate * 600); + int64_t d = f / frames_per10_minutes; + int64_t m = f % frames_per10_minutes; // Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate - int64_t dropFrames = std::llround(frame_rate * (2.0 / 30.0)); + int64_t drop_frames = std::llround(frame_rate * (2.0 / 30.0)); // Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames - f += dropFrames * 9 * d; - if (m > dropFrames) { - f += dropFrames * - ((m - dropFrames) / - (std::llround(frame_rate) * 60 - dropFrames)); + f += drop_frames * 9 * d; + if (m > drop_frames) { + f += drop_frames * + ((m - drop_frames) / + (std::llround(frame_rate) * 60 - drop_frames)); } } else { frame_token = ":"; @@ -126,16 +126,16 @@ std::string Timecode::time_to_timecode(const rational &time, StringUtils::to_string_leftpad(frames, 2).c_str()); } } - case kFrames: + case k_frames: return std::to_string(time_to_timestamp(time, timebase)); - case kMilliseconds: + case k_milliseconds: return std::to_string(std::llround(time_dbl * 1000)); } return "INVALID TIMECODE MODE"; } -int64_t StrToInt64EmptyTolerant(const std::string &s, bool *ok) +int64_t str_to_int64_empty_tolerant(const std::string &s, bool *ok) { if (s.empty()) { if (ok) @@ -155,7 +155,7 @@ int64_t StrToInt64EmptyTolerant(const std::string &s, bool *ok) } } -double StrToDoubleEmptyTolerant(const std::string &s, bool *ok) +double str_to_double_empty_tolerant(const std::string &s, bool *ok) { if (s.empty()) { if (ok) @@ -175,8 +175,8 @@ double StrToDoubleEmptyTolerant(const std::string &s, bool *ok) } } -rational Timecode::timecode_to_time(std::string timecode, - const rational &timebase, +Rational Timecode::timecode_to_time(std::string timecode, + const Rational &timebase, const Timecode::Display &display, bool *ok) { StringUtils::trim(timecode); @@ -185,13 +185,13 @@ rational Timecode::timecode_to_time(std::string timecode, } switch (display) { - case kTimecodeNonDropFrame: - case kTimecodeDropFrame: - case kTimecodeSeconds: { + case k_timecode_non_drop_frame: + case k_timecode_drop_frame: + case k_timecode_seconds: { std::vector timecode_split = StringUtils::split_regex(timecode, std::regex("(:)|(;)")); - const int element_count = display == kTimecodeSeconds ? 3 : 4; + const int element_count = display == k_timecode_seconds ? 3 : 4; // Remove excess tokens (we're only interested in HH:MM:SS.FF) if (timecode_split.size() > element_count) { @@ -207,60 +207,60 @@ rational Timecode::timecode_to_time(std::string timecode, bool negative = (timecode.at(0) == '-'); - double frame_rate = timebase.flipped().toDouble(); + double frame_rate = timebase.flipped().to_double(); int rounded_frame_rate = std::lround(frame_rate); bool valid; - rational time; + Rational time; - int64_t hours = StrToInt64EmptyTolerant(timecode_split.at(0), &valid); + int64_t hours = str_to_int64_empty_tolerant(timecode_split.at(0), &valid); if (!valid) goto err_fatal; - int64_t mins = StrToInt64EmptyTolerant(timecode_split.at(1), &valid); + int64_t mins = str_to_int64_empty_tolerant(timecode_split.at(1), &valid); if (!valid) goto err_fatal; - if (display == kTimecodeSeconds) { + if (display == k_timecode_seconds) { double secs = - StrToDoubleEmptyTolerant(timecode_split.at(2), &valid); + str_to_double_empty_tolerant(timecode_split.at(2), &valid); if (!valid) goto err_fatal; - time = rational::fromDouble(hours * 3600 + mins * 60 + secs); + time = Rational::from_double(hours * 3600 + mins * 60 + secs); } else { int64_t secs = - StrToInt64EmptyTolerant(timecode_split.at(2), &valid); + str_to_int64_empty_tolerant(timecode_split.at(2), &valid); if (!valid) goto err_fatal; int64_t frames = - StrToInt64EmptyTolerant(timecode_split.at(3), &valid); + str_to_int64_empty_tolerant(timecode_split.at(3), &valid); if (!valid) goto err_fatal; int64_t sec_count = (hours * 3600 + mins * 60 + secs); int64_t frame_count = sec_count * rounded_frame_rate + frames; - if (display == kTimecodeDropFrame && + if (display == k_timecode_drop_frame && timebase_is_drop_frame(timebase)) { // Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate - int64_t dropFrames = std::llround(frame_rate * (2.0 / 30.0)); + int64_t drop_frames = std::llround(frame_rate * (2.0 / 30.0)); // d and m need to be calculated from int64_t real_fr_ts = std::llround(static_cast(sec_count) * frame_rate) + frames; - int64_t framesPer10Minutes = std::llround(frame_rate * 600); - int64_t d = real_fr_ts / framesPer10Minutes; - int64_t m = real_fr_ts % framesPer10Minutes; + int64_t frames_per10_minutes = std::llround(frame_rate * 600); + int64_t d = real_fr_ts / frames_per10_minutes; + int64_t m = real_fr_ts % frames_per10_minutes; - if (m > dropFrames) { + if (m > drop_frames) { frame_count -= - dropFrames * - ((m - dropFrames) / - (std::llround(frame_rate) * 60 - dropFrames)); + drop_frames * + ((m - drop_frames) / + (std::llround(frame_rate) * 60 - drop_frames)); } - frame_count -= dropFrames * 9 * d; + frame_count -= drop_frames * 9 * d; } time = timestamp_to_time(frame_count, timebase); @@ -274,20 +274,20 @@ rational Timecode::timecode_to_time(std::string timecode, return time; } - case kMilliseconds: { + case k_milliseconds: { try { double timecode_secs = std::stod(timecode); // Convert milliseconds to seconds timecode_secs *= 0.001; - // Convert seconds to rational - return rational::fromDouble(timecode_secs, ok); + // Convert seconds to Rational + return Rational::from_double(timecode_secs, ok); } catch (const std::invalid_argument &e) { goto err_fatal; } } - case kFrames: { + case k_frames: { try { int64_t ts = std::stoll(timecode); if (ok) @@ -318,8 +318,8 @@ std::string Timecode::time_to_string(int64_t ms) StringUtils::to_string_leftpad(ss, 2).c_str()); } -rational Timecode::snap_time_to_timebase(const rational &time, - const rational &timebase, +Rational Timecode::snap_time_to_timebase(const Rational &time, + const Rational &timebase, Rounding floor) { // Just convert to a timestamp in timebase units and back @@ -328,32 +328,32 @@ rational Timecode::snap_time_to_timebase(const rational &time, return timestamp_to_time(timestamp, timebase); } -rational Timecode::timestamp_to_time(const int64_t ×tamp, - const rational &timebase) +Rational Timecode::timestamp_to_time(const int64_t ×tamp, + const Rational &timebase) { int64_t num = int64_t(timebase.numerator()) * timestamp; int64_t den = timebase.denominator(); - ReduceFraction(num, den, INT_MAX); + reduce_fraction(num, den, INT_MAX); - return rational(int(num), int(den)); + return Rational(int(num), int(den)); } -bool Timecode::timebase_is_drop_frame(const rational &timebase) +bool Timecode::timebase_is_drop_frame(const Rational &timebase) { return (timebase.numerator() != 1); } -int64_t Timecode::time_to_timestamp(const rational &time, - const rational &timebase, Rounding floor) +int64_t Timecode::time_to_timestamp(const Rational &time, + const Rational &timebase, Rounding floor) { - return time_to_timestamp(time.toDouble(), timebase, floor); + return time_to_timestamp(time.to_double(), timebase, floor); } int64_t Timecode::time_to_timestamp(const double &time, - const rational &timebase, Rounding floor) + const Rational &timebase, Rounding floor) { - const double d = time * timebase.flipped().toDouble(); + const double d = time * timebase.flipped().to_double(); if (std::isnan(d)) { return 0; @@ -362,16 +362,16 @@ int64_t Timecode::time_to_timestamp(const double &time, const double eps = 0.000000000001; switch (floor) { - case kRound: + case k_round: default: return std::llround(d); - case kFloor: + case k_floor: if (d > std::ceil(d) - eps) { return std::ceil(d); } else { return std::floor(d); } - case kCeil: + case k_ceil: if (d < std::floor(d) + eps) { return std::floor(d); } else { @@ -380,29 +380,29 @@ int64_t Timecode::time_to_timestamp(const double &time, } } -int64_t Timecode::rescale_timestamp(const int64_t &ts, const rational &source, - const rational &dest) +int64_t Timecode::rescale_timestamp(const int64_t &ts, const Rational &source, + const Rational &dest) { if (source == dest) { return ts; } - return RescaleRnd(ts, source.numerator() * int64_t(dest.denominator()), + return rescale_rnd(ts, source.numerator() * int64_t(dest.denominator()), source.denominator() * int64_t(dest.numerator()), - FractionRounding::kNearInf); + FractionRounding::k_near_inf); } int64_t Timecode::rescale_timestamp_ceil(const int64_t &ts, - const rational &source, - const rational &dest) + const Rational &source, + const Rational &dest) { if (source == dest) { return ts; } - return RescaleRnd(ts, source.numerator() * int64_t(dest.denominator()), + return rescale_rnd(ts, source.numerator() * int64_t(dest.denominator()), source.denominator() * int64_t(dest.numerator()), - FractionRounding::kUp); + FractionRounding::k_up); } } diff --git a/core/src/util/timerange.cpp b/core/src/util/timerange.cpp index 34730d7ac..864202f83 100644 --- a/core/src/util/timerange.cpp +++ b/core/src/util/timerange.cpp @@ -30,41 +30,41 @@ namespace olive::core { -TimeRange::TimeRange(const rational &in, const rational &out) +TimeRange::TimeRange(const Rational &in, const Rational &out) : in_(in) , out_(out) { normalize(); } -const rational &TimeRange::in() const +const Rational &TimeRange::in() const { return in_; } -const rational &TimeRange::out() const +const Rational &TimeRange::out() const { return out_; } -const rational &TimeRange::length() const +const Rational &TimeRange::length() const { return length_; } -void TimeRange::set_in(const rational &in) +void TimeRange::set_in(const Rational &in) { in_ = in; normalize(); } -void TimeRange::set_out(const rational &out) +void TimeRange::set_out(const Rational &out) { out_ = out; normalize(); } -void TimeRange::set_range(const rational &in, const rational &out) +void TimeRange::set_range(const Rational &in, const Rational &out) { in_ = in; out_ = out; @@ -81,7 +81,7 @@ bool TimeRange::operator!=(const TimeRange &r) const return in() != r.in() || out() != r.out(); } -bool TimeRange::OverlapsWith(const TimeRange &a, bool in_inclusive, +bool TimeRange::overlaps_with(const TimeRange &a, bool in_inclusive, bool out_inclusive) const { bool doesnt_overlap_in = (in_inclusive) ? (a.out() < in()) : @@ -93,12 +93,12 @@ bool TimeRange::OverlapsWith(const TimeRange &a, bool in_inclusive, return !doesnt_overlap_in && !doesnt_overlap_out; } -TimeRange TimeRange::Combined(const TimeRange &a) const +TimeRange TimeRange::combined(const TimeRange &a) const { - return Combine(a, *this); + return combine(a, *this); } -bool TimeRange::Contains(const TimeRange &compare, bool in_inclusive, +bool TimeRange::contains(const TimeRange &compare, bool in_inclusive, bool out_inclusive) const { bool contains_in = (in_inclusive) ? (compare.in() >= in()) : @@ -110,69 +110,69 @@ bool TimeRange::Contains(const TimeRange &compare, bool in_inclusive, return contains_in && contains_out; } -bool TimeRange::Contains(const rational &r) const +bool TimeRange::contains(const Rational &r) const { return r >= in_ && r < out_; } -TimeRange TimeRange::Combine(const TimeRange &a, const TimeRange &b) +TimeRange TimeRange::combine(const TimeRange &a, const TimeRange &b) { return TimeRange(std::min(a.in(), b.in()), std::max(a.out(), b.out())); } -TimeRange TimeRange::Intersected(const TimeRange &a) const +TimeRange TimeRange::intersected(const TimeRange &a) const { - return Intersect(a, *this); + return intersect(a, *this); } -TimeRange TimeRange::Intersect(const TimeRange &a, const TimeRange &b) +TimeRange TimeRange::intersect(const TimeRange &a, const TimeRange &b) { return TimeRange(std::max(a.in(), b.in()), std::min(a.out(), b.out())); } -TimeRange TimeRange::operator+(const rational &rhs) const +TimeRange TimeRange::operator+(const Rational &rhs) const { TimeRange answer(*this); answer += rhs; return answer; } -TimeRange TimeRange::operator-(const rational &rhs) const +TimeRange TimeRange::operator-(const Rational &rhs) const { TimeRange answer(*this); answer -= rhs; return answer; } -const TimeRange &TimeRange::operator+=(const rational &rhs) +const TimeRange &TimeRange::operator+=(const Rational &rhs) { set_range(in_ + rhs, out_ + rhs); return *this; } -const TimeRange &TimeRange::operator-=(const rational &rhs) +const TimeRange &TimeRange::operator-=(const Rational &rhs) { set_range(in_ - rhs, out_ - rhs); return *this; } -std::list TimeRange::Split(const int &chunk_size) const +std::list TimeRange::split(const int &chunk_size) const { std::list split_ranges; int start_time = - std::floor(this->in().toDouble() / static_cast(chunk_size)) * + std::floor(this->in().to_double() / static_cast(chunk_size)) * chunk_size; int end_time = - std::ceil(this->out().toDouble() / static_cast(chunk_size)) * + std::ceil(this->out().to_double() / static_cast(chunk_size)) * chunk_size; for (int i = start_time; i < end_time; i += chunk_size) { split_ranges.push_back( - TimeRange(std::max(this->in(), rational(i)), - std::min(this->out(), rational(i + chunk_size)))); + TimeRange(std::max(this->in(), Rational(i)), + std::min(this->out(), Rational(i + chunk_size)))); } return split_ranges; @@ -188,7 +188,7 @@ void TimeRange::normalize() // Calculate length if (out_ == RATIONAL_MIN || out_ == RATIONAL_MAX || in_ == RATIONAL_MIN || in_ == RATIONAL_MAX) { - length_ = rational::NaN; + length_ = Rational::na_n; } else { length_ = out_ - in_; } @@ -212,8 +212,8 @@ void TimeRangeList::insert(TimeRange range_to_add) for (auto it = array_.begin(); it != array_.end();) { const TimeRange &compare = *it; - if (compare.OverlapsWith(range_to_add)) { - range_to_add = TimeRange::Combine(range_to_add, compare); + if (compare.overlaps_with(range_to_add)) { + range_to_add = TimeRange::combine(range_to_add, compare); it = array_.erase(it); } else { it++; @@ -239,7 +239,7 @@ bool TimeRangeList::contains(const TimeRange &range, bool in_inclusive, bool out_inclusive) const { for (int i = 0; i < size(); i++) { - if (array_.at(i).Contains(range, in_inclusive, out_inclusive)) { + if (array_.at(i).contains(range, in_inclusive, out_inclusive)) { return true; } } @@ -247,14 +247,14 @@ bool TimeRangeList::contains(const TimeRange &range, bool in_inclusive, return false; } -void TimeRangeList::shift(const rational &diff) +void TimeRangeList::shift(const Rational &diff) { for (int i = 0; i < array_.size(); i++) { array_[i] += diff; } } -void TimeRangeList::trim_in(const rational &diff) +void TimeRangeList::trim_in(const Rational &diff) { // Re-do list since we want to handle overlaps TimeRangeList temp = *this; @@ -268,7 +268,7 @@ void TimeRangeList::trim_in(const rational &diff) } } -void TimeRangeList::trim_out(const rational &diff) +void TimeRangeList::trim_out(const Rational &diff) { // Re-do list since we want to handle overlaps TimeRangeList temp = *this; @@ -282,7 +282,7 @@ void TimeRangeList::trim_out(const rational &diff) } } -TimeRangeList TimeRangeList::Intersects(const TimeRange &range) const +TimeRangeList TimeRangeList::intersects(const TimeRange &range) const { TimeRangeList intersect_list; @@ -305,12 +305,12 @@ TimeRangeList TimeRangeList::Intersects(const TimeRange &range) const } TimeRangeListFrameIterator::TimeRangeListFrameIterator() - : TimeRangeListFrameIterator(TimeRangeList(), rational::NaN) + : TimeRangeListFrameIterator(TimeRangeList(), Rational::na_n) { } TimeRangeListFrameIterator::TimeRangeListFrameIterator( - const TimeRangeList &list, const rational &timebase) + const TimeRangeList &list, const Rational &timebase) : list_(list) , timebase_(timebase) , range_index_(-1) @@ -324,17 +324,17 @@ TimeRangeListFrameIterator::TimeRangeListFrameIterator( << std::endl; } - UpdateIndexIfNecessary(); + update_index_if_necessary(); } -rational TimeRangeListFrameIterator::Snap(const rational &r) const +Rational TimeRangeListFrameIterator::snap(const Rational &r) const { - return Timecode::snap_time_to_timebase(r, timebase_, Timecode::kFloor); + return Timecode::snap_time_to_timebase(r, timebase_, Timecode::k_floor); } -bool TimeRangeListFrameIterator::GetNext(rational *out) +bool TimeRangeListFrameIterator::get_next(Rational *out) { - if (!HasNext()) { + if (!has_next()) { return false; } @@ -345,7 +345,7 @@ bool TimeRangeListFrameIterator::GetNext(rational *out) current_ += timebase_; // If this time is outside the current range, jump to the next one - UpdateIndexIfNecessary(); + update_index_if_necessary(); // Increment frame index frame_index_++; @@ -353,7 +353,7 @@ bool TimeRangeListFrameIterator::GetNext(rational *out) return true; } -bool TimeRangeListFrameIterator::HasNext() const +bool TimeRangeListFrameIterator::has_next() const { return range_index_ < list_.size(); } @@ -365,9 +365,9 @@ int TimeRangeListFrameIterator::size() size_ = 0; for (const TimeRange &range : list_) { - rational start = Snap(range.in()); - rational end = Timecode::snap_time_to_timebase( - range.out(), timebase_, Timecode::kFloor); + Rational start = snap(range.in()); + Rational end = Timecode::snap_time_to_timebase( + range.out(), timebase_, Timecode::k_floor); if (end == range.out()) { end -= timebase_; @@ -383,14 +383,14 @@ int TimeRangeListFrameIterator::size() return size_; } -void TimeRangeListFrameIterator::UpdateIndexIfNecessary() +void TimeRangeListFrameIterator::update_index_if_necessary() { while (range_index_ < list_.size() && (range_index_ == -1 || current_ >= list_.at(range_index_).out())) { range_index_++; if (range_index_ < list_.size()) { - current_ = Snap(list_.at(range_index_).in()); + current_ = snap(list_.at(range_index_).in()); } } } diff --git a/core/tests/rational-test.cpp b/core/tests/rational-test.cpp index b20dcfd97..2271b853d 100644 --- a/core/tests/rational-test.cpp +++ b/core/tests/rational-test.cpp @@ -28,22 +28,22 @@ using namespace olive::core; bool rational_to_from_string_test() { - rational r(1, 30); + Rational r(1, 30); std::string s = r.toString(); - rational r2 = rational::fromString(s); + Rational r2 = Rational::fromString(s); return r == r2; } bool rational_to_from_string_test2() { - rational r(69, 420); + Rational r(69, 420); std::string s = r.toString(); - rational r2 = rational::fromString(s); + Rational r2 = Rational::fromString(s); return r == r2; } @@ -51,7 +51,7 @@ bool rational_to_from_string_test2() bool rational_defaults() { // By default, rationals are valid 0/1 - rational basic_constructor; + Rational basic_constructor; if (!basic_constructor.isNull()) { return false; @@ -67,21 +67,21 @@ bool rational_defaults() bool rational_nan() { // Create a NaN with a 0 denominator - rational nan = rational(0, 0); + Rational nan = Rational(0, 0); if (!nan.isNaN()) return false; if (!nan.isNull()) return false; // Create a non-NaN with a zero numerator - rational zero_nonnan(0, 999); + Rational zero_nonnan(0, 999); if (!zero_nonnan.isNull()) return false; if (zero_nonnan.isNaN()) return false; // Create a non-NaN with a non-zero numerator - rational nonzer_nonnan(1, 30); + Rational nonzer_nonnan(1, 30); if (nonzer_nonnan.isNull()) return false; if (nonzer_nonnan.isNaN()) @@ -92,18 +92,18 @@ bool rational_nan() bool rational_nan_constant() { - return rational::NaN.isNaN(); + return Rational::NaN.isNaN(); } int main() { Tester t; - t.add("rational::defaults", rational_defaults); - t.add("rational::NaN", rational_nan); - t.add("rational::NaN_constant", rational_nan_constant); - t.add("rational::toString/fromString", rational_to_from_string_test); - t.add("rational::toString/fromString2", rational_to_from_string_test2); + t.add("Rational::defaults", rational_defaults); + t.add("Rational::NaN", rational_nan); + t.add("Rational::NaN_constant", rational_nan_constant); + t.add("Rational::toString/fromString", rational_to_from_string_test); + t.add("Rational::toString/fromString2", rational_to_from_string_test2); return t.exec(); } diff --git a/core/tests/timecode-test.cpp b/core/tests/timecode-test.cpp index 42b5a09cf..bf446bf08 100644 --- a/core/tests/timecode-test.cpp +++ b/core/tests/timecode-test.cpp @@ -28,10 +28,10 @@ using namespace olive::core; bool timecodefunctions_time_to_timecode_test() { - rational drop_frame_30(1001, 30000); + Rational drop_frame_30(1001, 30000); std::string timecode = Timecode::time_to_timecode( - rational(1), drop_frame_30, Timecode::kTimecodeDropFrame); + Rational(1), drop_frame_30, Timecode::kTimecodeDropFrame); if (strcmp(timecode.c_str(), "00:00:01;00") != 0) { return false; } @@ -41,10 +41,10 @@ bool timecodefunctions_time_to_timecode_test() bool timecodefunctions_time_to_timecode_test2() { - rational bizarre_timebase(156632219); + Rational bizarre_timebase(156632219); std::string timecode = Timecode::time_to_timecode( - rational(0), bizarre_timebase, Timecode::kTimecodeDropFrame); + Rational(0), bizarre_timebase, Timecode::kTimecodeDropFrame); if (strcmp(timecode.c_str(), "INVALID TIMEBASE") != 0) { return false; } diff --git a/ffmpeg_bridge/include/ffmpeg_bridge/ffmpeg_bridge.h b/ffmpeg_bridge/include/ffmpeg_bridge/ffmpeg_bridge.h index 60511b362..04cabccf7 100644 --- a/ffmpeg_bridge/include/ffmpeg_bridge/ffmpeg_bridge.h +++ b/ffmpeg_bridge/include/ffmpeg_bridge/ffmpeg_bridge.h @@ -19,8 +19,8 @@ ***/ -#ifndef FFMPEG_BRIDGE_H -#define FFMPEG_BRIDGE_H +#ifndef OAK_FFMPEG_BRIDGE_H +#define OAK_FFMPEG_BRIDGE_H /** * ffmpeg_bridge - pure C API isolating all FFmpeg access from the editor. @@ -77,94 +77,94 @@ extern "C" { * format has no entry here receive an opaque process-local id >= 1000. */ typedef enum FBPixelFormat { - FB_PIX_FMT_NONE = -1, - FB_PIX_FMT_YUV420P = 0, - FB_PIX_FMT_RGB24 = 2, - FB_PIX_FMT_YUV422P = 4, - FB_PIX_FMT_YUV444P = 5, - FB_PIX_FMT_YUV410P = 6, - FB_PIX_FMT_YUV411P = 7, - FB_PIX_FMT_GRAY8 = 8, - FB_PIX_FMT_YUVJ420P = 12, - FB_PIX_FMT_YUVJ422P = 13, - FB_PIX_FMT_YUVJ444P = 14, - FB_PIX_FMT_NV12 = 23, - FB_PIX_FMT_RGBA = 26, - FB_PIX_FMT_GRAY16LE = 30, - FB_PIX_FMT_YUV440P = 31, - FB_PIX_FMT_YUVJ440P = 32, - FB_PIX_FMT_RGB48LE = 35, - FB_PIX_FMT_YUV420P10LE = 62, - FB_PIX_FMT_YUV422P10LE = 64, - FB_PIX_FMT_YUV444P10LE = 68, - FB_PIX_FMT_RGBA64LE = 105, - FB_PIX_FMT_YUV420P12LE = 123, - FB_PIX_FMT_YUV422P12LE = 127, - FB_PIX_FMT_YUV444P12LE = 131, - FB_PIX_FMT_YUVJ411P = 138, - FB_PIX_FMT_P010LE = 158, - FB_PIX_FMT_GRAYF32LE = 183, - FB_PIX_FMT_RGBAF16LE = 207, - FB_PIX_FMT_RGBF32LE = 218, - FB_PIX_FMT_RGBAF32LE = 220, - FB_PIX_FMT_RGBF16LE = 234, - FB_PIX_FMT_GRAYF16LE = 248 + fb_pix_fmt_none = -1, + fb_pix_fmt_yu_v420_p = 0, + fb_pix_fmt_rg_b24 = 2, + fb_pix_fmt_yu_v422_p = 4, + fb_pix_fmt_yu_v444_p = 5, + fb_pix_fmt_yu_v410_p = 6, + fb_pix_fmt_yu_v411_p = 7, + fb_pix_fmt_gra_y8 = 8, + fb_pix_fmt_yuv_j420_p = 12, + fb_pix_fmt_yuv_j422_p = 13, + fb_pix_fmt_yuv_j444_p = 14, + fb_pix_fmt_n_v12 = 23, + fb_pix_fmt_rgba = 26, + fb_pix_fmt_gra_y16_le = 30, + fb_pix_fmt_yu_v440_p = 31, + fb_pix_fmt_yuv_j440_p = 32, + fb_pix_fmt_rg_b48_le = 35, + fb_pix_fmt_yu_v420_p10_le = 62, + fb_pix_fmt_yu_v422_p10_le = 64, + fb_pix_fmt_yu_v444_p10_le = 68, + fb_pix_fmt_rgb_a64_le = 105, + fb_pix_fmt_yu_v420_p12_le = 123, + fb_pix_fmt_yu_v422_p12_le = 127, + fb_pix_fmt_yu_v444_p12_le = 131, + fb_pix_fmt_yuv_j411_p = 138, + fb_pix_fmt_p010_le = 158, + fb_pix_fmt_gray_f32_le = 183, + fb_pix_fmt_rgba_f16_le = 207, + fb_pix_fmt_rgb_f32_le = 218, + fb_pix_fmt_rgba_f32_le = 220, + fb_pix_fmt_rgb_f16_le = 234, + fb_pix_fmt_gray_f16_le = 248 } FBPixelFormat; /** * Sample formats. Values mirror AVSampleFormat (static_assert'ed). */ typedef enum FBSampleFormat { - FB_SAMPLE_FMT_NONE = -1, - FB_SAMPLE_FMT_U8 = 0, - FB_SAMPLE_FMT_S16 = 1, - FB_SAMPLE_FMT_S32 = 2, - FB_SAMPLE_FMT_FLT = 3, - FB_SAMPLE_FMT_DBL = 4, - FB_SAMPLE_FMT_U8P = 5, - FB_SAMPLE_FMT_S16P = 6, - FB_SAMPLE_FMT_S32P = 7, - FB_SAMPLE_FMT_FLTP = 8, - FB_SAMPLE_FMT_DBLP = 9, - FB_SAMPLE_FMT_S64 = 10, - FB_SAMPLE_FMT_S64P = 11 + fb_sample_fmt_none = -1, + fb_sample_fmt_u8 = 0, + fb_sample_fmt_s16 = 1, + fb_sample_fmt_s32 = 2, + fb_sample_fmt_flt = 3, + fb_sample_fmt_dbl = 4, + fb_sample_fmt_u8_p = 5, + fb_sample_fmt_s16_p = 6, + fb_sample_fmt_s32_p = 7, + fb_sample_fmt_fltp = 8, + fb_sample_fmt_dblp = 9, + fb_sample_fmt_s64 = 10, + fb_sample_fmt_s64_p = 11 } FBSampleFormat; /** Color ranges. Values mirror AVColorRange (static_assert'ed). */ typedef enum FBColorRange { - FB_COLOR_RANGE_UNSPEC = 0, - FB_COLOR_RANGE_MPEG = 1, - FB_COLOR_RANGE_JPEG = 2 + fb_color_range_unspec = 0, + fb_color_range_mpeg = 1, + fb_color_range_jpeg = 2 } FBColorRange; /** Color spaces. Values mirror AVColorSpace (static_assert'ed). */ typedef enum FBColorSpace { - FB_COL_SPC_RGB = 0, - FB_COL_SPC_BT709 = 1, - FB_COL_SPC_UNSPEC = 2, - FB_COL_SPC_FCC = 4, - FB_COL_SPC_BT470BG = 5, - FB_COL_SPC_SMPTE170M = 6, - FB_COL_SPC_SMPTE240M = 7, - FB_COL_SPC_BT2020_NCL = 9 + fb_col_spc_rgb = 0, + fb_col_spc_b_t709 = 1, + fb_col_spc_unspec = 2, + fb_col_spc_fcc = 4, + fb_col_spc_b_t470_bg = 5, + fb_col_spc_smpt_e170_m = 6, + fb_col_spc_smpt_e240_m = 7, + fb_col_spc_b_t2020_ncl = 9 } FBColorSpace; /** Media types. Values mirror AVMediaType (static_assert'ed). */ typedef enum FBMediaType { - FB_MEDIA_TYPE_VIDEO = 0, - FB_MEDIA_TYPE_AUDIO = 1, - FB_MEDIA_TYPE_DATA = 2, - FB_MEDIA_TYPE_SUBTITLE = 3 + fb_media_type_video = 0, + fb_media_type_audio = 1, + fb_media_type_data = 2, + fb_media_type_subtitle = 3 } FBMediaType; /** Field orders. Values mirror AVFieldOrder (static_assert'ed). */ typedef enum FBFieldOrder { - FB_FIELD_ORDER_UNKNOWN = 0, - FB_FIELD_ORDER_PROGRESSIVE = 1, - FB_FIELD_ORDER_TT = 2, - FB_FIELD_ORDER_BB = 3, - FB_FIELD_ORDER_TB = 4, - FB_FIELD_ORDER_BT = 5 + fb_field_order_unknown = 0, + fb_field_order_progressive = 1, + fb_field_order_tt = 2, + fb_field_order_bb = 3, + fb_field_order_tb = 4, + fb_field_order_bt = 5 } FBFieldOrder; /** @@ -181,26 +181,26 @@ typedef enum FBFieldOrder { * caller's adapter layer (no value relationship with any app-side enum). */ typedef enum FBCodec { - FB_CODEC_NONE = -1, - FB_CODEC_H264 = 0, - FB_CODEC_H264RGB, - FB_CODEC_DNXHD, - FB_CODEC_PRORES, - FB_CODEC_CINEFORM, - FB_CODEC_H265, - FB_CODEC_VP9, - FB_CODEC_AV1, - FB_CODEC_OPENEXR, - FB_CODEC_PNG, - FB_CODEC_TIFF, - FB_CODEC_MP2, - FB_CODEC_MP3, - FB_CODEC_AAC, - FB_CODEC_PCM, - FB_CODEC_FLAC, - FB_CODEC_OPUS, - FB_CODEC_VORBIS, - FB_CODEC_SRT + fb_codec_none = -1, + fb_codec_h264 = 0, + fb_codec_h264_rgb, + fb_codec_dnxhd, + fb_codec_prores, + fb_codec_cineform, + fb_codec_h265, + fb_codec_v_p9, + fb_codec_a_v1, + fb_codec_openexr, + fb_codec_png, + fb_codec_tiff, + fb_codec_m_p2, + fb_codec_m_p3, + fb_codec_aac, + fb_codec_pcm, + fb_codec_flac, + fb_codec_opus, + fb_codec_vorbis, + fb_codec_srt } FBCodec; /** Cancellation callback: return non-zero to request cancellation. */ @@ -602,4 +602,4 @@ FB_API int fb_encoder_codec_get_sample_formats(int codec, int *fmts, } #endif -#endif // FFMPEG_BRIDGE_H +#endif // OAK_FFMPEG_BRIDGE_H diff --git a/ffmpeg_bridge/src/audiograph.cpp b/ffmpeg_bridge/src/audiograph.cpp index 9e62e2857..896fd8f51 100644 --- a/ffmpeg_bridge/src/audiograph.cpp +++ b/ffmpeg_bridge/src/audiograph.cpp @@ -32,11 +32,11 @@ struct FBAudioGraph { int in_channels = 0; int in_sample_rate = 0; - int in_sample_format = FB_SAMPLE_FMT_NONE; + int in_sample_format = fb_sample_fmt_none; int64_t in_pts = 0; }; -static AVFilterContext *CreateTempoFilter(AVFilterGraph *graph, +static AVFilterContext *create_tempo_filter(AVFilterGraph *graph, AVFilterContext *link, double tempo) { char speed_param[20]; @@ -67,9 +67,9 @@ FBAudioGraph *fb_audio_graph_create(const FBAudioGraphConfig *config) } AVChannelLayout in_layout, out_layout; - fb::ChannelLayoutFromMask(&in_layout, config->in_channel_layout_mask, + fb::channel_layout_from_mask(&in_layout, config->in_channel_layout_mask, config->in_channels); - fb::ChannelLayoutFromMask(&out_layout, config->out_channel_layout_mask, + fb::channel_layout_from_mask(&out_layout, config->out_channel_layout_mask, config->out_channels); char filter_args[200]; @@ -104,7 +104,7 @@ FBAudioGraph *fb_audio_graph_create(const FBAudioGraphConfig *config) for (int i = 0; i <= whole; i++) { double filter_tempo = (i == whole) ? pow(base, speed_log) : base; previous_filter = - CreateTempoFilter(g->graph, previous_filter, filter_tempo); + create_tempo_filter(g->graph, previous_filter, filter_tempo); if (!previous_filter) { av_channel_layout_uninit(&in_layout); av_channel_layout_uninit(&out_layout); diff --git a/ffmpeg_bridge/src/decoder.cpp b/ffmpeg_bridge/src/decoder.cpp index 055ef669c..315aea470 100644 --- a/ffmpeg_bridge/src/decoder.cpp +++ b/ffmpeg_bridge/src/decoder.cpp @@ -30,26 +30,26 @@ namespace { -constexpr int64_t kAnalyzeDurationUs = 5000000; -constexpr int64_t kProbeSizeBytes = 20000000; +constexpr int64_t k_analyze_duration_us = 5000000; +constexpr int64_t k_probe_size_bytes = 20000000; -void ApplyFormatOpenOptions(AVDictionary **opts) +void apply_format_open_options(AVDictionary **opts) { - av_dict_set_int(opts, "analyzeduration", kAnalyzeDurationUs, 0); - av_dict_set_int(opts, "probesize", kProbeSizeBytes, 0); + av_dict_set_int(opts, "analyzeduration", k_analyze_duration_us, 0); + av_dict_set_int(opts, "probesize", k_probe_size_bytes, 0); } -void TuneFormatContext(AVFormatContext *ctx) +void tune_format_context(AVFormatContext *ctx) { if (!ctx) { return; } - ctx->probesize = kProbeSizeBytes; - ctx->max_analyze_duration = kAnalyzeDurationUs; + ctx->probesize = k_probe_size_bytes; + ctx->max_analyze_duration = k_analyze_duration_us; } -void DiscardSubtitleStreams(AVFormatContext *ctx) +void discard_subtitle_streams(AVFormatContext *ctx) { if (!ctx) { return; @@ -77,14 +77,14 @@ struct FBDecoder { AVPixelFormat hw_pix_fmt = AV_PIX_FMT_NONE; bool hwaccel_enabled = false; - bool Open(const char *filename, int stream_index); - void Close(); + bool open(const char *filename, int stream_index); + void close(); - static AVHWDeviceType ChooseHardwareDevice(); - static AVPixelFormat GetHardwareFormat(AVCodecContext *ctx, + static AVHWDeviceType choose_hardware_device(); + static AVPixelFormat get_hardware_format(AVCodecContext *ctx, const AVPixelFormat *pix_fmts); - bool InitHardwareAcceleration(const AVCodec *codec); - void CleanupHardwareAcceleration(); + bool init_hardware_acceleration(const AVCodec *codec); + void cleanup_hardware_acceleration(); }; FBDecoder *fb_decoder_create(void) @@ -95,21 +95,21 @@ FBDecoder *fb_decoder_create(void) void fb_decoder_free(FBDecoder **decoder) { if (decoder && *decoder) { - (*decoder)->Close(); + (*decoder)->close(); delete *decoder; *decoder = nullptr; } } -bool FBDecoder::Open(const char *filename, int stream_index) +bool FBDecoder::open(const char *filename, int stream_index) { // Open file in a format context AVDictionary *format_opts = nullptr; - ApplyFormatOpenOptions(&format_opts); + apply_format_open_options(&format_opts); int error_code = avformat_open_input(&fmt_ctx, filename, nullptr, &format_opts); av_dict_free(&format_opts); - TuneFormatContext(fmt_ctx); - DiscardSubtitleStreams(fmt_ctx); + tune_format_context(fmt_ctx); + discard_subtitle_streams(fmt_ctx); if (error_code != 0) { fprintf(stderr, "ffmpeg_bridge: failed to open input %s (%d)\n", filename, @@ -158,7 +158,7 @@ bool FBDecoder::Open(const char *filename, int stream_index) } // Attempt hardware accelerated decoding first, then fall back to software. - if (InitHardwareAcceleration(codec)) { + if (init_hardware_acceleration(codec)) { error_code = avcodec_open2(codec_ctx, codec, &opts); if (error_code == 0) { hwaccel_enabled = true; @@ -171,7 +171,7 @@ bool FBDecoder::Open(const char *filename, int stream_index) // Free the failed context and recreate it for software decoding. avcodec_free_context(&codec_ctx); - CleanupHardwareAcceleration(); + cleanup_hardware_acceleration(); codec_ctx = avcodec_alloc_context3(codec); if (codec_ctx == nullptr) { @@ -198,7 +198,7 @@ bool FBDecoder::Open(const char *filename, int stream_index) return true; } -AVHWDeviceType FBDecoder::ChooseHardwareDevice() +AVHWDeviceType FBDecoder::choose_hardware_device() { if (getenv("OAK_DISABLE_HWACCEL") != nullptr) { return AV_HWDEVICE_TYPE_NONE; @@ -231,7 +231,7 @@ AVHWDeviceType FBDecoder::ChooseHardwareDevice() return AV_HWDEVICE_TYPE_NONE; } -AVPixelFormat FBDecoder::GetHardwareFormat(AVCodecContext *ctx, +AVPixelFormat FBDecoder::get_hardware_format(AVCodecContext *ctx, const AVPixelFormat *pix_fmts) { const FBDecoder *inst = static_cast(ctx->opaque); @@ -246,9 +246,9 @@ AVPixelFormat FBDecoder::GetHardwareFormat(AVCodecContext *ctx, return pix_fmts[0]; } -bool FBDecoder::InitHardwareAcceleration(const AVCodec *codec) +bool FBDecoder::init_hardware_acceleration(const AVCodec *codec) { - const AVHWDeviceType device_type = ChooseHardwareDevice(); + const AVHWDeviceType device_type = choose_hardware_device(); if (device_type == AV_HWDEVICE_TYPE_NONE) { return false; } @@ -279,20 +279,20 @@ bool FBDecoder::InitHardwareAcceleration(const AVCodec *codec) fprintf(stderr, "ffmpeg_bridge: failed to create hardware device context (%d)\n", ret); - CleanupHardwareAcceleration(); + cleanup_hardware_acceleration(); return false; } codec_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx); codec_ctx->opaque = this; - codec_ctx->get_format = GetHardwareFormat; + codec_ctx->get_format = get_hardware_format; // Most hardware decoders do not support frame threading. av_dict_set(&opts, "threads", "1", 0); return true; } -void FBDecoder::CleanupHardwareAcceleration() +void FBDecoder::cleanup_hardware_acceleration() { hwaccel_enabled = false; hw_device_type = AV_HWDEVICE_TYPE_NONE; @@ -304,7 +304,7 @@ void FBDecoder::CleanupHardwareAcceleration() } } -void FBDecoder::Close() +void FBDecoder::close() { if (opts) { av_dict_free(&opts); @@ -316,7 +316,7 @@ void FBDecoder::Close() codec_ctx = nullptr; } - CleanupHardwareAcceleration(); + cleanup_hardware_acceleration(); if (fmt_ctx) { avformat_close_input(&fmt_ctx); @@ -331,13 +331,13 @@ int fb_decoder_open(FBDecoder *decoder, const char *filename, int stream_index) if (!decoder || !filename) { return AVERROR(EINVAL); } - return decoder->Open(filename, stream_index) ? 0 : AVERROR_EXTERNAL; + return decoder->open(filename, stream_index) ? 0 : AVERROR_EXTERNAL; } void fb_decoder_close(FBDecoder *decoder) { if (decoder) { - decoder->Close(); + decoder->close(); } } @@ -431,13 +431,13 @@ int fb_decoder_get_stream_info(const FBDecoder *decoder, FBStreamInfo *out) out->has_decoder = 1; // stream is open, so a decoder was found out->width = par->width; out->height = par->height; - out->pixel_format = fb::PixFmtFromAV(AVPixelFormat(par->format)); + out->pixel_format = fb::pix_fmt_from_av(AVPixelFormat(par->format)); out->field_order = decoder->codec_ctx ? decoder->codec_ctx->field_order : AV_FIELD_UNKNOWN; out->color_range = par->color_range; out->sample_rate = par->sample_rate; out->sample_format = par->format; - out->channel_layout_mask = fb::ValidateStreamChannelLayoutMask(s); + out->channel_layout_mask = fb::validate_stream_channel_layout_mask(s); out->start_time = s->start_time; out->duration = s->duration; out->time_base_num = s->time_base.num; @@ -502,5 +502,5 @@ int fb_decoder_hw_pix_fmt(const FBDecoder *decoder) // Hardware pixel formats have no static FB_PIX_FMT_* identifier, so this // returns a process-local dynamic id for them. Use fb_frame_is_hw() to // detect hardware frames. - return decoder ? fb::PixFmtFromAV(decoder->hw_pix_fmt) : FB_PIX_FMT_NONE; + return decoder ? fb::pix_fmt_from_av(decoder->hw_pix_fmt) : fb_pix_fmt_none; } diff --git a/ffmpeg_bridge/src/encoder.cpp b/ffmpeg_bridge/src/encoder.cpp index 8b0893620..b1a023141 100644 --- a/ffmpeg_bridge/src/encoder.cpp +++ b/ffmpeg_bridge/src/encoder.cpp @@ -37,7 +37,7 @@ namespace { -AVPixelFormat ConvertJPEGSpaceToRegularSpace(AVPixelFormat f) +AVPixelFormat convert_jpeg_space_to_regular_space(AVPixelFormat f) { switch (f) { case AV_PIX_FMT_YUVJ420P: @@ -57,67 +57,67 @@ AVPixelFormat ConvertJPEGSpaceToRegularSpace(AVPixelFormat f) return f; } -const AVCodec *FindEncoder(int codec, int sample_format) +const AVCodec *find_encoder(int codec, int sample_format) { switch (codec) { - case FB_CODEC_H264: + case fb_codec_h264: return avcodec_find_encoder_by_name("libx264"); - case FB_CODEC_H264RGB: + case fb_codec_h264_rgb: return avcodec_find_encoder_by_name("libx264rgb"); - case FB_CODEC_DNXHD: + case fb_codec_dnxhd: return avcodec_find_encoder(AV_CODEC_ID_DNXHD); - case FB_CODEC_PRORES: + case fb_codec_prores: return avcodec_find_encoder(AV_CODEC_ID_PRORES); - case FB_CODEC_CINEFORM: + case fb_codec_cineform: return avcodec_find_encoder(AV_CODEC_ID_CFHD); - case FB_CODEC_H265: + case fb_codec_h265: return avcodec_find_encoder(AV_CODEC_ID_HEVC); - case FB_CODEC_VP9: + case fb_codec_v_p9: return avcodec_find_encoder(AV_CODEC_ID_VP9); - case FB_CODEC_AV1: { + case fb_codec_a_v1: { const AVCodec *encoder = avcodec_find_encoder_by_name("libsvtav1"); if (!encoder) { encoder = avcodec_find_encoder(AV_CODEC_ID_AV1); } return encoder; } - case FB_CODEC_OPENEXR: + case fb_codec_openexr: return avcodec_find_encoder(AV_CODEC_ID_EXR); - case FB_CODEC_PNG: + case fb_codec_png: return avcodec_find_encoder(AV_CODEC_ID_PNG); - case FB_CODEC_TIFF: + case fb_codec_tiff: return avcodec_find_encoder(AV_CODEC_ID_TIFF); - case FB_CODEC_MP2: + case fb_codec_m_p2: return avcodec_find_encoder(AV_CODEC_ID_MP2); - case FB_CODEC_MP3: + case fb_codec_m_p3: return avcodec_find_encoder(AV_CODEC_ID_MP3); - case FB_CODEC_AAC: + case fb_codec_aac: return avcodec_find_encoder(AV_CODEC_ID_AAC); - case FB_CODEC_PCM: + case fb_codec_pcm: switch (sample_format) { - case FB_SAMPLE_FMT_U8: + case fb_sample_fmt_u8: return avcodec_find_encoder(AV_CODEC_ID_PCM_U8); - case FB_SAMPLE_FMT_S16: + case fb_sample_fmt_s16: return avcodec_find_encoder(AV_CODEC_ID_PCM_S16LE); - case FB_SAMPLE_FMT_S32: + case fb_sample_fmt_s32: return avcodec_find_encoder(AV_CODEC_ID_PCM_S32LE); - case FB_SAMPLE_FMT_S64: + case fb_sample_fmt_s64: return avcodec_find_encoder(AV_CODEC_ID_PCM_S64LE); - case FB_SAMPLE_FMT_FLT: + case fb_sample_fmt_flt: return avcodec_find_encoder(AV_CODEC_ID_PCM_F32LE); - case FB_SAMPLE_FMT_DBL: + case fb_sample_fmt_dbl: return avcodec_find_encoder(AV_CODEC_ID_PCM_F64LE); default: break; } break; - case FB_CODEC_FLAC: + case fb_codec_flac: return avcodec_find_encoder(AV_CODEC_ID_FLAC); - case FB_CODEC_OPUS: + case fb_codec_opus: return avcodec_find_encoder(AV_CODEC_ID_OPUS); - case FB_CODEC_VORBIS: + case fb_codec_vorbis: return avcodec_find_encoder(AV_CODEC_ID_VORBIS); - case FB_CODEC_SRT: + case fb_codec_srt: return avcodec_find_encoder(AV_CODEC_ID_SUBRIP); default: break; @@ -133,7 +133,7 @@ struct FBEncoder { std::string filename; int video_enabled = 0; - int video_codec = FB_CODEC_NONE; + int video_codec = fb_codec_none; int video_width = 0; int video_height = 0; int video_pixel_aspect_num = 1; @@ -144,9 +144,9 @@ struct FBEncoder { int video_frame_rate_den = 1; std::string video_pix_fmt; // In AVPixelFormat space (translated from the FB config value at create) - int video_src_pix_fmt = FB_PIX_FMT_NONE; - int video_color_range = FB_COLOR_RANGE_UNSPEC; - int video_field_order = FB_FIELD_ORDER_PROGRESSIVE; + int video_src_pix_fmt = fb_pix_fmt_none; + int video_color_range = fb_color_range_unspec; + int video_field_order = fb_field_order_progressive; int64_t video_bit_rate = 0; int64_t video_min_bit_rate = 0; int64_t video_max_bit_rate = 0; @@ -156,14 +156,14 @@ struct FBEncoder { std::vector> video_opts; int audio_enabled = 0; - int audio_codec = FB_CODEC_NONE; + int audio_codec = fb_codec_none; int audio_sample_rate = 0; uint64_t audio_channel_layout_mask = 0; - int audio_sample_format = FB_SAMPLE_FMT_NONE; + int audio_sample_format = fb_sample_fmt_none; int64_t audio_bit_rate = 0; int subtitles_enabled = 0; - int subtitle_codec = FB_CODEC_NONE; + int subtitle_codec = fb_codec_none; std::vector subtitle_header; // Runtime state @@ -190,29 +190,29 @@ struct FBEncoder { char error[1024] = { 0 }; - void SetError(const char *context, int error_code) + void set_error(const char *context, int error_code) { - fb::SetError(error, sizeof(error), context, error_code); + fb::set_error(error, sizeof(error), context, error_code); } - void SetError(const char *message) + void set_error(const char *message) { snprintf(error, sizeof(error), "%s", message); } - bool WriteAVFrame(AVFrame *frame, AVCodecContext *codec_ctx, + bool write_av_frame(AVFrame *frame, AVCodecContext *codec_ctx, AVStream *stream); - bool InitializeStream(AVMediaType type, AVStream **stream, + bool initialize_stream(AVMediaType type, AVStream **stream, AVCodecContext **codec_ctx, int codec); - bool InitializeCodecContext(AVStream **stream, AVCodecContext **codec_ctx, + bool initialize_codec_context(AVStream **stream, AVCodecContext **codec_ctx, const AVCodec *codec); - bool SetupCodecContext(AVStream *stream, AVCodecContext *codec_ctx, + bool setup_codec_context(AVStream *stream, AVCodecContext *codec_ctx, const AVCodec *codec); - void FlushEncoders(); - void FlushCodecCtx(AVCodecContext *codec_ctx, AVStream *stream); - bool InitializeResampleContext(int sample_format, int sample_rate, + void flush_encoders(); + void flush_codec_ctx(AVCodecContext *codec_ctx, AVStream *stream); + bool initialize_resample_context(int sample_format, int sample_rate, uint64_t channel_layout_mask); - bool WriteAudioData(int sample_format, int sample_rate, + bool write_audio_data(int sample_format, int sample_rate, uint64_t channel_layout_mask, const uint8_t **input_data, int input_sample_count); }; @@ -242,7 +242,7 @@ FBEncoder *fb_encoder_create(const FBEncoderConfig *config) } // Stored in AVPixelFormat space; the public config value is an // FB_PIX_FMT_* identifier. - e->video_src_pix_fmt = fb::PixFmtToAV(config->video_src_pix_fmt); + e->video_src_pix_fmt = fb::pix_fmt_to_av(config->video_src_pix_fmt); e->video_color_range = config->video_color_range; e->video_field_order = config->video_field_order; e->video_bit_rate = config->video_bit_rate; @@ -301,13 +301,13 @@ int fb_encoder_open(FBEncoder *e) error_code = avformat_alloc_output_context2(&e->fmt_ctx, nullptr, nullptr, e->filename.c_str()); if (error_code < 0) { - e->SetError("Failed to allocate output context", error_code); + e->set_error("Failed to allocate output context", error_code); return error_code; } // Initialize a video stream if it's enabled if (e->video_enabled) { - if (!e->InitializeStream(AVMEDIA_TYPE_VIDEO, &e->video_stream, + if (!e->initialize_stream(AVMEDIA_TYPE_VIDEO, &e->video_stream, &e->video_codec_ctx, e->video_codec)) { return AVERROR_EXTERNAL; } @@ -317,14 +317,14 @@ int fb_encoder_open(FBEncoder *e) e->video_scale_ctx = avfilter_graph_alloc(); if (!e->video_scale_ctx) { - e->SetError("Failed to allocate filter graph"); + e->set_error("Failed to allocate filter graph"); return AVERROR_EXTERNAL; } - static const int FILTER_ARG_SZ = 1024; - char filter_args[FILTER_ARG_SZ]; + static const int filter_arg_sz = 1024; + char filter_args[filter_arg_sz]; - snprintf(filter_args, FILTER_ARG_SZ, + snprintf(filter_args, filter_arg_sz, "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d", e->video_width, e->video_height, e->video_src_pix_fmt, e->video_time_base_num, e->video_time_base_den, @@ -343,8 +343,8 @@ int fb_encoder_open(FBEncoder *e) // Set color range AVFilterContext *range_filter; - snprintf(filter_args, FILTER_ARG_SZ, "in_range=full:out_range=%s", - e->video_color_range == FB_COLOR_RANGE_JPEG ? "full" : + snprintf(filter_args, filter_arg_sz, "in_range=full:out_range=%s", + e->video_color_range == fb_color_range_jpeg ? "full" : "limited"); avfilter_graph_create_filter(&range_filter, @@ -360,7 +360,7 @@ int fb_encoder_open(FBEncoder *e) // Transform pixel format AVFilterContext *format_filter; - snprintf(filter_args, FILTER_ARG_SZ, "pix_fmts=%u", encoder_pix_fmt); + snprintf(filter_args, filter_arg_sz, "pix_fmts=%u", encoder_pix_fmt); avfilter_graph_create_filter(&format_filter, avfilter_get_by_name("format"), @@ -374,14 +374,14 @@ int fb_encoder_open(FBEncoder *e) avfilter_link(last_filter, 0, e->video_buffersink_ctx, 0); if (avfilter_graph_config(e->video_scale_ctx, nullptr) < 0) { - e->SetError("Failed to configure filter graph"); + e->set_error("Failed to configure filter graph"); return AVERROR_EXTERNAL; } } // Initialize an audio stream if it's enabled if (e->audio_enabled) { - if (!e->InitializeStream(AVMEDIA_TYPE_AUDIO, &e->audio_stream, + if (!e->initialize_stream(AVMEDIA_TYPE_AUDIO, &e->audio_stream, &e->audio_codec_ctx, e->audio_codec)) { return AVERROR_EXTERNAL; } @@ -389,7 +389,7 @@ int fb_encoder_open(FBEncoder *e) // Initialize a subtitle stream if it's enabled if (e->subtitles_enabled) { - if (!e->InitializeStream(AVMEDIA_TYPE_SUBTITLE, &e->subtitle_stream, + if (!e->initialize_stream(AVMEDIA_TYPE_SUBTITLE, &e->subtitle_stream, &e->subtitle_codec_ctx, e->subtitle_codec)) { return AVERROR_EXTERNAL; } @@ -400,14 +400,14 @@ int fb_encoder_open(FBEncoder *e) // Open output file for writing error_code = avio_open(&e->fmt_ctx->pb, e->filename.c_str(), AVIO_FLAG_WRITE); if (error_code < 0) { - e->SetError("Failed to open IO context", error_code); + e->set_error("Failed to open IO context", error_code); return error_code; } // Write header error_code = avformat_write_header(e->fmt_ctx, nullptr); if (error_code < 0) { - e->SetError("Failed to write format header", error_code); + e->set_error("Failed to write format header", error_code); return error_code; } @@ -426,13 +426,13 @@ int fb_encoder_write_video_frame(FBEncoder *e, int width, int height, // Use the filter graph to convert formats/linesizes AVFrame *input_frame = av_frame_alloc(); if (!input_frame) { - e->SetError("Failed to allocate input frame"); + e->set_error("Failed to allocate input frame"); return AVERROR(ENOMEM); } input_frame->width = width; input_frame->height = height; - input_frame->format = fb::PixFmtToAV(pix_fmt); + input_frame->format = fb::pix_fmt_to_av(pix_fmt); input_frame->data[0] = const_cast(data); input_frame->linesize[0] = linesize; @@ -445,20 +445,20 @@ int fb_encoder_write_video_frame(FBEncoder *e, int width, int height, AV_BUFFERSRC_FLAG_KEEP_REF); av_frame_free(&input_frame); if (r < 0) { - e->SetError("Failed to add frame to filter graph", r); + e->set_error("Failed to add frame to filter graph", r); return r; } AVFrame *encoded_frame = av_frame_alloc(); if (!encoded_frame) { - e->SetError("Failed to allocate encode frame"); + e->set_error("Failed to allocate encode frame"); return AVERROR(ENOMEM); } r = av_buffersink_get_frame(e->video_buffersink_ctx, encoded_frame); if (r < 0) { av_frame_free(&encoded_frame); - e->SetError("Failed to retrieve frame from buffer sink", r); + e->set_error("Failed to retrieve frame from buffer sink", r); return r; } @@ -466,21 +466,21 @@ int fb_encoder_write_video_frame(FBEncoder *e, int width, int height, llround(time_seconds / av_q2d(e->video_codec_ctx->time_base)); bool result = - e->WriteAVFrame(encoded_frame, e->video_codec_ctx, e->video_stream); + e->write_av_frame(encoded_frame, e->video_codec_ctx, e->video_stream); av_frame_free(&encoded_frame); return result ? 0 : AVERROR_EXTERNAL; } -bool FBEncoder::WriteAudioData(int sample_format, int sample_rate, +bool FBEncoder::write_audio_data(int sample_format, int sample_rate, uint64_t channel_layout_mask, const uint8_t **input_data, int input_sample_count) { - if (!InitializeResampleContext(sample_format, sample_rate, + if (!initialize_resample_context(sample_format, sample_rate, channel_layout_mask)) { - SetError("Failed to initialize resample context"); + set_error("Failed to initialize resample context"); return false; } @@ -527,13 +527,13 @@ bool FBEncoder::WriteAudioData(int sample_format, int sample_rate, audio_write_count, { 1, audio_codec_ctx->sample_rate }, audio_codec_ctx->time_base); - WriteAVFrame(audio_frame, audio_codec_ctx, audio_stream); + write_av_frame(audio_frame, audio_codec_ctx, audio_stream); audio_write_count += audio_frame_offset; audio_frame_offset = 0; } } } else if (converted < 0) { - SetError("Failed to resample audio", converted); + set_error("Failed to resample audio", converted); result = false; } @@ -542,7 +542,7 @@ bool FBEncoder::WriteAudioData(int sample_format, int sample_rate, audio_frame->pts = av_rescale_q(audio_write_count, { 1, audio_codec_ctx->sample_rate }, audio_codec_ctx->time_base); - WriteAVFrame(audio_frame, audio_codec_ctx, audio_stream); + write_av_frame(audio_frame, audio_codec_ctx, audio_stream); } // Free buffers created @@ -590,7 +590,7 @@ int fb_encoder_write_audio(FBEncoder *e, const uint8_t *const *channel_data, static_cast(sample_format), 0); if (r < 0) { - e->SetError("Failed to allocate sample array", r); + e->set_error("Failed to allocate sample array", r); return r; } else { if (planar) { @@ -608,7 +608,7 @@ int fb_encoder_write_audio(FBEncoder *e, const uint8_t *const *channel_data, start += input_sample_count; } - result = e->WriteAudioData(sample_format, sample_rate, + result = e->write_audio_data(sample_format, sample_rate, channel_layout_mask, const_cast(input_data), int(input_sample_count)); @@ -659,7 +659,7 @@ int fb_encoder_write_subtitle(FBEncoder *e, const char *utf8_text, bool ret = true; if (err < 0) { - e->SetError("Failed to write interleaved packet", err); + e->set_error("Failed to write interleaved packet", err); ret = false; } @@ -676,7 +676,7 @@ void fb_encoder_close(FBEncoder *e) if (e->open) { // Flush encoders - e->FlushEncoders(); + e->flush_encoders(); // We've written a header, so we'll write a trailer av_write_trailer(e->fmt_ctx); @@ -732,13 +732,13 @@ const char *fb_encoder_get_error(const FBEncoder *encoder) return encoder ? encoder->error : ""; } -bool FBEncoder::WriteAVFrame(AVFrame *frame, AVCodecContext *codec_ctx, +bool FBEncoder::write_av_frame(AVFrame *frame, AVCodecContext *codec_ctx, AVStream *stream) { // Send raw frame to the encoder int error_code = avcodec_send_frame(codec_ctx, frame); if (error_code < 0) { - SetError("Failed to send frame to encoder", error_code); + set_error("Failed to send frame to encoder", error_code); return false; } @@ -754,7 +754,7 @@ bool FBEncoder::WriteAVFrame(AVFrame *frame, AVCodecContext *codec_ctx, if (error_code == AVERROR(EAGAIN)) { break; } else if (error_code < 0) { - SetError("Failed to receive packet from decoder", error_code); + set_error("Failed to receive packet from decoder", error_code); goto fail; } @@ -766,7 +766,7 @@ bool FBEncoder::WriteAVFrame(AVFrame *frame, AVCodecContext *codec_ctx, // Write packet to file error_code = av_interleaved_write_frame(fmt_ctx, pkt); if (error_code < 0) { - SetError("Failed to write interleaved packet", error_code); + set_error("Failed to write interleaved packet", error_code); goto fail; } @@ -782,30 +782,30 @@ fail: return succeeded; } -bool FBEncoder::InitializeStream(AVMediaType type, AVStream **stream_ptr, +bool FBEncoder::initialize_stream(AVMediaType type, AVStream **stream_ptr, AVCodecContext **codec_ctx_ptr, int codec) { if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO && type != AVMEDIA_TYPE_SUBTITLE) { - SetError("Cannot initialize a stream that is not a video, audio, or subtitle type"); + set_error("Cannot initialize a stream that is not a video, audio, or subtitle type"); return false; } // Find encoder - const AVCodec *encoder = FindEncoder(codec, audio_sample_format); + const AVCodec *encoder = find_encoder(codec, audio_sample_format); if (!encoder) { char msg[128]; snprintf(msg, sizeof(msg), "Failed to find codec for 0x%x", codec); - SetError(msg); + set_error(msg); return false; } if (encoder->type != type) { - SetError("Retrieved unexpected codec type for codec"); + set_error("Retrieved unexpected codec type for codec"); return false; } - if (!InitializeCodecContext(stream_ptr, codec_ctx_ptr, encoder)) { + if (!initialize_codec_context(stream_ptr, codec_ctx_ptr, encoder)) { return false; } @@ -821,23 +821,23 @@ bool FBEncoder::InitializeStream(AVMediaType type, AVStream **stream_ptr, codec_ctx->time_base = { video_time_base_num, video_time_base_den }; codec_ctx->framerate = { video_frame_rate_num, video_frame_rate_den }; codec_ctx->pix_fmt = av_get_pix_fmt(video_pix_fmt.c_str()); - codec_ctx->color_range = video_color_range == FB_COLOR_RANGE_JPEG ? + codec_ctx->color_range = video_color_range == fb_color_range_jpeg ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; - if (video_field_order != FB_FIELD_ORDER_PROGRESSIVE) { + if (video_field_order != fb_field_order_progressive) { // FIXME: I actually don't know what these flags do, the documentation helpfully doesn't // explain them at all. I hope using both of them is the right thing to do. codec_ctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME; - if (video_field_order == FB_FIELD_ORDER_TT) { + if (video_field_order == fb_field_order_tt) { codec_ctx->field_order = AV_FIELD_TT; } else { codec_ctx->field_order = AV_FIELD_BB; - if (video_codec == FB_CODEC_H264 || - video_codec == FB_CODEC_H264RGB) { + if (video_codec == fb_codec_h264 || + video_codec == fb_codec_h264_rgb) { // For some reason, FFmpeg doesn't set libx264's bff flag so we have to do it ourselves av_opt_set(codec_ctx->priv_data, "x264opts", "bff=1", AV_OPT_SEARCH_CHILDREN); @@ -902,34 +902,34 @@ bool FBEncoder::InitializeStream(AVMediaType type, AVStream **stream_ptr, } } - if (!SetupCodecContext(stream, codec_ctx, encoder)) { + if (!setup_codec_context(stream, codec_ctx, encoder)) { return false; } return true; } -bool FBEncoder::InitializeCodecContext(AVStream **stream, +bool FBEncoder::initialize_codec_context(AVStream **stream, AVCodecContext **codec_ctx, const AVCodec *codec) { *stream = avformat_new_stream(fmt_ctx, nullptr); if (!(*stream)) { - SetError("Failed to allocate AVStream"); + set_error("Failed to allocate AVStream"); return false; } // Allocate a codec context *codec_ctx = avcodec_alloc_context3(codec); if (!(*codec_ctx)) { - SetError("Failed to allocate AVCodecContext"); + set_error("Failed to allocate AVCodecContext"); return false; } return true; } -bool FBEncoder::SetupCodecContext(AVStream *stream, AVCodecContext *codec_ctx, +bool FBEncoder::setup_codec_context(AVStream *stream, AVCodecContext *codec_ctx, const AVCodec *codec) { int error_code; @@ -953,14 +953,14 @@ bool FBEncoder::SetupCodecContext(AVStream *stream, AVCodecContext *codec_ctx, error_code = avcodec_open2(codec_ctx, codec, &codec_opts); av_dict_free(&codec_opts); if (error_code < 0) { - SetError("Failed to open encoder", error_code); + set_error("Failed to open encoder", error_code); return false; } // Copy context settings to codecpar object error_code = avcodec_parameters_from_context(stream->codecpar, codec_ctx); if (error_code < 0) { - SetError("Failed to copy codec parameters to stream", error_code); + set_error("Failed to copy codec parameters to stream", error_code); return false; } @@ -971,27 +971,27 @@ bool FBEncoder::SetupCodecContext(AVStream *stream, AVCodecContext *codec_ctx, return true; } -void FBEncoder::FlushEncoders() +void FBEncoder::flush_encoders() { if (video_codec_ctx) { - FlushCodecCtx(video_codec_ctx, video_stream); + flush_codec_ctx(video_codec_ctx, video_stream); } if (audio_codec_ctx) { - FlushCodecCtx(audio_codec_ctx, audio_stream); + flush_codec_ctx(audio_codec_ctx, audio_stream); } if (fmt_ctx) { if (fmt_ctx->oformat->flags) { int r = av_interleaved_write_frame(fmt_ctx, nullptr); if (r < 0) { - SetError("Failed to write interleaved packet", r); + set_error("Failed to write interleaved packet", r); } } } } -void FBEncoder::FlushCodecCtx(AVCodecContext *codec_ctx, AVStream *stream) +void FBEncoder::flush_codec_ctx(AVCodecContext *codec_ctx, AVStream *stream) { avcodec_send_frame(codec_ctx, nullptr); AVPacket *pkt = av_packet_alloc(); @@ -1008,7 +1008,7 @@ void FBEncoder::FlushCodecCtx(AVCodecContext *codec_ctx, AVStream *stream) av_packet_rescale_ts(pkt, codec_ctx->time_base, stream->time_base); int r = av_interleaved_write_frame(fmt_ctx, pkt); if (r < 0) { - SetError("Failed to write interleaved packet", r); + set_error("Failed to write interleaved packet", r); break; } av_packet_unref(pkt); @@ -1017,7 +1017,7 @@ void FBEncoder::FlushCodecCtx(AVCodecContext *codec_ctx, AVStream *stream) av_packet_free(&pkt); } -bool FBEncoder::InitializeResampleContext(int sample_format, int sample_rate, +bool FBEncoder::initialize_resample_context(int sample_format, int sample_rate, uint64_t channel_layout_mask) { if (audio_resample_ctx) { @@ -1025,7 +1025,7 @@ bool FBEncoder::InitializeResampleContext(int sample_format, int sample_rate, } AVChannelLayout layout; - fb::ChannelLayoutFromMask(&layout, channel_layout_mask, 0); + fb::channel_layout_from_mask(&layout, channel_layout_mask, 0); // Create resample context swr_alloc_set_opts2(&audio_resample_ctx, &audio_codec_ctx->ch_layout, @@ -1041,7 +1041,7 @@ bool FBEncoder::InitializeResampleContext(int sample_format, int sample_rate, int err = swr_init(audio_resample_ctx); if (err < 0) { - SetError("Failed to create resampling context", err); + set_error("Failed to create resampling context", err); return false; } @@ -1070,7 +1070,7 @@ bool FBEncoder::InitializeResampleContext(int sample_format, int sample_rate, err = av_frame_get_buffer(audio_frame, 0); if (err < 0) { - SetError("Failed to create audio frame", err); + set_error("Failed to create audio frame", err); return false; } @@ -1083,7 +1083,7 @@ bool FBEncoder::InitializeResampleContext(int sample_format, int sample_rate, int fb_encoder_codec_get_pixel_formats(int codec, const char **names, int max_names) { - const AVCodec *codec_info = FindEncoder(codec, FB_SAMPLE_FMT_NONE); + const AVCodec *codec_info = find_encoder(codec, fb_sample_fmt_none); if (!codec_info || !codec_info->pix_fmts) { return 0; } @@ -1091,7 +1091,7 @@ int fb_encoder_codec_get_pixel_formats(int codec, const char **names, int count = 0; for (int i = 0; codec_info->pix_fmts[i] != AV_PIX_FMT_NONE; i++) { AVPixelFormat fmt = codec_info->pix_fmts[i]; - if (ConvertJPEGSpaceToRegularSpace(fmt) != fmt) { + if (convert_jpeg_space_to_regular_space(fmt) != fmt) { // This is a deprecated "JPEG" space, skip it continue; } @@ -1107,7 +1107,7 @@ int fb_encoder_codec_get_pixel_formats(int codec, const char **names, int fb_encoder_codec_get_sample_formats(int codec, int *fmts, int max_fmts) { - const AVCodec *codec_info = FindEncoder(codec, FB_SAMPLE_FMT_NONE); + const AVCodec *codec_info = find_encoder(codec, fb_sample_fmt_none); if (!codec_info || !codec_info->sample_fmts) { return 0; } diff --git a/ffmpeg_bridge/src/frame.cpp b/ffmpeg_bridge/src/frame.cpp index 63434cb46..69258d212 100644 --- a/ffmpeg_bridge/src/frame.cpp +++ b/ffmpeg_bridge/src/frame.cpp @@ -114,14 +114,14 @@ void fb_frame_set_height(FBFrame *frame, int height) int fb_frame_get_format(const FBFrame *frame) { - return frame ? fb::PixFmtFromAV(AVPixelFormat(frame->frame->format)) : - FB_PIX_FMT_NONE; + return frame ? fb::pix_fmt_from_av(AVPixelFormat(frame->frame->format)) : + fb_pix_fmt_none; } void fb_frame_set_format(FBFrame *frame, int format) { if (frame) { - frame->frame->format = fb::PixFmtToAV(format); + frame->frame->format = fb::pix_fmt_to_av(format); } } @@ -168,7 +168,7 @@ void fb_frame_set_sample_rate(FBFrame *frame, int sample_rate) int fb_frame_get_color_range(const FBFrame *frame) { - return frame ? int(frame->frame->color_range) : FB_COLOR_RANGE_UNSPEC; + return frame ? int(frame->frame->color_range) : fb_color_range_unspec; } void fb_frame_set_color_range(FBFrame *frame, int color_range) @@ -180,7 +180,7 @@ void fb_frame_set_color_range(FBFrame *frame, int color_range) int fb_frame_get_colorspace(const FBFrame *frame) { - return frame ? int(frame->frame->colorspace) : FB_COL_SPC_UNSPEC; + return frame ? int(frame->frame->colorspace) : fb_col_spc_unspec; } void fb_frame_set_colorspace(FBFrame *frame, int colorspace) diff --git a/ffmpeg_bridge/src/internal.h b/ffmpeg_bridge/src/internal.h index 2cf15dbf0..5ce09d92f 100644 --- a/ffmpeg_bridge/src/internal.h +++ b/ffmpeg_bridge/src/internal.h @@ -19,8 +19,8 @@ ***/ -#ifndef FFMPEG_BRIDGE_INTERNAL_H -#define FFMPEG_BRIDGE_INTERNAL_H +#ifndef OAK_FFMPEG_BRIDGE_INTERNAL_H +#define OAK_FFMPEG_BRIDGE_INTERNAL_H // Fixes weird define issue when including #include @@ -55,46 +55,46 @@ static_assert(FB_NOPTS_VALUE == AV_NOPTS_VALUE, "FB_NOPTS_VALUE mismatch"); static_assert(FB_TIME_BASE == AV_TIME_BASE, "FB_TIME_BASE mismatch"); static_assert(FB_SCALER_POINT == SWS_POINT, "FB_SCALER_POINT mismatch"); -static_assert(FB_PIX_FMT_NONE == AV_PIX_FMT_NONE, "FB_PIX_FMT_NONE mismatch"); +static_assert(fb_pix_fmt_none == AV_PIX_FMT_NONE, "FB_PIX_FMT_NONE mismatch"); -static_assert(FB_SAMPLE_FMT_NONE == AV_SAMPLE_FMT_NONE, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_U8 == AV_SAMPLE_FMT_U8, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_S16 == AV_SAMPLE_FMT_S16, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_S32 == AV_SAMPLE_FMT_S32, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_FLT == AV_SAMPLE_FMT_FLT, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_DBL == AV_SAMPLE_FMT_DBL, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_U8P == AV_SAMPLE_FMT_U8P, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_S16P == AV_SAMPLE_FMT_S16P, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_S32P == AV_SAMPLE_FMT_S32P, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_FLTP == AV_SAMPLE_FMT_FLTP, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_DBLP == AV_SAMPLE_FMT_DBLP, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_S64 == AV_SAMPLE_FMT_S64, "samplefmt mismatch"); -static_assert(FB_SAMPLE_FMT_S64P == AV_SAMPLE_FMT_S64P, "samplefmt mismatch"); +static_assert(fb_sample_fmt_none == AV_SAMPLE_FMT_NONE, "samplefmt mismatch"); +static_assert(fb_sample_fmt_u8 == AV_SAMPLE_FMT_U8, "samplefmt mismatch"); +static_assert(fb_sample_fmt_s16 == AV_SAMPLE_FMT_S16, "samplefmt mismatch"); +static_assert(fb_sample_fmt_s32 == AV_SAMPLE_FMT_S32, "samplefmt mismatch"); +static_assert(fb_sample_fmt_flt == AV_SAMPLE_FMT_FLT, "samplefmt mismatch"); +static_assert(fb_sample_fmt_dbl == AV_SAMPLE_FMT_DBL, "samplefmt mismatch"); +static_assert(fb_sample_fmt_u8_p == AV_SAMPLE_FMT_U8P, "samplefmt mismatch"); +static_assert(fb_sample_fmt_s16_p == AV_SAMPLE_FMT_S16P, "samplefmt mismatch"); +static_assert(fb_sample_fmt_s32_p == AV_SAMPLE_FMT_S32P, "samplefmt mismatch"); +static_assert(fb_sample_fmt_fltp == AV_SAMPLE_FMT_FLTP, "samplefmt mismatch"); +static_assert(fb_sample_fmt_dblp == AV_SAMPLE_FMT_DBLP, "samplefmt mismatch"); +static_assert(fb_sample_fmt_s64 == AV_SAMPLE_FMT_S64, "samplefmt mismatch"); +static_assert(fb_sample_fmt_s64_p == AV_SAMPLE_FMT_S64P, "samplefmt mismatch"); -static_assert(FB_COLOR_RANGE_UNSPEC == AVCOL_RANGE_UNSPECIFIED, "range mismatch"); -static_assert(FB_COLOR_RANGE_MPEG == AVCOL_RANGE_MPEG, "range mismatch"); -static_assert(FB_COLOR_RANGE_JPEG == AVCOL_RANGE_JPEG, "range mismatch"); +static_assert(fb_color_range_unspec == AVCOL_RANGE_UNSPECIFIED, "range mismatch"); +static_assert(fb_color_range_mpeg == AVCOL_RANGE_MPEG, "range mismatch"); +static_assert(fb_color_range_jpeg == AVCOL_RANGE_JPEG, "range mismatch"); -static_assert(FB_COL_SPC_RGB == AVCOL_SPC_RGB, "colspace mismatch"); -static_assert(FB_COL_SPC_BT709 == AVCOL_SPC_BT709, "colspace mismatch"); -static_assert(FB_COL_SPC_UNSPEC == AVCOL_SPC_UNSPECIFIED, "colspace mismatch"); -static_assert(FB_COL_SPC_FCC == AVCOL_SPC_FCC, "colspace mismatch"); -static_assert(FB_COL_SPC_BT470BG == AVCOL_SPC_BT470BG, "colspace mismatch"); -static_assert(FB_COL_SPC_SMPTE170M == AVCOL_SPC_SMPTE170M, "colspace mismatch"); -static_assert(FB_COL_SPC_SMPTE240M == AVCOL_SPC_SMPTE240M, "colspace mismatch"); -static_assert(FB_COL_SPC_BT2020_NCL == AVCOL_SPC_BT2020_NCL, "colspace mismatch"); +static_assert(fb_col_spc_rgb == AVCOL_SPC_RGB, "colspace mismatch"); +static_assert(fb_col_spc_b_t709 == AVCOL_SPC_BT709, "colspace mismatch"); +static_assert(fb_col_spc_unspec == AVCOL_SPC_UNSPECIFIED, "colspace mismatch"); +static_assert(fb_col_spc_fcc == AVCOL_SPC_FCC, "colspace mismatch"); +static_assert(fb_col_spc_b_t470_bg == AVCOL_SPC_BT470BG, "colspace mismatch"); +static_assert(fb_col_spc_smpt_e170_m == AVCOL_SPC_SMPTE170M, "colspace mismatch"); +static_assert(fb_col_spc_smpt_e240_m == AVCOL_SPC_SMPTE240M, "colspace mismatch"); +static_assert(fb_col_spc_b_t2020_ncl == AVCOL_SPC_BT2020_NCL, "colspace mismatch"); -static_assert(FB_MEDIA_TYPE_VIDEO == AVMEDIA_TYPE_VIDEO, "mediatype mismatch"); -static_assert(FB_MEDIA_TYPE_AUDIO == AVMEDIA_TYPE_AUDIO, "mediatype mismatch"); -static_assert(FB_MEDIA_TYPE_DATA == AVMEDIA_TYPE_DATA, "mediatype mismatch"); -static_assert(FB_MEDIA_TYPE_SUBTITLE == AVMEDIA_TYPE_SUBTITLE, "mediatype mismatch"); +static_assert(fb_media_type_video == AVMEDIA_TYPE_VIDEO, "mediatype mismatch"); +static_assert(fb_media_type_audio == AVMEDIA_TYPE_AUDIO, "mediatype mismatch"); +static_assert(fb_media_type_data == AVMEDIA_TYPE_DATA, "mediatype mismatch"); +static_assert(fb_media_type_subtitle == AVMEDIA_TYPE_SUBTITLE, "mediatype mismatch"); -static_assert(FB_FIELD_ORDER_UNKNOWN == AV_FIELD_UNKNOWN, "fieldorder mismatch"); -static_assert(FB_FIELD_ORDER_PROGRESSIVE == AV_FIELD_PROGRESSIVE, "fieldorder mismatch"); -static_assert(FB_FIELD_ORDER_TT == AV_FIELD_TT, "fieldorder mismatch"); -static_assert(FB_FIELD_ORDER_BB == AV_FIELD_BB, "fieldorder mismatch"); -static_assert(FB_FIELD_ORDER_TB == AV_FIELD_TB, "fieldorder mismatch"); -static_assert(FB_FIELD_ORDER_BT == AV_FIELD_BT, "fieldorder mismatch"); +static_assert(fb_field_order_unknown == AV_FIELD_UNKNOWN, "fieldorder mismatch"); +static_assert(fb_field_order_progressive == AV_FIELD_PROGRESSIVE, "fieldorder mismatch"); +static_assert(fb_field_order_tt == AV_FIELD_TT, "fieldorder mismatch"); +static_assert(fb_field_order_bb == AV_FIELD_BB, "fieldorder mismatch"); +static_assert(fb_field_order_tb == AV_FIELD_TB, "fieldorder mismatch"); +static_assert(fb_field_order_bt == AV_FIELD_BT, "fieldorder mismatch"); static_assert(FB_CH_LAYOUT_MONO == AV_CH_LAYOUT_MONO, "layout mismatch"); static_assert(FB_CH_LAYOUT_STEREO == AV_CH_LAYOUT_STEREO, "layout mismatch"); @@ -123,15 +123,15 @@ namespace fb /** Allocate a channel layout from a mask, falling back to a default layout * derived from `fallback_channels` when the mask is zero. */ -void ChannelLayoutFromMask(AVChannelLayout *layout, uint64_t mask, +void channel_layout_from_mask(AVChannelLayout *layout, uint64_t mask, int fallback_channels); /** Validate a stream's channel layout, returning a usable mask (never zero * unless the stream truly has no channels). */ -uint64_t ValidateStreamChannelLayoutMask(const AVStream *stream); +uint64_t validate_stream_channel_layout_mask(const AVStream *stream); /** Map an AVColorSpace to the corresponding SWS_CS_* constant. */ -int SwsColorspaceFromAVColorSpace(AVColorSpace cs); +int sws_colorspace_from_av_color_space(AVColorSpace cs); /** * Translate an FB_PIX_FMT_* value to the AVPixelFormat of the FFmpeg build @@ -141,7 +141,7 @@ int SwsColorspaceFromAVColorSpace(AVColorSpace cs); * AV_PIX_FMT_NONE for FB_PIX_FMT_NONE and for static FB formats unknown to * this FFmpeg build (e.g. rgbf16le/grayf16le on FFmpeg < 7.1). */ -AVPixelFormat PixFmtToAV(int fb_fmt); +AVPixelFormat pix_fmt_to_av(int fb_fmt); /** * Reverse of PixFmtToAV. Returns FB_PIX_FMT_NONE for AV_PIX_FMT_NONE. @@ -149,11 +149,11 @@ AVPixelFormat PixFmtToAV(int fb_fmt); * formats such as p210le, etc.) receive a process-local dynamic id >= 1000 * so they can still round-trip through the API. */ -int PixFmtFromAV(AVPixelFormat fmt); +int pix_fmt_from_av(AVPixelFormat fmt); -void SetError(char *error_buffer, size_t error_buffer_size, const char *context, +void set_error(char *error_buffer, size_t error_buffer_size, const char *context, int error_code); } // namespace fb -#endif // FFMPEG_BRIDGE_INTERNAL_H +#endif // OAK_FFMPEG_BRIDGE_INTERNAL_H diff --git a/ffmpeg_bridge/src/probe.cpp b/ffmpeg_bridge/src/probe.cpp index c6cfef227..e9727c502 100644 --- a/ffmpeg_bridge/src/probe.cpp +++ b/ffmpeg_bridge/src/probe.cpp @@ -31,10 +31,10 @@ struct FBProbe { namespace { -constexpr int64_t kAnalyzeDurationUs = 5000000; -constexpr int64_t kProbeSizeBytes = 20000000; +constexpr int64_t k_analyze_duration_us = 5000000; +constexpr int64_t k_probe_size_bytes = 20000000; -void FillStreamInfo(const AVStream *s, int has_decoder, FBStreamInfo *out) +void fill_stream_info(const AVStream *s, int has_decoder, FBStreamInfo *out) { const AVCodecParameters *par = s->codecpar; @@ -45,12 +45,12 @@ void FillStreamInfo(const AVStream *s, int has_decoder, FBStreamInfo *out) out->has_decoder = has_decoder; out->width = par->width; out->height = par->height; - out->pixel_format = fb::PixFmtFromAV(AVPixelFormat(par->format)); - out->field_order = FB_FIELD_ORDER_UNKNOWN; + out->pixel_format = fb::pix_fmt_from_av(AVPixelFormat(par->format)); + out->field_order = fb_field_order_unknown; out->color_range = par->color_range; out->sample_rate = par->sample_rate; out->sample_format = par->format; - out->channel_layout_mask = fb::ValidateStreamChannelLayoutMask(s); + out->channel_layout_mask = fb::validate_stream_channel_layout_mask(s); out->start_time = s->start_time; out->duration = s->duration; out->time_base_num = s->time_base.num; @@ -59,7 +59,7 @@ void FillStreamInfo(const AVStream *s, int has_decoder, FBStreamInfo *out) out->avg_frame_rate_den = s->avg_frame_rate.den; } -bool IsCancelled(FBCancelCallback cancel, void *userdata) +bool is_cancelled(FBCancelCallback cancel, void *userdata) { return cancel && cancel(userdata); } @@ -87,16 +87,16 @@ int fb_probe_open(FBProbe *probe, const char *filename) } AVDictionary *format_opts = nullptr; - av_dict_set_int(&format_opts, "analyzeduration", kAnalyzeDurationUs, 0); - av_dict_set_int(&format_opts, "probesize", kProbeSizeBytes, 0); + av_dict_set_int(&format_opts, "analyzeduration", k_analyze_duration_us, 0); + av_dict_set_int(&format_opts, "probesize", k_probe_size_bytes, 0); AVFormatContext *ctx = nullptr; int error_code = avformat_open_input(&ctx, filename, nullptr, &format_opts); av_dict_free(&format_opts); if (ctx) { - ctx->probesize = kProbeSizeBytes; - ctx->max_analyze_duration = kAnalyzeDurationUs; + ctx->probesize = k_probe_size_bytes; + ctx->max_analyze_duration = k_analyze_duration_us; // Subtitle streams are read on demand, don't let them slow down probing for (unsigned int i = 0; i < ctx->nb_streams; i++) { @@ -144,7 +144,7 @@ int fb_probe_get_stream_info(const FBProbe *probe, int stream_index, const AVStream *s = probe->fmt_ctx->streams[stream_index]; int has_decoder = avcodec_find_decoder(s->codecpar->codec_id) != nullptr; - FillStreamInfo(s, has_decoder, out); + fill_stream_info(s, has_decoder, out); return 0; } @@ -210,7 +210,7 @@ int fb_probe_video_stream_details(const char *filename, int stream_index, } memset(out, 0, sizeof(*out)); - out->field_order = FB_FIELD_ORDER_PROGRESSIVE; + out->field_order = fb_field_order_progressive; out->pixel_aspect_num = 1; out->pixel_aspect_den = 1; out->decoded_duration = FB_NOPTS_VALUE; @@ -250,7 +250,7 @@ int fb_probe_video_stream_details(const char *filename, int stream_index, // Decode until the end to determine the true duration int64_t last_ts = fb_frame_get_best_effort_timestamp(frame); while (fb_decoder_get_frame(decoder, pkt, frame) >= 0 && - !IsCancelled(cancel, cancel_userdata)) { + !is_cancelled(cancel, cancel_userdata)) { last_ts = fb_frame_get_best_effort_timestamp(frame); } out->decoded_duration = last_ts; @@ -285,7 +285,7 @@ int fb_probe_audio_stream_duration(const char *filename, int stream_index, do { duration = fb_frame_get_best_effort_timestamp(frame); } while (fb_decoder_get_frame(decoder, pkt, frame) >= 0 && - !IsCancelled(cancel, cancel_userdata)); + !is_cancelled(cancel, cancel_userdata)); fb_frame_free(&frame); fb_packet_free(&pkt); diff --git a/ffmpeg_bridge/src/swr.cpp b/ffmpeg_bridge/src/swr.cpp index 57d0fdaa5..9ca92dd04 100644 --- a/ffmpeg_bridge/src/swr.cpp +++ b/ffmpeg_bridge/src/swr.cpp @@ -30,8 +30,8 @@ FBResampler *fb_resampler_create(uint64_t out_layout_mask, int out_format, int in_format, int in_rate) { AVChannelLayout out_layout, in_layout; - fb::ChannelLayoutFromMask(&out_layout, out_layout_mask, 0); - fb::ChannelLayoutFromMask(&in_layout, in_layout_mask, 0); + fb::channel_layout_from_mask(&out_layout, out_layout_mask, 0); + fb::channel_layout_from_mask(&in_layout, in_layout_mask, 0); SwrContext *ctx = nullptr; int r = swr_alloc_set_opts2(&ctx, &out_layout, diff --git a/ffmpeg_bridge/src/sws.cpp b/ffmpeg_bridge/src/sws.cpp index 0d8276c3f..5d29976e0 100644 --- a/ffmpeg_bridge/src/sws.cpp +++ b/ffmpeg_bridge/src/sws.cpp @@ -30,8 +30,8 @@ FBScaler *fb_scaler_create(int src_width, int src_height, int src_format, int flags) { SwsContext *ctx = sws_getContext( - src_width, src_height, fb::PixFmtToAV(src_format), - dst_width, dst_height, fb::PixFmtToAV(dst_format), flags, + src_width, src_height, fb::pix_fmt_to_av(src_format), + dst_width, dst_height, fb::pix_fmt_to_av(dst_format), flags, nullptr, nullptr, nullptr); if (!ctx) { return nullptr; @@ -58,7 +58,7 @@ int fb_scaler_set_colorspace(FBScaler *scaler, int colorspace, int jpeg_range) } const int *coeffs = sws_getCoefficients( - fb::SwsColorspaceFromAVColorSpace(static_cast(colorspace))); + fb::sws_colorspace_from_av_color_space(static_cast(colorspace))); return sws_setColorspaceDetails(scaler->ctx, coeffs, jpeg_range, coeffs, jpeg_range, 0, 0x10000, 0x10000); } @@ -85,7 +85,7 @@ int fb_scaler_scale_slices(FBScaler *scaler, const uint8_t *const *src_data, void fb_get_yuv_coefficients(int colorspace, double out[4]) { const int *coeffs = sws_getCoefficients( - fb::SwsColorspaceFromAVColorSpace(static_cast(colorspace))); + fb::sws_colorspace_from_av_color_space(static_cast(colorspace))); // Matches the historical usage order: crv, cbu, cgu, cgv out[0] = coeffs[0] / 65536.0; // crv out[1] = coeffs[1] / 65536.0; // cbu diff --git a/ffmpeg_bridge/src/utils.cpp b/ffmpeg_bridge/src/utils.cpp index 49224eb6b..2f9df9693 100644 --- a/ffmpeg_bridge/src/utils.cpp +++ b/ffmpeg_bridge/src/utils.cpp @@ -48,38 +48,38 @@ struct PixFmtName { const char *av_name; }; -constexpr PixFmtName kPixFmtNames[] = { - { FB_PIX_FMT_YUV420P, "yuv420p" }, - { FB_PIX_FMT_RGB24, "rgb24" }, - { FB_PIX_FMT_YUV422P, "yuv422p" }, - { FB_PIX_FMT_YUV444P, "yuv444p" }, - { FB_PIX_FMT_YUV410P, "yuv410p" }, - { FB_PIX_FMT_YUV411P, "yuv411p" }, - { FB_PIX_FMT_GRAY8, "gray8" }, - { FB_PIX_FMT_YUVJ420P, "yuvj420p" }, - { FB_PIX_FMT_YUVJ422P, "yuvj422p" }, - { FB_PIX_FMT_YUVJ444P, "yuvj444p" }, - { FB_PIX_FMT_NV12, "nv12" }, - { FB_PIX_FMT_RGBA, "rgba" }, - { FB_PIX_FMT_GRAY16LE, "gray16le" }, - { FB_PIX_FMT_YUV440P, "yuv440p" }, - { FB_PIX_FMT_YUVJ440P, "yuvj440p" }, - { FB_PIX_FMT_RGB48LE, "rgb48le" }, - { FB_PIX_FMT_YUV420P10LE, "yuv420p10le" }, - { FB_PIX_FMT_YUV422P10LE, "yuv422p10le" }, - { FB_PIX_FMT_YUV444P10LE, "yuv444p10le" }, - { FB_PIX_FMT_RGBA64LE, "rgba64le" }, - { FB_PIX_FMT_YUV420P12LE, "yuv420p12le" }, - { FB_PIX_FMT_YUV422P12LE, "yuv422p12le" }, - { FB_PIX_FMT_YUV444P12LE, "yuv444p12le" }, - { FB_PIX_FMT_YUVJ411P, "yuvj411p" }, - { FB_PIX_FMT_P010LE, "p010le" }, - { FB_PIX_FMT_GRAYF32LE, "grayf32le" }, - { FB_PIX_FMT_RGBAF16LE, "rgbaf16le" }, - { FB_PIX_FMT_RGBF32LE, "rgbf32le" }, - { FB_PIX_FMT_RGBAF32LE, "rgbaf32le" }, - { FB_PIX_FMT_RGBF16LE, "rgbf16le" }, - { FB_PIX_FMT_GRAYF16LE, "grayf16le" }, +constexpr PixFmtName k_pix_fmt_names[] = { + { fb_pix_fmt_yu_v420_p, "yuv420p" }, + { fb_pix_fmt_rg_b24, "rgb24" }, + { fb_pix_fmt_yu_v422_p, "yuv422p" }, + { fb_pix_fmt_yu_v444_p, "yuv444p" }, + { fb_pix_fmt_yu_v410_p, "yuv410p" }, + { fb_pix_fmt_yu_v411_p, "yuv411p" }, + { fb_pix_fmt_gra_y8, "gray8" }, + { fb_pix_fmt_yuv_j420_p, "yuvj420p" }, + { fb_pix_fmt_yuv_j422_p, "yuvj422p" }, + { fb_pix_fmt_yuv_j444_p, "yuvj444p" }, + { fb_pix_fmt_n_v12, "nv12" }, + { fb_pix_fmt_rgba, "rgba" }, + { fb_pix_fmt_gra_y16_le, "gray16le" }, + { fb_pix_fmt_yu_v440_p, "yuv440p" }, + { fb_pix_fmt_yuv_j440_p, "yuvj440p" }, + { fb_pix_fmt_rg_b48_le, "rgb48le" }, + { fb_pix_fmt_yu_v420_p10_le, "yuv420p10le" }, + { fb_pix_fmt_yu_v422_p10_le, "yuv422p10le" }, + { fb_pix_fmt_yu_v444_p10_le, "yuv444p10le" }, + { fb_pix_fmt_rgb_a64_le, "rgba64le" }, + { fb_pix_fmt_yu_v420_p12_le, "yuv420p12le" }, + { fb_pix_fmt_yu_v422_p12_le, "yuv422p12le" }, + { fb_pix_fmt_yu_v444_p12_le, "yuv444p12le" }, + { fb_pix_fmt_yuv_j411_p, "yuvj411p" }, + { fb_pix_fmt_p010_le, "p010le" }, + { fb_pix_fmt_gray_f32_le, "grayf32le" }, + { fb_pix_fmt_rgba_f16_le, "rgbaf16le" }, + { fb_pix_fmt_rgb_f32_le, "rgbf32le" }, + { fb_pix_fmt_rgba_f32_le, "rgbaf32le" }, + { fb_pix_fmt_rgb_f16_le, "rgbf16le" }, + { fb_pix_fmt_gray_f16_le, "grayf16le" }, }; } // namespace @@ -95,23 +95,23 @@ namespace * FB_PIX_FMT_* value and are not stable across runs, which is fine because * callers treat the values as opaque. */ -constexpr int kDynamicPixFmtBase = 1000; +constexpr int k_dynamic_pix_fmt_base = 1000; std::mutex g_dynamic_pix_fmt_mutex; std::vector> g_dynamic_pix_fmts; } // namespace -AVPixelFormat PixFmtToAV(int fb_fmt) +AVPixelFormat pix_fmt_to_av(int fb_fmt) { - if (fb_fmt == FB_PIX_FMT_NONE) { + if (fb_fmt == fb_pix_fmt_none) { return AV_PIX_FMT_NONE; } - for (const PixFmtName &entry : kPixFmtNames) { + for (const PixFmtName &entry : k_pix_fmt_names) { if (entry.fb_fmt == fb_fmt) { return av_get_pix_fmt(entry.av_name); } } - if (fb_fmt >= kDynamicPixFmtBase) { + if (fb_fmt >= k_dynamic_pix_fmt_base) { std::lock_guard lock(g_dynamic_pix_fmt_mutex); for (const auto &entry : g_dynamic_pix_fmts) { if (entry.first == fb_fmt) { @@ -122,14 +122,14 @@ AVPixelFormat PixFmtToAV(int fb_fmt) return AV_PIX_FMT_NONE; } -int PixFmtFromAV(AVPixelFormat fmt) +int pix_fmt_from_av(AVPixelFormat fmt) { if (fmt == AV_PIX_FMT_NONE) { - return FB_PIX_FMT_NONE; + return fb_pix_fmt_none; } const char *name = av_get_pix_fmt_name(fmt); if (name) { - for (const PixFmtName &entry : kPixFmtNames) { + for (const PixFmtName &entry : k_pix_fmt_names) { if (strcmp(name, entry.av_name) == 0) { return entry.fb_fmt; } @@ -142,12 +142,12 @@ int PixFmtFromAV(AVPixelFormat fmt) return entry.first; } } - const int id = kDynamicPixFmtBase + int(g_dynamic_pix_fmts.size()); + const int id = k_dynamic_pix_fmt_base + int(g_dynamic_pix_fmts.size()); g_dynamic_pix_fmts.emplace_back(id, fmt); return id; } -void ChannelLayoutFromMask(AVChannelLayout *layout, uint64_t mask, +void channel_layout_from_mask(AVChannelLayout *layout, uint64_t mask, int fallback_channels) { if (mask != 0) { @@ -161,7 +161,7 @@ void ChannelLayoutFromMask(AVChannelLayout *layout, uint64_t mask, av_channel_layout_default(layout, fallback_channels); } -uint64_t ValidateStreamChannelLayoutMask(const AVStream *stream) +uint64_t validate_stream_channel_layout_mask(const AVStream *stream) { if (!stream || !stream->codecpar) { return 0; @@ -188,7 +188,7 @@ uint64_t ValidateStreamChannelLayoutMask(const AVStream *stream) return mask; } -int SwsColorspaceFromAVColorSpace(AVColorSpace cs) +int sws_colorspace_from_av_color_space(AVColorSpace cs) { switch (cs) { case AVCOL_SPC_BT709: @@ -210,7 +210,7 @@ int SwsColorspaceFromAVColorSpace(AVColorSpace cs) return SWS_CS_DEFAULT; } -void SetError(char *error_buffer, size_t error_buffer_size, const char *context, +void set_error(char *error_buffer, size_t error_buffer_size, const char *context, int error_code) { if (!error_buffer || error_buffer_size == 0) { @@ -252,18 +252,18 @@ const char *fb_version_string(void) const char *fb_pix_fmt_name(int pix_fmt) { - return av_get_pix_fmt_name(fb::PixFmtToAV(pix_fmt)); + return av_get_pix_fmt_name(fb::pix_fmt_to_av(pix_fmt)); } int fb_pix_fmt_from_name(const char *name) { - return fb::PixFmtFromAV(av_get_pix_fmt(name)); + return fb::pix_fmt_from_av(av_get_pix_fmt(name)); } int fb_pix_fmt_bits_per_pixel(int pix_fmt) { const AVPixFmtDescriptor *desc = - av_pix_fmt_desc_get(fb::PixFmtToAV(pix_fmt)); + av_pix_fmt_desc_get(fb::pix_fmt_to_av(pix_fmt)); if (!desc) { return 0; } @@ -273,21 +273,21 @@ int fb_pix_fmt_bits_per_pixel(int pix_fmt) int fb_pix_fmt_has_alpha(int pix_fmt) { const AVPixFmtDescriptor *desc = - av_pix_fmt_desc_get(fb::PixFmtToAV(pix_fmt)); + av_pix_fmt_desc_get(fb::pix_fmt_to_av(pix_fmt)); return desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA); } int fb_pix_fmt_is_planar(int pix_fmt) { const AVPixFmtDescriptor *desc = - av_pix_fmt_desc_get(fb::PixFmtToAV(pix_fmt)); + av_pix_fmt_desc_get(fb::pix_fmt_to_av(pix_fmt)); return desc && (desc->flags & AV_PIX_FMT_FLAG_PLANAR); } int fb_pix_fmt_component_size(int pix_fmt) { const AVPixFmtDescriptor *desc = - av_pix_fmt_desc_get(fb::PixFmtToAV(pix_fmt)); + av_pix_fmt_desc_get(fb::pix_fmt_to_av(pix_fmt)); if (!desc || desc->nb_components == 0) { return 0; } @@ -300,25 +300,25 @@ int fb_find_best_pix_fmt_of_list(const int *list, int pix_fmt) // Translate the FB_PIX_FMT_NONE-terminated list to AVPixelFormat values, // skipping formats unknown to this FFmpeg build std::vector av_list; - for (int i = 0; list[i] != FB_PIX_FMT_NONE; i++) { - AVPixelFormat fmt = fb::PixFmtToAV(list[i]); + for (int i = 0; list[i] != fb_pix_fmt_none; i++) { + AVPixelFormat fmt = fb::pix_fmt_to_av(list[i]); if (fmt != AV_PIX_FMT_NONE) { av_list.push_back(fmt); } } if (av_list.empty()) { - return FB_PIX_FMT_NONE; + return fb_pix_fmt_none; } // With an unknown source format there is no loss metric to compare // against; prefer the first (most desirable) list entry - AVPixelFormat av_src = fb::PixFmtToAV(pix_fmt); + AVPixelFormat av_src = fb::pix_fmt_to_av(pix_fmt); if (av_src == AV_PIX_FMT_NONE) { return list[0]; } av_list.push_back(AV_PIX_FMT_NONE); - return fb::PixFmtFromAV(avcodec_find_best_pix_fmt_of_list( + return fb::pix_fmt_from_av(avcodec_find_best_pix_fmt_of_list( av_list.data(), av_src, 1, nullptr)); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 54d063d30..616cdc6f3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,12 +17,12 @@ function(olive_add_test GROUP NAME SOURCE) file(READ "${SOURCE}" TEST_FILE_CONTENT) - string(REGEX MATCHALL "OLIVE_ADD_TEST\(.[A-Za-z0-9_]+\)" TEST_FUNCTIONS ${TEST_FILE_CONTENT}) + string(REGEX MATCHALL "OAK_ADD_TEST\(.[A-Za-z0-9_]+\)" TEST_FUNCTIONS ${TEST_FILE_CONTENT}) set(TEST_BODY "int main(int argc, char** argv)\n{\n int ret;(void)ret;") set(TEST_INDEX 1) list(LENGTH TEST_FUNCTIONS TEST_COUNT) foreach (TEST_FUNC ${TEST_FUNCTIONS}) - string(REPLACE "OLIVE_ADD_TEST(" "" TEST_FUNC "${TEST_FUNC}") + string(REPLACE "OAK_ADD_TEST(" "" TEST_FUNC "${TEST_FUNC}") string(APPEND TEST_BODY " std::cout << \"[${TEST_INDEX}/${TEST_COUNT}] ${GROUP} - ${TEST_FUNC}\";\n") string(APPEND TEST_BODY " if ((ret = olive::Test${TEST_FUNC}()) == OLIVE_TEST_SUCCESS) {std::cout << \" - PASSED\" << std::endl;}else{std::cout << \" - FAILED AT LINE \" << ret << std::endl;return 1;}\n") MATH(EXPR TEST_INDEX "${TEST_INDEX}+1") diff --git a/tests/compositing/compositing-tests.cpp b/tests/compositing/compositing-tests.cpp index 10bb72fe5..f516a63e1 100644 --- a/tests/compositing/compositing-tests.cpp +++ b/tests/compositing/compositing-tests.cpp @@ -1,8 +1,8 @@ /*** - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar + Olive - Non-Linear video Editor + Copyright (c) 2022 Olive Team + Modifications Copyright (c) 2025 mikesolar This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/tests/general/common-tests.cpp b/tests/general/common-tests.cpp index 25d1d73dd..a13f33b58 100644 --- a/tests/general/common-tests.cpp +++ b/tests/general/common-tests.cpp @@ -1,8 +1,8 @@ /*** - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar + Olive - Non-Linear video Editor + Copyright (c) 2022 Olive Team + Modifications Copyright (c) 2025 mikesolar This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,26 +26,26 @@ namespace olive { -OLIVE_ADD_TEST(DigitTest) +OAK_ADD_TEST(DigitTest) { - OLIVE_ASSERT(GetDigitCount(1) == 1); - OLIVE_ASSERT(GetDigitCount(69) == 2); - OLIVE_ASSERT(GetDigitCount(420) == 3); - OLIVE_ASSERT(GetDigitCount(1337) == 4); - OLIVE_ASSERT(GetDigitCount(80085) == 5); - OLIVE_ASSERT(GetDigitCount(555555) == 6); - OLIVE_ASSERT(GetDigitCount(8675309) == 7); - OLIVE_ASSERT(GetDigitCount(78956423) == 8); - OLIVE_ASSERT(GetDigitCount(148497523) == 9); - OLIVE_ASSERT(GetDigitCount(4845821233) == 10); - OLIVE_ASSERT(GetDigitCount(18002738255) == 11); - OLIVE_ASSERT(GetDigitCount(180027382556) == 12); - OLIVE_ASSERT(GetDigitCount(1800273825568) == 13); - OLIVE_ASSERT(GetDigitCount(18002738255685) == 14); - OLIVE_ASSERT(GetDigitCount(180027382556857) == 15); - OLIVE_ASSERT(GetDigitCount(1800273825564857) == 16); + OAK_ASSERT(get_digit_count(1) == 1); + OAK_ASSERT(get_digit_count(69) == 2); + OAK_ASSERT(get_digit_count(420) == 3); + OAK_ASSERT(get_digit_count(1337) == 4); + OAK_ASSERT(get_digit_count(80085) == 5); + OAK_ASSERT(get_digit_count(555555) == 6); + OAK_ASSERT(get_digit_count(8675309) == 7); + OAK_ASSERT(get_digit_count(78956423) == 8); + OAK_ASSERT(get_digit_count(148497523) == 9); + OAK_ASSERT(get_digit_count(4845821233) == 10); + OAK_ASSERT(get_digit_count(18002738255) == 11); + OAK_ASSERT(get_digit_count(180027382556) == 12); + OAK_ASSERT(get_digit_count(1800273825568) == 13); + OAK_ASSERT(get_digit_count(18002738255685) == 14); + OAK_ASSERT(get_digit_count(180027382556857) == 15); + OAK_ASSERT(get_digit_count(1800273825564857) == 16); - OLIVE_TEST_END; + OAK_TEST_END; } } diff --git a/tests/gtest/audio_level_meter_test.cpp b/tests/gtest/audio_level_meter_test.cpp index 18945f1c3..504d775f4 100644 --- a/tests/gtest/audio_level_meter_test.cpp +++ b/tests/gtest/audio_level_meter_test.cpp @@ -10,21 +10,21 @@ namespace { -olive::core::AudioParams MakeStereoParams() +olive::core::AudioParams make_stereo_params() { - return olive::core::AudioParams(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + return olive::core::AudioParams(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); } } TEST(AudioLevelMeter, Silence) { - olive::core::SampleBuffer samples(MakeStereoParams(), size_t(480)); + olive::core::SampleBuffer samples(make_stereo_params(), size_t(480)); samples.silence(); const olive::AudioLevelMeter::Stats stats = - olive::AudioLevelMeter::AnalyzeSampleBuffer(samples); + olive::AudioLevelMeter::analyze_sample_buffer(samples); ASSERT_EQ(stats.channels.size(), 2); EXPECT_TRUE(stats.silence); @@ -36,7 +36,7 @@ TEST(AudioLevelMeter, Silence) TEST(AudioLevelMeter, ConstantSignal) { - olive::core::SampleBuffer samples(MakeStereoParams(), size_t(480)); + olive::core::SampleBuffer samples(make_stereo_params(), size_t(480)); for (int channel = 0; channel < samples.channel_count(); channel++) { float *data = samples.data(channel); for (size_t i = 0; i < samples.sample_count(); i++) { @@ -45,7 +45,7 @@ TEST(AudioLevelMeter, ConstantSignal) } const olive::AudioLevelMeter::Stats stats = - olive::AudioLevelMeter::AnalyzeSampleBuffer(samples); + olive::AudioLevelMeter::analyze_sample_buffer(samples); ASSERT_EQ(stats.channels.size(), 2); EXPECT_FALSE(stats.silence); @@ -58,14 +58,14 @@ TEST(AudioLevelMeter, ConstantSignal) TEST(AudioLevelMeter, PerChannelPeaksAndRms) { - olive::core::SampleBuffer samples(MakeStereoParams(), size_t(4)); + olive::core::SampleBuffer samples(make_stereo_params(), size_t(4)); float left[] = { 0.0f, 0.25f, -0.5f, 1.0f }; float right[] = { 0.0f, -0.25f, 0.25f, -0.25f }; samples.set(0, left, 4); samples.set(1, right, 4); const olive::AudioLevelMeter::Stats stats = - olive::AudioLevelMeter::AnalyzeSampleBuffer(samples); + olive::AudioLevelMeter::analyze_sample_buffer(samples); ASSERT_EQ(stats.channels.size(), 2); EXPECT_DOUBLE_EQ(stats.channels.at(0).peak_linear, 1.0); diff --git a/tests/gtest/audio_manager_viewer_test.cpp b/tests/gtest/audio_manager_viewer_test.cpp index 13d73e749..d83212812 100644 --- a/tests/gtest/audio_manager_viewer_test.cpp +++ b/tests/gtest/audio_manager_viewer_test.cpp @@ -34,13 +34,13 @@ class AudioManagerTest : public ::testing::Test { protected: void SetUp() override { - olive::AudioManager::CreateInstance(); + olive::AudioManager::create_instance(); ASSERT_NE(olive::AudioManager::instance(), nullptr); } void TearDown() override { - olive::AudioManager::DestroyInstance(); + olive::AudioManager::destroy_instance(); EXPECT_EQ(olive::AudioManager::instance(), nullptr); } }; @@ -49,14 +49,14 @@ TEST_F(AudioManagerTest, InstanceLifecycle) { // The fixture already created the instance; creating again must be a no-op olive::AudioManager *first = olive::AudioManager::instance(); - olive::AudioManager::CreateInstance(); + olive::AudioManager::create_instance(); EXPECT_EQ(olive::AudioManager::instance(), first); // The stored indices are either paNoDevice or a valid device index with // channels in the appropriate direction const PaDeviceIndex output = - olive::AudioManager::instance()->GetOutputDevice(); - const PaDeviceIndex input = olive::AudioManager::instance()->GetInputDevice(); + olive::AudioManager::instance()->get_output_device(); + const PaDeviceIndex input = olive::AudioManager::instance()->get_input_device(); if (Pa_GetDeviceCount() == 0) { // No devices exist, so nothing could have been selected @@ -78,67 +78,67 @@ TEST_F(AudioManagerTest, InstanceLifecycle) TEST_F(AudioManagerTest, SetAndGetNoDevice) { - olive::AudioManager::instance()->SetOutputDevice(paNoDevice); - EXPECT_EQ(olive::AudioManager::instance()->GetOutputDevice(), paNoDevice); + olive::AudioManager::instance()->set_output_device(paNoDevice); + EXPECT_EQ(olive::AudioManager::instance()->get_output_device(), paNoDevice); - olive::AudioManager::instance()->SetInputDevice(paNoDevice); - EXPECT_EQ(olive::AudioManager::instance()->GetInputDevice(), paNoDevice); + olive::AudioManager::instance()->set_input_device(paNoDevice); + EXPECT_EQ(olive::AudioManager::instance()->get_input_device(), paNoDevice); } TEST_F(AudioManagerTest, PushToOutputWithoutDeviceFails) { - olive::AudioManager::instance()->SetOutputDevice(paNoDevice); + olive::AudioManager::instance()->set_output_device(paNoDevice); const olive::core::AudioParams params( - 48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + 48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); const QByteArray samples(1024, 0); QString error; EXPECT_FALSE( - olive::AudioManager::instance()->PushToOutput(params, samples, &error)); + olive::AudioManager::instance()->push_to_output(params, samples, &error)); EXPECT_EQ(error, QStringLiteral("No output device is set")); // A null error pointer must be tolerated too EXPECT_FALSE( - olive::AudioManager::instance()->PushToOutput(params, samples, nullptr)); + olive::AudioManager::instance()->push_to_output(params, samples, nullptr)); } TEST_F(AudioManagerTest, StartRecordingWithoutInputDeviceFails) { - olive::AudioManager::instance()->SetInputDevice(paNoDevice); + olive::AudioManager::instance()->set_input_device(paNoDevice); // Fails before any encoder or PortAudio stream is created QString error; EXPECT_FALSE( - olive::AudioManager::instance()->StartRecording(olive::EncodingParams(), + olive::AudioManager::instance()->start_recording(olive::EncodingParams(), &error)); // Tearing down a recording that never started must be harmless - olive::AudioManager::instance()->StopRecording(); + olive::AudioManager::instance()->stop_recording(); } TEST_F(AudioManagerTest, OutputControlsWithoutStreamAreNoOps) { - olive::AudioManager::instance()->SetOutputDevice(paNoDevice); + olive::AudioManager::instance()->set_output_device(paNoDevice); // No output stream is open; all of these must be harmless no-ops - olive::AudioManager::instance()->StopOutput(); - olive::AudioManager::instance()->ClearBufferedOutput(); - olive::AudioManager::instance()->SetOutputNotifyInterval(64); - olive::AudioManager::instance()->SetOutputNotifyInterval(0); + olive::AudioManager::instance()->stop_output(); + olive::AudioManager::instance()->clear_buffered_output(); + olive::AudioManager::instance()->set_output_notify_interval(64); + olive::AudioManager::instance()->set_output_notify_interval(0); // ...and they must not disturb the device bookkeeping - EXPECT_EQ(olive::AudioManager::instance()->GetOutputDevice(), paNoDevice); + EXPECT_EQ(olive::AudioManager::instance()->get_output_device(), paNoDevice); } TEST_F(AudioManagerTest, HardResetKeepsManagerUsable) { - olive::AudioManager::instance()->HardReset(); + olive::AudioManager::instance()->hard_reset(); // Device bookkeeping must survive a PortAudio terminate/init cycle - olive::AudioManager::instance()->SetOutputDevice(paNoDevice); - EXPECT_EQ(olive::AudioManager::instance()->GetOutputDevice(), paNoDevice); + olive::AudioManager::instance()->set_output_device(paNoDevice); + EXPECT_EQ(olive::AudioManager::instance()->get_output_device(), paNoDevice); } TEST_F(AudioManagerTest, FindDeviceByNameFallsBackForUnknownName) @@ -147,9 +147,9 @@ TEST_F(AudioManagerTest, FindDeviceByNameFallsBackForUnknownName) // devices exist there is nothing to fall back to and the result must be // exactly paNoDevice; otherwise the fallback is a preferred/default // device, i.e. a valid index or paNoDevice. - const PaDeviceIndex bogus_output = olive::AudioManager::FindDeviceByName( + const PaDeviceIndex bogus_output = olive::AudioManager::find_device_by_name( QStringLiteral("OakNoSuchAudioDevice12345"), true); - const PaDeviceIndex bogus_input = olive::AudioManager::FindDeviceByName( + const PaDeviceIndex bogus_input = olive::AudioManager::find_device_by_name( QStringLiteral("OakNoSuchAudioDevice12345"), false); if (Pa_GetDeviceCount() == 0) { @@ -194,7 +194,7 @@ TEST_F(AudioManagerTest, FindDeviceByNameFindsExactMatch) } #endif - EXPECT_EQ(olive::AudioManager::FindDeviceByName( + EXPECT_EQ(olive::AudioManager::find_device_by_name( QString::fromLatin1(info->name), true), i); return; @@ -208,18 +208,18 @@ TEST_F(AudioManagerTest, FindConfigDeviceByNameMatchesConfiguredLookup) // The config-driven lookup must be exactly FindDeviceByName applied to the // configured name, and must never return a garbage index const PaDeviceIndex output = - olive::AudioManager::FindConfigDeviceByName(true); + olive::AudioManager::find_config_device_by_name(true); const PaDeviceIndex input = - olive::AudioManager::FindConfigDeviceByName(false); + olive::AudioManager::find_config_device_by_name(false); EXPECT_EQ(output, - olive::AudioManager::FindDeviceByName( - olive::Config::Current()[QStringLiteral("AudioOutput")] + olive::AudioManager::find_device_by_name( + olive::Config::current()[QStringLiteral("AudioOutput")] .toString(), true)); EXPECT_EQ(input, - olive::AudioManager::FindDeviceByName( - olive::Config::Current()[QStringLiteral("AudioInput")] + olive::AudioManager::find_device_by_name( + olive::Config::current()[QStringLiteral("AudioInput")] .toString(), false)); @@ -236,10 +236,10 @@ TEST_F(AudioManagerTest, PortAudioParamsReflectAudioParams) } const olive::core::AudioParams params( - 48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32); + 48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32); const PaStreamParameters p = - olive::AudioManager::GetPortAudioParams(params, 0); + olive::AudioManager::get_port_audio_params(params, 0); EXPECT_EQ(p.channelCount, 2); EXPECT_EQ(p.device, 0); @@ -256,32 +256,32 @@ TEST_F(AudioManagerTest, PortAudioParamsMapsSampleFormats) const auto format_for = [](olive::core::SampleFormat f) { const olive::core::AudioParams params( - 48000, olive::core::kChannelLayoutMono, f); - return olive::AudioManager::GetPortAudioParams(params, 0).sampleFormat; + 48000, olive::core::k_channel_layout_mono, f); + return olive::AudioManager::get_port_audio_params(params, 0).sampleFormat; }; // Packed and planar variants of the same depth map to the same flag - EXPECT_EQ(format_for(olive::core::SampleFormat::U8), + EXPECT_EQ(format_for(olive::core::SampleFormat::u8), PaSampleFormat(paUInt8)); - EXPECT_EQ(format_for(olive::core::SampleFormat::U8P), + EXPECT_EQ(format_for(olive::core::SampleFormat::u8_p), PaSampleFormat(paUInt8)); - EXPECT_EQ(format_for(olive::core::SampleFormat::S16), + EXPECT_EQ(format_for(olive::core::SampleFormat::s16), PaSampleFormat(paInt16)); - EXPECT_EQ(format_for(olive::core::SampleFormat::S16P), + EXPECT_EQ(format_for(olive::core::SampleFormat::s16_p), PaSampleFormat(paInt16)); - EXPECT_EQ(format_for(olive::core::SampleFormat::S32), + EXPECT_EQ(format_for(olive::core::SampleFormat::s32), PaSampleFormat(paInt32)); - EXPECT_EQ(format_for(olive::core::SampleFormat::S32P), + EXPECT_EQ(format_for(olive::core::SampleFormat::s32_p), PaSampleFormat(paInt32)); - EXPECT_EQ(format_for(olive::core::SampleFormat::F32), + EXPECT_EQ(format_for(olive::core::SampleFormat::f32), PaSampleFormat(paFloat32)); - EXPECT_EQ(format_for(olive::core::SampleFormat::F32P), + EXPECT_EQ(format_for(olive::core::SampleFormat::f32_p), PaSampleFormat(paFloat32)); // 64-bit depths have no PortAudio equivalent and map to paCustomFormat(0) - EXPECT_EQ(format_for(olive::core::SampleFormat::S64), PaSampleFormat(0)); - EXPECT_EQ(format_for(olive::core::SampleFormat::F64), PaSampleFormat(0)); - EXPECT_EQ(format_for(olive::core::SampleFormat::INVALID), + EXPECT_EQ(format_for(olive::core::SampleFormat::s64), PaSampleFormat(0)); + EXPECT_EQ(format_for(olive::core::SampleFormat::f64), PaSampleFormat(0)); + EXPECT_EQ(format_for(olive::core::SampleFormat::invalid), PaSampleFormat(0)); } @@ -294,24 +294,24 @@ TEST_F(AudioManagerTest, PortAudioParamsMapsSampleFormats) class TestViewerOutput : public olive::ViewerOutput { public: using olive::ViewerOutput::ViewerOutput; - using olive::ViewerOutput::AddStream; - using olive::ViewerOutput::SetStream; + using olive::ViewerOutput::add_stream; + using olive::ViewerOutput::set_stream; }; class ViewerOutputTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); viewer_ = new TestViewerOutput(); viewer_->setParent(project_.get()); } - template T *AddNode() + template T *add_node() { T *node = new T(); node->setParent(project_.get()); @@ -324,82 +324,82 @@ protected: TEST_F(ViewerOutputTest, DefaultConstruction) { - EXPECT_EQ(viewer_->Name(), QStringLiteral("Viewer")); + EXPECT_EQ(viewer_->name(), QStringLiteral("Viewer")); EXPECT_EQ(viewer_->id(), QStringLiteral("org.olivevideoeditor.Olive.vieweroutput")); - EXPECT_TRUE(viewer_->Category().contains(olive::Node::kCategoryOutput)); + EXPECT_TRUE(viewer_->category().contains(olive::Node::k_category_output)); // One default video and audio stream, no subtitle streams - EXPECT_EQ(viewer_->GetVideoStreamCount(), 1); - EXPECT_EQ(viewer_->GetAudioStreamCount(), 1); - EXPECT_EQ(viewer_->GetSubtitleStreamCount(), 0); - EXPECT_EQ(viewer_->GetTotalStreamCount(), 2); + EXPECT_EQ(viewer_->get_video_stream_count(), 1); + EXPECT_EQ(viewer_->get_audio_stream_count(), 1); + EXPECT_EQ(viewer_->get_subtitle_stream_count(), 0); + EXPECT_EQ(viewer_->get_total_stream_count(), 2); - EXPECT_NE(viewer_->GetWorkArea(), nullptr); - EXPECT_NE(viewer_->GetMarkers(), nullptr); + EXPECT_NE(viewer_->get_work_area(), nullptr); + EXPECT_NE(viewer_->get_markers(), nullptr); - EXPECT_EQ(viewer_->GetPlayhead(), olive::rational(0)); - EXPECT_EQ(viewer_->GetLength(), olive::rational(0)); - EXPECT_EQ(viewer_->GetVideoLength(), olive::rational(0)); - EXPECT_EQ(viewer_->GetAudioLength(), olive::rational(0)); + EXPECT_EQ(viewer_->get_playhead(), olive::Rational(0)); + EXPECT_EQ(viewer_->get_length(), olive::Rational(0)); + EXPECT_EQ(viewer_->get_video_length(), olive::Rational(0)); + EXPECT_EQ(viewer_->get_audio_length(), olive::Rational(0)); - EXPECT_EQ(viewer_->GetConnectedTextureOutput(), nullptr); - EXPECT_EQ(viewer_->GetConnectedSampleOutput(), nullptr); - EXPECT_EQ(viewer_->GetConnectedWaveform(), nullptr); + EXPECT_EQ(viewer_->get_connected_texture_output(), nullptr); + EXPECT_EQ(viewer_->get_connected_sample_output(), nullptr); + EXPECT_EQ(viewer_->get_connected_waveform(), nullptr); // The autocache API is currently a stub that always reports disabled - EXPECT_FALSE(viewer_->IsVideoAutoCacheEnabled()); + EXPECT_FALSE(viewer_->is_video_auto_cache_enabled()); } TEST_F(ViewerOutputTest, SetAndGetVideoParams) { - const olive::VideoParams vp(1920, 1080, olive::rational(1, 30), - olive::PixelFormat::U8, 4); - viewer_->SetVideoParams(vp); + const olive::VideoParams vp(1920, 1080, olive::Rational(1, 30), + olive::PixelFormat::u8, 4); + viewer_->set_video_params(vp); - EXPECT_EQ(viewer_->GetVideoParams(), vp); - EXPECT_EQ(viewer_->GetVideoParams().width(), 1920); - EXPECT_EQ(viewer_->GetVideoParams().height(), 1080); + EXPECT_EQ(viewer_->get_video_params(), vp); + EXPECT_EQ(viewer_->get_video_params().width(), 1920); + EXPECT_EQ(viewer_->get_video_params().height(), 1080); // Out-of-range indices return invalid params instead of garbage - EXPECT_FALSE(viewer_->GetVideoParams(5).is_valid()); + EXPECT_FALSE(viewer_->get_video_params(5).is_valid()); } TEST_F(ViewerOutputTest, SetAndGetAudioParams) { - const olive::core::AudioParams ap(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); - viewer_->SetAudioParams(ap); + const olive::core::AudioParams ap(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); + viewer_->set_audio_params(ap); - EXPECT_EQ(viewer_->GetAudioParams(), ap); + EXPECT_EQ(viewer_->get_audio_params(), ap); // The default-constructed stream uses the viewer's default sample format const olive::core::SampleFormat default_format = - olive::ViewerOutput::kDefaultSampleFormat; - EXPECT_EQ(viewer_->GetAudioParams().format(), default_format); + olive::ViewerOutput::k_default_sample_format; + EXPECT_EQ(viewer_->get_audio_params().format(), default_format); // Out-of-range indices return invalid params instead of garbage - EXPECT_FALSE(viewer_->GetAudioParams(9).is_valid()); + EXPECT_FALSE(viewer_->get_audio_params(9).is_valid()); } TEST_F(ViewerOutputTest, SetAndGetSubtitleParams) { olive::SubtitleParams subs; subs.push_back(olive::Subtitle( - olive::TimeRange(olive::rational(0), olive::rational(2)), + olive::TimeRange(olive::Rational(0), olive::Rational(2)), QStringLiteral("hello"))); - EXPECT_EQ(viewer_->AddStream(olive::Track::kSubtitle, + EXPECT_EQ(viewer_->add_stream(olive::Track::k_subtitle, QVariant::fromValue(subs)), 0); - EXPECT_EQ(viewer_->GetSubtitleStreamCount(), 1); + EXPECT_EQ(viewer_->get_subtitle_stream_count(), 1); - ASSERT_TRUE(viewer_->GetSubtitleParams(0).is_valid()); - EXPECT_EQ(viewer_->GetSubtitleParams(0).duration(), olive::rational(2)); - EXPECT_TRUE(viewer_->HasEnabledSubtitleStreams()); + ASSERT_TRUE(viewer_->get_subtitle_params(0).is_valid()); + EXPECT_EQ(viewer_->get_subtitle_params(0).duration(), olive::Rational(2)); + EXPECT_TRUE(viewer_->has_enabled_subtitle_streams()); // Out-of-range indices return invalid (empty) params - EXPECT_FALSE(viewer_->GetSubtitleParams(3).is_valid()); + EXPECT_FALSE(viewer_->get_subtitle_params(3).is_valid()); } TEST_F(ViewerOutputTest, VideoParamSignals) @@ -409,41 +409,41 @@ TEST_F(ViewerOutputTest, VideoParamSignals) int pixel_aspect_emissions = 0; int interlacing_emissions = 0; int params_emissions = 0; - olive::rational emitted_frame_rate; - QObject::connect(viewer_, &olive::ViewerOutput::SizeChanged, + olive::Rational emitted_frame_rate; + QObject::connect(viewer_, &olive::ViewerOutput::size_changed, [&size_emissions](int, int) { ++size_emissions; }); - QObject::connect(viewer_, &olive::ViewerOutput::FrameRateChanged, + QObject::connect(viewer_, &olive::ViewerOutput::frame_rate_changed, [&frame_rate_emissions, &emitted_frame_rate]( - const olive::rational &r) { + const olive::Rational &r) { ++frame_rate_emissions; emitted_frame_rate = r; }); - QObject::connect(viewer_, &olive::ViewerOutput::PixelAspectChanged, - [&pixel_aspect_emissions](const olive::rational &) { + QObject::connect(viewer_, &olive::ViewerOutput::pixel_aspect_changed, + [&pixel_aspect_emissions](const olive::Rational &) { ++pixel_aspect_emissions; }); - QObject::connect(viewer_, &olive::ViewerOutput::InterlacingChanged, + QObject::connect(viewer_, &olive::ViewerOutput::interlacing_changed, [&interlacing_emissions](olive::VideoParams::Interlacing) { ++interlacing_emissions; }); - QObject::connect(viewer_, &olive::ViewerOutput::VideoParamsChanged, + QObject::connect(viewer_, &olive::ViewerOutput::video_params_changed, [¶ms_emissions]() { ++params_emissions; }); // Every aspect differs from the cached defaults, so all signals fire once - const olive::VideoParams vp(1280, 720, olive::rational(1, 60), - olive::PixelFormat::U8, 4, olive::rational(2), - olive::VideoParams::kInterlacedTopFirst); - viewer_->SetVideoParams(vp); + const olive::VideoParams vp(1280, 720, olive::Rational(1, 60), + olive::PixelFormat::u8, 4, olive::Rational(2), + olive::VideoParams::k_interlaced_top_first); + viewer_->set_video_params(vp); EXPECT_EQ(size_emissions, 1); EXPECT_EQ(frame_rate_emissions, 1); - EXPECT_EQ(emitted_frame_rate, olive::rational(60, 1)); + EXPECT_EQ(emitted_frame_rate, olive::Rational(60, 1)); EXPECT_EQ(pixel_aspect_emissions, 1); EXPECT_EQ(interlacing_emissions, 1); EXPECT_EQ(params_emissions, 1); // Setting identical params only re-emits the unconditional change signal - viewer_->SetVideoParams(vp); + viewer_->set_video_params(vp); EXPECT_EQ(size_emissions, 1); EXPECT_EQ(frame_rate_emissions, 1); @@ -457,24 +457,24 @@ TEST_F(ViewerOutputTest, AudioParamSignals) int sample_rate_emissions = 0; int params_emissions = 0; int emitted_sample_rate = 0; - QObject::connect(viewer_, &olive::ViewerOutput::SampleRateChanged, + QObject::connect(viewer_, &olive::ViewerOutput::sample_rate_changed, [&sample_rate_emissions, &emitted_sample_rate](int sr) { ++sample_rate_emissions; emitted_sample_rate = sr; }); - QObject::connect(viewer_, &olive::ViewerOutput::AudioParamsChanged, + QObject::connect(viewer_, &olive::ViewerOutput::audio_params_changed, [¶ms_emissions]() { ++params_emissions; }); - const olive::core::AudioParams ap(44100, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); - viewer_->SetAudioParams(ap); + const olive::core::AudioParams ap(44100, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); + viewer_->set_audio_params(ap); EXPECT_EQ(sample_rate_emissions, 1); EXPECT_EQ(emitted_sample_rate, 44100); EXPECT_EQ(params_emissions, 1); // Same sample rate again: no SampleRateChanged, but AudioParamsChanged - viewer_->SetAudioParams(ap); + viewer_->set_audio_params(ap); EXPECT_EQ(sample_rate_emissions, 1); EXPECT_EQ(params_emissions, 2); @@ -483,214 +483,214 @@ TEST_F(ViewerOutputTest, AudioParamSignals) TEST_F(ViewerOutputTest, SetPlayheadEmitsPlayheadChanged) { int emissions = 0; - olive::rational emitted; - QObject::connect(viewer_, &olive::ViewerOutput::PlayheadChanged, - [&emissions, &emitted](const olive::rational &t) { + olive::Rational emitted; + QObject::connect(viewer_, &olive::ViewerOutput::playhead_changed, + [&emissions, &emitted](const olive::Rational &t) { ++emissions; emitted = t; }); - viewer_->SetPlayhead(olive::rational(3, 2)); + viewer_->set_playhead(olive::Rational(3, 2)); EXPECT_EQ(emissions, 1); - EXPECT_EQ(emitted, olive::rational(3, 2)); - EXPECT_EQ(viewer_->GetPlayhead(), olive::rational(3, 2)); + EXPECT_EQ(emitted, olive::Rational(3, 2)); + EXPECT_EQ(viewer_->get_playhead(), olive::Rational(3, 2)); } TEST_F(ViewerOutputTest, VerifyLengthWithoutConnectionsStaysZero) { int length_emissions = 0; - QObject::connect(viewer_, &olive::ViewerOutput::LengthChanged, - [&length_emissions](const olive::rational &) { + QObject::connect(viewer_, &olive::ViewerOutput::length_changed, + [&length_emissions](const olive::Rational &) { ++length_emissions; }); - viewer_->VerifyLength(); - viewer_->VerifyLength(); + viewer_->verify_length(); + viewer_->verify_length(); // Nothing is connected, so all lengths stay zero and nothing is emitted - EXPECT_EQ(viewer_->GetLength(), olive::rational(0)); - EXPECT_EQ(viewer_->GetVideoLength(), olive::rational(0)); - EXPECT_EQ(viewer_->GetAudioLength(), olive::rational(0)); + EXPECT_EQ(viewer_->get_length(), olive::Rational(0)); + EXPECT_EQ(viewer_->get_video_length(), olive::Rational(0)); + EXPECT_EQ(viewer_->get_audio_length(), olive::Rational(0)); EXPECT_EQ(length_emissions, 0); - EXPECT_EQ(viewer_->GetVideoCacheRange(), - olive::TimeRange(olive::rational(0), olive::rational(0))); - EXPECT_EQ(viewer_->GetAudioCacheRange(), - olive::TimeRange(olive::rational(0), olive::rational(0))); + EXPECT_EQ(viewer_->get_video_cache_range(), + olive::TimeRange(olive::Rational(0), olive::Rational(0))); + EXPECT_EQ(viewer_->get_audio_cache_range(), + olive::TimeRange(olive::Rational(0), olive::Rational(0))); } TEST_F(ViewerOutputTest, StreamEnableDisable) { - ASSERT_TRUE(viewer_->HasEnabledVideoStreams()); - ASSERT_TRUE(viewer_->HasEnabledAudioStreams()); + ASSERT_TRUE(viewer_->has_enabled_video_streams()); + ASSERT_TRUE(viewer_->has_enabled_audio_streams()); - olive::VideoParams vp = viewer_->GetVideoParams(); + olive::VideoParams vp = viewer_->get_video_params(); vp.set_enabled(false); - viewer_->SetVideoParams(vp); + viewer_->set_video_params(vp); - EXPECT_FALSE(viewer_->HasEnabledVideoStreams()); - EXPECT_FALSE(viewer_->GetFirstEnabledVideoStream().is_valid()); - EXPECT_TRUE(viewer_->GetEnabledVideoStreams().isEmpty()); + EXPECT_FALSE(viewer_->has_enabled_video_streams()); + EXPECT_FALSE(viewer_->get_first_enabled_video_stream().is_valid()); + EXPECT_TRUE(viewer_->get_enabled_video_streams().isEmpty()); - olive::core::AudioParams ap = viewer_->GetAudioParams(); + olive::core::AudioParams ap = viewer_->get_audio_params(); ap.set_enabled(false); - viewer_->SetAudioParams(ap); + viewer_->set_audio_params(ap); - EXPECT_FALSE(viewer_->HasEnabledAudioStreams()); - EXPECT_FALSE(viewer_->GetFirstEnabledAudioStream().is_valid()); - EXPECT_TRUE(viewer_->GetEnabledAudioStreams().isEmpty()); - EXPECT_TRUE(viewer_->GetEnabledStreamsAsReferences().isEmpty()); + EXPECT_FALSE(viewer_->has_enabled_audio_streams()); + EXPECT_FALSE(viewer_->get_first_enabled_audio_stream().is_valid()); + EXPECT_TRUE(viewer_->get_enabled_audio_streams().isEmpty()); + EXPECT_TRUE(viewer_->get_enabled_streams_as_references().isEmpty()); } TEST_F(ViewerOutputTest, AddAndSetStreams) { - const olive::VideoParams vp2(640, 360, olive::rational(1, 25), - olive::PixelFormat::U8, 4); + const olive::VideoParams vp2(640, 360, olive::Rational(1, 25), + olive::PixelFormat::u8, 4); - EXPECT_EQ(viewer_->AddStream(olive::Track::kVideo, + EXPECT_EQ(viewer_->add_stream(olive::Track::k_video, QVariant::fromValue(vp2)), 1); - EXPECT_EQ(viewer_->GetVideoStreamCount(), 2); - EXPECT_EQ(viewer_->GetVideoParams(1), vp2); - EXPECT_EQ(viewer_->GetTotalStreamCount(), 3); + EXPECT_EQ(viewer_->get_video_stream_count(), 2); + EXPECT_EQ(viewer_->get_video_params(1), vp2); + EXPECT_EQ(viewer_->get_total_stream_count(), 3); // References enumerate the enabled streams in video/audio/subtitle order const QVector refs = - viewer_->GetEnabledStreamsAsReferences(); + viewer_->get_enabled_streams_as_references(); ASSERT_EQ(refs.size(), 3); - EXPECT_EQ(refs.at(0), olive::Track::Reference(olive::Track::kVideo, 0)); - EXPECT_EQ(refs.at(1), olive::Track::Reference(olive::Track::kVideo, 1)); - EXPECT_EQ(refs.at(2), olive::Track::Reference(olive::Track::kAudio, 0)); + EXPECT_EQ(refs.at(0), olive::Track::Reference(olive::Track::k_video, 0)); + EXPECT_EQ(refs.at(1), olive::Track::Reference(olive::Track::k_video, 1)); + EXPECT_EQ(refs.at(2), olive::Track::Reference(olive::Track::k_audio, 0)); // SetStream replaces an existing element in place const olive::core::AudioParams ap2( - 32000, olive::core::kChannelLayoutMono, olive::core::SampleFormat::S16); - EXPECT_EQ(viewer_->SetStream(olive::Track::kAudio, + 32000, olive::core::k_channel_layout_mono, olive::core::SampleFormat::s16); + EXPECT_EQ(viewer_->set_stream(olive::Track::k_audio, QVariant::fromValue(ap2), 0), 0); - EXPECT_EQ(viewer_->GetAudioStreamCount(), 1); - EXPECT_EQ(viewer_->GetAudioParams(0), ap2); + EXPECT_EQ(viewer_->get_audio_stream_count(), 1); + EXPECT_EQ(viewer_->get_audio_params(0), ap2); // kNone is not a valid stream type - EXPECT_EQ(viewer_->AddStream(olive::Track::kNone, QVariant()), -1); + EXPECT_EQ(viewer_->add_stream(olive::Track::k_none, QVariant()), -1); } TEST_F(ViewerOutputTest, ConnectTextureEmitsAndResolves) { - auto *solid = AddNode(); + auto *solid = add_node(); int emissions = 0; - QObject::connect(viewer_, &olive::ViewerOutput::TextureInputChanged, + QObject::connect(viewer_, &olive::ViewerOutput::texture_input_changed, [&emissions]() { ++emissions; }); - olive::Node::ConnectEdge( - solid, olive::NodeInput(viewer_, olive::ViewerOutput::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(viewer_, olive::ViewerOutput::k_texture_input)); EXPECT_EQ(emissions, 1); - EXPECT_EQ(viewer_->GetConnectedTextureOutput(), solid); + EXPECT_EQ(viewer_->get_connected_texture_output(), solid); // Explicit value hints set on the input are reported through the getter - const olive::Node::ValueHint hint({ olive::NodeValue::kTexture }, 2, + const olive::Node::ValueHint hint({ olive::NodeValue::k_texture }, 2, QStringLiteral("tex")); - viewer_->SetValueHintForInput(olive::ViewerOutput::kTextureInput, hint); + viewer_->set_value_hint_for_input(olive::ViewerOutput::k_texture_input, hint); const olive::Node::ValueHint got = - viewer_->GetConnectedTextureValueHint(); + viewer_->get_connected_texture_value_hint(); ASSERT_EQ(got.types().size(), 1); - EXPECT_EQ(got.types().first(), olive::NodeValue::kTexture); + EXPECT_EQ(got.types().first(), olive::NodeValue::k_texture); EXPECT_EQ(got.index(), 2); EXPECT_EQ(got.tag(), QStringLiteral("tex")); - olive::Node::DisconnectEdge( - solid, olive::NodeInput(viewer_, olive::ViewerOutput::kTextureInput)); + olive::Node::disconnect_edge( + solid, olive::NodeInput(viewer_, olive::ViewerOutput::k_texture_input)); EXPECT_EQ(emissions, 2); - EXPECT_EQ(viewer_->GetConnectedTextureOutput(), nullptr); + EXPECT_EQ(viewer_->get_connected_texture_output(), nullptr); } TEST_F(ViewerOutputTest, ConnectSamplesResolves) { - auto *clip = AddNode(); + auto *clip = add_node(); - olive::Node::ConnectEdge( - clip, olive::NodeInput(viewer_, olive::ViewerOutput::kSamplesInput)); + olive::Node::connect_edge( + clip, olive::NodeInput(viewer_, olive::ViewerOutput::k_samples_input)); - EXPECT_EQ(viewer_->GetConnectedSampleOutput(), clip); - EXPECT_EQ(viewer_->GetConnectedWaveform(), clip->waveform_cache()); + EXPECT_EQ(viewer_->get_connected_sample_output(), clip); + EXPECT_EQ(viewer_->get_connected_waveform(), clip->waveform_cache()); // Without an explicit hint the sample value hint is empty - EXPECT_TRUE(viewer_->GetConnectedSampleValueHint().types().isEmpty()); + EXPECT_TRUE(viewer_->get_connected_sample_value_hint().types().isEmpty()); - olive::Node::DisconnectEdge( - clip, olive::NodeInput(viewer_, olive::ViewerOutput::kSamplesInput)); + olive::Node::disconnect_edge( + clip, olive::NodeInput(viewer_, olive::ViewerOutput::k_samples_input)); - EXPECT_EQ(viewer_->GetConnectedSampleOutput(), nullptr); - EXPECT_EQ(viewer_->GetConnectedWaveform(), nullptr); + EXPECT_EQ(viewer_->get_connected_sample_output(), nullptr); + EXPECT_EQ(viewer_->get_connected_waveform(), nullptr); } TEST_F(ViewerOutputTest, InvalidateCacheWithoutConnectionsIsSafe) { // With nothing connected the request path is skipped entirely; this must // neither crash nor produce a length change - viewer_->InvalidateCache(olive::TimeRange(olive::rational(0), - olive::rational(1)), - olive::ViewerOutput::kTextureInput, -1, + viewer_->invalidate_cache(olive::TimeRange(olive::Rational(0), + olive::Rational(1)), + olive::ViewerOutput::k_texture_input, -1, olive::Node::InvalidateCacheOptions()); - viewer_->InvalidateCache(olive::TimeRange(olive::rational(0), - olive::rational(1)), - olive::ViewerOutput::kSamplesInput, -1, + viewer_->invalidate_cache(olive::TimeRange(olive::Rational(0), + olive::Rational(1)), + olive::ViewerOutput::k_samples_input, -1, olive::Node::InvalidateCacheOptions()); - EXPECT_EQ(viewer_->GetLength(), olive::rational(0)); + EXPECT_EQ(viewer_->get_length(), olive::Rational(0)); } TEST_F(ViewerOutputTest, ValueRepushTagsStreams) { olive::NodeValueRow row; - row.insert(olive::ViewerOutput::kTextureInput, - olive::NodeValue(olive::NodeValue::kTexture, 0)); - row.insert(olive::ViewerOutput::kSamplesInput, - olive::NodeValue(olive::NodeValue::kSamples, 0)); + row.insert(olive::ViewerOutput::k_texture_input, + olive::NodeValue(olive::NodeValue::k_texture, 0)); + row.insert(olive::ViewerOutput::k_samples_input, + olive::NodeValue(olive::NodeValue::k_samples, 0)); olive::NodeValueTable table; - viewer_->Value(row, olive::NodeGlobals(), &table); + viewer_->value(row, olive::NodeGlobals(), &table); // The texture value is re-pushed tagged as video stream 0 const QString video_tag = - olive::Track::Reference(olive::Track::kVideo, 0).ToString(); - EXPECT_EQ(table.Get(olive::NodeValue::kTexture, video_tag).type(), - olive::NodeValue::kTexture); + olive::Track::Reference(olive::Track::k_video, 0).to_string(); + EXPECT_EQ(table.get(olive::NodeValue::k_texture, video_tag).type(), + olive::NodeValue::k_texture); // The samples value is re-pushed tagged as audio stream 0 const QString audio_tag = - olive::Track::Reference(olive::Track::kAudio, 0).ToString(); - EXPECT_EQ(table.Get(olive::NodeValue::kSamples, audio_tag).type(), - olive::NodeValue::kSamples); - EXPECT_EQ(table.Get(olive::NodeValue::kSamples).tag(), audio_tag); + olive::Track::Reference(olive::Track::k_audio, 0).to_string(); + EXPECT_EQ(table.get(olive::NodeValue::k_samples, audio_tag).type(), + olive::NodeValue::k_samples); + EXPECT_EQ(table.get(olive::NodeValue::k_samples).tag(), audio_tag); } TEST_F(ViewerOutputTest, LastUsedEncodingParamsRoundTrip) { olive::EncodingParams params; - params.SetFilename(QStringLiteral("/tmp/oak-export.mp4")); + params.set_filename(QStringLiteral("/tmp/oak-export.mp4")); - viewer_->SetLastUsedEncodingParams(params); + viewer_->set_last_used_encoding_params(params); - EXPECT_EQ(viewer_->GetLastUsedEncodingParams().filename(), + EXPECT_EQ(viewer_->get_last_used_encoding_params().filename(), QStringLiteral("/tmp/oak-export.mp4")); } TEST_F(ViewerOutputTest, SaveLoadCustomRoundTrip) { - viewer_->GetWorkArea()->set_enabled(true); - viewer_->GetWorkArea()->set_range( - olive::TimeRange(olive::rational(1), olive::rational(5))); + viewer_->get_work_area()->set_enabled(true); + viewer_->get_work_area()->set_range( + olive::TimeRange(olive::Rational(1), olive::Rational(5))); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("custom")); - viewer_->SaveCustom(&writer); + viewer_->save_custom(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -702,56 +702,56 @@ TEST_F(ViewerOutputTest, SaveLoadCustomRoundTrip) ASSERT_EQ(reader.name(), QStringLiteral("custom")); olive::ViewerOutput loaded; - ASSERT_TRUE(loaded.LoadCustom(&reader, nullptr)); - EXPECT_TRUE(loaded.GetWorkArea()->enabled()); - EXPECT_EQ(loaded.GetWorkArea()->range(), viewer_->GetWorkArea()->range()); + ASSERT_TRUE(loaded.load_custom(&reader, nullptr)); + EXPECT_TRUE(loaded.get_work_area()->enabled()); + EXPECT_EQ(loaded.get_work_area()->range(), viewer_->get_work_area()->range()); } TEST_F(ViewerOutputTest, RetranslateSetsInputNames) { - viewer_->Retranslate(); + viewer_->retranslate(); - EXPECT_EQ(viewer_->GetInputName(olive::ViewerOutput::kVideoParamsInput), + EXPECT_EQ(viewer_->get_input_name(olive::ViewerOutput::k_video_params_input), QStringLiteral("Video Parameters")); - EXPECT_EQ(viewer_->GetInputName(olive::ViewerOutput::kAudioParamsInput), + EXPECT_EQ(viewer_->get_input_name(olive::ViewerOutput::k_audio_params_input), QStringLiteral("Audio Parameters")); - EXPECT_EQ(viewer_->GetInputName(olive::ViewerOutput::kSubtitleParamsInput), + EXPECT_EQ(viewer_->get_input_name(olive::ViewerOutput::k_subtitle_params_input), QStringLiteral("Subtitle Parameters")); - EXPECT_EQ(viewer_->GetInputName(olive::ViewerOutput::kTextureInput), + EXPECT_EQ(viewer_->get_input_name(olive::ViewerOutput::k_texture_input), QStringLiteral("Texture")); - EXPECT_EQ(viewer_->GetInputName(olive::ViewerOutput::kSamplesInput), + EXPECT_EQ(viewer_->get_input_name(olive::ViewerOutput::k_samples_input), QStringLiteral("Samples")); } TEST_F(ViewerOutputTest, AutoCacheStubsAlwaysReportDisabled) { - EXPECT_FALSE(viewer_->IsVideoAutoCacheEnabled()); + EXPECT_FALSE(viewer_->is_video_auto_cache_enabled()); // The setter is a stub and must not change the reported state - viewer_->SetVideoAutoCacheEnabled(true); - EXPECT_FALSE(viewer_->IsVideoAutoCacheEnabled()); + viewer_->set_video_auto_cache_enabled(true); + EXPECT_FALSE(viewer_->is_video_auto_cache_enabled()); } TEST_F(ViewerOutputTest, SetWaveformEnabledWithoutConnectionIsSafe) { // No samples input connected: enabling waveform requests must not crash - viewer_->SetWaveformEnabled(true); - EXPECT_EQ(viewer_->GetConnectedWaveform(), nullptr); + viewer_->set_waveform_enabled(true); + EXPECT_EQ(viewer_->get_connected_waveform(), nullptr); - viewer_->SetWaveformEnabled(false); + viewer_->set_waveform_enabled(false); } TEST_F(ViewerOutputTest, FrequencyRateDataReflectsEnabledStreams) { // A video stream takes priority and is reported as a frame rate - QString rate = viewer_->data(olive::Node::FREQUENCY_RATE).toString(); + QString rate = viewer_->data(olive::Node::frequency_rate).toString(); EXPECT_TRUE(rate.endsWith(QStringLiteral(" FPS"))); // With the video stream disabled, the audio sample rate is reported - olive::VideoParams vp = viewer_->GetVideoParams(); + olive::VideoParams vp = viewer_->get_video_params(); vp.set_enabled(false); - viewer_->SetVideoParams(vp); + viewer_->set_video_params(vp); - rate = viewer_->data(olive::Node::FREQUENCY_RATE).toString(); + rate = viewer_->data(olive::Node::frequency_rate).toString(); EXPECT_TRUE(rate.endsWith(QStringLiteral(" Hz"))); } diff --git a/tests/gtest/audio_smoke_test.cpp b/tests/gtest/audio_smoke_test.cpp index 2669fd465..c7e9def15 100644 --- a/tests/gtest/audio_smoke_test.cpp +++ b/tests/gtest/audio_smoke_test.cpp @@ -44,13 +44,13 @@ namespace test // Helper Functions // ============================================================================ -static AudioParams MakeAudioParams(int sample_rate, uint64_t channel_layout, +static AudioParams make_audio_params(int sample_rate, uint64_t channel_layout, SampleFormat format) { return AudioParams(sample_rate, channel_layout, format); } -static void FillSampleBuffer(SampleBuffer &buffer, float value) +static void fill_sample_buffer(SampleBuffer &buffer, float value) { for (int ch = 0; ch < buffer.channel_count(); ++ch) { float *data = buffer.data(ch); @@ -64,16 +64,16 @@ static void FillSampleBuffer(SampleBuffer &buffer, float value) // filter graph still holds, returning the accumulated per-plane output. // Draining after a flush ends at EOF, which AudioProcessor reports as a // negative return value, so the final Convert result is intentionally unused. -static AudioProcessor::Buffer ConvertAndDrain(AudioProcessor &processor, +static AudioProcessor::Buffer convert_and_drain(AudioProcessor &processor, float **input, int nb_samples) { AudioProcessor::Buffer output; - EXPECT_GE(processor.Convert(input, nb_samples, &output), 0); + EXPECT_GE(processor.convert(input, nb_samples, &output), 0); - processor.Flush(); + processor.flush(); AudioProcessor::Buffer rest; - processor.Convert(nullptr, 0, &rest); + processor.convert(nullptr, 0, &rest); if (output.size() < rest.size()) { output.resize(rest.size()); @@ -94,24 +94,24 @@ TEST(AudioSmokeParams, DefaultConstruction) EXPECT_FALSE(params.is_valid()); EXPECT_EQ(params.sample_rate(), 0); EXPECT_EQ(params.channel_count(), 0); - EXPECT_EQ(params.format(), SampleFormat::INVALID); + EXPECT_EQ(params.format(), SampleFormat::invalid); } TEST(AudioSmokeParams, ValidConstruction) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); EXPECT_TRUE(params.is_valid()); EXPECT_EQ(params.sample_rate(), 48000); EXPECT_EQ(params.channel_count(), 2); - EXPECT_EQ(params.format(), SampleFormat::F32P); + EXPECT_EQ(params.format(), SampleFormat::f32_p); EXPECT_EQ(params.bytes_per_sample_per_channel(), 4); EXPECT_EQ(params.bits_per_sample(), 32); } TEST(AudioSmokeParams, MonoChannelLayout) { - AudioParams params(44100, kChannelLayoutMono, SampleFormat::S16); + AudioParams params(44100, k_channel_layout_mono, SampleFormat::s16); EXPECT_TRUE(params.is_valid()); EXPECT_EQ(params.sample_rate(), 44100); @@ -120,7 +120,7 @@ TEST(AudioSmokeParams, MonoChannelLayout) TEST(AudioSmokeParams, SurroundChannelLayout) { - AudioParams params(48000, kChannelLayout5Point1, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout5_point1, SampleFormat::f32_p); EXPECT_TRUE(params.is_valid()); EXPECT_EQ(params.channel_count(), 6); @@ -128,7 +128,7 @@ TEST(AudioSmokeParams, SurroundChannelLayout) TEST(AudioSmokeParams, TimeConversions) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); // Time to samples EXPECT_EQ(params.time_to_samples(1.0), 48000); @@ -145,11 +145,11 @@ TEST(AudioSmokeParams, TimeConversions) TEST(AudioSmokeParams, EqualityOperators) { - AudioParams params1(48000, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams params2(48000, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams params3(44100, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams params4(48000, kChannelLayoutMono, SampleFormat::F32P); - AudioParams params5(48000, kChannelLayoutStereo, SampleFormat::S16); + AudioParams params1(48000, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams params2(48000, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams params3(44100, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams params4(48000, k_channel_layout_mono, SampleFormat::f32_p); + AudioParams params5(48000, k_channel_layout_stereo, SampleFormat::s16); EXPECT_TRUE(params1 == params2); EXPECT_FALSE(params1 != params2); @@ -161,7 +161,7 @@ TEST(AudioSmokeParams, EqualityOperators) TEST(AudioSmokeParams, CopyConstruction) { - AudioParams original(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams original(48000, k_channel_layout_stereo, SampleFormat::f32_p); AudioParams copy(original); EXPECT_TRUE(copy.is_valid()); @@ -177,7 +177,7 @@ TEST(AudioSmokeParams, CopyConstruction) TEST(AudioSmokeParams, CopyAssignment) { - AudioParams original(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams original(48000, k_channel_layout_stereo, SampleFormat::f32_p); AudioParams copy; copy = original; @@ -189,15 +189,15 @@ TEST(AudioSmokeParams, CopyAssignment) TEST(AudioSmokeParams, ChannelLayoutModification) { - AudioParams params(48000, kChannelLayoutMono, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_mono, SampleFormat::f32_p); EXPECT_EQ(params.channel_count(), 1); // Change to stereo - params.set_channel_layout(kChannelLayoutStereo); + params.set_channel_layout(k_channel_layout_stereo); EXPECT_EQ(params.channel_count(), 2); // Change to 5.1 - params.set_channel_layout(kChannelLayout5Point1); + params.set_channel_layout(k_channel_layout5_point1); EXPECT_EQ(params.channel_count(), 6); } @@ -215,7 +215,7 @@ TEST(AudioSmokeBuffer, DefaultConstruction) TEST(AudioSmokeBuffer, Allocation) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(48000)); // 1 second of samples EXPECT_TRUE(buffer.is_allocated()); @@ -225,11 +225,11 @@ TEST(AudioSmokeBuffer, Allocation) TEST(AudioSmokeBuffer, DataAccess) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(100)); // Fill with test data - FillSampleBuffer(buffer, 0.5f); + fill_sample_buffer(buffer, 0.5f); // Verify data for (int ch = 0; ch < buffer.channel_count(); ++ch) { @@ -242,11 +242,11 @@ TEST(AudioSmokeBuffer, DataAccess) TEST(AudioSmokeBuffer, Silence) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(100)); // Fill with non-zero values - FillSampleBuffer(buffer, 0.5f); + fill_sample_buffer(buffer, 0.5f); // Apply silence buffer.silence(); @@ -262,11 +262,11 @@ TEST(AudioSmokeBuffer, Silence) TEST(AudioSmokeBuffer, VolumeTransform) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(100)); // Fill with 1.0 - FillSampleBuffer(buffer, 1.0f); + fill_sample_buffer(buffer, 1.0f); // Apply volume transform (50%) buffer.transform_volume(0.5f); @@ -282,7 +282,7 @@ TEST(AudioSmokeBuffer, VolumeTransform) TEST(AudioSmokeBuffer, Clamp) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(100)); // Fill with values outside [-1, 1] @@ -308,11 +308,11 @@ TEST(AudioSmokeBuffer, Clamp) TEST(AudioSmokeBuffer, FastSet) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer source(params, size_t(100)); SampleBuffer dest(params, size_t(100)); - FillSampleBuffer(source, 0.75f); + fill_sample_buffer(source, 0.75f); dest.silence(); // Fast copy from source to dest @@ -327,7 +327,7 @@ TEST(AudioSmokeBuffer, FastSet) TEST(AudioSmokeBuffer, RipChannel) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(100)); // Fill channel 0 with 0.5, channel 1 with 0.25 @@ -358,7 +358,7 @@ TEST(AudioSmokeWaveform, DefaultConstruction) { AudioVisualWaveform waveform; EXPECT_EQ(waveform.channel_count(), 0); - EXPECT_EQ(waveform.length(), rational(0)); + EXPECT_EQ(waveform.length(), Rational(0)); } TEST(AudioSmokeWaveform, ChannelCount) @@ -377,7 +377,7 @@ TEST(AudioSmokeWaveform, OverwriteSamples) waveform.set_channel_count(2); // Create sample buffer with sine wave-like data - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(4800)); // 0.1 seconds for (int ch = 0; ch < buffer.channel_count(); ++ch) { @@ -388,10 +388,10 @@ TEST(AudioSmokeWaveform, OverwriteSamples) } // Write samples to waveform - waveform.OverwriteSamples(buffer, 48000, rational(0)); + waveform.overwrite_samples(buffer, 48000, Rational(0)); // 4800 samples at 48000 Hz is exactly 0.1 seconds - EXPECT_EQ(waveform.length(), rational(1, 10)); + EXPECT_EQ(waveform.length(), Rational(1, 10)); } TEST(AudioSmokeWaveform, OverwriteSilence) @@ -400,20 +400,20 @@ TEST(AudioSmokeWaveform, OverwriteSilence) waveform.set_channel_count(2); // First add some samples - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(4800)); - FillSampleBuffer(buffer, 0.5f); - waveform.OverwriteSamples(buffer, 48000, rational(0)); + fill_sample_buffer(buffer, 0.5f); + waveform.overwrite_samples(buffer, 48000, Rational(0)); // Overwrite with silence - waveform.OverwriteSilence(rational(0), rational(1, 10)); // 0.1 seconds + waveform.overwrite_silence(Rational(0), Rational(1, 10)); // 0.1 seconds // The silence covers exactly the written region, so the length is // unchanged at exactly 0.1 seconds - EXPECT_EQ(waveform.length(), rational(1, 10)); + EXPECT_EQ(waveform.length(), Rational(1, 10)); // ...and the overwritten region is actually silent - auto summary = waveform.GetSummaryFromTime(rational(0), rational(1, 10)); + auto summary = waveform.get_summary_from_time(Rational(0), Rational(1, 10)); ASSERT_EQ(summary.size(), 2); EXPECT_FLOAT_EQ(summary[0].min, 0.0f); EXPECT_FLOAT_EQ(summary[0].max, 0.0f); @@ -427,17 +427,17 @@ TEST(AudioSmokeWaveform, TrimIn) waveform.set_channel_count(2); // Add samples - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(48000)); // 1 second - FillSampleBuffer(buffer, 0.5f); - waveform.OverwriteSamples(buffer, 48000, rational(0)); + fill_sample_buffer(buffer, 0.5f); + waveform.overwrite_samples(buffer, 48000, Rational(0)); - EXPECT_EQ(waveform.length(), rational(1)); + EXPECT_EQ(waveform.length(), Rational(1)); // Trim 0.25 seconds from start - waveform.TrimIn(rational(1, 4)); + waveform.trim_in(Rational(1, 4)); - EXPECT_EQ(waveform.length(), rational(3, 4)); + EXPECT_EQ(waveform.length(), Rational(3, 4)); } TEST(AudioSmokeWaveform, Resize) @@ -446,17 +446,17 @@ TEST(AudioSmokeWaveform, Resize) waveform.set_channel_count(2); // Add samples - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(48000)); - FillSampleBuffer(buffer, 0.5f); - waveform.OverwriteSamples(buffer, 48000, rational(0)); + fill_sample_buffer(buffer, 0.5f); + waveform.overwrite_samples(buffer, 48000, Rational(0)); - EXPECT_EQ(waveform.length(), rational(1)); + EXPECT_EQ(waveform.length(), Rational(1)); // Resize to 0.5 seconds - waveform.Resize(rational(1, 2)); + waveform.resize(Rational(1, 2)); - EXPECT_EQ(waveform.length(), rational(1, 2)); + EXPECT_EQ(waveform.length(), Rational(1, 2)); } TEST(AudioSmokeWaveform, TrimRange) @@ -465,17 +465,17 @@ TEST(AudioSmokeWaveform, TrimRange) waveform.set_channel_count(2); // Add 2 seconds of samples - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(96000)); - FillSampleBuffer(buffer, 0.5f); - waveform.OverwriteSamples(buffer, 48000, rational(0)); + fill_sample_buffer(buffer, 0.5f); + waveform.overwrite_samples(buffer, 48000, Rational(0)); - EXPECT_EQ(waveform.length(), rational(2)); + EXPECT_EQ(waveform.length(), Rational(2)); // Trim to range [0.5, 1.0] (0.5 seconds duration starting at 0.5) - waveform.TrimRange(rational(1, 2), rational(1, 2)); + waveform.trim_range(Rational(1, 2), Rational(1, 2)); - EXPECT_EQ(waveform.length(), rational(1, 2)); + EXPECT_EQ(waveform.length(), Rational(1, 2)); } TEST(AudioSmokeWaveform, Mid) @@ -484,15 +484,15 @@ TEST(AudioSmokeWaveform, Mid) waveform.set_channel_count(2); // Add 2 seconds of samples - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(96000)); - FillSampleBuffer(buffer, 0.5f); - waveform.OverwriteSamples(buffer, 48000, rational(0)); + fill_sample_buffer(buffer, 0.5f); + waveform.overwrite_samples(buffer, 48000, Rational(0)); // Get mid section [0.5, 1.5] - AudioVisualWaveform mid = waveform.Mid(rational(1, 2), rational(1)); + AudioVisualWaveform mid = waveform.mid(Rational(1, 2), Rational(1)); - EXPECT_EQ(mid.length(), rational(1)); + EXPECT_EQ(mid.length(), Rational(1)); EXPECT_EQ(mid.channel_count(), 2); } @@ -502,7 +502,7 @@ TEST(AudioSmokeWaveform, GetSummaryFromTime) waveform.set_channel_count(2); // Add samples with varying values - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(4800)); for (int ch = 0; ch < buffer.channel_count(); ++ch) { float *data = buffer.data(ch); @@ -510,10 +510,10 @@ TEST(AudioSmokeWaveform, GetSummaryFromTime) data[i] = (i % 2 == 0) ? 0.8f : -0.8f; } } - waveform.OverwriteSamples(buffer, 48000, rational(0)); + waveform.overwrite_samples(buffer, 48000, Rational(0)); // Get summary for first half - auto summary = waveform.GetSummaryFromTime(rational(0), rational(1, 20)); + auto summary = waveform.get_summary_from_time(Rational(0), Rational(1, 20)); ASSERT_EQ(summary.size(), 2); // 2 channels // Samples alternate between +0.8 and -0.8, so the summary is exactly that @@ -525,7 +525,7 @@ TEST(AudioSmokeWaveform, GetSummaryFromTime) TEST(AudioSmokeWaveform, SumSamples) { - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(100)); // Fill with known pattern @@ -536,7 +536,7 @@ TEST(AudioSmokeWaveform, SumSamples) } } - auto summary = AudioVisualWaveform::SumSamples(buffer, 0, 100); + auto summary = AudioVisualWaveform::sum_samples(buffer, 0, 100); EXPECT_EQ(summary.size(), 2); EXPECT_FLOAT_EQ(summary[0].min, 0.0f); @@ -554,7 +554,7 @@ TEST(AudioSmokeWaveform, ReSumSamples) samples[i * 2 + 1].max = 0.3f; } - auto summary = AudioVisualWaveform::ReSumSamples(samples.data(), 200, 2); + auto summary = AudioVisualWaveform::re_sum_samples(samples.data(), 200, 2); EXPECT_EQ(summary.size(), 2); EXPECT_FLOAT_EQ(summary[0].min, -0.5f); @@ -570,43 +570,43 @@ TEST(AudioSmokeWaveform, ReSumSamples) TEST(AudioSmokeProcessor, DefaultConstruction) { AudioProcessor processor; - EXPECT_FALSE(processor.IsOpen()); + EXPECT_FALSE(processor.is_open()); } TEST(AudioSmokeProcessor, OpenClose) { AudioProcessor processor; - AudioParams from(48000, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams to(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams from(48000, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams to(48000, k_channel_layout_stereo, SampleFormat::f32_p); - EXPECT_TRUE(processor.Open(from, to, 1.0)); - EXPECT_TRUE(processor.IsOpen()); + EXPECT_TRUE(processor.open(from, to, 1.0)); + EXPECT_TRUE(processor.is_open()); - processor.Close(); - EXPECT_FALSE(processor.IsOpen()); + processor.close(); + EXPECT_FALSE(processor.is_open()); } TEST(AudioSmokeProcessor, SampleRateConversion) { AudioProcessor processor; - AudioParams from(48000, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams to(44100, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams from(48000, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams to(44100, k_channel_layout_stereo, SampleFormat::f32_p); - ASSERT_TRUE(processor.Open(from, to, 1.0)); - ASSERT_TRUE(processor.IsOpen()); + ASSERT_TRUE(processor.open(from, to, 1.0)); + ASSERT_TRUE(processor.is_open()); EXPECT_EQ(processor.from().sample_rate(), 48000); EXPECT_EQ(processor.to().sample_rate(), 44100); // Push one second of a constant signal - constexpr int kSamples = 48000; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, 0.5f); + constexpr int k_samples = 48000; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, 0.5f); float *input[2] = { left.data(), right.data() }; const AudioProcessor::Buffer output = - ConvertAndDrain(processor, input, kSamples); + convert_and_drain(processor, input, k_samples); ASSERT_EQ(output.size(), 2); ASSERT_EQ(output.at(0).size(), output.at(1).size()); @@ -629,25 +629,25 @@ TEST(AudioSmokeProcessor, ChannelLayoutConversion) { AudioProcessor processor; - AudioParams from(48000, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams to(48000, kChannelLayoutMono, SampleFormat::F32P); + AudioParams from(48000, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams to(48000, k_channel_layout_mono, SampleFormat::f32_p); - ASSERT_TRUE(processor.Open(from, to, 1.0)); - ASSERT_TRUE(processor.IsOpen()); + ASSERT_TRUE(processor.open(from, to, 1.0)); + ASSERT_TRUE(processor.is_open()); EXPECT_EQ(processor.from().channel_count(), 2); EXPECT_EQ(processor.to().channel_count(), 1); - constexpr int kSamples = 1024; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, 0.5f); + constexpr int k_samples = 1024; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, 0.5f); float *input[2] = { left.data(), right.data() }; AudioProcessor::Buffer output; - ASSERT_EQ(processor.Convert(input, kSamples, &output), 0); + ASSERT_EQ(processor.convert(input, k_samples, &output), 0); // Downmixing folds both channels into a single mono plane ASSERT_EQ(output.size(), 1); - ASSERT_EQ(output.at(0).size(), kSamples * int(sizeof(float))); + ASSERT_EQ(output.at(0).size(), k_samples * int(sizeof(float))); // The downmix of two identical channels must stay audible regardless of // the exact mixing coefficients @@ -661,24 +661,24 @@ TEST(AudioSmokeProcessor, FormatConversion) { AudioProcessor processor; - AudioParams from(48000, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams to(48000, kChannelLayoutStereo, SampleFormat::S16P); + AudioParams from(48000, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams to(48000, k_channel_layout_stereo, SampleFormat::s16_p); - ASSERT_TRUE(processor.Open(from, to, 1.0)); - ASSERT_TRUE(processor.IsOpen()); + ASSERT_TRUE(processor.open(from, to, 1.0)); + ASSERT_TRUE(processor.is_open()); - constexpr int kSamples = 1024; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, -0.25f); + constexpr int k_samples = 1024; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, -0.25f); float *input[2] = { left.data(), right.data() }; AudioProcessor::Buffer output; - ASSERT_EQ(processor.Convert(input, kSamples, &output), 0); + ASSERT_EQ(processor.convert(input, k_samples, &output), 0); // Planar 16-bit output keeps one plane per channel at 2 bytes per sample ASSERT_EQ(output.size(), 2); - ASSERT_EQ(output.at(0).size(), kSamples * int(sizeof(int16_t))); - ASSERT_EQ(output.at(1).size(), kSamples * int(sizeof(int16_t))); + ASSERT_EQ(output.at(0).size(), k_samples * int(sizeof(int16_t))); + ASSERT_EQ(output.at(1).size(), k_samples * int(sizeof(int16_t))); // Known float values land on the expected 16-bit codes int16_t value = 0; @@ -692,21 +692,21 @@ TEST(AudioSmokeProcessor, TempoChange) { AudioProcessor processor; - AudioParams from(48000, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams to(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams from(48000, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams to(48000, k_channel_layout_stereo, SampleFormat::f32_p); // Open with 2x tempo - ASSERT_TRUE(processor.Open(from, to, 2.0)); - ASSERT_TRUE(processor.IsOpen()); + ASSERT_TRUE(processor.open(from, to, 2.0)); + ASSERT_TRUE(processor.is_open()); // One second of input - constexpr int kSamples = 48000; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, 0.5f); + constexpr int k_samples = 48000; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, 0.5f); float *input[2] = { left.data(), right.data() }; const AudioProcessor::Buffer output = - ConvertAndDrain(processor, input, kSamples); + convert_and_drain(processor, input, k_samples); ASSERT_EQ(output.size(), 2); ASSERT_EQ(output.at(0).size(), output.at(1).size()); @@ -730,12 +730,12 @@ TEST(AudioSmokeProcessor, InvalidOpen) AudioProcessor processor; // Open with valid params - AudioParams from(48000, kChannelLayoutStereo, SampleFormat::F32P); - AudioParams to(48000, kChannelLayoutStereo, SampleFormat::F32P); - EXPECT_TRUE(processor.Open(from, to, 1.0)); + AudioParams from(48000, k_channel_layout_stereo, SampleFormat::f32_p); + AudioParams to(48000, k_channel_layout_stereo, SampleFormat::f32_p); + EXPECT_TRUE(processor.open(from, to, 1.0)); // Try to open again while already open (should fail) - EXPECT_FALSE(processor.Open(from, to, 1.0)); + EXPECT_FALSE(processor.open(from, to, 1.0)); } TEST(AudioSmokeProcessor, ConvertWithoutOpen) @@ -752,7 +752,7 @@ TEST(AudioSmokeProcessor, ConvertWithoutOpen) AudioProcessor::Buffer output; // Should fail since processor is not open - EXPECT_EQ(processor.Convert(input, 100, &output), -1); + EXPECT_EQ(processor.convert(input, 100, &output), -1); } // ============================================================================ @@ -769,10 +769,10 @@ TEST(AudioSmokePreviewDevice, Construction) // SetParams derives the frame size from the audio format: // bytes per sample per channel * channel count - device.SetParams(AudioParams(48000, kChannelLayoutStereo, SampleFormat::F32P)); + device.set_params(AudioParams(48000, k_channel_layout_stereo, SampleFormat::f32_p)); EXPECT_EQ(device.bytes_per_frame(), 8); - device.SetParams(AudioParams(48000, kChannelLayoutMono, SampleFormat::S16)); + device.set_params(AudioParams(48000, k_channel_layout_mono, SampleFormat::s16)); EXPECT_EQ(device.bytes_per_frame(), 2); } @@ -799,7 +799,7 @@ TEST(AudioSmokePreviewDevice, NotifyInterval) device.set_notify_interval(64); int notify_count = 0; - QObject::connect(&device, &PreviewAudioDevice::Notify, &device, + QObject::connect(&device, &PreviewAudioDevice::notify, &device, [¬ify_count]() { ++notify_count; }); QByteArray data(256, 0x01); @@ -827,7 +827,7 @@ TEST(AudioSmokePreviewDevice, NotifyInterval) PreviewAudioDevice quiet_device; quiet_device.open(QIODevice::ReadWrite); int quiet_count = 0; - QObject::connect(&quiet_device, &PreviewAudioDevice::Notify, &quiet_device, + QObject::connect(&quiet_device, &PreviewAudioDevice::notify, &quiet_device, [&quiet_count]() { ++quiet_count; }); ASSERT_EQ(quiet_device.write(data), 256); EXPECT_EQ(quiet_device.readData(buf, 128), 128); @@ -841,7 +841,7 @@ TEST(AudioSmokePreviewDevice, Clear) device.set_notify_interval(64); int notify_count = 0; - QObject::connect(&device, &PreviewAudioDevice::Notify, &device, + QObject::connect(&device, &PreviewAudioDevice::notify, &device, [¬ify_count]() { ++notify_count; }); // Write some data and read it back (readData() is called directly to @@ -874,59 +874,59 @@ TEST(AudioSmokePreviewDevice, Clear) TEST(AudioSmokeSampleFormat, ByteCount) { - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::INVALID), 0); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::U8), 1); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::U8P), 1); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::S16), 2); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::S16P), 2); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::S32), 4); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::S32P), 4); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::F32), 4); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::F32P), 4); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::S64), 8); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::S64P), 8); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::F64), 8); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::F64P), 8); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::invalid), 0); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::u8), 1); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::u8_p), 1); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::s16), 2); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::s16_p), 2); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::s32), 4); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::s32_p), 4); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::f32), 4); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::f32_p), 4); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::s64), 8); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::s64_p), 8); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::f64), 8); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::f64_p), 8); } TEST(AudioSmokeSampleFormat, PackedVsPlanar) { // Packed formats - EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::U8)); - EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::S16)); - EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::S32)); - EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::F32)); - EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::S64)); - EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::F64)); + EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::u8)); + EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::s16)); + EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::s32)); + EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::f32)); + EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::s64)); + EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::f64)); // Planar formats - EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::U8P)); - EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::S16P)); - EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::S32P)); - EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::F32P)); - EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::S64P)); - EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::F64P)); + EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::u8_p)); + EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::s16_p)); + EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::s32_p)); + EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::f32_p)); + EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::s64_p)); + EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::f64_p)); } TEST(AudioSmokeSampleFormat, StringConversion) { // Test to_string (values may vary based on FFmpeg version) - EXPECT_EQ(SampleFormat::to_string(SampleFormat::U8), "u8"); - EXPECT_EQ(SampleFormat::to_string(SampleFormat::S16), "s16"); - EXPECT_EQ(SampleFormat::to_string(SampleFormat::S32), "s32"); + EXPECT_EQ(SampleFormat::to_string(SampleFormat::u8), "u8"); + EXPECT_EQ(SampleFormat::to_string(SampleFormat::s16), "s16"); + EXPECT_EQ(SampleFormat::to_string(SampleFormat::s32), "s32"); // F32 can be "flt" or "f32" depending on FFmpeg version - std::string f32_str = SampleFormat::to_string(SampleFormat::F32); + std::string f32_str = SampleFormat::to_string(SampleFormat::f32); EXPECT_TRUE(f32_str == "flt" || f32_str == "f32"); // F64 can be "dbl" or "f64" depending on FFmpeg version - std::string f64_str = SampleFormat::to_string(SampleFormat::F64); + std::string f64_str = SampleFormat::to_string(SampleFormat::f64); EXPECT_TRUE(f64_str == "dbl" || f64_str == "f64"); // Test from_string - EXPECT_EQ(SampleFormat::from_string("u8"), SampleFormat::U8); - EXPECT_EQ(SampleFormat::from_string("s16"), SampleFormat::S16); + EXPECT_EQ(SampleFormat::from_string("u8"), SampleFormat::u8); + EXPECT_EQ(SampleFormat::from_string("s16"), SampleFormat::s16); // from_string may not support all format names - EXPECT_EQ(SampleFormat::from_string(""), SampleFormat::INVALID); - EXPECT_EQ(SampleFormat::from_string("unknown"), SampleFormat::INVALID); + EXPECT_EQ(SampleFormat::from_string(""), SampleFormat::invalid); + EXPECT_EQ(SampleFormat::from_string("unknown"), SampleFormat::invalid); } // ============================================================================ @@ -942,10 +942,10 @@ TEST(AudioSmokeThread, ConcurrentWaveformAccess) waveform.set_channel_count(2); // Pre-populate with data - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); SampleBuffer buffer(params, size_t(4800)); - FillSampleBuffer(buffer, 0.5f); - waveform.OverwriteSamples(buffer, 48000, rational(0)); + fill_sample_buffer(buffer, 0.5f); + waveform.overwrite_samples(buffer, 48000, Rational(0)); std::vector threads; std::atomic success_count{ 0 }; @@ -954,9 +954,9 @@ TEST(AudioSmokeThread, ConcurrentWaveformAccess) threads.emplace_back([&waveform, &success_count, num_ops_per_thread]() { for (int i = 0; i < num_ops_per_thread; ++i) { // Read summary from different times - auto summary = waveform.GetSummaryFromTime( - rational(i % 10, 100), // 0.00 to 0.09 seconds - rational(1, 100) // 0.01 second duration + auto summary = waveform.get_summary_from_time( + Rational(i % 10, 100), // 0.00 to 0.09 seconds + Rational(1, 100) // 0.01 second duration ); if (summary.size() == 2) { @@ -980,13 +980,13 @@ TEST(AudioSmokeThread, ConcurrentSampleBufferOperations) // race-free and must produce deterministic results const int num_threads = 4; - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); std::vector buffers; buffers.reserve(num_threads); for (int t = 0; t < num_threads; ++t) { buffers.emplace_back(params, size_t(1000)); - FillSampleBuffer(buffers.back(), 0.5f); + fill_sample_buffer(buffers.back(), 0.5f); } std::vector threads; diff --git a/tests/gtest/audio_synchronizer_test.cpp b/tests/gtest/audio_synchronizer_test.cpp index 6e9cabd0e..f2b5f413f 100644 --- a/tests/gtest/audio_synchronizer_test.cpp +++ b/tests/gtest/audio_synchronizer_test.cpp @@ -5,52 +5,52 @@ TEST(AudioSynchronizer, PlacesCandidateBySourceStartTime) { olive::AudioSynchronizer::SourceClip reference; - reference.source_start_time = olive::core::rational(100); + reference.source_start_time = olive::core::Rational(100); reference.has_source_start_time = true; olive::AudioSynchronizer::SourceClip candidate; - candidate.source_start_time = olive::core::rational(112); + candidate.source_start_time = olive::core::Rational(112); candidate.has_source_start_time = true; const olive::AudioSynchronizer::Placement placement = - olive::AudioSynchronizer::PlaceBySourceTime(reference, candidate, - olive::core::rational(10)); + olive::AudioSynchronizer::place_by_source_time(reference, candidate, + olive::core::Rational(10)); ASSERT_TRUE(placement.valid); - EXPECT_EQ(placement.timeline_in, olive::core::rational(22)); + EXPECT_EQ(placement.timeline_in, olive::core::Rational(22)); } TEST(AudioSynchronizer, AccountsForMediaInWhenPlacingBySourceTime) { olive::AudioSynchronizer::SourceClip reference; - reference.source_start_time = olive::core::rational(100); - reference.media_in = olive::core::rational(2); + reference.source_start_time = olive::core::Rational(100); + reference.media_in = olive::core::Rational(2); reference.has_source_start_time = true; olive::AudioSynchronizer::SourceClip candidate; - candidate.source_start_time = olive::core::rational(100); - candidate.media_in = olive::core::rational(5); + candidate.source_start_time = olive::core::Rational(100); + candidate.media_in = olive::core::Rational(5); candidate.has_source_start_time = true; const olive::AudioSynchronizer::Placement placement = - olive::AudioSynchronizer::PlaceBySourceTime(reference, candidate, - olive::core::rational(20)); + olive::AudioSynchronizer::place_by_source_time(reference, candidate, + olive::core::Rational(20)); ASSERT_TRUE(placement.valid); - EXPECT_EQ(placement.timeline_in, olive::core::rational(23)); + EXPECT_EQ(placement.timeline_in, olive::core::Rational(23)); } TEST(AudioSynchronizer, RejectsMissingSourceStartTime) { olive::AudioSynchronizer::SourceClip reference; - reference.source_start_time = olive::core::rational(100); + reference.source_start_time = olive::core::Rational(100); reference.has_source_start_time = true; olive::AudioSynchronizer::SourceClip candidate; const olive::AudioSynchronizer::Placement placement = - olive::AudioSynchronizer::PlaceBySourceTime(reference, candidate, - olive::core::rational(10)); + olive::AudioSynchronizer::place_by_source_time(reference, candidate, + olive::core::Rational(10)); EXPECT_FALSE(placement.valid); } @@ -58,19 +58,19 @@ TEST(AudioSynchronizer, RejectsMissingSourceStartTime) TEST(AudioSynchronizer, PlacesCandidateByWaveformOffset) { const olive::AudioSynchronizer::Placement placement = - olive::AudioSynchronizer::PlaceByWaveformOffset( - olive::core::rational(10), 24000, 48000); + olive::AudioSynchronizer::place_by_waveform_offset( + olive::core::Rational(10), 24000, 48000); ASSERT_TRUE(placement.valid); - EXPECT_EQ(placement.timeline_in, olive::core::rational(21, 2)); + EXPECT_EQ(placement.timeline_in, olive::core::Rational(21, 2)); } TEST(AudioSynchronizer, SupportsCandidateLeadByWaveformOffset) { const olive::AudioSynchronizer::Placement placement = - olive::AudioSynchronizer::PlaceByWaveformOffset( - olive::core::rational(10), -48000, 48000); + olive::AudioSynchronizer::place_by_waveform_offset( + olive::core::Rational(10), -48000, 48000); ASSERT_TRUE(placement.valid); - EXPECT_EQ(placement.timeline_in, olive::core::rational(9)); + EXPECT_EQ(placement.timeline_in, olive::core::Rational(9)); } diff --git a/tests/gtest/audio_waveform_sync_test.cpp b/tests/gtest/audio_waveform_sync_test.cpp index e31800bf8..981b0c66d 100644 --- a/tests/gtest/audio_waveform_sync_test.cpp +++ b/tests/gtest/audio_waveform_sync_test.cpp @@ -8,15 +8,15 @@ namespace { -olive::core::AudioParams MakeMonoParams() +olive::core::AudioParams make_mono_params() { - return olive::core::AudioParams(48000, olive::core::kChannelLayoutMono, - olive::core::SampleFormat::F32P); + return olive::core::AudioParams(48000, olive::core::k_channel_layout_mono, + olive::core::SampleFormat::f32_p); } -olive::core::SampleBuffer MakeBuffer(const QVector &values) +olive::core::SampleBuffer make_buffer(const QVector &values) { - olive::core::SampleBuffer samples(MakeMonoParams(), + olive::core::SampleBuffer samples(make_mono_params(), static_cast(values.size())); float *data = samples.data(0); for (int i = 0; i < values.size(); i++) { @@ -30,10 +30,10 @@ olive::core::SampleBuffer MakeBuffer(const QVector &values) TEST(AudioWaveformSync, ExtractsRmsEnvelope) { olive::core::SampleBuffer samples = - MakeBuffer({ 1.0f, -1.0f, 0.5f, -0.5f, 0.0f, 0.0f }); + make_buffer({ 1.0f, -1.0f, 0.5f, -0.5f, 0.0f, 0.0f }); const QVector envelope = - olive::AudioWaveformSync::ExtractRmsEnvelope(samples, 2); + olive::AudioWaveformSync::extract_rms_envelope(samples, 2); ASSERT_EQ(envelope.size(), 3); EXPECT_NEAR(envelope.at(0), 1.0, 0.0001); @@ -50,8 +50,8 @@ TEST(AudioWaveformSync, EstimatesCandidateLag) 0.6f, 0.6f, 0.0f, 0.0f }; const olive::AudioWaveformSync::OffsetResult result = - olive::AudioWaveformSync::EstimateOffset( - MakeBuffer(reference_values), MakeBuffer(candidate_values), 2, 8); + olive::AudioWaveformSync::estimate_offset( + make_buffer(reference_values), make_buffer(candidate_values), 2, 8); ASSERT_TRUE(result.valid); EXPECT_EQ(result.offset_samples, 2); @@ -67,8 +67,8 @@ TEST(AudioWaveformSync, EstimatesCandidateLead) 0.7f, 0.7f, 0.0f, 0.0f }; const olive::AudioWaveformSync::OffsetResult result = - olive::AudioWaveformSync::EstimateOffset( - MakeBuffer(reference_values), MakeBuffer(candidate_values), 2, 4); + olive::AudioWaveformSync::estimate_offset( + make_buffer(reference_values), make_buffer(candidate_values), 2, 4); ASSERT_TRUE(result.valid); EXPECT_EQ(result.offset_samples, -4); @@ -77,13 +77,13 @@ TEST(AudioWaveformSync, EstimatesCandidateLead) TEST(AudioWaveformSync, RejectsSilence) { - olive::core::SampleBuffer reference(MakeMonoParams(), size_t(16)); - olive::core::SampleBuffer candidate(MakeMonoParams(), size_t(16)); + olive::core::SampleBuffer reference(make_mono_params(), size_t(16)); + olive::core::SampleBuffer candidate(make_mono_params(), size_t(16)); reference.silence(); candidate.silence(); const olive::AudioWaveformSync::OffsetResult result = - olive::AudioWaveformSync::EstimateOffset(reference, candidate, 4, 16); + olive::AudioWaveformSync::estimate_offset(reference, candidate, 4, 16); EXPECT_FALSE(result.valid); } @@ -106,10 +106,10 @@ TEST(AudioWaveformSync, MaskedEstimationIgnoresInvalidWindows) } const olive::AudioWaveformSync::OffsetResult unmasked = - olive::AudioWaveformSync::EstimateEnvelopeOffset(reference, candidate, 1, + olive::AudioWaveformSync::estimate_envelope_offset(reference, candidate, 1, 8); const olive::AudioWaveformSync::OffsetResult masked = - olive::AudioWaveformSync::EstimateEnvelopeOffset( + olive::AudioWaveformSync::estimate_envelope_offset( reference, candidate, QVector(), candidate_valid, 1, 8); ASSERT_TRUE(masked.valid); @@ -140,7 +140,7 @@ TEST(AudioWaveformSync, EstimatesStretchAndOffset) } const olive::AudioWaveformSync::StretchOffsetResult result = - olive::AudioWaveformSync::EstimateStretchAndOffset( + olive::AudioWaveformSync::estimate_stretch_and_offset( reference, candidate, QVector(), QVector(), 1, 12, 0.8, 2.5, 0.005); @@ -156,7 +156,7 @@ TEST(AudioWaveformSync, StretchEstimationRejectsSilence) const QVector silence(16, 0.0); const olive::AudioWaveformSync::StretchOffsetResult result = - olive::AudioWaveformSync::EstimateStretchAndOffset( + olive::AudioWaveformSync::estimate_stretch_and_offset( silence, silence, QVector(), QVector(), 1, 8, 0.5, 2.0, 0.1); @@ -167,15 +167,15 @@ TEST(AudioWaveformSync, StretchEstimationRejectsInvalidParameters) { const QVector envelope = { 0.5, 0.6, 0.7, 0.8 }; - EXPECT_FALSE(olive::AudioWaveformSync::EstimateStretchAndOffset( + EXPECT_FALSE(olive::AudioWaveformSync::estimate_stretch_and_offset( envelope, envelope, QVector(), QVector(), 1, 8, 0.0, 2.0, 0.1) .valid); - EXPECT_FALSE(olive::AudioWaveformSync::EstimateStretchAndOffset( + EXPECT_FALSE(olive::AudioWaveformSync::estimate_stretch_and_offset( envelope, envelope, QVector(), QVector(), 1, 8, 2.0, 0.5, 0.1) .valid); - EXPECT_FALSE(olive::AudioWaveformSync::EstimateStretchAndOffset( + EXPECT_FALSE(olive::AudioWaveformSync::estimate_stretch_and_offset( envelope, envelope, QVector(), QVector(), 1, 8, 0.5, 2.0, 0.0) .valid); diff --git a/tests/gtest/audio_waveform_test.cpp b/tests/gtest/audio_waveform_test.cpp index 2d143565e..b2b18ff1f 100644 --- a/tests/gtest/audio_waveform_test.cpp +++ b/tests/gtest/audio_waveform_test.cpp @@ -22,18 +22,18 @@ namespace { -constexpr int kSampleRate = 48000; +constexpr int k_sample_rate = 48000; -olive::core::AudioParams MakeParams(uint64_t channel_layout) +olive::core::AudioParams make_params(uint64_t channel_layout) { - return olive::core::AudioParams(kSampleRate, channel_layout, - olive::core::SampleFormat::F32P); + return olive::core::AudioParams(k_sample_rate, channel_layout, + olive::core::SampleFormat::f32_p); } // Returns a buffer of `sample_count` samples per channel, every sample set to // `value`. Constant buffers keep mipmap chunk boundaries irrelevant, so // summaries can be checked with exact float comparisons. -olive::core::SampleBuffer MakeConstantBuffer( +olive::core::SampleBuffer make_constant_buffer( const olive::core::AudioParams ¶ms, size_t sample_count, float value) { olive::core::SampleBuffer buffer(params, sample_count); @@ -49,28 +49,28 @@ olive::core::SampleBuffer MakeConstantBuffer( // Returns one second of mono `first_value` followed by one second of mono // `second_value`. The split lands exactly on a chunk boundary at every mipmap // rate when kSampleRate is 48000, so per-range summaries stay exact. -olive::core::SampleBuffer MakeSplitMonoBuffer(float first_value, +olive::core::SampleBuffer make_split_mono_buffer(float first_value, float second_value) { olive::core::SampleBuffer buffer( - MakeParams(olive::core::kChannelLayoutMono), size_t(kSampleRate * 2)); + make_params(olive::core::k_channel_layout_mono), size_t(k_sample_rate * 2)); float *data = buffer.data(0); - for (size_t i = 0; i < size_t(kSampleRate); i++) { + for (size_t i = 0; i < size_t(k_sample_rate); i++) { data[i] = first_value; } - for (size_t i = size_t(kSampleRate); i < buffer.sample_count(); i++) { + for (size_t i = size_t(k_sample_rate); i < buffer.sample_count(); i++) { data[i] = second_value; } return buffer; } -olive::core::SampleBuffer MakeMonoConstant(size_t sample_count, float value) +olive::core::SampleBuffer make_mono_constant(size_t sample_count, float value) { - return MakeConstantBuffer(MakeParams(olive::core::kChannelLayoutMono), + return make_constant_buffer(make_params(olive::core::k_channel_layout_mono), sample_count, value); } -void ExpectSummary(const olive::AudioVisualWaveform::Sample &summary, +void expect_summary(const olive::AudioVisualWaveform::Sample &summary, size_t channel, float expected_min, float expected_max) { ASSERT_LT(channel, summary.size()); @@ -84,16 +84,16 @@ void ExpectSummary(const olive::AudioVisualWaveform::Sample &summary, // filter graph still holds, returning the accumulated per-plane output. // Draining after a flush ends at EOF, which AudioProcessor reports as a // negative return value, so the final Convert result is intentionally unused. -olive::AudioProcessor::Buffer ConvertAndDrain(olive::AudioProcessor &processor, +olive::AudioProcessor::Buffer convert_and_drain(olive::AudioProcessor &processor, float **input, int nb_samples) { olive::AudioProcessor::Buffer output; - EXPECT_GE(processor.Convert(input, nb_samples, &output), 0); + EXPECT_GE(processor.convert(input, nb_samples, &output), 0); - processor.Flush(); + processor.flush(); olive::AudioProcessor::Buffer rest; - processor.Convert(nullptr, 0, &rest); + processor.convert(nullptr, 0, &rest); if (output.size() < rest.size()) { output.resize(rest.size()); @@ -115,14 +115,14 @@ TEST(AudioVisualWaveform, OverwriteSamplesWithZeroChannelsIsIgnored) olive::AudioVisualWaveform waveform; // channel count defaults to zero olive::core::SampleBuffer buffer( - MakeParams(olive::core::kChannelLayoutStereo), size_t(100)); - waveform.OverwriteSamples(buffer, kSampleRate, olive::core::rational(0)); + make_params(olive::core::k_channel_layout_stereo), size_t(100)); + waveform.overwrite_samples(buffer, k_sample_rate, olive::core::Rational(0)); // Nothing is written and no length is recorded - EXPECT_EQ(waveform.length(), olive::core::rational(0)); + EXPECT_EQ(waveform.length(), olive::core::Rational(0)); EXPECT_TRUE(waveform - .GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)) + .get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)) .empty()); } @@ -131,17 +131,17 @@ TEST(AudioVisualWaveform, OverwriteSamplesAtNonZeroStartSetsLength) olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.75f), - kSampleRate, olive::core::rational(2)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.75f), + k_sample_rate, olive::core::Rational(2)); // length() tracks the absolute end time of the written data - EXPECT_EQ(waveform.length(), olive::core::rational(3)); + EXPECT_EQ(waveform.length(), olive::core::Rational(3)); const olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(2), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(2), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.75f, 0.75f); + expect_summary(summary, 0, 0.75f, 0.75f); } TEST(AudioVisualWaveform, OverwriteSamplesReplacesPreviousData) @@ -149,19 +149,19 @@ TEST(AudioVisualWaveform, OverwriteSamplesReplacesPreviousData) olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.8f), - kSampleRate, olive::core::rational(0)); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.2f), - kSampleRate, olive::core::rational(0)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.8f), + k_sample_rate, olive::core::Rational(0)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.2f), + k_sample_rate, olive::core::Rational(0)); // Overwriting must replace, not mix or extend - EXPECT_EQ(waveform.length(), olive::core::rational(1)); + EXPECT_EQ(waveform.length(), olive::core::Rational(1)); const olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.2f, 0.2f); + expect_summary(summary, 0, 0.2f, 0.2f); } TEST(AudioVisualWaveform, OverwriteSamplesAfterGapLeavesSilence) @@ -169,29 +169,29 @@ TEST(AudioVisualWaveform, OverwriteSamplesAfterGapLeavesSilence) olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.25f), - kSampleRate, olive::core::rational(0)); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.75f), - kSampleRate, olive::core::rational(2)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.25f), + k_sample_rate, olive::core::Rational(0)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.75f), + k_sample_rate, olive::core::Rational(2)); - EXPECT_EQ(waveform.length(), olive::core::rational(3)); + EXPECT_EQ(waveform.length(), olive::core::Rational(3)); olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.25f, 0.25f); + expect_summary(summary, 0, 0.25f, 0.25f); // The unwritten gap between the two writes reads back as zeros - summary = waveform.GetSummaryFromTime(olive::core::rational(1), - olive::core::rational(1)); + summary = waveform.get_summary_from_time(olive::core::Rational(1), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.0f, 0.0f); + expect_summary(summary, 0, 0.0f, 0.0f); - summary = waveform.GetSummaryFromTime(olive::core::rational(2), - olive::core::rational(1)); + summary = waveform.get_summary_from_time(olive::core::Rational(2), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.75f, 0.75f); + expect_summary(summary, 0, 0.75f, 0.75f); } TEST(AudioVisualWaveform, OverwriteSamplesBeforeExistingDataPrependsZeros) @@ -199,35 +199,35 @@ TEST(AudioVisualWaveform, OverwriteSamplesBeforeExistingDataPrependsZeros) olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.75f), - kSampleRate, olive::core::rational(2)); - ASSERT_EQ(waveform.length(), olive::core::rational(3)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.75f), + k_sample_rate, olive::core::Rational(2)); + ASSERT_EQ(waveform.length(), olive::core::Rational(3)); // Writing before the current virtual start pushes the existing data back - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.25f), - kSampleRate, olive::core::rational(0)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.25f), + k_sample_rate, olive::core::Rational(0)); olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.25f, 0.25f); + expect_summary(summary, 0, 0.25f, 0.25f); // Two seconds (one written, one gap) were prepended - summary = waveform.GetSummaryFromTime(olive::core::rational(1), - olive::core::rational(1)); + summary = waveform.get_summary_from_time(olive::core::Rational(1), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.0f, 0.0f); + expect_summary(summary, 0, 0.0f, 0.0f); // The original data is still intact at its absolute position - summary = waveform.GetSummaryFromTime(olive::core::rational(2), - olive::core::rational(1)); + summary = waveform.get_summary_from_time(olive::core::Rational(2), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.75f, 0.75f); + expect_summary(summary, 0, 0.75f, 0.75f); // The data now spans [0, 3): prepending via a negative TrimIn keeps the // absolute end time tracked by length() - EXPECT_EQ(waveform.length(), olive::core::rational(3)); + EXPECT_EQ(waveform.length(), olive::core::Rational(3)); } // --------------------------------------------------------------------------- @@ -240,22 +240,22 @@ TEST(AudioVisualWaveform, GetSummaryFromTimeReturnsExactMinMaxPerChannel) waveform.set_channel_count(2); olive::core::SampleBuffer buffer( - MakeParams(olive::core::kChannelLayoutStereo), size_t(kSampleRate)); + make_params(olive::core::k_channel_layout_stereo), size_t(k_sample_rate)); float *left = buffer.data(0); float *right = buffer.data(1); for (size_t i = 0; i < buffer.sample_count(); i++) { left[i] = 0.5f; right[i] = -0.25f; } - waveform.OverwriteSamples(buffer, kSampleRate, olive::core::rational(0)); + waveform.overwrite_samples(buffer, k_sample_rate, olive::core::Rational(0)); const olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 2); - ExpectSummary(summary, 0, 0.5f, 0.5f); - ExpectSummary(summary, 1, -0.25f, -0.25f); + expect_summary(summary, 0, 0.5f, 0.5f); + expect_summary(summary, 1, -0.25f, -0.25f); } TEST(AudioVisualWaveform, GetSummaryFromTimeResolvesDistinctRanges) @@ -264,26 +264,26 @@ TEST(AudioVisualWaveform, GetSummaryFromTimeResolvesDistinctRanges) waveform.set_channel_count(1); // One second of 0.25 followed by one second of 0.75 - waveform.OverwriteSamples(MakeSplitMonoBuffer(0.25f, 0.75f), kSampleRate, - olive::core::rational(0)); - ASSERT_EQ(waveform.length(), olive::core::rational(2)); + waveform.overwrite_samples(make_split_mono_buffer(0.25f, 0.75f), k_sample_rate, + olive::core::Rational(0)); + ASSERT_EQ(waveform.length(), olive::core::Rational(2)); olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.25f, 0.25f); + expect_summary(summary, 0, 0.25f, 0.25f); - summary = waveform.GetSummaryFromTime(olive::core::rational(1), - olive::core::rational(1)); + summary = waveform.get_summary_from_time(olive::core::Rational(1), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.75f, 0.75f); + expect_summary(summary, 0, 0.75f, 0.75f); // A range covering both seconds merges their extremes - summary = waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(2)); + summary = waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(2)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.25f, 0.75f); + expect_summary(summary, 0, 0.25f, 0.75f); } TEST(AudioVisualWaveform, GetSummaryFromTimeHandlesSurroundChannels) @@ -292,23 +292,23 @@ TEST(AudioVisualWaveform, GetSummaryFromTimeHandlesSurroundChannels) waveform.set_channel_count(6); olive::core::SampleBuffer buffer( - MakeParams(olive::core::kChannelLayout5Point1), size_t(kSampleRate)); + make_params(olive::core::k_channel_layout5_point1), size_t(k_sample_rate)); for (int ch = 0; ch < buffer.channel_count(); ch++) { float *data = buffer.data(ch); for (size_t i = 0; i < buffer.sample_count(); i++) { data[i] = 0.1f * float(ch + 1); } } - waveform.OverwriteSamples(buffer, kSampleRate, olive::core::rational(0)); + waveform.overwrite_samples(buffer, k_sample_rate, olive::core::Rational(0)); const olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 6); for (size_t ch = 0; ch < 6; ch++) { const float expected = 0.1f * float(ch + 1); - ExpectSummary(summary, ch, expected, expected); + expect_summary(summary, ch, expected, expected); } } @@ -318,13 +318,13 @@ TEST(AudioVisualWaveform, GetSummaryFromTimeOnEmptyWaveformReturnsNullSamples) waveform.set_channel_count(2); const olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); // No data written: one zeroed entry per channel ASSERT_EQ(summary.size(), 2); - ExpectSummary(summary, 0, 0.0f, 0.0f); - ExpectSummary(summary, 1, 0.0f, 0.0f); + expect_summary(summary, 0, 0.0f, 0.0f); + expect_summary(summary, 1, 0.0f, 0.0f); } TEST(AudioVisualWaveform, @@ -332,17 +332,17 @@ TEST(AudioVisualWaveform, { olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.5f), - kSampleRate, olive::core::rational(0)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.5f), + k_sample_rate, olive::core::Rational(0)); // Shorter than a single frame even at the highest mipmap rate (1024 Hz), // so the request quantizes down to zero frames const olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1, 100000)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1, 100000)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.0f, 0.0f); + expect_summary(summary, 0, 0.0f, 0.0f); } // --------------------------------------------------------------------------- @@ -353,120 +353,120 @@ TEST(AudioVisualWaveform, OverwriteSumsCopiesEntireWaveform) { olive::AudioVisualWaveform source; source.set_channel_count(1); - source.OverwriteSamples(MakeSplitMonoBuffer(0.25f, 0.75f), kSampleRate, - olive::core::rational(0)); + source.overwrite_samples(make_split_mono_buffer(0.25f, 0.75f), k_sample_rate, + olive::core::Rational(0)); olive::AudioVisualWaveform dest; dest.set_channel_count(1); - dest.OverwriteSums(source, olive::core::rational(0)); + dest.overwrite_sums(source, olive::core::Rational(0)); - EXPECT_EQ(dest.length(), olive::core::rational(2)); + EXPECT_EQ(dest.length(), olive::core::Rational(2)); olive::AudioVisualWaveform::Sample summary = - dest.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + dest.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.25f, 0.25f); + expect_summary(summary, 0, 0.25f, 0.25f); - summary = dest.GetSummaryFromTime(olive::core::rational(1), - olive::core::rational(1)); + summary = dest.get_summary_from_time(olive::core::Rational(1), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.75f, 0.75f); + expect_summary(summary, 0, 0.75f, 0.75f); } TEST(AudioVisualWaveform, OverwriteSumsAtDestinationOffset) { olive::AudioVisualWaveform source; source.set_channel_count(1); - source.OverwriteSamples(MakeSplitMonoBuffer(0.25f, 0.75f), kSampleRate, - olive::core::rational(0)); + source.overwrite_samples(make_split_mono_buffer(0.25f, 0.75f), k_sample_rate, + olive::core::Rational(0)); olive::AudioVisualWaveform dest; dest.set_channel_count(1); - dest.OverwriteSums(source, olive::core::rational(1)); + dest.overwrite_sums(source, olive::core::Rational(1)); - EXPECT_EQ(dest.length(), olive::core::rational(3)); + EXPECT_EQ(dest.length(), olive::core::Rational(3)); // The copied data lands one second later; because the destination's // virtual start moved to the destination offset, only [1, 3) can be // queried safely olive::AudioVisualWaveform::Sample summary = - dest.GetSummaryFromTime(olive::core::rational(1), - olive::core::rational(1)); + dest.get_summary_from_time(olive::core::Rational(1), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.25f, 0.25f); + expect_summary(summary, 0, 0.25f, 0.25f); - summary = dest.GetSummaryFromTime(olive::core::rational(2), - olive::core::rational(1)); + summary = dest.get_summary_from_time(olive::core::Rational(2), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.75f, 0.75f); + expect_summary(summary, 0, 0.75f, 0.75f); } TEST(AudioVisualWaveform, OverwriteSumsWithSourceOffset) { olive::AudioVisualWaveform source; source.set_channel_count(1); - source.OverwriteSamples(MakeSplitMonoBuffer(0.25f, 0.75f), kSampleRate, - olive::core::rational(0)); + source.overwrite_samples(make_split_mono_buffer(0.25f, 0.75f), k_sample_rate, + olive::core::Rational(0)); olive::AudioVisualWaveform dest; dest.set_channel_count(1); - dest.OverwriteSums(source, olive::core::rational(0), - olive::core::rational(1)); + dest.overwrite_sums(source, olive::core::Rational(0), + olive::core::Rational(1)); // Only the source's second second is copied - EXPECT_EQ(dest.length(), olive::core::rational(1)); + EXPECT_EQ(dest.length(), olive::core::Rational(1)); const olive::AudioVisualWaveform::Sample summary = - dest.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + dest.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.75f, 0.75f); + expect_summary(summary, 0, 0.75f, 0.75f); } TEST(AudioVisualWaveform, OverwriteSumsWithLengthLimit) { olive::AudioVisualWaveform source; source.set_channel_count(1); - source.OverwriteSamples(MakeSplitMonoBuffer(0.25f, 0.75f), kSampleRate, - olive::core::rational(0)); + source.overwrite_samples(make_split_mono_buffer(0.25f, 0.75f), k_sample_rate, + olive::core::Rational(0)); olive::AudioVisualWaveform dest; dest.set_channel_count(1); - dest.OverwriteSums(source, olive::core::rational(0), - olive::core::rational(0), olive::core::rational(1)); + dest.overwrite_sums(source, olive::core::Rational(0), + olive::core::Rational(0), olive::core::Rational(1)); // Only the source's first second is copied - EXPECT_EQ(dest.length(), olive::core::rational(1)); + EXPECT_EQ(dest.length(), olive::core::Rational(1)); const olive::AudioVisualWaveform::Sample summary = - dest.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + dest.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.25f, 0.25f); + expect_summary(summary, 0, 0.25f, 0.25f); } TEST(AudioVisualWaveform, OverwriteSumsWithOffsetBeyondSourceIsIgnored) { olive::AudioVisualWaveform source; source.set_channel_count(1); - source.OverwriteSamples(MakeSplitMonoBuffer(0.25f, 0.75f), kSampleRate, - olive::core::rational(0)); + source.overwrite_samples(make_split_mono_buffer(0.25f, 0.75f), k_sample_rate, + olive::core::Rational(0)); olive::AudioVisualWaveform dest; dest.set_channel_count(1); - dest.OverwriteSums(source, olive::core::rational(0), - olive::core::rational(10)); + dest.overwrite_sums(source, olive::core::Rational(0), + olive::core::Rational(10)); // The offset starts past the end of every source mipmap, so nothing is // copied and the destination stays empty - EXPECT_EQ(dest.length(), olive::core::rational(0)); + EXPECT_EQ(dest.length(), olive::core::Rational(0)); const olive::AudioVisualWaveform::Sample summary = - dest.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + dest.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.0f, 0.0f); + expect_summary(summary, 0, 0.0f, 0.0f); } // --------------------------------------------------------------------------- @@ -478,54 +478,54 @@ TEST(AudioVisualWaveform, OverwriteSilenceZeroesRange) olive::AudioVisualWaveform waveform; waveform.set_channel_count(2); - waveform.OverwriteSamples( - MakeConstantBuffer(MakeParams(olive::core::kChannelLayoutStereo), - size_t(kSampleRate * 2), 0.8f), - kSampleRate, olive::core::rational(0)); + waveform.overwrite_samples( + make_constant_buffer(make_params(olive::core::k_channel_layout_stereo), + size_t(k_sample_rate * 2), 0.8f), + k_sample_rate, olive::core::Rational(0)); // Silence [0.5, 1.5) - waveform.OverwriteSilence(olive::core::rational(1, 2), - olive::core::rational(1)); + waveform.overwrite_silence(olive::core::Rational(1, 2), + olive::core::Rational(1)); olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1, 2)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1, 2)); ASSERT_EQ(summary.size(), 2); - ExpectSummary(summary, 0, 0.8f, 0.8f); - ExpectSummary(summary, 1, 0.8f, 0.8f); + expect_summary(summary, 0, 0.8f, 0.8f); + expect_summary(summary, 1, 0.8f, 0.8f); - summary = waveform.GetSummaryFromTime(olive::core::rational(1, 2), - olive::core::rational(1, 2)); + summary = waveform.get_summary_from_time(olive::core::Rational(1, 2), + olive::core::Rational(1, 2)); ASSERT_EQ(summary.size(), 2); - ExpectSummary(summary, 0, 0.0f, 0.0f); - ExpectSummary(summary, 1, 0.0f, 0.0f); + expect_summary(summary, 0, 0.0f, 0.0f); + expect_summary(summary, 1, 0.0f, 0.0f); - summary = waveform.GetSummaryFromTime(olive::core::rational(3, 2), - olive::core::rational(1, 2)); + summary = waveform.get_summary_from_time(olive::core::Rational(3, 2), + olive::core::Rational(1, 2)); ASSERT_EQ(summary.size(), 2); - ExpectSummary(summary, 0, 0.8f, 0.8f); - ExpectSummary(summary, 1, 0.8f, 0.8f); + expect_summary(summary, 0, 0.8f, 0.8f); + expect_summary(summary, 1, 0.8f, 0.8f); } TEST(AudioVisualWaveform, OverwriteSilenceExtendsLength) { olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.5f), - kSampleRate, olive::core::rational(0)); - ASSERT_EQ(waveform.length(), olive::core::rational(1)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.5f), + k_sample_rate, olive::core::Rational(0)); + ASSERT_EQ(waveform.length(), olive::core::Rational(1)); // Silencing past the end grows the buffer with zeros - waveform.OverwriteSilence(olive::core::rational(2), - olive::core::rational(1)); + waveform.overwrite_silence(olive::core::Rational(2), + olive::core::Rational(1)); - EXPECT_EQ(waveform.length(), olive::core::rational(3)); + EXPECT_EQ(waveform.length(), olive::core::Rational(3)); const olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(2), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(2), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.0f, 0.0f); + expect_summary(summary, 0, 0.0f, 0.0f); } // --------------------------------------------------------------------------- @@ -536,65 +536,65 @@ TEST(AudioVisualWaveform, MidFromOffsetReturnsTail) { olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeSplitMonoBuffer(0.25f, 0.75f), kSampleRate, - olive::core::rational(0)); + waveform.overwrite_samples(make_split_mono_buffer(0.25f, 0.75f), k_sample_rate, + olive::core::Rational(0)); const olive::AudioVisualWaveform mid = - waveform.Mid(olive::core::rational(1)); + waveform.mid(olive::core::Rational(1)); - EXPECT_EQ(mid.length(), olive::core::rational(1)); + EXPECT_EQ(mid.length(), olive::core::Rational(1)); EXPECT_EQ(mid.channel_count(), 1); // The original is untouched - EXPECT_EQ(waveform.length(), olive::core::rational(2)); + EXPECT_EQ(waveform.length(), olive::core::Rational(2)); const olive::AudioVisualWaveform::Sample summary = - mid.GetSummaryFromTime(olive::core::rational(1), - olive::core::rational(1)); + mid.get_summary_from_time(olive::core::Rational(1), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.75f, 0.75f); + expect_summary(summary, 0, 0.75f, 0.75f); } TEST(AudioVisualWaveform, ResizeExtendPadsWithZeros) { olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.5f), - kSampleRate, olive::core::rational(0)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.5f), + k_sample_rate, olive::core::Rational(0)); - waveform.Resize(olive::core::rational(3)); + waveform.resize(olive::core::Rational(3)); - EXPECT_EQ(waveform.length(), olive::core::rational(3)); + EXPECT_EQ(waveform.length(), olive::core::Rational(3)); olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.5f, 0.5f); + expect_summary(summary, 0, 0.5f, 0.5f); // The extended region is zero-filled - summary = waveform.GetSummaryFromTime(olive::core::rational(2), - olive::core::rational(1)); + summary = waveform.get_summary_from_time(olive::core::Rational(2), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.0f, 0.0f); + expect_summary(summary, 0, 0.0f, 0.0f); } TEST(AudioVisualWaveform, TrimInZeroIsNoOp) { olive::AudioVisualWaveform waveform; waveform.set_channel_count(1); - waveform.OverwriteSamples(MakeMonoConstant(size_t(kSampleRate), 0.5f), - kSampleRate, olive::core::rational(0)); + waveform.overwrite_samples(make_mono_constant(size_t(k_sample_rate), 0.5f), + k_sample_rate, olive::core::Rational(0)); - waveform.TrimIn(olive::core::rational(0)); + waveform.trim_in(olive::core::Rational(0)); - EXPECT_EQ(waveform.length(), olive::core::rational(1)); + EXPECT_EQ(waveform.length(), olive::core::Rational(1)); const olive::AudioVisualWaveform::Sample summary = - waveform.GetSummaryFromTime(olive::core::rational(0), - olive::core::rational(1)); + waveform.get_summary_from_time(olive::core::Rational(0), + olive::core::Rational(1)); ASSERT_EQ(summary.size(), 1); - ExpectSummary(summary, 0, 0.5f, 0.5f); + expect_summary(summary, 0, 0.5f, 0.5f); } // --------------------------------------------------------------------------- @@ -604,7 +604,7 @@ TEST(AudioVisualWaveform, TrimInZeroIsNoOp) TEST(AudioVisualWaveform, SumSamplesHonorsStartOffsetAndChannels) { olive::core::SampleBuffer buffer( - MakeParams(olive::core::kChannelLayoutStereo), size_t(100)); + make_params(olive::core::k_channel_layout_stereo), size_t(100)); float *left = buffer.data(0); float *right = buffer.data(1); for (size_t i = 0; i < buffer.sample_count(); i++) { @@ -614,7 +614,7 @@ TEST(AudioVisualWaveform, SumSamplesHonorsStartOffsetAndChannels) // Summarize samples [10, 30) only const olive::AudioVisualWaveform::Sample summary = - olive::AudioVisualWaveform::SumSamples(buffer, 10, 20); + olive::AudioVisualWaveform::sum_samples(buffer, 10, 20); ASSERT_EQ(summary.size(), 2); // SumSamples (unlike ReSumSamples) reports the true extremes of the range @@ -633,11 +633,11 @@ TEST(AudioVisualWaveform, ReSumSamplesMergesExtremesAcrossFrames) frames[3] = { 0.05f, 0.08f }; // channel 1 const olive::AudioVisualWaveform::Sample summary = - olive::AudioVisualWaveform::ReSumSamples(frames.data(), 4, 2); + olive::AudioVisualWaveform::re_sum_samples(frames.data(), 4, 2); ASSERT_EQ(summary.size(), 2); - ExpectSummary(summary, 0, -0.9f, 0.3f); - ExpectSummary(summary, 1, 0.0f, 0.1f); + expect_summary(summary, 0, -0.9f, 0.3f); + expect_summary(summary, 1, 0.0f, 0.1f); } TEST(AudioVisualWaveform, ReSumSamplesSingleFrameIsIdentity) @@ -647,11 +647,11 @@ TEST(AudioVisualWaveform, ReSumSamplesSingleFrameIsIdentity) frames[1] = { -0.1f, 0.2f }; const olive::AudioVisualWaveform::Sample summary = - olive::AudioVisualWaveform::ReSumSamples(frames.data(), 2, 2); + olive::AudioVisualWaveform::re_sum_samples(frames.data(), 2, 2); ASSERT_EQ(summary.size(), 2); - ExpectSummary(summary, 0, -0.3f, 0.7f); - ExpectSummary(summary, 1, -0.1f, 0.2f); + expect_summary(summary, 0, -0.3f, 0.7f); + expect_summary(summary, 1, -0.1f, 0.2f); } // --------------------------------------------------------------------------- @@ -666,7 +666,7 @@ TEST(AudioVisualWaveform, DrawSamplePaintsVerticalSpan) { QPainter painter(&image); const olive::AudioVisualWaveform::Sample sample = { { -1.0f, 1.0f } }; - olive::AudioVisualWaveform::DrawSample(&painter, sample, 1, 0, 100, + olive::AudioVisualWaveform::draw_sample(&painter, sample, 1, 0, 100, false); } @@ -682,7 +682,7 @@ TEST(AudioVisualWaveform, DrawSampleIgnoresEmptySample) { QPainter painter(&image); - olive::AudioVisualWaveform::DrawSample( + olive::AudioVisualWaveform::draw_sample( &painter, olive::AudioVisualWaveform::Sample(), 1, 0, 100, false); } @@ -697,27 +697,27 @@ TEST(AudioProcessor, ConvertPassthroughCopiesInputSamples) { olive::AudioProcessor processor; const olive::core::AudioParams params = - MakeParams(olive::core::kChannelLayoutStereo); - ASSERT_TRUE(processor.Open(params, params, 1.0)); + make_params(olive::core::k_channel_layout_stereo); + ASSERT_TRUE(processor.open(params, params, 1.0)); - constexpr int kSamples = 1024; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, -0.25f); + constexpr int k_samples = 1024; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, -0.25f); float *input[2] = { left.data(), right.data() }; olive::AudioProcessor::Buffer output; - EXPECT_EQ(processor.Convert(input, kSamples, &output), 0); + EXPECT_EQ(processor.convert(input, k_samples, &output), 0); // Planar output keeps one byte plane per channel ASSERT_EQ(output.size(), 2); - ASSERT_EQ(output.at(0).size(), kSamples * int(sizeof(float))); - ASSERT_EQ(output.at(1).size(), kSamples * int(sizeof(float))); + ASSERT_EQ(output.at(0).size(), k_samples * int(sizeof(float))); + ASSERT_EQ(output.at(1).size(), k_samples * int(sizeof(float))); float value = 0.0f; std::memcpy(&value, output.at(0).constData(), sizeof(float)); EXPECT_FLOAT_EQ(value, 0.5f); std::memcpy(&value, - output.at(0).constData() + (kSamples - 1) * sizeof(float), + output.at(0).constData() + (k_samples - 1) * sizeof(float), sizeof(float)); EXPECT_FLOAT_EQ(value, 0.5f); std::memcpy(&value, output.at(1).constData(), sizeof(float)); @@ -728,23 +728,23 @@ TEST(AudioProcessor, ConvertToPackedInterleavesChannels) { olive::AudioProcessor processor; const olive::core::AudioParams from = - MakeParams(olive::core::kChannelLayoutStereo); - const olive::core::AudioParams to(kSampleRate, - olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32); - ASSERT_TRUE(processor.Open(from, to, 1.0)); + make_params(olive::core::k_channel_layout_stereo); + const olive::core::AudioParams to(k_sample_rate, + olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32); + ASSERT_TRUE(processor.open(from, to, 1.0)); - constexpr int kSamples = 1024; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, -0.25f); + constexpr int k_samples = 1024; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, -0.25f); float *input[2] = { left.data(), right.data() }; olive::AudioProcessor::Buffer output; - EXPECT_EQ(processor.Convert(input, kSamples, &output), 0); + EXPECT_EQ(processor.convert(input, k_samples, &output), 0); // Packed output folds both channels into a single interleaved plane ASSERT_EQ(output.size(), 1); - ASSERT_EQ(output.at(0).size(), kSamples * 2 * int(sizeof(float))); + ASSERT_EQ(output.at(0).size(), k_samples * 2 * int(sizeof(float))); float left_value = 0.0f; float right_value = 0.0f; @@ -758,20 +758,20 @@ TEST(AudioProcessor, ConvertToPackedInterleavesChannels) TEST(AudioProcessor, ConvertDownmixToMonoReducesPlaneCount) { olive::AudioProcessor processor; - ASSERT_TRUE(processor.Open(MakeParams(olive::core::kChannelLayoutStereo), - MakeParams(olive::core::kChannelLayoutMono), + ASSERT_TRUE(processor.open(make_params(olive::core::k_channel_layout_stereo), + make_params(olive::core::k_channel_layout_mono), 1.0)); - constexpr int kSamples = 1024; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, 0.5f); + constexpr int k_samples = 1024; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, 0.5f); float *input[2] = { left.data(), right.data() }; olive::AudioProcessor::Buffer output; - EXPECT_EQ(processor.Convert(input, kSamples, &output), 0); + EXPECT_EQ(processor.convert(input, k_samples, &output), 0); ASSERT_EQ(output.size(), 1); - ASSERT_EQ(output.at(0).size(), kSamples * int(sizeof(float))); + ASSERT_EQ(output.at(0).size(), k_samples * int(sizeof(float))); // The downmix of two identical channels must stay audible regardless of // the exact mixing coefficients @@ -785,20 +785,20 @@ TEST(AudioProcessor, ConvertResampleDrainProducesExpectedSampleCount) { olive::AudioProcessor processor; const olive::core::AudioParams from = - MakeParams(olive::core::kChannelLayoutStereo); - const olive::core::AudioParams to(kSampleRate / 2, - olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); - ASSERT_TRUE(processor.Open(from, to, 1.0)); + make_params(olive::core::k_channel_layout_stereo); + const olive::core::AudioParams to(k_sample_rate / 2, + olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); + ASSERT_TRUE(processor.open(from, to, 1.0)); // One second of input - constexpr int kSamples = 48000; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, 0.5f); + constexpr int k_samples = 48000; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, 0.5f); float *input[2] = { left.data(), right.data() }; const olive::AudioProcessor::Buffer output = - ConvertAndDrain(processor, input, kSamples); + convert_and_drain(processor, input, k_samples); ASSERT_EQ(output.size(), 2); EXPECT_EQ(output.at(0).size(), output.at(1).size()); @@ -814,17 +814,17 @@ TEST(AudioProcessor, ConvertTempoDrainReducesSampleCount) { olive::AudioProcessor processor; const olive::core::AudioParams params = - MakeParams(olive::core::kChannelLayoutStereo); - ASSERT_TRUE(processor.Open(params, params, 2.0)); + make_params(olive::core::k_channel_layout_stereo); + ASSERT_TRUE(processor.open(params, params, 2.0)); // One second of input - constexpr int kSamples = 48000; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, 0.5f); + constexpr int k_samples = 48000; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, 0.5f); float *input[2] = { left.data(), right.data() }; const olive::AudioProcessor::Buffer output = - ConvertAndDrain(processor, input, kSamples); + convert_and_drain(processor, input, k_samples); ASSERT_EQ(output.size(), 2); @@ -839,27 +839,27 @@ TEST(AudioProcessor, ConvertWithNullOutputOnlyPushes) { olive::AudioProcessor processor; const olive::core::AudioParams params = - MakeParams(olive::core::kChannelLayoutStereo); - ASSERT_TRUE(processor.Open(params, params, 1.0)); + make_params(olive::core::k_channel_layout_stereo); + ASSERT_TRUE(processor.open(params, params, 1.0)); - constexpr int kSamples = 1024; - std::vector left(kSamples, 0.5f); - std::vector right(kSamples, 0.5f); + constexpr int k_samples = 1024; + std::vector left(k_samples, 0.5f); + std::vector right(k_samples, 0.5f); float *input[2] = { left.data(), right.data() }; // A null output buffer means push-only and is not an error - EXPECT_EQ(processor.Convert(input, kSamples, nullptr), 0); + EXPECT_EQ(processor.convert(input, k_samples, nullptr), 0); } TEST(AudioProcessor, ConvertWithNoInputReturnsZeroWithEmptyPlanes) { olive::AudioProcessor processor; const olive::core::AudioParams params = - MakeParams(olive::core::kChannelLayoutStereo); - ASSERT_TRUE(processor.Open(params, params, 1.0)); + make_params(olive::core::k_channel_layout_stereo); + ASSERT_TRUE(processor.open(params, params, 1.0)); olive::AudioProcessor::Buffer output; - EXPECT_EQ(processor.Convert(nullptr, 0, &output), 0); + EXPECT_EQ(processor.convert(nullptr, 0, &output), 0); // The output is still sized to the planar channel count, but empty ASSERT_EQ(output.size(), 2); @@ -873,12 +873,12 @@ TEST(AudioProcessor, OpenFixesZeroChannelLayout) // A zero layout mask is unusable by the filter graph and must be replaced // with a default layout derived from the channel count - const olive::core::AudioParams from(kSampleRate, 0, - olive::core::SampleFormat::F32P); + const olive::core::AudioParams from(k_sample_rate, 0, + olive::core::SampleFormat::f32_p); const olive::core::AudioParams to = - MakeParams(olive::core::kChannelLayoutStereo); + make_params(olive::core::k_channel_layout_stereo); - ASSERT_TRUE(processor.Open(from, to, 1.0)); + ASSERT_TRUE(processor.open(from, to, 1.0)); EXPECT_NE(processor.from().channel_layout(), uint64_t(0)); EXPECT_EQ(processor.from().channel_count(), 2); } @@ -887,19 +887,19 @@ TEST(AudioProcessor, CloseIsIdempotentAndReopenSucceeds) { olive::AudioProcessor processor; const olive::core::AudioParams params = - MakeParams(olive::core::kChannelLayoutStereo); + make_params(olive::core::k_channel_layout_stereo); // Closing an unopened processor must be safe - processor.Close(); - EXPECT_FALSE(processor.IsOpen()); + processor.close(); + EXPECT_FALSE(processor.is_open()); - ASSERT_TRUE(processor.Open(params, params, 1.0)); - processor.Close(); - processor.Close(); - EXPECT_FALSE(processor.IsOpen()); + ASSERT_TRUE(processor.open(params, params, 1.0)); + processor.close(); + processor.close(); + EXPECT_FALSE(processor.is_open()); - EXPECT_TRUE(processor.Open(params, params, 1.0)); - EXPECT_TRUE(processor.IsOpen()); + EXPECT_TRUE(processor.open(params, params, 1.0)); + EXPECT_TRUE(processor.is_open()); } TEST(AudioProcessor, FlushWithoutOpenDoesNotCrash) @@ -907,6 +907,6 @@ TEST(AudioProcessor, FlushWithoutOpenDoesNotCrash) olive::AudioProcessor processor; // Logs an error but must not crash - processor.Flush(); - EXPECT_FALSE(processor.IsOpen()); + processor.flush(); + EXPECT_FALSE(processor.is_open()); } diff --git a/tests/gtest/cli_test.cpp b/tests/gtest/cli_test.cpp index 07165dae6..0a6c46ff3 100644 --- a/tests/gtest/cli_test.cpp +++ b/tests/gtest/cli_test.cpp @@ -12,14 +12,14 @@ public: explicit DummyTask(bool succeed) : succeed_(succeed) { - SetTitle(QStringLiteral("Dummy")); + set_title(QStringLiteral("Dummy")); } protected: - virtual bool Run() override + virtual bool run() override { - emit ProgressChanged(0.5); - emit ProgressChanged(1.0); + emit progress_changed(0.5); + emit progress_changed(1.0); return succeed_; } @@ -47,7 +47,7 @@ TEST(CLIProgress, SameProgressValueDoesNotRedraw) olive::CLIProgressDialog dlg(QStringLiteral("Job")); testing::internal::CaptureStdout(); - dlg.SetProgress(0.0); + dlg.set_progress(0.0); const QString out = QString::fromStdString(testing::internal::GetCapturedStdout()); @@ -59,7 +59,7 @@ TEST(CLIProgress, ProgressRendersPercentage) olive::CLIProgressDialog dlg(QStringLiteral("Job")); testing::internal::CaptureStdout(); - dlg.SetProgress(0.25); + dlg.set_progress(0.25); const QString out = QString::fromStdString(testing::internal::GetCapturedStdout()); @@ -86,7 +86,7 @@ TEST(CLIProgress, BarFillMatchesProgress) olive::CLIProgressDialog dlg(QStringLiteral("Job")); testing::internal::CaptureStdout(); - dlg.SetProgress(1.0); + dlg.set_progress(1.0); const QString out = QString::fromStdString(testing::internal::GetCapturedStdout()); @@ -100,7 +100,7 @@ TEST(CLIProgress, PercentageIsPaddedToThreeColumns) auto pct_field = [&](double p) { testing::internal::CaptureStdout(); - dlg.SetProgress(p); + dlg.set_progress(p); const QString out = QString::fromStdString(testing::internal::GetCapturedStdout()); const int bracket = out.indexOf(QLatin1Char(']')); @@ -124,7 +124,7 @@ TEST(CLITask, RunReturnsTaskResult) olive::CLITaskDialog dlg(&task); testing::internal::CaptureStdout(); - const bool ok = dlg.Run(); + const bool ok = dlg.run(); testing::internal::GetCapturedStdout(); EXPECT_TRUE(ok); @@ -135,7 +135,7 @@ TEST(CLITask, RunReturnsTaskResult) olive::CLITaskDialog dlg(&task); testing::internal::CaptureStdout(); - const bool ok = dlg.Run(); + const bool ok = dlg.run(); testing::internal::GetCapturedStdout(); EXPECT_FALSE(ok); @@ -148,7 +148,7 @@ TEST(CLITask, TaskProgressIsForwardedToDisplay) olive::CLITaskDialog dlg(&task); testing::internal::CaptureStdout(); - dlg.Run(); + dlg.run(); const QString out = QString::fromStdString(testing::internal::GetCapturedStdout()); diff --git a/tests/gtest/clip_traverser_test.cpp b/tests/gtest/clip_traverser_test.cpp index 69eb4c88e..cebdf7364 100644 --- a/tests/gtest/clip_traverser_test.cpp +++ b/tests/gtest/clip_traverser_test.cpp @@ -32,7 +32,7 @@ public: NODE_DEFAULT_FUNCTIONS(LoopModeProbeNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Loop Mode Probe"); } @@ -42,19 +42,19 @@ public: return QStringLiteral("org.oak.test.loopmodeprobe"); } - virtual QVector Category() const override + virtual QVector category() const override { return {}; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { Q_UNUSED(value) last_loop_mode_ = globals.loop_mode(); - table->Push(olive::NodeValue::kFloat, 0.0, this); + table->push(olive::NodeValue::k_float, 0.0, this); } olive::LoopMode last_loop_mode() const @@ -63,7 +63,7 @@ public: } private: - mutable olive::LoopMode last_loop_mode_ = olive::LoopMode::kLoopModeOff; + mutable olive::LoopMode last_loop_mode_ = olive::LoopMode::k_loop_mode_off; }; // Node with two connectable inputs and a configurable gizmo transformation, @@ -72,13 +72,13 @@ class GizmoProbeNode : public olive::Node { public: GizmoProbeNode() { - AddInput(QStringLiteral("a_in"), olive::NodeValue::kFloat, 0.0); - AddInput(QStringLiteral("b_in"), olive::NodeValue::kFloat, 0.0); + add_input(QStringLiteral("a_in"), olive::NodeValue::k_float, 0.0); + add_input(QStringLiteral("b_in"), olive::NodeValue::k_float, 0.0); } NODE_DEFAULT_FUNCTIONS(GizmoProbeNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Gizmo Probe"); } @@ -88,18 +88,18 @@ public: return QStringLiteral("org.oak.test.gizmoprobe"); } - virtual QVector Category() const override + virtual QVector category() const override { return {}; } - void SetGizmoTransform(const QTransform &t) + void set_gizmo_transform(const QTransform &t) { t_ = t; } virtual QTransform - GizmoTransformation(const olive::NodeValueRow &row, + gizmo_transformation(const olive::NodeValueRow &row, const olive::NodeGlobals &globals) const override { Q_UNUSED(row) @@ -108,22 +108,22 @@ public: return t_; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { Q_UNUSED(value) Q_UNUSED(globals) - table->Push(olive::NodeValue::kFloat, 0.0, this); + table->push(olive::NodeValue::k_float, 0.0, this); } - static QString InputA() + static QString input_a() { return QStringLiteral("a_in"); } - static QString InputB() + static QString input_b() { return QStringLiteral("b_in"); } @@ -132,8 +132,8 @@ private: QTransform t_; }; -olive::ClipBlock *CreateClip(olive::Project *project, - const olive::core::rational &length) +olive::ClipBlock *create_clip(olive::Project *project, + const olive::core::Rational &length) { auto *clip = new olive::ClipBlock(); clip->setParent(project); @@ -141,7 +141,7 @@ olive::ClipBlock *CreateClip(olive::Project *project, return clip; } -olive::SolidGenerator *CreateSolid(olive::Project *project) +olive::SolidGenerator *create_solid(olive::Project *project) { auto *solid = new olive::SolidGenerator(); solid->setParent(project); @@ -151,23 +151,23 @@ olive::SolidGenerator *CreateSolid(olive::Project *project) // Generates the clip's output table at a single time with a fresh traverser // (the traverser caches tables per node+range, so reusing one would return // stale values after the clip's parameters change). -olive::NodeValueTable GenerateClipTable(const olive::ClipBlock *clip, - const olive::core::rational &time) +olive::NodeValueTable generate_clip_table(const olive::ClipBlock *clip, + const olive::core::Rational &time) { olive::NodeTraverser traverser; - return traverser.GenerateTable( - clip, olive::TimeRange(time, time + olive::core::rational(1, 30))); + return traverser.generate_table( + clip, olive::TimeRange(time, time + olive::core::Rational(1, 30))); } -double GenerateClipTimeValue(const olive::ClipBlock *clip, - const olive::core::rational &time) +double generate_clip_time_value(const olive::ClipBlock *clip, + const olive::core::Rational &time) { - olive::NodeValueTable table = GenerateClipTable(clip, time); - olive::NodeValue v = table.Get(olive::NodeValue::kFloat); - if (v.type() != olive::NodeValue::kFloat) { + olive::NodeValueTable table = generate_clip_table(clip, time); + olive::NodeValue v = table.get(olive::NodeValue::k_float); + if (v.type() != olive::NodeValue::k_float) { return std::numeric_limits::quiet_NaN(); } - return v.toDouble(); + return v.to_double(); } } // namespace @@ -178,33 +178,33 @@ TEST(ClipBlock, DefaultState) EXPECT_DOUBLE_EQ(clip.speed(), 1.0); EXPECT_FALSE(clip.reverse()); - EXPECT_EQ(clip.loop_mode(), olive::LoopMode::kLoopModeOff); - EXPECT_EQ(clip.media_in(), olive::core::rational(0)); + EXPECT_EQ(clip.loop_mode(), olive::LoopMode::k_loop_mode_off); + EXPECT_EQ(clip.media_in(), olive::core::Rational(0)); EXPECT_FALSE(clip.maintain_audio_pitch()); - EXPECT_FALSE(clip.IsAutocaching()); + EXPECT_FALSE(clip.is_autocaching()); EXPECT_EQ(clip.in_transition(), nullptr); EXPECT_EQ(clip.out_transition(), nullptr); EXPECT_EQ(clip.connected_viewer(), nullptr); - EXPECT_EQ(clip.GetTrackType(), olive::Track::kNone); + EXPECT_EQ(clip.get_track_type(), olive::Track::k_none); EXPECT_TRUE(clip.block_links().isEmpty()); - EXPECT_EQ(clip.length(), olive::core::rational(0)); - EXPECT_EQ(clip.GetVideoCacheRange(), - olive::TimeRange(olive::core::rational(0), olive::core::rational(0))); - EXPECT_EQ(clip.GetAudioCacheRange(), - olive::TimeRange(olive::core::rational(0), olive::core::rational(0))); + EXPECT_EQ(clip.length(), olive::core::Rational(0)); + EXPECT_EQ(clip.get_video_cache_range(), + olive::TimeRange(olive::core::Rational(0), olive::core::Rational(0))); + EXPECT_EQ(clip.get_audio_cache_range(), + olive::TimeRange(olive::core::Rational(0), olive::core::Rational(0))); EXPECT_EQ(clip.id(), QStringLiteral("org.olivevideoeditor.Olive.clip")); - EXPECT_EQ(clip.Name(), QStringLiteral("Clip")); - EXPECT_FALSE(clip.Description().isEmpty()); - EXPECT_TRUE(clip.Category().contains(olive::Node::kCategoryTimeline)); + EXPECT_EQ(clip.name(), QStringLiteral("Clip")); + EXPECT_FALSE(clip.description().isEmpty()); + EXPECT_TRUE(clip.category().contains(olive::Node::k_category_timeline)); } TEST(ClipBlock, SpeedReverseLoopPitchAutocacheAccessors) { olive::ClipBlock clip; - clip.SetStandardValue(olive::ClipBlock::kSpeedInput, 2.5); + clip.set_standard_value(olive::ClipBlock::k_speed_input, 2.5); EXPECT_DOUBLE_EQ(clip.speed(), 2.5); clip.set_reverse(true); @@ -212,20 +212,20 @@ TEST(ClipBlock, SpeedReverseLoopPitchAutocacheAccessors) clip.set_reverse(false); EXPECT_FALSE(clip.reverse()); - clip.set_loop_mode(olive::LoopMode::kLoopModeLoop); - EXPECT_EQ(clip.loop_mode(), olive::LoopMode::kLoopModeLoop); - clip.set_loop_mode(olive::LoopMode::kLoopModeClamp); - EXPECT_EQ(clip.loop_mode(), olive::LoopMode::kLoopModeClamp); - clip.set_loop_mode(olive::LoopMode::kLoopModeOff); - EXPECT_EQ(clip.loop_mode(), olive::LoopMode::kLoopModeOff); + clip.set_loop_mode(olive::LoopMode::k_loop_mode_loop); + EXPECT_EQ(clip.loop_mode(), olive::LoopMode::k_loop_mode_loop); + clip.set_loop_mode(olive::LoopMode::k_loop_mode_clamp); + EXPECT_EQ(clip.loop_mode(), olive::LoopMode::k_loop_mode_clamp); + clip.set_loop_mode(olive::LoopMode::k_loop_mode_off); + EXPECT_EQ(clip.loop_mode(), olive::LoopMode::k_loop_mode_off); clip.set_maintain_audio_pitch(true); EXPECT_TRUE(clip.maintain_audio_pitch()); - clip.SetAutocache(true); - EXPECT_TRUE(clip.IsAutocaching()); - clip.SetAutocache(false); - EXPECT_FALSE(clip.IsAutocaching()); + clip.set_autocache(true); + EXPECT_TRUE(clip.is_autocaching()); + clip.set_autocache(false); + EXPECT_FALSE(clip.is_autocaching()); } TEST(ClipBlock, LoopModeChangeEmitsPreviewChanged) @@ -233,13 +233,13 @@ TEST(ClipBlock, LoopModeChangeEmitsPreviewChanged) olive::ClipBlock clip; int emissions = 0; - QObject::connect(&clip, &olive::Block::PreviewChanged, + QObject::connect(&clip, &olive::Block::preview_changed, [&emissions]() { ++emissions; }); - clip.set_loop_mode(olive::LoopMode::kLoopModeLoop); + clip.set_loop_mode(olive::LoopMode::k_loop_mode_loop); EXPECT_EQ(emissions, 1); - clip.set_loop_mode(olive::LoopMode::kLoopModeClamp); + clip.set_loop_mode(olive::LoopMode::k_loop_mode_clamp); EXPECT_EQ(emissions, 2); } @@ -247,278 +247,278 @@ TEST(ClipBlock, MediaInAccessor) { olive::ClipBlock clip; - clip.set_media_in(olive::core::rational(5)); - EXPECT_EQ(clip.media_in(), olive::core::rational(5)); - EXPECT_EQ(clip.GetStandardValue(olive::ClipBlock::kMediaInInput) - .value(), - olive::core::rational(5)); + clip.set_media_in(olive::core::Rational(5)); + EXPECT_EQ(clip.media_in(), olive::core::Rational(5)); + EXPECT_EQ(clip.get_standard_value(olive::ClipBlock::k_media_in_input) + .value(), + olive::core::Rational(5)); } TEST(ClipBlock, InputTimeAdjustmentPassesThroughByDefault) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); - const olive::TimeRange range(olive::core::rational(2), - olive::core::rational(4)); + const olive::TimeRange range(olive::core::Rational(2), + olive::core::Rational(4)); // A default clip (speed 1, no reverse, no media in) maps times unchanged - EXPECT_EQ(clip->InputTimeAdjustment(olive::ClipBlock::kBufferIn, -1, range, + EXPECT_EQ(clip->input_time_adjustment(olive::ClipBlock::k_buffer_in, -1, range, true), range); // Non-buffer inputs never adjust time - EXPECT_EQ(clip->InputTimeAdjustment(olive::ClipBlock::kSpeedInput, -1, + EXPECT_EQ(clip->input_time_adjustment(olive::ClipBlock::k_speed_input, -1, range, true), range); - EXPECT_EQ(clip->OutputTimeAdjustment(olive::ClipBlock::kSpeedInput, -1, + EXPECT_EQ(clip->output_time_adjustment(olive::ClipBlock::k_speed_input, -1, range), range); } TEST(ClipBlock, InputTimeAdjustmentAppliesSpeed) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); - EXPECT_EQ(clip->InputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4)), + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); + EXPECT_EQ(clip->input_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)), true), - olive::TimeRange(olive::core::rational(4), - olive::core::rational(8))); + olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8))); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 0.5); - EXPECT_EQ(clip->InputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4)), + clip->set_standard_value(olive::ClipBlock::k_speed_input, 0.5); + EXPECT_EQ(clip->input_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)), true), - olive::TimeRange(olive::core::rational(1), - olive::core::rational(2))); + olive::TimeRange(olive::core::Rational(1), + olive::core::Rational(2))); // Media in is added after the speed multiplication - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); - clip->set_media_in(olive::core::rational(3)); - EXPECT_EQ(clip->InputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4)), + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); + clip->set_media_in(olive::core::Rational(3)); + EXPECT_EQ(clip->input_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)), true), - olive::TimeRange(olive::core::rational(7), - olive::core::rational(11))); + olive::TimeRange(olive::core::Rational(7), + olive::core::Rational(11))); } TEST(ClipBlock, InputTimeAdjustmentZeroSpeedHoldsAtMediaIn) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 0.0); - clip->set_media_in(olive::core::rational(5)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 0.0); + clip->set_media_in(olive::core::Rational(5)); // Zero speed collapses every sequence time onto the media in point - const olive::TimeRange adjusted = clip->InputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - olive::TimeRange(olive::core::rational(2), olive::core::rational(4)), + const olive::TimeRange adjusted = clip->input_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + olive::TimeRange(olive::core::Rational(2), olive::core::Rational(4)), true); - EXPECT_EQ(adjusted.in(), olive::core::rational(5)); - EXPECT_EQ(adjusted.out(), olive::core::rational(5)); + EXPECT_EQ(adjusted.in(), olive::core::Rational(5)); + EXPECT_EQ(adjusted.out(), olive::core::Rational(5)); } TEST(ClipBlock, InputTimeAdjustmentAppliesReverse) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); clip->set_reverse(true); // Reverse mirrors time around the clip length; TimeRange normalizes the // resulting inverted range - EXPECT_EQ(clip->InputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(3)), + EXPECT_EQ(clip->input_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(3)), true), - olive::TimeRange(olive::core::rational(7), - olive::core::rational(8))); + olive::TimeRange(olive::core::Rational(7), + olive::core::Rational(8))); } TEST(ClipBlock, InputTimeAdjustmentCombinesReverseSpeedAndMediaIn) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); clip->set_reverse(true); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); - clip->set_media_in(olive::core::rational(5)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); + clip->set_media_in(olive::core::Rational(5)); // (10 - 2) * 2 + 5 = 21, (10 - 3) * 2 + 5 = 19, normalized to [19, 21] - EXPECT_EQ(clip->InputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(3)), + EXPECT_EQ(clip->input_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(3)), true), - olive::TimeRange(olive::core::rational(19), - olive::core::rational(21))); + olive::TimeRange(olive::core::Rational(19), + olive::core::Rational(21))); } TEST(ClipBlock, InputTimeAdjustmentPassesThroughInfinities) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); clip->set_reverse(true); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); - clip->set_media_in(olive::core::rational(5)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); + clip->set_media_in(olive::core::Rational(5)); - const olive::core::rational kMin(INT_MIN); - const olive::core::rational kMax(INT_MAX); - const olive::TimeRange infinite(kMin, kMax); + const olive::core::Rational k_min(INT_MIN); + const olive::core::Rational k_max(INT_MAX); + const olive::TimeRange infinite(k_min, k_max); - EXPECT_EQ(clip->InputTimeAdjustment(olive::ClipBlock::kBufferIn, -1, + EXPECT_EQ(clip->input_time_adjustment(olive::ClipBlock::k_buffer_in, -1, infinite, true), infinite); - EXPECT_EQ(clip->OutputTimeAdjustment(olive::ClipBlock::kBufferIn, -1, + EXPECT_EQ(clip->output_time_adjustment(olive::ClipBlock::k_buffer_in, -1, infinite), infinite); } TEST(ClipBlock, OutputTimeAdjustmentInvertsInputAdjustment) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); - clip->set_media_in(olive::core::rational(5)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); + clip->set_media_in(olive::core::Rational(5)); // Media time is converted back by subtracting media in and dividing speed - EXPECT_EQ(clip->OutputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - olive::TimeRange(olive::core::rational(5), - olive::core::rational(9))), - olive::TimeRange(olive::core::rational(0), - olive::core::rational(2))); + EXPECT_EQ(clip->output_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + olive::TimeRange(olive::core::Rational(5), + olive::core::Rational(9))), + olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(2))); // Round trip through both adjustments returns the original range - const olive::TimeRange range(olive::core::rational(1), - olive::core::rational(3)); - EXPECT_EQ(clip->OutputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - clip->InputTimeAdjustment(olive::ClipBlock::kBufferIn, -1, + const olive::TimeRange range(olive::core::Rational(1), + olive::core::Rational(3)); + EXPECT_EQ(clip->output_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + clip->input_time_adjustment(olive::ClipBlock::k_buffer_in, -1, range, true)), range); // Round trip also holds in reverse clip->set_reverse(true); - EXPECT_EQ(clip->OutputTimeAdjustment( - olive::ClipBlock::kBufferIn, -1, - clip->InputTimeAdjustment(olive::ClipBlock::kBufferIn, -1, + EXPECT_EQ(clip->output_time_adjustment( + olive::ClipBlock::k_buffer_in, -1, + clip->input_time_adjustment(olive::ClipBlock::k_buffer_in, -1, range, true)), range); } TEST(ClipBlock, MediaRangeReflectsSpeedReverseAndMediaIn) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); EXPECT_EQ(clip->media_range(), - olive::TimeRange(olive::core::rational(0), - olive::core::rational(10))); + olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(10))); - clip->set_media_in(olive::core::rational(5)); + clip->set_media_in(olive::core::Rational(5)); EXPECT_EQ(clip->media_range(), - olive::TimeRange(olive::core::rational(5), - olive::core::rational(15))); + olive::TimeRange(olive::core::Rational(5), + olive::core::Rational(15))); // A 2x clip consumes twice its length in media time - clip->set_media_in(olive::core::rational(0)); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); + clip->set_media_in(olive::core::Rational(0)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); EXPECT_EQ(clip->media_range(), - olive::TimeRange(olive::core::rational(0), - olive::core::rational(20))); + olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(20))); // Reverse maps the same media extent (the range normalizes) - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 1.0); - clip->set_media_in(olive::core::rational(5)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 1.0); + clip->set_media_in(olive::core::Rational(5)); clip->set_reverse(true); EXPECT_EQ(clip->media_range(), - olive::TimeRange(olive::core::rational(5), - olive::core::rational(15))); + olive::TimeRange(olive::core::Rational(5), + olive::core::Rational(15))); } TEST(ClipBlock, SetLengthAndMediaOutInReversePreservesMediaOut) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); clip->set_reverse(true); // Trimming the out point of a reversed clip moves the media in point so // that the media out point is preserved - clip->set_length_and_media_out(olive::core::rational(4)); + clip->set_length_and_media_out(olive::core::Rational(4)); - EXPECT_EQ(clip->length(), olive::core::rational(4)); - EXPECT_EQ(clip->media_in(), olive::core::rational(6)); + EXPECT_EQ(clip->length(), olive::core::Rational(4)); + EXPECT_EQ(clip->media_in(), olive::core::Rational(6)); EXPECT_EQ(clip->media_range(), - olive::TimeRange(olive::core::rational(6), - olive::core::rational(10))); + olive::TimeRange(olive::core::Rational(6), + olive::core::Rational(10))); } TEST(ClipBlock, SetLengthAndMediaInForwardAdjustsMediaIn) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); // Trimming the in point of a forward clip pushes the media in point // forward by the removed amount - clip->set_length_and_media_in(olive::core::rational(4)); + clip->set_length_and_media_in(olive::core::Rational(4)); - EXPECT_EQ(clip->length(), olive::core::rational(4)); - EXPECT_EQ(clip->media_in(), olive::core::rational(6)); + EXPECT_EQ(clip->length(), olive::core::Rational(4)); + EXPECT_EQ(clip->media_in(), olive::core::Rational(6)); EXPECT_EQ(clip->media_range(), - olive::TimeRange(olive::core::rational(6), - olive::core::rational(10))); + olive::TimeRange(olive::core::Rational(6), + olive::core::Rational(10))); } TEST(ClipBlock, ConnectedCacheAccessors) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); EXPECT_EQ(clip->connected_video_cache(), nullptr); EXPECT_EQ(clip->connected_audio_cache(), nullptr); EXPECT_EQ(clip->thumbnails(), nullptr); EXPECT_EQ(clip->waveform(), nullptr); - olive::SolidGenerator *solid = CreateSolid(&project); - olive::Node::ConnectEdge(solid, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::SolidGenerator *solid = create_solid(&project); + olive::Node::connect_edge(solid, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); EXPECT_EQ(clip->connected_video_cache(), solid->video_frame_cache()); EXPECT_EQ(clip->connected_audio_cache(), solid->audio_playback_cache()); @@ -528,485 +528,485 @@ TEST(ClipBlock, ConnectedCacheAccessors) TEST(ClipBlock, InvalidateCacheTransformsMediaTimeToSequenceTime) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); - olive::SolidGenerator *solid = CreateSolid(&project); - olive::Node::ConnectEdge(solid, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::SolidGenerator *solid = create_solid(&project); + olive::Node::connect_edge(solid, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); QVector invalidated; QObject::connect(clip->video_frame_cache(), - &olive::PlaybackCache::Invalidated, + &olive::PlaybackCache::invalidated, [&invalidated](const olive::TimeRange &r) { invalidated.append(r); }); // An invalidation in media time [4,8] covers sequence time [2,4] at 2x - solid->InvalidateCache(olive::TimeRange(olive::core::rational(4), - olive::core::rational(8)), - olive::SolidGenerator::kColorInput); + solid->invalidate_cache(olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8)), + olive::SolidGenerator::k_color_input); ASSERT_EQ(invalidated.size(), 1); EXPECT_EQ(invalidated.first(), - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4))); + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4))); } TEST(ClipBlock, InvalidateCacheReverseTransformsRange) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); clip->set_reverse(true); - olive::SolidGenerator *solid = CreateSolid(&project); - olive::Node::ConnectEdge(solid, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::SolidGenerator *solid = create_solid(&project); + olive::Node::connect_edge(solid, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); QVector invalidated; QObject::connect(clip->video_frame_cache(), - &olive::PlaybackCache::Invalidated, + &olive::PlaybackCache::invalidated, [&invalidated](const olive::TimeRange &r) { invalidated.append(r); }); // Media time [4,8] maps to sequence time [2,6] when reversed - solid->InvalidateCache(olive::TimeRange(olive::core::rational(4), - olive::core::rational(8)), - olive::SolidGenerator::kColorInput); + solid->invalidate_cache(olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8)), + olive::SolidGenerator::k_color_input); ASSERT_EQ(invalidated.size(), 1); EXPECT_EQ(invalidated.first(), - olive::TimeRange(olive::core::rational(2), - olive::core::rational(6))); + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(6))); } TEST(ClipBlock, InvalidateCacheZeroSpeedInvalidatesWholeClip) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 0.0); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 0.0); - olive::SolidGenerator *solid = CreateSolid(&project); - olive::Node::ConnectEdge(solid, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::SolidGenerator *solid = create_solid(&project); + olive::Node::connect_edge(solid, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); QVector invalidated; QObject::connect(clip->video_frame_cache(), - &olive::PlaybackCache::Invalidated, + &olive::PlaybackCache::invalidated, [&invalidated](const olive::TimeRange &r) { invalidated.append(r); }); // With zero speed any media invalidation affects the whole clip - solid->InvalidateCache(olive::TimeRange(olive::core::rational(4), - olive::core::rational(8)), - olive::SolidGenerator::kColorInput); + solid->invalidate_cache(olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8)), + olive::SolidGenerator::k_color_input); ASSERT_EQ(invalidated.size(), 1); EXPECT_EQ(invalidated.first(), - olive::TimeRange(olive::core::rational(0), - olive::core::rational(10))); + olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(10))); } TEST(ClipBlock, InvalidateCacheWithVideoTrackReachesConnectedCaches) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *track = new olive::Track(); track->setParent(&project); - track->set_type(olive::Track::kVideo); + track->set_type(olive::Track::k_video); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); - track->AppendBlock(clip); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); + track->append_block(clip); - olive::SolidGenerator *solid = CreateSolid(&project); - olive::Node::ConnectEdge(solid, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::SolidGenerator *solid = create_solid(&project); + olive::Node::connect_edge(solid, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); QVector invalidated; QObject::connect(solid->video_frame_cache(), - &olive::PlaybackCache::Invalidated, + &olive::PlaybackCache::invalidated, [&invalidated](const olive::TimeRange &r) { invalidated.append(r); }); QVector requested; QObject::connect(solid->video_frame_cache(), - &olive::PlaybackCache::Requested, + &olive::PlaybackCache::requested, [&requested](olive::ViewerOutput *, const olive::TimeRange &r) { requested.append(r); }); // Without autocache the connected cache is invalidated but not requested - clip->InvalidateCache(olive::TimeRange(olive::core::rational(4), - olive::core::rational(8)), - olive::ClipBlock::kBufferIn, -1, + clip->invalidate_cache(olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8)), + olive::ClipBlock::k_buffer_in, -1, olive::Node::InvalidateCacheOptions()); ASSERT_EQ(invalidated.size(), 1); EXPECT_EQ(invalidated.first(), - olive::TimeRange(olive::core::rational(4), - olive::core::rational(8))); + olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8))); EXPECT_TRUE(requested.isEmpty()); // Enabling autocache re-requests everything currently invalidated (a // fresh cache has no validated ranges, so the full media range) - clip->SetAutocache(true); + clip->set_autocache(true); ASSERT_GE(requested.size(), 1); EXPECT_EQ(requested.first(), - olive::TimeRange(olive::core::rational(0), - olive::core::rational(10))); + olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(10))); // With autocache on, invalidations are also requested invalidated.clear(); requested.clear(); - clip->InvalidateCache(olive::TimeRange(olive::core::rational(4), - olive::core::rational(8)), - olive::ClipBlock::kBufferIn, -1, + clip->invalidate_cache(olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8)), + olive::ClipBlock::k_buffer_in, -1, olive::Node::InvalidateCacheOptions()); ASSERT_EQ(invalidated.size(), 1); EXPECT_EQ(invalidated.first(), - olive::TimeRange(olive::core::rational(4), - olive::core::rational(8))); + olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8))); ASSERT_EQ(requested.size(), 1); EXPECT_EQ(requested.first(), - olive::TimeRange(olive::core::rational(4), - olive::core::rational(8))); + olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8))); } TEST(ClipBlock, DiscardCacheInvalidatesConnectedNodeCache) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *track = new olive::Track(); track->setParent(&project); - track->set_type(olive::Track::kVideo); + track->set_type(olive::Track::k_video); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); - track->AppendBlock(clip); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); + track->append_block(clip); - olive::SolidGenerator *solid = CreateSolid(&project); - olive::Node::ConnectEdge(solid, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::SolidGenerator *solid = create_solid(&project); + olive::Node::connect_edge(solid, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); QVector invalidated; QObject::connect(solid->video_frame_cache(), - &olive::PlaybackCache::Invalidated, + &olive::PlaybackCache::invalidated, [&invalidated](const olive::TimeRange &r) { invalidated.append(r); }); - clip->DiscardCache(); + clip->discard_cache(); - const olive::core::rational kMin(INT_MIN); - const olive::core::rational kMax(INT_MAX); + const olive::core::Rational k_min(INT_MIN); + const olive::core::Rational k_max(INT_MAX); ASSERT_EQ(invalidated.size(), 1); - EXPECT_EQ(invalidated.first(), olive::TimeRange(kMin, kMax)); + EXPECT_EQ(invalidated.first(), olive::TimeRange(k_min, k_max)); } TEST(ClipBlock, AddCachePassthroughFromUnvalidatedSourceAddsNoPassthroughs) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(10)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(10)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(10)); // Passthroughs are only added for validated ranges of the source caches, // and a fresh cache has none - b->AddCachePassthroughFrom(a); + b->add_cache_passthrough_from(a); - EXPECT_TRUE(b->video_frame_cache()->GetPassthroughs().empty()); - EXPECT_TRUE(b->audio_playback_cache()->GetPassthroughs().empty()); + EXPECT_TRUE(b->video_frame_cache()->get_passthroughs().empty()); + EXPECT_TRUE(b->audio_playback_cache()->get_passthroughs().empty()); } TEST(ClipBlock, GetValueHintForBufferWithoutTrackHasNoPreference) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); // With no track the clip cannot prefer texture or samples and falls back // to the default (typeless) hint - EXPECT_TRUE(clip->GetValueHintForInput(olive::ClipBlock::kBufferIn) + EXPECT_TRUE(clip->get_value_hint_for_input(olive::ClipBlock::k_buffer_in) .types() .isEmpty()); } TEST(ClipBlock, FindMulticamReturnsNullWithoutMulticam) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); - EXPECT_EQ(clip->FindMulticam(), nullptr); + EXPECT_EQ(clip->find_multicam(), nullptr); - olive::SolidGenerator *solid = CreateSolid(&project); - olive::Node::ConnectEdge(solid, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); - EXPECT_EQ(clip->FindMulticam(), nullptr); + olive::SolidGenerator *solid = create_solid(&project); + olive::Node::connect_edge(solid, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); + EXPECT_EQ(clip->find_multicam(), nullptr); } TEST(ClipTraverser, GenerateTablePropagatesSpeedAdjustedTime) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); auto *time = new olive::TimeInput(); time->setParent(&project); - olive::Node::ConnectEdge(time, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::Node::connect_edge(time, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); // The connected node is evaluated in media time: sequence time 3 at 2x // speed reaches the time node as 6 - EXPECT_DOUBLE_EQ(GenerateClipTimeValue(clip, olive::core::rational(3)), + EXPECT_DOUBLE_EQ(generate_clip_time_value(clip, olive::core::Rational(3)), 6.0); } TEST(ClipTraverser, GenerateTablePropagatesMediaInOffset) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); - clip->set_media_in(olive::core::rational(5)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); + clip->set_media_in(olive::core::Rational(5)); auto *time = new olive::TimeInput(); time->setParent(&project); - olive::Node::ConnectEdge(time, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::Node::connect_edge(time, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); - EXPECT_DOUBLE_EQ(GenerateClipTimeValue(clip, olive::core::rational(3)), + EXPECT_DOUBLE_EQ(generate_clip_time_value(clip, olive::core::Rational(3)), 8.0); } TEST(ClipTraverser, GenerateTablePropagatesReverseTime) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); clip->set_reverse(true); auto *time = new olive::TimeInput(); time->setParent(&project); - olive::Node::ConnectEdge(time, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::Node::connect_edge(time, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); // Reverse maps the frame range [t, t+1/30) onto media [7, 7-1/30), so the // connected node is evaluated at 7 - 1/30 - EXPECT_DOUBLE_EQ(GenerateClipTimeValue(clip, olive::core::rational(3)), + EXPECT_DOUBLE_EQ(generate_clip_time_value(clip, olive::core::Rational(3)), 7.0 - 1.0 / 30.0); } TEST(ClipTraverser, GenerateTableCombinesReverseSpeedAndMediaIn) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); clip->set_reverse(true); - clip->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); - clip->set_media_in(olive::core::rational(5)); + clip->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); + clip->set_media_in(olive::core::Rational(5)); auto *time = new olive::TimeInput(); time->setParent(&project); - olive::Node::ConnectEdge(time, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::Node::connect_edge(time, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); // (10 - 1/30 - 3) * 2 + 5 = 19 - 2/30 - EXPECT_DOUBLE_EQ(GenerateClipTimeValue(clip, olive::core::rational(3)), + EXPECT_DOUBLE_EQ(generate_clip_time_value(clip, olive::core::Rational(3)), 19.0 - 2.0 / 30.0); } TEST(ClipTraverser, GenerateTablePicksUpClipLoopMode) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::ClipBlock *clip = CreateClip(&project, olive::core::rational(10)); + project.initialize(); + olive::ClipBlock *clip = create_clip(&project, olive::core::Rational(10)); auto *probe = new LoopModeProbeNode(); probe->setParent(&project); - olive::Node::ConnectEdge(probe, - olive::NodeInput(clip, olive::ClipBlock::kBufferIn)); + olive::Node::connect_edge(probe, + olive::NodeInput(clip, olive::ClipBlock::k_buffer_in)); - GenerateClipTable(clip, olive::core::rational(0)); - EXPECT_EQ(probe->last_loop_mode(), olive::LoopMode::kLoopModeOff); + generate_clip_table(clip, olive::core::Rational(0)); + EXPECT_EQ(probe->last_loop_mode(), olive::LoopMode::k_loop_mode_off); - clip->set_loop_mode(olive::LoopMode::kLoopModeLoop); - GenerateClipTable(clip, olive::core::rational(0)); - EXPECT_EQ(probe->last_loop_mode(), olive::LoopMode::kLoopModeLoop); + clip->set_loop_mode(olive::LoopMode::k_loop_mode_loop); + generate_clip_table(clip, olive::core::Rational(0)); + EXPECT_EQ(probe->last_loop_mode(), olive::LoopMode::k_loop_mode_loop); - clip->set_loop_mode(olive::LoopMode::kLoopModeClamp); - GenerateClipTable(clip, olive::core::rational(0)); - EXPECT_EQ(probe->last_loop_mode(), olive::LoopMode::kLoopModeClamp); + clip->set_loop_mode(olive::LoopMode::k_loop_mode_clamp); + generate_clip_table(clip, olive::core::Rational(0)); + EXPECT_EQ(probe->last_loop_mode(), olive::LoopMode::k_loop_mode_clamp); } TEST(ClipTraverser, GenerateTableDefaultsToLoopModeOff) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *probe = new LoopModeProbeNode(); probe->setParent(&project); olive::NodeTraverser traverser; - traverser.GenerateTable( - probe, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - EXPECT_EQ(probe->last_loop_mode(), olive::LoopMode::kLoopModeOff); + traverser.generate_table( + probe, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + EXPECT_EQ(probe->last_loop_mode(), olive::LoopMode::k_loop_mode_off); } TEST(ClipTraverser, TransformAccumulatesGizmosAlongPath) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *start = new GizmoProbeNode(); start->setParent(&project); - start->SetGizmoTransform(QTransform().translate(1, 0)); + start->set_gizmo_transform(QTransform().translate(1, 0)); auto *middle = new GizmoProbeNode(); middle->setParent(&project); - middle->SetGizmoTransform(QTransform().translate(2, 0)); + middle->set_gizmo_transform(QTransform().translate(2, 0)); auto *end = new GizmoProbeNode(); end->setParent(&project); - end->SetGizmoTransform(QTransform().translate(4, 0)); + end->set_gizmo_transform(QTransform().translate(4, 0)); - olive::Node::ConnectEdge(start, - olive::NodeInput(middle, GizmoProbeNode::InputA())); - olive::Node::ConnectEdge(middle, - olive::NodeInput(end, GizmoProbeNode::InputA())); + olive::Node::connect_edge(start, + olive::NodeInput(middle, GizmoProbeNode::input_a())); + olive::Node::connect_edge(middle, + olive::NodeInput(end, GizmoProbeNode::input_a())); - const olive::TimeRange range(olive::core::rational(0), - olive::core::rational(1, 30)); + const olive::TimeRange range(olive::core::Rational(0), + olive::core::Rational(1, 30)); // The start node defines the reference frame, so only the gizmos of the // nodes between start and end (inclusive of end) are accumulated olive::NodeTraverser traverser; QTransform t; - traverser.Transform(&t, start, end, range); + traverser.transform(&t, start, end, range); EXPECT_DOUBLE_EQ(t.dx(), 6.0); EXPECT_DOUBLE_EQ(t.dy(), 0.0); // Stopping at the middle node accumulates only its gizmo olive::NodeTraverser traverser2; QTransform t2; - traverser2.Transform(&t2, start, middle, range); + traverser2.transform(&t2, start, middle, range); EXPECT_DOUBLE_EQ(t2.dx(), 2.0); EXPECT_DOUBLE_EQ(t2.dy(), 0.0); } TEST(ClipTraverser, TransformIgnoresNodesOffThePath) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *start = new GizmoProbeNode(); start->setParent(&project); - start->SetGizmoTransform(QTransform().translate(1, 0)); + start->set_gizmo_transform(QTransform().translate(1, 0)); auto *end = new GizmoProbeNode(); end->setParent(&project); - end->SetGizmoTransform(QTransform().translate(4, 0)); + end->set_gizmo_transform(QTransform().translate(4, 0)); // Connected to the end node but not on the start->end path auto *off_path = new GizmoProbeNode(); off_path->setParent(&project); - off_path->SetGizmoTransform(QTransform().translate(100, 0)); + off_path->set_gizmo_transform(QTransform().translate(100, 0)); - olive::Node::ConnectEdge(start, - olive::NodeInput(end, GizmoProbeNode::InputA())); - olive::Node::ConnectEdge(off_path, - olive::NodeInput(end, GizmoProbeNode::InputB())); + olive::Node::connect_edge(start, + olive::NodeInput(end, GizmoProbeNode::input_a())); + olive::Node::connect_edge(off_path, + olive::NodeInput(end, GizmoProbeNode::input_b())); - const olive::TimeRange range(olive::core::rational(0), - olive::core::rational(1, 30)); + const olive::TimeRange range(olive::core::Rational(0), + olive::core::Rational(1, 30)); olive::NodeTraverser traverser; QTransform t; - traverser.Transform(&t, start, end, range); + traverser.transform(&t, start, end, range); EXPECT_DOUBLE_EQ(t.dx(), 4.0); EXPECT_DOUBLE_EQ(t.dy(), 0.0); } TEST(ClipTraverser, TransformWithSameStartAndEndIsIdentity) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new GizmoProbeNode(); node->setParent(&project); - node->SetGizmoTransform(QTransform().translate(4, 0)); + node->set_gizmo_transform(QTransform().translate(4, 0)); - const olive::TimeRange range(olive::core::rational(0), - olive::core::rational(1, 30)); + const olive::TimeRange range(olive::core::Rational(0), + olive::core::Rational(1, 30)); olive::NodeTraverser traverser; QTransform t; - traverser.Transform(&t, node, node, range); + traverser.transform(&t, node, node, range); EXPECT_TRUE(t.isIdentity()); } TEST(ClipTraverser, ViewerConnectedOutputsResolveThroughGraph) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *viewer = new olive::ViewerOutput(); viewer->setParent(&project); - EXPECT_EQ(viewer->GetConnectedTextureOutput(), nullptr); - EXPECT_EQ(viewer->GetConnectedSampleOutput(), nullptr); + EXPECT_EQ(viewer->get_connected_texture_output(), nullptr); + EXPECT_EQ(viewer->get_connected_sample_output(), nullptr); auto *texture_source = new GizmoProbeNode(); texture_source->setParent(&project); auto *sample_source = new GizmoProbeNode(); sample_source->setParent(&project); - olive::Node::ConnectEdge( + olive::Node::connect_edge( texture_source, - olive::NodeInput(viewer, olive::ViewerOutput::kTextureInput)); - olive::Node::ConnectEdge( + olive::NodeInput(viewer, olive::ViewerOutput::k_texture_input)); + olive::Node::connect_edge( sample_source, - olive::NodeInput(viewer, olive::ViewerOutput::kSamplesInput)); + olive::NodeInput(viewer, olive::ViewerOutput::k_samples_input)); - EXPECT_EQ(viewer->GetConnectedTextureOutput(), texture_source); - EXPECT_EQ(viewer->GetConnectedSampleOutput(), sample_source); + EXPECT_EQ(viewer->get_connected_texture_output(), texture_source); + EXPECT_EQ(viewer->get_connected_sample_output(), sample_source); // The value hint getters delegate to the corresponding input hints - EXPECT_EQ(viewer->GetConnectedTextureValueHint().types(), - viewer->GetValueHintForInput(olive::ViewerOutput::kTextureInput) + EXPECT_EQ(viewer->get_connected_texture_value_hint().types(), + viewer->get_value_hint_for_input(olive::ViewerOutput::k_texture_input) .types()); - EXPECT_EQ(viewer->GetConnectedSampleValueHint().types(), - viewer->GetValueHintForInput(olive::ViewerOutput::kSamplesInput) + EXPECT_EQ(viewer->get_connected_sample_value_hint().types(), + viewer->get_value_hint_for_input(olive::ViewerOutput::k_samples_input) .types()); - olive::Node::DisconnectEdge( + olive::Node::disconnect_edge( texture_source, - olive::NodeInput(viewer, olive::ViewerOutput::kTextureInput)); - EXPECT_EQ(viewer->GetConnectedTextureOutput(), nullptr); - EXPECT_EQ(viewer->GetConnectedSampleOutput(), sample_source); + olive::NodeInput(viewer, olive::ViewerOutput::k_texture_input)); + EXPECT_EQ(viewer->get_connected_texture_output(), nullptr); + EXPECT_EQ(viewer->get_connected_sample_output(), sample_source); } diff --git a/tests/gtest/codec_decoder_test.cpp b/tests/gtest/codec_decoder_test.cpp index 4b876333e..9f546f5ad 100644 --- a/tests/gtest/codec_decoder_test.cpp +++ b/tests/gtest/codec_decoder_test.cpp @@ -12,21 +12,21 @@ TEST(CodecDecoder, RetrieveVideoFrameFromDemoMp4) ASSERT_TRUE(QFileInfo::exists(path)); olive::DecoderPtr decoder = - olive::Decoder::CreateFromID(QStringLiteral("ffmpeg")); + olive::Decoder::create_from_id(QStringLiteral("ffmpeg")); ASSERT_TRUE(decoder); - ASSERT_TRUE(decoder->Open(olive::Decoder::CodecStream(path, 0, nullptr))); + ASSERT_TRUE(decoder->open(olive::Decoder::CodecStream(path, 0, nullptr))); olive::Decoder::RetrieveVideoParams params; - params.time = olive::rational(0); - params.maximum_format = olive::core::PixelFormat::U8; + params.time = olive::Rational(0); + params.maximum_format = olive::core::PixelFormat::u8; - olive::FramePtr frame = decoder->RetrieveVideoFrame(params); + olive::FramePtr frame = decoder->retrieve_video_frame(params); ASSERT_TRUE(frame); ASSERT_TRUE(frame->is_allocated()); EXPECT_EQ(frame->width(), 1920); EXPECT_EQ(frame->height(), 1080); - EXPECT_NE(frame->format(), olive::core::PixelFormat::INVALID); + EXPECT_NE(frame->format(), olive::core::PixelFormat::invalid); EXPECT_GT(frame->channel_count(), 0); EXPECT_GT(frame->allocated_size(), 0); EXPECT_GT(frame->linesize_bytes(), 0); diff --git a/tests/gtest/codec_encoder_test.cpp b/tests/gtest/codec_encoder_test.cpp index c8731f9dd..185b6e78c 100644 --- a/tests/gtest/codec_encoder_test.cpp +++ b/tests/gtest/codec_encoder_test.cpp @@ -11,27 +11,27 @@ public: { } - bool Open() override + bool open() override { return true; } - bool WriteFrame(olive::FramePtr, olive::core::rational) override + bool write_frame(olive::FramePtr, olive::core::Rational) override { return true; } - bool WriteAudio(const olive::SampleBuffer &) override + bool write_audio(const olive::SampleBuffer &) override { return true; } - bool WriteSubtitle(const olive::SubtitleBlock *) override + bool write_subtitle(const olive::SubtitleBlock *) override { return true; } - void Close() override + void close() override { } }; @@ -40,26 +40,26 @@ public: TEST(CodecEncoder, ImageSequenceFilenames) { olive::EncodingParams params; - params.SetFilename(QStringLiteral("frame_[####].png")); + params.set_filename(QStringLiteral("frame_[####].png")); params.set_video_is_image_sequence(true); olive::VideoParams video_params; - video_params.set_frame_rate(olive::core::rational(24, 1)); - params.EnableVideo(video_params, olive::ExportCodec::kCodecPNG); + video_params.set_frame_rate(olive::core::Rational(24, 1)); + params.enable_video(video_params, olive::ExportCodec::k_codec_png); TestEncoder encoder(params); - EXPECT_TRUE(olive::Encoder::FilenameContainsDigitPlaceholder( + EXPECT_TRUE(olive::Encoder::filename_contains_digit_placeholder( QStringLiteral("frame_[####].png"))); - EXPECT_EQ(olive::Encoder::GetImageSequencePlaceholderDigitCount( + EXPECT_EQ(olive::Encoder::get_image_sequence_placeholder_digit_count( QStringLiteral("frame_[####].png")), 4); - EXPECT_EQ(olive::Encoder::FilenameRemoveDigitPlaceholder( + EXPECT_EQ(olive::Encoder::filename_remove_digit_placeholder( QStringLiteral("frame_[####].png")), QStringLiteral("frame.png")); const QString filename = - encoder.GetFilenameForFrame(olive::core::rational(1, 24)); + encoder.get_filename_for_frame(olive::core::Rational(1, 24)); EXPECT_EQ(filename, QStringLiteral("frame_0001.png")); } @@ -67,17 +67,17 @@ TEST(CodecEncoder, MatrixGeneration) { using Method = olive::EncodingParams::VideoScalingMethod; - QMatrix4x4 stretch = olive::EncodingParams::GenerateMatrix( - Method::kStretch, 1920, 1080, 1280, 720); + QMatrix4x4 stretch = olive::EncodingParams::generate_matrix( + Method::k_stretch, 1920, 1080, 1280, 720); EXPECT_TRUE(qFuzzyCompare(stretch(0, 0), 1.0f)); EXPECT_TRUE(qFuzzyCompare(stretch(1, 1), 1.0f)); - QMatrix4x4 fit = olive::EncodingParams::GenerateMatrix(Method::kFit, 1920, + QMatrix4x4 fit = olive::EncodingParams::generate_matrix(Method::k_fit, 1920, 1080, 1024, 1024); EXPECT_TRUE(qFuzzyCompare(fit(0, 0), 1.0f)); EXPECT_FALSE(qFuzzyCompare(fit(1, 1), 1.0f)); - QMatrix4x4 crop = olive::EncodingParams::GenerateMatrix(Method::kCrop, 1920, + QMatrix4x4 crop = olive::EncodingParams::generate_matrix(Method::k_crop, 1920, 1080, 1024, 1024); EXPECT_FALSE(qFuzzyCompare(crop(0, 0), 1.0f)); EXPECT_TRUE(qFuzzyCompare(crop(1, 1), 1.0f)); @@ -88,10 +88,10 @@ TEST(CodecEncoder, TypeFromFormat) using olive::Encoder; using olive::ExportFormat; - EXPECT_EQ(Encoder::GetTypeFromFormat(ExportFormat::kFormatPNG), - Encoder::kEncoderTypeOIIO); - EXPECT_EQ(Encoder::GetTypeFromFormat(ExportFormat::kFormatDNxHD), - Encoder::kEncoderTypeFFmpeg); - EXPECT_EQ(Encoder::GetTypeFromFormat(ExportFormat::kFormatCount), - Encoder::kEncoderTypeNone); + EXPECT_EQ(Encoder::get_type_from_format(ExportFormat::k_format_png), + Encoder::k_encoder_type_oiio); + EXPECT_EQ(Encoder::get_type_from_format(ExportFormat::k_format_d_nx_hd), + Encoder::k_encoder_type_f_fmpeg); + EXPECT_EQ(Encoder::get_type_from_format(ExportFormat::k_format_count), + Encoder::k_encoder_type_none); } diff --git a/tests/gtest/codec_exportcodec_test.cpp b/tests/gtest/codec_exportcodec_test.cpp index 0bab32db5..72d2390ef 100644 --- a/tests/gtest/codec_exportcodec_test.cpp +++ b/tests/gtest/codec_exportcodec_test.cpp @@ -6,26 +6,26 @@ TEST(CodecExportCodec, NamesAndFlags) { using olive::ExportCodec; - EXPECT_EQ(ExportCodec::GetCodecName(ExportCodec::kCodecH264), + EXPECT_EQ(ExportCodec::get_codec_name(ExportCodec::k_codec_h264), QStringLiteral("H.264")); - EXPECT_EQ(ExportCodec::GetCodecName(ExportCodec::kCodecCount), + EXPECT_EQ(ExportCodec::get_codec_name(ExportCodec::k_codec_count), QStringLiteral("Unknown")); - EXPECT_TRUE(ExportCodec::IsCodecAStillImage(ExportCodec::kCodecPNG)); - EXPECT_FALSE(ExportCodec::IsCodecAStillImage(ExportCodec::kCodecH264)); + EXPECT_TRUE(ExportCodec::is_codec_a_still_image(ExportCodec::k_codec_png)); + EXPECT_FALSE(ExportCodec::is_codec_a_still_image(ExportCodec::k_codec_h264)); - EXPECT_TRUE(ExportCodec::IsCodecLossless(ExportCodec::kCodecPCM)); - EXPECT_TRUE(ExportCodec::IsCodecLossless(ExportCodec::kCodecFLAC)); - EXPECT_FALSE(ExportCodec::IsCodecLossless(ExportCodec::kCodecH265)); + EXPECT_TRUE(ExportCodec::is_codec_lossless(ExportCodec::k_codec_pcm)); + EXPECT_TRUE(ExportCodec::is_codec_lossless(ExportCodec::k_codec_flac)); + EXPECT_FALSE(ExportCodec::is_codec_lossless(ExportCodec::k_codec_h265)); } TEST(CodecExportCodec, VideoCodecNamesAreNonEmpty) { using olive::ExportCodec; - for (int i = 0; i < ExportCodec::kCodecCount; ++i) { + for (int i = 0; i < ExportCodec::k_codec_count; ++i) { const auto codec = static_cast(i); - const QString name = ExportCodec::GetCodecName(codec); + const QString name = ExportCodec::get_codec_name(codec); EXPECT_FALSE(name.isEmpty()) << "Codec " << i; } } @@ -34,18 +34,18 @@ TEST(CodecExportCodec, AudioCodecsAreNotStillImages) { using olive::ExportCodec; - EXPECT_FALSE(ExportCodec::IsCodecAStillImage(ExportCodec::kCodecPCM)); - EXPECT_FALSE(ExportCodec::IsCodecAStillImage(ExportCodec::kCodecAAC)); - EXPECT_FALSE(ExportCodec::IsCodecAStillImage(ExportCodec::kCodecFLAC)); - EXPECT_FALSE(ExportCodec::IsCodecAStillImage(ExportCodec::kCodecOpus)); + EXPECT_FALSE(ExportCodec::is_codec_a_still_image(ExportCodec::k_codec_pcm)); + EXPECT_FALSE(ExportCodec::is_codec_a_still_image(ExportCodec::k_codec_aac)); + EXPECT_FALSE(ExportCodec::is_codec_a_still_image(ExportCodec::k_codec_flac)); + EXPECT_FALSE(ExportCodec::is_codec_a_still_image(ExportCodec::k_codec_opus)); } TEST(CodecExportCodec, LossyCodecsAreNotLossless) { using olive::ExportCodec; - EXPECT_FALSE(ExportCodec::IsCodecLossless(ExportCodec::kCodecH264)); - EXPECT_FALSE(ExportCodec::IsCodecLossless(ExportCodec::kCodecH265)); - EXPECT_FALSE(ExportCodec::IsCodecLossless(ExportCodec::kCodecVP9)); - EXPECT_FALSE(ExportCodec::IsCodecLossless(ExportCodec::kCodecAAC)); + EXPECT_FALSE(ExportCodec::is_codec_lossless(ExportCodec::k_codec_h264)); + EXPECT_FALSE(ExportCodec::is_codec_lossless(ExportCodec::k_codec_h265)); + EXPECT_FALSE(ExportCodec::is_codec_lossless(ExportCodec::k_codec_v_p9)); + EXPECT_FALSE(ExportCodec::is_codec_lossless(ExportCodec::k_codec_aac)); } diff --git a/tests/gtest/codec_exportformat_test.cpp b/tests/gtest/codec_exportformat_test.cpp index 3fdea8357..3101de12c 100644 --- a/tests/gtest/codec_exportformat_test.cpp +++ b/tests/gtest/codec_exportformat_test.cpp @@ -6,23 +6,23 @@ TEST(CodecExportFormat, NamesAndExtensions) { using olive::ExportFormat; - EXPECT_EQ(ExportFormat::GetName(ExportFormat::kFormatDNxHD), + EXPECT_EQ(ExportFormat::get_name(ExportFormat::k_format_d_nx_hd), QStringLiteral("DNxHD")); - EXPECT_EQ(ExportFormat::GetExtension(ExportFormat::kFormatDNxHD), + EXPECT_EQ(ExportFormat::get_extension(ExportFormat::k_format_d_nx_hd), QStringLiteral("mxf")); - EXPECT_EQ(ExportFormat::GetName(ExportFormat::kFormatCount), + EXPECT_EQ(ExportFormat::get_name(ExportFormat::k_format_count), QStringLiteral("Unknown")); EXPECT_TRUE( - ExportFormat::GetExtension(ExportFormat::kFormatCount).isEmpty()); + ExportFormat::get_extension(ExportFormat::k_format_count).isEmpty()); } TEST(CodecExportFormat, AllFormatsHaveNames) { using olive::ExportFormat; - for (int i = 0; i < ExportFormat::kFormatCount; ++i) { + for (int i = 0; i < ExportFormat::k_format_count; ++i) { const auto fmt = static_cast(i); - EXPECT_FALSE(ExportFormat::GetName(fmt).isEmpty()) << "Format " << i; + EXPECT_FALSE(ExportFormat::get_name(fmt).isEmpty()) << "Format " << i; } } @@ -30,11 +30,11 @@ TEST(CodecExportFormat, AllFormatsHaveAtLeastOneCodecList) { using olive::ExportFormat; - for (int i = 0; i < ExportFormat::kFormatCount; ++i) { + for (int i = 0; i < ExportFormat::k_format_count; ++i) { const auto fmt = static_cast(i); - EXPECT_FALSE(ExportFormat::GetVideoCodecs(fmt).isEmpty() && - ExportFormat::GetAudioCodecs(fmt).isEmpty() && - ExportFormat::GetSubtitleCodecs(fmt).isEmpty()) + EXPECT_FALSE(ExportFormat::get_video_codecs(fmt).isEmpty() && + ExportFormat::get_audio_codecs(fmt).isEmpty() && + ExportFormat::get_subtitle_codecs(fmt).isEmpty()) << "Format " << i; } } @@ -45,26 +45,26 @@ TEST(CodecExportFormat, CodecLists) using olive::ExportFormat; const QList matroska_video = - ExportFormat::GetVideoCodecs(ExportFormat::kFormatMatroska); - EXPECT_TRUE(matroska_video.contains(ExportCodec::kCodecH264)); - EXPECT_TRUE(matroska_video.contains(ExportCodec::kCodecVP9)); + ExportFormat::get_video_codecs(ExportFormat::k_format_matroska); + EXPECT_TRUE(matroska_video.contains(ExportCodec::k_codec_h264)); + EXPECT_TRUE(matroska_video.contains(ExportCodec::k_codec_v_p9)); const QList ogg_audio = - ExportFormat::GetAudioCodecs(ExportFormat::kFormatOgg); - EXPECT_TRUE(ogg_audio.contains(ExportCodec::kCodecOpus)); - EXPECT_TRUE(ogg_audio.contains(ExportCodec::kCodecVorbis)); + ExportFormat::get_audio_codecs(ExportFormat::k_format_ogg); + EXPECT_TRUE(ogg_audio.contains(ExportCodec::k_codec_opus)); + EXPECT_TRUE(ogg_audio.contains(ExportCodec::k_codec_vorbis)); const QList png_video = - ExportFormat::GetVideoCodecs(ExportFormat::kFormatPNG); - EXPECT_EQ(png_video, QList{ ExportCodec::kCodecPNG }); + ExportFormat::get_video_codecs(ExportFormat::k_format_png); + EXPECT_EQ(png_video, QList{ ExportCodec::k_codec_png }); const QList srt_subs = - ExportFormat::GetSubtitleCodecs(ExportFormat::kFormatMatroska); - EXPECT_EQ(srt_subs, QList{ ExportCodec::kCodecSRT }); + ExportFormat::get_subtitle_codecs(ExportFormat::k_format_matroska); + EXPECT_EQ(srt_subs, QList{ ExportCodec::k_codec_srt }); const QList wav_audio = - ExportFormat::GetAudioCodecs(ExportFormat::kFormatWAV); - EXPECT_EQ(wav_audio, QList{ ExportCodec::kCodecPCM }); + ExportFormat::get_audio_codecs(ExportFormat::k_format_wav); + EXPECT_EQ(wav_audio, QList{ ExportCodec::k_codec_pcm }); } TEST(CodecExportFormat, MPEG4ContainsH264AndAAC) @@ -72,8 +72,8 @@ TEST(CodecExportFormat, MPEG4ContainsH264AndAAC) using olive::ExportCodec; using olive::ExportFormat; - EXPECT_TRUE(ExportFormat::GetVideoCodecs(ExportFormat::kFormatMPEG4Video) - .contains(ExportCodec::kCodecH264)); - EXPECT_TRUE(ExportFormat::GetAudioCodecs(ExportFormat::kFormatMPEG4Audio) - .contains(ExportCodec::kCodecAAC)); + EXPECT_TRUE(ExportFormat::get_video_codecs(ExportFormat::k_format_mpe_g4_video) + .contains(ExportCodec::k_codec_h264)); + EXPECT_TRUE(ExportFormat::get_audio_codecs(ExportFormat::k_format_mpe_g4_audio) + .contains(ExportCodec::k_codec_aac)); } diff --git a/tests/gtest/codec_ffmpegencoder_test.cpp b/tests/gtest/codec_ffmpegencoder_test.cpp index 36baec5fb..7ed6bdea6 100644 --- a/tests/gtest/codec_ffmpegencoder_test.cpp +++ b/tests/gtest/codec_ffmpegencoder_test.cpp @@ -15,12 +15,12 @@ TEST(CodecFFmpegEncoder, PixelFormatsForCodec) olive::FFmpegEncoder encoder(params); const QStringList png_fmts = - encoder.GetPixelFormatsForCodec(olive::ExportCodec::kCodecPNG); + encoder.get_pixel_formats_for_codec(olive::ExportCodec::k_codec_png); EXPECT_FALSE(png_fmts.isEmpty()); EXPECT_TRUE(png_fmts.contains(QStringLiteral("rgba"))); EXPECT_TRUE( - encoder.GetPixelFormatsForCodec(olive::ExportCodec::kCodecCount) + encoder.get_pixel_formats_for_codec(olive::ExportCodec::k_codec_count) .isEmpty()); } @@ -31,13 +31,13 @@ TEST(CodecFFmpegEncoder, SampleFormatsForCodec) // PCM is handled with a custom list whose first element is the default const std::vector pcm = - encoder.GetSampleFormatsForCodec(olive::ExportCodec::kCodecPCM); + encoder.get_sample_formats_for_codec(olive::ExportCodec::k_codec_pcm); ASSERT_FALSE(pcm.empty()); - EXPECT_EQ(pcm.front(), olive::core::SampleFormat::S16); + EXPECT_EQ(pcm.front(), olive::core::SampleFormat::s16); - EXPECT_FALSE(encoder.GetSampleFormatsForCodec(olive::ExportCodec::kCodecAAC) + EXPECT_FALSE(encoder.get_sample_formats_for_codec(olive::ExportCodec::k_codec_aac) .empty()); - EXPECT_TRUE(encoder.GetSampleFormatsForCodec(olive::ExportCodec::kCodecCount) + EXPECT_TRUE(encoder.get_sample_formats_for_codec(olive::ExportCodec::k_codec_count) .empty()); } @@ -47,14 +47,14 @@ TEST(CodecFFmpegEncoder, OpenWithInvalidPixelFormatFails) ASSERT_TRUE(dir.isValid()); olive::EncodingParams params; - params.SetFilename(dir.filePath(QStringLiteral("invalid.mkv"))); + params.set_filename(dir.filePath(QStringLiteral("invalid.mkv"))); // A default-constructed VideoParams has PixelFormat::INVALID, for which no // bridge pixel format exists - params.EnableVideo(olive::VideoParams(), olive::ExportCodec::kCodecPNG); + params.enable_video(olive::VideoParams(), olive::ExportCodec::k_codec_png); olive::FFmpegEncoder encoder(params); - EXPECT_FALSE(encoder.Open()); - EXPECT_FALSE(encoder.GetError().isEmpty()); + EXPECT_FALSE(encoder.open()); + EXPECT_FALSE(encoder.get_error().isEmpty()); } TEST(CodecFFmpegEncoder, EncodePngVideoAndProbeBack) @@ -68,19 +68,19 @@ TEST(CodecFFmpegEncoder, EncodePngVideoAndProbeBack) const int frame_count = 5; olive::EncodingParams params; - params.SetFilename(path); - olive::VideoParams video_params(width, height, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - video_params.set_frame_rate(olive::core::rational(30, 1)); - params.EnableVideo(video_params, olive::ExportCodec::kCodecPNG); + params.set_filename(path); + olive::VideoParams video_params(width, height, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + video_params.set_frame_rate(olive::core::Rational(30, 1)); + params.enable_video(video_params, olive::ExportCodec::k_codec_png); params.set_video_pix_fmt(QStringLiteral("rgba")); olive::FFmpegEncoder encoder(params); - ASSERT_TRUE(encoder.Open()) << encoder.GetError().toStdString(); - EXPECT_EQ(encoder.GetDesiredPixelFormat(), olive::core::PixelFormat::U8); + ASSERT_TRUE(encoder.open()) << encoder.get_error().toStdString(); + EXPECT_EQ(encoder.get_desired_pixel_format(), olive::core::PixelFormat::u8); for (int f = 0; f < frame_count; f++) { - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(video_params); ASSERT_TRUE(frame->allocate()); for (int i = 0; i < width * height; i++) { @@ -90,10 +90,10 @@ TEST(CodecFFmpegEncoder, EncodePngVideoAndProbeBack) px[2] = 64; px[3] = 255; } - ASSERT_TRUE(encoder.WriteFrame(frame, olive::core::rational(f, 30))) - << encoder.GetError().toStdString(); + ASSERT_TRUE(encoder.write_frame(frame, olive::core::Rational(f, 30))) + << encoder.get_error().toStdString(); } - encoder.Close(); + encoder.close(); // The file must exist and probe back as a 64x64 video ASSERT_TRUE(QFileInfo::exists(path)); @@ -107,7 +107,7 @@ TEST(CodecFFmpegEncoder, EncodePngVideoAndProbeBack) for (int i = 0; i < stream_count; i++) { FBStreamInfo info; if (fb_probe_get_stream_info(probe, i, &info) == 0 && - info.codec_type == FB_MEDIA_TYPE_VIDEO) { + info.codec_type == fb_media_type_video) { found_video = true; EXPECT_EQ(info.width, width); EXPECT_EQ(info.height, height); diff --git a/tests/gtest/codec_frame_test.cpp b/tests/gtest/codec_frame_test.cpp index 3e1938616..eceff1166 100644 --- a/tests/gtest/codec_frame_test.cpp +++ b/tests/gtest/codec_frame_test.cpp @@ -7,17 +7,17 @@ TEST(CodecFrame, DefaultState) olive::Frame frame; EXPECT_EQ(frame.width(), 0); EXPECT_EQ(frame.height(), 0); - EXPECT_EQ(frame.format(), olive::core::PixelFormat::INVALID); + EXPECT_EQ(frame.format(), olive::core::PixelFormat::invalid); EXPECT_FALSE(frame.is_allocated()); EXPECT_EQ(frame.data(), nullptr); } TEST(CodecFrame, CreateAllocatesForParams) { - olive::VideoParams params(64, 32, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + olive::VideoParams params(64, 32, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(params); frame->allocate(); @@ -25,15 +25,15 @@ TEST(CodecFrame, CreateAllocatesForParams) EXPECT_NE(frame->data(), nullptr); EXPECT_EQ(frame->width(), 64); EXPECT_EQ(frame->height(), 32); - EXPECT_EQ(frame->format(), olive::core::PixelFormat::U8); + EXPECT_EQ(frame->format(), olive::core::PixelFormat::u8); } TEST(CodecFrame, AllocateMatchesLineSize) { - olive::VideoParams params(64, 32, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + olive::VideoParams params(64, 32, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(params); frame->allocate(); @@ -43,10 +43,10 @@ TEST(CodecFrame, AllocateMatchesLineSize) TEST(CodecFrame, DestroyDeallocatesData) { - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params( - olive::VideoParams(8, 8, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(8, 8, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); frame->allocate(); EXPECT_TRUE(frame->is_allocated()); @@ -63,9 +63,9 @@ TEST(CodecFrame, AllocateInvalidParamsFails) TEST(CodecFrame, DoubleAllocateReturnsTrue) { - olive::VideoParams params(8, 8, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::FramePtr frame = olive::Frame::Create(); + olive::VideoParams params(8, 8, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(params); EXPECT_TRUE(frame->allocate()); EXPECT_TRUE(frame->allocate()); @@ -73,9 +73,9 @@ TEST(CodecFrame, DoubleAllocateReturnsTrue) TEST(CodecFrame, ContainsPixel) { - olive::VideoParams params(8, 8, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::FramePtr frame = olive::Frame::Create(); + olive::VideoParams params(8, 8, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(params); EXPECT_FALSE(frame->contains_pixel(0, 0)); @@ -90,9 +90,9 @@ TEST(CodecFrame, ContainsPixel) TEST(CodecFrame, GetPixelOutOfBoundsReturnsBlack) { - olive::VideoParams params(8, 8, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::FramePtr frame = olive::Frame::Create(); + olive::VideoParams params(8, 8, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(params); frame->allocate(); @@ -102,9 +102,9 @@ TEST(CodecFrame, GetPixelOutOfBoundsReturnsBlack) TEST(CodecFrame, SetAndGetPixel) { - olive::VideoParams params(8, 8, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::FramePtr frame = olive::Frame::Create(); + olive::VideoParams params(8, 8, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(params); frame->allocate(); @@ -119,35 +119,35 @@ TEST(CodecFrame, SetAndGetPixel) TEST(CodecFrame, TimestampRoundTrip) { - olive::FramePtr frame = olive::Frame::Create(); - frame->set_timestamp(olive::core::rational(5, 1)); - EXPECT_EQ(frame->timestamp(), olive::core::rational(5, 1)); + olive::FramePtr frame = olive::Frame::create(); + frame->set_timestamp(olive::core::Rational(5, 1)); + EXPECT_EQ(frame->timestamp(), olive::core::Rational(5, 1)); } TEST(CodecFrame, GenerateLineSizeBytes) { EXPECT_EQ(olive::Frame::generate_linesize_bytes( - 64, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount), + 64, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count), 64 * 4); } TEST(CodecFrame, InterlaceFrames) { - olive::VideoParams params(4, 4, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + olive::VideoParams params(4, 4, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - olive::FramePtr top = olive::Frame::Create(); + olive::FramePtr top = olive::Frame::create(); top->set_video_params(params); top->allocate(); memset(top->data(), 0xFF, top->allocated_size()); - olive::FramePtr bottom = olive::Frame::Create(); + olive::FramePtr bottom = olive::Frame::create(); bottom->set_video_params(params); bottom->allocate(); memset(bottom->data(), 0x00, bottom->allocated_size()); - olive::FramePtr interlaced = olive::Frame::Interlace(top, bottom); + olive::FramePtr interlaced = olive::Frame::interlace(top, bottom); ASSERT_NE(interlaced, nullptr); EXPECT_EQ(interlaced->width(), 4); EXPECT_EQ(interlaced->height(), 4); @@ -155,32 +155,32 @@ TEST(CodecFrame, InterlaceFrames) TEST(CodecFrame, InterlaceIncompatibleReturnsNull) { - olive::FramePtr top = olive::Frame::Create(); + olive::FramePtr top = olive::Frame::create(); top->set_video_params( - olive::VideoParams(4, 4, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(4, 4, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); top->allocate(); - olive::FramePtr bottom = olive::Frame::Create(); + olive::FramePtr bottom = olive::Frame::create(); bottom->set_video_params( - olive::VideoParams(8, 8, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(8, 8, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); bottom->allocate(); - EXPECT_EQ(olive::Frame::Interlace(top, bottom), nullptr); + EXPECT_EQ(olive::Frame::interlace(top, bottom), nullptr); } TEST(CodecFrame, ConvertU8ToU16) { - olive::VideoParams params(4, 4, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::FramePtr frame = olive::Frame::Create(); + olive::VideoParams params(4, 4, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(params); frame->allocate(); - olive::FramePtr converted = frame->convert(olive::core::PixelFormat::U16); + olive::FramePtr converted = frame->convert(olive::core::PixelFormat::u16); ASSERT_NE(converted, nullptr); - EXPECT_EQ(converted->format(), olive::core::PixelFormat::U16); + EXPECT_EQ(converted->format(), olive::core::PixelFormat::u16); EXPECT_EQ(converted->width(), 4); EXPECT_EQ(converted->height(), 4); } diff --git a/tests/gtest/codec_oiio_test.cpp b/tests/gtest/codec_oiio_test.cpp index e51262621..61c37aa80 100644 --- a/tests/gtest/codec_oiio_test.cpp +++ b/tests/gtest/codec_oiio_test.cpp @@ -11,7 +11,7 @@ namespace { -QString ImgPath() +QString img_path() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/img.png")); @@ -21,19 +21,19 @@ QString ImgPath() TEST(CodecOIIO, ProbePngReportsStillImage) { olive::OIIODecoder decoder; - olive::FootageDescription desc = decoder.Probe(ImgPath(), nullptr); + olive::FootageDescription desc = decoder.probe(img_path(), nullptr); - ASSERT_TRUE(desc.IsValid()); + ASSERT_TRUE(desc.is_valid()); EXPECT_EQ(desc.decoder(), QStringLiteral("oiio")); - EXPECT_EQ(desc.GetStreamCount(), 1); + EXPECT_EQ(desc.get_stream_count(), 1); - const QVector &streams = desc.GetVideoStreams(); + const QVector &streams = desc.get_video_streams(); ASSERT_EQ(streams.size(), 1); EXPECT_EQ(streams.first().width(), 1920); EXPECT_EQ(streams.first().height(), 1080); - EXPECT_EQ(streams.first().format(), olive::core::PixelFormat::U8); + EXPECT_EQ(streams.first().format(), olive::core::PixelFormat::u8); EXPECT_EQ(streams.first().channel_count(), 4); - EXPECT_EQ(streams.first().video_type(), olive::VideoParams::kVideoTypeStill); + EXPECT_EQ(streams.first().video_type(), olive::VideoParams::k_video_type_still); EXPECT_EQ(streams.first().stream_index(), 0); EXPECT_TRUE(streams.first().enabled()); } @@ -42,36 +42,36 @@ TEST(CodecOIIO, ProbeUnsupportedExtensionReturnsInvalid) { olive::OIIODecoder decoder; olive::FootageDescription desc = - decoder.Probe(QStringLiteral("nonexistent.zzz"), nullptr); + decoder.probe(QStringLiteral("nonexistent.zzz"), nullptr); - EXPECT_FALSE(desc.IsValid()); - EXPECT_TRUE(desc.GetVideoStreams().isEmpty()); + EXPECT_FALSE(desc.is_valid()); + EXPECT_TRUE(desc.get_video_streams().isEmpty()); } TEST(CodecOIIO, DecodePngFrame) { - const QString path = ImgPath(); + const QString path = img_path(); ASSERT_TRUE(QFileInfo::exists(path)); olive::DecoderPtr decoder = - olive::Decoder::CreateFromID(QStringLiteral("oiio")); + olive::Decoder::create_from_id(QStringLiteral("oiio")); ASSERT_TRUE(decoder); - ASSERT_TRUE(decoder->Open(olive::Decoder::CodecStream(path, 0, nullptr))); + ASSERT_TRUE(decoder->open(olive::Decoder::CodecStream(path, 0, nullptr))); olive::Decoder::RetrieveVideoParams params; - params.time = olive::core::rational(0); + params.time = olive::core::Rational(0); params.divider = 1; - olive::FramePtr frame = decoder->RetrieveVideoFrame(params); + olive::FramePtr frame = decoder->retrieve_video_frame(params); ASSERT_TRUE(frame); ASSERT_TRUE(frame->is_allocated()); EXPECT_EQ(frame->width(), 1920); EXPECT_EQ(frame->height(), 1080); // Still images are always converted to F32 by OIIODecoder - EXPECT_EQ(frame->format(), olive::core::PixelFormat::F32); + EXPECT_EQ(frame->format(), olive::core::PixelFormat::f32); EXPECT_EQ(frame->channel_count(), 4); - EXPECT_EQ(frame->timestamp(), olive::core::rational(0)); + EXPECT_EQ(frame->timestamp(), olive::core::Rational(0)); EXPECT_GT(frame->allocated_size(), 0); bool has_nonzero_byte = false; @@ -84,29 +84,29 @@ TEST(CodecOIIO, DecodePngFrame) } EXPECT_TRUE(has_nonzero_byte); - decoder->Close(); + decoder->close(); } TEST(CodecOIIO, DecodeWithDividerHalvesResolution) { olive::DecoderPtr decoder = - olive::Decoder::CreateFromID(QStringLiteral("oiio")); + olive::Decoder::create_from_id(QStringLiteral("oiio")); ASSERT_TRUE(decoder); ASSERT_TRUE( - decoder->Open(olive::Decoder::CodecStream(ImgPath(), 0, nullptr))); + decoder->open(olive::Decoder::CodecStream(img_path(), 0, nullptr))); olive::Decoder::RetrieveVideoParams params; - params.time = olive::core::rational(0); + params.time = olive::core::Rational(0); params.divider = 2; - olive::FramePtr frame = decoder->RetrieveVideoFrame(params); + olive::FramePtr frame = decoder->retrieve_video_frame(params); ASSERT_TRUE(frame); ASSERT_TRUE(frame->is_allocated()); EXPECT_EQ(frame->width(), 960); EXPECT_EQ(frame->height(), 540); - decoder->Close(); + decoder->close(); } TEST(CodecOIIO, EncodePngAndDecodeBack) @@ -119,16 +119,16 @@ TEST(CodecOIIO, EncodePngAndDecodeBack) const int height = 32; olive::EncodingParams params; - params.SetFilename(path); - params.EnableVideo( - olive::VideoParams(width, height, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount), - olive::ExportCodec::kCodecPNG); + params.set_filename(path); + params.enable_video( + olive::VideoParams(width, height, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count), + olive::ExportCodec::k_codec_png); olive::OIIOEncoder encoder(params); - ASSERT_TRUE(encoder.Open()); + ASSERT_TRUE(encoder.open()); - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(params.video_params()); ASSERT_TRUE(frame->allocate()); for (int y = 0; y < height; y++) { @@ -142,22 +142,22 @@ TEST(CodecOIIO, EncodePngAndDecodeBack) } } - EXPECT_TRUE(encoder.WriteFrame(frame, olive::core::rational(0))); - encoder.Close(); + EXPECT_TRUE(encoder.write_frame(frame, olive::core::Rational(0))); + encoder.close(); ASSERT_TRUE(QFileInfo::exists(path)); // Decode the file we just wrote and verify dimensions and pixels olive::DecoderPtr decoder = - olive::Decoder::CreateFromID(QStringLiteral("oiio")); + olive::Decoder::create_from_id(QStringLiteral("oiio")); ASSERT_TRUE(decoder); - ASSERT_TRUE(decoder->Open(olive::Decoder::CodecStream(path, 0, nullptr))); + ASSERT_TRUE(decoder->open(olive::Decoder::CodecStream(path, 0, nullptr))); olive::Decoder::RetrieveVideoParams rp; - rp.time = olive::core::rational(0); + rp.time = olive::core::Rational(0); rp.divider = 1; - olive::FramePtr back = decoder->RetrieveVideoFrame(rp); + olive::FramePtr back = decoder->retrieve_video_frame(rp); ASSERT_TRUE(back); EXPECT_EQ(back->width(), width); EXPECT_EQ(back->height(), height); @@ -170,7 +170,7 @@ TEST(CodecOIIO, EncodePngAndDecodeBack) EXPECT_NEAR(c.blue(), 200.0f / 255.0f, eps); EXPECT_NEAR(c.alpha(), 1.0f, eps); - decoder->Close(); + decoder->close(); } TEST(CodecOIIO, EncoderRejectsAudioAndSubtitles) @@ -179,6 +179,6 @@ TEST(CodecOIIO, EncoderRejectsAudioAndSubtitles) olive::OIIOEncoder encoder(params); olive::SampleBuffer buffer; - EXPECT_FALSE(encoder.WriteAudio(buffer)); - EXPECT_FALSE(encoder.WriteSubtitle(nullptr)); + EXPECT_FALSE(encoder.write_audio(buffer)); + EXPECT_FALSE(encoder.write_subtitle(nullptr)); } diff --git a/tests/gtest/color_lut_test.cpp b/tests/gtest/color_lut_test.cpp index 452f705d4..d898818f3 100644 --- a/tests/gtest/color_lut_test.cpp +++ b/tests/gtest/color_lut_test.cpp @@ -20,12 +20,12 @@ #include "render/colorprocessor.h" #include "render/lutlibrary.h" -namespace OCIO = OCIO_NAMESPACE; +namespace ocio = OCIO_NAMESPACE; namespace { -QString WriteTestCube(QTemporaryDir *dir) +QString write_test_cube(QTemporaryDir *dir) { const QString path = QDir(dir->path()).filePath(QStringLiteral("invert.cube")); @@ -49,16 +49,16 @@ QString WriteTestCube(QTemporaryDir *dir) // into real frames so we can compare pixels without a GPU/worker process. class PixelColorTransformTraverser : public olive::NodeTraverser { public: - void Resolve(olive::NodeValue &value) + void resolve(olive::NodeValue &value) { - ResolveJobs(value); + resolve_jobs(value); } olive::FramePtr source_frame; olive::FramePtr output_frame; protected: - virtual void ProcessShader(olive::TexturePtr destination, + virtual void process_shader(olive::TexturePtr destination, const olive::Node *node, const olive::ShaderJob *job) override { @@ -66,13 +66,13 @@ protected: Q_UNUSED(node) const olive::Color c = - job->GetValues().value(olive::SolidGenerator::kColorInput).toColor(); + job->get_values().value(olive::SolidGenerator::k_color_input).to_color(); olive::VideoParams p = destination->params(); - p.set_format(olive::core::PixelFormat::F32); - p.set_channel_count(olive::VideoParams::kRGBAChannelCount); + p.set_format(olive::core::PixelFormat::f32); + p.set_channel_count(olive::VideoParams::k_rgba_channel_count); - source_frame = olive::Frame::Create(); + source_frame = olive::Frame::create(); source_frame->set_video_params(p); source_frame->allocate(); @@ -84,30 +84,30 @@ protected: } virtual void - ProcessColorTransform(olive::TexturePtr destination, + process_color_transform(olive::TexturePtr destination, const olive::Node *node, const olive::ColorTransformJob *job) override { Q_UNUSED(destination) Q_UNUSED(node) - olive::ColorProcessorPtr processor = job->GetColorProcessor(); + olive::ColorProcessorPtr processor = job->get_color_processor(); if (!processor || !source_frame) { return; } - output_frame = olive::Frame::Create(); + output_frame = olive::Frame::create(); output_frame->set_video_params(source_frame->video_params()); output_frame->allocate(); std::memcpy(output_frame->data(), source_frame->const_data(), source_frame->allocated_size()); - processor->ConvertFrame(output_frame); + processor->convert_frame(output_frame); } }; -QString WriteTestCubeLut(QTemporaryDir *dir, const char *title, float low, +QString write_test_cube_lut(QTemporaryDir *dir, const char *title, float low, float high) { const QString path = @@ -136,7 +136,7 @@ QString WriteTestCubeLut(QTemporaryDir *dir, const char *title, float low, // 1.0 -> 1.00 // Forward: (0.25, 0.50, 0.75) -> (0.375, 0.750, 0.875) // Inverse: (0.25, 0.50, 0.75) -> (0.167, 0.333, 0.500) -QString WriteAsymmetricCube(QTemporaryDir *dir) +QString write_asymmetric_cube(QTemporaryDir *dir) { const QString path = QDir(dir->path()).filePath(QStringLiteral("asymmetric.cube")); @@ -161,34 +161,34 @@ QString WriteAsymmetricCube(QTemporaryDir *dir) TEST(ColorProcessor, CreateFromInvalidTransformThrows) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); - OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create(); + ocio::FileTransformRcPtr transform = ocio::FileTransform::Create(); transform->setSrc("/nonexistent/lut.cube"); - transform->setInterpolation(OCIO::INTERP_LINEAR); - transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD); + transform->setInterpolation(ocio::INTERP_LINEAR); + transform->setDirection(ocio::TRANSFORM_DIR_FORWARD); // A FileTransform pointing at a missing LUT makes OCIO throw while // resolving the processor, before ColorProcessor is even constructed. - EXPECT_THROW(olive::ColorProcessor::Create( - olive::ColorManager::GetDefaultConfig()->getProcessor( + EXPECT_THROW(olive::ColorProcessor::create( + olive::ColorManager::get_default_config()->getProcessor( transform)), - OCIO::Exception); + ocio::Exception); } TEST(ColorProcessor, ConvertColorWithIdentityProcessor) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); - OCIO::MatrixTransformRcPtr transform = OCIO::MatrixTransform::Create(); - transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD); + ocio::MatrixTransformRcPtr transform = ocio::MatrixTransform::Create(); + transform->setDirection(ocio::TRANSFORM_DIR_FORWARD); - olive::ColorProcessorPtr processor = olive::ColorProcessor::Create( - olive::ColorManager::GetDefaultConfig()->getProcessor(transform)); + olive::ColorProcessorPtr processor = olive::ColorProcessor::create( + olive::ColorManager::get_default_config()->getProcessor(transform)); ASSERT_NE(processor, nullptr); const olive::Color in(0.25f, 0.50f, 0.75f, 1.0f); - const olive::Color out = processor->ConvertColor(in); + const olive::Color out = processor->convert_color(in); EXPECT_NEAR(out.red(), in.red(), 0.001f); EXPECT_NEAR(out.green(), in.green(), 0.001f); @@ -200,21 +200,21 @@ TEST(ColorLut, CubeFileTransformConvertsColor) { QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString path = WriteTestCube(&dir); + const QString path = write_test_cube(&dir); ASSERT_FALSE(path.isEmpty()); - OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create(); + ocio::FileTransformRcPtr transform = ocio::FileTransform::Create(); transform->setSrc(path.toUtf8().constData()); - transform->setInterpolation(OCIO::INTERP_LINEAR); - transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD); + transform->setInterpolation(ocio::INTERP_LINEAR); + transform->setDirection(ocio::TRANSFORM_DIR_FORWARD); - OCIO::ConstConfigRcPtr config = OCIO::Config::CreateRaw(); + ocio::ConstConfigRcPtr config = ocio::Config::CreateRaw(); olive::ColorProcessorPtr processor = - olive::ColorProcessor::Create(config->getProcessor(transform)); + olive::ColorProcessor::create(config->getProcessor(transform)); ASSERT_TRUE(processor); const olive::Color out = - processor->ConvertColor(olive::Color(0.25f, 0.50f, 0.75f, 1.0f)); + processor->convert_color(olive::Color(0.25f, 0.50f, 0.75f, 1.0f)); EXPECT_NEAR(out.red(), 0.75f, 0.02f); EXPECT_NEAR(out.green(), 0.50f, 0.02f); EXPECT_NEAR(out.blue(), 0.25f, 0.02f); @@ -223,27 +223,27 @@ TEST(ColorLut, CubeFileTransformConvertsColor) TEST(ColorV04, FactoryCreatesColorNodes) { - std::unique_ptr lut(olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kOCIOLut)); + std::unique_ptr lut(olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_ocio_lut)); ASSERT_NE(lut, nullptr); EXPECT_EQ(lut->id(), QStringLiteral("org.olivevideoeditor.Olive.ociolut")); std::unique_ptr three_way( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kThreeWayColor)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_three_way_color)); ASSERT_NE(three_way, nullptr); EXPECT_EQ(three_way->id(), QStringLiteral("org.olivevideoeditor.Olive.threewaycolor")); - EXPECT_TRUE(three_way->HasInputWithID( - olive::ThreeWayColorNode::kShadowsColorInput)); - EXPECT_TRUE(three_way->HasInputWithID( - olive::ThreeWayColorNode::kMidtonesColorInput)); - EXPECT_TRUE(three_way->HasInputWithID( - olive::ThreeWayColorNode::kHighlightsColorInput)); + EXPECT_TRUE(three_way->has_input_with_id( + olive::ThreeWayColorNode::k_shadows_color_input)); + EXPECT_TRUE(three_way->has_input_with_id( + olive::ThreeWayColorNode::k_midtones_color_input)); + EXPECT_TRUE(three_way->has_input_with_id( + olive::ThreeWayColorNode::k_highlights_color_input)); const olive::Color neutral = three_way - ->GetStandardValue(olive::ThreeWayColorNode::kMidtonesColorInput) + ->get_standard_value(olive::ThreeWayColorNode::k_midtones_color_input) .value(); EXPECT_FLOAT_EQ(neutral.red(), 0.5f); EXPECT_FLOAT_EQ(neutral.green(), 0.5f); @@ -264,41 +264,41 @@ TEST(ColorV04, FactoryCreatesColorNodes) TEST(ColorLutNode, ForwardDirectionInvertsPixels) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString path = WriteTestCubeLut(&dir, "invert", 0.0f, 1.0f); + const QString path = write_test_cube_lut(&dir, "invert", 0.0f, 1.0f); ASSERT_FALSE(path.isEmpty()); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, path); - lut->SetStandardValue(olive::OCIOLutNode::kDirectionInput, 0); // Forward + lut->set_standard_value(olive::OCIOLutNode::k_file_input, path); + lut->set_standard_value(olive::OCIOLutNode::k_direction_input, 0); // Forward - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); + traverser.set_cache_video_params(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - traverser.Resolve(tex_val); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + traverser.resolve(tex_val); ASSERT_TRUE(traverser.output_frame); const olive::Color out = traverser.output_frame->get_pixel(0, 0); @@ -311,41 +311,41 @@ TEST(ColorLutNode, ForwardDirectionInvertsPixels) TEST(ColorLutNode, InverseDirectionReversesForwardTransform) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString path = WriteTestCubeLut(&dir, "invert", 0.0f, 1.0f); + const QString path = write_test_cube_lut(&dir, "invert", 0.0f, 1.0f); ASSERT_FALSE(path.isEmpty()); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.75f, 0.50f, 0.25f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, path); - lut->SetStandardValue(olive::OCIOLutNode::kDirectionInput, 1); // Inverse + lut->set_standard_value(olive::OCIOLutNode::k_file_input, path); + lut->set_standard_value(olive::OCIOLutNode::k_direction_input, 1); // Inverse - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); + traverser.set_cache_video_params(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - traverser.Resolve(tex_val); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + traverser.resolve(tex_val); ASSERT_TRUE(traverser.output_frame); const olive::Color out = traverser.output_frame->get_pixel(0, 0); @@ -358,42 +358,42 @@ TEST(ColorLutNode, InverseDirectionReversesForwardTransform) TEST(ColorLutNode, SwitchingDirectionUpdatesProcessorAndPixels) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString path = WriteAsymmetricCube(&dir); + const QString path = write_asymmetric_cube(&dir); ASSERT_FALSE(path.isEmpty()); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, path); - lut->SetStandardValue(olive::OCIOLutNode::kDirectionInput, 0); // Forward + lut->set_standard_value(olive::OCIOLutNode::k_file_input, path); + lut->set_standard_value(olive::OCIOLutNode::k_direction_input, 0); // Forward - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); // First render: forward direction. PixelColorTransformTraverser forward_traverser; - forward_traverser.SetCacheVideoParams(params); - olive::NodeValueTable forward_table = forward_traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); + forward_traverser.set_cache_video_params(params); + olive::NodeValueTable forward_table = forward_traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); olive::NodeValue forward_tex = - forward_table.Get(olive::NodeValue::kTexture); - forward_traverser.Resolve(forward_tex); + forward_table.get(olive::NodeValue::k_texture); + forward_traverser.resolve(forward_tex); ASSERT_TRUE(forward_traverser.output_frame); const olive::Color forward_out = @@ -404,16 +404,16 @@ TEST(ColorLutNode, SwitchingDirectionUpdatesProcessorAndPixels) // Switch direction. Before the Value()/EnsureProcessor() fix, the node // would keep using the old forward processor. - lut->SetStandardValue(olive::OCIOLutNode::kDirectionInput, 1); // Inverse + lut->set_standard_value(olive::OCIOLutNode::k_direction_input, 1); // Inverse PixelColorTransformTraverser inverse_traverser; - inverse_traverser.SetCacheVideoParams(params); - olive::NodeValueTable inverse_table = inverse_traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); + inverse_traverser.set_cache_video_params(params); + olive::NodeValueTable inverse_table = inverse_traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); olive::NodeValue inverse_tex = - inverse_table.Get(olive::NodeValue::kTexture); - inverse_traverser.Resolve(inverse_tex); + inverse_table.get(olive::NodeValue::k_texture); + inverse_traverser.resolve(inverse_tex); ASSERT_TRUE(inverse_traverser.output_frame); const olive::Color inverse_out = @@ -432,144 +432,144 @@ TEST(ColorLutNode, SwitchingDirectionUpdatesProcessorAndPixels) TEST(ColorLutNode, EmptyFilePathLeavesProcessorNull) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, QString()); + lut->set_standard_value(olive::OCIOLutNode::k_file_input, QString()); - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); // With an empty LUT path, the node should pass the input texture through // without producing a color-transform job. - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - EXPECT_EQ(tex_val.type(), olive::NodeValue::kTexture); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + EXPECT_EQ(tex_val.type(), olive::NodeValue::k_texture); } TEST(ColorLutNode, MissingFilePathLeavesProcessorNull) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, + lut->set_standard_value(olive::OCIOLutNode::k_file_input, QStringLiteral("/nonexistent/path/lut.cube")); - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - EXPECT_EQ(tex_val.type(), olive::NodeValue::kTexture); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + EXPECT_EQ(tex_val.type(), olive::NodeValue::k_texture); } TEST(ColorLutNode, UnsupportedExtensionLeavesProcessorNull) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, + lut->set_standard_value(olive::OCIOLutNode::k_file_input, QStringLiteral("/tmp/lut.txt")); - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - EXPECT_EQ(tex_val.type(), olive::NodeValue::kTexture); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + EXPECT_EQ(tex_val.type(), olive::NodeValue::k_texture); } TEST(ColorLutNode, DirectionStringValuesAreAccepted) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString path = WriteTestCubeLut(&dir, "invert", 0.0f, 1.0f); + const QString path = write_test_cube_lut(&dir, "invert", 0.0f, 1.0f); ASSERT_FALSE(path.isEmpty()); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, path); - lut->SetStandardValue(olive::OCIOLutNode::kDirectionInput, + lut->set_standard_value(olive::OCIOLutNode::k_file_input, path); + lut->set_standard_value(olive::OCIOLutNode::k_direction_input, QStringLiteral("forward")); - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - traverser.Resolve(tex_val); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + traverser.resolve(tex_val); ASSERT_TRUE(traverser.output_frame); const olive::Color out = traverser.output_frame->get_pixel(0, 0); @@ -581,41 +581,41 @@ TEST(ColorLutNode, DirectionStringValuesAreAccepted) TEST(ColorLutNode, DirectionStringInverseIsAccepted) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString path = WriteTestCubeLut(&dir, "invert", 0.0f, 1.0f); + const QString path = write_test_cube_lut(&dir, "invert", 0.0f, 1.0f); ASSERT_FALSE(path.isEmpty()); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.75f, 0.50f, 0.25f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, path); - lut->SetStandardValue(olive::OCIOLutNode::kDirectionInput, + lut->set_standard_value(olive::OCIOLutNode::k_file_input, path); + lut->set_standard_value(olive::OCIOLutNode::k_direction_input, QStringLiteral("inverse")); - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - traverser.Resolve(tex_val); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + traverser.resolve(tex_val); ASSERT_TRUE(traverser.output_frame); const olive::Color out = traverser.output_frame->get_pixel(0, 0); @@ -627,41 +627,41 @@ TEST(ColorLutNode, DirectionStringInverseIsAccepted) TEST(ColorLutNode, ReusingSameFileDoesNotCrash) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString path = WriteTestCubeLut(&dir, "invert", 0.0f, 1.0f); + const QString path = write_test_cube_lut(&dir, "invert", 0.0f, 1.0f); ASSERT_FALSE(path.isEmpty()); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, path); + lut->set_standard_value(olive::OCIOLutNode::k_file_input, path); - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); // Render twice; the second render should reuse the cached processor. for (int i = 0; i < 2; ++i) { PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - traverser.Resolve(tex_val); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + traverser.resolve(tex_val); ASSERT_TRUE(traverser.output_frame); const olive::Color out = traverser.output_frame->get_pixel(0, 0); @@ -673,43 +673,43 @@ TEST(ColorLutNode, ReusingSameFileDoesNotCrash) TEST(ColorLutNode, SwitchingBackToOriginalFileRestoresOriginalPixels) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString invert_path = WriteTestCubeLut(&dir, "invert", 0.0f, 1.0f); - const QString boost_path = WriteTestCubeLut(&dir, "boost", 0.5f, 1.0f); + const QString invert_path = write_test_cube_lut(&dir, "invert", 0.0f, 1.0f); + const QString boost_path = write_test_cube_lut(&dir, "boost", 0.5f, 1.0f); ASSERT_FALSE(invert_path.isEmpty()); ASSERT_FALSE(boost_path.isEmpty()); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, invert_path); + lut->set_standard_value(olive::OCIOLutNode::k_file_input, invert_path); - olive::Node::ConnectEdge( - solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput)); + olive::Node::connect_edge( + solid, olive::NodeInput(lut, olive::OCIOLutNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); auto render = [&]() { PixelColorTransformTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - lut, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - traverser.Resolve(tex_val); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + lut, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + traverser.resolve(tex_val); return traverser.output_frame->get_pixel(0, 0); }; @@ -718,11 +718,11 @@ TEST(ColorLutNode, SwitchingBackToOriginalFileRestoresOriginalPixels) EXPECT_NEAR(invert_out.red(), 0.75f, 0.02f); // Switch to boost, then back to invert. - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, boost_path); + lut->set_standard_value(olive::OCIOLutNode::k_file_input, boost_path); const olive::Color boost_out = render(); EXPECT_GT(std::abs(boost_out.red() - invert_out.red()), 0.1f); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, invert_path); + lut->set_standard_value(olive::OCIOLutNode::k_file_input, invert_path); const olive::Color restored_out = render(); EXPECT_NEAR(restored_out.red(), invert_out.red(), 0.02f); EXPECT_NEAR(restored_out.green(), invert_out.green(), 0.02f); @@ -735,14 +735,14 @@ TEST(ColorLutNode, SwitchingBackToOriginalFileRestoresOriginalPixels) TEST(ColorLutNode, MissingFileSetsLastError) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, + lut->set_standard_value(olive::OCIOLutNode::k_file_input, QStringLiteral("/nonexistent/path/lut.cube")); EXPECT_FALSE(lut->last_error().isEmpty()); @@ -750,10 +750,10 @@ TEST(ColorLutNode, MissingFileSetsLastError) TEST(ColorLutNode, UnsupportedExtensionSetsLastError) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); @@ -764,49 +764,49 @@ TEST(ColorLutNode, UnsupportedExtensionSetsLastError) auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, path); + lut->set_standard_value(olive::OCIOLutNode::k_file_input, path); EXPECT_FALSE(lut->last_error().isEmpty()); } TEST(ColorLutNode, ValidFileClearsLastError) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString path = WriteTestCubeLut(&dir, "invert", 0.0f, 1.0f); + const QString path = write_test_cube_lut(&dir, "invert", 0.0f, 1.0f); ASSERT_FALSE(path.isEmpty()); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, + lut->set_standard_value(olive::OCIOLutNode::k_file_input, QStringLiteral("/nonexistent/path/lut.cube")); EXPECT_FALSE(lut->last_error().isEmpty()); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, path); + lut->set_standard_value(olive::OCIOLutNode::k_file_input, path); EXPECT_TRUE(lut->last_error().isEmpty()); } TEST(ColorLutNode, EmptyPathClearsLastError) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *lut = new olive::OCIOLutNode(); lut->setParent(&project); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, + lut->set_standard_value(olive::OCIOLutNode::k_file_input, QStringLiteral("/nonexistent/path/lut.cube")); EXPECT_FALSE(lut->last_error().isEmpty()); - lut->SetStandardValue(olive::OCIOLutNode::kFileInput, QString()); + lut->set_standard_value(olive::OCIOLutNode::k_file_input, QString()); EXPECT_TRUE(lut->last_error().isEmpty()); } @@ -816,36 +816,36 @@ TEST(ColorLutNode, EmptyPathClearsLastError) TEST(LUTLibrary, SupportsCubeAnd3dlExtensions) { - EXPECT_TRUE(olive::LUTLibrary::IsSupportedExtension(QStringLiteral("cube"))); + EXPECT_TRUE(olive::LUTLibrary::is_supported_extension(QStringLiteral("cube"))); EXPECT_TRUE( - olive::LUTLibrary::IsSupportedExtension(QStringLiteral(".cube"))); - EXPECT_TRUE(olive::LUTLibrary::IsSupportedExtension(QStringLiteral("CUBE"))); - EXPECT_TRUE(olive::LUTLibrary::IsSupportedExtension(QStringLiteral("3dl"))); - EXPECT_TRUE(olive::LUTLibrary::IsSupportedExtension(QStringLiteral(".3dl"))); - EXPECT_FALSE(olive::LUTLibrary::IsSupportedExtension(QStringLiteral("txt"))); - EXPECT_FALSE(olive::LUTLibrary::IsSupportedExtension(QString())); + olive::LUTLibrary::is_supported_extension(QStringLiteral(".cube"))); + EXPECT_TRUE(olive::LUTLibrary::is_supported_extension(QStringLiteral("CUBE"))); + EXPECT_TRUE(olive::LUTLibrary::is_supported_extension(QStringLiteral("3dl"))); + EXPECT_TRUE(olive::LUTLibrary::is_supported_extension(QStringLiteral(".3dl"))); + EXPECT_FALSE(olive::LUTLibrary::is_supported_extension(QStringLiteral("txt"))); + EXPECT_FALSE(olive::LUTLibrary::is_supported_extension(QString())); } TEST(LUTLibrary, DirectoryRoundTripCleansAndDeduplicates) { const QString previous = - olive::Config::Current()[QStringLiteral("LUTLibraryPaths")].toString(); + olive::Config::current()[QStringLiteral("LUTLibraryPaths")].toString(); - olive::LUTLibrary::SetDirectories( + olive::LUTLibrary::set_directories( { QStringLiteral("/a/luts"), QStringLiteral(" /a/luts "), QStringLiteral("/b/luts"), QString() }); - EXPECT_EQ(olive::LUTLibrary::GetDirectories(), + EXPECT_EQ(olive::LUTLibrary::get_directories(), (QStringList{ QStringLiteral("/a/luts"), QStringLiteral("/b/luts") })); - olive::Config::Current()[QStringLiteral("LUTLibraryPaths")] = previous; + olive::Config::current()[QStringLiteral("LUTLibraryPaths")] = previous; } TEST(LUTLibrary, ScansDirectoriesRecursivelyForSupportedLuts) { const QString previous = - olive::Config::Current()[QStringLiteral("LUTLibraryPaths")].toString(); + olive::Config::current()[QStringLiteral("LUTLibraryPaths")].toString(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); @@ -865,15 +865,15 @@ TEST(LUTLibrary, ScansDirectoriesRecursivelyForSupportedLuts) file.close(); } - olive::LUTLibrary::SetDirectories({ dir.path() }); + olive::LUTLibrary::set_directories({ dir.path() }); - const QStringList files = olive::LUTLibrary::GetLutFiles(); + const QStringList files = olive::LUTLibrary::get_lut_files(); EXPECT_EQ(files.size(), 2); EXPECT_TRUE(files.contains(cube_path)); EXPECT_TRUE(files.contains(three_dl_path)); EXPECT_FALSE(files.contains(text_path)); - olive::Config::Current()[QStringLiteral("LUTLibraryPaths")] = previous; + olive::Config::current()[QStringLiteral("LUTLibraryPaths")] = previous; } // ----------------------------------------------------------------------------- @@ -883,36 +883,36 @@ TEST(LUTLibrary, ScansDirectoriesRecursivelyForSupportedLuts) TEST(ColorProcessor, InverseDisplayTransformRoundTripsColor) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::ColorManager *color_manager = project.color_manager(); ASSERT_NE(color_manager, nullptr); - const QString display = color_manager->GetDefaultDisplay(); - const QString view = color_manager->GetDefaultView(display); + const QString display = color_manager->get_default_display(); + const QString view = color_manager->get_default_view(display); ASSERT_FALSE(display.isEmpty()); ASSERT_FALSE(view.isEmpty()); const olive::ColorTransform output_transform(display, view, QString()); - olive::ColorProcessorPtr ref_to_display = olive::ColorProcessor::Create( - color_manager, color_manager->GetReferenceColorSpace(), + olive::ColorProcessorPtr ref_to_display = olive::ColorProcessor::create( + color_manager, color_manager->get_reference_color_space(), output_transform); ASSERT_NE(ref_to_display, nullptr); - ASSERT_NE(ref_to_display->GetProcessor(), nullptr); + ASSERT_NE(ref_to_display->get_processor(), nullptr); - olive::ColorProcessorPtr display_to_ref = olive::ColorProcessor::Create( - color_manager, color_manager->GetReferenceColorSpace(), - output_transform, olive::ColorProcessor::kInverse); + olive::ColorProcessorPtr display_to_ref = olive::ColorProcessor::create( + color_manager, color_manager->get_reference_color_space(), + output_transform, olive::ColorProcessor::k_inverse); ASSERT_NE(display_to_ref, nullptr); - ASSERT_NE(display_to_ref->GetProcessor(), nullptr); + ASSERT_NE(display_to_ref->get_processor(), nullptr); const olive::Color reference(0.2f, 0.4f, 0.6f, 1.0f); - const olive::Color display_color = ref_to_display->ConvertColor(reference); - const olive::Color round_trip = display_to_ref->ConvertColor(display_color); + const olive::Color display_color = ref_to_display->convert_color(reference); + const olive::Color round_trip = display_to_ref->convert_color(display_color); EXPECT_NEAR(round_trip.red(), reference.red(), 0.001f); EXPECT_NEAR(round_trip.green(), reference.green(), 0.001f); @@ -934,20 +934,20 @@ public: protected: virtual void - ProcessColorTransform(olive::TexturePtr destination, const olive::Node *node, + process_color_transform(olive::TexturePtr destination, const olive::Node *node, const olive::ColorTransformJob *job) override { - const olive::NodeValueRow &values = job->GetValues(); + const olive::NodeValueRow &values = job->get_values(); if (values.contains( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput)) { + olive::OCIOGradingTransformLinearNode::k_clamp_white_input)) { white_clamp_value = values .value(olive::OCIOGradingTransformLinearNode:: - kClampWhiteInput) - .toDouble(); + k_clamp_white_input) + .to_double(); captured_white_clamp = true; } - PixelColorTransformTraverser::ProcessColorTransform(destination, node, + PixelColorTransformTraverser::process_color_transform(destination, node, job); } }; @@ -956,45 +956,45 @@ protected: TEST(ColorGradingLinear, InvalidClampRangeIsCorrectedPerFrame) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *grading = new olive::OCIOGradingTransformLinearNode(); grading->setParent(&project); - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackEnableInput, true); - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampWhiteEnableInput, true); - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackInput, 0.5); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_enable_input, true); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_white_enable_input, true); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input, 0.5); // Invalid: white clamp below black clamp - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, 0.0); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, 0.0); - olive::Node::ConnectEdge( + olive::Node::connect_edge( solid, olive::NodeInput( grading, - olive::OCIOGradingTransformLinearNode::kTextureInput)); + olive::OCIOGradingTransformLinearNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); ClampCaptureTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - grading, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - traverser.Resolve(tex_val); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + grading, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + traverser.resolve(tex_val); // The node must have corrected the white clamp to just above the black // clamp instead of feeding an invalid grading primary to OCIO @@ -1007,44 +1007,44 @@ TEST(ColorGradingLinear, InvalidClampRangeIsCorrectedPerFrame) TEST(ColorGradingLinear, ValidClampRangeIsLeftUntouched) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.50f, 0.75f, 1.0f))); auto *grading = new olive::OCIOGradingTransformLinearNode(); grading->setParent(&project); - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackEnableInput, true); - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampWhiteEnableInput, true); - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackInput, 0.1); - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, 0.9); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_enable_input, true); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_white_enable_input, true); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input, 0.1); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, 0.9); - olive::Node::ConnectEdge( + olive::Node::connect_edge( solid, olive::NodeInput( grading, - olive::OCIOGradingTransformLinearNode::kTextureInput)); + olive::OCIOGradingTransformLinearNode::k_texture_input)); - const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); ClampCaptureTraverser traverser; - traverser.SetCacheVideoParams(params); - olive::NodeValueTable table = traverser.GenerateTable( - grading, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - olive::NodeValue tex_val = table.Get(olive::NodeValue::kTexture); - traverser.Resolve(tex_val); + traverser.set_cache_video_params(params); + olive::NodeValueTable table = traverser.generate_table( + grading, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + olive::NodeValue tex_val = table.get(olive::NodeValue::k_texture); + traverser.resolve(tex_val); ASSERT_TRUE(traverser.captured_white_clamp); EXPECT_NEAR(traverser.white_clamp_value, 0.9, 1e-9); @@ -1054,28 +1054,28 @@ TEST(ColorGradingLinear, ValidClampRangeIsLeftUntouched) TEST(ColorGradingLinear, StaticBlackClampConstrainsWhiteMinimum) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *grading = new olive::OCIOGradingTransformLinearNode(); grading->setParent(&project); // Default black clamp is 0, so the white minimum starts just above it EXPECT_NEAR(grading - ->GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, + ->get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, QStringLiteral("min")) .toDouble(), 0.000001, 1e-9); // Changing the static black clamp updates the white minimum - grading->SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackInput, 0.25); + grading->set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input, 0.25); EXPECT_NEAR(grading - ->GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, + ->get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, QStringLiteral("min")) .toDouble(), 0.250001, 1e-9); diff --git a/tests/gtest/common_commandlineparser_test.cpp b/tests/gtest/common_commandlineparser_test.cpp index 386c3e9a6..c72db1b5d 100644 --- a/tests/gtest/common_commandlineparser_test.cpp +++ b/tests/gtest/common_commandlineparser_test.cpp @@ -10,7 +10,7 @@ namespace // Collects qDebug/qWarning/qCritical output for inspection QStringList g_captured_messages; -void CaptureMessageHandler(QtMsgType, const QMessageLogContext &, +void capture_message_handler(QtMsgType, const QMessageLogContext &, const QString &msg) { g_captured_messages.append(msg); @@ -22,60 +22,60 @@ TEST(CommonCommandLineParser, OptionWithoutArgument) { CommandLineParser parser; const CommandLineParser::Option *opt = - parser.AddOption({ QStringLiteral("help"), QStringLiteral("h") }, + parser.add_option({ QStringLiteral("help"), QStringLiteral("h") }, QStringLiteral("Show help"), false); - parser.Process({ QStringLiteral("app"), QStringLiteral("-help") }); + parser.process({ QStringLiteral("app"), QStringLiteral("-help") }); - EXPECT_TRUE(opt->IsSet()); + EXPECT_TRUE(opt->is_set()); } TEST(CommonCommandLineParser, ShortOption) { CommandLineParser parser; const CommandLineParser::Option *opt = - parser.AddOption({ QStringLiteral("help"), QStringLiteral("h") }, + parser.add_option({ QStringLiteral("help"), QStringLiteral("h") }, QStringLiteral("Show help"), false); - parser.Process({ QStringLiteral("app"), QStringLiteral("-h") }); + parser.process({ QStringLiteral("app"), QStringLiteral("-h") }); - EXPECT_TRUE(opt->IsSet()); + EXPECT_TRUE(opt->is_set()); } TEST(CommonCommandLineParser, OptionWithArgument) { CommandLineParser parser; - const CommandLineParser::Option *opt = parser.AddOption( + const CommandLineParser::Option *opt = parser.add_option( { QStringLiteral("project") }, QStringLiteral("Project file"), true, QStringLiteral("file")); - parser.Process({ QStringLiteral("app"), QStringLiteral("-project"), + parser.process({ QStringLiteral("app"), QStringLiteral("-project"), QStringLiteral("test.ove") }); - EXPECT_TRUE(opt->IsSet()); - EXPECT_EQ(opt->GetSetting(), QStringLiteral("test.ove")); + EXPECT_TRUE(opt->is_set()); + EXPECT_EQ(opt->get_setting(), QStringLiteral("test.ove")); } TEST(CommonCommandLineParser, PositionalArgument) { CommandLineParser parser; const CommandLineParser::PositionalArgument *arg = - parser.AddPositionalArgument(QStringLiteral("filename"), + parser.add_positional_argument(QStringLiteral("filename"), QStringLiteral("Project file"), true); - parser.Process({ QStringLiteral("app"), QStringLiteral("test.ove") }); + parser.process({ QStringLiteral("app"), QStringLiteral("test.ove") }); - EXPECT_EQ(arg->GetSetting(), QStringLiteral("test.ove")); + EXPECT_EQ(arg->get_setting(), QStringLiteral("test.ove")); } TEST(CommonCommandLineParser, UnknownOptionWarning) { CommandLineParser parser; - parser.AddOption({ QStringLiteral("known") }, QStringLiteral("Known")); + parser.add_option({ QStringLiteral("known") }, QStringLiteral("Known")); g_captured_messages.clear(); - QtMessageHandler old = qInstallMessageHandler(CaptureMessageHandler); - parser.Process({ QStringLiteral("app"), QStringLiteral("-unknown") }); + QtMessageHandler old = qInstallMessageHandler(capture_message_handler); + parser.process({ QStringLiteral("app"), QStringLiteral("-unknown") }); qInstallMessageHandler(old); // The warning must name the offending option @@ -91,8 +91,8 @@ TEST(CommonCommandLineParser, UnknownPositionalWarning) CommandLineParser parser; g_captured_messages.clear(); - QtMessageHandler old = qInstallMessageHandler(CaptureMessageHandler); - parser.Process({ QStringLiteral("app"), QStringLiteral("extra") }); + QtMessageHandler old = qInstallMessageHandler(capture_message_handler); + parser.process({ QStringLiteral("app"), QStringLiteral("extra") }); qInstallMessageHandler(old); // The warning must name the offending positional argument @@ -106,15 +106,15 @@ TEST(CommonCommandLineParser, UnknownPositionalWarning) TEST(CommonCommandLineParser, HiddenOptionExcludedFromHelp) { CommandLineParser parser; - parser.AddOption({ QStringLiteral("visible") }, QStringLiteral("Visible")); - parser.AddOption({ QStringLiteral("hidden") }, QStringLiteral("Hidden"), + parser.add_option({ QStringLiteral("visible") }, QStringLiteral("Visible")); + parser.add_option({ QStringLiteral("hidden") }, QStringLiteral("Hidden"), false, QString(), true); - parser.AddPositionalArgument(QStringLiteral("file"), + parser.add_positional_argument(QStringLiteral("file"), QStringLiteral("Input file")); // PrintHelp writes to stdout via printf testing::internal::CaptureStdout(); - parser.PrintHelp("/usr/bin/app"); + parser.print_help("/usr/bin/app"); std::string help = testing::internal::GetCapturedStdout(); // Visible option and positional argument must be listed diff --git a/tests/gtest/common_current_test.cpp b/tests/gtest/common_current_test.cpp index b505b5033..a0480a6e2 100644 --- a/tests/gtest/common_current_test.cpp +++ b/tests/gtest/common_current_test.cpp @@ -1,6 +1,6 @@ #include -#include "common/Current.h" +#include "common/current.h" #include "render/videoparams.h" #include "olive/core/render/audioparams.h" @@ -12,7 +12,7 @@ TEST(CommonCurrent, SetAndGetVideoParams) Current::getInstance().setCurrentVideoParams(params); const olive::VideoParams &stored = - Current::getInstance().currentVideoParams(); + Current::getInstance().current_video_params(); EXPECT_EQ(stored.width(), 1920); EXPECT_EQ(stored.height(), 1080); } @@ -24,6 +24,6 @@ TEST(CommonCurrent, SetAndGetAudioParams) Current::getInstance().setCurrentAudioParams(params); const olive::AudioParams &stored = - Current::getInstance().currentAudioParams(); + Current::getInstance().current_audio_params(); EXPECT_EQ(stored.sample_rate(), 48000); } diff --git a/tests/gtest/common_debug_test.cpp b/tests/gtest/common_debug_test.cpp index 5f203af78..8faf2d33f 100644 --- a/tests/gtest/common_debug_test.cpp +++ b/tests/gtest/common_debug_test.cpp @@ -6,7 +6,7 @@ TEST(CommonDebug, DebugHandlerFormatsAllLevels) { // DebugHandler writes "[LEVEL] message" lines to stderr testing::internal::CaptureStderr(); - QtMessageHandler old = qInstallMessageHandler(olive::DebugHandler); + QtMessageHandler old = qInstallMessageHandler(olive::debug_handler); qDebug() << "debug message"; qInfo() << "info message"; diff --git a/tests/gtest/common_decibel_test.cpp b/tests/gtest/common_decibel_test.cpp index 236944e7b..499704bf6 100644 --- a/tests/gtest/common_decibel_test.cpp +++ b/tests/gtest/common_decibel_test.cpp @@ -4,49 +4,49 @@ TEST(CommonDecibel, FromLinearZeroReturnsMinimum) { - EXPECT_DOUBLE_EQ(olive::Decibel::fromLinear(0.0), olive::Decibel::MINIMUM); + EXPECT_DOUBLE_EQ(olive::Decibel::from_linear(0.0), olive::Decibel::minimum); } TEST(CommonDecibel, FromLinearOneReturnsZero) { - EXPECT_DOUBLE_EQ(olive::Decibel::fromLinear(1.0), 0.0); + EXPECT_DOUBLE_EQ(olive::Decibel::from_linear(1.0), 0.0); } TEST(CommonDecibel, FromLinearTenReturnsTwenty) { - EXPECT_DOUBLE_EQ(olive::Decibel::fromLinear(10.0), 20.0); + EXPECT_DOUBLE_EQ(olive::Decibel::from_linear(10.0), 20.0); } TEST(CommonDecibel, ToLinearZeroReturnsOne) { - EXPECT_DOUBLE_EQ(olive::Decibel::toLinear(0.0), 1.0); + EXPECT_DOUBLE_EQ(olive::Decibel::to_linear(0.0), 1.0); } TEST(CommonDecibel, ToLinearMinimumReturnsZero) { - EXPECT_DOUBLE_EQ(olive::Decibel::toLinear(olive::Decibel::MINIMUM), 0.0); + EXPECT_DOUBLE_EQ(olive::Decibel::to_linear(olive::Decibel::minimum), 0.0); } TEST(CommonDecibel, ToLinearTwentyReturnsTen) { - EXPECT_DOUBLE_EQ(olive::Decibel::toLinear(20.0), 10.0); + EXPECT_DOUBLE_EQ(olive::Decibel::to_linear(20.0), 10.0); } TEST(CommonDecibel, FromLogarithmicAtEdges) { - EXPECT_DOUBLE_EQ(olive::Decibel::fromLogarithmic(0.0), - olive::Decibel::MINIMUM); - EXPECT_DOUBLE_EQ(olive::Decibel::fromLogarithmic(1.0), 0.0); + EXPECT_DOUBLE_EQ(olive::Decibel::from_logarithmic(0.0), + olive::Decibel::minimum); + EXPECT_DOUBLE_EQ(olive::Decibel::from_logarithmic(1.0), 0.0); } TEST(CommonDecibel, ToLogarithmicAtEdges) { - EXPECT_DOUBLE_EQ(olive::Decibel::toLogarithmic(0.0), 1.0); + EXPECT_DOUBLE_EQ(olive::Decibel::to_logarithmic(0.0), 1.0); } TEST(CommonDecibel, LinearLogarithmicRoundTrip) { - EXPECT_NEAR(olive::Decibel::LogarithmicToLinear( - olive::Decibel::LinearToLogarithmic(0.5)), + EXPECT_NEAR(olive::Decibel::logarithmic_to_linear( + olive::Decibel::linear_to_logarithmic(0.5)), 0.5, 1e-6); } diff --git a/tests/gtest/common_digit_test.cpp b/tests/gtest/common_digit_test.cpp index cf1ce24c2..e423c4093 100644 --- a/tests/gtest/common_digit_test.cpp +++ b/tests/gtest/common_digit_test.cpp @@ -4,20 +4,20 @@ TEST(CommonDigit, SingleDigit) { - EXPECT_EQ(olive::GetDigitCount(0), 1); - EXPECT_EQ(olive::GetDigitCount(5), 1); - EXPECT_EQ(olive::GetDigitCount(-5), 1); + EXPECT_EQ(olive::get_digit_count(0), 1); + EXPECT_EQ(olive::get_digit_count(5), 1); + EXPECT_EQ(olive::get_digit_count(-5), 1); } TEST(CommonDigit, MultipleDigits) { - EXPECT_EQ(olive::GetDigitCount(10), 2); - EXPECT_EQ(olive::GetDigitCount(999), 3); - EXPECT_EQ(olive::GetDigitCount(1000), 4); - EXPECT_EQ(olive::GetDigitCount(-12345), 5); + EXPECT_EQ(olive::get_digit_count(10), 2); + EXPECT_EQ(olive::get_digit_count(999), 3); + EXPECT_EQ(olive::get_digit_count(1000), 4); + EXPECT_EQ(olive::get_digit_count(-12345), 5); } TEST(CommonDigit, LargeValue) { - EXPECT_EQ(olive::GetDigitCount(123456789012345LL), 15); + EXPECT_EQ(olive::get_digit_count(123456789012345LL), 15); } diff --git a/tests/gtest/common_ffmpegutils_test.cpp b/tests/gtest/common_ffmpegutils_test.cpp index 5ac6e974c..404fd488d 100644 --- a/tests/gtest/common_ffmpegutils_test.cpp +++ b/tests/gtest/common_ffmpegutils_test.cpp @@ -6,126 +6,126 @@ using namespace olive; TEST(CommonFFmpegUtils, GetNativeSampleFormatMapsCorrectly) { - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_U8), - SampleFormat::U8); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_S16), - SampleFormat::S16); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_S32), - SampleFormat::S32); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_S64), - SampleFormat::S64); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_FLT), - SampleFormat::F32); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_DBL), - SampleFormat::F64); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_U8P), - SampleFormat::U8P); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_S16P), - SampleFormat::S16P); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_S32P), - SampleFormat::S32P); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_S64P), - SampleFormat::S64P); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_FLTP), - SampleFormat::F32P); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_DBLP), - SampleFormat::F64P); - EXPECT_EQ(FFmpegUtils::GetNativeSampleFormat(FB_SAMPLE_FMT_NONE), - SampleFormat::INVALID); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_u8), + SampleFormat::u8); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s16), + SampleFormat::s16); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s32), + SampleFormat::s32); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s64), + SampleFormat::s64); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_flt), + SampleFormat::f32); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_dbl), + SampleFormat::f64); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_u8_p), + SampleFormat::u8_p); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s16_p), + SampleFormat::s16_p); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s32_p), + SampleFormat::s32_p); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_s64_p), + SampleFormat::s64_p); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_fltp), + SampleFormat::f32_p); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_dblp), + SampleFormat::f64_p); + EXPECT_EQ(FFmpegUtils::get_native_sample_format(fb_sample_fmt_none), + SampleFormat::invalid); } TEST(CommonFFmpegUtils, GetFFmpegSampleFormatMapsCorrectly) { - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::U8), - FB_SAMPLE_FMT_U8); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::S16), - FB_SAMPLE_FMT_S16); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::S32), - FB_SAMPLE_FMT_S32); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::S64), - FB_SAMPLE_FMT_S64); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::F32), - FB_SAMPLE_FMT_FLT); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::F64), - FB_SAMPLE_FMT_DBL); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::U8P), - FB_SAMPLE_FMT_U8P); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::S16P), - FB_SAMPLE_FMT_S16P); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::S32P), - FB_SAMPLE_FMT_S32P); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::S64P), - FB_SAMPLE_FMT_S64P); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::F32P), - FB_SAMPLE_FMT_FLTP); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::F64P), - FB_SAMPLE_FMT_DBLP); - EXPECT_EQ(FFmpegUtils::GetFFmpegSampleFormat(SampleFormat::INVALID), - FB_SAMPLE_FMT_NONE); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::u8), + fb_sample_fmt_u8); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s16), + fb_sample_fmt_s16); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s32), + fb_sample_fmt_s32); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s64), + fb_sample_fmt_s64); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::f32), + fb_sample_fmt_flt); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::f64), + fb_sample_fmt_dbl); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::u8_p), + fb_sample_fmt_u8_p); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s16_p), + fb_sample_fmt_s16_p); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s32_p), + fb_sample_fmt_s32_p); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::s64_p), + fb_sample_fmt_s64_p); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::f32_p), + fb_sample_fmt_fltp); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::f64_p), + fb_sample_fmt_dblp); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_sample_format(SampleFormat::invalid), + fb_sample_fmt_none); } TEST(CommonFFmpegUtils, ConvertJPEGSpaceToRegularSpace) { - EXPECT_EQ(FFmpegUtils::ConvertJPEGSpaceToRegularSpace(FB_PIX_FMT_YUVJ420P), - FB_PIX_FMT_YUV420P); - EXPECT_EQ(FFmpegUtils::ConvertJPEGSpaceToRegularSpace(FB_PIX_FMT_YUVJ422P), - FB_PIX_FMT_YUV422P); - EXPECT_EQ(FFmpegUtils::ConvertJPEGSpaceToRegularSpace(FB_PIX_FMT_YUVJ444P), - FB_PIX_FMT_YUV444P); - EXPECT_EQ(FFmpegUtils::ConvertJPEGSpaceToRegularSpace(FB_PIX_FMT_YUVJ440P), - FB_PIX_FMT_YUV440P); - EXPECT_EQ(FFmpegUtils::ConvertJPEGSpaceToRegularSpace(FB_PIX_FMT_YUVJ411P), - FB_PIX_FMT_YUV411P); - EXPECT_EQ(FFmpegUtils::ConvertJPEGSpaceToRegularSpace(FB_PIX_FMT_YUV420P), - FB_PIX_FMT_YUV420P); + EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j420_p), + fb_pix_fmt_yu_v420_p); + EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j422_p), + fb_pix_fmt_yu_v422_p); + EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j444_p), + fb_pix_fmt_yu_v444_p); + EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j440_p), + fb_pix_fmt_yu_v440_p); + EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yuv_j411_p), + fb_pix_fmt_yu_v411_p); + EXPECT_EQ(FFmpegUtils::convert_jpeg_space_to_regular_space(fb_pix_fmt_yu_v420_p), + fb_pix_fmt_yu_v420_p); } TEST(CommonFFmpegUtils, GetCompatiblePixelFormatNative) { - EXPECT_EQ(FFmpegUtils::GetCompatiblePixelFormat(PixelFormat::U8), - PixelFormat::U8); - EXPECT_EQ(FFmpegUtils::GetCompatiblePixelFormat(PixelFormat::U10), - PixelFormat::U8); - EXPECT_EQ(FFmpegUtils::GetCompatiblePixelFormat(PixelFormat::U16), - PixelFormat::U16); - EXPECT_EQ(FFmpegUtils::GetCompatiblePixelFormat(PixelFormat::F16), - PixelFormat::U16); - EXPECT_EQ(FFmpegUtils::GetCompatiblePixelFormat(PixelFormat::F32), - PixelFormat::U16); - EXPECT_EQ(FFmpegUtils::GetCompatiblePixelFormat(PixelFormat::INVALID), - PixelFormat::INVALID); + EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::u8), + PixelFormat::u8); + EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::u10), + PixelFormat::u8); + EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::u16), + PixelFormat::u16); + EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::f16), + PixelFormat::u16); + EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::f32), + PixelFormat::u16); + EXPECT_EQ(FFmpegUtils::get_compatible_pixel_format(PixelFormat::invalid), + PixelFormat::invalid); } TEST(CommonFFmpegUtils, GetFFmpegPixelFormat) { - EXPECT_EQ(FFmpegUtils::GetFFmpegPixelFormat(PixelFormat::U8, - VideoParams::kRGBChannelCount), - FB_PIX_FMT_RGB24); - EXPECT_EQ(FFmpegUtils::GetFFmpegPixelFormat(PixelFormat::U16, - VideoParams::kRGBChannelCount), - FB_PIX_FMT_RGB48LE); - EXPECT_EQ(FFmpegUtils::GetFFmpegPixelFormat(PixelFormat::F32, - VideoParams::kRGBChannelCount), - FB_PIX_FMT_RGBF32LE); - EXPECT_EQ(FFmpegUtils::GetFFmpegPixelFormat(PixelFormat::U8, - VideoParams::kRGBAChannelCount), - FB_PIX_FMT_RGBA); - EXPECT_EQ(FFmpegUtils::GetFFmpegPixelFormat(PixelFormat::U16, - VideoParams::kRGBAChannelCount), - FB_PIX_FMT_RGBA64LE); - EXPECT_EQ(FFmpegUtils::GetFFmpegPixelFormat(PixelFormat::F32, - VideoParams::kRGBAChannelCount), - FB_PIX_FMT_RGBAF32LE); - EXPECT_EQ(FFmpegUtils::GetFFmpegPixelFormat(PixelFormat::INVALID, 0), - FB_PIX_FMT_NONE); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::u8, + VideoParams::k_rgb_channel_count), + fb_pix_fmt_rg_b24); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::u16, + VideoParams::k_rgb_channel_count), + fb_pix_fmt_rg_b48_le); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::f32, + VideoParams::k_rgb_channel_count), + fb_pix_fmt_rgb_f32_le); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::u8, + VideoParams::k_rgba_channel_count), + fb_pix_fmt_rgba); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::u16, + VideoParams::k_rgba_channel_count), + fb_pix_fmt_rgb_a64_le); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::f32, + VideoParams::k_rgba_channel_count), + fb_pix_fmt_rgba_f32_le); + EXPECT_EQ(FFmpegUtils::get_f_fmpeg_pixel_format(PixelFormat::invalid, 0), + fb_pix_fmt_none); } TEST(CommonFFmpegUtils, GetCompatiblePixelFormatAV) { - int fmt = FFmpegUtils::GetCompatibleBridgePixelFormat(FB_PIX_FMT_YUV420P); - EXPECT_NE(fmt, FB_PIX_FMT_NONE); + int fmt = FFmpegUtils::get_compatible_bridge_pixel_format(fb_pix_fmt_yu_v420_p); + EXPECT_NE(fmt, fb_pix_fmt_none); - fmt = FFmpegUtils::GetCompatibleBridgePixelFormat(FB_PIX_FMT_YUV420P, - PixelFormat::U8); - EXPECT_EQ(fmt, FB_PIX_FMT_RGBA); + fmt = FFmpegUtils::get_compatible_bridge_pixel_format(fb_pix_fmt_yu_v420_p, + PixelFormat::u8); + EXPECT_EQ(fmt, fb_pix_fmt_rgba); } diff --git a/tests/gtest/common_filefunctions_test.cpp b/tests/gtest/common_filefunctions_test.cpp index 653207de5..ebaff51ec 100644 --- a/tests/gtest/common_filefunctions_test.cpp +++ b/tests/gtest/common_filefunctions_test.cpp @@ -12,7 +12,7 @@ namespace // Collects qDebug/qWarning/qCritical output for inspection QStringList g_captured_messages; -void CaptureMessageHandler(QtMsgType, const QMessageLogContext &, +void capture_message_handler(QtMsgType, const QMessageLogContext &, const QString &msg) { g_captured_messages.append(msg); @@ -22,19 +22,19 @@ void CaptureMessageHandler(QtMsgType, const QMessageLogContext &, TEST(CommonFileFunctions, EnsureFilenameExtension) { - EXPECT_EQ(olive::FileFunctions::EnsureFilenameExtension( + EXPECT_EQ(olive::FileFunctions::ensure_filename_extension( QStringLiteral("project"), QStringLiteral("ove")), QStringLiteral("project.ove")); - EXPECT_EQ(olive::FileFunctions::EnsureFilenameExtension( + EXPECT_EQ(olive::FileFunctions::ensure_filename_extension( QStringLiteral("project.ove"), QStringLiteral("ove")), QStringLiteral("project.ove")); - EXPECT_EQ(olive::FileFunctions::EnsureFilenameExtension( + EXPECT_EQ(olive::FileFunctions::ensure_filename_extension( QStringLiteral("PROJECT"), QStringLiteral("ove")), QStringLiteral("PROJECT.ove")); - EXPECT_TRUE(olive::FileFunctions::EnsureFilenameExtension( + EXPECT_TRUE(olive::FileFunctions::ensure_filename_extension( QString(), QStringLiteral("ove")) .isEmpty()); - EXPECT_EQ(olive::FileFunctions::EnsureFilenameExtension( + EXPECT_EQ(olive::FileFunctions::ensure_filename_extension( QStringLiteral("project"), QString()), QStringLiteral("project")); } @@ -45,7 +45,7 @@ TEST(CommonFileFunctions, GetSafeTemporaryFilename) ASSERT_TRUE(dir.isValid()); QString base = dir.filePath(QStringLiteral("test.ove")); - QString first = olive::FileFunctions::GetSafeTemporaryFilename(base); + QString first = olive::FileFunctions::get_safe_temporary_filename(base); EXPECT_FALSE(QFileInfo::exists(first)); EXPECT_TRUE(first.contains(QStringLiteral(".tmp0."))); @@ -53,7 +53,7 @@ TEST(CommonFileFunctions, GetSafeTemporaryFilename) f.open(QIODevice::WriteOnly); f.close(); - QString second = olive::FileFunctions::GetSafeTemporaryFilename(base); + QString second = olive::FileFunctions::get_safe_temporary_filename(base); EXPECT_NE(first, second); EXPECT_TRUE(second.contains(QStringLiteral(".tmp1."))); } @@ -64,10 +64,10 @@ TEST(CommonFileFunctions, DirectoryIsValid) ASSERT_TRUE(dir.isValid()); EXPECT_TRUE( - olive::FileFunctions::DirectoryIsValid(QDir(dir.path()), false)); + olive::FileFunctions::directory_is_valid(QDir(dir.path()), false)); QDir nonexistent(dir.filePath(QStringLiteral("subdir/nested"))); - EXPECT_TRUE(olive::FileFunctions::DirectoryIsValid(nonexistent, true)); + EXPECT_TRUE(olive::FileFunctions::directory_is_valid(nonexistent, true)); EXPECT_TRUE(nonexistent.exists()); } @@ -89,7 +89,7 @@ TEST(CommonFileFunctions, RenameFileAllowOverwrite) t.write("existing"); t.close(); - EXPECT_TRUE(olive::FileFunctions::RenameFileAllowOverwrite(from, to)); + EXPECT_TRUE(olive::FileFunctions::rename_file_allow_overwrite(from, to)); EXPECT_FALSE(QFileInfo::exists(from)); QFile result(to); result.open(QIODevice::ReadOnly); @@ -108,7 +108,7 @@ TEST(CommonFileFunctions, CanCopyDirectoryWithoutOverwriting) f.open(QIODevice::WriteOnly); f.close(); - EXPECT_TRUE(olive::FileFunctions::CanCopyDirectoryWithoutOverwriting( + EXPECT_TRUE(olive::FileFunctions::can_copy_directory_without_overwriting( src.path(), dst.path())); QString dst_file = QDir(dst.path()).filePath(QStringLiteral("file.txt")); @@ -116,7 +116,7 @@ TEST(CommonFileFunctions, CanCopyDirectoryWithoutOverwriting) g.open(QIODevice::WriteOnly); g.close(); - EXPECT_FALSE(olive::FileFunctions::CanCopyDirectoryWithoutOverwriting( + EXPECT_FALSE(olive::FileFunctions::can_copy_directory_without_overwriting( src.path(), dst.path())); } @@ -134,7 +134,7 @@ TEST(CommonFileFunctions, CopyDirectory) f.close(); QString dst_dir = QDir(dst.path()).filePath(QStringLiteral("copied")); - olive::FileFunctions::CopyDirectory(src.path(), dst_dir, false); + olive::FileFunctions::copy_directory(src.path(), dst_dir, false); QFile result(QDir(dst_dir).filePath(QStringLiteral("file.txt"))); EXPECT_TRUE(result.open(QIODevice::ReadOnly)); @@ -148,9 +148,9 @@ TEST(CommonFileFunctions, ReadFileAsString) f.write("hello world"); f.close(); - EXPECT_EQ(olive::FileFunctions::ReadFileAsString(f.fileName()), + EXPECT_EQ(olive::FileFunctions::read_file_as_string(f.fileName()), QStringLiteral("hello world")); - EXPECT_TRUE(olive::FileFunctions::ReadFileAsString( + EXPECT_TRUE(olive::FileFunctions::read_file_as_string( QStringLiteral("/nonexistent/path")) .isEmpty()); } @@ -161,33 +161,33 @@ TEST(CommonFileFunctions, GetUniqueFileIdentifier) ASSERT_TRUE(f.open()); f.close(); - QString id1 = olive::FileFunctions::GetUniqueFileIdentifier(f.fileName()); - QString id2 = olive::FileFunctions::GetUniqueFileIdentifier(f.fileName()); + QString id1 = olive::FileFunctions::get_unique_file_identifier(f.fileName()); + QString id2 = olive::FileFunctions::get_unique_file_identifier(f.fileName()); EXPECT_FALSE(id1.isEmpty()); EXPECT_EQ(id1, id2); - EXPECT_TRUE(olive::FileFunctions::GetUniqueFileIdentifier( + EXPECT_TRUE(olive::FileFunctions::get_unique_file_identifier( QStringLiteral("/nonexistent")) .isEmpty()); } TEST(CommonFileFunctions, GetConfigurationLocation) { - QString loc = olive::FileFunctions::GetConfigurationLocation(); + QString loc = olive::FileFunctions::get_configuration_location(); EXPECT_FALSE(loc.isEmpty()); EXPECT_TRUE(QDir(loc).exists()); } TEST(CommonFileFunctions, GetTempFilePath) { - QString temp = olive::FileFunctions::GetTempFilePath(); + QString temp = olive::FileFunctions::get_temp_file_path(); EXPECT_FALSE(temp.isEmpty()); EXPECT_TRUE(QDir(temp).exists()); } TEST(CommonFileFunctions, GetAutoRecoveryRoot) { - QString root = olive::FileFunctions::GetAutoRecoveryRoot(); + QString root = olive::FileFunctions::get_auto_recovery_root(); EXPECT_FALSE(root.isEmpty()); } @@ -196,7 +196,7 @@ TEST(CommonFileFunctions, DirectoryIsValidExisting) QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); EXPECT_TRUE( - olive::FileFunctions::DirectoryIsValid(QDir(dir.path()), false)); + olive::FileFunctions::directory_is_valid(QDir(dir.path()), false)); } TEST(CommonFileFunctions, CopyDirectoryWithOverwrite) @@ -218,7 +218,7 @@ TEST(CommonFileFunctions, CopyDirectoryWithOverwrite) g.write("old content"); g.close(); - olive::FileFunctions::CopyDirectory(src.path(), dst.path(), true); + olive::FileFunctions::copy_directory(src.path(), dst.path(), true); QFile result(dst_file); result.open(QIODevice::ReadOnly); @@ -233,8 +233,8 @@ TEST(CommonFileFunctions, CopyDirectorySourceMissing) // A missing source must log a critical error naming the source and // leave the destination untouched g_captured_messages.clear(); - QtMessageHandler old = qInstallMessageHandler(CaptureMessageHandler); - olive::FileFunctions::CopyDirectory(QStringLiteral("/nonexistent/path"), + QtMessageHandler old = qInstallMessageHandler(capture_message_handler); + olive::FileFunctions::copy_directory(QStringLiteral("/nonexistent/path"), dst.path(), false); qInstallMessageHandler(old); diff --git a/tests/gtest/common_html_test.cpp b/tests/gtest/common_html_test.cpp index 8c5f1ef9d..e721c3fe5 100644 --- a/tests/gtest/common_html_test.cpp +++ b/tests/gtest/common_html_test.cpp @@ -8,7 +8,7 @@ namespace { -QTextDocument *MakeDoc(const QString &plain_text) +QTextDocument *make_doc(const QString &plain_text) { auto *doc = new QTextDocument(); QTextCursor c(doc); @@ -17,7 +17,7 @@ QTextDocument *MakeDoc(const QString &plain_text) } // Extract the single fragment of a single-block document for format checks. -QTextFragment OnlyFragment(QTextDocument *doc) +QTextFragment only_fragment(QTextDocument *doc) { QTextBlock block = doc->begin(); auto it = block.begin(); @@ -29,9 +29,9 @@ QTextFragment OnlyFragment(QTextDocument *doc) TEST(CommonHtml, DocToHtmlWrapsTextInParagraph) { - std::unique_ptr doc(MakeDoc(QStringLiteral("hello"))); + std::unique_ptr doc(make_doc(QStringLiteral("hello"))); - const QString html = olive::Html::DocToHtml(doc.get()); + const QString html = olive::Html::doc_to_html(doc.get()); EXPECT_TRUE(html.contains(QStringLiteral(" doc(MakeDoc(QStringLiteral("a&\"c\""))); + std::unique_ptr doc(make_doc(QStringLiteral("a&\"c\""))); - const QString html = olive::Html::DocToHtml(doc.get()); + const QString html = olive::Html::doc_to_html(doc.get()); EXPECT_FALSE(html.contains(QStringLiteral("a"))); EXPECT_TRUE(html.contains(QStringLiteral("<"))); @@ -58,7 +58,7 @@ TEST(CommonHtml, AlignmentIsWrittenAsAttribute) c.setBlockFormat(fmt); c.insertText(QStringLiteral("right")); - const QString html = olive::Html::DocToHtml(&doc); + const QString html = olive::Html::doc_to_html(&doc); EXPECT_TRUE(html.contains(QStringLiteral("align=\"right\""))); } @@ -72,7 +72,7 @@ TEST(CommonHtml, CenterAlignmentIsWrittenAsAttribute) c.setBlockFormat(fmt); c.insertText(QStringLiteral("center")); - const QString html = olive::Html::DocToHtml(&doc); + const QString html = olive::Html::doc_to_html(&doc); EXPECT_TRUE(html.contains(QStringLiteral("align=\"center\""))); } @@ -86,7 +86,7 @@ TEST(CommonHtml, LeftAlignmentWritesNoAlignAttribute) c.setBlockFormat(fmt); c.insertText(QStringLiteral("left")); - const QString html = olive::Html::DocToHtml(&doc); + const QString html = olive::Html::doc_to_html(&doc); EXPECT_FALSE(html.contains(QStringLiteral("align="))); } @@ -105,13 +105,13 @@ TEST(CommonHtml, CharFormatRoundTrip) fmt.setForeground(QColor(255, 0, 0)); c.insertText(QStringLiteral("styled"), fmt); - const QString html = olive::Html::DocToHtml(&doc); + const QString html = olive::Html::doc_to_html(&doc); QTextDocument parsed; - olive::Html::HtmlToDoc(&parsed, html); + olive::Html::html_to_doc(&parsed, html); ASSERT_EQ(parsed.begin().text(), QStringLiteral("styled")); - const QTextFragment frag = OnlyFragment(&parsed); + const QTextFragment frag = only_fragment(&parsed); const QTextCharFormat &out = frag.charFormat(); EXPECT_EQ(out.fontWeight(), QFont::Bold); EXPECT_TRUE(out.fontItalic()); @@ -131,13 +131,13 @@ TEST(CommonHtml, ColorWithAlphaRoundTripsAsRgba) fmt.setForeground(semi); c.insertText(QStringLiteral("x"), fmt); - const QString html = olive::Html::DocToHtml(&doc); + const QString html = olive::Html::doc_to_html(&doc); EXPECT_TRUE(html.contains(QStringLiteral("rgba("))); QTextDocument parsed; - olive::Html::HtmlToDoc(&parsed, html); + olive::Html::html_to_doc(&parsed, html); - const QTextFragment frag = OnlyFragment(&parsed); + const QTextFragment frag = only_fragment(&parsed); const QColor out = frag.charFormat().foreground().color(); EXPECT_EQ(out.red(), semi.red()); EXPECT_EQ(out.green(), semi.green()); @@ -155,7 +155,7 @@ TEST(CommonHtml, BlockAlignmentRoundTrips) c.insertText(QStringLiteral("centered")); QTextDocument parsed; - olive::Html::HtmlToDoc(&parsed, olive::Html::DocToHtml(&doc)); + olive::Html::html_to_doc(&parsed, olive::Html::doc_to_html(&doc)); EXPECT_TRUE(parsed.begin().blockFormat().alignment() & Qt::AlignHCenter); } @@ -169,7 +169,7 @@ TEST(CommonHtml, MultipleBlocksSurviveRoundTrip) c.insertText(QStringLiteral("second")); QTextDocument parsed; - olive::Html::HtmlToDoc(&parsed, olive::Html::DocToHtml(&doc)); + olive::Html::html_to_doc(&parsed, olive::Html::doc_to_html(&doc)); EXPECT_EQ(parsed.blockCount(), 2); EXPECT_EQ(parsed.begin().text(), QStringLiteral("first")); @@ -184,7 +184,7 @@ TEST(CommonHtml, LineSeparatorBecomesBr) c.insertText(QString(QChar(QChar::LineSeparator)) + QStringLiteral("line2")); - const QString html = olive::Html::DocToHtml(&doc); + const QString html = olive::Html::doc_to_html(&doc); EXPECT_TRUE(html.contains(QStringLiteral("
"))); } @@ -195,7 +195,7 @@ TEST(CommonHtml, HtmlToDocReplacesExistingContent) QTextCursor c(&doc); c.insertText(QStringLiteral("old content that should disappear")); - olive::Html::HtmlToDoc(&doc, QStringLiteral("

new

")); + olive::Html::html_to_doc(&doc, QStringLiteral("

new

")); EXPECT_EQ(doc.toPlainText().trimmed(), QStringLiteral("new")); } @@ -205,7 +205,7 @@ TEST(CommonHtml, HtmlToDocHandlesInvalidMarkupWithoutCrash) QTextDocument doc; // Malformed markup must not crash; error is only logged. - olive::Html::HtmlToDoc(&doc, QStringLiteral("

unclosed")); + olive::Html::html_to_doc(&doc, QStringLiteral("

unclosed")); SUCCEED(); } @@ -213,7 +213,7 @@ TEST(CommonHtml, HtmlToDocHandlesInvalidMarkupWithoutCrash) TEST(CommonHtml, EmptyHtmlProducesEmptyDocument) { QTextDocument doc; - olive::Html::HtmlToDoc(&doc, QString()); + olive::Html::html_to_doc(&doc, QString()); EXPECT_LE(doc.blockCount(), 1); EXPECT_TRUE(doc.toPlainText().trimmed().isEmpty()); @@ -229,9 +229,9 @@ TEST(CommonHtml, LetterSpacingAndStretchRoundTrip) c.insertText(QStringLiteral("spaced"), fmt); QTextDocument parsed; - olive::Html::HtmlToDoc(&parsed, olive::Html::DocToHtml(&doc)); + olive::Html::html_to_doc(&parsed, olive::Html::doc_to_html(&doc)); - const QTextFragment frag = OnlyFragment(&parsed); + const QTextFragment frag = only_fragment(&parsed); EXPECT_DOUBLE_EQ(frag.charFormat().fontLetterSpacing(), 150.0); EXPECT_EQ(frag.charFormat().fontStretch(), 125); } @@ -239,12 +239,12 @@ TEST(CommonHtml, LetterSpacingAndStretchRoundTrip) TEST(CommonHtml, NestedInlineTagsMergeFormats) { QTextDocument doc; - olive::Html::HtmlToDoc( + olive::Html::html_to_doc( &doc, QStringLiteral( "

both

")); - const QTextFragment frag = OnlyFragment(&doc); + const QTextFragment frag = only_fragment(&doc); EXPECT_TRUE(frag.charFormat().fontItalic()); // CSS font-weight 600 maps to 75 on the legacy 0-99 Qt weight scale EXPECT_EQ(frag.charFormat().fontWeight(), 75); diff --git a/tests/gtest/common_jobtime_test.cpp b/tests/gtest/common_jobtime_test.cpp index 5f5f050b1..eb982e5c5 100644 --- a/tests/gtest/common_jobtime_test.cpp +++ b/tests/gtest/common_jobtime_test.cpp @@ -8,7 +8,7 @@ namespace // Collects qDebug output for inspection QStringList g_captured_messages; -void CaptureMessageHandler(QtMsgType, const QMessageLogContext &, +void capture_message_handler(QtMsgType, const QMessageLogContext &, const QString &msg) { g_captured_messages.append(msg); @@ -29,7 +29,7 @@ TEST(CommonJobTime, AcquireUpdatesValue) { olive::JobTime a; uint64_t first = a.value(); - a.Acquire(); + a.acquire(); uint64_t second = a.value(); EXPECT_GT(second, first); @@ -59,7 +59,7 @@ TEST(CommonJobTime, DebugStream) olive::JobTime a; g_captured_messages.clear(); - QtMessageHandler old = qInstallMessageHandler(CaptureMessageHandler); + QtMessageHandler old = qInstallMessageHandler(capture_message_handler); { QDebug debug(QtDebugMsg); debug << a; diff --git a/tests/gtest/common_oiioutils_test.cpp b/tests/gtest/common_oiioutils_test.cpp index badf85974..3d86a53e3 100644 --- a/tests/gtest/common_oiioutils_test.cpp +++ b/tests/gtest/common_oiioutils_test.cpp @@ -11,17 +11,17 @@ TEST(CommonOIIOUtils, BaseTypeFromPixelFormat) { using olive::core::PixelFormat; - EXPECT_EQ(olive::OIIOUtils::GetOIIOBaseTypeFromFormat(PixelFormat::U8), + EXPECT_EQ(olive::OIIOUtils::get_oiio_base_type_from_format(PixelFormat::u8), OIIO::TypeDesc::UINT8); - EXPECT_EQ(olive::OIIOUtils::GetOIIOBaseTypeFromFormat(PixelFormat::U16), + EXPECT_EQ(olive::OIIOUtils::get_oiio_base_type_from_format(PixelFormat::u16), OIIO::TypeDesc::UINT16); - EXPECT_EQ(olive::OIIOUtils::GetOIIOBaseTypeFromFormat(PixelFormat::F16), + EXPECT_EQ(olive::OIIOUtils::get_oiio_base_type_from_format(PixelFormat::f16), OIIO::TypeDesc::HALF); - EXPECT_EQ(olive::OIIOUtils::GetOIIOBaseTypeFromFormat(PixelFormat::F32), + EXPECT_EQ(olive::OIIOUtils::get_oiio_base_type_from_format(PixelFormat::f32), OIIO::TypeDesc::FLOAT); - EXPECT_EQ(olive::OIIOUtils::GetOIIOBaseTypeFromFormat(PixelFormat::U10), + EXPECT_EQ(olive::OIIOUtils::get_oiio_base_type_from_format(PixelFormat::u10), OIIO::TypeDesc::UNKNOWN); - EXPECT_EQ(olive::OIIOUtils::GetOIIOBaseTypeFromFormat(PixelFormat::INVALID), + EXPECT_EQ(olive::OIIOUtils::get_oiio_base_type_from_format(PixelFormat::invalid), OIIO::TypeDesc::UNKNOWN); } @@ -29,22 +29,22 @@ TEST(CommonOIIOUtils, PixelFormatFromBaseType) { using olive::core::PixelFormat; - EXPECT_EQ(olive::OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::UINT8), - PixelFormat::U8); + EXPECT_EQ(olive::OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::UINT8), + PixelFormat::u8); EXPECT_EQ( - olive::OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::UINT16), - PixelFormat::U16); - EXPECT_EQ(olive::OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::HALF), - PixelFormat::F16); - EXPECT_EQ(olive::OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::FLOAT), - PixelFormat::F32); + olive::OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::UINT16), + PixelFormat::u16); + EXPECT_EQ(olive::OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::HALF), + PixelFormat::f16); + EXPECT_EQ(olive::OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::FLOAT), + PixelFormat::f32); EXPECT_EQ( - olive::OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::UNKNOWN), - PixelFormat::INVALID); - EXPECT_EQ(olive::OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::DOUBLE), - PixelFormat::INVALID); - EXPECT_EQ(olive::OIIOUtils::GetFormatFromOIIOBasetype(OIIO::TypeDesc::STRING), - PixelFormat::INVALID); + olive::OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::UNKNOWN), + PixelFormat::invalid); + EXPECT_EQ(olive::OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::DOUBLE), + PixelFormat::invalid); + EXPECT_EQ(olive::OIIOUtils::get_format_from_oiio_basetype(OIIO::TypeDesc::STRING), + PixelFormat::invalid); } TEST(CommonOIIOUtils, FormatRoundTripIsSymmetric) @@ -52,10 +52,10 @@ TEST(CommonOIIOUtils, FormatRoundTripIsSymmetric) using olive::core::PixelFormat; for (PixelFormat fmt : - { PixelFormat::U8, PixelFormat::U16, PixelFormat::F16, - PixelFormat::F32 }) { - EXPECT_EQ(olive::OIIOUtils::GetFormatFromOIIOBasetype( - olive::OIIOUtils::GetOIIOBaseTypeFromFormat(fmt)), + { PixelFormat::u8, PixelFormat::u16, PixelFormat::f16, + PixelFormat::f32 }) { + EXPECT_EQ(olive::OIIOUtils::get_format_from_oiio_basetype( + olive::OIIOUtils::get_oiio_base_type_from_format(fmt)), fmt); } } @@ -64,10 +64,10 @@ TEST(CommonOIIOUtils, PixelAspectRatioDefaultsToOne) { OIIO::ImageSpec spec(16, 16, 4, OIIO::TypeDesc::FLOAT); - const olive::core::rational par = - olive::OIIOUtils::GetPixelAspectRatioFromOIIO(spec); + const olive::core::Rational par = + olive::OIIOUtils::get_pixel_aspect_ratio_from_oiio(spec); - EXPECT_EQ(par, olive::core::rational(1, 1)); + EXPECT_EQ(par, olive::core::Rational(1, 1)); } TEST(CommonOIIOUtils, PixelAspectRatioIsReadFromAttribute) @@ -75,20 +75,20 @@ TEST(CommonOIIOUtils, PixelAspectRatioIsReadFromAttribute) OIIO::ImageSpec spec(16, 16, 4, OIIO::TypeDesc::FLOAT); spec.attribute("PixelAspectRatio", 2.0f); - const olive::core::rational par = - olive::OIIOUtils::GetPixelAspectRatioFromOIIO(spec); + const olive::core::Rational par = + olive::OIIOUtils::get_pixel_aspect_ratio_from_oiio(spec); - EXPECT_EQ(par, olive::core::rational(2, 1)); + EXPECT_EQ(par, olive::core::Rational(2, 1)); } TEST(CommonOIIOUtils, FrameBufferRoundTripPreservesPixels) { using olive::core::PixelFormat; - const olive::VideoParams params(8, 8, PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(8, 8, PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); - auto frame = olive::Frame::Create(); + auto frame = olive::Frame::create(); frame->set_video_params(params); frame->allocate(); @@ -97,20 +97,20 @@ TEST(CommonOIIOUtils, FrameBufferRoundTripPreservesPixels) OIIO::ImageSpec spec(params.effective_width(), params.effective_height(), params.channel_count(), - olive::OIIOUtils::GetOIIOBaseTypeFromFormat( + olive::OIIOUtils::get_oiio_base_type_from_format( params.format())); OIIO::ImageBuf buf(spec); ASSERT_TRUE(buf.initialized()); - olive::OIIOUtils::FrameToBuffer(frame.get(), &buf); + olive::OIIOUtils::frame_to_buffer(frame.get(), &buf); - auto out = olive::Frame::Create(); + auto out = olive::Frame::create(); out->set_video_params(params); out->allocate(); // Poison the output so a failed transfer is visible. std::memset(out->data(), 0xFF, out->allocated_size()); - olive::OIIOUtils::BufferToFrame(&buf, out.get()); + olive::OIIOUtils::buffer_to_frame(&buf, out.get()); const olive::Color a = out->get_pixel(0, 0); EXPECT_NEAR(a.red(), 0.1f, 1e-5f); diff --git a/tests/gtest/common_qtutils_test.cpp b/tests/gtest/common_qtutils_test.cpp index 10ed04232..284c86e2d 100644 --- a/tests/gtest/common_qtutils_test.cpp +++ b/tests/gtest/common_qtutils_test.cpp @@ -11,8 +11,8 @@ TEST(CommonQtUtils, PtrToValueAndBack) { int value = 42; void *ptr = &value; - QVariant v = olive::QtUtils::PtrToValue(ptr); - EXPECT_EQ(olive::QtUtils::ValueToPtr(v), &value); + QVariant v = olive::QtUtils::ptr_to_value(ptr); + EXPECT_EQ(olive::QtUtils::value_to_ptr(v), &value); } TEST(CommonQtUtils, GetParentOfType) @@ -20,8 +20,8 @@ TEST(CommonQtUtils, GetParentOfType) QWidget root; QLabel *child = new QLabel(&root); - EXPECT_EQ(olive::QtUtils::GetParentOfType(child), nullptr); - EXPECT_EQ(olive::QtUtils::GetParentOfType(child), &root); + EXPECT_EQ(olive::QtUtils::get_parent_of_type(child), nullptr); + EXPECT_EQ(olive::QtUtils::get_parent_of_type(child), &root); } TEST(CommonQtUtils, FlipControlAndShiftModifiers) @@ -31,24 +31,24 @@ TEST(CommonQtUtils, FlipControlAndShiftModifiers) // always swaps Control and Shift. This test documents current behavior. Qt::KeyboardModifiers both = Qt::ControlModifier | Qt::ShiftModifier; Qt::KeyboardModifiers flipped = - olive::QtUtils::FlipControlAndShiftModifiers(both); + olive::QtUtils::flip_control_and_shift_modifiers(both); EXPECT_TRUE(flipped & Qt::ControlModifier); EXPECT_FALSE(flipped & Qt::ShiftModifier); Qt::KeyboardModifiers only_shift = Qt::ShiftModifier | Qt::AltModifier; - flipped = olive::QtUtils::FlipControlAndShiftModifiers(only_shift); + flipped = olive::QtUtils::flip_control_and_shift_modifiers(only_shift); EXPECT_TRUE(flipped & Qt::ControlModifier); EXPECT_FALSE(flipped & Qt::ShiftModifier); EXPECT_TRUE(flipped & Qt::AltModifier); Qt::KeyboardModifiers only_ctrl = Qt::ControlModifier | Qt::AltModifier; - flipped = olive::QtUtils::FlipControlAndShiftModifiers(only_ctrl); + flipped = olive::QtUtils::flip_control_and_shift_modifiers(only_ctrl); EXPECT_FALSE(flipped & Qt::ControlModifier); EXPECT_TRUE(flipped & Qt::ShiftModifier); EXPECT_TRUE(flipped & Qt::AltModifier); Qt::KeyboardModifiers none; - EXPECT_EQ(olive::QtUtils::FlipControlAndShiftModifiers(none), none); + EXPECT_EQ(olive::QtUtils::flip_control_and_shift_modifiers(none), none); } TEST(CommonQtUtils, SetComboBoxDataByInt) @@ -58,11 +58,11 @@ TEST(CommonQtUtils, SetComboBoxDataByInt) cb.addItem(QStringLiteral("B"), 2); cb.addItem(QStringLiteral("C"), 3); - olive::QtUtils::SetComboBoxData(&cb, 2); + olive::QtUtils::set_combo_box_data(&cb, 2); EXPECT_EQ(cb.currentData().toInt(), 2); EXPECT_EQ(cb.currentText(), QStringLiteral("B")); - olive::QtUtils::SetComboBoxData(&cb, 42); + olive::QtUtils::set_combo_box_data(&cb, 42); EXPECT_EQ(cb.currentData().toInt(), 2); } @@ -72,10 +72,10 @@ TEST(CommonQtUtils, SetComboBoxDataByString) cb.addItem(QStringLiteral("A"), QStringLiteral("alpha")); cb.addItem(QStringLiteral("B"), QStringLiteral("beta")); - olive::QtUtils::SetComboBoxData(&cb, QStringLiteral("beta")); + olive::QtUtils::set_combo_box_data(&cb, QStringLiteral("beta")); EXPECT_EQ(cb.currentData().toString(), QStringLiteral("beta")); - olive::QtUtils::SetComboBoxData(&cb, QStringLiteral("missing")); + olive::QtUtils::set_combo_box_data(&cb, QStringLiteral("missing")); EXPECT_EQ(cb.currentData().toString(), QStringLiteral("beta")); } @@ -86,13 +86,13 @@ TEST(CommonQtUtils, QFontMetricsWidth) QString text = QStringLiteral("Olive"); // Thin wrapper: must forward to QFontMetrics::horizontalAdvance exactly - EXPECT_EQ(olive::QtUtils::QFontMetricsWidth(fm, text), + EXPECT_EQ(olive::QtUtils::q_font_metrics_width(fm, text), fm.horizontalAdvance(text)); } TEST(CommonQtUtils, CreateHorizontalLine) { - QFrame *line = olive::QtUtils::CreateHorizontalLine(); + QFrame *line = olive::QtUtils::create_horizontal_line(); ASSERT_NE(line, nullptr); EXPECT_EQ(line->frameShape(), QFrame::HLine); delete line; @@ -100,7 +100,7 @@ TEST(CommonQtUtils, CreateHorizontalLine) TEST(CommonQtUtils, CreateVerticalLine) { - QFrame *line = olive::QtUtils::CreateVerticalLine(); + QFrame *line = olive::QtUtils::create_vertical_line(); ASSERT_NE(line, nullptr); EXPECT_EQ(line->frameShape(), QFrame::VLine); delete line; @@ -109,7 +109,7 @@ TEST(CommonQtUtils, CreateVerticalLine) TEST(CommonQtUtils, ToQColor) { olive::core::Color c(0.1f, 0.2f, 0.3f, 0.4f); - QColor qc = olive::QtUtils::toQColor(c); + QColor qc = olive::QtUtils::to_q_color(c); EXPECT_NEAR(qc.redF(), 0.1, 0.001); EXPECT_NEAR(qc.greenF(), 0.2, 0.001); EXPECT_NEAR(qc.blueF(), 0.3, 0.001); @@ -122,7 +122,7 @@ TEST(CommonQtUtils, GetFormattedDateTime) Qt::ISODate); // Qt::TextDate renders "ddd MMM d HH:mm:ss yyyy" in the C locale - EXPECT_EQ(olive::QtUtils::GetFormattedDateTime(dt), + EXPECT_EQ(olive::QtUtils::get_formatted_date_time(dt), QStringLiteral("Wed Jan 15 10:30:00 2025")); } @@ -133,18 +133,18 @@ TEST(CommonQtUtils, WordWrapString) // A string wider than the bounding width must be split into // multiple lines - QStringList wrapped = olive::QtUtils::WordWrapString( + QStringList wrapped = olive::QtUtils::word_wrap_string( QStringLiteral("hello world foo bar"), fm, 40); EXPECT_GT(wrapped.size(), 1); // A string that fits stays on a single line, untouched - wrapped = olive::QtUtils::WordWrapString( + wrapped = olive::QtUtils::word_wrap_string( QStringLiteral("hello world foo bar"), fm, 100000); EXPECT_EQ(wrapped.size(), 1); EXPECT_EQ(wrapped.first(), QStringLiteral("hello world foo bar")); // Should preserve manual newlines - wrapped = olive::QtUtils::WordWrapString(QStringLiteral("line1\nline2"), fm, + wrapped = olive::QtUtils::word_wrap_string(QStringLiteral("line1\nline2"), fm, 1000); EXPECT_EQ(wrapped.size(), 2); EXPECT_EQ(wrapped.at(0), QStringLiteral("line1")); @@ -154,7 +154,7 @@ TEST(CommonQtUtils, WordWrapString) TEST(CommonQtUtils, ToQColorClampsValues) { olive::core::Color c(2.0f, -1.0f, 0.5f, 1.5f); - QColor qc = olive::QtUtils::toQColor(c); + QColor qc = olive::QtUtils::to_q_color(c); EXPECT_NEAR(qc.redF(), 1.0, 0.001); EXPECT_NEAR(qc.greenF(), 0.0, 0.001); EXPECT_NEAR(qc.blueF(), 0.5, 0.001); @@ -163,29 +163,29 @@ TEST(CommonQtUtils, ToQColorClampsValues) TEST(CommonQtUtils, qHashRational) { - using olive::core::rational; + using olive::core::Rational; // Hash contract: equal rationals must hash equally - EXPECT_EQ(qHash(rational(3, 4)), qHash(rational(3, 4))); - EXPECT_EQ(qHash(rational(3, 4)), qHash(rational(6, 8))); + EXPECT_EQ(qHash(Rational(3, 4)), qHash(Rational(3, 4))); + EXPECT_EQ(qHash(Rational(3, 4)), qHash(Rational(6, 8))); // Distinct values must hash differently - EXPECT_NE(qHash(rational(3, 4)), qHash(rational(1, 2))); - EXPECT_NE(qHash(rational(1, 3)), qHash(rational(2, 3))); + EXPECT_NE(qHash(Rational(3, 4)), qHash(Rational(1, 2))); + EXPECT_NE(qHash(Rational(1, 3)), qHash(Rational(2, 3))); } TEST(CommonQtUtils, qHashTimeRange) { - using olive::core::rational; + using olive::core::Rational; using olive::core::TimeRange; // Hash contract: equal ranges must hash equally - EXPECT_EQ(qHash(TimeRange(rational(1), rational(5))), - qHash(TimeRange(rational(1), rational(5)))); + EXPECT_EQ(qHash(TimeRange(Rational(1), Rational(5))), + qHash(TimeRange(Rational(1), Rational(5)))); // Ranges differing in their in- or out-point must hash differently - EXPECT_NE(qHash(TimeRange(rational(1), rational(5))), - qHash(TimeRange(rational(2), rational(5)))); - EXPECT_NE(qHash(TimeRange(rational(1), rational(5))), - qHash(TimeRange(rational(1), rational(6)))); + EXPECT_NE(qHash(TimeRange(Rational(1), Rational(5))), + qHash(TimeRange(Rational(2), Rational(5)))); + EXPECT_NE(qHash(TimeRange(Rational(1), Rational(5))), + qHash(TimeRange(Rational(1), Rational(6)))); } diff --git a/tests/gtest/common_range_test.cpp b/tests/gtest/common_range_test.cpp index 307a823bb..914fc81a5 100644 --- a/tests/gtest/common_range_test.cpp +++ b/tests/gtest/common_range_test.cpp @@ -4,23 +4,23 @@ TEST(CommonRange, InRangeExact) { - EXPECT_TRUE(InRange(5, 5, 0)); + EXPECT_TRUE(in_range(5, 5, 0)); } TEST(CommonRange, InRangeWithinTolerance) { - EXPECT_TRUE(InRange(5.0, 5.5, 1.0)); - EXPECT_TRUE(InRange(5.0, 4.5, 1.0)); + EXPECT_TRUE(in_range(5.0, 5.5, 1.0)); + EXPECT_TRUE(in_range(5.0, 4.5, 1.0)); } TEST(CommonRange, OutOfRange) { - EXPECT_FALSE(InRange(5.0, 7.0, 1.0)); - EXPECT_FALSE(InRange(5.0, 3.0, 1.0)); + EXPECT_FALSE(in_range(5.0, 7.0, 1.0)); + EXPECT_FALSE(in_range(5.0, 3.0, 1.0)); } TEST(CommonRange, BoundaryValues) { - EXPECT_TRUE(InRange(5.0, 6.0, 1.0)); - EXPECT_TRUE(InRange(5.0, 4.0, 1.0)); + EXPECT_TRUE(in_range(5.0, 6.0, 1.0)); + EXPECT_TRUE(in_range(5.0, 4.0, 1.0)); } diff --git a/tests/gtest/common_ratiodialog_test.cpp b/tests/gtest/common_ratiodialog_test.cpp index 1a7239078..1572eaeb4 100644 --- a/tests/gtest/common_ratiodialog_test.cpp +++ b/tests/gtest/common_ratiodialog_test.cpp @@ -22,12 +22,12 @@ public: explicit DialogDriver(const QStringList &responses) : responses_(responses) { - connect(&timer_, &QTimer::timeout, this, &DialogDriver::Step); + connect(&timer_, &QTimer::timeout, this, &DialogDriver::step); timer_.start(10); } private: - void Step() + void step() { QWidget *modal = QApplication::activeModalWidget(); if (!modal) { @@ -67,7 +67,7 @@ TEST(CommonRatioDialog, AcceptsPlainDecimal) DialogDriver driver({ QStringLiteral("1.5") }); bool ok = false; - const double ratio = GetFloatRatioFromUser(nullptr, QStringLiteral("Test"), &ok); + const double ratio = get_float_ratio_from_user(nullptr, QStringLiteral("Test"), &ok); EXPECT_TRUE(ok); EXPECT_DOUBLE_EQ(ratio, 1.5); @@ -78,7 +78,7 @@ TEST(CommonRatioDialog, AcceptsColonSeparatedRatio) DialogDriver driver({ QStringLiteral("16:9") }); bool ok = false; - const double ratio = GetFloatRatioFromUser(nullptr, QStringLiteral("Test"), &ok); + const double ratio = get_float_ratio_from_user(nullptr, QStringLiteral("Test"), &ok); EXPECT_TRUE(ok); EXPECT_DOUBLE_EQ(ratio, 16.0 / 9.0); @@ -89,7 +89,7 @@ TEST(CommonRatioDialog, AcceptsSlashSeparatedRatio) DialogDriver driver({ QStringLiteral("4/3") }); bool ok = false; - const double ratio = GetFloatRatioFromUser(nullptr, QStringLiteral("Test"), &ok); + const double ratio = get_float_ratio_from_user(nullptr, QStringLiteral("Test"), &ok); EXPECT_TRUE(ok); EXPECT_DOUBLE_EQ(ratio, 4.0 / 3.0); @@ -100,7 +100,7 @@ TEST(CommonRatioDialog, AcceptsSemicolonSeparatedRatio) DialogDriver driver({ QStringLiteral("1;2") }); bool ok = false; - const double ratio = GetFloatRatioFromUser(nullptr, QStringLiteral("Test"), &ok); + const double ratio = get_float_ratio_from_user(nullptr, QStringLiteral("Test"), &ok); EXPECT_TRUE(ok); EXPECT_DOUBLE_EQ(ratio, 0.5); @@ -112,7 +112,7 @@ TEST(CommonRatioDialog, CancelReturnsNaN) DialogDriver driver({}); bool ok = true; - const double ratio = GetFloatRatioFromUser(nullptr, QStringLiteral("Test"), &ok); + const double ratio = get_float_ratio_from_user(nullptr, QStringLiteral("Test"), &ok); EXPECT_FALSE(ok); EXPECT_TRUE(std::isnan(ratio)); @@ -125,7 +125,7 @@ TEST(CommonRatioDialog, InvalidInputWarnsAndRetries) DialogDriver driver({ QStringLiteral("banana"), QStringLiteral("2") }); bool ok = false; - const double ratio = GetFloatRatioFromUser(nullptr, QStringLiteral("Test"), &ok); + const double ratio = get_float_ratio_from_user(nullptr, QStringLiteral("Test"), &ok); EXPECT_TRUE(ok); EXPECT_DOUBLE_EQ(ratio, 2.0); @@ -139,7 +139,7 @@ TEST(CommonRatioDialog, RejectsNonPositiveValues) { QStringLiteral("0"), QStringLiteral("-4:2"), QStringLiteral("3") }); bool ok = false; - const double ratio = GetFloatRatioFromUser(nullptr, QStringLiteral("Test"), &ok); + const double ratio = get_float_ratio_from_user(nullptr, QStringLiteral("Test"), &ok); EXPECT_TRUE(ok); EXPECT_DOUBLE_EQ(ratio, 3.0); diff --git a/tests/gtest/common_xmlutils_test.cpp b/tests/gtest/common_xmlutils_test.cpp index 40c58be5a..2ddbe5d2a 100644 --- a/tests/gtest/common_xmlutils_test.cpp +++ b/tests/gtest/common_xmlutils_test.cpp @@ -13,9 +13,9 @@ TEST(CommonXmlUtils, ReadNextStartElement) buffer.open(QIODevice::ReadOnly); QXmlStreamReader reader(&buffer); - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader)); EXPECT_EQ(reader.name().toString(), QStringLiteral("root")); - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader)); EXPECT_EQ(reader.name().toString(), QStringLiteral("child")); } @@ -26,9 +26,9 @@ TEST(CommonXmlUtils, ReadNextStartElementSkipsWhitespace) buffer.open(QIODevice::ReadOnly); QXmlStreamReader reader(&buffer); - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader)); EXPECT_EQ(reader.name().toString(), QStringLiteral("root")); - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader)); EXPECT_EQ(reader.name().toString(), QStringLiteral("child")); } @@ -39,9 +39,9 @@ TEST(CommonXmlUtils, ReadNextStartElementReturnsFalseAtEnd) buffer.open(QIODevice::ReadOnly); QXmlStreamReader reader(&buffer); - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader)); EXPECT_EQ(reader.name().toString(), QStringLiteral("root")); - EXPECT_FALSE(olive::XMLReadNextStartElement(&reader)); + EXPECT_FALSE(olive::xml_read_next_start_element(&reader)); } TEST(CommonXmlUtils, ReadNextStartElementSkipsUnknown) @@ -51,11 +51,11 @@ TEST(CommonXmlUtils, ReadNextStartElementSkipsUnknown) buffer.open(QIODevice::ReadOnly); QXmlStreamReader reader(&buffer); - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader)); - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader)); EXPECT_EQ(reader.name().toString(), QStringLiteral("unknown")); reader.skipCurrentElement(); - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader)); EXPECT_EQ(reader.name().toString(), QStringLiteral("known")); } @@ -67,7 +67,7 @@ TEST(CommonXmlUtils, ReadNextStartElementWithCancel) QXmlStreamReader reader(&buffer); olive::CancelAtom atom; - EXPECT_TRUE(olive::XMLReadNextStartElement(&reader, &atom)); + EXPECT_TRUE(olive::xml_read_next_start_element(&reader, &atom)); EXPECT_EQ(reader.name().toString(), QStringLiteral("root")); } @@ -79,6 +79,6 @@ TEST(CommonXmlUtils, ReadNextStartElementRespectsCancel) QXmlStreamReader reader(&buffer); olive::CancelAtom atom; - atom.Cancel(); - EXPECT_FALSE(olive::XMLReadNextStartElement(&reader, &atom)); + atom.cancel(); + EXPECT_FALSE(olive::xml_read_next_start_element(&reader, &atom)); } diff --git a/tests/gtest/config_test.cpp b/tests/gtest/config_test.cpp index 78963d12a..3681a4c85 100644 --- a/tests/gtest/config_test.cpp +++ b/tests/gtest/config_test.cpp @@ -5,8 +5,8 @@ TEST(Config, DefaultsPresent) { - olive::Config &cfg = olive::Config::Current(); - cfg.SetDefaults(); + olive::Config &cfg = olive::Config::current(); + cfg.set_defaults(); EXPECT_TRUE(cfg[QStringLiteral("Style")].isValid()); EXPECT_TRUE(cfg[QStringLiteral("TimecodeDisplay")].isValid()); @@ -17,7 +17,7 @@ TEST(Config, DefaultsPresent) TEST(Config, SetAndGetValues) { - olive::Config &cfg = olive::Config::Current(); + olive::Config &cfg = olive::Config::current(); cfg[QStringLiteral("UnitTestValue")] = 42; EXPECT_EQ(cfg[QStringLiteral("UnitTestValue")].toInt(), 42); @@ -33,7 +33,7 @@ TEST(Config, SetAndGetValues) // Config offers no key-removal API, so reset the singleton to its // default state to avoid leaking the UnitTest* keys into later tests - cfg.SetDefaults(); + cfg.set_defaults(); EXPECT_FALSE(cfg[QStringLiteral("UnitTestValue")].isValid()); EXPECT_FALSE(cfg[QStringLiteral("UnitTestString")].isValid()); EXPECT_FALSE(cfg[QStringLiteral("UnitTestBool")].isValid()); @@ -42,41 +42,41 @@ TEST(Config, SetAndGetValues) TEST(Config, MissingKeyReturnsInvalidVariant) { - olive::Config &cfg = olive::Config::Current(); + olive::Config &cfg = olive::Config::current(); EXPECT_FALSE(cfg[QStringLiteral("DefinitelyMissingKey")].isValid()); } TEST(Config, GraphicsBackendStringConversion) { - EXPECT_EQ(olive::RenderManager::BackendFromString(QStringLiteral("opengl")), - olive::RenderManager::kOpenGL); - EXPECT_EQ(olive::RenderManager::BackendFromString(QStringLiteral("vulkan")), - olive::RenderManager::kVulkan); - EXPECT_EQ(olive::RenderManager::BackendFromString(QStringLiteral("dummy")), - olive::RenderManager::kDummy); + EXPECT_EQ(olive::RenderManager::backend_from_string(QStringLiteral("opengl")), + olive::RenderManager::k_open_gl); + EXPECT_EQ(olive::RenderManager::backend_from_string(QStringLiteral("vulkan")), + olive::RenderManager::k_vulkan); + EXPECT_EQ(olive::RenderManager::backend_from_string(QStringLiteral("dummy")), + olive::RenderManager::k_dummy); EXPECT_EQ( - olive::RenderManager::BackendFromString(QStringLiteral("multiprocess")), - olive::RenderManager::kMultiProcess); + olive::RenderManager::backend_from_string(QStringLiteral("multiprocess")), + olive::RenderManager::k_multi_process); EXPECT_EQ( - olive::RenderManager::BackendToString(olive::RenderManager::kOpenGL), + olive::RenderManager::backend_to_string(olive::RenderManager::k_open_gl), QStringLiteral("opengl")); EXPECT_EQ( - olive::RenderManager::BackendToString(olive::RenderManager::kVulkan), + olive::RenderManager::backend_to_string(olive::RenderManager::k_vulkan), QStringLiteral("vulkan")); EXPECT_EQ( - olive::RenderManager::BackendToString(olive::RenderManager::kDummy), + olive::RenderManager::backend_to_string(olive::RenderManager::k_dummy), QStringLiteral("dummy")); - EXPECT_EQ(olive::RenderManager::BackendToString( - olive::RenderManager::kMultiProcess), + EXPECT_EQ(olive::RenderManager::backend_to_string( + olive::RenderManager::k_multi_process), QStringLiteral("multiprocess")); - EXPECT_EQ(olive::RenderManager::BackendFromString(QStringLiteral("bad")), - olive::RenderManager::kOpenGL); + EXPECT_EQ(olive::RenderManager::backend_from_string(QStringLiteral("bad")), + olive::RenderManager::k_open_gl); } TEST(Config, SetDefaultsPopulatesRequiredKeys) { - olive::Config &cfg = olive::Config::Current(); - cfg.SetDefaults(); + olive::Config &cfg = olive::Config::current(); + cfg.set_defaults(); const QStringList required = { QStringLiteral("Style"), diff --git a/tests/gtest/core_bezier_test.cpp b/tests/gtest/core_bezier_test.cpp index 7263574c7..7ef82d726 100644 --- a/tests/gtest/core_bezier_test.cpp +++ b/tests/gtest/core_bezier_test.cpp @@ -53,21 +53,21 @@ TEST(CoreBezier, Setters) TEST(CoreBezier, QuadraticXtoT) { - double t = Bezier::QuadraticXtoT(0.5, 0.0, 0.5, 1.0); + double t = Bezier::quadratic_xto_t(0.5, 0.0, 0.5, 1.0); EXPECT_NEAR(t, 0.5, 0.00001); - t = Bezier::QuadraticXtoT(0.0, 0.0, 0.5, 1.0); + t = Bezier::quadratic_xto_t(0.0, 0.0, 0.5, 1.0); EXPECT_NEAR(t, 0.0, 0.00001); - t = Bezier::QuadraticXtoT(1.0, 0.0, 0.5, 1.0); + t = Bezier::quadratic_xto_t(1.0, 0.0, 0.5, 1.0); EXPECT_NEAR(t, 1.0, 0.00001); } TEST(CoreBezier, QuadraticTtoY) { - EXPECT_NEAR(Bezier::QuadraticTtoY(0.0, 0.5, 1.0, 0.0), 0.0, 0.00001); - EXPECT_NEAR(Bezier::QuadraticTtoY(0.0, 0.5, 1.0, 0.5), 0.5, 0.00001); - EXPECT_NEAR(Bezier::QuadraticTtoY(0.0, 0.5, 1.0, 1.0), 1.0, 0.00001); + EXPECT_NEAR(Bezier::quadratic_tto_y(0.0, 0.5, 1.0, 0.0), 0.0, 0.00001); + EXPECT_NEAR(Bezier::quadratic_tto_y(0.0, 0.5, 1.0, 0.5), 0.5, 0.00001); + EXPECT_NEAR(Bezier::quadratic_tto_y(0.0, 0.5, 1.0, 1.0), 1.0, 0.00001); } TEST(CoreBezier, QuadraticXtoY) @@ -76,7 +76,7 @@ TEST(CoreBezier, QuadraticXtoY) Imath::V2d b(0.5, 0.5); Imath::V2d c(1.0, 1.0); - EXPECT_NEAR(Bezier::QuadraticXtoY(0.5, a, b, c), 0.5, 0.00001); + EXPECT_NEAR(Bezier::quadratic_xto_y(0.5, a, b, c), 0.5, 0.00001); } TEST(CoreBezier, CubicXtoT) @@ -86,14 +86,14 @@ TEST(CoreBezier, CubicXtoT) // and x(t) = 0.5 is solved by t = 0.5037592 (Newton-Raphson). The // implementation bisects until |x(t) - x| < 1e-6 and dx/dt >= 0.99 on // [0,1], so the returned t is well within 1e-5 of the true root. - double t = Bezier::CubicXtoT(0.5, 0.0, 0.33, 0.66, 1.0); + double t = Bezier::cubic_xto_t(0.5, 0.0, 0.33, 0.66, 1.0); EXPECT_NEAR(t, 0.5037592, 1e-5); } TEST(CoreBezier, CubicTtoY) { - EXPECT_NEAR(Bezier::CubicTtoY(0.0, 0.33, 0.66, 1.0, 0.0), 0.0, 0.00001); - EXPECT_NEAR(Bezier::CubicTtoY(0.0, 0.33, 0.66, 1.0, 1.0), 1.0, 0.00001); + EXPECT_NEAR(Bezier::cubic_tto_y(0.0, 0.33, 0.66, 1.0, 0.0), 0.0, 0.00001); + EXPECT_NEAR(Bezier::cubic_tto_y(0.0, 0.33, 0.66, 1.0, 1.0), 1.0, 0.00001); } TEST(CoreBezier, CubicXtoY) @@ -108,7 +108,7 @@ TEST(CoreBezier, CubicXtoY) // the y curve is y(t) = 3(1-t)t^2 + t^3 = 3t^2 - 2t^3, which then yields // y = 0.5056392. The implementation's 1e-6 bisection tolerance in x is // amplified by dy/dt < 1.5, keeping the y error well under 1e-5. - double y = Bezier::CubicXtoY(0.5, a, b, c, d); + double y = Bezier::cubic_xto_y(0.5, a, b, c, d); EXPECT_NEAR(y, 0.5056392, 1e-5); } diff --git a/tests/gtest/core_color_test.cpp b/tests/gtest/core_color_test.cpp index 94196ea95..a54f5ef22 100644 --- a/tests/gtest/core_color_test.cpp +++ b/tests/gtest/core_color_test.cpp @@ -38,7 +38,7 @@ TEST(CoreColor, SettersAndDataAccess) TEST(CoreColor, FromHsvRed) { - Color c = Color::fromHsv(0.0f, 1.0f, 1.0f); + Color c = Color::from_hsv(0.0f, 1.0f, 1.0f); EXPECT_NEAR(c.red(), 1.0f, 0.001f); EXPECT_NEAR(c.green(), 0.0f, 0.001f); EXPECT_NEAR(c.blue(), 0.0f, 0.001f); @@ -46,7 +46,7 @@ TEST(CoreColor, FromHsvRed) TEST(CoreColor, FromHsvGreen) { - Color c = Color::fromHsv(120.0f, 1.0f, 1.0f); + Color c = Color::from_hsv(120.0f, 1.0f, 1.0f); EXPECT_NEAR(c.red(), 0.0f, 0.001f); EXPECT_NEAR(c.green(), 1.0f, 0.001f); EXPECT_NEAR(c.blue(), 0.0f, 0.001f); @@ -54,7 +54,7 @@ TEST(CoreColor, FromHsvGreen) TEST(CoreColor, FromHsvBlue) { - Color c = Color::fromHsv(240.0f, 1.0f, 1.0f); + Color c = Color::from_hsv(240.0f, 1.0f, 1.0f); EXPECT_NEAR(c.red(), 0.0f, 0.001f); EXPECT_NEAR(c.green(), 0.0f, 0.001f); EXPECT_NEAR(c.blue(), 1.0f, 0.001f); @@ -64,7 +64,7 @@ TEST(CoreColor, HsvRoundTrip) { Color original(0.8f, 0.4f, 0.2f); float h, s, v; - original.toHsv(&h, &s, &v); + original.to_hsv(&h, &s, &v); // Independently derived expectation: max=0.8 (red), delta=0.6, so // h = 60*(g-b)/delta = 20, s = delta/max = 0.75, v = max = 0.8 @@ -73,7 +73,7 @@ TEST(CoreColor, HsvRoundTrip) EXPECT_NEAR(v, 0.8f, 0.0001f); // True round trip: converting the HSV values back must restore the color - Color restored = Color::fromHsv(h, s, v); + Color restored = Color::from_hsv(h, s, v); EXPECT_NEAR(restored.red(), original.red(), 0.0001f); EXPECT_NEAR(restored.green(), original.green(), 0.0001f); EXPECT_NEAR(restored.blue(), original.blue(), 0.0001f); @@ -83,7 +83,7 @@ TEST(CoreColor, HslRoundTrip) { Color original(0.2f, 0.5f, 0.8f); float h, s, l; - original.toHsl(&h, &s, &l); + original.to_hsl(&h, &s, &l); // Color has no fromHsl(), so instead of a round trip check the HSL // values against independently derived expectations: min=0.2, max=0.8, @@ -128,25 +128,25 @@ TEST(CoreColor, CompoundAssignment) TEST(CoreColor, GetRoughLuminance) { Color white(1.0f, 1.0f, 1.0f); - EXPECT_FLOAT_EQ(white.GetRoughLuminance(), 1.0f); + EXPECT_FLOAT_EQ(white.get_rough_luminance(), 1.0f); Color black(0.0f, 0.0f, 0.0f); - EXPECT_FLOAT_EQ(black.GetRoughLuminance(), 0.0f); + EXPECT_FLOAT_EQ(black.get_rough_luminance(), 0.0f); } TEST(CoreColor, ToDataAndFromDataU8) { Color c(1.0f, 0.5f, 0.0f, 1.0f); uint8_t data[4]; - c.toData(reinterpret_cast(data), PixelFormat::U8, 4); + c.to_data(reinterpret_cast(data), PixelFormat::u8, 4); EXPECT_EQ(data[0], 255u); EXPECT_EQ(data[1], 127u); EXPECT_EQ(data[2], 0u); EXPECT_EQ(data[3], 255u); - Color restored = Color::fromData(reinterpret_cast(data), - PixelFormat::U8, 4); + Color restored = Color::from_data(reinterpret_cast(data), + PixelFormat::u8, 4); EXPECT_NEAR(restored.red(), 1.0f, 0.01f); EXPECT_NEAR(restored.green(), 0.5f, 0.01f); } @@ -155,15 +155,15 @@ TEST(CoreColor, ToDataAndFromDataF32) { Color c(0.25f, 0.5f, 0.75f, 1.0f); float data[4]; - c.toData(reinterpret_cast(data), PixelFormat::F32, 4); + c.to_data(reinterpret_cast(data), PixelFormat::f32, 4); EXPECT_FLOAT_EQ(data[0], 0.25f); EXPECT_FLOAT_EQ(data[1], 0.5f); EXPECT_FLOAT_EQ(data[2], 0.75f); EXPECT_FLOAT_EQ(data[3], 1.0f); - Color restored = Color::fromData(reinterpret_cast(data), - PixelFormat::F32, 4); + Color restored = Color::from_data(reinterpret_cast(data), + PixelFormat::f32, 4); EXPECT_FLOAT_EQ(restored.red(), 0.25f); } @@ -171,10 +171,10 @@ TEST(CoreColor, ToDataAndFromDataU10) { Color c(1.0f, 0.5f, 0.0f, 1.0f); uint32_t data; - c.toData(reinterpret_cast(&data), PixelFormat::U10, 4); + c.to_data(reinterpret_cast(&data), PixelFormat::u10, 4); - Color restored = Color::fromData(reinterpret_cast(&data), - PixelFormat::U10, 4); + Color restored = Color::from_data(reinterpret_cast(&data), + PixelFormat::u10, 4); EXPECT_NEAR(restored.red(), 1.0f, 0.001f); EXPECT_NEAR(restored.green(), 0.5f, 0.001f); EXPECT_NEAR(restored.blue(), 0.0f, 0.001f); diff --git a/tests/gtest/core_rational_test.cpp b/tests/gtest/core_rational_test.cpp index 98ee9e549..42869bebb 100644 --- a/tests/gtest/core_rational_test.cpp +++ b/tests/gtest/core_rational_test.cpp @@ -10,35 +10,35 @@ using namespace olive::core; TEST(CoreRational, DefaultConstruction) { - rational r; + Rational r; EXPECT_EQ(r.numerator(), 0); EXPECT_EQ(r.denominator(), 1); } TEST(CoreRational, IntegerConstruction) { - rational r(5); + Rational r(5); EXPECT_EQ(r.numerator(), 5); EXPECT_EQ(r.denominator(), 1); } TEST(CoreRational, FractionConstructionReduces) { - rational r(4, 8); + Rational r(4, 8); EXPECT_EQ(r.numerator(), 1); EXPECT_EQ(r.denominator(), 2); } TEST(CoreRational, NegativeDenominatorNormalizes) { - rational r(1, -2); + Rational r(1, -2); EXPECT_EQ(r.numerator(), -1); EXPECT_EQ(r.denominator(), 2); } TEST(CoreRational, ZeroNormalizes) { - rational r(0, 5); + Rational r(0, 5); EXPECT_EQ(r.numerator(), 0); EXPECT_EQ(r.denominator(), 1); } @@ -46,11 +46,11 @@ TEST(CoreRational, ZeroNormalizes) TEST(CoreRational, FromDouble) { bool ok = false; - rational r = rational::fromDouble(0.5, &ok); + Rational r = Rational::from_double(0.5, &ok); EXPECT_TRUE(ok); - EXPECT_EQ(r, rational(1, 2)); + EXPECT_EQ(r, Rational(1, 2)); - r = rational::fromDouble(std::numeric_limits::quiet_NaN(), &ok); + r = Rational::from_double(std::numeric_limits::quiet_NaN(), &ok); EXPECT_FALSE(ok); EXPECT_TRUE(r.isNaN()); } @@ -58,56 +58,56 @@ TEST(CoreRational, FromDouble) TEST(CoreRational, FromString) { bool ok = false; - rational r = rational::fromString("3/4", &ok); + Rational r = Rational::from_string("3/4", &ok); EXPECT_TRUE(ok); - EXPECT_EQ(r, rational(3, 4)); + EXPECT_EQ(r, Rational(3, 4)); - r = rational::fromString("42", &ok); + r = Rational::from_string("42", &ok); EXPECT_TRUE(ok); - EXPECT_EQ(r, rational(42)); + EXPECT_EQ(r, Rational(42)); - r = rational::fromString("1/2/3", &ok); + r = Rational::from_string("1/2/3", &ok); EXPECT_FALSE(ok); EXPECT_TRUE(r.isNaN()); } TEST(CoreRational, ToDouble) { - EXPECT_DOUBLE_EQ(rational(1, 2).toDouble(), 0.5); - EXPECT_TRUE(std::isnan(rational::NaN.toDouble())); + EXPECT_DOUBLE_EQ(Rational(1, 2).to_double(), 0.5); + EXPECT_TRUE(std::isnan(Rational::na_n.to_double())); } TEST(CoreRational, ToString) { - EXPECT_EQ(rational(1, 2).toString(), "1/2"); + EXPECT_EQ(Rational(1, 2).to_string(), "1/2"); } TEST(CoreRational, Arithmetic) { - rational a(1, 2); - rational b(1, 3); + Rational a(1, 2); + Rational b(1, 3); - EXPECT_EQ(a + b, rational(5, 6)); - EXPECT_EQ(a - b, rational(1, 6)); - EXPECT_EQ(a * b, rational(1, 6)); - EXPECT_EQ(a / b, rational(3, 2)); + EXPECT_EQ(a + b, Rational(5, 6)); + EXPECT_EQ(a - b, Rational(1, 6)); + EXPECT_EQ(a * b, Rational(1, 6)); + EXPECT_EQ(a / b, Rational(3, 2)); } TEST(CoreRational, CompoundAssignment) { - rational a(1, 2); - a += rational(1, 4); - EXPECT_EQ(a, rational(3, 4)); + Rational a(1, 2); + a += Rational(1, 4); + EXPECT_EQ(a, Rational(3, 4)); - a *= rational(2, 3); - EXPECT_EQ(a, rational(1, 2)); + a *= Rational(2, 3); + EXPECT_EQ(a, Rational(1, 2)); } TEST(CoreRational, Comparisons) { - rational a(1, 2); - rational b(2, 4); - rational c(1, 3); + Rational a(1, 2); + Rational b(2, 4); + Rational c(1, 3); EXPECT_TRUE(a == b); EXPECT_FALSE(a != b); @@ -119,46 +119,46 @@ TEST(CoreRational, Comparisons) TEST(CoreRational, UnaryOperators) { - rational a(1, 2); + Rational a(1, 2); EXPECT_EQ(+a, a); - EXPECT_EQ(-a, rational(-1, 2)); + EXPECT_EQ(-a, Rational(-1, 2)); EXPECT_FALSE(!a); - rational zero(0); + Rational zero(0); EXPECT_TRUE(!zero); } TEST(CoreRational, Flip) { - rational a(2, 3); + Rational a(2, 3); a.flip(); - EXPECT_EQ(a, rational(3, 2)); + EXPECT_EQ(a, Rational(3, 2)); - rational zero(0); + Rational zero(0); zero.flip(); - EXPECT_EQ(zero, rational(0)); + EXPECT_EQ(zero, Rational(0)); } TEST(CoreRational, Flipped) { - EXPECT_EQ(rational(2, 3).flipped(), rational(3, 2)); + EXPECT_EQ(Rational(2, 3).flipped(), Rational(3, 2)); } TEST(CoreRational, IsNullAndIsNaN) { - rational zero(0); + Rational zero(0); EXPECT_TRUE(zero.isNull()); EXPECT_FALSE(zero.isNaN()); - rational nan = rational::NaN; + Rational nan = Rational::na_n; EXPECT_TRUE(nan.isNaN()); EXPECT_TRUE(nan.isNull()); } TEST(CoreRational, NaNPropagation) { - rational a(1, 2); - rational nan = rational::NaN; + Rational a(1, 2); + Rational nan = Rational::na_n; a += nan; EXPECT_TRUE(a.isNaN()); @@ -167,12 +167,12 @@ TEST(CoreRational, NaNPropagation) TEST(CoreRational, StreamOutput) { std::ostringstream oss; - oss << rational(3, 4); + oss << Rational(3, 4); EXPECT_EQ(oss.str(), "3/4"); } TEST(CoreRational, MinMaxConstants) { - EXPECT_TRUE(RATIONAL_MIN < rational(0)); - EXPECT_TRUE(RATIONAL_MAX > rational(0)); + EXPECT_TRUE(RATIONAL_MIN < Rational(0)); + EXPECT_TRUE(RATIONAL_MAX > Rational(0)); } diff --git a/tests/gtest/core_samplebuffer_test.cpp b/tests/gtest/core_samplebuffer_test.cpp index b979c4c27..edc86c2a5 100644 --- a/tests/gtest/core_samplebuffer_test.cpp +++ b/tests/gtest/core_samplebuffer_test.cpp @@ -4,9 +4,9 @@ using namespace olive::core; -static AudioParams MakeParams(int channels = 2, int sample_rate = 48000) +static AudioParams make_params(int channels = 2, int sample_rate = 48000) { - AudioParams params(sample_rate, kChannelLayoutStereo, SampleFormat::F32P); + AudioParams params(sample_rate, k_channel_layout_stereo, SampleFormat::f32_p); return params; } @@ -20,8 +20,8 @@ TEST(CoreSampleBuffer, DefaultConstruction) TEST(CoreSampleBuffer, AllocateByLength) { - AudioParams params = MakeParams(); - SampleBuffer b(params, rational(1, 24)); + AudioParams params = make_params(); + SampleBuffer b(params, Rational(1, 24)); EXPECT_TRUE(b.is_allocated()); EXPECT_EQ(b.channel_count(), 2); EXPECT_EQ(b.sample_count(), 2000u); @@ -29,7 +29,7 @@ TEST(CoreSampleBuffer, AllocateByLength) TEST(CoreSampleBuffer, AllocateBySampleCount) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 1024); EXPECT_TRUE(b.is_allocated()); EXPECT_EQ(b.sample_count(), 1024u); @@ -44,14 +44,14 @@ TEST(CoreSampleBuffer, AllocateInvalidParams) TEST(CoreSampleBuffer, AllocateZeroSampleCount) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 0); EXPECT_FALSE(b.is_allocated()); } TEST(CoreSampleBuffer, Destroy) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 100); EXPECT_TRUE(b.is_allocated()); b.destroy(); @@ -60,7 +60,7 @@ TEST(CoreSampleBuffer, Destroy) TEST(CoreSampleBuffer, SetAudioParamsBeforeAllocate) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b; b.set_audio_params(params); b.set_sample_count(100); @@ -70,7 +70,7 @@ TEST(CoreSampleBuffer, SetAudioParamsBeforeAllocate) TEST(CoreSampleBuffer, SetParamsOnAllocatedIsIgnored) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 100); AudioParams other; b.set_audio_params(other); @@ -79,7 +79,7 @@ TEST(CoreSampleBuffer, SetParamsOnAllocatedIsIgnored) TEST(CoreSampleBuffer, SetSampleCountOnAllocatedIsIgnored) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 100); b.set_sample_count(200); EXPECT_EQ(b.sample_count(), 100u); @@ -87,7 +87,7 @@ TEST(CoreSampleBuffer, SetSampleCountOnAllocatedIsIgnored) TEST(CoreSampleBuffer, DataAccess) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 0.1f; b.data(0)[1] = 0.2f; @@ -97,7 +97,7 @@ TEST(CoreSampleBuffer, DataAccess) TEST(CoreSampleBuffer, ToRawPtrs) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); std::vector ptrs = b.to_raw_ptrs(); EXPECT_EQ(ptrs.size(), 2u); @@ -107,7 +107,7 @@ TEST(CoreSampleBuffer, ToRawPtrs) TEST(CoreSampleBuffer, RipChannel) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 0.5f; b.data(1)[0] = 0.7f; @@ -119,7 +119,7 @@ TEST(CoreSampleBuffer, RipChannel) TEST(CoreSampleBuffer, RipChannelVector) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 0.3f; @@ -130,7 +130,7 @@ TEST(CoreSampleBuffer, RipChannelVector) TEST(CoreSampleBuffer, TransformVolume) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 0.5f; b.transform_volume(2.0f); @@ -139,7 +139,7 @@ TEST(CoreSampleBuffer, TransformVolume) TEST(CoreSampleBuffer, TransformVolumeForChannel) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 0.5f; b.data(1)[0] = 0.5f; @@ -150,7 +150,7 @@ TEST(CoreSampleBuffer, TransformVolumeForChannel) TEST(CoreSampleBuffer, TransformVolumeStatic) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer in(params, 4); SampleBuffer out(params, 4); in.data(0)[0] = 0.5f; @@ -160,7 +160,7 @@ TEST(CoreSampleBuffer, TransformVolumeStatic) TEST(CoreSampleBuffer, TransformVolumeForSample) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 0.5f; b.data(1)[0] = 0.5f; @@ -171,7 +171,7 @@ TEST(CoreSampleBuffer, TransformVolumeForSample) TEST(CoreSampleBuffer, Clamp) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 2.0f; b.data(0)[1] = -2.0f; @@ -182,7 +182,7 @@ TEST(CoreSampleBuffer, Clamp) TEST(CoreSampleBuffer, Silence) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 1.0f; b.silence(); @@ -191,7 +191,7 @@ TEST(CoreSampleBuffer, Silence) TEST(CoreSampleBuffer, SilenceRange) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 1.0f; b.data(0)[1] = 1.0f; @@ -206,7 +206,7 @@ TEST(CoreSampleBuffer, SilenceRange) TEST(CoreSampleBuffer, Set) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); float data[2] = { 0.3f, 0.4f }; b.set(0, data, 1, 2); @@ -216,7 +216,7 @@ TEST(CoreSampleBuffer, Set) TEST(CoreSampleBuffer, FastSet) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer src(params, 4); SampleBuffer dst(params, 4); src.data(1)[0] = 0.9f; @@ -226,7 +226,7 @@ TEST(CoreSampleBuffer, FastSet) TEST(CoreSampleBuffer, Reverse) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 0.1f; b.data(0)[1] = 0.2f; @@ -239,7 +239,7 @@ TEST(CoreSampleBuffer, Reverse) TEST(CoreSampleBuffer, Speed) { - AudioParams params = MakeParams(); + AudioParams params = make_params(); SampleBuffer b(params, 4); b.data(0)[0] = 0.1f; b.data(0)[1] = 0.2f; diff --git a/tests/gtest/core_timecode_test.cpp b/tests/gtest/core_timecode_test.cpp index 1d39f6e0d..cc768749a 100644 --- a/tests/gtest/core_timecode_test.cpp +++ b/tests/gtest/core_timecode_test.cpp @@ -6,63 +6,63 @@ using namespace olive::core; TEST(CoreTimecode, TimeToTimecodeSeconds) { - rational time(5, 1); - rational tb(1, 25); + Rational time(5, 1); + Rational tb(1, 25); std::string tc = - Timecode::time_to_timecode(time, tb, Timecode::kTimecodeSeconds); + Timecode::time_to_timecode(time, tb, Timecode::k_timecode_seconds); EXPECT_EQ(tc, "00:00:05.000"); } TEST(CoreTimecode, TimeToTimecodeNonDropFrame) { - rational time(2, 1); - rational tb(1, 25); + Rational time(2, 1); + Rational tb(1, 25); std::string tc = - Timecode::time_to_timecode(time, tb, Timecode::kTimecodeNonDropFrame); + Timecode::time_to_timecode(time, tb, Timecode::k_timecode_non_drop_frame); EXPECT_EQ(tc, "00:00:02:00"); } TEST(CoreTimecode, TimeToTimecodePlusSign) { - rational time(1, 1); - rational tb(1, 25); + Rational time(1, 1); + Rational tb(1, 25); std::string tc = - Timecode::time_to_timecode(time, tb, Timecode::kTimecodeSeconds, true); + Timecode::time_to_timecode(time, tb, Timecode::k_timecode_seconds, true); EXPECT_EQ(tc.substr(0, 1), "+"); } TEST(CoreTimecode, TimeToTimecodeInvalidTimebase) { - rational time(1, 1); - EXPECT_EQ(Timecode::time_to_timecode(time, rational(), Timecode::kFrames), + Rational time(1, 1); + EXPECT_EQ(Timecode::time_to_timecode(time, Rational(), Timecode::k_frames), "INVALID TIMEBASE"); } TEST(CoreTimecode, TimecodeToTimeSeconds) { - rational tb(1, 25); + Rational tb(1, 25); bool ok = false; - rational t = Timecode::timecode_to_time("00:00:05.500", tb, - Timecode::kTimecodeSeconds, &ok); + Rational t = Timecode::timecode_to_time("00:00:05.500", tb, + Timecode::k_timecode_seconds, &ok); EXPECT_TRUE(ok); - EXPECT_EQ(t, rational(11, 2)); + EXPECT_EQ(t, Rational(11, 2)); } TEST(CoreTimecode, TimecodeToTimeNonDropFrame) { - rational tb(1, 25); + Rational tb(1, 25); bool ok = false; - rational t = Timecode::timecode_to_time( - "00:00:02:03", tb, Timecode::kTimecodeNonDropFrame, &ok); + Rational t = Timecode::timecode_to_time( + "00:00:02:03", tb, Timecode::k_timecode_non_drop_frame, &ok); EXPECT_TRUE(ok); - EXPECT_EQ(t, rational(53, 25)); + EXPECT_EQ(t, Rational(53, 25)); } TEST(CoreTimecode, TimecodeToTimeInvalid) { - rational tb(1, 25); + Rational tb(1, 25); bool ok = true; - Timecode::timecode_to_time("not a timecode", tb, Timecode::kTimecodeSeconds, + Timecode::timecode_to_time("not a timecode", tb, Timecode::k_timecode_seconds, &ok); EXPECT_FALSE(ok); } @@ -74,50 +74,50 @@ TEST(CoreTimecode, TimeToString) TEST(CoreTimecode, SnapTimeToTimebase) { - rational tb(1, 25); - rational snapped = Timecode::snap_time_to_timebase(rational(1, 10), tb); + Rational tb(1, 25); + Rational snapped = Timecode::snap_time_to_timebase(Rational(1, 10), tb); // 0.1s @ 25fps rounds to frame 3 (0.12s) - EXPECT_EQ(snapped, rational(3, 25)); + EXPECT_EQ(snapped, Rational(3, 25)); } TEST(CoreTimecode, TimeToTimestamp) { - rational tb(1, 25); - EXPECT_EQ(Timecode::time_to_timestamp(rational(2, 1), tb), 50); + Rational tb(1, 25); + EXPECT_EQ(Timecode::time_to_timestamp(Rational(2, 1), tb), 50); // 0.08s @ 25fps lands exactly on frame 2, so the rounding mode // must not matter - EXPECT_EQ(Timecode::time_to_timestamp(0.08, tb, Timecode::kFloor), 2); - EXPECT_EQ(Timecode::time_to_timestamp(0.08, tb, Timecode::kCeil), 2); + EXPECT_EQ(Timecode::time_to_timestamp(0.08, tb, Timecode::k_floor), 2); + EXPECT_EQ(Timecode::time_to_timestamp(0.08, tb, Timecode::k_ceil), 2); // 0.1s @ 25fps is 2.5 frames: floor and ceil must differ - EXPECT_EQ(Timecode::time_to_timestamp(0.1, tb, Timecode::kFloor), 2); - EXPECT_EQ(Timecode::time_to_timestamp(0.1, tb, Timecode::kCeil), 3); + EXPECT_EQ(Timecode::time_to_timestamp(0.1, tb, Timecode::k_floor), 2); + EXPECT_EQ(Timecode::time_to_timestamp(0.1, tb, Timecode::k_ceil), 3); } TEST(CoreTimecode, TimestampToTime) { - rational tb(1, 25); - EXPECT_EQ(Timecode::timestamp_to_time(50, tb), rational(2, 1)); + Rational tb(1, 25); + EXPECT_EQ(Timecode::timestamp_to_time(50, tb), Rational(2, 1)); } TEST(CoreTimecode, RescaleTimestamp) { - rational src(1, 25); - rational dst(1, 30); + Rational src(1, 25); + Rational dst(1, 30); EXPECT_EQ(Timecode::rescale_timestamp(50, src, dst), 60); EXPECT_EQ(Timecode::rescale_timestamp(50, src, src), 50); } TEST(CoreTimecode, RescaleTimestampCeil) { - rational src(1, 25); - rational dst(1, 30); + Rational src(1, 25); + Rational dst(1, 30); EXPECT_EQ(Timecode::rescale_timestamp_ceil(1, src, dst), 2); } TEST(CoreTimecode, TimebaseIsDropFrame) { - EXPECT_FALSE(Timecode::timebase_is_drop_frame(rational(1, 25))); - EXPECT_TRUE(Timecode::timebase_is_drop_frame(rational(1001, 30000))); + EXPECT_FALSE(Timecode::timebase_is_drop_frame(Rational(1, 25))); + EXPECT_TRUE(Timecode::timebase_is_drop_frame(Rational(1001, 30000))); } diff --git a/tests/gtest/core_timerange_test.cpp b/tests/gtest/core_timerange_test.cpp index fa8fe1263..5723dbb0e 100644 --- a/tests/gtest/core_timerange_test.cpp +++ b/tests/gtest/core_timerange_test.cpp @@ -6,164 +6,164 @@ using namespace olive::core; TEST(CoreTimeRange, ConstructAndAccess) { - TimeRange r(rational(1), rational(5)); - EXPECT_EQ(r.in(), rational(1)); - EXPECT_EQ(r.out(), rational(5)); - EXPECT_EQ(r.length(), rational(4)); + TimeRange r(Rational(1), Rational(5)); + EXPECT_EQ(r.in(), Rational(1)); + EXPECT_EQ(r.out(), Rational(5)); + EXPECT_EQ(r.length(), Rational(4)); } TEST(CoreTimeRange, NormalizationSwapsReversedBounds) { - TimeRange r(rational(5), rational(1)); - EXPECT_EQ(r.in(), rational(1)); - EXPECT_EQ(r.out(), rational(5)); + TimeRange r(Rational(5), Rational(1)); + EXPECT_EQ(r.in(), Rational(1)); + EXPECT_EQ(r.out(), Rational(5)); } TEST(CoreTimeRange, SettersNormalize) { - TimeRange r(rational(0), rational(10)); - r.set_in(rational(15)); - EXPECT_EQ(r.in(), rational(10)); - EXPECT_EQ(r.out(), rational(15)); + TimeRange r(Rational(0), Rational(10)); + r.set_in(Rational(15)); + EXPECT_EQ(r.in(), Rational(10)); + EXPECT_EQ(r.out(), Rational(15)); - r.set_out(rational(2)); - EXPECT_EQ(r.in(), rational(2)); - EXPECT_EQ(r.out(), rational(10)); + r.set_out(Rational(2)); + EXPECT_EQ(r.in(), Rational(2)); + EXPECT_EQ(r.out(), Rational(10)); } TEST(CoreTimeRange, ContainsRational) { - TimeRange r(rational(0), rational(10)); - EXPECT_TRUE(r.Contains(rational(5))); - EXPECT_FALSE(r.Contains(rational(10))); - EXPECT_FALSE(r.Contains(rational(-1))); + TimeRange r(Rational(0), Rational(10)); + EXPECT_TRUE(r.contains(Rational(5))); + EXPECT_FALSE(r.contains(Rational(10))); + EXPECT_FALSE(r.contains(Rational(-1))); } TEST(CoreTimeRange, ContainsRange) { - TimeRange outer(rational(0), rational(10)); - TimeRange inner(rational(2), rational(8)); - TimeRange partial(rational(5), rational(15)); + TimeRange outer(Rational(0), Rational(10)); + TimeRange inner(Rational(2), Rational(8)); + TimeRange partial(Rational(5), Rational(15)); - EXPECT_TRUE(outer.Contains(inner)); - EXPECT_FALSE(outer.Contains(partial)); + EXPECT_TRUE(outer.contains(inner)); + EXPECT_FALSE(outer.contains(partial)); } TEST(CoreTimeRange, OverlapsWith) { - TimeRange a(rational(0), rational(10)); - TimeRange b(rational(5), rational(15)); - TimeRange c(rational(10), rational(20)); + TimeRange a(Rational(0), Rational(10)); + TimeRange b(Rational(5), Rational(15)); + TimeRange c(Rational(10), Rational(20)); - EXPECT_TRUE(a.OverlapsWith(b)); + EXPECT_TRUE(a.overlaps_with(b)); // By default bounds are inclusive, so [0,10] and [10,20] touch and overlap - EXPECT_TRUE(a.OverlapsWith(c)); - EXPECT_FALSE(a.OverlapsWith(c, false, false)); + EXPECT_TRUE(a.overlaps_with(c)); + EXPECT_FALSE(a.overlaps_with(c, false, false)); } TEST(CoreTimeRange, CombineAndIntersect) { - TimeRange a(rational(0), rational(10)); - TimeRange b(rational(5), rational(15)); + TimeRange a(Rational(0), Rational(10)); + TimeRange b(Rational(5), Rational(15)); - TimeRange combined = a.Combined(b); - EXPECT_EQ(combined.in(), rational(0)); - EXPECT_EQ(combined.out(), rational(15)); + TimeRange combined = a.combined(b); + EXPECT_EQ(combined.in(), Rational(0)); + EXPECT_EQ(combined.out(), Rational(15)); - TimeRange intersect = a.Intersected(b); - EXPECT_EQ(intersect.in(), rational(5)); - EXPECT_EQ(intersect.out(), rational(10)); + TimeRange intersect = a.intersected(b); + EXPECT_EQ(intersect.in(), Rational(5)); + EXPECT_EQ(intersect.out(), Rational(10)); } TEST(CoreTimeRange, Arithmetic) { - TimeRange r(rational(0), rational(10)); - TimeRange shifted = r + rational(5); - EXPECT_EQ(shifted.in(), rational(5)); - EXPECT_EQ(shifted.out(), rational(15)); + TimeRange r(Rational(0), Rational(10)); + TimeRange shifted = r + Rational(5); + EXPECT_EQ(shifted.in(), Rational(5)); + EXPECT_EQ(shifted.out(), Rational(15)); - shifted -= rational(3); - EXPECT_EQ(shifted.in(), rational(2)); - EXPECT_EQ(shifted.out(), rational(12)); + shifted -= Rational(3); + EXPECT_EQ(shifted.in(), Rational(2)); + EXPECT_EQ(shifted.out(), Rational(12)); } TEST(CoreTimeRange, Split) { - TimeRange r(rational(0), rational(10)); - auto pieces = r.Split(3); + TimeRange r(Rational(0), Rational(10)); + auto pieces = r.split(3); ASSERT_EQ(pieces.size(), 4u); - EXPECT_EQ(pieces.front().in(), rational(0)); + EXPECT_EQ(pieces.front().in(), Rational(0)); } TEST(CoreTimeRangeList, InsertMergesOverlapping) { TimeRangeList list; - list.insert(TimeRange(rational(0), rational(5))); - list.insert(TimeRange(rational(3), rational(8))); - list.insert(TimeRange(rational(10), rational(12))); + list.insert(TimeRange(Rational(0), Rational(5))); + list.insert(TimeRange(Rational(3), Rational(8))); + list.insert(TimeRange(Rational(10), Rational(12))); EXPECT_EQ(list.size(), 2); - EXPECT_EQ(list.first().in(), rational(0)); - EXPECT_EQ(list.first().out(), rational(8)); + EXPECT_EQ(list.first().in(), Rational(0)); + EXPECT_EQ(list.first().out(), Rational(8)); } TEST(CoreTimeRangeList, RemoveSplitsRange) { TimeRangeList list; - list.insert(TimeRange(rational(0), rational(10))); - list.remove(TimeRange(rational(3), rational(7))); + list.insert(TimeRange(Rational(0), Rational(10))); + list.remove(TimeRange(Rational(3), Rational(7))); EXPECT_EQ(list.size(), 2); - EXPECT_EQ(list.first().out(), rational(3)); - EXPECT_EQ(list.last().in(), rational(7)); + EXPECT_EQ(list.first().out(), Rational(3)); + EXPECT_EQ(list.last().in(), Rational(7)); } TEST(CoreTimeRangeList, Shift) { TimeRangeList list; - list.insert(TimeRange(rational(0), rational(5))); - list.shift(rational(10)); + list.insert(TimeRange(Rational(0), Rational(5))); + list.shift(Rational(10)); - EXPECT_EQ(list.first().in(), rational(10)); - EXPECT_EQ(list.first().out(), rational(15)); + EXPECT_EQ(list.first().in(), Rational(10)); + EXPECT_EQ(list.first().out(), Rational(15)); } TEST(CoreTimeRangeList, TrimInAndOut) { TimeRangeList list; - list.insert(TimeRange(rational(10), rational(20))); - list.trim_in(rational(5)); - EXPECT_EQ(list.first().in(), rational(15)); - EXPECT_EQ(list.first().out(), rational(20)); + list.insert(TimeRange(Rational(10), Rational(20))); + list.trim_in(Rational(5)); + EXPECT_EQ(list.first().in(), Rational(15)); + EXPECT_EQ(list.first().out(), Rational(20)); - list.trim_out(rational(-5)); + list.trim_out(Rational(-5)); // set_out(out + diff) = 20 + (-5) = 15 - EXPECT_EQ(list.first().out(), rational(15)); + EXPECT_EQ(list.first().out(), Rational(15)); } TEST(CoreTimeRangeList, Intersects) { TimeRangeList list; - list.insert(TimeRange(rational(0), rational(10))); - list.insert(TimeRange(rational(20), rational(30))); + list.insert(TimeRange(Rational(0), Rational(10))); + list.insert(TimeRange(Rational(20), Rational(30))); TimeRangeList result = - list.Intersects(TimeRange(rational(5), rational(25))); + list.intersects(TimeRange(Rational(5), Rational(25))); EXPECT_EQ(result.size(), 2); - EXPECT_EQ(result.first().in(), rational(5)); - EXPECT_EQ(result.first().out(), rational(10)); + EXPECT_EQ(result.first().in(), Rational(5)); + EXPECT_EQ(result.first().out(), Rational(10)); } TEST(CoreTimeRangeListFrameIterator, IteratesFrames) { TimeRangeList list; // 5 seconds at 25fps = 125 frames - list.insert(TimeRange(rational(0), rational(5))); - TimeRangeListFrameIterator it(list, rational(1, 25)); + list.insert(TimeRange(Rational(0), Rational(5))); + TimeRangeListFrameIterator it(list, Rational(1, 25)); - rational out; + Rational out; int count = 0; - while (it.GetNext(&out)) { + while (it.get_next(&out)) { count++; } @@ -174,12 +174,12 @@ TEST(CoreTimeRangeListFrameIterator, IteratesFrames) TEST(CoreTimeRangeListFrameIterator, HasNext) { TimeRangeList list; - list.insert(TimeRange(rational(0), rational(1))); - TimeRangeListFrameIterator it(list, rational(1, 25)); + list.insert(TimeRange(Rational(0), Rational(1))); + TimeRangeListFrameIterator it(list, Rational(1, 25)); - EXPECT_TRUE(it.HasNext()); - rational out; - while (it.GetNext(&out)) { + EXPECT_TRUE(it.has_next()); + Rational out; + while (it.get_next(&out)) { } - EXPECT_FALSE(it.HasNext()); + EXPECT_FALSE(it.has_next()); } diff --git a/tests/gtest/dialog_editing_test.cpp b/tests/gtest/dialog_editing_test.cpp index 81eb67bf0..9bd7ce4ab 100644 --- a/tests/gtest/dialog_editing_test.cpp +++ b/tests/gtest/dialog_editing_test.cpp @@ -43,29 +43,29 @@ namespace // Several of these dialogs push undo commands to the global undo stack on // accept(), which requires the Core singleton (see project_factory_test.cpp) -void EnsureAppSingletons() +void ensure_app_singletons() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } -void ClearUndoStack() +void clear_undo_stack() { if (olive::Core::instance()) { olive::Core::instance()->undo_stack()->clear(); } } -std::unique_ptr CreateProject() +std::unique_ptr create_project() { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); auto project = std::make_unique(); - project->Initialize(); + project->initialize(); return project; } @@ -84,8 +84,8 @@ public: } }; -olive::ClipBlock *CreateClip(olive::Project *project, - const olive::rational &length) +olive::ClipBlock *create_clip(olive::Project *project, + const olive::Rational &length) { auto *clip = new olive::ClipBlock(); clip->setParent(project); @@ -93,12 +93,12 @@ olive::ClipBlock *CreateClip(olive::Project *project, return clip; } -olive::Track *CreateTrackWithClip(olive::Project *project, +olive::Track *create_track_with_clip(olive::Project *project, olive::ClipBlock *clip) { auto *track = new olive::Track(); track->setParent(project); - track->AppendBlock(clip); + track->append_block(clip); return track; } @@ -109,138 +109,138 @@ olive::Track *CreateTrackWithClip(olive::Project *project, // TEST(DialogSpeedDuration, InitialValuesReflectSingleClip) { - EnsureAppSingletons(); - auto project = CreateProject(); - auto *clip = CreateClip(project.get(), olive::rational(4)); - CreateTrackWithClip(project.get(), clip); + ensure_app_singletons(); + auto project = create_project(); + auto *clip = create_clip(project.get(), olive::Rational(4)); + create_track_with_clip(project.get(), clip); - olive::SpeedDurationDialog dialog({ clip }, olive::rational(1, 24)); + olive::SpeedDurationDialog dialog({ clip }, olive::Rational(1, 24)); auto *speed_slider = dialog.findChild(); auto *dur_slider = dialog.findChild(); ASSERT_NE(speed_slider, nullptr); ASSERT_NE(dur_slider, nullptr); - EXPECT_DOUBLE_EQ(speed_slider->GetValue(), 1.0); - EXPECT_EQ(dur_slider->GetValue(), olive::rational(4)); - EXPECT_FALSE(speed_slider->IsTristate()); - EXPECT_FALSE(dur_slider->IsTristate()); + EXPECT_DOUBLE_EQ(speed_slider->get_value(), 1.0); + EXPECT_EQ(dur_slider->get_value(), olive::Rational(4)); + EXPECT_FALSE(speed_slider->is_tristate()); + EXPECT_FALSE(dur_slider->is_tristate()); } TEST(DialogSpeedDuration, LinkedSpeedChangeUpdatesDuration) { - EnsureAppSingletons(); - auto project = CreateProject(); - auto *clip = CreateClip(project.get(), olive::rational(4)); - CreateTrackWithClip(project.get(), clip); + ensure_app_singletons(); + auto project = create_project(); + auto *clip = create_clip(project.get(), olive::Rational(4)); + create_track_with_clip(project.get(), clip); - olive::SpeedDurationDialog dialog({ clip }, olive::rational(1, 24)); + olive::SpeedDurationDialog dialog({ clip }, olive::Rational(1, 24)); auto *speed_slider = dialog.findChild(); auto *dur_slider = dialog.findChild(); // Programmatic SetValue() does not emit ValueChanged (only user edits // do), so emit the signal explicitly to drive the linked update - speed_slider->SetValue(2.0); - emit speed_slider->ValueChanged(2.0); - EXPECT_EQ(dur_slider->GetValue(), olive::rational(2)); + speed_slider->set_value(2.0); + emit speed_slider->value_changed(2.0); + EXPECT_EQ(dur_slider->get_value(), olive::Rational(2)); - speed_slider->SetValue(0.5); - emit speed_slider->ValueChanged(0.5); - EXPECT_EQ(dur_slider->GetValue(), olive::rational(8)); + speed_slider->set_value(0.5); + emit speed_slider->value_changed(0.5); + EXPECT_EQ(dur_slider->get_value(), olive::Rational(8)); } TEST(DialogSpeedDuration, LinkedDurationChangeUpdatesSpeed) { - EnsureAppSingletons(); - auto project = CreateProject(); - auto *clip = CreateClip(project.get(), olive::rational(4)); - CreateTrackWithClip(project.get(), clip); + ensure_app_singletons(); + auto project = create_project(); + auto *clip = create_clip(project.get(), olive::Rational(4)); + create_track_with_clip(project.get(), clip); - olive::SpeedDurationDialog dialog({ clip }, olive::rational(1, 24)); + olive::SpeedDurationDialog dialog({ clip }, olive::Rational(1, 24)); auto *speed_slider = dialog.findChild(); auto *dur_slider = dialog.findChild(); // Programmatic SetValue() does not emit ValueChanged (only user edits // do), so emit the signal explicitly to drive the linked update - dur_slider->SetValue(olive::rational(2)); - emit dur_slider->ValueChanged(olive::rational(2)); - EXPECT_DOUBLE_EQ(speed_slider->GetValue(), 2.0); + dur_slider->set_value(olive::Rational(2)); + emit dur_slider->value_changed(olive::Rational(2)); + EXPECT_DOUBLE_EQ(speed_slider->get_value(), 2.0); - dur_slider->SetValue(olive::rational(16)); - emit dur_slider->ValueChanged(olive::rational(16)); - EXPECT_DOUBLE_EQ(speed_slider->GetValue(), 0.25); + dur_slider->set_value(olive::Rational(16)); + emit dur_slider->value_changed(olive::Rational(16)); + EXPECT_DOUBLE_EQ(speed_slider->get_value(), 0.25); } TEST(DialogSpeedDuration, AcceptAppliesSpeedAndLength) { - EnsureAppSingletons(); - auto project = CreateProject(); - auto *clip = CreateClip(project.get(), olive::rational(4)); - CreateTrackWithClip(project.get(), clip); + ensure_app_singletons(); + auto project = create_project(); + auto *clip = create_clip(project.get(), olive::Rational(4)); + create_track_with_clip(project.get(), clip); { - olive::SpeedDurationDialog dialog({ clip }, olive::rational(1, 24)); + olive::SpeedDurationDialog dialog({ clip }, olive::Rational(1, 24)); // Doubling the speed with the link checked halves the duration auto *speed_slider = dialog.findChild(); - speed_slider->SetValue(2.0); - emit speed_slider->ValueChanged(2.0); + speed_slider->set_value(2.0); + emit speed_slider->value_changed(2.0); dialog.accept(); } EXPECT_DOUBLE_EQ(clip->speed(), 2.0); - EXPECT_EQ(clip->length(), olive::rational(2)); + EXPECT_EQ(clip->length(), olive::Rational(2)); - ClearUndoStack(); + clear_undo_stack(); } TEST(DialogSpeedDuration, DifferingSpeedsAcrossClipsProduceTristate) { - EnsureAppSingletons(); - auto project = CreateProject(); - auto *clip_a = CreateClip(project.get(), olive::rational(4)); - auto *clip_b = CreateClip(project.get(), olive::rational(4)); - CreateTrackWithClip(project.get(), clip_a); - clip_b->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); - CreateTrackWithClip(project.get(), clip_b); + ensure_app_singletons(); + auto project = create_project(); + auto *clip_a = create_clip(project.get(), olive::Rational(4)); + auto *clip_b = create_clip(project.get(), olive::Rational(4)); + create_track_with_clip(project.get(), clip_a); + clip_b->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); + create_track_with_clip(project.get(), clip_b); olive::SpeedDurationDialog dialog({ clip_a, clip_b }, - olive::rational(1, 24)); + olive::Rational(1, 24)); - EXPECT_TRUE(dialog.findChild()->IsTristate()); + EXPECT_TRUE(dialog.findChild()->is_tristate()); // Durations are identical, so the duration slider must not be tristate - EXPECT_FALSE(dialog.findChild()->IsTristate()); + EXPECT_FALSE(dialog.findChild()->is_tristate()); } TEST(DialogSpeedDuration, AcceptDerivesPerClipSpeedFromDuration) { - EnsureAppSingletons(); - auto project = CreateProject(); - auto *clip_a = CreateClip(project.get(), olive::rational(4)); - auto *clip_b = CreateClip(project.get(), olive::rational(4)); - CreateTrackWithClip(project.get(), clip_a); - clip_b->SetStandardValue(olive::ClipBlock::kSpeedInput, 2.0); - CreateTrackWithClip(project.get(), clip_b); + ensure_app_singletons(); + auto project = create_project(); + auto *clip_a = create_clip(project.get(), olive::Rational(4)); + auto *clip_b = create_clip(project.get(), olive::Rational(4)); + create_track_with_clip(project.get(), clip_a); + clip_b->set_standard_value(olive::ClipBlock::k_speed_input, 2.0); + create_track_with_clip(project.get(), clip_b); { olive::SpeedDurationDialog dialog({ clip_a, clip_b }, - olive::rational(1, 24)); + olive::Rational(1, 24)); // Speed is tristate, so accept() must compute each clip's speed // from its own length/speed ratio: speed = old_speed * old_len / new_len - dialog.findChild()->SetValue( - olive::rational(2)); + dialog.findChild()->set_value( + olive::Rational(2)); dialog.accept(); } - EXPECT_EQ(clip_a->length(), olive::rational(2)); - EXPECT_EQ(clip_b->length(), olive::rational(2)); + EXPECT_EQ(clip_a->length(), olive::Rational(2)); + EXPECT_EQ(clip_b->length(), olive::Rational(2)); EXPECT_DOUBLE_EQ(clip_a->speed(), 2.0); EXPECT_DOUBLE_EQ(clip_b->speed(), 4.0); - ClearUndoStack(); + clear_undo_stack(); } // @@ -248,21 +248,21 @@ TEST(DialogSpeedDuration, AcceptDerivesPerClipSpeedFromDuration) // TEST(DialogKeyframeProperties, SingleKeyAcceptWritesAllFields) { - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); auto *node = new olive::MathNode(); node->setParent(project.get()); - auto *key = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *key = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key->setParent(node); // The dialog stores the keyframe vector by reference, so it must outlive it std::vector keys = { key }; { - olive::KeyframePropertiesDialog dialog(keys, olive::rational(1, 24)); + olive::KeyframePropertiesDialog dialog(keys, olive::Rational(1, 24)); auto *time_slider = dialog.findChild(); auto *type_select = dialog.findChild(); @@ -273,53 +273,53 @@ TEST(DialogKeyframeProperties, SingleKeyAcceptWritesAllFields) // Initial state reflects the keyframe EXPECT_TRUE(time_slider->isEnabled()); - EXPECT_EQ(time_slider->GetValue(), olive::rational(0)); + EXPECT_EQ(time_slider->get_value(), olive::Rational(0)); ASSERT_EQ(type_select->count(), 3); - EXPECT_EQ(type_select->currentData().toInt(), olive::NodeKeyframe::kLinear); + EXPECT_EQ(type_select->currentData().toInt(), olive::NodeKeyframe::k_linear); EXPECT_FALSE(bezier_group->isEnabled()); // Switching to Bezier enables the bezier handle editors type_select->setCurrentIndex(2); ASSERT_EQ(type_select->currentData().toInt(), - olive::NodeKeyframe::kBezier); + olive::NodeKeyframe::k_bezier); EXPECT_TRUE(bezier_group->isEnabled()); - time_slider->SetValue(olive::rational(1, 2)); + time_slider->set_value(olive::Rational(1, 2)); const QList sliders = dialog.findChildren(); ASSERT_EQ(sliders.size(), 4); - sliders.at(0)->SetValue(0.1); // bezier in x - sliders.at(1)->SetValue(0.2); // bezier in y - sliders.at(2)->SetValue(0.3); // bezier out x - sliders.at(3)->SetValue(0.4); // bezier out y + sliders.at(0)->set_value(0.1); // bezier in x + sliders.at(1)->set_value(0.2); // bezier in y + sliders.at(2)->set_value(0.3); // bezier out x + sliders.at(3)->set_value(0.4); // bezier out y dialog.accept(); } - EXPECT_EQ(key->time(), olive::rational(1, 2)); - EXPECT_EQ(key->type(), olive::NodeKeyframe::kBezier); + EXPECT_EQ(key->time(), olive::Rational(1, 2)); + EXPECT_EQ(key->type(), olive::NodeKeyframe::k_bezier); EXPECT_DOUBLE_EQ(key->bezier_control_in().x(), 0.1); EXPECT_DOUBLE_EQ(key->bezier_control_in().y(), 0.2); EXPECT_DOUBLE_EQ(key->bezier_control_out().x(), 0.3); EXPECT_DOUBLE_EQ(key->bezier_control_out().y(), 0.4); - ClearUndoStack(); + clear_undo_stack(); } TEST(DialogKeyframeProperties, MixedTypesAddPlaceholderItem) { - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); auto *node = new olive::MathNode(); node->setParent(project.get()); - auto *key_a = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); - auto *key_b = new olive::NodeKeyframe(olive::rational(1), 2.0, - olive::NodeKeyframe::kHold, 0, -1, - olive::MathNode::kParamAIn); + auto *key_a = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); + auto *key_b = new olive::NodeKeyframe(olive::Rational(1), 2.0, + olive::NodeKeyframe::k_hold, 0, -1, + olive::MathNode::k_param_a_in); key_a->setParent(node); key_b->setParent(node); @@ -327,7 +327,7 @@ TEST(DialogKeyframeProperties, MixedTypesAddPlaceholderItem) std::vector keys = { key_a, key_b }; { - olive::KeyframePropertiesDialog dialog(keys, olive::rational(1, 24)); + olive::KeyframePropertiesDialog dialog(keys, olive::Rational(1, 24)); auto *type_select = dialog.findChild(); // An "--" placeholder item with data -1 is prepended for mixed types @@ -339,32 +339,32 @@ TEST(DialogKeyframeProperties, MixedTypesAddPlaceholderItem) } // Accepting with the placeholder selected must not change key types - EXPECT_EQ(key_a->type(), olive::NodeKeyframe::kLinear); - EXPECT_EQ(key_b->type(), olive::NodeKeyframe::kHold); + EXPECT_EQ(key_a->type(), olive::NodeKeyframe::k_linear); + EXPECT_EQ(key_b->type(), olive::NodeKeyframe::k_hold); - ClearUndoStack(); + clear_undo_stack(); } TEST(DialogKeyframeProperties, KeysOnSameTrackDisableTimeEdit) { - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); auto *node = new olive::MathNode(); node->setParent(project.get()); - auto *key_a = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); - auto *key_b = new olive::NodeKeyframe(olive::rational(1), 2.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *key_a = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); + auto *key_b = new olive::NodeKeyframe(olive::Rational(1), 2.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key_a->setParent(node); key_b->setParent(node); // The dialog stores the keyframe vector by reference, so it must outlive it std::vector keys = { key_a, key_b }; - olive::KeyframePropertiesDialog dialog(keys, olive::rational(1, 24)); + olive::KeyframePropertiesDialog dialog(keys, olive::Rational(1, 24)); // Moving two keys of the same track in time could reorder them, so the // time editor must be disabled @@ -376,16 +376,16 @@ TEST(DialogKeyframeProperties, KeysOnSameTrackDisableTimeEdit) // TEST(DialogMarkerProperties, SingleMarkerAcceptWritesFields) { - EnsureAppSingletons(); + ensure_app_singletons(); olive::TimelineMarker marker( 3, - olive::TimeRange(olive::rational(1), olive::rational(2)), + olive::TimeRange(olive::Rational(1), olive::Rational(2)), QStringLiteral("Marker A")); { olive::MarkerPropertiesDialog dialog({ &marker }, - olive::rational(1, 24)); + olive::Rational(1, 24)); auto *label_edit = dialog.findChild(); auto *color_menu = dialog.findChild(); @@ -396,41 +396,41 @@ TEST(DialogMarkerProperties, SingleMarkerAcceptWritesFields) ASSERT_EQ(sliders.size(), 2); EXPECT_EQ(label_edit->text(), QStringLiteral("Marker A")); - EXPECT_EQ(color_menu->GetSelectedColor(), 3); - EXPECT_EQ(sliders.at(0)->GetValue(), olive::rational(1)); - EXPECT_EQ(sliders.at(1)->GetValue(), olive::rational(2)); + EXPECT_EQ(color_menu->get_selected_color(), 3); + EXPECT_EQ(sliders.at(0)->get_value(), olive::Rational(1)); + EXPECT_EQ(sliders.at(1)->get_value(), olive::Rational(2)); label_edit->setText(QStringLiteral("Renamed")); - sliders.at(0)->SetValue(olive::rational(1, 2)); - sliders.at(1)->SetValue(olive::rational(3, 2)); + sliders.at(0)->set_value(olive::Rational(1, 2)); + sliders.at(1)->set_value(olive::Rational(3, 2)); dialog.accept(); } EXPECT_EQ(marker.name(), QStringLiteral("Renamed")); - EXPECT_EQ(marker.time().in(), olive::rational(1, 2)); - EXPECT_EQ(marker.time().out(), olive::rational(3, 2)); + EXPECT_EQ(marker.time().in(), olive::Rational(1, 2)); + EXPECT_EQ(marker.time().out(), olive::Rational(3, 2)); EXPECT_EQ(marker.color(), 3); - ClearUndoStack(); + clear_undo_stack(); } TEST(DialogMarkerProperties, MultipleMarkersDisableTimeAndShowPlaceholder) { - EnsureAppSingletons(); + ensure_app_singletons(); olive::TimelineMarker marker_a( 1, - olive::TimeRange(olive::rational(1), olive::rational(2)), + olive::TimeRange(olive::Rational(1), olive::Rational(2)), QStringLiteral("Alpha")); olive::TimelineMarker marker_b( 2, - olive::TimeRange(olive::rational(5), olive::rational(6)), + olive::TimeRange(olive::Rational(5), olive::Rational(6)), QStringLiteral("Beta")); { olive::MarkerPropertiesDialog dialog({ &marker_a, &marker_b }, - olive::rational(1, 24)); + olive::Rational(1, 24)); auto *label_edit = dialog.findChild(); auto *color_menu = dialog.findChild(); @@ -439,16 +439,16 @@ TEST(DialogMarkerProperties, MultipleMarkersDisableTimeAndShowPlaceholder) // Time cannot be edited for multiple markers EXPECT_FALSE(sliders.at(0)->isEnabled()); - EXPECT_TRUE(sliders.at(0)->IsTristate()); + EXPECT_TRUE(sliders.at(0)->is_tristate()); EXPECT_FALSE(sliders.at(1)->isEnabled()); - EXPECT_TRUE(sliders.at(1)->IsTristate()); + EXPECT_TRUE(sliders.at(1)->is_tristate()); // Differing names show a placeholder instead of text EXPECT_TRUE(label_edit->text().isEmpty()); EXPECT_FALSE(label_edit->placeholderText().isEmpty()); // Differing colors are represented by -1 - EXPECT_EQ(color_menu->GetSelectedColor(), -1); + EXPECT_EQ(color_menu->get_selected_color(), -1); dialog.accept(); } @@ -459,7 +459,7 @@ TEST(DialogMarkerProperties, MultipleMarkersDisableTimeAndShowPlaceholder) EXPECT_EQ(marker_a.color(), 1); EXPECT_EQ(marker_b.color(), 2); - ClearUndoStack(); + clear_undo_stack(); } // @@ -468,10 +468,10 @@ TEST(DialogMarkerProperties, MultipleMarkersDisableTimeAndShowPlaceholder) TEST(DialogSequencePreset, SaveLoadRoundTrip) { olive::SequencePreset preset(QStringLiteral("Test Preset"), 1920, 1080, - olive::rational(24, 1), olive::rational(1, 1), - olive::VideoParams::kInterlacedTopFirst, 48000, - olive::core::kChannelLayoutStereo, 2, - olive::PixelFormat::F16, true); + olive::Rational(24, 1), olive::Rational(1, 1), + olive::VideoParams::k_interlaced_top_first, 48000, + olive::core::k_channel_layout_stereo, 2, + olive::PixelFormat::f16, true); QByteArray xml; QBuffer buffer(&xml); @@ -479,7 +479,7 @@ TEST(DialogSequencePreset, SaveLoadRoundTrip) QXmlStreamWriter writer(&buffer); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("preset")); - preset.Save(&writer); + preset.save(&writer); writer.writeEndElement(); writer.writeEndDocument(); buffer.close(); @@ -490,18 +490,18 @@ TEST(DialogSequencePreset, SaveLoadRoundTrip) QXmlStreamReader reader(&read_buffer); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name().toString(), QStringLiteral("preset")); - loaded.Load(&reader); + loaded.load(&reader); - EXPECT_EQ(loaded.GetName(), QStringLiteral("Test Preset")); + EXPECT_EQ(loaded.get_name(), QStringLiteral("Test Preset")); EXPECT_EQ(loaded.width(), 1920); EXPECT_EQ(loaded.height(), 1080); - EXPECT_EQ(loaded.frame_rate(), olive::rational(24, 1)); - EXPECT_EQ(loaded.pixel_aspect(), olive::rational(1, 1)); - EXPECT_EQ(loaded.interlacing(), olive::VideoParams::kInterlacedTopFirst); + EXPECT_EQ(loaded.frame_rate(), olive::Rational(24, 1)); + EXPECT_EQ(loaded.pixel_aspect(), olive::Rational(1, 1)); + EXPECT_EQ(loaded.interlacing(), olive::VideoParams::k_interlaced_top_first); EXPECT_EQ(loaded.sample_rate(), 48000); - EXPECT_EQ(loaded.channel_layout(), olive::core::kChannelLayoutStereo); + EXPECT_EQ(loaded.channel_layout(), olive::core::k_channel_layout_stereo); EXPECT_EQ(loaded.preview_divider(), 2); - EXPECT_EQ(loaded.preview_format(), olive::PixelFormat::F16); + EXPECT_EQ(loaded.preview_format(), olive::PixelFormat::f16); EXPECT_TRUE(loaded.preview_autocache()); } @@ -529,9 +529,9 @@ TEST(DialogSequencePreset, LoadsLegacyInterlacingElement) QXmlStreamReader reader(&read_buffer); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name().toString(), QStringLiteral("preset")); - loaded.Load(&reader); + loaded.load(&reader); - EXPECT_EQ(loaded.GetName(), QStringLiteral("Legacy")); + EXPECT_EQ(loaded.get_name(), QStringLiteral("Legacy")); EXPECT_EQ(loaded.width(), 1280); EXPECT_EQ(loaded.interlacing(), static_cast(2)); @@ -539,92 +539,92 @@ TEST(DialogSequencePreset, LoadsLegacyInterlacingElement) TEST(DialogSequenceParameterTab, ReflectsSequenceParameters) { - auto project = CreateProject(); + auto project = create_project(); auto *sequence = new olive::Sequence(); sequence->setParent(project.get()); - sequence->SetVideoParams(olive::VideoParams( - 1920, 1080, olive::rational(1001, 30000), olive::PixelFormat::F32, - olive::VideoParams::kInternalChannelCount, olive::rational(1, 1), - olive::VideoParams::kInterlaceNone, 2)); - sequence->SetAudioParams(olive::AudioParams( - 48000, olive::core::kChannelLayoutStereo, - olive::Sequence::kDefaultSampleFormat)); + sequence->set_video_params(olive::VideoParams( + 1920, 1080, olive::Rational(1001, 30000), olive::PixelFormat::f32, + olive::VideoParams::k_internal_channel_count, olive::Rational(1, 1), + olive::VideoParams::k_interlace_none, 2)); + sequence->set_audio_params(olive::AudioParams( + 48000, olive::core::k_channel_layout_stereo, + olive::Sequence::k_default_sample_format)); olive::SequenceDialogParameterTab tab(sequence); - EXPECT_EQ(tab.GetSelectedVideoWidth(), 1920); - EXPECT_EQ(tab.GetSelectedVideoHeight(), 1080); - EXPECT_EQ(tab.GetSelectedVideoFrameRate(), olive::rational(30000, 1001)); - EXPECT_EQ(tab.GetSelectedVideoPixelAspect(), olive::rational(1, 1)); - EXPECT_EQ(tab.GetSelectedVideoInterlacingMode(), - olive::VideoParams::kInterlaceNone); - EXPECT_EQ(tab.GetSelectedPreviewResolution(), 2); - EXPECT_EQ(tab.GetSelectedPreviewFormat(), olive::PixelFormat::F32); - EXPECT_EQ(tab.GetSelectedAudioSampleRate(), 48000); - EXPECT_EQ(tab.GetSelectedAudioChannelLayout(), - olive::core::kChannelLayoutStereo); + EXPECT_EQ(tab.get_selected_video_width(), 1920); + EXPECT_EQ(tab.get_selected_video_height(), 1080); + EXPECT_EQ(tab.get_selected_video_frame_rate(), olive::Rational(30000, 1001)); + EXPECT_EQ(tab.get_selected_video_pixel_aspect(), olive::Rational(1, 1)); + EXPECT_EQ(tab.get_selected_video_interlacing_mode(), + olive::VideoParams::k_interlace_none); + EXPECT_EQ(tab.get_selected_preview_resolution(), 2); + EXPECT_EQ(tab.get_selected_preview_format(), olive::PixelFormat::f32); + EXPECT_EQ(tab.get_selected_audio_sample_rate(), 48000); + EXPECT_EQ(tab.get_selected_audio_channel_layout(), + olive::core::k_channel_layout_stereo); } TEST(DialogSequenceParameterTab, PresetChangedAppliesValues) { - auto project = CreateProject(); + auto project = create_project(); auto *sequence = new olive::Sequence(); sequence->setParent(project.get()); - sequence->SetVideoParams(olive::VideoParams( - 1920, 1080, olive::rational(1, 24), olive::PixelFormat::F32, - olive::VideoParams::kInternalChannelCount, olive::rational(1, 1), - olive::VideoParams::kInterlaceNone, 1)); - sequence->SetAudioParams(olive::AudioParams( - 48000, olive::core::kChannelLayoutStereo, - olive::Sequence::kDefaultSampleFormat)); + sequence->set_video_params(olive::VideoParams( + 1920, 1080, olive::Rational(1, 24), olive::PixelFormat::f32, + olive::VideoParams::k_internal_channel_count, olive::Rational(1, 1), + olive::VideoParams::k_interlace_none, 1)); + sequence->set_audio_params(olive::AudioParams( + 48000, olive::core::k_channel_layout_stereo, + olive::Sequence::k_default_sample_format)); olive::SequenceDialogParameterTab tab(sequence); - tab.PresetChanged(olive::SequencePreset( - QStringLiteral("Preset"), 1280, 720, olive::rational(24, 1), - olive::rational(1, 1), olive::VideoParams::kInterlacedTopFirst, 44100, - olive::core::kChannelLayoutStereo, 4, olive::PixelFormat::F16, false)); + tab.preset_changed(olive::SequencePreset( + QStringLiteral("Preset"), 1280, 720, olive::Rational(24, 1), + olive::Rational(1, 1), olive::VideoParams::k_interlaced_top_first, 44100, + olive::core::k_channel_layout_stereo, 4, olive::PixelFormat::f16, false)); - EXPECT_EQ(tab.GetSelectedVideoWidth(), 1280); - EXPECT_EQ(tab.GetSelectedVideoHeight(), 720); - EXPECT_EQ(tab.GetSelectedVideoFrameRate(), olive::rational(24, 1)); - EXPECT_EQ(tab.GetSelectedVideoInterlacingMode(), - olive::VideoParams::kInterlacedTopFirst); - EXPECT_EQ(tab.GetSelectedAudioSampleRate(), 44100); - EXPECT_EQ(tab.GetSelectedPreviewResolution(), 4); - EXPECT_EQ(tab.GetSelectedPreviewFormat(), olive::PixelFormat::F16); + EXPECT_EQ(tab.get_selected_video_width(), 1280); + EXPECT_EQ(tab.get_selected_video_height(), 720); + EXPECT_EQ(tab.get_selected_video_frame_rate(), olive::Rational(24, 1)); + EXPECT_EQ(tab.get_selected_video_interlacing_mode(), + olive::VideoParams::k_interlaced_top_first); + EXPECT_EQ(tab.get_selected_audio_sample_rate(), 44100); + EXPECT_EQ(tab.get_selected_preview_resolution(), 4); + EXPECT_EQ(tab.get_selected_preview_format(), olive::PixelFormat::f16); } TEST(DialogSequenceDialog, AcceptNonUndoableAppliesParameters) { StandardPathsTestModeGuard test_mode; - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); auto *sequence = new olive::Sequence(); sequence->setParent(project.get()); - sequence->SetLabel(QStringLiteral("Seq A")); - sequence->SetVideoParams(olive::VideoParams( - 1920, 1080, olive::rational(1, 24), olive::PixelFormat::F32, - olive::VideoParams::kInternalChannelCount, olive::rational(1, 1), - olive::VideoParams::kInterlaceNone, 1)); - sequence->SetAudioParams(olive::AudioParams( - 48000, olive::core::kChannelLayoutStereo, - olive::Sequence::kDefaultSampleFormat)); + sequence->set_label(QStringLiteral("Seq A")); + sequence->set_video_params(olive::VideoParams( + 1920, 1080, olive::Rational(1, 24), olive::PixelFormat::f32, + olive::VideoParams::k_internal_channel_count, olive::Rational(1, 1), + olive::VideoParams::k_interlace_none, 1)); + sequence->set_audio_params(olive::AudioParams( + 48000, olive::core::k_channel_layout_stereo, + olive::Sequence::k_default_sample_format)); { - olive::SequenceDialog dialog(sequence, olive::SequenceDialog::kExisting); - dialog.SetUndoable(false); + olive::SequenceDialog dialog(sequence, olive::SequenceDialog::k_existing); + dialog.set_undoable(false); auto *tab = dialog.findChild(); ASSERT_NE(tab, nullptr); - tab->PresetChanged(olive::SequencePreset( - QStringLiteral("Preset"), 1280, 720, olive::rational(24, 1), - olive::rational(1, 1), olive::VideoParams::kInterlacedTopFirst, - 44100, olive::core::kChannelLayoutStereo, 4, - olive::PixelFormat::F32, false)); + tab->preset_changed(olive::SequencePreset( + QStringLiteral("Preset"), 1280, 720, olive::Rational(24, 1), + olive::Rational(1, 1), olive::VideoParams::k_interlaced_top_first, + 44100, olive::core::k_channel_layout_stereo, 4, + olive::PixelFormat::f32, false)); auto *name_field = dialog.findChild(); ASSERT_NE(name_field, nullptr); @@ -634,64 +634,64 @@ TEST(DialogSequenceDialog, AcceptNonUndoableAppliesParameters) EXPECT_EQ(dialog.result(), QDialog::Accepted); } - EXPECT_EQ(sequence->GetLabel(), QStringLiteral("Seq B")); - EXPECT_EQ(sequence->GetVideoParams().width(), 1280); - EXPECT_EQ(sequence->GetVideoParams().height(), 720); - EXPECT_EQ(sequence->GetVideoParams().frame_rate(), olive::rational(24, 1)); - EXPECT_EQ(sequence->GetVideoParams().interlacing(), - olive::VideoParams::kInterlacedTopFirst); - EXPECT_EQ(sequence->GetVideoParams().divider(), 4); - EXPECT_EQ(sequence->GetAudioParams().sample_rate(), 44100); + EXPECT_EQ(sequence->get_label(), QStringLiteral("Seq B")); + EXPECT_EQ(sequence->get_video_params().width(), 1280); + EXPECT_EQ(sequence->get_video_params().height(), 720); + EXPECT_EQ(sequence->get_video_params().frame_rate(), olive::Rational(24, 1)); + EXPECT_EQ(sequence->get_video_params().interlacing(), + olive::VideoParams::k_interlaced_top_first); + EXPECT_EQ(sequence->get_video_params().divider(), 4); + EXPECT_EQ(sequence->get_audio_params().sample_rate(), 44100); } TEST(DialogSequenceDialog, AcceptUndoablePushesCommand) { StandardPathsTestModeGuard test_mode; - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); auto *sequence = new olive::Sequence(); sequence->setParent(project.get()); - sequence->SetLabel(QStringLiteral("Seq A")); - sequence->SetVideoParams(olive::VideoParams( - 1920, 1080, olive::rational(1, 24), olive::PixelFormat::F32, - olive::VideoParams::kInternalChannelCount, olive::rational(1, 1), - olive::VideoParams::kInterlaceNone, 1)); - sequence->SetAudioParams(olive::AudioParams( - 48000, olive::core::kChannelLayoutStereo, - olive::Sequence::kDefaultSampleFormat)); + sequence->set_label(QStringLiteral("Seq A")); + sequence->set_video_params(olive::VideoParams( + 1920, 1080, olive::Rational(1, 24), olive::PixelFormat::f32, + olive::VideoParams::k_internal_channel_count, olive::Rational(1, 1), + olive::VideoParams::k_interlace_none, 1)); + sequence->set_audio_params(olive::AudioParams( + 48000, olive::core::k_channel_layout_stereo, + olive::Sequence::k_default_sample_format)); { - olive::SequenceDialog dialog(sequence, olive::SequenceDialog::kExisting); + olive::SequenceDialog dialog(sequence, olive::SequenceDialog::k_existing); auto *tab = dialog.findChild(); ASSERT_NE(tab, nullptr); - tab->PresetChanged(olive::SequencePreset( - QStringLiteral("Preset"), 640, 360, olive::rational(24, 1), - olive::rational(1, 1), olive::VideoParams::kInterlaceNone, 48000, - olive::core::kChannelLayoutStereo, 1, olive::PixelFormat::F32, + tab->preset_changed(olive::SequencePreset( + QStringLiteral("Preset"), 640, 360, olive::Rational(24, 1), + olive::Rational(1, 1), olive::VideoParams::k_interlace_none, 48000, + olive::core::k_channel_layout_stereo, 1, olive::PixelFormat::f32, false)); dialog.accept(); EXPECT_EQ(dialog.result(), QDialog::Accepted); } - EXPECT_EQ(sequence->GetVideoParams().width(), 640); - EXPECT_EQ(sequence->GetVideoParams().height(), 360); + EXPECT_EQ(sequence->get_video_params().width(), 640); + EXPECT_EQ(sequence->get_video_params().height(), 360); - ClearUndoStack(); + clear_undo_stack(); } TEST(DialogSequenceDialog, PresetTabListsDefaultPresets) { StandardPathsTestModeGuard test_mode; - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); auto *sequence = new olive::Sequence(); sequence->setParent(project.get()); - olive::SequenceDialog dialog(sequence, olive::SequenceDialog::kExisting); + olive::SequenceDialog dialog(sequence, olive::SequenceDialog::k_existing); auto *tree = dialog.findChild(); ASSERT_NE(tree, nullptr); @@ -704,12 +704,12 @@ TEST(DialogSequenceDialog, PresetTabListsDefaultPresets) // TEST(DialogFootageProperties, AcceptRenamesAndSetsSourceStartTime) { - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); auto *footage = new olive::Footage(); footage->setParent(project.get()); - footage->SetLabel(QStringLiteral("Clip A")); + footage->set_label(QStringLiteral("Clip A")); footage->set_filename(QStringLiteral("/tmp/oak-nonexistent.mp4")); { @@ -735,9 +735,9 @@ TEST(DialogFootageProperties, AcceptRenamesAndSetsSourceStartTime) QMetaObject::invokeMethod(&dialog, "accept"); } - EXPECT_EQ(footage->GetLabel(), QStringLiteral("Clip B")); - EXPECT_TRUE(footage->HasSourceStartTime()); - EXPECT_EQ(footage->source_start_time(), olive::rational(25, 2)); + EXPECT_EQ(footage->get_label(), QStringLiteral("Clip B")); + EXPECT_TRUE(footage->has_source_start_time()); + EXPECT_EQ(footage->source_start_time(), olive::Rational(25, 2)); EXPECT_EQ(footage->source_start_time_source(), QStringLiteral("manual")); { @@ -753,9 +753,9 @@ TEST(DialogFootageProperties, AcceptRenamesAndSetsSourceStartTime) QMetaObject::invokeMethod(&dialog, "accept"); } - EXPECT_FALSE(footage->HasSourceStartTime()); + EXPECT_FALSE(footage->has_source_start_time()); - ClearUndoStack(); + clear_undo_stack(); } // @@ -763,16 +763,16 @@ TEST(DialogFootageProperties, AcceptRenamesAndSetsSourceStartTime) // TEST(DialogFootageRelink, TableListsFootageAndFilenames) { - auto project = CreateProject(); + auto project = create_project(); auto *footage_a = new olive::Footage(); footage_a->setParent(project.get()); - footage_a->SetLabel(QStringLiteral("Footage A")); + footage_a->set_label(QStringLiteral("Footage A")); footage_a->set_filename(QStringLiteral("/old/path/a.mp4")); auto *footage_b = new olive::Footage(); footage_b->setParent(project.get()); - footage_b->SetLabel(QStringLiteral("Footage B")); + footage_b->set_label(QStringLiteral("Footage B")); footage_b->set_filename(QStringLiteral("/old/path/b.mp4")); olive::FootageRelinkDialog dialog({ footage_a, footage_b }); @@ -793,8 +793,8 @@ TEST(DialogFootageRelink, TableListsFootageAndFilenames) // TEST(DialogProjectProperties, OcioValidationTogglesOnInvalidFilename) { - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); olive::ProjectPropertiesDialog dialog(project.get(), nullptr); @@ -830,8 +830,8 @@ TEST(DialogProjectProperties, OcioValidationTogglesOnInvalidFilename) TEST(DialogProjectProperties, AcceptWithDefaultsClosesDialog) { - EnsureAppSingletons(); - auto project = CreateProject(); + ensure_app_singletons(); + auto project = create_project(); olive::ProjectPropertiesDialog dialog(project.get(), nullptr); dialog.accept(); diff --git a/tests/gtest/dialog_export_test.cpp b/tests/gtest/dialog_export_test.cpp index c835e632f..5ce26eec7 100644 --- a/tests/gtest/dialog_export_test.cpp +++ b/tests/gtest/dialog_export_test.cpp @@ -37,7 +37,7 @@ public: } }; -QList MenuFormatData(const olive::ExportFormatComboBox &combo) +QList menu_format_data(const olive::ExportFormatComboBox &combo) { QList formats; // custom_menu_ is an olive::Menu (a QMenu without its own Q_OBJECT) @@ -63,51 +63,51 @@ TEST(DialogExportFormatComboBox, GetSetFormatRoundTrip) olive::ExportFormatComboBox combo; // Before any selection the format is the invalid placeholder - EXPECT_EQ(combo.GetFormat(), olive::ExportFormat::kFormatCount); + EXPECT_EQ(combo.get_format(), olive::ExportFormat::k_format_count); - combo.SetFormat(olive::ExportFormat::kFormatMatroska); - EXPECT_EQ(combo.GetFormat(), olive::ExportFormat::kFormatMatroska); + combo.set_format(olive::ExportFormat::k_format_matroska); + EXPECT_EQ(combo.get_format(), olive::ExportFormat::k_format_matroska); EXPECT_EQ(combo.currentText(), - olive::ExportFormat::GetName(olive::ExportFormat::kFormatMatroska)); + olive::ExportFormat::get_name(olive::ExportFormat::k_format_matroska)); } TEST(DialogExportFormatComboBox, MenuSelectionEmitsFormatChanged) { olive::ExportFormatComboBox combo; - QSignalSpy spy(&combo, &olive::ExportFormatComboBox::FormatChanged); + QSignalSpy spy(&combo, &olive::ExportFormatComboBox::format_changed); QAction action(QStringLiteral("QuickTime"), &combo); - action.setData(static_cast(olive::ExportFormat::kFormatQuickTime)); + action.setData(static_cast(olive::ExportFormat::k_format_quick_time)); - QMetaObject::invokeMethod(&combo, "HandleIndexChange", + QMetaObject::invokeMethod(&combo, "handle_index_change", Q_ARG(QAction *, &action)); - EXPECT_EQ(combo.GetFormat(), olive::ExportFormat::kFormatQuickTime); + EXPECT_EQ(combo.get_format(), olive::ExportFormat::k_format_quick_time); ASSERT_EQ(spy.count(), 1); EXPECT_EQ(spy.first().first().toInt(), - static_cast(olive::ExportFormat::kFormatQuickTime)); + static_cast(olive::ExportFormat::k_format_quick_time)); } TEST(DialogExportFormatComboBox, AudioOnlyModeListsOnlyAudioFormats) { olive::ExportFormatComboBox combo( - olive::ExportFormatComboBox::kShowAudioOnly); + olive::ExportFormatComboBox::k_show_audio_only); - const QList formats = MenuFormatData(combo); + const QList formats = menu_format_data(combo); EXPECT_FALSE(formats.isEmpty()); foreach (int f, formats) { const auto fmt = static_cast(f); - EXPECT_TRUE(olive::ExportFormat::GetVideoCodecs(fmt).isEmpty()) + EXPECT_TRUE(olive::ExportFormat::get_video_codecs(fmt).isEmpty()) << "Format " << f << " should not have video codecs"; - EXPECT_FALSE(olive::ExportFormat::GetAudioCodecs(fmt).isEmpty()) + EXPECT_FALSE(olive::ExportFormat::get_audio_codecs(fmt).isEmpty()) << "Format " << f << " should have audio codecs"; } EXPECT_TRUE(formats.contains( - static_cast(olive::ExportFormat::kFormatWAV))); + static_cast(olive::ExportFormat::k_format_wav))); EXPECT_FALSE(formats.contains( - static_cast(olive::ExportFormat::kFormatMatroska))); + static_cast(olive::ExportFormat::k_format_matroska))); } // @@ -118,30 +118,30 @@ TEST(DialogExportAudioTab, SetFormatPopulatesCodecs) olive::ExportAudioTab tab; const QList codecs = - olive::ExportFormat::GetAudioCodecs(olive::ExportFormat::kFormatMatroska); + olive::ExportFormat::get_audio_codecs(olive::ExportFormat::k_format_matroska); ASSERT_FALSE(codecs.isEmpty()); - EXPECT_EQ(tab.SetFormat(olive::ExportFormat::kFormatMatroska), + EXPECT_EQ(tab.set_format(olive::ExportFormat::k_format_matroska), codecs.size()); // The first codec is auto-selected - EXPECT_EQ(tab.GetCodec(), codecs.first()); + EXPECT_EQ(tab.get_codec(), codecs.first()); } TEST(DialogExportAudioTab, LosslessCodecDisablesBitRate) { olive::ExportAudioTab tab; - tab.SetFormat(olive::ExportFormat::kFormatMatroska); + tab.set_format(olive::ExportFormat::k_format_matroska); - tab.SetCodec(olive::ExportCodec::kCodecAAC); + tab.set_codec(olive::ExportCodec::k_codec_aac); EXPECT_TRUE(tab.bit_rate_slider()->isEnabled()); - EXPECT_EQ(tab.GetCodec(), olive::ExportCodec::kCodecAAC); + EXPECT_EQ(tab.get_codec(), olive::ExportCodec::k_codec_aac); // PCM is lossless, so no bit rate setting applies - tab.SetCodec(olive::ExportCodec::kCodecPCM); - EXPECT_EQ(tab.GetCodec(), olive::ExportCodec::kCodecPCM); + tab.set_codec(olive::ExportCodec::k_codec_pcm); + EXPECT_EQ(tab.get_codec(), olive::ExportCodec::k_codec_pcm); EXPECT_FALSE(tab.bit_rate_slider()->isEnabled()); - EXPECT_TRUE(tab.bit_rate_slider()->IsTristate()); + EXPECT_TRUE(tab.bit_rate_slider()->is_tristate()); } TEST(DialogExportAudioTab, FormatWithoutAudioCodecsDisablesTab) @@ -149,7 +149,7 @@ TEST(DialogExportAudioTab, FormatWithoutAudioCodecsDisablesTab) olive::ExportAudioTab tab; // PNG carries no audio - EXPECT_EQ(tab.SetFormat(olive::ExportFormat::kFormatPNG), 0); + EXPECT_EQ(tab.set_format(olive::ExportFormat::k_format_png), 0); EXPECT_FALSE(tab.isEnabled()); } @@ -159,32 +159,32 @@ TEST(DialogExportAudioTab, FormatWithoutAudioCodecsDisablesTab) TEST(DialogExportSubtitlesTab, SidecarStateFollowsFormatCapabilities) { olive::ExportSubtitlesTab tab; - tab.SetSidecarFormat(olive::ExportFormat::kFormatSRT); + tab.set_sidecar_format(olive::ExportFormat::k_format_srt); auto *sidecar_box = tab.findChild(); ASSERT_NE(sidecar_box, nullptr); // Matroska can embed subtitles: sidecar is optional and off by default - tab.SetFormat(olive::ExportFormat::kFormatMatroska); + tab.set_format(olive::ExportFormat::k_format_matroska); EXPECT_TRUE(sidecar_box->isEnabled()); - EXPECT_FALSE(tab.GetSidecarEnabled()); - EXPECT_EQ(tab.GetSubtitleCodec(), olive::ExportCodec::kCodecSRT); + EXPECT_FALSE(tab.get_sidecar_enabled()); + EXPECT_EQ(tab.get_subtitle_codec(), olive::ExportCodec::k_codec_srt); // SetSidecarEnabled toggles the check state (used to restore params) - tab.SetSidecarEnabled(true); - EXPECT_TRUE(tab.GetSidecarEnabled()); - tab.SetSidecarEnabled(false); - EXPECT_FALSE(tab.GetSidecarEnabled()); + tab.set_sidecar_enabled(true); + EXPECT_TRUE(tab.get_sidecar_enabled()); + tab.set_sidecar_enabled(false); + EXPECT_FALSE(tab.get_sidecar_enabled()); // SRT is a subtitles-only format: sidecar makes no sense, forced off - tab.SetFormat(olive::ExportFormat::kFormatSRT); + tab.set_format(olive::ExportFormat::k_format_srt); EXPECT_FALSE(sidecar_box->isEnabled()); - EXPECT_FALSE(tab.GetSidecarEnabled()); + EXPECT_FALSE(tab.get_sidecar_enabled()); // WAV cannot carry subtitles at all: sidecar is forced on - tab.SetFormat(olive::ExportFormat::kFormatWAV); + tab.set_format(olive::ExportFormat::k_format_wav); EXPECT_FALSE(sidecar_box->isEnabled()); - EXPECT_TRUE(tab.GetSidecarEnabled()); + EXPECT_TRUE(tab.get_sidecar_enabled()); } // @@ -192,61 +192,61 @@ TEST(DialogExportSubtitlesTab, SidecarStateFollowsFormatCapabilities) // TEST(DialogExportVideoTab, SetFormatPopulatesCodecs) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; olive::ExportVideoTab tab(project.color_manager()); const QList codecs = - olive::ExportFormat::GetVideoCodecs(olive::ExportFormat::kFormatMatroska); + olive::ExportFormat::get_video_codecs(olive::ExportFormat::k_format_matroska); ASSERT_FALSE(codecs.isEmpty()); - EXPECT_EQ(tab.SetFormat(olive::ExportFormat::kFormatMatroska), + EXPECT_EQ(tab.set_format(olive::ExportFormat::k_format_matroska), codecs.size()); - EXPECT_EQ(tab.GetSelectedCodec(), codecs.first()); + EXPECT_EQ(tab.get_selected_codec(), codecs.first()); - tab.SetSelectedCodec(olive::ExportCodec::kCodecH265); - EXPECT_EQ(tab.GetSelectedCodec(), olive::ExportCodec::kCodecH265); + tab.set_selected_codec(olive::ExportCodec::k_codec_h265); + EXPECT_EQ(tab.get_selected_codec(), olive::ExportCodec::k_codec_h265); } TEST(DialogExportVideoTab, CodecSelectsMatchingSection) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; olive::ExportVideoTab tab(project.color_manager()); - tab.SetFormat(olive::ExportFormat::kFormatMatroska); + tab.set_format(olive::ExportFormat::k_format_matroska); // First Matroska codec is H.264, which has a dedicated section - tab.VideoCodecChanged(); - EXPECT_NE(tab.GetCodecSection(), nullptr); + tab.video_codec_changed(); + EXPECT_NE(tab.get_codec_section(), nullptr); // Still image codecs get the image section instead - tab.SetFormat(olive::ExportFormat::kFormatPNG); - tab.VideoCodecChanged(); - EXPECT_NE(dynamic_cast(tab.GetCodecSection()), + tab.set_format(olive::ExportFormat::k_format_png); + tab.video_codec_changed(); + EXPECT_NE(dynamic_cast(tab.get_codec_section()), nullptr); } TEST(DialogExportVideoTab, ImageSequenceCheckboxRoundTrips) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; olive::ExportVideoTab tab(project.color_manager()); - tab.SetFormat(olive::ExportFormat::kFormatPNG); - tab.VideoCodecChanged(); + tab.set_format(olive::ExportFormat::k_format_png); + tab.video_codec_changed(); - tab.SetImageSequence(true); - EXPECT_TRUE(tab.IsImageSequenceSet()); + tab.set_image_sequence(true); + EXPECT_TRUE(tab.is_image_sequence_set()); - tab.SetImageSequence(false); - EXPECT_FALSE(tab.IsImageSequenceSet()); + tab.set_image_sequence(false); + EXPECT_FALSE(tab.is_image_sequence_set()); } TEST(DialogExportVideoTab, MaintainAspectTogglesScalingMethod) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; olive::ExportVideoTab tab(project.color_manager()); @@ -263,29 +263,29 @@ TEST(DialogExportVideoTab, MaintainAspectTogglesScalingMethod) // TEST(DialogExportH264CRFSection, ValueRoundTripsAndClamps) { - olive::H264CRFSection section(olive::H264CRFSection::kDefaultH264CRF); + olive::H264CRFSection section(olive::H264CRFSection::k_default_h264_crf); - EXPECT_EQ(section.GetValue(), olive::H264CRFSection::kDefaultH264CRF); + EXPECT_EQ(section.get_value(), olive::H264CRFSection::k_default_h264_crf); - section.SetValue(30); - EXPECT_EQ(section.GetValue(), 30); + section.set_value(30); + EXPECT_EQ(section.get_value(), 30); - section.SetValue(99); - EXPECT_EQ(section.GetValue(), 51); + section.set_value(99); + EXPECT_EQ(section.get_value(), 51); - section.SetValue(-5); - EXPECT_EQ(section.GetValue(), 0); + section.set_value(-5); + EXPECT_EQ(section.get_value(), 0); } TEST(DialogExportH264BitRateSection, BitRateRoundTripsInBits) { olive::H264BitRateSection section; - section.SetTargetBitRate(8000000); - EXPECT_EQ(section.GetTargetBitRate(), 8000000); + section.set_target_bit_rate(8000000); + EXPECT_EQ(section.get_target_bit_rate(), 8000000); - section.SetMaximumBitRate(16000000); - EXPECT_EQ(section.GetMaximumBitRate(), 16000000); + section.set_maximum_bit_rate(16000000); + EXPECT_EQ(section.get_maximum_bit_rate(), 16000000); } // @@ -302,8 +302,8 @@ TEST(DialogExportAdvancedVideo, FieldsRoundTrip) dialog.set_pix_fmt(QStringLiteral("yuv422p")); EXPECT_EQ(dialog.pix_fmt(), QStringLiteral("yuv422p")); - dialog.set_yuv_range(olive::VideoParams::kColorRangeFull); - EXPECT_EQ(dialog.yuv_range(), olive::VideoParams::kColorRangeFull); + dialog.set_yuv_range(olive::VideoParams::k_color_range_full); + EXPECT_EQ(dialog.yuv_range(), olive::VideoParams::k_color_range_full); } // @@ -321,16 +321,16 @@ TEST(DialogExportSavePreset, AcceptWritesPresetFile) ASSERT_NE(name_edit, nullptr); name_edit->setText(QStringLiteral("oak-test-preset")); - EXPECT_EQ(dialog.GetSelectedPresetName(), + EXPECT_EQ(dialog.get_selected_preset_name(), QStringLiteral("oak-test-preset")); dialog.accept(); EXPECT_EQ(dialog.result(), QDialog::Accepted); - EXPECT_TRUE(olive::EncodingParams::GetListOfPresets().contains( + EXPECT_TRUE(olive::EncodingParams::get_list_of_presets().contains( QStringLiteral("oak-test-preset"))); // Clean up the preset file written to the test config location - QFile::remove(QDir(olive::EncodingParams::GetPresetPath()) + QFile::remove(QDir(olive::EncodingParams::get_preset_path()) .filePath(QStringLiteral("oak-test-preset"))); } diff --git a/tests/gtest/dialog_misc_test.cpp b/tests/gtest/dialog_misc_test.cpp index e371f372c..5cc375dc3 100644 --- a/tests/gtest/dialog_misc_test.cpp +++ b/tests/gtest/dialog_misc_test.cpp @@ -40,13 +40,13 @@ namespace { -void EnsureAppSingletons() +void ensure_app_singletons() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } @@ -70,12 +70,12 @@ public: bool validate_result = true; int accept_count = 0; - virtual bool Validate() override + virtual bool validate() override { return validate_result; } - virtual void Accept(olive::MultiUndoCommand *) override + virtual void accept(olive::MultiUndoCommand *) override { ++accept_count; } @@ -83,7 +83,7 @@ public: class TestConfigDialog : public olive::ConfigDialogBase { public: - using olive::ConfigDialogBase::AddTab; + using olive::ConfigDialogBase::add_tab; using olive::ConfigDialogBase::ConfigDialogBase; bool accept_event_called = false; @@ -99,11 +99,11 @@ class DummyTask : public olive::Task { public: DummyTask() { - SetTitle(QStringLiteral("DummyTask")); + set_title(QStringLiteral("DummyTask")); } protected: - virtual bool Run() override + virtual bool run() override { return true; } @@ -126,7 +126,7 @@ TEST(DialogAbout, WelcomeDialogHasDontShowAgainCheckbox) TEST(DialogAbout, AcceptWithCheckboxWritesConfig) { const QVariant old_value = - olive::Config::Current()[QStringLiteral("ShowWelcomeDialog")]; + olive::Config::current()[QStringLiteral("ShowWelcomeDialog")]; { olive::AboutDialog welcome(true); @@ -137,9 +137,9 @@ TEST(DialogAbout, AcceptWithCheckboxWritesConfig) } EXPECT_FALSE( - olive::Config::Current()[QStringLiteral("ShowWelcomeDialog")].toBool()); + olive::Config::current()[QStringLiteral("ShowWelcomeDialog")].toBool()); - olive::Config::Current()[QStringLiteral("ShowWelcomeDialog")] = old_value; + olive::Config::current()[QStringLiteral("ShowWelcomeDialog")] = old_value; } // @@ -159,7 +159,7 @@ TEST(DialogActionSearch, SearchFiltersActionsCaseInsensitively) recent_menu->addAction(QStringLiteral("Project A")); bar.addMenu(QStringLiteral("&Edit"))->addAction(QStringLiteral("Undo")); - dialog.SetMenuBar(&bar); + dialog.set_menu_bar(&bar); auto *entry = dialog.findChild(); auto *list = dialog.findChild(); @@ -192,7 +192,7 @@ TEST(DialogActionSearch, PerformActionTriggersSelectedAction) QMenu *file_menu = bar.addMenu(QStringLiteral("&File")); QAction *open_action = file_menu->addAction(QStringLiteral("Open...")); - dialog.SetMenuBar(&bar); + dialog.set_menu_bar(&bar); bool triggered = false; QObject::connect(open_action, &QAction::triggered, @@ -217,7 +217,7 @@ TEST(DialogActionSearch, SelectionMovesUpAndDown) file_menu->addAction(QStringLiteral("Alpha")); file_menu->addAction(QStringLiteral("Beta")); - dialog.SetMenuBar(&bar); + dialog.set_menu_bar(&bar); auto *entry = dialog.findChild(); auto *list = dialog.findChild(); @@ -242,9 +242,9 @@ TEST(DialogActionSearch, SelectionMovesUpAndDown) TEST(DialogAutoRecovery, PopulatesTreeFromRecoveryFolders) { StandardPathsTestModeGuard test_mode; - EnsureAppSingletons(); + ensure_app_singletons(); - const QString root = olive::FileFunctions::GetAutoRecoveryRoot(); + const QString root = olive::FileFunctions::get_auto_recovery_root(); const QString folder = QStringLiteral("uuid-abc"); QDir recovery_dir(QDir(root).filePath(folder)); ASSERT_TRUE(recovery_dir.mkpath(QStringLiteral("."))); @@ -317,9 +317,9 @@ TEST(DialogAutoRecovery, PopulatesTreeFromRecoveryFolders) TEST(DialogAutoRecovery, MissingRealnameFallsBackToFolderName) { StandardPathsTestModeGuard test_mode; - EnsureAppSingletons(); + ensure_app_singletons(); - const QString root = olive::FileFunctions::GetAutoRecoveryRoot(); + const QString root = olive::FileFunctions::get_auto_recovery_root(); const QString folder = QStringLiteral("uuid-no-realname"); QDir recovery_dir(QDir(root).filePath(folder)); ASSERT_TRUE(recovery_dir.mkpath(QStringLiteral("."))); @@ -349,8 +349,8 @@ TEST(DialogConfigBase, AddTabPopulatesListAndStack) auto *tab_a = new DummyTab(); auto *tab_b = new DummyTab(); - dialog.AddTab(tab_a, QStringLiteral("First")); - dialog.AddTab(tab_b, QStringLiteral("Second")); + dialog.add_tab(tab_a, QStringLiteral("First")); + dialog.add_tab(tab_b, QStringLiteral("Second")); auto *list = dialog.findChild(); auto *stack = dialog.findChild(); @@ -360,20 +360,20 @@ TEST(DialogConfigBase, AddTabPopulatesListAndStack) EXPECT_EQ(list->count(), 2); EXPECT_EQ(stack->count(), 2); - dialog.SetCurrentTab(1); + dialog.set_current_tab(1); EXPECT_EQ(list->currentRow(), 1); EXPECT_EQ(stack->currentIndex(), 1); } TEST(DialogConfigBase, AcceptCallsTabsAndAcceptEvent) { - EnsureAppSingletons(); + ensure_app_singletons(); TestConfigDialog dialog; auto *tab_a = new DummyTab(); auto *tab_b = new DummyTab(); - dialog.AddTab(tab_a, QStringLiteral("First")); - dialog.AddTab(tab_b, QStringLiteral("Second")); + dialog.add_tab(tab_a, QStringLiteral("First")); + dialog.add_tab(tab_b, QStringLiteral("Second")); // accept() is a private slot, invoke it through the meta-object QMetaObject::invokeMethod(&dialog, "accept"); @@ -386,14 +386,14 @@ TEST(DialogConfigBase, AcceptCallsTabsAndAcceptEvent) TEST(DialogConfigBase, FailedValidateBlocksAccept) { - EnsureAppSingletons(); + ensure_app_singletons(); TestConfigDialog dialog; auto *tab_a = new DummyTab(); auto *tab_b = new DummyTab(); tab_a->validate_result = false; - dialog.AddTab(tab_a, QStringLiteral("First")); - dialog.AddTab(tab_b, QStringLiteral("Second")); + dialog.add_tab(tab_a, QStringLiteral("First")); + dialog.add_tab(tab_b, QStringLiteral("Second")); // accept() is a private slot, invoke it through the meta-object QMetaObject::invokeMethod(&dialog, "accept"); @@ -422,17 +422,17 @@ TEST(DialogDiskCache, AcceptAppliesLimitAndClearOnClose) ASSERT_NE(clear_box, nullptr); // Fields reflect the folder's current settings (20 GB default) - EXPECT_DOUBLE_EQ(limit_slider->GetValue(), 20.0); + EXPECT_DOUBLE_EQ(limit_slider->get_value(), 20.0); EXPECT_FALSE(clear_box->isChecked()); - limit_slider->SetValue(5.0); + limit_slider->set_value(5.0); clear_box->setChecked(true); dialog.accept(); - EXPECT_EQ(folder.GetLimit(), - 5 * static_cast(olive::kBytesInGigabyte)); - EXPECT_TRUE(folder.GetClearOnClose()); + EXPECT_EQ(folder.get_limit(), + 5 * static_cast(olive::k_bytes_in_gigabyte)); + EXPECT_TRUE(folder.get_clear_on_close()); } // @@ -468,7 +468,7 @@ TEST(DialogProgress, CancelButtonEmitsCancelledAndDisables) ASSERT_NE(cancel_btn, nullptr); bool cancelled = false; - QObject::connect(&dialog, &olive::ProgressDialog::Cancelled, + QObject::connect(&dialog, &olive::ProgressDialog::cancelled, [&cancelled]() { cancelled = true; }); cancel_btn->click(); @@ -484,12 +484,12 @@ TEST(DialogRenderCancel, IdleWorkersDoNotBlock) { olive::RenderCancelDialog dialog; - dialog.SetWorkerCount(2); - dialog.WorkerStarted(); - dialog.WorkerDone(); + dialog.set_worker_count(2); + dialog.worker_started(); + dialog.worker_done(); // No busy workers: must return immediately without exec()ing - dialog.RunIfWorkersAreBusy(); + dialog.run_if_workers_are_busy(); EXPECT_FALSE(dialog.isVisible()); } @@ -504,7 +504,7 @@ TEST(DialogTask, WrapsAndOwnsTask) auto *dialog = new olive::TaskDialog(task, QStringLiteral("Title")); - EXPECT_EQ(dialog->GetTask(), task); + EXPECT_EQ(dialog->get_task(), task); EXPECT_EQ(task->parent(), dialog); // The dialog takes ownership of the task @@ -517,19 +517,19 @@ TEST(DialogTask, WrapsAndOwnsTask) // TEST(DialogColor, SelectedColorRoundTrips) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; olive::ColorDialog dialog(project.color_manager(), olive::Color(1.0f, 0.0f, 0.0f, 1.0f)); - olive::ManagedColor selected = dialog.GetSelectedColor(); + olive::ManagedColor selected = dialog.get_selected_color(); EXPECT_GT(selected.red(), selected.green()); EXPECT_GT(selected.red(), selected.blue()); - dialog.SetColor(olive::Color(0.0f, 0.0f, 1.0f, 1.0f)); + dialog.set_color(olive::Color(0.0f, 0.0f, 1.0f, 1.0f)); - olive::ManagedColor blue = dialog.GetSelectedColor(); + olive::ManagedColor blue = dialog.get_selected_color(); EXPECT_GT(blue.blue(), blue.red()); EXPECT_GT(blue.blue(), blue.green()); } @@ -547,12 +547,12 @@ TEST(PreferencesAppearanceTab, ContainsStyleAndColorChoices) TEST(PreferencesDiskTab, ValidatesUnchangedCacheLocation) { - EnsureAppSingletons(); + ensure_app_singletons(); olive::PreferencesDiskTab tab; // Unchanged location must validate without prompting - EXPECT_TRUE(tab.Validate()); + EXPECT_TRUE(tab.validate()); } TEST(PreferencesLutTab, ConstructsWithDirectoryList) diff --git a/tests/gtest/dynamic_render_backend_test.cpp b/tests/gtest/dynamic_render_backend_test.cpp index fabac4591..c0e1d9e53 100644 --- a/tests/gtest/dynamic_render_backend_test.cpp +++ b/tests/gtest/dynamic_render_backend_test.cpp @@ -20,21 +20,21 @@ TEST(DynamicRenderBackend, LoadsExperimentalOpenGLBackend) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("opengl")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "opengl backend library could not be loaded in this environment"; } - EXPECT_EQ(renderer.OpenGLContext(), nullptr); + EXPECT_EQ(renderer.open_gl_context(), nullptr); OakRenderBackendInfo info = {}; - ASSERT_TRUE(renderer.GetBackendInfo(&info)); + ASSERT_TRUE(renderer.get_backend_info(&info)); EXPECT_EQ(info.abi_version, 1U); - EXPECT_EQ(info.kind, OAK_RENDER_BACKEND_OPENGL); + EXPECT_EQ(info.kind, oak_render_backend_opengl); EXPECT_STREQ(info.name, "opengl"); - EXPECT_TRUE(info.capabilities & OAK_RENDER_BACKEND_CAP_TEXTURES); - EXPECT_TRUE(info.capabilities & OAK_RENDER_BACKEND_CAP_SHADERS); - EXPECT_TRUE(info.capabilities & OAK_RENDER_BACKEND_CAP_BLIT); - EXPECT_TRUE(info.capabilities & OAK_RENDER_BACKEND_CAP_READBACK); + EXPECT_TRUE(info.capabilities & oak_render_backend_cap_textures); + EXPECT_TRUE(info.capabilities & oak_render_backend_cap_shaders); + EXPECT_TRUE(info.capabilities & oak_render_backend_cap_blit); + EXPECT_TRUE(info.capabilities & oak_render_backend_cap_readback); #endif } @@ -48,12 +48,12 @@ TEST(DynamicRenderBackend, OpenGLBackendFollowsAdapterToRenderThread) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("opengl")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "opengl backend library could not be loaded in this environment"; } - if (!renderer.Init()) { + if (!renderer.init()) { GTEST_SKIP() << "OpenGL backend could not be initialized on this system"; } @@ -62,7 +62,7 @@ TEST(DynamicRenderBackend, OpenGLBackendFollowsAdapterToRenderThread) renderer.moveToThread(&render_thread); render_thread.start(); - QOpenGLContext *ctx = renderer.OpenGLContext(); + QOpenGLContext *ctx = renderer.open_gl_context(); ASSERT_NE(ctx, nullptr); EXPECT_EQ(ctx->thread(), &render_thread) << "Backend OpenGL context did not follow DynamicRenderer to render thread"; @@ -73,10 +73,10 @@ TEST(DynamicRenderBackend, OpenGLBackendFollowsAdapterToRenderThread) QMetaObject::invokeMethod( &renderer, [&]() { - renderer.PostInit(); - texture = renderer.CreateTexture( - olive::VideoParams(64, 64, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + renderer.post_init(); + texture = renderer.create_texture( + olive::VideoParams(64, 64, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); }, Qt::BlockingQueuedConnection); @@ -84,7 +84,7 @@ TEST(DynamicRenderBackend, OpenGLBackendFollowsAdapterToRenderThread) render_thread.wait(); ASSERT_NE(texture, nullptr); - EXPECT_FALSE(texture->IsDummy()); + EXPECT_FALSE(texture->is_dummy()); #endif } @@ -96,23 +96,23 @@ TEST(DynamicRenderBackend, LoadsExperimentalVulkanBackendWhenAvailable) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("vulkan")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "vulkan backend library could not be loaded in this environment"; } OakRenderBackendInfo info = {}; - ASSERT_TRUE(renderer.GetBackendInfo(&info)); - if (info.kind != OAK_RENDER_BACKEND_VULKAN) { + ASSERT_TRUE(renderer.get_backend_info(&info)); + if (info.kind != oak_render_backend_vulkan) { GTEST_SKIP() << "Vulkan backend is not available on this system"; } EXPECT_EQ(renderer.backend_name(), QStringLiteral("vulkan")); - EXPECT_EQ(renderer.OpenGLContext(), nullptr); + EXPECT_EQ(renderer.open_gl_context(), nullptr); EXPECT_STREQ(info.name, "vulkan"); - EXPECT_TRUE(info.capabilities & OAK_RENDER_BACKEND_CAP_TEXTURES); - EXPECT_TRUE(info.capabilities & OAK_RENDER_BACKEND_CAP_SHADERS); - EXPECT_TRUE(info.capabilities & OAK_RENDER_BACKEND_CAP_BLIT); - EXPECT_TRUE(info.capabilities & OAK_RENDER_BACKEND_CAP_READBACK); + EXPECT_TRUE(info.capabilities & oak_render_backend_cap_textures); + EXPECT_TRUE(info.capabilities & oak_render_backend_cap_shaders); + EXPECT_TRUE(info.capabilities & oak_render_backend_cap_blit); + EXPECT_TRUE(info.capabilities & oak_render_backend_cap_readback); #endif } @@ -124,20 +124,20 @@ TEST(DynamicRenderBackend, FallsBackWhenExperimentalVulkanUnavailable) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("vulkan")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "vulkan backend library could not be loaded in this environment"; } OakRenderBackendInfo info = {}; - ASSERT_TRUE(renderer.GetBackendInfo(&info)); - if (info.kind == OAK_RENDER_BACKEND_VULKAN) { + ASSERT_TRUE(renderer.get_backend_info(&info)); + if (info.kind == oak_render_backend_vulkan) { GTEST_SKIP() << "Vulkan backend is available on this system; skip fallback test"; } EXPECT_EQ(renderer.backend_name(), QStringLiteral("opengl")); - EXPECT_EQ(renderer.OpenGLContext(), nullptr); - EXPECT_EQ(info.kind, OAK_RENDER_BACKEND_OPENGL); + EXPECT_EQ(renderer.open_gl_context(), nullptr); + EXPECT_EQ(info.kind, oak_render_backend_opengl); EXPECT_STREQ(info.name, "opengl"); #endif } @@ -150,40 +150,40 @@ TEST(DynamicRenderBackend, VulkanUploadBlitDownload) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("vulkan")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "vulkan backend library could not be loaded in this environment"; } OakRenderBackendInfo info = {}; - ASSERT_TRUE(renderer.GetBackendInfo(&info)); - if (info.kind != OAK_RENDER_BACKEND_VULKAN) { + ASSERT_TRUE(renderer.get_backend_info(&info)); + if (info.kind != oak_render_backend_vulkan) { GTEST_SKIP() << "Vulkan backend is not available on this system"; } - ASSERT_TRUE(renderer.Init()); - renderer.PostInit(); + ASSERT_TRUE(renderer.init()); + renderer.post_init(); - const int kSize = 64; - olive::VideoParams params(kSize, kSize, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const int k_size = 64; + olive::VideoParams params(k_size, k_size, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - olive::TexturePtr src = renderer.CreateTexture(params); + olive::TexturePtr src = renderer.create_texture(params); ASSERT_NE(src, nullptr); - ASSERT_FALSE(src->IsDummy()); + ASSERT_FALSE(src->is_dummy()); - QByteArray src_data(kSize * kSize * 4, 0); - for (int i = 0; i < kSize * kSize; ++i) { + QByteArray src_data(k_size * k_size * 4, 0); + for (int i = 0; i < k_size * k_size; ++i) { src_data[i * 4 + 0] = static_cast(255); // R src_data[i * 4 + 1] = static_cast(0); // G src_data[i * 4 + 2] = static_cast(0); // B src_data[i * 4 + 3] = static_cast(255); // A } - src->Upload(src_data.data(), kSize); + src->upload(src_data.data(), k_size); - olive::TexturePtr dst = renderer.CreateTexture(params); + olive::TexturePtr dst = renderer.create_texture(params); ASSERT_NE(dst, nullptr); - ASSERT_FALSE(dst->IsDummy()); + ASSERT_FALSE(dst->is_dummy()); const QString vert = QStringLiteral("uniform mat4 ove_mvpmat;\n" @@ -202,20 +202,20 @@ TEST(DynamicRenderBackend, VulkanUploadBlitDownload) " frag_color = texture(ove_maintex, ove_texcoord);\n" "}\n"); QVariant shader = - renderer.CreateNativeShader(olive::ShaderCode(frag, vert)); + renderer.create_native_shader(olive::ShaderCode(frag, vert)); ASSERT_FALSE(shader.isNull()); olive::ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), - olive::NodeValue(olive::NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + olive::NodeValue(olive::NodeValue::k_texture, QVariant::fromValue(src))); - job.Insert(QStringLiteral("ove_mvpmat"), - olive::NodeValue(olive::NodeValue::kMatrix, QMatrix4x4())); + job.insert(QStringLiteral("ove_mvpmat"), + olive::NodeValue(olive::NodeValue::k_matrix, QMatrix4x4())); - renderer.BlitToTexture(shader, job, dst.get(), true); + renderer.blit_to_texture(shader, job, dst.get(), true); - QByteArray dst_data(kSize * kSize * 4, 0); - dst->Download(dst_data.data(), kSize); + QByteArray dst_data(k_size * k_size * 4, 0); + dst->download(dst_data.data(), k_size); // The default pass-through shader should reproduce the red source pixel. EXPECT_EQ(static_cast(dst_data[0]), 255u); @@ -233,34 +233,34 @@ TEST(DynamicRenderBackend, VulkanNullDestinationBlitDoesNotCrash) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("vulkan")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "vulkan backend library could not be loaded in this environment"; } OakRenderBackendInfo info = {}; - ASSERT_TRUE(renderer.GetBackendInfo(&info)); - if (info.kind != OAK_RENDER_BACKEND_VULKAN) { + ASSERT_TRUE(renderer.get_backend_info(&info)); + if (info.kind != oak_render_backend_vulkan) { GTEST_SKIP() << "Vulkan backend is not available on this system"; } - ASSERT_TRUE(renderer.Init()); - renderer.PostInit(); + ASSERT_TRUE(renderer.init()); + renderer.post_init(); - const int kSize = 32; - olive::VideoParams params(kSize, kSize, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const int k_size = 32; + olive::VideoParams params(k_size, k_size, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - olive::TexturePtr src = renderer.CreateTexture(params); + olive::TexturePtr src = renderer.create_texture(params); ASSERT_NE(src, nullptr); - ASSERT_FALSE(src->IsDummy()); + ASSERT_FALSE(src->is_dummy()); - QByteArray src_data(kSize * kSize * 4, 0); - for (int i = 0; i < kSize * kSize; ++i) { + QByteArray src_data(k_size * k_size * 4, 0); + for (int i = 0; i < k_size * k_size; ++i) { src_data[i * 4 + 0] = static_cast(255); src_data[i * 4 + 3] = static_cast(255); } - src->Upload(src_data.data(), kSize); + src->upload(src_data.data(), k_size); const QString vert = QStringLiteral("uniform mat4 ove_mvpmat;\n" @@ -279,18 +279,18 @@ TEST(DynamicRenderBackend, VulkanNullDestinationBlitDoesNotCrash) " frag_color = texture(ove_maintex, ove_texcoord);\n" "}\n"); QVariant shader = - renderer.CreateNativeShader(olive::ShaderCode(frag, vert)); + renderer.create_native_shader(olive::ShaderCode(frag, vert)); ASSERT_FALSE(shader.isNull()); olive::ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), - olive::NodeValue(olive::NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + olive::NodeValue(olive::NodeValue::k_texture, QVariant::fromValue(src))); - job.Insert(QStringLiteral("ove_mvpmat"), - olive::NodeValue(olive::NodeValue::kMatrix, QMatrix4x4())); + job.insert(QStringLiteral("ove_mvpmat"), + olive::NodeValue(olive::NodeValue::k_matrix, QMatrix4x4())); // Null-destination Blit has no render target; it should simply not crash. - renderer.Blit(shader, job, params, true); + renderer.blit(shader, job, params, true); SUCCEED(); #endif } @@ -303,39 +303,39 @@ TEST(DynamicRenderBackend, VulkanIterativeBlitPingPong) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("vulkan")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "vulkan backend library could not be loaded in this environment"; } OakRenderBackendInfo info = {}; - ASSERT_TRUE(renderer.GetBackendInfo(&info)); - if (info.kind != OAK_RENDER_BACKEND_VULKAN) { + ASSERT_TRUE(renderer.get_backend_info(&info)); + if (info.kind != oak_render_backend_vulkan) { GTEST_SKIP() << "Vulkan backend is not available on this system"; } - ASSERT_TRUE(renderer.Init()); - renderer.PostInit(); + ASSERT_TRUE(renderer.init()); + renderer.post_init(); - const int kSize = 32; - olive::VideoParams params(kSize, kSize, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const int k_size = 32; + olive::VideoParams params(k_size, k_size, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - olive::TexturePtr src = renderer.CreateTexture(params); + olive::TexturePtr src = renderer.create_texture(params); ASSERT_NE(src, nullptr); - ASSERT_FALSE(src->IsDummy()); + ASSERT_FALSE(src->is_dummy()); // Start with a fully red texture. - QByteArray src_data(kSize * kSize * 4, 0); - for (int i = 0; i < kSize * kSize; ++i) { + QByteArray src_data(k_size * k_size * 4, 0); + for (int i = 0; i < k_size * k_size; ++i) { src_data[i * 4 + 0] = static_cast(255); src_data[i * 4 + 3] = static_cast(255); } - src->Upload(src_data.data(), kSize); + src->upload(src_data.data(), k_size); - olive::TexturePtr dst = renderer.CreateTexture(params); + olive::TexturePtr dst = renderer.create_texture(params); ASSERT_NE(dst, nullptr); - ASSERT_FALSE(dst->IsDummy()); + ASSERT_FALSE(dst->is_dummy()); // Shader that samples the iterative input and scales RGB by 0.5 each pass. const QString vert = @@ -356,21 +356,21 @@ TEST(DynamicRenderBackend, VulkanIterativeBlitPingPong) " frag_color = vec4(c.rgb * 0.5, c.a);\n" "}\n"); QVariant shader = - renderer.CreateNativeShader(olive::ShaderCode(frag, vert)); + renderer.create_native_shader(olive::ShaderCode(frag, vert)); ASSERT_FALSE(shader.isNull()); olive::ShaderJob job; - job.Insert(QStringLiteral("ove_maintex"), - olive::NodeValue(olive::NodeValue::kTexture, + job.insert(QStringLiteral("ove_maintex"), + olive::NodeValue(olive::NodeValue::k_texture, QVariant::fromValue(src))); - job.Insert(QStringLiteral("ove_mvpmat"), - olive::NodeValue(olive::NodeValue::kMatrix, QMatrix4x4())); - job.SetIterations(2, QStringLiteral("ove_maintex")); + job.insert(QStringLiteral("ove_mvpmat"), + olive::NodeValue(olive::NodeValue::k_matrix, QMatrix4x4())); + job.set_iterations(2, QStringLiteral("ove_maintex")); - renderer.BlitToTexture(shader, job, dst.get(), true); + renderer.blit_to_texture(shader, job, dst.get(), true); - QByteArray dst_data(kSize * kSize * 4, 0); - dst->Download(dst_data.data(), kSize); + QByteArray dst_data(k_size * k_size * 4, 0); + dst->download(dst_data.data(), k_size); // After two halving passes, red is 255 * 0.5 * 0.5. UNORM conversion floors // the intermediate value, so the result is 63 rather than 64. @@ -389,38 +389,38 @@ TEST(DynamicRenderBackend, VulkanUploadDownloadThreeChannel) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("vulkan")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "vulkan backend library could not be loaded in this environment"; } OakRenderBackendInfo info = {}; - ASSERT_TRUE(renderer.GetBackendInfo(&info)); - if (info.kind != OAK_RENDER_BACKEND_VULKAN) { + ASSERT_TRUE(renderer.get_backend_info(&info)); + if (info.kind != oak_render_backend_vulkan) { GTEST_SKIP() << "Vulkan backend is not available on this system"; } - ASSERT_TRUE(renderer.Init()); - renderer.PostInit(); + ASSERT_TRUE(renderer.init()); + renderer.post_init(); - const int kSize = 16; - olive::VideoParams params(kSize, kSize, olive::PixelFormat::U8, - olive::VideoParams::kRGBChannelCount); + const int k_size = 16; + olive::VideoParams params(k_size, k_size, olive::PixelFormat::u8, + olive::VideoParams::k_rgb_channel_count); - olive::TexturePtr tex = renderer.CreateTexture(params); + olive::TexturePtr tex = renderer.create_texture(params); ASSERT_NE(tex, nullptr); - ASSERT_FALSE(tex->IsDummy()); + ASSERT_FALSE(tex->is_dummy()); - QByteArray src_data(kSize * kSize * 3, 0); - for (int i = 0; i < kSize * kSize; ++i) { + QByteArray src_data(k_size * k_size * 3, 0); + for (int i = 0; i < k_size * k_size; ++i) { src_data[i * 3 + 0] = static_cast(255); src_data[i * 3 + 1] = static_cast(128); src_data[i * 3 + 2] = static_cast(64); } - tex->Upload(src_data.data(), kSize); + tex->upload(src_data.data(), k_size); - QByteArray dst_data(kSize * kSize * 3, 0); - tex->Download(dst_data.data(), kSize); + QByteArray dst_data(k_size * k_size * 3, 0); + tex->download(dst_data.data(), k_size); EXPECT_EQ(static_cast(dst_data[0]), 255u); EXPECT_EQ(static_cast(dst_data[1]), 128u); diff --git a/tests/gtest/ffmpeg_bridge_test.cpp b/tests/gtest/ffmpeg_bridge_test.cpp index 99df5b4cf..4963b5a7f 100644 --- a/tests/gtest/ffmpeg_bridge_test.cpp +++ b/tests/gtest/ffmpeg_bridge_test.cpp @@ -27,21 +27,21 @@ namespace { -QString DemoPath() +QString demo_path() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/demo.mp4")); } -QString TempFilePath(const QString &name) +QString temp_file_path(const QString &name) { return QDir::temp().filePath(name); } -constexpr double kPi = 3.14159265358979323846; +constexpr double k_pi = 3.14159265358979323846; // Finds the first stream of `type`; returns its index or -1. -int FindStream(FBProbe *probe, int type) +int find_stream(FBProbe *probe, int type) { const int count = fb_probe_get_stream_count(probe); for (int i = 0; i < count; ++i) { @@ -64,11 +64,11 @@ TEST(FFmpegBridgeConstants, ChannelLayoutsMatchCore) { // The core library and the bridge must agree on layout masks or all // audio plumbing between them breaks. - EXPECT_EQ(FB_CH_LAYOUT_MONO, olive::core::kChannelLayoutMono); - EXPECT_EQ(FB_CH_LAYOUT_STEREO, olive::core::kChannelLayoutStereo); - EXPECT_EQ(FB_CH_LAYOUT_2_1, olive::core::kChannelLayout2_1); - EXPECT_EQ(FB_CH_LAYOUT_5POINT1, olive::core::kChannelLayout5Point1); - EXPECT_EQ(FB_CH_LAYOUT_7POINT1, olive::core::kChannelLayout7Point1); + EXPECT_EQ(FB_CH_LAYOUT_MONO, olive::core::k_channel_layout_mono); + EXPECT_EQ(FB_CH_LAYOUT_STEREO, olive::core::k_channel_layout_stereo); + EXPECT_EQ(FB_CH_LAYOUT_2_1, olive::core::k_channel_layout2_1); + EXPECT_EQ(FB_CH_LAYOUT_5POINT1, olive::core::k_channel_layout5_point1); + EXPECT_EQ(FB_CH_LAYOUT_7POINT1, olive::core::k_channel_layout7_point1); } TEST(FFmpegBridgeConstants, SpecialValues) @@ -76,8 +76,8 @@ TEST(FFmpegBridgeConstants, SpecialValues) EXPECT_EQ(FB_NOPTS_VALUE, INT64_MIN); EXPECT_EQ(FB_TIME_BASE, 1000000); EXPECT_LT(FB_ERROR_EOF, 0); - EXPECT_EQ(FB_PIX_FMT_NONE, -1); - EXPECT_EQ(FB_SAMPLE_FMT_NONE, -1); + EXPECT_EQ(fb_pix_fmt_none, -1); + EXPECT_EQ(fb_sample_fmt_none, -1); } // ============================================================================ @@ -107,37 +107,37 @@ TEST(FFmpegBridgeError, VersionString) TEST(FFmpegBridgePixFmt, NameRoundtrip) { - const char *name = fb_pix_fmt_name(FB_PIX_FMT_YUV420P); + const char *name = fb_pix_fmt_name(fb_pix_fmt_yu_v420_p); ASSERT_NE(name, nullptr); EXPECT_STREQ(name, "yuv420p"); - EXPECT_EQ(fb_pix_fmt_from_name(name), FB_PIX_FMT_YUV420P); + EXPECT_EQ(fb_pix_fmt_from_name(name), fb_pix_fmt_yu_v420_p); - EXPECT_STREQ(fb_pix_fmt_name(FB_PIX_FMT_RGBA), "rgba"); - EXPECT_EQ(fb_pix_fmt_from_name("rgba"), FB_PIX_FMT_RGBA); + EXPECT_STREQ(fb_pix_fmt_name(fb_pix_fmt_rgba), "rgba"); + EXPECT_EQ(fb_pix_fmt_from_name("rgba"), fb_pix_fmt_rgba); } TEST(FFmpegBridgePixFmt, Properties) { - EXPECT_EQ(fb_pix_fmt_bits_per_pixel(FB_PIX_FMT_RGBA), 32); - EXPECT_EQ(fb_pix_fmt_bits_per_pixel(FB_PIX_FMT_YUV420P), 12); - EXPECT_EQ(fb_pix_fmt_bits_per_pixel(FB_PIX_FMT_RGBA64LE), 64); + EXPECT_EQ(fb_pix_fmt_bits_per_pixel(fb_pix_fmt_rgba), 32); + EXPECT_EQ(fb_pix_fmt_bits_per_pixel(fb_pix_fmt_yu_v420_p), 12); + EXPECT_EQ(fb_pix_fmt_bits_per_pixel(fb_pix_fmt_rgb_a64_le), 64); - EXPECT_EQ(fb_pix_fmt_has_alpha(FB_PIX_FMT_RGBA), 1); - EXPECT_EQ(fb_pix_fmt_has_alpha(FB_PIX_FMT_YUV420P), 0); + EXPECT_EQ(fb_pix_fmt_has_alpha(fb_pix_fmt_rgba), 1); + EXPECT_EQ(fb_pix_fmt_has_alpha(fb_pix_fmt_yu_v420_p), 0); - EXPECT_EQ(fb_pix_fmt_is_planar(FB_PIX_FMT_YUV420P), 1); - EXPECT_EQ(fb_pix_fmt_is_planar(FB_PIX_FMT_RGBA), 0); + EXPECT_EQ(fb_pix_fmt_is_planar(fb_pix_fmt_yu_v420_p), 1); + EXPECT_EQ(fb_pix_fmt_is_planar(fb_pix_fmt_rgba), 0); - EXPECT_EQ(fb_pix_fmt_component_size(FB_PIX_FMT_RGBA), 1); - EXPECT_EQ(fb_pix_fmt_component_size(FB_PIX_FMT_RGBA64LE), 2); + EXPECT_EQ(fb_pix_fmt_component_size(fb_pix_fmt_rgba), 1); + EXPECT_EQ(fb_pix_fmt_component_size(fb_pix_fmt_rgb_a64_le), 2); } TEST(FFmpegBridgePixFmt, FindBestOfList) { - const int list[] = { FB_PIX_FMT_YUV420P, FB_PIX_FMT_YUV444P, - FB_PIX_FMT_NONE }; - EXPECT_EQ(fb_find_best_pix_fmt_of_list(list, FB_PIX_FMT_YUV420P), - FB_PIX_FMT_YUV420P); + const int list[] = { fb_pix_fmt_yu_v420_p, fb_pix_fmt_yu_v444_p, + fb_pix_fmt_none }; + EXPECT_EQ(fb_find_best_pix_fmt_of_list(list, fb_pix_fmt_yu_v420_p), + fb_pix_fmt_yu_v420_p); } TEST(FFmpegBridgeChannelLayout, ChannelCounts) @@ -168,16 +168,16 @@ TEST(FFmpegBridgeFrame, AllocAndFields) ASSERT_NE(frame, nullptr); EXPECT_EQ(fb_frame_get_width(frame), 0); - EXPECT_EQ(fb_frame_get_format(frame), FB_PIX_FMT_NONE); + EXPECT_EQ(fb_frame_get_format(frame), fb_pix_fmt_none); fb_frame_set_width(frame, 320); fb_frame_set_height(frame, 240); - fb_frame_set_format(frame, FB_PIX_FMT_RGBA); + fb_frame_set_format(frame, fb_pix_fmt_rgba); fb_frame_set_pts(frame, 12345); EXPECT_EQ(fb_frame_get_width(frame), 320); EXPECT_EQ(fb_frame_get_height(frame), 240); - EXPECT_EQ(fb_frame_get_format(frame), FB_PIX_FMT_RGBA); + EXPECT_EQ(fb_frame_get_format(frame), fb_pix_fmt_rgba); EXPECT_EQ(fb_frame_get_pts(frame), 12345); fb_frame_free(&frame); @@ -191,7 +191,7 @@ TEST(FFmpegBridgeFrame, BufferAllocAndAccess) fb_frame_set_width(frame, 64); fb_frame_set_height(frame, 48); - fb_frame_set_format(frame, FB_PIX_FMT_RGBA); + fb_frame_set_format(frame, fb_pix_fmt_rgba); ASSERT_EQ(fb_frame_get_buffer(frame, 0), 0); ASSERT_EQ(fb_frame_make_writable(frame), 0); @@ -227,7 +227,7 @@ TEST(FFmpegBridgeFrame, AudioFields) fb_frame_set_nb_samples(frame, 1024); fb_frame_set_sample_rate(frame, 44100); - fb_frame_set_format(frame, FB_SAMPLE_FMT_FLTP); + fb_frame_set_format(frame, fb_sample_fmt_fltp); fb_frame_set_channel_layout_mask(frame, FB_CH_LAYOUT_STEREO); ASSERT_EQ(fb_frame_get_buffer(frame, 0), 0); @@ -250,13 +250,13 @@ TEST(FFmpegBridgeFrame, CopyProps) // av_frame_copy_props copies metadata properties, not dimensions/format fb_frame_set_pts(src, 777); - fb_frame_set_color_range(src, FB_COLOR_RANGE_JPEG); - fb_frame_set_colorspace(src, FB_COL_SPC_BT709); + fb_frame_set_color_range(src, fb_color_range_jpeg); + fb_frame_set_colorspace(src, fb_col_spc_b_t709); ASSERT_EQ(fb_frame_copy_props(dst, src), 0); EXPECT_EQ(fb_frame_get_pts(dst), 777); - EXPECT_EQ(fb_frame_get_color_range(dst), FB_COLOR_RANGE_JPEG); - EXPECT_EQ(fb_frame_get_colorspace(dst), FB_COL_SPC_BT709); + EXPECT_EQ(fb_frame_get_color_range(dst), fb_color_range_jpeg); + EXPECT_EQ(fb_frame_get_colorspace(dst), fb_col_spc_b_t709); fb_frame_free(&src); fb_frame_free(&dst); @@ -301,7 +301,7 @@ TEST(FFmpegBridgeScaler, RgbaToYuv420P) FBFrame *src = fb_frame_alloc(); fb_frame_set_width(src, width); fb_frame_set_height(src, height); - fb_frame_set_format(src, FB_PIX_FMT_RGBA); + fb_frame_set_format(src, fb_pix_fmt_rgba); ASSERT_EQ(fb_frame_get_buffer(src, 0), 0); // Solid mid-grey image @@ -314,11 +314,11 @@ TEST(FFmpegBridgeScaler, RgbaToYuv420P) FBFrame *dst = fb_frame_alloc(); fb_frame_set_width(dst, width); fb_frame_set_height(dst, height); - fb_frame_set_format(dst, FB_PIX_FMT_YUV420P); + fb_frame_set_format(dst, fb_pix_fmt_yu_v420_p); ASSERT_EQ(fb_frame_get_buffer(dst, 0), 0); - FBScaler *scaler = fb_scaler_create(width, height, FB_PIX_FMT_RGBA, width, - height, FB_PIX_FMT_YUV420P, + FBScaler *scaler = fb_scaler_create(width, height, fb_pix_fmt_rgba, width, + height, fb_pix_fmt_yu_v420_p, FB_SCALER_POINT); ASSERT_NE(scaler, nullptr); // sws_scale returns the output slice height on success @@ -345,10 +345,10 @@ TEST(FFmpegBridgeScaler, RgbaToYuv420P) TEST(FFmpegBridgeScaler, SetColorspace) { - FBScaler *scaler = fb_scaler_create(64, 64, FB_PIX_FMT_YUV420P, 64, 64, - FB_PIX_FMT_RGBA, FB_SCALER_POINT); + FBScaler *scaler = fb_scaler_create(64, 64, fb_pix_fmt_yu_v420_p, 64, 64, + fb_pix_fmt_rgba, FB_SCALER_POINT); ASSERT_NE(scaler, nullptr); - EXPECT_GE(fb_scaler_set_colorspace(scaler, FB_COL_SPC_BT709, 0), 0); + EXPECT_GE(fb_scaler_set_colorspace(scaler, fb_col_spc_b_t709, 0), 0); fb_scaler_free(&scaler); } @@ -357,13 +357,13 @@ TEST(FFmpegBridgeScaler, YuvCoefficients) // Values come from swscale's coefficient tables (sws_getCoefficients / // 65536), which include the studio-range scaling factor. double coeffs[4] = { 0, 0, 0, 0 }; - fb_get_yuv_coefficients(FB_COL_SPC_BT709, coeffs); + fb_get_yuv_coefficients(fb_col_spc_b_t709, coeffs); EXPECT_NEAR(coeffs[0], 117489 / 65536.0, 1e-6); // crv EXPECT_NEAR(coeffs[1], 138438 / 65536.0, 1e-6); // cbu EXPECT_GT(coeffs[2], 0.0); EXPECT_GT(coeffs[3], 0.0); - fb_get_yuv_coefficients(FB_COL_SPC_SMPTE170M, coeffs); + fb_get_yuv_coefficients(fb_col_spc_smpt_e170_m, coeffs); EXPECT_NEAR(coeffs[0], 104597 / 65536.0, 1e-6); // crv } @@ -378,8 +378,8 @@ TEST(FFmpegBridgeResampler, ConvertFltpToS16p) const double rate = 44100.0; FBResampler *resampler = - fb_resampler_create(FB_CH_LAYOUT_STEREO, FB_SAMPLE_FMT_S16P, 44100, - FB_CH_LAYOUT_STEREO, FB_SAMPLE_FMT_FLTP, 44100); + fb_resampler_create(FB_CH_LAYOUT_STEREO, fb_sample_fmt_s16_p, 44100, + FB_CH_LAYOUT_STEREO, fb_sample_fmt_fltp, 44100); ASSERT_NE(resampler, nullptr); const int out_capacity = fb_resampler_get_out_samples(resampler, in_samples); @@ -387,8 +387,8 @@ TEST(FFmpegBridgeResampler, ConvertFltpToS16p) std::vector in_left(in_samples), in_right(in_samples); for (int i = 0; i < in_samples; ++i) { - in_left[i] = 0.5f * std::sin(2.0 * kPi * freq * i / rate); - in_right[i] = 0.5f * std::sin(2.0 * kPi * freq * i / rate); + in_left[i] = 0.5f * std::sin(2.0 * k_pi * freq * i / rate); + in_right[i] = 0.5f * std::sin(2.0 * k_pi * freq * i / rate); } const uint8_t *in_planes[2] = { reinterpret_cast(in_left.data()), @@ -424,14 +424,14 @@ TEST(FFmpegBridgeResampler, ConvertFrameInput) const int in_samples = 512; FBResampler *resampler = - fb_resampler_create(FB_CH_LAYOUT_STEREO, FB_SAMPLE_FMT_S16P, 44100, - FB_CH_LAYOUT_STEREO, FB_SAMPLE_FMT_FLTP, 44100); + fb_resampler_create(FB_CH_LAYOUT_STEREO, fb_sample_fmt_s16_p, 44100, + FB_CH_LAYOUT_STEREO, fb_sample_fmt_fltp, 44100); ASSERT_NE(resampler, nullptr); FBFrame *frame = fb_frame_alloc(); fb_frame_set_nb_samples(frame, in_samples); fb_frame_set_sample_rate(frame, 44100); - fb_frame_set_format(frame, FB_SAMPLE_FMT_FLTP); + fb_frame_set_format(frame, fb_sample_fmt_fltp); fb_frame_set_channel_layout_mask(frame, FB_CH_LAYOUT_STEREO); ASSERT_EQ(fb_frame_get_buffer(frame, 0), 0); @@ -467,7 +467,7 @@ TEST(FFmpegBridgeResampler, ConvertFrameInput) TEST(FFmpegBridgeProbe, DemoMp4Streams) { - const QString path = DemoPath(); + const QString path = demo_path(); ASSERT_TRUE(QFileInfo::exists(path)); FBProbe *probe = fb_probe_create(); @@ -477,14 +477,14 @@ TEST(FFmpegBridgeProbe, DemoMp4Streams) EXPECT_GE(fb_probe_get_stream_count(probe), 1); EXPECT_GT(fb_probe_get_duration(probe), 0); - const int video = FindStream(probe, FB_MEDIA_TYPE_VIDEO); + const int video = find_stream(probe, fb_media_type_video); ASSERT_GE(video, 0); FBStreamInfo info; ASSERT_EQ(fb_probe_get_stream_info(probe, video, &info), 0); EXPECT_EQ(info.width, 1920); EXPECT_EQ(info.height, 1080); - EXPECT_NE(info.pixel_format, FB_PIX_FMT_NONE); + EXPECT_NE(info.pixel_format, fb_pix_fmt_none); EXPECT_EQ(info.has_decoder, 1); EXPECT_GT(info.time_base_den, 0); @@ -500,15 +500,15 @@ TEST(FFmpegBridgeProbe, DemoMp4Streams) TEST(FFmpegBridgeProbe, VideoStreamDetails) { - const QString path = DemoPath(); + const QString path = demo_path(); ASSERT_TRUE(QFileInfo::exists(path)); FBVideoStreamDetails details; ASSERT_EQ(fb_probe_video_stream_details(path.toUtf8().constData(), 0, &details, 0, nullptr, nullptr), 0); - EXPECT_TRUE(details.field_order == FB_FIELD_ORDER_PROGRESSIVE || - details.field_order == FB_FIELD_ORDER_UNKNOWN); + EXPECT_TRUE(details.field_order == fb_field_order_progressive || + details.field_order == fb_field_order_unknown); EXPECT_GT(details.frame_rate_num, 0); EXPECT_GT(details.frame_rate_den, 0); EXPECT_EQ(details.pixel_aspect_num, 1); @@ -518,7 +518,7 @@ TEST(FFmpegBridgeProbe, VideoStreamDetails) TEST(FFmpegBridgeProbe, ReadSubtitleStream) { // Write a small SRT file and read it back through the bridge - const QString path = TempFilePath(QStringLiteral("fb_bridge_test.srt")); + const QString path = temp_file_path(QStringLiteral("fb_bridge_test.srt")); { QFile file(path); ASSERT_TRUE(file.open(QIODevice::WriteOnly | QIODevice::Text)); @@ -555,7 +555,7 @@ TEST(FFmpegBridgeProbe, ReadSubtitleStream) TEST(FFmpegBridgeDecoder, DecodeFirstFrame) { - const QString path = DemoPath(); + const QString path = demo_path(); ASSERT_TRUE(QFileInfo::exists(path)); FBDecoder *decoder = fb_decoder_create(); @@ -566,7 +566,7 @@ TEST(FFmpegBridgeDecoder, DecodeFirstFrame) ASSERT_EQ(fb_decoder_get_stream_info(decoder, &info), 0); EXPECT_EQ(info.width, 1920); EXPECT_EQ(info.height, 1080); - EXPECT_EQ(info.codec_type, FB_MEDIA_TYPE_VIDEO); + EXPECT_EQ(info.codec_type, fb_media_type_video); EXPECT_GT(fb_decoder_get_format_duration(decoder), 0); FBPacket *packet = fb_packet_alloc(); @@ -582,7 +582,7 @@ TEST(FFmpegBridgeDecoder, DecodeFirstFrame) EXPECT_EQ(fb_frame_get_width(frame), 1920); EXPECT_EQ(fb_frame_get_height(frame), 1080); - EXPECT_NE(fb_frame_get_format(frame), FB_PIX_FMT_NONE); + EXPECT_NE(fb_frame_get_format(frame), fb_pix_fmt_none); // Software frames must have CPU-accessible data. Hardware frames live in // device memory, so their data is checked after the transfer below. if (!fb_frame_is_hw(frame)) { @@ -641,7 +641,7 @@ TEST(FFmpegBridgeDecoder, OpenFailure) TEST(FFmpegBridgeDecoder, GuessRates) { - const QString path = DemoPath(); + const QString path = demo_path(); ASSERT_TRUE(QFileInfo::exists(path)); FBDecoder *decoder = fb_decoder_create(); @@ -669,11 +669,11 @@ TEST(FFmpegBridgeAudioGraph, TempoProcessing) FBAudioGraphConfig config = {}; config.in_sample_rate = 44100; config.in_channel_layout_mask = FB_CH_LAYOUT_STEREO; - config.in_sample_format = FB_SAMPLE_FMT_FLTP; + config.in_sample_format = fb_sample_fmt_fltp; config.in_channels = 2; config.out_sample_rate = 44100; config.out_channel_layout_mask = FB_CH_LAYOUT_STEREO; - config.out_sample_format = FB_SAMPLE_FMT_FLTP; + config.out_sample_format = fb_sample_fmt_fltp; config.out_channels = 2; config.out_is_planar = 1; config.tempo = 2.0; @@ -721,18 +721,18 @@ TEST(FFmpegBridgeEncoder, CodecFormatLists) // PNG is a native FFmpeg encoder and always available const char *names[16]; const int pix_count = - fb_encoder_codec_get_pixel_formats(FB_CODEC_PNG, names, 16); + fb_encoder_codec_get_pixel_formats(fb_codec_png, names, 16); EXPECT_GT(pix_count, 0); int fmts[16]; const int sample_count = - fb_encoder_codec_get_sample_formats(FB_CODEC_AAC, fmts, 16); + fb_encoder_codec_get_sample_formats(fb_codec_aac, fmts, 16); EXPECT_GT(sample_count, 0); } TEST(FFmpegBridgeEncoder, WritePngVideoAndProbeBack) { - const QString path = TempFilePath(QStringLiteral("fb_bridge_test.mkv")); + const QString path = temp_file_path(QStringLiteral("fb_bridge_test.mkv")); QFile::remove(path); const int width = 64; @@ -744,7 +744,7 @@ TEST(FFmpegBridgeEncoder, WritePngVideoAndProbeBack) FBEncoderConfig config = {}; config.filename = filename.constData(); config.video_enabled = 1; - config.video_codec = FB_CODEC_PNG; + config.video_codec = fb_codec_png; config.video_width = width; config.video_height = height; config.video_pixel_aspect_num = 1; @@ -754,9 +754,9 @@ TEST(FFmpegBridgeEncoder, WritePngVideoAndProbeBack) config.video_frame_rate_num = 30; config.video_frame_rate_den = 1; config.video_pix_fmt = "rgba"; - config.video_src_pix_fmt = FB_PIX_FMT_RGBA; - config.video_color_range = FB_COLOR_RANGE_UNSPEC; - config.video_field_order = FB_FIELD_ORDER_PROGRESSIVE; + config.video_src_pix_fmt = fb_pix_fmt_rgba; + config.video_color_range = fb_color_range_unspec; + config.video_field_order = fb_field_order_progressive; config.video_threads = 1; FBEncoder *encoder = fb_encoder_create(&config); @@ -773,7 +773,7 @@ TEST(FFmpegBridgeEncoder, WritePngVideoAndProbeBack) pixels[i * 4 + 3] = 255; // A } ASSERT_EQ(fb_encoder_write_video_frame(encoder, width, height, - FB_PIX_FMT_RGBA, pixels.data(), + fb_pix_fmt_rgba, pixels.data(), width * 4, f / 30.0), 0) << "encoder error: " << fb_encoder_get_error(encoder); @@ -787,7 +787,7 @@ TEST(FFmpegBridgeEncoder, WritePngVideoAndProbeBack) FBProbe *probe = fb_probe_create(); ASSERT_EQ(fb_probe_open(probe, path.toUtf8().constData()), 0); - const int video = FindStream(probe, FB_MEDIA_TYPE_VIDEO); + const int video = find_stream(probe, fb_media_type_video); ASSERT_GE(video, 0); FBStreamInfo info; @@ -802,7 +802,7 @@ TEST(FFmpegBridgeEncoder, WritePngVideoAndProbeBack) TEST(FFmpegBridgeEncoder, WritePcmAudioAndProbeBack) { - const QString path = TempFilePath(QStringLiteral("fb_bridge_test.wav")); + const QString path = temp_file_path(QStringLiteral("fb_bridge_test.wav")); QFile::remove(path); const QByteArray filename = path.toUtf8(); @@ -810,10 +810,10 @@ TEST(FFmpegBridgeEncoder, WritePcmAudioAndProbeBack) FBEncoderConfig config = {}; config.filename = filename.constData(); config.audio_enabled = 1; - config.audio_codec = FB_CODEC_PCM; + config.audio_codec = fb_codec_pcm; config.audio_sample_rate = 44100; config.audio_channel_layout_mask = FB_CH_LAYOUT_STEREO; - config.audio_sample_format = FB_SAMPLE_FMT_S16; + config.audio_sample_format = fb_sample_fmt_s16; FBEncoder *encoder = fb_encoder_create(&config); ASSERT_NE(encoder, nullptr); @@ -824,7 +824,7 @@ TEST(FFmpegBridgeEncoder, WritePcmAudioAndProbeBack) std::vector left(sample_count), right(sample_count); for (int i = 0; i < sample_count; ++i) { left[i] = static_cast( - 10000 * std::sin(2.0 * kPi * 440.0 * i / 44100.0)); + 10000 * std::sin(2.0 * k_pi * 440.0 * i / 44100.0)); right[i] = left[i]; } const uint8_t *planes[2] = { @@ -832,13 +832,13 @@ TEST(FFmpegBridgeEncoder, WritePcmAudioAndProbeBack) reinterpret_cast(right.data()) }; - ASSERT_EQ(fb_encoder_write_audio(encoder, planes, 2, FB_SAMPLE_FMT_S16P, + ASSERT_EQ(fb_encoder_write_audio(encoder, planes, 2, fb_sample_fmt_s16_p, 44100, FB_CH_LAYOUT_STEREO, sample_count), 0) << "encoder error: " << fb_encoder_get_error(encoder); // Flush - EXPECT_EQ(fb_encoder_write_audio(encoder, nullptr, 2, FB_SAMPLE_FMT_S16P, + EXPECT_EQ(fb_encoder_write_audio(encoder, nullptr, 2, fb_sample_fmt_s16_p, 44100, FB_CH_LAYOUT_STEREO, 0), 0); @@ -849,7 +849,7 @@ TEST(FFmpegBridgeEncoder, WritePcmAudioAndProbeBack) FBProbe *probe = fb_probe_create(); ASSERT_EQ(fb_probe_open(probe, path.toUtf8().constData()), 0); - const int audio = FindStream(probe, FB_MEDIA_TYPE_AUDIO); + const int audio = find_stream(probe, fb_media_type_audio); ASSERT_GE(audio, 0); FBStreamInfo info; diff --git a/tests/gtest/ffmpeg_decoder_hw_test.cpp b/tests/gtest/ffmpeg_decoder_hw_test.cpp index 485179578..dff481298 100644 --- a/tests/gtest/ffmpeg_decoder_hw_test.cpp +++ b/tests/gtest/ffmpeg_decoder_hw_test.cpp @@ -23,20 +23,20 @@ TEST(FFmpegDecoderHW, H264_422_10bit_CPUFrame_IsNotBlack) GTEST_SKIP() << "Test footage not available: " << path.toStdString(); } - DecoderPtr decoder = Decoder::CreateFromID(QStringLiteral("ffmpeg")); + DecoderPtr decoder = Decoder::create_from_id(QStringLiteral("ffmpeg")); ASSERT_TRUE(decoder); Footage footage(path); - ASSERT_TRUE(footage.IsValid()); + ASSERT_TRUE(footage.is_valid()); - Decoder::CodecStream stream(path, footage.GetStreamIndex(Track::kVideo, 0), + Decoder::CodecStream stream(path, footage.get_stream_index(Track::k_video, 0), nullptr); - ASSERT_TRUE(decoder->Open(stream)); + ASSERT_TRUE(decoder->open(stream)); Decoder::RetrieveVideoParams params; - params.time = rational(0); - params.maximum_format = PixelFormat::U16; - FramePtr frame = decoder->RetrieveVideoFrame(params); + params.time = Rational(0); + params.maximum_format = PixelFormat::u16; + FramePtr frame = decoder->retrieve_video_frame(params); ASSERT_TRUE(frame); ASSERT_TRUE(frame->is_allocated()); @@ -47,7 +47,7 @@ TEST(FFmpegDecoderHW, H264_422_10bit_CPUFrame_IsNotBlack) double avg = 0.0; int samples = 0; - const int bpc = VideoParams::GetBytesPerChannel(frame->format()); + const int bpc = VideoParams::get_bytes_per_channel(frame->format()); const int stride = frame->linesize_bytes(); for (int y = 0; y < height && y < 1080; y += 120) { for (int x = 0; x < width && x < 1920; x += 240) { diff --git a/tests/gtest/footage_probe_test.cpp b/tests/gtest/footage_probe_test.cpp index 5aa4c1d8b..2a78bcdda 100644 --- a/tests/gtest/footage_probe_test.cpp +++ b/tests/gtest/footage_probe_test.cpp @@ -26,70 +26,70 @@ namespace { -QString DemoVideoPath() +QString demo_video_path() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/demo.mp4")); } -QString TestImagePath() +QString test_image_path() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/img.png")); } // Mirrors the cache path expression used by Footage::Reprobe() -QString MetadataCacheFileFor(const QString &media_path) +QString metadata_cache_file_for(const QString &media_path) { return QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) - .filePath(olive::FileFunctions::GetUniqueFileIdentifier(media_path)); + .filePath(olive::FileFunctions::get_unique_file_identifier(media_path)); } } // namespace TEST(FootageProbe, FFmpegProbeOfDemoMp4ReportsExpectedStreams) { - const QString path = DemoVideoPath(); + const QString path = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(path)); olive::DecoderPtr decoder = - olive::Decoder::CreateFromID(QStringLiteral("ffmpeg")); + olive::Decoder::create_from_id(QStringLiteral("ffmpeg")); ASSERT_TRUE(decoder); - const olive::FootageDescription desc = decoder->Probe(path, nullptr); - ASSERT_TRUE(desc.IsValid()); + const olive::FootageDescription desc = decoder->probe(path, nullptr); + ASSERT_TRUE(desc.is_valid()); EXPECT_EQ(desc.decoder(), QStringLiteral("ffmpeg")); // The file holds video + audio + a timecode data track. The data track is // counted in the total but not exposed as a usable stream. - ASSERT_EQ(desc.GetVideoStreams().size(), 1); - ASSERT_EQ(desc.GetAudioStreams().size(), 1); - EXPECT_EQ(desc.GetSubtitleStreams().size(), 0); - EXPECT_EQ(desc.GetStreamCount(), 3); + ASSERT_EQ(desc.get_video_streams().size(), 1); + ASSERT_EQ(desc.get_audio_streams().size(), 1); + EXPECT_EQ(desc.get_subtitle_streams().size(), 0); + EXPECT_EQ(desc.get_stream_count(), 3); - const olive::VideoParams &video = desc.GetVideoStreams().first(); + const olive::VideoParams &video = desc.get_video_streams().first(); EXPECT_EQ(video.stream_index(), 0); EXPECT_EQ(video.width(), 1920); EXPECT_EQ(video.height(), 1080); - EXPECT_EQ(video.video_type(), olive::VideoParams::kVideoTypeVideo); - EXPECT_EQ(video.interlacing(), olive::VideoParams::kInterlaceNone); - EXPECT_EQ(video.pixel_aspect_ratio(), olive::rational(1, 1)); - EXPECT_EQ(video.frame_rate(), olive::rational(25)); - EXPECT_EQ(video.time_base(), olive::rational(1, 12800)); + EXPECT_EQ(video.video_type(), olive::VideoParams::k_video_type_video); + EXPECT_EQ(video.interlacing(), olive::VideoParams::k_interlace_none); + EXPECT_EQ(video.pixel_aspect_ratio(), olive::Rational(1, 1)); + EXPECT_EQ(video.frame_rate(), olive::Rational(25)); + EXPECT_EQ(video.time_base(), olive::Rational(1, 12800)); EXPECT_EQ(video.duration(), 217600); // 17 seconds at 1/12800 - EXPECT_NE(video.format(), olive::core::PixelFormat::INVALID); + EXPECT_NE(video.format(), olive::core::PixelFormat::invalid); EXPECT_GT(video.channel_count(), 0); - const olive::core::AudioParams &audio = desc.GetAudioStreams().first(); + const olive::core::AudioParams &audio = desc.get_audio_streams().first(); EXPECT_EQ(audio.stream_index(), 1); EXPECT_EQ(audio.sample_rate(), 48000); EXPECT_EQ(audio.channel_count(), 2); - EXPECT_EQ(audio.time_base(), olive::rational(1, 48000)); + EXPECT_EQ(audio.time_base(), olive::Rational(1, 48000)); EXPECT_EQ(audio.duration(), 816000); // 17 seconds at 1/48000 // The file's timecode track starts at 01:00:00:00 - ASSERT_TRUE(desc.HasSourceStartTime()); - EXPECT_EQ(desc.source_start_time(), olive::rational(3600)); + ASSERT_TRUE(desc.has_source_start_time()); + EXPECT_EQ(desc.source_start_time(), olive::Rational(3600)); EXPECT_EQ(desc.source_start_time_source(), QStringLiteral("timecode")); } @@ -107,8 +107,8 @@ TEST(FootageProbe, ProbeOfUnprobeableFileYieldsInvalidDescription) } for (const olive::DecoderPtr &decoder : - olive::Decoder::ReceiveListOfAllDecoders()) { - EXPECT_FALSE(decoder->Probe(path, nullptr).IsValid()) + olive::Decoder::receive_list_of_all_decoders()) { + EXPECT_FALSE(decoder->probe(path, nullptr).is_valid()) << decoder->id().toStdString(); } } @@ -126,7 +126,7 @@ protected: // the DiskManager singleton created_disk_manager_ = (olive::DiskManager::instance() == nullptr); if (created_disk_manager_) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } // Sandbox the footage metadata cache so real probes write into the @@ -138,17 +138,17 @@ protected: QDir().mkpath( QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override { project_.reset(); if (created_disk_manager_) { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } if (had_cache_home_) { qputenv("XDG_CACHE_HOME", old_cache_home_); @@ -159,7 +159,7 @@ protected: // Constructs a Footage pointing at path; the constructor's set_filename() // call probes the file synchronously before the node joins the graph - olive::Footage *AddProbedFootage(const QString &path) + olive::Footage *add_probed_footage(const QString &path) { auto *footage = new olive::Footage(path); footage->setParent(project_.get()); @@ -175,52 +175,52 @@ protected: TEST_F(FootageProbeTest, ProbingDemoMp4PopulatesFootageState) { - const QString path = DemoVideoPath(); + const QString path = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(path)); - olive::Footage *footage = AddProbedFootage(path); + olive::Footage *footage = add_probed_footage(path); - EXPECT_TRUE(footage->IsValid()); + EXPECT_TRUE(footage->is_valid()); EXPECT_EQ(footage->decoder(), QStringLiteral("ffmpeg")); EXPECT_EQ(footage->timestamp(), QFileInfo(path).lastModified().toMSecsSinceEpoch()); // Video + audio streams are usable; the timecode data track only shows up // in the total stream count - EXPECT_EQ(footage->GetTotalStreamCount(), 3); - EXPECT_EQ(footage->GetVideoStreamCount(), 1); - EXPECT_EQ(footage->GetAudioStreamCount(), 1); - EXPECT_EQ(footage->GetSubtitleStreamCount(), 0); + EXPECT_EQ(footage->get_total_stream_count(), 3); + EXPECT_EQ(footage->get_video_stream_count(), 1); + EXPECT_EQ(footage->get_audio_stream_count(), 1); + EXPECT_EQ(footage->get_subtitle_stream_count(), 0); - EXPECT_EQ(footage->GetStreamIndex(olive::Track::kVideo, 0), 0); - EXPECT_EQ(footage->GetStreamIndex(olive::Track::kAudio, 0), 1); - EXPECT_EQ(footage->GetReferenceFromRealIndex(0), - olive::Track::Reference(olive::Track::kVideo, 0)); - EXPECT_EQ(footage->GetReferenceFromRealIndex(1), - olive::Track::Reference(olive::Track::kAudio, 0)); - EXPECT_EQ(footage->GetReferenceFromRealIndex(2).type(), - olive::Track::kNone); + EXPECT_EQ(footage->get_stream_index(olive::Track::k_video, 0), 0); + EXPECT_EQ(footage->get_stream_index(olive::Track::k_audio, 0), 1); + EXPECT_EQ(footage->get_reference_from_real_index(0), + olive::Track::Reference(olive::Track::k_video, 0)); + EXPECT_EQ(footage->get_reference_from_real_index(1), + olive::Track::Reference(olive::Track::k_audio, 0)); + EXPECT_EQ(footage->get_reference_from_real_index(2).type(), + olive::Track::k_none); - EXPECT_EQ(footage->GetConnectedTextureOutput(), + EXPECT_EQ(footage->get_connected_texture_output(), static_cast(footage)); - EXPECT_EQ(footage->GetConnectedSampleOutput(), + EXPECT_EQ(footage->get_connected_sample_output(), static_cast(footage)); - const olive::VideoParams video = footage->GetVideoParams(0); + const olive::VideoParams video = footage->get_video_params(0); ASSERT_TRUE(video.is_valid()); EXPECT_EQ(video.stream_index(), 0); EXPECT_EQ(video.width(), 1920); EXPECT_EQ(video.height(), 1080); - EXPECT_EQ(video.video_type(), olive::VideoParams::kVideoTypeVideo); - EXPECT_EQ(video.frame_rate(), olive::rational(25)); - EXPECT_EQ(video.time_base(), olive::rational(1, 12800)); + EXPECT_EQ(video.video_type(), olive::VideoParams::k_video_type_video); + EXPECT_EQ(video.frame_rate(), olive::Rational(25)); + EXPECT_EQ(video.time_base(), olive::Rational(1, 12800)); EXPECT_EQ(video.duration(), 217600); - EXPECT_EQ(video.color_range(), olive::VideoParams::kColorRangeLimited); + EXPECT_EQ(video.color_range(), olive::VideoParams::k_color_range_limited); EXPECT_TRUE(video.enabled()); // The FFmpeg probe leaves colorspace unset so the project default applies EXPECT_TRUE(video.colorspace().isEmpty()); - const olive::core::AudioParams audio = footage->GetAudioParams(0); + const olive::core::AudioParams audio = footage->get_audio_params(0); ASSERT_TRUE(audio.is_valid()); EXPECT_EQ(audio.stream_index(), 1); EXPECT_EQ(audio.sample_rate(), 48000); @@ -231,103 +231,103 @@ TEST_F(FootageProbeTest, ProbingDemoMp4PopulatesFootageState) TEST_F(FootageProbeTest, ProbingDemoMp4SetsLengthsAndSourceStartTime) { - const QString path = DemoVideoPath(); + const QString path = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(path)); - olive::Footage *footage = AddProbedFootage(path); - footage->VerifyLength(); + olive::Footage *footage = add_probed_footage(path); + footage->verify_length(); // Both streams describe 17 seconds of media - EXPECT_EQ(footage->GetVideoLength(), olive::rational(17)); - EXPECT_EQ(footage->GetAudioLength(), olive::rational(17)); - EXPECT_EQ(footage->GetLength(), olive::rational(17)); + EXPECT_EQ(footage->get_video_length(), olive::Rational(17)); + EXPECT_EQ(footage->get_audio_length(), olive::Rational(17)); + EXPECT_EQ(footage->get_length(), olive::Rational(17)); // The embedded 01:00:00:00 timecode becomes the source start time - ASSERT_TRUE(footage->HasSourceStartTime()); - EXPECT_EQ(footage->source_start_time(), olive::rational(3600)); + ASSERT_TRUE(footage->has_source_start_time()); + EXPECT_EQ(footage->source_start_time(), olive::Rational(3600)); EXPECT_EQ(footage->source_start_time_source(), QStringLiteral("timecode")); } TEST_F(FootageProbeTest, ProbingPngImageProducesSingleStillStream) { - const QString path = TestImagePath(); + const QString path = test_image_path(); ASSERT_TRUE(QFileInfo::exists(path)); - olive::Footage *footage = AddProbedFootage(path); + olive::Footage *footage = add_probed_footage(path); - EXPECT_TRUE(footage->IsValid()); + EXPECT_TRUE(footage->is_valid()); // Still images are handled by the OIIO decoder, which probes before FFmpeg EXPECT_EQ(footage->decoder(), QStringLiteral("oiio")); - EXPECT_EQ(footage->GetTotalStreamCount(), 1); - EXPECT_EQ(footage->GetVideoStreamCount(), 1); - EXPECT_EQ(footage->GetAudioStreamCount(), 0); - EXPECT_EQ(footage->GetSubtitleStreamCount(), 0); + EXPECT_EQ(footage->get_total_stream_count(), 1); + EXPECT_EQ(footage->get_video_stream_count(), 1); + EXPECT_EQ(footage->get_audio_stream_count(), 0); + EXPECT_EQ(footage->get_subtitle_stream_count(), 0); - const olive::VideoParams still = footage->GetVideoParams(0); + const olive::VideoParams still = footage->get_video_params(0); ASSERT_TRUE(still.is_valid()); EXPECT_EQ(still.stream_index(), 0); EXPECT_EQ(still.width(), 1920); EXPECT_EQ(still.height(), 1080); - EXPECT_EQ(still.video_type(), olive::VideoParams::kVideoTypeStill); + EXPECT_EQ(still.video_type(), olive::VideoParams::k_video_type_still); EXPECT_EQ(still.channel_count(), 4); - EXPECT_EQ(still.format(), olive::core::PixelFormat::U8); + EXPECT_EQ(still.format(), olive::core::PixelFormat::u8); EXPECT_TRUE(still.premultiplied_alpha()); EXPECT_TRUE(still.enabled()); EXPECT_TRUE(still.colorspace().isEmpty()); // Stills have no duration and no source start time - footage->VerifyLength(); - EXPECT_EQ(footage->GetVideoLength(), olive::rational(0)); - EXPECT_EQ(footage->GetLength(), olive::rational(0)); - EXPECT_FALSE(footage->HasSourceStartTime()); + footage->verify_length(); + EXPECT_EQ(footage->get_video_length(), olive::Rational(0)); + EXPECT_EQ(footage->get_length(), olive::Rational(0)); + EXPECT_FALSE(footage->has_source_start_time()); - EXPECT_EQ(footage->GetConnectedTextureOutput(), + EXPECT_EQ(footage->get_connected_texture_output(), static_cast(footage)); - EXPECT_EQ(footage->GetConnectedSampleOutput(), nullptr); + EXPECT_EQ(footage->get_connected_sample_output(), nullptr); } TEST_F(FootageProbeTest, ProbedFootageValuePushesRealStreamJobs) { - const QString path = DemoVideoPath(); + const QString path = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(path)); - olive::Footage *footage = AddProbedFootage(path); - footage->VerifyLength(); + olive::Footage *footage = add_probed_footage(path); + footage->verify_length(); // The colorspace fallback reads the project default, and the audio cache // path comes from the project's cache settings - project_->SetDefaultInputColorSpace(QStringLiteral("ProbeInputSpace")); - project_->SetCacheLocationSetting(olive::Project::kCacheCustomPath); + project_->set_default_input_color_space(QStringLiteral("ProbeInputSpace")); + project_->set_cache_location_setting(olive::Project::k_cache_custom_path); const QString cache_path = QDir(temp_dir_.path()).filePath(QStringLiteral("cache")); - project_->SetCustomCachePath(cache_path); + project_->set_custom_cache_path(cache_path); olive::NodeValueRow row; - row.insert(olive::Footage::kFilenameInput, - olive::NodeValue(olive::NodeValue::kFile, path)); + row.insert(olive::Footage::k_filename_input, + olive::NodeValue(olive::NodeValue::k_file, path)); - olive::VideoParams vparams(64, 64, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams vparams(64, 64, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); const olive::NodeGlobals globals(vparams, olive::core::AudioParams(), - olive::rational(0), - olive::LoopMode::kLoopModeOff); + olive::Rational(0), + olive::LoopMode::k_loop_mode_off); olive::NodeValueTable table; - footage->Value(row, globals, &table); + footage->value(row, globals, &table); // Length, one texture job for the video stream, one sample job for the // audio stream; the timecode data track produces no job - ASSERT_EQ(table.Count(), 3); + ASSERT_EQ(table.count(), 3); const olive::NodeValue length = - table.Get(olive::NodeValue::kRational, QStringLiteral("length")); - ASSERT_EQ(length.type(), olive::NodeValue::kRational); - EXPECT_EQ(length.toRational(), olive::rational(17)); + table.get(olive::NodeValue::k_rational, QStringLiteral("length")); + ASSERT_EQ(length.type(), olive::NodeValue::k_rational); + EXPECT_EQ(length.to_rational(), olive::Rational(17)); const olive::TexturePtr texture = - table.Get(olive::NodeValue::kTexture, QStringLiteral("v:0")) - .toTexture(); + table.get(olive::NodeValue::k_texture, QStringLiteral("v:0")) + .to_texture(); ASSERT_NE(texture, nullptr); EXPECT_EQ(texture->params().width(), 1920); EXPECT_EQ(texture->params().height(), 1080); @@ -340,44 +340,44 @@ TEST_F(FootageProbeTest, ProbedFootageValuePushesRealStreamJobs) ASSERT_NE(video_job, nullptr); EXPECT_EQ(video_job->decoder(), QStringLiteral("ffmpeg")); EXPECT_EQ(video_job->filename(), path); - EXPECT_EQ(video_job->type(), olive::Track::kVideo); - EXPECT_EQ(video_job->length(), olive::rational(17)); + EXPECT_EQ(video_job->type(), olive::Track::k_video); + EXPECT_EQ(video_job->length(), olive::Rational(17)); const olive::FootageJob audio_job = - table.Get(olive::NodeValue::kSamples, QStringLiteral("a:0")) + table.get(olive::NodeValue::k_samples, QStringLiteral("a:0")) .data() .value(); EXPECT_EQ(audio_job.decoder(), QStringLiteral("ffmpeg")); EXPECT_EQ(audio_job.filename(), path); - EXPECT_EQ(audio_job.type(), olive::Track::kAudio); + EXPECT_EQ(audio_job.type(), olive::Track::k_audio); EXPECT_EQ(audio_job.audio_params().sample_rate(), 48000); - EXPECT_EQ(audio_job.length(), olive::rational(17)); + EXPECT_EQ(audio_job.length(), olive::Rational(17)); EXPECT_EQ(audio_job.cache_path(), cache_path); } TEST_F(FootageProbeTest, SecondProbeReadsBackMetadataCache) { - const QString path = DemoVideoPath(); + const QString path = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(path)); - olive::Footage *first = AddProbedFootage(path); - ASSERT_TRUE(first->IsValid()); + olive::Footage *first = add_probed_footage(path); + ASSERT_TRUE(first->is_valid()); // The first probe writes a stream metadata cache into the cache location - const QString cache_file = MetadataCacheFileFor(path); + const QString cache_file = metadata_cache_file_for(path); ASSERT_TRUE(QFileInfo::exists(cache_file)); // A second footage for the same file loads its metadata from that cache // and ends up with identical state - olive::Footage *second = AddProbedFootage(path); - ASSERT_TRUE(second->IsValid()); + olive::Footage *second = add_probed_footage(path); + ASSERT_TRUE(second->is_valid()); EXPECT_EQ(second->decoder(), first->decoder()); - EXPECT_EQ(second->GetTotalStreamCount(), first->GetTotalStreamCount()); - EXPECT_EQ(second->GetVideoStreamCount(), first->GetVideoStreamCount()); - EXPECT_EQ(second->GetAudioStreamCount(), first->GetAudioStreamCount()); + EXPECT_EQ(second->get_total_stream_count(), first->get_total_stream_count()); + EXPECT_EQ(second->get_video_stream_count(), first->get_video_stream_count()); + EXPECT_EQ(second->get_audio_stream_count(), first->get_audio_stream_count()); - const olive::VideoParams from_cache = second->GetVideoParams(0); - const olive::VideoParams probed = first->GetVideoParams(0); + const olive::VideoParams from_cache = second->get_video_params(0); + const olive::VideoParams probed = first->get_video_params(0); EXPECT_EQ(from_cache.stream_index(), probed.stream_index()); EXPECT_EQ(from_cache.width(), probed.width()); EXPECT_EQ(from_cache.height(), probed.height()); @@ -386,37 +386,37 @@ TEST_F(FootageProbeTest, SecondProbeReadsBackMetadataCache) EXPECT_EQ(from_cache.duration(), probed.duration()); EXPECT_EQ(from_cache.video_type(), probed.video_type()); - ASSERT_TRUE(second->HasSourceStartTime()); - EXPECT_EQ(second->source_start_time(), olive::rational(3600)); + ASSERT_TRUE(second->has_source_start_time()); + EXPECT_EQ(second->source_start_time(), olive::Rational(3600)); EXPECT_EQ(second->source_start_time_source(), QStringLiteral("timecode")); } TEST_F(FootageProbeTest, FilenameChangeToMissingFileClearsProbeState) { - const QString path = DemoVideoPath(); + const QString path = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(path)); - olive::Footage *footage = AddProbedFootage(path); - ASSERT_TRUE(footage->IsValid()); - ASSERT_GT(footage->GetTotalStreamCount(), 0); + olive::Footage *footage = add_probed_footage(path); + ASSERT_TRUE(footage->is_valid()); + ASSERT_GT(footage->get_total_stream_count(), 0); // Pointing the footage at a nonexistent file clears the probed state and // the re-probe fails footage->set_filename( QDir(temp_dir_.path()).filePath(QStringLiteral("gone.mp4"))); - EXPECT_FALSE(footage->IsValid()); - EXPECT_EQ(footage->GetTotalStreamCount(), 0); - EXPECT_EQ(footage->GetVideoStreamCount(), 0); - EXPECT_EQ(footage->GetAudioStreamCount(), 0); + EXPECT_FALSE(footage->is_valid()); + EXPECT_EQ(footage->get_total_stream_count(), 0); + EXPECT_EQ(footage->get_video_stream_count(), 0); + EXPECT_EQ(footage->get_audio_stream_count(), 0); EXPECT_TRUE(footage->decoder().isEmpty()); EXPECT_EQ(footage->timestamp(), 0); - EXPECT_FALSE(footage->HasSourceStartTime()); + EXPECT_FALSE(footage->has_source_start_time()); } TEST_F(FootageProbeTest, CheckFootageOnlyRespondsWithActiveWindow) { - const QString path = TestImagePath(); + const QString path = test_image_path(); ASSERT_TRUE(QFileInfo::exists(path)); // Work on a copy so the original test asset is untouched @@ -424,8 +424,8 @@ TEST_F(FootageProbeTest, CheckFootageOnlyRespondsWithActiveWindow) QDir(temp_dir_.path()).filePath(QStringLiteral("image.png")); ASSERT_TRUE(QFile::copy(path, copy)); - olive::Footage *footage = AddProbedFootage(copy); - ASSERT_TRUE(footage->IsValid()); + olive::Footage *footage = add_probed_footage(copy); + ASSERT_TRUE(footage->is_valid()); const qint64 probed_timestamp = footage->timestamp(); ASSERT_GT(probed_timestamp, 0); @@ -434,9 +434,9 @@ TEST_F(FootageProbeTest, CheckFootageOnlyRespondsWithActiveWindow) // Without an active window, CheckFootage is a no-op ASSERT_TRUE( - QMetaObject::invokeMethod(footage, "CheckFootage", Qt::DirectConnection)); + QMetaObject::invokeMethod(footage, "check_footage", Qt::DirectConnection)); EXPECT_EQ(footage->timestamp(), probed_timestamp); - EXPECT_TRUE(footage->IsValid()); + EXPECT_TRUE(footage->is_valid()); // With an active window, CheckFootage notices the missing file and // re-probes. The re-probe clears the existing state first, and since the @@ -448,14 +448,14 @@ TEST_F(FootageProbeTest, CheckFootageOnlyRespondsWithActiveWindow) QCoreApplication::processEvents(); ASSERT_EQ(qApp->activeWindow(), &window); - ASSERT_TRUE(QMetaObject::invokeMethod(footage, "CheckFootage", + ASSERT_TRUE(QMetaObject::invokeMethod(footage, "check_footage", Qt::DirectConnection)); } ASSERT_EQ(qApp->activeWindow(), nullptr); EXPECT_EQ(footage->timestamp(), 0); - EXPECT_FALSE(footage->IsValid()); - EXPECT_EQ(footage->GetVideoStreamCount(), 0); + EXPECT_FALSE(footage->is_valid()); + EXPECT_EQ(footage->get_video_stream_count(), 0); } TEST_F(FootageProbeTest, ProbingExistingButInvalidMediaStaysInvalid) @@ -468,18 +468,18 @@ TEST_F(FootageProbeTest, ProbingExistingButInvalidMediaStaysInvalid) file.write("OAK_FAKE_MEDIA"); } - olive::Footage *footage = AddProbedFootage(path); + olive::Footage *footage = add_probed_footage(path); // The file exists but no decoder can probe it, so the footage stays // invalid - EXPECT_FALSE(footage->IsValid()); + EXPECT_FALSE(footage->is_valid()); EXPECT_TRUE(footage->decoder().isEmpty()); - EXPECT_EQ(footage->GetTotalStreamCount(), 0); - EXPECT_EQ(footage->GetVideoStreamCount(), 0); - EXPECT_EQ(footage->GetAudioStreamCount(), 0); - EXPECT_EQ(footage->GetSubtitleStreamCount(), 0); + EXPECT_EQ(footage->get_total_stream_count(), 0); + EXPECT_EQ(footage->get_video_stream_count(), 0); + EXPECT_EQ(footage->get_audio_stream_count(), 0); + EXPECT_EQ(footage->get_subtitle_stream_count(), 0); // A failed probe is not written to the metadata cache, so future reprobes // of the same path probe again instead of reloading an invalid description - EXPECT_FALSE(QFileInfo::exists(MetadataCacheFileFor(path))); + EXPECT_FALSE(QFileInfo::exists(metadata_cache_file_for(path))); } diff --git a/tests/gtest/footage_test.cpp b/tests/gtest/footage_test.cpp index af508e19d..3b11e1702 100644 --- a/tests/gtest/footage_test.cpp +++ b/tests/gtest/footage_test.cpp @@ -30,8 +30,8 @@ namespace // so tests can populate streams without probing real media class TestableFootage : public olive::Footage { public: - using olive::ViewerOutput::AddStream; - using olive::ViewerOutput::SetStream; + using olive::ViewerOutput::add_stream; + using olive::ViewerOutput::set_stream; }; // Temporarily overrides an environment variable, restoring the previous state @@ -62,57 +62,57 @@ private: bool had_value_; }; -olive::VideoParams MakeVideoStream(int stream_index) +olive::VideoParams make_video_stream(int stream_index) { - olive::VideoParams params(1920, 1080, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams params(1920, 1080, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); params.set_stream_index(stream_index); params.set_duration(48); // 2 seconds at 24 fps return params; } -olive::core::AudioParams MakeAudioStream(int stream_index) +olive::core::AudioParams make_audio_stream(int stream_index) { - olive::core::AudioParams params(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + olive::core::AudioParams params(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); params.set_stream_index(stream_index); params.set_duration(96000); // 2 seconds at 48 kHz return params; } -olive::SubtitleParams MakeSubtitleStream(int stream_index) +olive::SubtitleParams make_subtitle_stream(int stream_index) { olive::SubtitleParams params; params.set_stream_index(stream_index); params.push_back(olive::Subtitle( - olive::TimeRange(olive::rational(0), olive::rational(3)), + olive::TimeRange(olive::Rational(0), olive::Rational(3)), QStringLiteral("subtitle text"))); return params; } // Two video streams (one with an explicit colorspace, one without) and one // audio stream, reported as three source streams in total -olive::FootageDescription MakeStandardDescription() +olive::FootageDescription make_standard_description() { olive::FootageDescription desc(QStringLiteral("fakedecoder")); - olive::VideoParams video0 = MakeVideoStream(0); - desc.AddVideoStream(video0); + olive::VideoParams video0 = make_video_stream(0); + desc.add_video_stream(video0); - olive::VideoParams video1(1280, 720, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams video1(1280, 720, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); video1.set_stream_index(1); video1.set_duration(48); video1.set_colorspace(QStringLiteral("ExplicitSpace")); - desc.AddVideoStream(video1); + desc.add_video_stream(video1); - desc.AddAudioStream(MakeAudioStream(2)); + desc.add_audio_stream(make_audio_stream(2)); - desc.SetStreamCount(3); + desc.set_stream_count(3); return desc; } -QString CreateFakeMediaFile(QTemporaryDir &dir, const QString &name) +QString create_fake_media_file(QTemporaryDir &dir, const QString &name) { const QString path = QDir(dir.path()).filePath(name); QFile file(path); @@ -129,7 +129,7 @@ QString CreateFakeMediaFile(QTemporaryDir &dir, const QString &name) // running any real decoders. The caller is responsible for redirecting // QStandardPaths::CacheLocation into a temporary directory first. Returns // nullptr if the cache file could not be written. -TestableFootage *ProbeFootageFromCache(olive::Project *project, +TestableFootage *probe_footage_from_cache(olive::Project *project, const QString &media_path, const olive::FootageDescription &desc) { @@ -141,8 +141,8 @@ TestableFootage *ProbeFootageFromCache(olive::Project *project, const QString cache_file = QDir(cache_location) - .filePath(olive::FileFunctions::GetUniqueFileIdentifier(media_path)); - if (!desc.Save(cache_file)) { + .filePath(olive::FileFunctions::get_unique_file_identifier(media_path)); + if (!desc.save(cache_file)) { return nullptr; } @@ -152,59 +152,59 @@ TestableFootage *ProbeFootageFromCache(olive::Project *project, return footage; } -olive::NodeGlobals MakeGlobals( - olive::LoopMode loop_mode = olive::LoopMode::kLoopModeOff, int divider = 1) +olive::NodeGlobals make_globals( + olive::LoopMode loop_mode = olive::LoopMode::k_loop_mode_off, int divider = 1) { - olive::VideoParams vparams(64, 64, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams vparams(64, 64, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); vparams.set_divider(divider); return olive::NodeGlobals(vparams, olive::core::AudioParams(), - olive::rational(0), loop_mode); + olive::Rational(0), loop_mode); } } // namespace TEST(FootageStatic, DescribeVideoStreamFormatsVideoAndStillStreams) { - olive::VideoParams video = MakeVideoStream(0); - EXPECT_EQ(olive::Footage::DescribeVideoStream(video), + olive::VideoParams video = make_video_stream(0); + EXPECT_EQ(olive::Footage::describe_video_stream(video), QStringLiteral("0: Video - 1920x1080")); - video.set_video_type(olive::VideoParams::kVideoTypeStill); + video.set_video_type(olive::VideoParams::k_video_type_still); video.set_stream_index(3); - EXPECT_EQ(olive::Footage::DescribeVideoStream(video), + EXPECT_EQ(olive::Footage::describe_video_stream(video), QStringLiteral("3: Image - 1920x1080")); } TEST(FootageStatic, DescribeAudioStreamContainsIndexAndRate) { - olive::core::AudioParams audio = MakeAudioStream(1); + olive::core::AudioParams audio = make_audio_stream(1); // The %n plural marker is only substituted when a translation is loaded, // so assert on the stable parts of the description instead - const QString description = olive::Footage::DescribeAudioStream(audio); + const QString description = olive::Footage::describe_audio_stream(audio); EXPECT_TRUE(description.startsWith(QStringLiteral("1: Audio"))); EXPECT_TRUE(description.contains(QStringLiteral("48000Hz"))); } TEST(FootageStatic, DescribeSubtitleStreamContainsIndex) { - olive::SubtitleParams subs = MakeSubtitleStream(4); - EXPECT_EQ(olive::Footage::DescribeSubtitleStream(subs), + olive::SubtitleParams subs = make_subtitle_stream(4); + EXPECT_EQ(olive::Footage::describe_subtitle_stream(subs), QStringLiteral("4: Subtitle")); } TEST(FootageStatic, GetStreamTypeNameCoversAllTrackTypes) { - EXPECT_EQ(olive::Footage::GetStreamTypeName(olive::Track::kVideo), + EXPECT_EQ(olive::Footage::get_stream_type_name(olive::Track::k_video), QStringLiteral("Video")); - EXPECT_EQ(olive::Footage::GetStreamTypeName(olive::Track::kAudio), + EXPECT_EQ(olive::Footage::get_stream_type_name(olive::Track::k_audio), QStringLiteral("Audio")); - EXPECT_EQ(olive::Footage::GetStreamTypeName(olive::Track::kSubtitle), + EXPECT_EQ(olive::Footage::get_stream_type_name(olive::Track::k_subtitle), QStringLiteral("Subtitle")); - EXPECT_EQ(olive::Footage::GetStreamTypeName(olive::Track::kNone), + EXPECT_EQ(olive::Footage::get_stream_type_name(olive::Track::k_none), QStringLiteral("Unknown")); - EXPECT_EQ(olive::Footage::GetStreamTypeName(olive::Track::kCount), + EXPECT_EQ(olive::Footage::get_stream_type_name(olive::Track::k_count), QStringLiteral("Unknown")); } @@ -212,125 +212,125 @@ TEST(FootageStatic, AdjustTimeByLoopModeReturnsZeroForStillImages) { // Still images never loop, clamp, or drop: the adjusted time is always 0, // even for in-bounds times - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(3), olive::LoopMode::kLoopModeOff, - olive::rational(10), olive::VideoParams::kVideoTypeStill, - olive::rational(1, 24)), - olive::rational(0)); - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(30), olive::LoopMode::kLoopModeLoop, - olive::rational(10), olive::VideoParams::kVideoTypeStill, - olive::rational(1, 24)), - olive::rational(0)); - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(-1), olive::LoopMode::kLoopModeClamp, - olive::rational(10), olive::VideoParams::kVideoTypeStill, - olive::rational(1, 24)), - olive::rational(0)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(3), olive::LoopMode::k_loop_mode_off, + olive::Rational(10), olive::VideoParams::k_video_type_still, + olive::Rational(1, 24)), + olive::Rational(0)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(30), olive::LoopMode::k_loop_mode_loop, + olive::Rational(10), olive::VideoParams::k_video_type_still, + olive::Rational(1, 24)), + olive::Rational(0)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(-1), olive::LoopMode::k_loop_mode_clamp, + olive::Rational(10), olive::VideoParams::k_video_type_still, + olive::Rational(1, 24)), + olive::Rational(0)); } TEST(FootageStatic, AdjustTimeByLoopModeKeepsInBoundsTime) { - for (olive::LoopMode mode : { olive::LoopMode::kLoopModeOff, - olive::LoopMode::kLoopModeClamp, - olive::LoopMode::kLoopModeLoop }) { - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(3), mode, olive::rational(10), - olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)), - olive::rational(3)); + for (olive::LoopMode mode : { olive::LoopMode::k_loop_mode_off, + olive::LoopMode::k_loop_mode_clamp, + olive::LoopMode::k_loop_mode_loop }) { + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(3), mode, olive::Rational(10), + olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)), + olive::Rational(3)); } } TEST(FootageStatic, AdjustTimeByLoopModeOffDropsOutOfBoundsTime) { - const olive::rational negative = olive::Footage::AdjustTimeByLoopMode( - olive::rational(-1), olive::LoopMode::kLoopModeOff, olive::rational(10), - olive::VideoParams::kVideoTypeVideo, olive::rational(1, 24)); + const olive::Rational negative = olive::Footage::adjust_time_by_loop_mode( + olive::Rational(-1), olive::LoopMode::k_loop_mode_off, olive::Rational(10), + olive::VideoParams::k_video_type_video, olive::Rational(1, 24)); EXPECT_TRUE(negative.isNaN()); // The length itself is already out of bounds - const olive::rational at_length = olive::Footage::AdjustTimeByLoopMode( - olive::rational(10), olive::LoopMode::kLoopModeOff, olive::rational(10), - olive::VideoParams::kVideoTypeVideo, olive::rational(1, 24)); + const olive::Rational at_length = olive::Footage::adjust_time_by_loop_mode( + olive::Rational(10), olive::LoopMode::k_loop_mode_off, olive::Rational(10), + olive::VideoParams::k_video_type_video, olive::Rational(1, 24)); EXPECT_TRUE(at_length.isNaN()); } TEST(FootageStatic, AdjustTimeByLoopModeClampsToLength) { // Beyond the end, clamp to the last frame (length - timebase) - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(10), olive::LoopMode::kLoopModeClamp, - olive::rational(10), olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)), - olive::rational(239, 24)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(10), olive::LoopMode::k_loop_mode_clamp, + olive::Rational(10), olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)), + olive::Rational(239, 24)); // Before the start, clamp to 0 - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(-5), olive::LoopMode::kLoopModeClamp, - olive::rational(10), olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)), - olive::rational(0)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(-5), olive::LoopMode::k_loop_mode_clamp, + olive::Rational(10), olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)), + olive::Rational(0)); } TEST(FootageStatic, AdjustTimeByLoopModeLoopsAroundLength) { // Single wrap past the end - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(12), olive::LoopMode::kLoopModeLoop, - olive::rational(10), olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)), - olive::rational(2)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(12), olive::LoopMode::k_loop_mode_loop, + olive::Rational(10), olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)), + olive::Rational(2)); // Multiple wraps past the end - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(25), olive::LoopMode::kLoopModeLoop, - olive::rational(10), olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)), - olive::rational(5)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(25), olive::LoopMode::k_loop_mode_loop, + olive::Rational(10), olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)), + olive::Rational(5)); // Wraps from before the start - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(-3), olive::LoopMode::kLoopModeLoop, - olive::rational(10), olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)), - olive::rational(7)); - EXPECT_EQ(olive::Footage::AdjustTimeByLoopMode( - olive::rational(-25), olive::LoopMode::kLoopModeLoop, - olive::rational(10), olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)), - olive::rational(5)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(-3), olive::LoopMode::k_loop_mode_loop, + olive::Rational(10), olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)), + olive::Rational(7)); + EXPECT_EQ(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(-25), olive::LoopMode::k_loop_mode_loop, + olive::Rational(10), olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)), + olive::Rational(5)); } TEST(FootageStatic, AdjustTimeByLoopModeWithEmptyRangeReturnsNaN) { // Looping an empty range would never terminate; return NaN instead - EXPECT_TRUE(olive::Footage::AdjustTimeByLoopMode( - olive::rational(1), olive::LoopMode::kLoopModeLoop, - olive::rational(0), olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)) + EXPECT_TRUE(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(1), olive::LoopMode::k_loop_mode_loop, + olive::Rational(0), olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)) .isNaN()); // Clamping a range shorter than one frame has no frame to clamp to - EXPECT_TRUE(olive::Footage::AdjustTimeByLoopMode( - olive::rational(1), olive::LoopMode::kLoopModeClamp, - olive::rational(0), olive::VideoParams::kVideoTypeVideo, - olive::rational(1, 24)) + EXPECT_TRUE(olive::Footage::adjust_time_by_loop_mode( + olive::Rational(1), olive::LoopMode::k_loop_mode_clamp, + olive::Rational(0), olive::VideoParams::k_video_type_video, + olive::Rational(1, 24)) .isNaN()); } TEST(FootageStatic, RetranslateSetsInputNames) { TestableFootage footage; - footage.Retranslate(); + footage.retranslate(); - EXPECT_EQ(footage.GetInputName(olive::Footage::kFilenameInput), + EXPECT_EQ(footage.get_input_name(olive::Footage::k_filename_input), QStringLiteral("Filename")); - EXPECT_EQ(footage.GetInputName(olive::ViewerOutput::kVideoParamsInput), + EXPECT_EQ(footage.get_input_name(olive::ViewerOutput::k_video_params_input), QStringLiteral("Video Parameters")); - EXPECT_EQ(footage.GetInputName(olive::ViewerOutput::kAudioParamsInput), + EXPECT_EQ(footage.get_input_name(olive::ViewerOutput::k_audio_params_input), QStringLiteral("Audio Parameters")); - EXPECT_EQ(footage.GetInputName(olive::ViewerOutput::kSubtitleParamsInput), + EXPECT_EQ(footage.get_input_name(olive::ViewerOutput::k_subtitle_params_input), QStringLiteral("Subtitle Parameters")); } @@ -346,21 +346,21 @@ protected: // Footage::Value() resolves Project::cache_path(), which goes through // the DiskManager singleton - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override { project_.reset(); - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } - olive::Footage *AddFootage() + olive::Footage *add_footage() { auto *footage = new olive::Footage(); footage->setParent(project_.get()); @@ -374,41 +374,41 @@ TEST_F(FootageTest, ManuallyAddedStreamsMapBetweenReferencesAndIndices) { TestableFootage footage; - EXPECT_EQ(footage.AddStream(olive::Track::kVideo, - QVariant::fromValue(MakeVideoStream(5))), + EXPECT_EQ(footage.add_stream(olive::Track::k_video, + QVariant::fromValue(make_video_stream(5))), 0); - EXPECT_EQ(footage.AddStream(olive::Track::kAudio, - QVariant::fromValue(MakeAudioStream(2))), + EXPECT_EQ(footage.add_stream(olive::Track::k_audio, + QVariant::fromValue(make_audio_stream(2))), 0); - EXPECT_EQ(footage.AddStream(olive::Track::kSubtitle, - QVariant::fromValue(MakeSubtitleStream(7))), + EXPECT_EQ(footage.add_stream(olive::Track::k_subtitle, + QVariant::fromValue(make_subtitle_stream(7))), 0); - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kVideo, 0), 5); - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kAudio, 0), 2); - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kSubtitle, 0), 7); - EXPECT_EQ(footage.GetStreamIndex( - olive::Track::Reference(olive::Track::kVideo, 0)), + EXPECT_EQ(footage.get_stream_index(olive::Track::k_video, 0), 5); + EXPECT_EQ(footage.get_stream_index(olive::Track::k_audio, 0), 2); + EXPECT_EQ(footage.get_stream_index(olive::Track::k_subtitle, 0), 7); + EXPECT_EQ(footage.get_stream_index( + olive::Track::Reference(olive::Track::k_video, 0)), 5); - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kNone, 0), -1); - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kCount, 0), -1); + EXPECT_EQ(footage.get_stream_index(olive::Track::k_none, 0), -1); + EXPECT_EQ(footage.get_stream_index(olive::Track::k_count, 0), -1); // Out-of-range indices report -1 rather than a default-constructed stream - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kVideo, 1), -1); - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kVideo, -1), -1); - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kAudio, 1), -1); - EXPECT_EQ(footage.GetStreamIndex(olive::Track::kSubtitle, 1), -1); + EXPECT_EQ(footage.get_stream_index(olive::Track::k_video, 1), -1); + EXPECT_EQ(footage.get_stream_index(olive::Track::k_video, -1), -1); + EXPECT_EQ(footage.get_stream_index(olive::Track::k_audio, 1), -1); + EXPECT_EQ(footage.get_stream_index(olive::Track::k_subtitle, 1), -1); - EXPECT_EQ(footage.GetReferenceFromRealIndex(5), - olive::Track::Reference(olive::Track::kVideo, 0)); - EXPECT_EQ(footage.GetReferenceFromRealIndex(2), - olive::Track::Reference(olive::Track::kAudio, 0)); - EXPECT_EQ(footage.GetReferenceFromRealIndex(7), - olive::Track::Reference(olive::Track::kSubtitle, 0)); + EXPECT_EQ(footage.get_reference_from_real_index(5), + olive::Track::Reference(olive::Track::k_video, 0)); + EXPECT_EQ(footage.get_reference_from_real_index(2), + olive::Track::Reference(olive::Track::k_audio, 0)); + EXPECT_EQ(footage.get_reference_from_real_index(7), + olive::Track::Reference(olive::Track::k_subtitle, 0)); const olive::Track::Reference unknown = - footage.GetReferenceFromRealIndex(99); - EXPECT_EQ(unknown.type(), olive::Track::kNone); + footage.get_reference_from_real_index(99); + EXPECT_EQ(unknown.type(), olive::Track::k_none); EXPECT_EQ(unknown.index(), -1); } @@ -416,18 +416,18 @@ TEST_F(FootageTest, ConnectedOutputsReflectStreamTypes) { TestableFootage footage; - EXPECT_EQ(footage.GetConnectedTextureOutput(), nullptr); - EXPECT_EQ(footage.GetConnectedSampleOutput(), nullptr); + EXPECT_EQ(footage.get_connected_texture_output(), nullptr); + EXPECT_EQ(footage.get_connected_sample_output(), nullptr); - footage.AddStream(olive::Track::kVideo, - QVariant::fromValue(MakeVideoStream(0))); - EXPECT_EQ(footage.GetConnectedTextureOutput(), + footage.add_stream(olive::Track::k_video, + QVariant::fromValue(make_video_stream(0))); + EXPECT_EQ(footage.get_connected_texture_output(), static_cast(&footage)); - EXPECT_EQ(footage.GetConnectedSampleOutput(), nullptr); + EXPECT_EQ(footage.get_connected_sample_output(), nullptr); - footage.AddStream(olive::Track::kAudio, - QVariant::fromValue(MakeAudioStream(1))); - EXPECT_EQ(footage.GetConnectedSampleOutput(), + footage.add_stream(olive::Track::k_audio, + QVariant::fromValue(make_audio_stream(1))); + EXPECT_EQ(footage.get_connected_sample_output(), static_cast(&footage)); } @@ -435,14 +435,14 @@ TEST_F(FootageTest, DataRolesForInvalidFootage) { TestableFootage footage; - EXPECT_EQ(footage.data(olive::Node::TOOLTIP).toString(), + EXPECT_EQ(footage.data(olive::Node::tooltip).toString(), QStringLiteral("Invalid")); - EXPECT_TRUE(footage.data(olive::Node::ICON).canConvert()); + EXPECT_TRUE(footage.data(olive::Node::icon).canConvert()); // With no existing file behind the footage, the time roles fall through // to the base class and stay invalid - EXPECT_FALSE(footage.data(olive::Node::CREATED_TIME).isValid()); - EXPECT_FALSE(footage.data(olive::Node::MODIFIED_TIME).isValid()); + EXPECT_FALSE(footage.data(olive::Node::created_time).isValid()); + EXPECT_FALSE(footage.data(olive::Node::modified_time).isValid()); } TEST_F(FootageTest, TooltipDescribesEnabledStreams) @@ -451,24 +451,24 @@ TEST_F(FootageTest, TooltipDescribesEnabledStreams) // The file does not exist, so the filename change clears the footage // without probing anything footage.set_filename(QStringLiteral("/nonexistent/media.mkv")); - footage.AddStream(olive::Track::kVideo, - QVariant::fromValue(MakeVideoStream(0))); - footage.AddStream(olive::Track::kAudio, - QVariant::fromValue(MakeAudioStream(1))); - footage.SetValid(); + footage.add_stream(olive::Track::k_video, + QVariant::fromValue(make_video_stream(0))); + footage.add_stream(olive::Track::k_audio, + QVariant::fromValue(make_audio_stream(1))); + footage.set_valid(); - QString tip = footage.data(olive::Node::TOOLTIP).toString(); + QString tip = footage.data(olive::Node::tooltip).toString(); EXPECT_TRUE( tip.contains(QStringLiteral("Filename: /nonexistent/media.mkv"))); EXPECT_TRUE(tip.contains(QStringLiteral("0: Video - 1920x1080"))); EXPECT_TRUE(tip.contains(QStringLiteral("Audio"))); // Disabled streams are omitted from the tooltip - olive::VideoParams disabled = footage.GetVideoParams(0); + olive::VideoParams disabled = footage.get_video_params(0); disabled.set_enabled(false); - footage.SetStream(olive::Track::kVideo, QVariant::fromValue(disabled), 0); + footage.set_stream(olive::Track::k_video, QVariant::fromValue(disabled), 0); - tip = footage.data(olive::Node::TOOLTIP).toString(); + tip = footage.data(olive::Node::tooltip).toString(); EXPECT_FALSE(tip.contains(QStringLiteral("0: Video"))); EXPECT_TRUE(tip.contains(QStringLiteral("Audio"))); } @@ -477,12 +477,12 @@ TEST_F(FootageTest, IconReflectsPrioritizedStreamType) { // The icon globals must be loaded for the returned icons to be // distinguishable (null icons all share the same cache key) - olive::icon::LoadAll(QStringLiteral(":/style/olive-dark")); - ASSERT_FALSE(olive::icon::Video.isNull()); - ASSERT_FALSE(olive::icon::Audio.isNull()); - ASSERT_FALSE(olive::icon::Image.isNull()); - ASSERT_FALSE(olive::icon::Subtitles.isNull()); - ASSERT_FALSE(olive::icon::Error.isNull()); + olive::icon::load_all(QStringLiteral(":/style/olive-dark")); + ASSERT_FALSE(olive::icon::video.isNull()); + ASSERT_FALSE(olive::icon::audio.isNull()); + ASSERT_FALSE(olive::icon::image.isNull()); + ASSERT_FALSE(olive::icon::subtitles.isNull()); + ASSERT_FALSE(olive::icon::error.isNull()); // Footage::data(ICON) only inspects streams once the footage has been // probed (total_stream_count_ is set by Reprobe), so each variant is @@ -495,85 +495,85 @@ TEST_F(FootageTest, IconReflectsPrioritizedStreamType) auto probe = [&](const QString &name, const olive::FootageDescription &desc) { - const QString media = CreateFakeMediaFile(dir, name); + const QString media = create_fake_media_file(dir, name); EXPECT_FALSE(media.isEmpty()); TestableFootage *footage = - ProbeFootageFromCache(project_.get(), media, desc); + probe_footage_from_cache(project_.get(), media, desc); EXPECT_NE(footage, nullptr); return footage; }; // Invalid footage gets the error icon TestableFootage invalid; - EXPECT_EQ(invalid.data(olive::Node::ICON).value().cacheKey(), - olive::icon::Error.cacheKey()); + EXPECT_EQ(invalid.data(olive::Node::icon).value().cacheKey(), + olive::icon::error.cacheKey()); // Real video streams take priority over audio olive::FootageDescription video_audio(QStringLiteral("fakedecoder")); - video_audio.AddVideoStream(MakeVideoStream(0)); - video_audio.AddAudioStream(MakeAudioStream(1)); - video_audio.SetStreamCount(2); + video_audio.add_video_stream(make_video_stream(0)); + video_audio.add_audio_stream(make_audio_stream(1)); + video_audio.set_stream_count(2); TestableFootage *footage = probe(QStringLiteral("video-audio.mkv"), video_audio); ASSERT_NE(footage, nullptr); - const QIcon video_icon = footage->data(olive::Node::ICON).value(); - EXPECT_EQ(video_icon.cacheKey(), olive::icon::Video.cacheKey()); - EXPECT_NE(video_icon.cacheKey(), olive::icon::Audio.cacheKey()); - EXPECT_NE(video_icon.cacheKey(), olive::icon::Error.cacheKey()); + const QIcon video_icon = footage->data(olive::Node::icon).value(); + EXPECT_EQ(video_icon.cacheKey(), olive::icon::video.cacheKey()); + EXPECT_NE(video_icon.cacheKey(), olive::icon::audio.cacheKey()); + EXPECT_NE(video_icon.cacheKey(), olive::icon::error.cacheKey()); // Audio still takes priority over a still image stream - olive::VideoParams still_stream = MakeVideoStream(0); - still_stream.set_video_type(olive::VideoParams::kVideoTypeStill); + olive::VideoParams still_stream = make_video_stream(0); + still_stream.set_video_type(olive::VideoParams::k_video_type_still); olive::FootageDescription still_audio(QStringLiteral("fakedecoder")); - still_audio.AddVideoStream(still_stream); - still_audio.AddAudioStream(MakeAudioStream(1)); - still_audio.SetStreamCount(2); + still_audio.add_video_stream(still_stream); + still_audio.add_audio_stream(make_audio_stream(1)); + still_audio.set_stream_count(2); TestableFootage *still_and_audio = probe(QStringLiteral("still-audio.mkv"), still_audio); ASSERT_NE(still_and_audio, nullptr); const QIcon still_audio_icon = - still_and_audio->data(olive::Node::ICON).value(); - EXPECT_EQ(still_audio_icon.cacheKey(), olive::icon::Audio.cacheKey()); - EXPECT_NE(still_audio_icon.cacheKey(), olive::icon::Image.cacheKey()); + still_and_audio->data(olive::Node::icon).value(); + EXPECT_EQ(still_audio_icon.cacheKey(), olive::icon::audio.cacheKey()); + EXPECT_NE(still_audio_icon.cacheKey(), olive::icon::image.cacheKey()); // A still image without audio hits the image branch olive::FootageDescription stills(QStringLiteral("fakedecoder")); - stills.AddVideoStream(still_stream); - stills.SetStreamCount(1); + stills.add_video_stream(still_stream); + stills.set_stream_count(1); TestableFootage *still_only = probe(QStringLiteral("still.mkv"), stills); ASSERT_NE(still_only, nullptr); - EXPECT_EQ(still_only->data(olive::Node::ICON).value().cacheKey(), - olive::icon::Image.cacheKey()); + EXPECT_EQ(still_only->data(olive::Node::icon).value().cacheKey(), + olive::icon::image.cacheKey()); // Audio-only footage olive::FootageDescription audio(QStringLiteral("fakedecoder")); - audio.AddAudioStream(MakeAudioStream(0)); - audio.SetStreamCount(1); + audio.add_audio_stream(make_audio_stream(0)); + audio.set_stream_count(1); TestableFootage *audio_only = probe(QStringLiteral("audio.mkv"), audio); ASSERT_NE(audio_only, nullptr); - EXPECT_EQ(audio_only->data(olive::Node::ICON).value().cacheKey(), - olive::icon::Audio.cacheKey()); + EXPECT_EQ(audio_only->data(olive::Node::icon).value().cacheKey(), + olive::icon::audio.cacheKey()); // Subtitle-only footage olive::FootageDescription subs(QStringLiteral("fakedecoder")); - subs.AddSubtitleStream(MakeSubtitleStream(0)); - subs.SetStreamCount(1); + subs.add_subtitle_stream(make_subtitle_stream(0)); + subs.set_stream_count(1); TestableFootage *subs_only = probe(QStringLiteral("subs.mkv"), subs); ASSERT_NE(subs_only, nullptr); - EXPECT_EQ(subs_only->data(olive::Node::ICON).value().cacheKey(), - olive::icon::Subtitles.cacheKey()); + EXPECT_EQ(subs_only->data(olive::Node::icon).value().cacheKey(), + olive::icon::subtitles.cacheKey()); } TEST_F(FootageTest, ProxyChangesMarkProjectModifiedAndEmitSignal) { - olive::Footage *footage = AddFootage(); + olive::Footage *footage = add_footage(); ASSERT_FALSE(project_->is_modified()); int emissions = 0; - QObject::connect(footage, &olive::Footage::ProxySettingsChanged, + QObject::connect(footage, &olive::Footage::proxy_settings_changed, [&emissions]() { ++emissions; }); - footage->SetProxy(QStringLiteral("/cache/proxy/example.mp4"), - olive::ProxyManager::kProxyReady, 0, 1, true); + footage->set_proxy(QStringLiteral("/cache/proxy/example.mp4"), + olive::ProxyManager::k_proxy_ready, 0, 1, true); EXPECT_EQ(emissions, 1); EXPECT_TRUE(project_->is_modified()); @@ -597,37 +597,37 @@ TEST_F(FootageTest, ReprobeRestoresStreamsFromMetadataCache) "XDG_CACHE_HOME", QDir(dir.path()).filePath(QStringLiteral("xdg")).toUtf8()); - const QString media = CreateFakeMediaFile(dir, QStringLiteral("fake.mkv")); + const QString media = create_fake_media_file(dir, QStringLiteral("fake.mkv")); ASSERT_FALSE(media.isEmpty()); - TestableFootage *footage = ProbeFootageFromCache( - project_.get(), media, MakeStandardDescription()); + TestableFootage *footage = probe_footage_from_cache( + project_.get(), media, make_standard_description()); ASSERT_NE(footage, nullptr); - EXPECT_TRUE(footage->IsValid()); + EXPECT_TRUE(footage->is_valid()); EXPECT_EQ(footage->decoder(), QStringLiteral("fakedecoder")); - EXPECT_EQ(footage->GetTotalStreamCount(), 3); - EXPECT_EQ(footage->GetVideoStreamCount(), 2); - EXPECT_EQ(footage->GetAudioStreamCount(), 1); - EXPECT_EQ(footage->GetSubtitleStreamCount(), 0); + EXPECT_EQ(footage->get_total_stream_count(), 3); + EXPECT_EQ(footage->get_video_stream_count(), 2); + EXPECT_EQ(footage->get_audio_stream_count(), 1); + EXPECT_EQ(footage->get_subtitle_stream_count(), 0); - EXPECT_EQ(footage->GetStreamIndex(olive::Track::kVideo, 0), 0); - EXPECT_EQ(footage->GetStreamIndex(olive::Track::kVideo, 1), 1); - EXPECT_EQ(footage->GetStreamIndex(olive::Track::kAudio, 0), 2); - EXPECT_EQ(footage->GetReferenceFromRealIndex(2), - olive::Track::Reference(olive::Track::kAudio, 0)); + EXPECT_EQ(footage->get_stream_index(olive::Track::k_video, 0), 0); + EXPECT_EQ(footage->get_stream_index(olive::Track::k_video, 1), 1); + EXPECT_EQ(footage->get_stream_index(olive::Track::k_audio, 0), 2); + EXPECT_EQ(footage->get_reference_from_real_index(2), + olive::Track::Reference(olive::Track::k_audio, 0)); - EXPECT_EQ(footage->GetConnectedTextureOutput(), + EXPECT_EQ(footage->get_connected_texture_output(), static_cast(footage)); - EXPECT_EQ(footage->GetConnectedSampleOutput(), + EXPECT_EQ(footage->get_connected_sample_output(), static_cast(footage)); // The file behind the footage exists, so both time roles are reported - const QVariant modified = footage->data(olive::Node::MODIFIED_TIME); + const QVariant modified = footage->data(olive::Node::modified_time); ASSERT_TRUE(modified.isValid()); EXPECT_EQ(modified.toLongLong(), QFileInfo(media).lastModified().toSecsSinceEpoch()); - EXPECT_TRUE(footage->data(olive::Node::CREATED_TIME).isValid()); + EXPECT_TRUE(footage->data(olive::Node::created_time).isValid()); } TEST_F(FootageTest, VerifyLengthUsesStreamDurations) @@ -638,18 +638,18 @@ TEST_F(FootageTest, VerifyLengthUsesStreamDurations) "XDG_CACHE_HOME", QDir(dir.path()).filePath(QStringLiteral("xdg")).toUtf8()); - const QString media = CreateFakeMediaFile(dir, QStringLiteral("fake.mkv")); + const QString media = create_fake_media_file(dir, QStringLiteral("fake.mkv")); ASSERT_FALSE(media.isEmpty()); - TestableFootage *footage = ProbeFootageFromCache( - project_.get(), media, MakeStandardDescription()); + TestableFootage *footage = probe_footage_from_cache( + project_.get(), media, make_standard_description()); ASSERT_NE(footage, nullptr); // Both streams describe two seconds of media - footage->VerifyLength(); - EXPECT_EQ(footage->GetVideoLength(), olive::rational(2)); - EXPECT_EQ(footage->GetAudioLength(), olive::rational(2)); - EXPECT_EQ(footage->GetLength(), olive::rational(2)); + footage->verify_length(); + EXPECT_EQ(footage->get_video_length(), olive::Rational(2)); + EXPECT_EQ(footage->get_audio_length(), olive::Rational(2)); + EXPECT_EQ(footage->get_length(), olive::Rational(2)); } TEST_F(FootageTest, ValueSkipsMissingFiles) @@ -657,12 +657,12 @@ TEST_F(FootageTest, ValueSkipsMissingFiles) TestableFootage footage; olive::NodeValueRow row; - row.insert(olive::Footage::kFilenameInput, - olive::NodeValue(olive::NodeValue::kFile, + row.insert(olive::Footage::k_filename_input, + olive::NodeValue(olive::NodeValue::k_file, QStringLiteral("/nonexistent/media.mkv"))); olive::NodeValueTable table; - footage.Value(row, MakeGlobals(), &table); + footage.value(row, make_globals(), &table); EXPECT_TRUE(table.isEmpty()); } @@ -671,25 +671,25 @@ TEST_F(FootageTest, ValuePushesOnlyLengthWhenNoStreams) { QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - const QString media = CreateFakeMediaFile(dir, QStringLiteral("empty.mkv")); + const QString media = create_fake_media_file(dir, QStringLiteral("empty.mkv")); ASSERT_FALSE(media.isEmpty()); TestableFootage footage; olive::NodeValueRow row; - row.insert(olive::Footage::kFilenameInput, - olive::NodeValue(olive::NodeValue::kFile, media)); + row.insert(olive::Footage::k_filename_input, + olive::NodeValue(olive::NodeValue::k_file, media)); olive::NodeValueTable table; - footage.Value(row, MakeGlobals(), &table); + footage.value(row, make_globals(), &table); // The file exists but no streams were ever probed, so only the (zero) // length is pushed - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::NodeValue length = - table.Get(olive::NodeValue::kRational, QStringLiteral("length")); - EXPECT_EQ(length.type(), olive::NodeValue::kRational); - EXPECT_EQ(length.toRational(), olive::rational(0)); + table.get(olive::NodeValue::k_rational, QStringLiteral("length")); + EXPECT_EQ(length.type(), olive::NodeValue::k_rational); + EXPECT_EQ(length.to_rational(), olive::Rational(0)); EXPECT_EQ(length.source(), static_cast(&footage)); } @@ -701,44 +701,44 @@ TEST_F(FootageTest, ValuePushesStreamJobs) "XDG_CACHE_HOME", QDir(dir.path()).filePath(QStringLiteral("xdg")).toUtf8()); - const QString media = CreateFakeMediaFile(dir, QStringLiteral("fake.mkv")); + const QString media = create_fake_media_file(dir, QStringLiteral("fake.mkv")); ASSERT_FALSE(media.isEmpty()); - TestableFootage *footage = ProbeFootageFromCache( - project_.get(), media, MakeStandardDescription()); + TestableFootage *footage = probe_footage_from_cache( + project_.get(), media, make_standard_description()); ASSERT_NE(footage, nullptr); - footage->VerifyLength(); + footage->verify_length(); // The colorspace fallback reads the project default, and the audio cache // path comes from the project's cache settings - project_->SetDefaultInputColorSpace(QStringLiteral("TestInputSpace")); - project_->SetCacheLocationSetting(olive::Project::kCacheCustomPath); + project_->set_default_input_color_space(QStringLiteral("TestInputSpace")); + project_->set_cache_location_setting(olive::Project::k_cache_custom_path); const QString cache_path = QDir(dir.path()).filePath(QStringLiteral("cache")); - project_->SetCustomCachePath(cache_path); + project_->set_custom_cache_path(cache_path); olive::NodeValueRow row; - row.insert(olive::Footage::kFilenameInput, - olive::NodeValue(olive::NodeValue::kFile, media)); + row.insert(olive::Footage::k_filename_input, + olive::NodeValue(olive::NodeValue::k_file, media)); // A divider > 1 routes through the target-resolution divider calculation const olive::NodeGlobals globals = - MakeGlobals(olive::LoopMode::kLoopModeLoop, 2); + make_globals(olive::LoopMode::k_loop_mode_loop, 2); olive::NodeValueTable table; - footage->Value(row, globals, &table); + footage->value(row, globals, &table); // Length, two texture jobs, and one sample job - EXPECT_EQ(table.Count(), 4); + EXPECT_EQ(table.count(), 4); const olive::NodeValue length = - table.Get(olive::NodeValue::kRational, QStringLiteral("length")); - EXPECT_EQ(length.toRational(), olive::rational(2)); + table.get(olive::NodeValue::k_rational, QStringLiteral("length")); + EXPECT_EQ(length.to_rational(), olive::Rational(2)); // A stream without a colorspace falls back to the project default const olive::TexturePtr tex0 = - table.Get(olive::NodeValue::kTexture, QStringLiteral("v:0")) - .toTexture(); + table.get(olive::NodeValue::k_texture, QStringLiteral("v:0")) + .to_texture(); ASSERT_NE(tex0, nullptr); EXPECT_EQ(tex0->params().colorspace(), QStringLiteral("TestInputSpace")); // min(calculated divider for 32x32 from 1920x1080, requested 2) @@ -746,31 +746,31 @@ TEST_F(FootageTest, ValuePushesStreamJobs) // An explicit colorspace survives const olive::TexturePtr tex1 = - table.Get(olive::NodeValue::kTexture, QStringLiteral("v:1")) - .toTexture(); + table.get(olive::NodeValue::k_texture, QStringLiteral("v:1")) + .to_texture(); ASSERT_NE(tex1, nullptr); EXPECT_EQ(tex1->params().colorspace(), QStringLiteral("ExplicitSpace")); const olive::NodeValue samples = - table.Get(olive::NodeValue::kSamples, QStringLiteral("a:0")); - ASSERT_EQ(samples.type(), olive::NodeValue::kSamples); + table.get(olive::NodeValue::k_samples, QStringLiteral("a:0")); + ASSERT_EQ(samples.type(), olive::NodeValue::k_samples); const olive::FootageJob audio_job = samples.data().value(); EXPECT_EQ(audio_job.filename(), media); EXPECT_EQ(audio_job.decoder(), QStringLiteral("fakedecoder")); - EXPECT_EQ(audio_job.type(), olive::Track::kAudio); + EXPECT_EQ(audio_job.type(), olive::Track::k_audio); EXPECT_EQ(audio_job.audio_params().sample_rate(), 48000); - EXPECT_EQ(audio_job.length(), olive::rational(2)); - EXPECT_EQ(audio_job.loop_mode(), olive::LoopMode::kLoopModeLoop); + EXPECT_EQ(audio_job.length(), olive::Rational(2)); + EXPECT_EQ(audio_job.loop_mode(), olive::LoopMode::k_loop_mode_loop); EXPECT_EQ(audio_job.time(), globals.time()); EXPECT_EQ(audio_job.cache_path(), cache_path); // With a divider of 1, everything renders at full resolution olive::NodeValueTable full_res; - footage->Value(row, MakeGlobals(), &full_res); + footage->value(row, make_globals(), &full_res); const olive::TexturePtr full_res_tex = - full_res.Get(olive::NodeValue::kTexture, QStringLiteral("v:0")) - .toTexture(); + full_res.get(olive::NodeValue::k_texture, QStringLiteral("v:0")) + .to_texture(); ASSERT_NE(full_res_tex, nullptr); EXPECT_EQ(full_res_tex->params().divider(), 1); } @@ -783,13 +783,13 @@ TEST_F(FootageTest, ValueAttachesReadyProxyToJobs) "XDG_CACHE_HOME", QDir(dir.path()).filePath(QStringLiteral("xdg")).toUtf8()); - const QString media = CreateFakeMediaFile(dir, QStringLiteral("fake.mkv")); + const QString media = create_fake_media_file(dir, QStringLiteral("fake.mkv")); ASSERT_FALSE(media.isEmpty()); - TestableFootage *footage = ProbeFootageFromCache( - project_.get(), media, MakeStandardDescription()); + TestableFootage *footage = probe_footage_from_cache( + project_.get(), media, make_standard_description()); ASSERT_NE(footage, nullptr); - footage->VerifyLength(); + footage->verify_length(); // A ready proxy is simply an existing proxy file with no .working // sibling; the .a1. marker declares that it contains audio @@ -800,19 +800,19 @@ TEST_F(FootageTest, ValueAttachesReadyProxyToJobs) QFile proxy_file(proxy); ASSERT_TRUE(proxy_file.open(QFile::WriteOnly)); } - footage->SetProxy(proxy, olive::ProxyManager::kProxyReady, 0, 1, true); + footage->set_proxy(proxy, olive::ProxyManager::k_proxy_ready, 0, 1, true); olive::NodeValueRow row; - row.insert(olive::Footage::kFilenameInput, - olive::NodeValue(olive::NodeValue::kFile, media)); + row.insert(olive::Footage::k_filename_input, + olive::NodeValue(olive::NodeValue::k_file, media)); olive::NodeValueTable table; - footage->Value(row, MakeGlobals(), &table); + footage->value(row, make_globals(), &table); // The proxied video stream (real index 0) gets the proxy at stream 0 const olive::TexturePtr tex0 = - table.Get(olive::NodeValue::kTexture, QStringLiteral("v:0")) - .toTexture(); + table.get(olive::NodeValue::k_texture, QStringLiteral("v:0")) + .to_texture(); ASSERT_NE(tex0, nullptr); const auto *video0_job = static_cast(tex0->job()); @@ -824,8 +824,8 @@ TEST_F(FootageTest, ValueAttachesReadyProxyToJobs) // Other video streams are unaffected const olive::TexturePtr tex1 = - table.Get(olive::NodeValue::kTexture, QStringLiteral("v:1")) - .toTexture(); + table.get(olive::NodeValue::k_texture, QStringLiteral("v:1")) + .to_texture(); ASSERT_NE(tex1, nullptr); const auto *video1_job = static_cast(tex1->job()); @@ -834,7 +834,7 @@ TEST_F(FootageTest, ValueAttachesReadyProxyToJobs) // The first audio stream follows the video stream inside the proxy file const olive::FootageJob audio_job = - table.Get(olive::NodeValue::kSamples, QStringLiteral("a:0")) + table.get(olive::NodeValue::k_samples, QStringLiteral("a:0")) .data() .value(); EXPECT_TRUE(audio_job.has_proxy()); @@ -844,10 +844,10 @@ TEST_F(FootageTest, ValueAttachesReadyProxyToJobs) // Disabling the proxy detaches it from subsequent jobs footage->set_proxy_enabled(false); olive::NodeValueTable no_proxy; - footage->Value(row, MakeGlobals(), &no_proxy); + footage->value(row, make_globals(), &no_proxy); const olive::TexturePtr no_proxy_tex = - no_proxy.Get(olive::NodeValue::kTexture, QStringLiteral("v:0")) - .toTexture(); + no_proxy.get(olive::NodeValue::k_texture, QStringLiteral("v:0")) + .to_texture(); ASSERT_NE(no_proxy_tex, nullptr); const auto *no_proxy_job = static_cast(no_proxy_tex->job()); @@ -859,13 +859,13 @@ TEST_F(FootageTest, SaveCustomPersistsSourceStartTime) { olive::Footage footage; footage.set_timestamp(7); - footage.SetSourceStartTime(olive::rational(3600), QStringLiteral("manual")); + footage.set_source_start_time(olive::Rational(3600), QStringLiteral("manual")); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("custom")); - footage.SaveCustom(&writer); + footage.save_custom(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -878,9 +878,9 @@ TEST_F(FootageTest, SaveCustomPersistsSourceStartTime) ASSERT_EQ(reader.name(), QStringLiteral("custom")); olive::Footage loaded; - ASSERT_TRUE(loaded.LoadCustom(&reader, nullptr)); - ASSERT_TRUE(loaded.HasSourceStartTime()); - EXPECT_EQ(loaded.source_start_time(), olive::rational(3600)); + ASSERT_TRUE(loaded.load_custom(&reader, nullptr)); + ASSERT_TRUE(loaded.has_source_start_time()); + EXPECT_EQ(loaded.source_start_time(), olive::Rational(3600)); EXPECT_EQ(loaded.source_start_time_source(), QStringLiteral("manual")); EXPECT_EQ(loaded.timestamp(), 7); } diff --git a/tests/gtest/lut_file_field_test.cpp b/tests/gtest/lut_file_field_test.cpp index 957d93eec..3d8b2e5d8 100644 --- a/tests/gtest/lut_file_field_test.cpp +++ b/tests/gtest/lut_file_field_test.cpp @@ -15,21 +15,21 @@ namespace class LutLibraryConfigGuard { public: LutLibraryConfigGuard() - : previous_(olive::Config::Current()[QStringLiteral("LUTLibraryPaths")] + : previous_(olive::Config::current()[QStringLiteral("LUTLibraryPaths")] .toString()) { } ~LutLibraryConfigGuard() { - olive::Config::Current()[QStringLiteral("LUTLibraryPaths")] = previous_; + olive::Config::current()[QStringLiteral("LUTLibraryPaths")] = previous_; } private: QString previous_; }; -QString WriteFile(const QString &path) +QString write_file(const QString &path) { QFile file(path); if (!file.open(QIODevice::WriteOnly)) { @@ -49,16 +49,16 @@ TEST(LutFileField, PopulatesComboFromLibrary) ASSERT_TRUE(dir.isValid()); const QString cube = - WriteFile(QDir(dir.path()).filePath(QStringLiteral("a.cube"))); + write_file(QDir(dir.path()).filePath(QStringLiteral("a.cube"))); const QString three_dl = - WriteFile(QDir(dir.path()).filePath(QStringLiteral("b.3dl"))); + write_file(QDir(dir.path()).filePath(QStringLiteral("b.3dl"))); const QString other = - WriteFile(QDir(dir.path()).filePath(QStringLiteral("c.txt"))); + write_file(QDir(dir.path()).filePath(QStringLiteral("c.txt"))); ASSERT_FALSE(cube.isEmpty()); ASSERT_FALSE(three_dl.isEmpty()); ASSERT_FALSE(other.isEmpty()); - olive::LUTLibrary::SetDirectories({ dir.path() }); + olive::LUTLibrary::set_directories({ dir.path() }); olive::LutFileField field; @@ -78,30 +78,30 @@ TEST(LutFileField, SelectionFollowsFilenameAndEmitsOnPick) ASSERT_TRUE(dir.isValid()); const QString cube = - WriteFile(QDir(dir.path()).filePath(QStringLiteral("a.cube"))); + write_file(QDir(dir.path()).filePath(QStringLiteral("a.cube"))); ASSERT_FALSE(cube.isEmpty()); - olive::LUTLibrary::SetDirectories({ dir.path() }); + olive::LUTLibrary::set_directories({ dir.path() }); olive::LutFileField field; // A path that is not in the library shows the "Other" entry - field.SetFilename(QStringLiteral("/custom/elsewhere.cube")); + field.set_filename(QStringLiteral("/custom/elsewhere.cube")); EXPECT_EQ(field.library_combo()->currentIndex(), 0); // A library path selects its entry - field.SetFilename(cube); + field.set_filename(cube); EXPECT_GT(field.library_combo()->currentIndex(), 0); // Picking a library entry updates the filename and emits the change // signal so the parameter bridge applies it like any other edit - field.SetFilename(QString()); - QSignalSpy spy(&field, &olive::FileField::FilenameChanged); + field.set_filename(QString()); + QSignalSpy spy(&field, &olive::FileField::filename_changed); const int index = field.library_combo()->findData(cube); ASSERT_GE(index, 1); emit field.library_combo()->activated(index); - EXPECT_EQ(field.GetFilename(), cube); + EXPECT_EQ(field.get_filename(), cube); ASSERT_EQ(spy.count(), 1); EXPECT_EQ(spy.first().first().toString(), cube); } diff --git a/tests/gtest/mainwindow_test.cpp b/tests/gtest/mainwindow_test.cpp index e6609b4ea..eda517ca2 100644 --- a/tests/gtest/mainwindow_test.cpp +++ b/tests/gtest/mainwindow_test.cpp @@ -35,11 +35,11 @@ class DummyTask : public Task { public: DummyTask() { - SetTitle(QStringLiteral("Status Test Task")); + set_title(QStringLiteral("Status Test Task")); } protected: - virtual bool Run() override + virtual bool run() override { return true; } @@ -50,7 +50,7 @@ protected: TEST(MainWindowLayoutInfo, AccessorsStoreAndRetrieve) { Project project; - project.Initialize(); + project.initialize(); auto *folder = new Folder(); folder->setParent(&project); auto *sequence = new Sequence(); @@ -102,7 +102,7 @@ TEST(MainWindowLayoutInfo, AccessorsStoreAndRetrieve) TEST(MainWindowLayoutInfo, XmlRoundTripPreservesEverything) { Project project; - project.Initialize(); + project.initialize(); auto *folder = new Folder(); folder->setParent(&project); auto *sequence = new Sequence(); @@ -123,7 +123,7 @@ TEST(MainWindowLayoutInfo, XmlRoundTripPreservesEverything) QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("layout")); - info.toXml(&writer); + info.to_xml(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -136,7 +136,7 @@ TEST(MainWindowLayoutInfo, XmlRoundTripPreservesEverything) ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("layout")); - MainWindowLayoutInfo loaded = MainWindowLayoutInfo::fromXml(&reader, node_map); + MainWindowLayoutInfo loaded = MainWindowLayoutInfo::from_xml(&reader, node_map); ASSERT_EQ(loaded.open_folders().size(), 1); EXPECT_EQ(loaded.open_folders().front(), folder); @@ -177,7 +177,7 @@ TEST(MainWindowLayoutInfo, FromXmlSkipsUnknownElementsAndNodes) ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("layout")); - MainWindowLayoutInfo info = MainWindowLayoutInfo::fromXml(&reader, {}); + MainWindowLayoutInfo info = MainWindowLayoutInfo::from_xml(&reader, {}); // Unknown pointers resolve to null but are still listed ASSERT_EQ(info.open_folders().size(), 1); @@ -209,22 +209,22 @@ TEST(MainWindowStatusBar, ReflectsTaskManagerState) auto *progress = bar.findChild(); ASSERT_NE(progress, nullptr); - bar.ConnectTaskManager(&manager); + bar.connect_task_manager(&manager); auto *task = new DummyTask(); - manager.AddTask(task); + manager.add_task(task); // One running task shows its title and the progress bar EXPECT_EQ(bar.currentMessage(), QStringLiteral("Status Test Task")); EXPECT_TRUE(progress->isVisible()); // Progress signals are forwarded to the bar - emit task->ProgressChanged(0.5); + emit task->progress_changed(0.5); EXPECT_EQ(progress->value(), 50); // When the task list empties, the bar hides and the message clears - manager.CancelTaskAndWait(task); - QTRY_COMPARE_WITH_TIMEOUT(manager.GetTaskCount(), 0, 2000); + manager.cancel_task_and_wait(task); + QTRY_COMPARE_WITH_TIMEOUT(manager.get_task_count(), 0, 2000); EXPECT_TRUE(bar.currentMessage().isEmpty()); EXPECT_FALSE(progress->isVisible()); EXPECT_EQ(progress->value(), 0); @@ -237,7 +237,7 @@ TEST(MainWindowStatusBar, DoubleClickEmitsSignal) MainStatusBar bar; bar.show(); - QSignalSpy spy(&bar, &MainStatusBar::DoubleClicked); + QSignalSpy spy(&bar, &MainStatusBar::double_clicked); QTest::mouseDClick(&bar, Qt::LeftButton); EXPECT_GE(spy.count(), 1); } @@ -267,37 +267,37 @@ TEST(MainWindow, ConstructsOffscreenWithPanelsAndMenus) // Must precede RenderManager creation: PreviewAutoCacher constructs a // Project whose ColorManager dereferences the default OCIO config - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); const bool created_task_manager = (TaskManager::instance() == nullptr); if (created_task_manager) { - TaskManager::CreateInstance(); + TaskManager::create_instance(); } const bool created_render_manager = (RenderManager::instance() == nullptr); QVariant saved_backend; if (created_render_manager) { // Another suite may have left an experimental backend in the config; // RenderManager needs a real one to create its cacher - saved_backend = Config::Current()[QStringLiteral("GraphicsBackend")]; - Config::Current()[QStringLiteral("GraphicsBackend")] = + saved_backend = Config::current()[QStringLiteral("GraphicsBackend")]; + Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("opengl"); - RenderManager::CreateInstance(); + RenderManager::create_instance(); } const bool created_disk_manager = (DiskManager::instance() == nullptr); if (created_disk_manager) { - DiskManager::CreateInstance(); + DiskManager::create_instance(); } const bool created_menu_shared = (MenuShared::instance() == nullptr); if (created_menu_shared) { - MenuShared::CreateInstance(); + MenuShared::create_instance(); } const bool created_panel_manager = (PanelManager::instance() == nullptr); if (created_panel_manager) { - PanelManager::CreateInstance(); + PanelManager::create_instance(); } const bool created_audio_manager = (AudioManager::instance() == nullptr); if (created_audio_manager) { - AudioManager::CreateInstance(); + AudioManager::create_instance(); } if (!Core::instance()) { new Core(Core::CoreParams()); // intentionally leaked @@ -306,8 +306,8 @@ TEST(MainWindow, ConstructsOffscreenWithPanelsAndMenus) // Suppress the modal welcome dialog shown on first show const QVariant welcome_setting = - Config::Current()[QStringLiteral("ShowWelcomeDialog")]; - Config::Current()[QStringLiteral("ShowWelcomeDialog")] = false; + Config::current()[QStringLiteral("ShowWelcomeDialog")]; + Config::current()[QStringLiteral("ShowWelcomeDialog")] = false; MainWindow *window = new MainWindow(); window->showMaximized(); @@ -316,15 +316,15 @@ TEST(MainWindow, ConstructsOffscreenWithPanelsAndMenus) PanelManager *panels = PanelManager::instance(); ASSERT_NE(panels, nullptr); EXPECT_GE(panels->panels().size(), 10); - EXPECT_NE(panels->GetPanelWithName(QStringLiteral("NodePanel")), nullptr); - EXPECT_NE(panels->GetPanelWithName(QStringLiteral("ProjectPanel")), + EXPECT_NE(panels->get_panel_with_name(QStringLiteral("NodePanel")), nullptr); + EXPECT_NE(panels->get_panel_with_name(QStringLiteral("ProjectPanel")), nullptr); // Timeline panels get their index appended to the unique name - EXPECT_NE(panels->GetPanelWithName(QStringLiteral("TimelinePanel:0")), + EXPECT_NE(panels->get_panel_with_name(QStringLiteral("TimelinePanel:0")), nullptr); - EXPECT_NE(panels->GetPanelWithName(QStringLiteral("SequenceViewerPanel")), + EXPECT_NE(panels->get_panel_with_name(QStringLiteral("SequenceViewerPanel")), nullptr); - EXPECT_NE(panels->GetPanelWithName(QStringLiteral("FootageViewerPanel")), + EXPECT_NE(panels->get_panel_with_name(QStringLiteral("FootageViewerPanel")), nullptr); // The menu bar is fully populated (this is what the action search dialog @@ -348,29 +348,29 @@ TEST(MainWindow, ConstructsOffscreenWithPanelsAndMenus) // loop must not crash QCoreApplication::processEvents(QEventLoop::AllEvents, 100); - Config::Current()[QStringLiteral("ShowWelcomeDialog")] = welcome_setting; + Config::current()[QStringLiteral("ShowWelcomeDialog")] = welcome_setting; // Tear down in reverse order: window first, then its panels, then only // the singletons this test created delete window; if (created_panel_manager) { - PanelManager::instance()->DeleteAllPanels(); - PanelManager::DestroyInstance(); + PanelManager::instance()->delete_all_panels(); + PanelManager::destroy_instance(); } if (created_audio_manager) { - AudioManager::DestroyInstance(); + AudioManager::destroy_instance(); } if (created_menu_shared) { - MenuShared::DestroyInstance(); + MenuShared::destroy_instance(); } if (created_render_manager) { - RenderManager::DestroyInstance(); - Config::Current()[QStringLiteral("GraphicsBackend")] = saved_backend; + RenderManager::destroy_instance(); + Config::current()[QStringLiteral("GraphicsBackend")] = saved_backend; } if (created_task_manager) { - TaskManager::DestroyInstance(); + TaskManager::destroy_instance(); } if (created_disk_manager) { - DiskManager::DestroyInstance(); + DiskManager::destroy_instance(); } } diff --git a/tests/gtest/module_smoke_test.cpp b/tests/gtest/module_smoke_test.cpp index 8d8ec04b0..2c37cf181 100644 --- a/tests/gtest/module_smoke_test.cpp +++ b/tests/gtest/module_smoke_test.cpp @@ -5,36 +5,36 @@ TEST(ModuleSmoke, ToolAddableObjectNames) { EXPECT_FALSE( - olive::Tool::GetAddableObjectName(olive::Tool::kAddableEmpty).isEmpty()); + olive::Tool::get_addable_object_name(olive::Tool::k_addable_empty).isEmpty()); EXPECT_FALSE( - olive::Tool::GetAddableObjectName(olive::Tool::kAddableBars).isEmpty()); + olive::Tool::get_addable_object_name(olive::Tool::k_addable_bars).isEmpty()); EXPECT_FALSE( - olive::Tool::GetAddableObjectName(olive::Tool::kAddableShape).isEmpty()); + olive::Tool::get_addable_object_name(olive::Tool::k_addable_shape).isEmpty()); EXPECT_FALSE( - olive::Tool::GetAddableObjectName(olive::Tool::kAddableSolid).isEmpty()); + olive::Tool::get_addable_object_name(olive::Tool::k_addable_solid).isEmpty()); EXPECT_FALSE( - olive::Tool::GetAddableObjectName(olive::Tool::kAddableTitle).isEmpty()); + olive::Tool::get_addable_object_name(olive::Tool::k_addable_title).isEmpty()); EXPECT_FALSE( - olive::Tool::GetAddableObjectName(olive::Tool::kAddableTone).isEmpty()); + olive::Tool::get_addable_object_name(olive::Tool::k_addable_tone).isEmpty()); EXPECT_FALSE( - olive::Tool::GetAddableObjectName(olive::Tool::kAddableSubtitle) + olive::Tool::get_addable_object_name(olive::Tool::k_addable_subtitle) .isEmpty()); } TEST(ModuleSmoke, ToolAddableObjectIds) { - EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableEmpty), + EXPECT_EQ(olive::Tool::get_addable_object_id(olive::Tool::k_addable_empty), QStringLiteral("empty")); - EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableBars), + EXPECT_EQ(olive::Tool::get_addable_object_id(olive::Tool::k_addable_bars), QStringLiteral("bars")); - EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableShape), + EXPECT_EQ(olive::Tool::get_addable_object_id(olive::Tool::k_addable_shape), QStringLiteral("shape")); - EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableSolid), + EXPECT_EQ(olive::Tool::get_addable_object_id(olive::Tool::k_addable_solid), QStringLiteral("solid")); - EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableTitle), + EXPECT_EQ(olive::Tool::get_addable_object_id(olive::Tool::k_addable_title), QStringLiteral("title")); - EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableTone), + EXPECT_EQ(olive::Tool::get_addable_object_id(olive::Tool::k_addable_tone), QStringLiteral("tone")); - EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableSubtitle), + EXPECT_EQ(olive::Tool::get_addable_object_id(olive::Tool::k_addable_subtitle), QStringLiteral("subtitle")); } diff --git a/tests/gtest/multicam_serializer_test.cpp b/tests/gtest/multicam_serializer_test.cpp index 5313979da..35f1b52de 100644 --- a/tests/gtest/multicam_serializer_test.cpp +++ b/tests/gtest/multicam_serializer_test.cpp @@ -22,18 +22,18 @@ namespace { // Project save/load and cache paths go through the DiskManager singleton -void EnsureDiskManager(bool *created) +void ensure_disk_manager(bool *created) { *created = (olive::DiskManager::instance() == nullptr); if (*created) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } -void ReleaseDiskManager(bool created) +void release_disk_manager(bool created) { if (created) { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } } @@ -43,56 +43,56 @@ TEST(MultiCamNode, DefaultState) { olive::MultiCamNode node; - EXPECT_EQ(node.Name(), QStringLiteral("Multi-Cam")); + EXPECT_EQ(node.name(), QStringLiteral("Multi-Cam")); EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.multicam")); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryTimeline)); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_timeline)); // The "arraystart" property only hints the UI; the sources array itself // starts empty - EXPECT_EQ(node.GetSourceCount(), 0); - EXPECT_EQ(node.GetCurrentSource(), 0); + EXPECT_EQ(node.get_source_count(), 0); + EXPECT_EQ(node.get_current_source(), 0); // Sequence type selector stays hidden until a sequence is connected - EXPECT_TRUE(node.GetInputFlags(olive::MultiCamNode::kSequenceTypeInput) & - olive::kInputFlagHidden); + EXPECT_TRUE(node.get_input_flags(olive::MultiCamNode::k_sequence_type_input) & + olive::k_input_flag_hidden); } TEST(MultiCamNode, ActiveElementsSelectCurrentSource) { olive::MultiCamNode node; - node.InputArrayResize(olive::MultiCamNode::kSourcesInput, 3); - ASSERT_EQ(node.GetSourceCount(), 3); + node.input_array_resize(olive::MultiCamNode::k_sources_input, 3); + ASSERT_EQ(node.get_source_count(), 3); - node.SetStandardValue(olive::MultiCamNode::kCurrentInput, 1); + node.set_standard_value(olive::MultiCamNode::k_current_input, 1); - olive::Node::ActiveElements active = node.GetActiveElementsAtTime( - olive::MultiCamNode::kSourcesInput, olive::TimeRange()); - EXPECT_EQ(active.mode(), olive::Node::ActiveElements::kSpecified); + olive::Node::ActiveElements active = node.get_active_elements_at_time( + olive::MultiCamNode::k_sources_input, olive::TimeRange()); + EXPECT_EQ(active.mode(), olive::Node::ActiveElements::k_specified); ASSERT_EQ(active.elements().size(), 1); EXPECT_EQ(active.elements().front(), 1); // Any other input defers to the base implementation - olive::Node::ActiveElements all = node.GetActiveElementsAtTime( - olive::MultiCamNode::kCurrentInput, olive::TimeRange()); - EXPECT_EQ(all.mode(), olive::Node::ActiveElements::kAllElements); + olive::Node::ActiveElements all = node.get_active_elements_at_time( + olive::MultiCamNode::k_current_input, olive::TimeRange()); + EXPECT_EQ(all.mode(), olive::Node::ActiveElements::k_all_elements); } TEST(MultiCamNode, ActiveElementsOutOfRangeAreEmpty) { olive::MultiCamNode node; - node.InputArrayResize(olive::MultiCamNode::kSourcesInput, 3); + node.input_array_resize(olive::MultiCamNode::k_sources_input, 3); - node.SetStandardValue(olive::MultiCamNode::kCurrentInput, 5); - EXPECT_EQ(node.GetActiveElementsAtTime(olive::MultiCamNode::kSourcesInput, + node.set_standard_value(olive::MultiCamNode::k_current_input, 5); + EXPECT_EQ(node.get_active_elements_at_time(olive::MultiCamNode::k_sources_input, olive::TimeRange()) .mode(), - olive::Node::ActiveElements::kNoElements); + olive::Node::ActiveElements::k_no_elements); - node.SetStandardValue(olive::MultiCamNode::kCurrentInput, -1); - EXPECT_EQ(node.GetActiveElementsAtTime(olive::MultiCamNode::kSourcesInput, + node.set_standard_value(olive::MultiCamNode::k_current_input, -1); + EXPECT_EQ(node.get_active_elements_at_time(olive::MultiCamNode::k_sources_input, olive::TimeRange()) .mode(), - olive::Node::ActiveElements::kNoElements); + olive::Node::ActiveElements::k_no_elements); } TEST(MultiCamNode, RowsAndColumnsGrowToFitSources) @@ -101,12 +101,12 @@ TEST(MultiCamNode, RowsAndColumnsGrowToFitSources) int sources; int rows; int cols; - } kCases[] = { { 1, 1, 1 }, { 2, 1, 2 }, { 3, 2, 2 }, { 4, 2, 2 }, + } k_cases[] = { { 1, 1, 1 }, { 2, 1, 2 }, { 3, 2, 2 }, { 4, 2, 2 }, { 5, 2, 3 }, { 6, 2, 3 }, { 9, 3, 3 }, { 12, 3, 4 } }; - for (const auto &c : kCases) { + for (const auto &c : k_cases) { int rows = 0, cols = 0; - olive::MultiCamNode::GetRowsAndColumns(c.sources, &rows, &cols); + olive::MultiCamNode::get_rows_and_columns(c.sources, &rows, &cols); EXPECT_EQ(rows, c.rows) << "sources=" << c.sources; EXPECT_EQ(cols, c.cols) << "sources=" << c.sources; } @@ -114,7 +114,7 @@ TEST(MultiCamNode, RowsAndColumnsGrowToFitSources) // The grid always fits all sources and stays as square as possible for (int s = 1; s <= 16; s++) { int rows = 0, cols = 0; - olive::MultiCamNode::GetRowsAndColumns(s, &rows, &cols); + olive::MultiCamNode::get_rows_and_columns(s, &rows, &cols); EXPECT_GE(rows * cols, s); EXPECT_LE(rows, cols); } @@ -123,16 +123,16 @@ TEST(MultiCamNode, RowsAndColumnsGrowToFitSources) TEST(MultiCamNode, RowColumnIndexRoundTrip) { int row = -1, col = -1; - olive::MultiCamNode::IndexToRowCols(5, 2, 3, &row, &col); + olive::MultiCamNode::index_to_row_cols(5, 2, 3, &row, &col); EXPECT_EQ(row, 1); EXPECT_EQ(col, 2); - EXPECT_EQ(olive::MultiCamNode::RowsColsToIndex(1, 2, 2, 3), 5); + EXPECT_EQ(olive::MultiCamNode::rows_cols_to_index(1, 2, 2, 3), 5); - const int kRows = 3; - const int kCols = 4; - for (int i = 0; i < kRows * kCols; i++) { - olive::MultiCamNode::IndexToRowCols(i, kRows, kCols, &row, &col); - EXPECT_EQ(olive::MultiCamNode::RowsColsToIndex(row, col, kRows, kCols), + const int k_rows = 3; + const int k_cols = 4; + for (int i = 0; i < k_rows * k_cols; i++) { + olive::MultiCamNode::index_to_row_cols(i, k_rows, k_cols, &row, &col); + EXPECT_EQ(olive::MultiCamNode::rows_cols_to_index(row, col, k_rows, k_cols), i); } } @@ -140,23 +140,23 @@ TEST(MultiCamNode, RowColumnIndexRoundTrip) TEST(MultiCamNode, RetranslateSetsInputNamesAndComboStrings) { olive::MultiCamNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::MultiCamNode::kCurrentInput), + EXPECT_EQ(node.get_input_name(olive::MultiCamNode::k_current_input), QStringLiteral("Current")); - EXPECT_EQ(node.GetInputName(olive::MultiCamNode::kSourcesInput), + EXPECT_EQ(node.get_input_name(olive::MultiCamNode::k_sources_input), QStringLiteral("Sources")); - EXPECT_EQ(node.GetInputName(olive::MultiCamNode::kSequenceInput), + EXPECT_EQ(node.get_input_name(olive::MultiCamNode::k_sequence_input), QStringLiteral("Sequence")); - EXPECT_EQ(node.GetInputName(olive::MultiCamNode::kSequenceTypeInput), + EXPECT_EQ(node.get_input_name(olive::MultiCamNode::k_sequence_type_input), QStringLiteral("Sequence Type")); EXPECT_EQ( - node.GetComboBoxStrings(olive::MultiCamNode::kSequenceTypeInput), + node.get_combo_box_strings(olive::MultiCamNode::k_sequence_type_input), (QStringList{ QStringLiteral("Video"), QStringLiteral("Audio") })); // No sources yet, so no labels - EXPECT_TRUE(node.GetComboBoxStrings(olive::MultiCamNode::kCurrentInput) + EXPECT_TRUE(node.get_combo_box_strings(olive::MultiCamNode::k_current_input) .isEmpty()); } @@ -164,10 +164,10 @@ TEST(MultiCamNode, IgnoreInputsForRenderingSkipsSequenceInput) { olive::MultiCamNode node; - EXPECT_TRUE(node.IgnoreInputsForRendering().contains( - olive::MultiCamNode::kSequenceInput)); - EXPECT_FALSE(node.IgnoreInputsForRendering().contains( - olive::MultiCamNode::kSourcesInput)); + EXPECT_TRUE(node.ignore_inputs_for_rendering().contains( + olive::MultiCamNode::k_sequence_input)); + EXPECT_FALSE(node.ignore_inputs_for_rendering().contains( + olive::MultiCamNode::k_sources_input)); } TEST(MultiCamNode, ValuePushesFirstSourceArrayElement) @@ -175,23 +175,23 @@ TEST(MultiCamNode, ValuePushesFirstSourceArrayElement) olive::MultiCamNode node; olive::NodeValueArray sources; - sources[0] = olive::NodeValue(olive::NodeValue::kText, + sources[0] = olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("cam A"), &node); - sources[1] = olive::NodeValue(olive::NodeValue::kText, + sources[1] = olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("cam B"), &node); olive::NodeValueRow row; - row.insert(olive::MultiCamNode::kSourcesInput, - olive::NodeValue(olive::NodeValue::kNone, + row.insert(olive::MultiCamNode::k_sources_input, + olive::NodeValue(olive::NodeValue::k_none, QVariant::fromValue(sources), &node, true)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); // Value() forwards the first array element; the traverser filters the // array down to the active element before Value() is ever called - ASSERT_EQ(table.Count(), 1); - EXPECT_EQ(table.at(0).toString(), QStringLiteral("cam A")); + ASSERT_EQ(table.count(), 1); + EXPECT_EQ(table.at(0).to_string(), QStringLiteral("cam A")); } TEST(MultiCamNode, ValueWithoutSourcesLeavesTableEmpty) @@ -199,118 +199,118 @@ TEST(MultiCamNode, ValueWithoutSourcesLeavesTableEmpty) olive::MultiCamNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); EXPECT_TRUE(table.isEmpty()); } TEST(MultiCamNode, ConnectedSequenceProvidesTrackSources) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *sequence = new olive::Sequence(); sequence->setParent(&project); auto *node = new olive::MultiCamNode(); node->setParent(&project); - node->SetSequenceType(olive::Track::kVideo); + node->set_sequence_type(olive::Track::k_video); - olive::Node::ConnectEdge( - sequence, olive::NodeInput(node, olive::MultiCamNode::kSequenceInput)); + olive::Node::connect_edge( + sequence, olive::NodeInput(node, olive::MultiCamNode::k_sequence_input)); // Connecting a sequence exposes the type selector - EXPECT_FALSE(node->GetInputFlags(olive::MultiCamNode::kSequenceTypeInput) & - olive::kInputFlagHidden); + EXPECT_FALSE(node->get_input_flags(olive::MultiCamNode::k_sequence_type_input) & + olive::k_input_flag_hidden); // The sequence has no tracks yet - EXPECT_EQ(node->GetSourceCount(), 0); + EXPECT_EQ(node->get_source_count(), 0); - olive::TrackList *video_list = sequence->track_list(olive::Track::kVideo); + olive::TrackList *video_list = sequence->track_list(olive::Track::k_video); - video_list->ArrayAppend(); + video_list->array_append(); auto *track_a = new olive::Track(); track_a->setParent(&project); - olive::Node::ConnectEdge(track_a, video_list->track_input(0)); + olive::Node::connect_edge(track_a, video_list->track_input(0)); - video_list->ArrayAppend(); + video_list->array_append(); auto *track_b = new olive::Track(); track_b->setParent(&project); - olive::Node::ConnectEdge(track_b, video_list->track_input(1)); + olive::Node::connect_edge(track_b, video_list->track_input(1)); // Sources are now pulled from the sequence's track list - ASSERT_EQ(node->GetSourceCount(), 2); - EXPECT_EQ(node->GetConnectedRenderOutput(olive::MultiCamNode::kSourcesInput, + ASSERT_EQ(node->get_source_count(), 2); + EXPECT_EQ(node->get_connected_render_output(olive::MultiCamNode::k_sources_input, 0), track_a); - EXPECT_EQ(node->GetConnectedRenderOutput(olive::MultiCamNode::kSourcesInput, + EXPECT_EQ(node->get_connected_render_output(olive::MultiCamNode::k_sources_input, 1), track_b); EXPECT_TRUE( - node->IsInputConnectedForRender(olive::MultiCamNode::kSourcesInput, 0)); + node->is_input_connected_for_render(olive::MultiCamNode::k_sources_input, 0)); EXPECT_TRUE( - node->IsInputConnectedForRender(olive::MultiCamNode::kSourcesInput, 1)); + node->is_input_connected_for_render(olive::MultiCamNode::k_sources_input, 1)); // Past the end of the track list the overrides defer to the base class EXPECT_FALSE( - node->IsInputConnectedForRender(olive::MultiCamNode::kSourcesInput, 2)); - EXPECT_EQ(node->GetConnectedRenderOutput(olive::MultiCamNode::kSourcesInput, + node->is_input_connected_for_render(olive::MultiCamNode::k_sources_input, 2)); + EXPECT_EQ(node->get_connected_render_output(olive::MultiCamNode::k_sources_input, 2), nullptr); - node->SetStandardValue(olive::MultiCamNode::kCurrentInput, 1); - olive::Node::ActiveElements active = node->GetActiveElementsAtTime( - olive::MultiCamNode::kSourcesInput, olive::TimeRange()); - EXPECT_EQ(active.mode(), olive::Node::ActiveElements::kSpecified); + node->set_standard_value(olive::MultiCamNode::k_current_input, 1); + olive::Node::ActiveElements active = node->get_active_elements_at_time( + olive::MultiCamNode::k_sources_input, olive::TimeRange()); + EXPECT_EQ(active.mode(), olive::Node::ActiveElements::k_specified); ASSERT_EQ(active.elements().size(), 1); EXPECT_EQ(active.elements().front(), 1); // Retranslate names each angle after its track - node->Retranslate(); - EXPECT_EQ(node->GetComboBoxStrings(olive::MultiCamNode::kCurrentInput), + node->retranslate(); + EXPECT_EQ(node->get_combo_box_strings(olive::MultiCamNode::k_current_input), (QStringList{ QStringLiteral("1: Video Track 0"), QStringLiteral("2: Video Track 1") })); // Disconnecting hides the type selector and falls back to the sources array - olive::Node::DisconnectEdge( - sequence, olive::NodeInput(node, olive::MultiCamNode::kSequenceInput)); - EXPECT_TRUE(node->GetInputFlags(olive::MultiCamNode::kSequenceTypeInput) & - olive::kInputFlagHidden); + olive::Node::disconnect_edge( + sequence, olive::NodeInput(node, olive::MultiCamNode::k_sequence_input)); + EXPECT_TRUE(node->get_input_flags(olive::MultiCamNode::k_sequence_type_input) & + olive::k_input_flag_hidden); // With nothing appended to the sources array, it falls back to zero - EXPECT_EQ(node->GetSourceCount(), 0); + EXPECT_EQ(node->get_source_count(), 0); } TEST(MultiCamNode, SequenceTypeSelectsTrackList) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *sequence = new olive::Sequence(); sequence->setParent(&project); auto *node = new olive::MultiCamNode(); node->setParent(&project); - olive::Node::ConnectEdge( - sequence, olive::NodeInput(node, olive::MultiCamNode::kSequenceInput)); + olive::Node::connect_edge( + sequence, olive::NodeInput(node, olive::MultiCamNode::k_sequence_input)); - node->SetSequenceType(olive::Track::kAudio); - EXPECT_EQ(node->GetSourceCount(), 0); + node->set_sequence_type(olive::Track::k_audio); + EXPECT_EQ(node->get_source_count(), 0); - olive::TrackList *audio_list = sequence->track_list(olive::Track::kAudio); - audio_list->ArrayAppend(); + olive::TrackList *audio_list = sequence->track_list(olive::Track::k_audio); + audio_list->array_append(); auto *track = new olive::Track(); track->setParent(&project); - olive::Node::ConnectEdge(track, audio_list->track_input(0)); + olive::Node::connect_edge(track, audio_list->track_input(0)); - EXPECT_EQ(node->GetSourceCount(), 1); - EXPECT_EQ(node->GetConnectedRenderOutput(olive::MultiCamNode::kSourcesInput, + EXPECT_EQ(node->get_source_count(), 1); + EXPECT_EQ(node->get_connected_render_output(olive::MultiCamNode::k_sources_input, 0), track); // Switching the type swaps which track list feeds the sources - node->SetSequenceType(olive::Track::kVideo); - EXPECT_EQ(node->GetSourceCount(), 0); + node->set_sequence_type(olive::Track::k_video); + EXPECT_EQ(node->get_source_count(), 0); } TEST(FootageDescription, DefaultStateIsInvalid) @@ -318,79 +318,79 @@ TEST(FootageDescription, DefaultStateIsInvalid) olive::FootageDescription desc; EXPECT_TRUE(desc.decoder().isEmpty()); - EXPECT_EQ(desc.GetStreamCount(), 0); - EXPECT_TRUE(desc.GetVideoStreams().isEmpty()); - EXPECT_TRUE(desc.GetAudioStreams().isEmpty()); - EXPECT_TRUE(desc.GetSubtitleStreams().isEmpty()); - EXPECT_FALSE(desc.HasSourceStartTime()); - EXPECT_FALSE(desc.IsValid()); + EXPECT_EQ(desc.get_stream_count(), 0); + EXPECT_TRUE(desc.get_video_streams().isEmpty()); + EXPECT_TRUE(desc.get_audio_streams().isEmpty()); + EXPECT_TRUE(desc.get_subtitle_streams().isEmpty()); + EXPECT_FALSE(desc.has_source_start_time()); + EXPECT_FALSE(desc.is_valid()); } TEST(FootageDescription, ValidityRequiresDecoderAndStream) { - olive::VideoParams video(640, 480, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams video(640, 480, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); video.set_stream_index(0); // A stream without a decoder name is not enough olive::FootageDescription no_decoder; - no_decoder.AddVideoStream(video); - EXPECT_FALSE(no_decoder.IsValid()); + no_decoder.add_video_stream(video); + EXPECT_FALSE(no_decoder.is_valid()); // A decoder without any stream is not enough either olive::FootageDescription desc(QStringLiteral("fakedecoder")); - EXPECT_FALSE(desc.IsValid()); + EXPECT_FALSE(desc.is_valid()); - desc.AddVideoStream(video); - EXPECT_TRUE(desc.IsValid()); + desc.add_video_stream(video); + EXPECT_TRUE(desc.is_valid()); } TEST(FootageDescription, StreamTypeLookup) { olive::FootageDescription desc(QStringLiteral("fakedecoder")); - olive::VideoParams video(1920, 1080, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams video(1920, 1080, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); video.set_stream_index(0); - desc.AddVideoStream(video); + desc.add_video_stream(video); - olive::core::AudioParams audio(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + olive::core::AudioParams audio(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); audio.set_stream_index(1); - desc.AddAudioStream(audio); + desc.add_audio_stream(audio); olive::SubtitleParams subs; subs.set_stream_index(2); - subs.push_back(olive::Subtitle(olive::TimeRange(olive::rational(0), - olive::rational(3)), + subs.push_back(olive::Subtitle(olive::TimeRange(olive::Rational(0), + olive::Rational(3)), QStringLiteral("subtitle text"))); - desc.AddSubtitleStream(subs); + desc.add_subtitle_stream(subs); - desc.SetStreamCount(3); + desc.set_stream_count(3); EXPECT_EQ(desc.decoder(), QStringLiteral("fakedecoder")); - EXPECT_EQ(desc.GetStreamCount(), 3); + EXPECT_EQ(desc.get_stream_count(), 3); - EXPECT_TRUE(desc.StreamIsVideo(0)); - EXPECT_FALSE(desc.StreamIsVideo(1)); - EXPECT_TRUE(desc.StreamIsAudio(1)); - EXPECT_FALSE(desc.StreamIsAudio(2)); - EXPECT_TRUE(desc.StreamIsSubtitle(2)); - EXPECT_FALSE(desc.StreamIsSubtitle(0)); + EXPECT_TRUE(desc.stream_is_video(0)); + EXPECT_FALSE(desc.stream_is_video(1)); + EXPECT_TRUE(desc.stream_is_audio(1)); + EXPECT_FALSE(desc.stream_is_audio(2)); + EXPECT_TRUE(desc.stream_is_subtitle(2)); + EXPECT_FALSE(desc.stream_is_subtitle(0)); - EXPECT_TRUE(desc.HasStreamIndex(0)); - EXPECT_TRUE(desc.HasStreamIndex(1)); - EXPECT_TRUE(desc.HasStreamIndex(2)); - EXPECT_FALSE(desc.HasStreamIndex(3)); + EXPECT_TRUE(desc.has_stream_index(0)); + EXPECT_TRUE(desc.has_stream_index(1)); + EXPECT_TRUE(desc.has_stream_index(2)); + EXPECT_FALSE(desc.has_stream_index(3)); - EXPECT_EQ(desc.GetTypeOfStream(0), olive::Track::kVideo); - EXPECT_EQ(desc.GetTypeOfStream(1), olive::Track::kAudio); - EXPECT_EQ(desc.GetTypeOfStream(2), olive::Track::kSubtitle); - EXPECT_EQ(desc.GetTypeOfStream(99), olive::Track::kNone); + EXPECT_EQ(desc.get_type_of_stream(0), olive::Track::k_video); + EXPECT_EQ(desc.get_type_of_stream(1), olive::Track::k_audio); + EXPECT_EQ(desc.get_type_of_stream(2), olive::Track::k_subtitle); + EXPECT_EQ(desc.get_type_of_stream(99), olive::Track::k_none); - ASSERT_EQ(desc.GetVideoStreams().size(), 1); - ASSERT_EQ(desc.GetAudioStreams().size(), 1); - ASSERT_EQ(desc.GetSubtitleStreams().size(), 1); + ASSERT_EQ(desc.get_video_streams().size(), 1); + ASSERT_EQ(desc.get_audio_streams().size(), 1); + ASSERT_EQ(desc.get_subtitle_streams().size(), 1); } TEST(FootageDescription, SaveLoadRoundTrip) @@ -402,77 +402,77 @@ TEST(FootageDescription, SaveLoadRoundTrip) olive::FootageDescription desc(QStringLiteral("fakedecoder")); - olive::VideoParams video(1920, 1080, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams video(1920, 1080, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); video.set_stream_index(0); video.set_duration(48); - desc.AddVideoStream(video); + desc.add_video_stream(video); - olive::core::AudioParams audio(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + olive::core::AudioParams audio(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); audio.set_stream_index(1); audio.set_duration(96000); - desc.AddAudioStream(audio); + desc.add_audio_stream(audio); olive::SubtitleParams subs; subs.set_stream_index(2); - subs.push_back(olive::Subtitle(olive::TimeRange(olive::rational(0), - olive::rational(3)), + subs.push_back(olive::Subtitle(olive::TimeRange(olive::Rational(0), + olive::Rational(3)), QStringLiteral("subtitle text"))); - desc.AddSubtitleStream(subs); + desc.add_subtitle_stream(subs); - desc.SetStreamCount(3); + desc.set_stream_count(3); - ASSERT_TRUE(desc.Save(path)); + ASSERT_TRUE(desc.save(path)); olive::FootageDescription loaded; - ASSERT_TRUE(loaded.Load(path)); + ASSERT_TRUE(loaded.load(path)); - EXPECT_TRUE(loaded.IsValid()); + EXPECT_TRUE(loaded.is_valid()); EXPECT_EQ(loaded.decoder(), QStringLiteral("fakedecoder")); - EXPECT_EQ(loaded.GetStreamCount(), 3); + EXPECT_EQ(loaded.get_stream_count(), 3); - ASSERT_EQ(loaded.GetVideoStreams().size(), 1); - const olive::VideoParams &loaded_video = loaded.GetVideoStreams().first(); + ASSERT_EQ(loaded.get_video_streams().size(), 1); + const olive::VideoParams &loaded_video = loaded.get_video_streams().first(); EXPECT_EQ(loaded_video.width(), 1920); EXPECT_EQ(loaded_video.height(), 1080); EXPECT_EQ(loaded_video.stream_index(), 0); EXPECT_EQ(loaded_video.duration(), video.duration()); EXPECT_EQ(loaded_video.time_base(), video.time_base()); - ASSERT_EQ(loaded.GetAudioStreams().size(), 1); + ASSERT_EQ(loaded.get_audio_streams().size(), 1); const olive::core::AudioParams &loaded_audio = - loaded.GetAudioStreams().first(); + loaded.get_audio_streams().first(); EXPECT_EQ(loaded_audio.sample_rate(), 48000); - EXPECT_EQ(loaded_audio.channel_layout(), olive::core::kChannelLayoutStereo); + EXPECT_EQ(loaded_audio.channel_layout(), olive::core::k_channel_layout_stereo); EXPECT_EQ(loaded_audio.stream_index(), 1); EXPECT_EQ(loaded_audio.duration(), audio.duration()); - ASSERT_EQ(loaded.GetSubtitleStreams().size(), 1); + ASSERT_EQ(loaded.get_subtitle_streams().size(), 1); const olive::SubtitleParams &loaded_subs = - loaded.GetSubtitleStreams().first(); + loaded.get_subtitle_streams().first(); EXPECT_EQ(loaded_subs.stream_index(), 2); ASSERT_EQ(loaded_subs.size(), 1); EXPECT_EQ(loaded_subs.front().text(), QStringLiteral("subtitle text")); - EXPECT_EQ(loaded_subs.front().time().out(), olive::rational(3)); + EXPECT_EQ(loaded_subs.front().time().out(), olive::Rational(3)); } TEST(FootageDescription, LoadMissingFileFailsAndResetsState) { olive::FootageDescription desc(QStringLiteral("stale")); - olive::VideoParams video(640, 480, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams video(640, 480, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); video.set_stream_index(0); - desc.AddVideoStream(video); - ASSERT_TRUE(desc.IsValid()); + desc.add_video_stream(video); + ASSERT_TRUE(desc.is_valid()); EXPECT_FALSE( - desc.Load(QStringLiteral("/definitely/nonexistent/cache.xml"))); + desc.load(QStringLiteral("/definitely/nonexistent/cache.xml"))); // A failed load must not leave stale streams behind EXPECT_TRUE(desc.decoder().isEmpty()); - EXPECT_TRUE(desc.GetVideoStreams().isEmpty()); - EXPECT_FALSE(desc.IsValid()); + EXPECT_TRUE(desc.get_video_streams().isEmpty()); + EXPECT_FALSE(desc.is_valid()); } TEST(FootageDescription, LoadRejectsMismatchedVersion) @@ -490,23 +490,23 @@ TEST(FootageDescription, LoadRejectsMismatchedVersion) file.close(); olive::FootageDescription desc(QStringLiteral("stale")); - olive::VideoParams video(640, 480, olive::rational(1, 24), - olive::core::PixelFormat::U8, 4); + olive::VideoParams video(640, 480, olive::Rational(1, 24), + olive::core::PixelFormat::u8, 4); video.set_stream_index(0); - desc.AddVideoStream(video); + desc.add_video_stream(video); - EXPECT_FALSE(desc.Load(path)); + EXPECT_FALSE(desc.load(path)); EXPECT_TRUE(desc.decoder().isEmpty()); - EXPECT_FALSE(desc.IsValid()); + EXPECT_FALSE(desc.is_valid()); } TEST(ProjectSerializer, FileRoundTripPreservesMultiCamNode) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); bool created_disk_manager = false; - EnsureDiskManager(&created_disk_manager); - olive::NodeFactory::Initialize(); - olive::ProjectSerializer::Initialize(); + ensure_disk_manager(&created_disk_manager); + olive::NodeFactory::initialize(); + olive::ProjectSerializer::initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); @@ -514,18 +514,18 @@ TEST(ProjectSerializer, FileRoundTripPreservesMultiCamNode) QDir(dir.path()).filePath(QStringLiteral("multicam.ove")); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::MultiCamNode(); - node->SetLabel(QStringLiteral("Angles")); - node->SetStandardValue(olive::MultiCamNode::kCurrentInput, 2); + node->set_label(QStringLiteral("Angles")); + node->set_standard_value(olive::MultiCamNode::k_current_input, 2); node->setParent(&project); olive::ProjectSerializer::Result save_result = - olive::ProjectSerializer::Save(olive::ProjectSerializer::SaveData( - olive::ProjectSerializer::kProject, + olive::ProjectSerializer::save(olive::ProjectSerializer::SaveData( + olive::ProjectSerializer::k_project, &project, filename), false); - ASSERT_EQ(save_result.code(), olive::ProjectSerializer::kSuccess); + ASSERT_EQ(save_result.code(), olive::ProjectSerializer::k_success); ASSERT_TRUE(QFile::exists(filename)); // An uncompressed project is plain XML @@ -536,9 +536,9 @@ TEST(ProjectSerializer, FileRoundTripPreservesMultiCamNode) olive::Project loaded_project; olive::ProjectSerializer::Result load_result = - olive::ProjectSerializer::Load(&loaded_project, filename, - olive::ProjectSerializer::kProject); - ASSERT_EQ(load_result.code(), olive::ProjectSerializer::kSuccess); + olive::ProjectSerializer::load(&loaded_project, filename, + olive::ProjectSerializer::k_project); + ASSERT_EQ(load_result.code(), olive::ProjectSerializer::k_success); olive::MultiCamNode *loaded_node = nullptr; foreach (olive::Node *n, loaded_project.nodes()) { @@ -547,21 +547,21 @@ TEST(ProjectSerializer, FileRoundTripPreservesMultiCamNode) } } ASSERT_NE(loaded_node, nullptr); - EXPECT_EQ(loaded_node->GetLabel(), QStringLiteral("Angles")); - EXPECT_EQ(loaded_node->GetCurrentSource(), 2); + EXPECT_EQ(loaded_node->get_label(), QStringLiteral("Angles")); + EXPECT_EQ(loaded_node->get_current_source(), 2); - olive::ProjectSerializer::Destroy(); - olive::NodeFactory::Destroy(); - ReleaseDiskManager(created_disk_manager); + olive::ProjectSerializer::destroy(); + olive::NodeFactory::destroy(); + release_disk_manager(created_disk_manager); } TEST(ProjectSerializer, CompressedFileRoundTrip) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); bool created_disk_manager = false; - EnsureDiskManager(&created_disk_manager); - olive::NodeFactory::Initialize(); - olive::ProjectSerializer::Initialize(); + ensure_disk_manager(&created_disk_manager); + olive::NodeFactory::initialize(); + olive::ProjectSerializer::initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); @@ -569,17 +569,17 @@ TEST(ProjectSerializer, CompressedFileRoundTrip) QDir(dir.path()).filePath(QStringLiteral("compressed.ove")); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::MultiCamNode(); - node->SetLabel(QStringLiteral("Compressed")); + node->set_label(QStringLiteral("Compressed")); node->setParent(&project); olive::ProjectSerializer::Result save_result = - olive::ProjectSerializer::Save(olive::ProjectSerializer::SaveData( - olive::ProjectSerializer::kProject, + olive::ProjectSerializer::save(olive::ProjectSerializer::SaveData( + olive::ProjectSerializer::k_project, &project, filename), true); - ASSERT_EQ(save_result.code(), olive::ProjectSerializer::kSuccess); + ASSERT_EQ(save_result.code(), olive::ProjectSerializer::k_success); // Compressed projects are marked with the OVEC signature QFile raw(filename); @@ -589,41 +589,41 @@ TEST(ProjectSerializer, CompressedFileRoundTrip) olive::Project loaded_project; olive::ProjectSerializer::Result load_result = - olive::ProjectSerializer::Load(&loaded_project, filename, - olive::ProjectSerializer::kProject); - ASSERT_EQ(load_result.code(), olive::ProjectSerializer::kSuccess); + olive::ProjectSerializer::load(&loaded_project, filename, + olive::ProjectSerializer::k_project); + ASSERT_EQ(load_result.code(), olive::ProjectSerializer::k_success); bool found = false; foreach (olive::Node *n, loaded_project.nodes()) { if (dynamic_cast(n)) { found = true; - EXPECT_EQ(n->GetLabel(), QStringLiteral("Compressed")); + EXPECT_EQ(n->get_label(), QStringLiteral("Compressed")); break; } } EXPECT_TRUE(found); - olive::ProjectSerializer::Destroy(); - olive::NodeFactory::Destroy(); - ReleaseDiskManager(created_disk_manager); + olive::ProjectSerializer::destroy(); + olive::NodeFactory::destroy(); + release_disk_manager(created_disk_manager); } TEST(ProjectSerializer, LoadNonexistentFileFails) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - olive::ProjectSerializer::Result result = olive::ProjectSerializer::Load( + olive::ProjectSerializer::Result result = olive::ProjectSerializer::load( &project, QStringLiteral("/definitely/nonexistent/project.ove"), - olive::ProjectSerializer::kProject); + olive::ProjectSerializer::k_project); - EXPECT_EQ(result.code(), olive::ProjectSerializer::kFileError); - EXPECT_FALSE(result.GetDetails().isEmpty()); + EXPECT_EQ(result.code(), olive::ProjectSerializer::k_file_error); + EXPECT_FALSE(result.get_details().isEmpty()); } TEST(ProjectSerializer, LoadGarbageXmlReportsUnknownVersion) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); @@ -635,55 +635,55 @@ TEST(ProjectSerializer, LoadGarbageXmlReportsUnknownVersion) file.close(); olive::Project project; - olive::ProjectSerializer::Result result = olive::ProjectSerializer::Load( - &project, filename, olive::ProjectSerializer::kProject); + olive::ProjectSerializer::Result result = olive::ProjectSerializer::load( + &project, filename, olive::ProjectSerializer::k_project); - EXPECT_EQ(result.code(), olive::ProjectSerializer::kUnknownVersion); + EXPECT_EQ(result.code(), olive::ProjectSerializer::k_unknown_version); } TEST(ProjectSerializer, LoadOlderVersionReportsTooOld) { - olive::ProjectSerializer::Initialize(); + olive::ProjectSerializer::initialize(); // 190219 predates every registered serializer QXmlStreamReader reader( QStringLiteral("")); - olive::ProjectSerializer::Result result = olive::ProjectSerializer::Load( - nullptr, &reader, olive::ProjectSerializer::kOnlyNodes); + olive::ProjectSerializer::Result result = olive::ProjectSerializer::load( + nullptr, &reader, olive::ProjectSerializer::k_only_nodes); - EXPECT_EQ(result.code(), olive::ProjectSerializer::kProjectTooOld); + EXPECT_EQ(result.code(), olive::ProjectSerializer::k_project_too_old); - olive::ProjectSerializer::Destroy(); + olive::ProjectSerializer::destroy(); } TEST(ProjectSerializer, LoadNewerVersionReportsTooNew) { - olive::ProjectSerializer::Initialize(); + olive::ProjectSerializer::initialize(); QXmlStreamReader reader( QStringLiteral("")); - olive::ProjectSerializer::Result result = olive::ProjectSerializer::Load( - nullptr, &reader, olive::ProjectSerializer::kOnlyNodes); + olive::ProjectSerializer::Result result = olive::ProjectSerializer::load( + nullptr, &reader, olive::ProjectSerializer::k_only_nodes); - EXPECT_EQ(result.code(), olive::ProjectSerializer::kProjectTooNew); + EXPECT_EQ(result.code(), olive::ProjectSerializer::k_project_too_new); - olive::ProjectSerializer::Destroy(); + olive::ProjectSerializer::destroy(); } TEST(ProjectSerializer, LoadWithoutVersionReportsUnknown) { // A project element without a version attribute QXmlStreamReader no_version(QStringLiteral("")); - olive::ProjectSerializer::Result result = olive::ProjectSerializer::Load( - nullptr, &no_version, olive::ProjectSerializer::kOnlyNodes); - EXPECT_EQ(result.code(), olive::ProjectSerializer::kUnknownVersion); + olive::ProjectSerializer::Result result = olive::ProjectSerializer::load( + nullptr, &no_version, olive::ProjectSerializer::k_only_nodes); + EXPECT_EQ(result.code(), olive::ProjectSerializer::k_unknown_version); // No recognizable root element at all QXmlStreamReader wrong_root( QStringLiteral("")); - result = olive::ProjectSerializer::Load( - nullptr, &wrong_root, olive::ProjectSerializer::kOnlyNodes); - EXPECT_EQ(result.code(), olive::ProjectSerializer::kUnknownVersion); + result = olive::ProjectSerializer::load( + nullptr, &wrong_root, olive::ProjectSerializer::k_only_nodes); + EXPECT_EQ(result.code(), olive::ProjectSerializer::k_unknown_version); } TEST(ProjectSerializer, CheckCompressedIDDetectsSignature) @@ -701,7 +701,7 @@ TEST(ProjectSerializer, CheckCompressedIDDetectsSignature) QFile check(compressed); ASSERT_TRUE(check.open(QFile::ReadOnly)); - EXPECT_TRUE(olive::ProjectSerializer::CheckCompressedID(&check)); + EXPECT_TRUE(olive::ProjectSerializer::check_compressed_id(&check)); check.close(); const QString plain = @@ -713,29 +713,29 @@ TEST(ProjectSerializer, CheckCompressedIDDetectsSignature) QFile check_plain(plain); ASSERT_TRUE(check_plain.open(QFile::ReadOnly)); - EXPECT_FALSE(olive::ProjectSerializer::CheckCompressedID(&check_plain)); + EXPECT_FALSE(olive::ProjectSerializer::check_compressed_id(&check_plain)); check_plain.close(); } TEST(ProjectSerializer, SaveToInvalidDirectoryFails) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); bool created_disk_manager = false; - EnsureDiskManager(&created_disk_manager); - olive::ProjectSerializer::Initialize(); + ensure_disk_manager(&created_disk_manager); + olive::ProjectSerializer::initialize(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::ProjectSerializer::Result result = olive::ProjectSerializer::Save( + olive::ProjectSerializer::Result result = olive::ProjectSerializer::save( olive::ProjectSerializer::SaveData( - olive::ProjectSerializer::kProject, &project, + olive::ProjectSerializer::k_project, &project, QStringLiteral("/definitely/nonexistent/project.ove")), false); - EXPECT_EQ(result.code(), olive::ProjectSerializer::kFileError); - EXPECT_FALSE(result.GetDetails().isEmpty()); + EXPECT_EQ(result.code(), olive::ProjectSerializer::k_file_error); + EXPECT_FALSE(result.get_details().isEmpty()); - olive::ProjectSerializer::Destroy(); - ReleaseDiskManager(created_disk_manager); + olive::ProjectSerializer::destroy(); + release_disk_manager(created_disk_manager); } diff --git a/tests/gtest/node_audio_test.cpp b/tests/gtest/node_audio_test.cpp index 287a73618..9c5e8f288 100644 --- a/tests/gtest/node_audio_test.cpp +++ b/tests/gtest/node_audio_test.cpp @@ -31,7 +31,7 @@ public: NODE_DEFAULT_FUNCTIONS(ConstantValueNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Test Constant"); } @@ -41,24 +41,24 @@ public: return QStringLiteral("org.oak.test.constant"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryGenerator }; + return { k_category_generator }; } - void SetOutput(const olive::NodeValue &value) + void set_output(const olive::NodeValue &value) { output_ = value; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { Q_UNUSED(value) Q_UNUSED(globals) - table->Push(output_); + table->push(output_); } private: @@ -69,20 +69,20 @@ private: // non-static (job) paths of the audio nodes can be verified end to end. class SampleResolvingTraverser : public olive::NodeTraverser { public: - void Resolve(olive::NodeValue &value) + void resolve(olive::NodeValue &value) { - ResolveJobs(value); + resolve_jobs(value); } protected: virtual olive::core::SampleBuffer - CreateSampleBuffer(const olive::core::AudioParams ¶ms, + create_sample_buffer(const olive::core::AudioParams ¶ms, int sample_count) override { return olive::core::SampleBuffer(params, size_t(sample_count)); } - virtual void ProcessSamples(olive::core::SampleBuffer &destination, + virtual void process_samples(olive::core::SampleBuffer &destination, const olive::Node *node, const olive::TimeRange &range, const olive::SampleJob &job) override @@ -90,66 +90,66 @@ protected: Q_UNUSED(range) for (size_t i = 0; i < destination.sample_count(); i++) { - node->ProcessSamples(job.GetValues(), job.samples(), destination, + node->process_samples(job.get_values(), job.samples(), destination, int(i)); } } }; -template T *AddNode(olive::Project *project) +template T *add_node(olive::Project *project) { T *node = new T(); node->setParent(project); return node; } -ConstantValueNode *AddConstant(olive::Project *project, +ConstantValueNode *add_constant(olive::Project *project, const olive::NodeValue &value) { auto *node = new ConstantValueNode(); node->setParent(project); - node->SetOutput(value); + node->set_output(value); return node; } -olive::NodeKeyframe *AddKey(olive::Node *node, const QString &input, - const olive::core::rational &time, +olive::NodeKeyframe *add_key(olive::Node *node, const QString &input, + const olive::core::Rational &time, const QVariant &value) { auto *key = new olive::NodeKeyframe( - time, value, olive::NodeKeyframe::kLinear, 0, -1, input); + time, value, olive::NodeKeyframe::k_linear, 0, -1, input); key->setParent(node); return key; } // A fresh traverser per call: NodeTraverser caches tables per node+range, so // reusing one would return stale results after the node's parameters change. -olive::NodeValueTable GenerateTableAt(const olive::Node *node, - const olive::core::rational &time) +olive::NodeValueTable generate_table_at(const olive::Node *node, + const olive::core::Rational &time) { olive::NodeTraverser traverser; - return traverser.GenerateTable( - node, olive::TimeRange(time, time + olive::core::rational(1, 30))); + return traverser.generate_table( + node, olive::TimeRange(time, time + olive::core::Rational(1, 30))); } -olive::core::AudioParams StereoParams() +olive::core::AudioParams stereo_params() { - return olive::core::AudioParams(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + return olive::core::AudioParams(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); } -olive::core::AudioParams MonoParams() +olive::core::AudioParams mono_params() { - return olive::core::AudioParams(48000, olive::core::kChannelLayoutMono, - olive::core::SampleFormat::F32P); + return olive::core::AudioParams(48000, olive::core::k_channel_layout_mono, + olive::core::SampleFormat::f32_p); } // Creates a stereo buffer with the given per-channel samples. Both channels // must have the same number of samples. -olive::core::SampleBuffer MakeStereoBuffer(const std::vector &channel0, +olive::core::SampleBuffer make_stereo_buffer(const std::vector &channel0, const std::vector &channel1) { - olive::core::SampleBuffer buffer(StereoParams(), channel0.size()); + olive::core::SampleBuffer buffer(stereo_params(), channel0.size()); for (size_t i = 0; i < channel0.size(); i++) { buffer.data(0)[i] = channel0[i]; } @@ -159,30 +159,30 @@ olive::core::SampleBuffer MakeStereoBuffer(const std::vector &channel0, return buffer; } -olive::core::SampleBuffer MakeMonoBuffer(const std::vector &samples) +olive::core::SampleBuffer make_mono_buffer(const std::vector &samples) { - olive::core::SampleBuffer buffer(MonoParams(), samples.size()); + olive::core::SampleBuffer buffer(mono_params(), samples.size()); for (size_t i = 0; i < samples.size(); i++) { buffer.data(0)[i] = samples[i]; } return buffer; } -olive::NodeValue SampleValue(const olive::core::SampleBuffer &buffer) +olive::NodeValue sample_value(const olive::core::SampleBuffer &buffer) { - return olive::NodeValue(olive::NodeValue::kSamples, + return olive::NodeValue(olive::NodeValue::k_samples, QVariant::fromValue(buffer)); } // Connects a stereo buffer {1,2,3,4}/{5,6,7,8} to the node's samples input. -ConstantValueNode *ConnectTestSamples(olive::Project *project, +ConstantValueNode *connect_test_samples(olive::Project *project, olive::Node *node, const QString &samples_input) { - ConstantValueNode *samples = AddConstant( - project, SampleValue(MakeStereoBuffer({ 1.0f, 2.0f, 3.0f, 4.0f }, + ConstantValueNode *samples = add_constant( + project, sample_value(make_stereo_buffer({ 1.0f, 2.0f, 3.0f, 4.0f }, { 5.0f, 6.0f, 7.0f, 8.0f }))); - olive::Node::ConnectEdge(samples, olive::NodeInput(node, samples_input)); + olive::Node::connect_edge(samples, olive::NodeInput(node, samples_input)); return samples; } @@ -192,69 +192,69 @@ TEST(PanNode, Metadata) { olive::PanNode pan; - EXPECT_EQ(pan.Name(), QStringLiteral("Pan")); + EXPECT_EQ(pan.name(), QStringLiteral("Pan")); EXPECT_EQ(pan.id(), QStringLiteral("org.olivevideoeditor.Olive.pan")); - EXPECT_FALSE(pan.Description().isEmpty()); - EXPECT_TRUE(pan.Category().contains(olive::Node::kCategoryFilter)); + EXPECT_FALSE(pan.description().isEmpty()); + EXPECT_TRUE(pan.category().contains(olive::Node::k_category_filter)); // Registered as an audio effect with the samples input as effect input - EXPECT_TRUE(pan.GetFlags() & olive::Node::kAudioEffect); - EXPECT_EQ(pan.GetEffectInputID(), olive::PanNode::kSamplesInput); + EXPECT_TRUE(pan.get_flags() & olive::Node::k_audio_effect); + EXPECT_EQ(pan.get_effect_input_id(), olive::PanNode::k_samples_input); } TEST(PanNode, InputDefaults) { olive::PanNode pan; - EXPECT_EQ(pan.GetInputDataType(olive::PanNode::kSamplesInput), - olive::NodeValue::kSamples); - EXPECT_FALSE(pan.IsInputKeyframable(olive::PanNode::kSamplesInput)); - EXPECT_TRUE(pan.IsInputConnectable(olive::PanNode::kSamplesInput)); + EXPECT_EQ(pan.get_input_data_type(olive::PanNode::k_samples_input), + olive::NodeValue::k_samples); + EXPECT_FALSE(pan.is_input_keyframable(olive::PanNode::k_samples_input)); + EXPECT_TRUE(pan.is_input_connectable(olive::PanNode::k_samples_input)); - EXPECT_EQ(pan.GetInputDataType(olive::PanNode::kPanningInput), - olive::NodeValue::kFloat); - EXPECT_TRUE(pan.IsInputKeyframable(olive::PanNode::kPanningInput)); + EXPECT_EQ(pan.get_input_data_type(olive::PanNode::k_panning_input), + olive::NodeValue::k_float); + EXPECT_TRUE(pan.is_input_keyframable(olive::PanNode::k_panning_input)); EXPECT_DOUBLE_EQ( - pan.GetStandardValue(olive::PanNode::kPanningInput).toDouble(), 0.0); - EXPECT_DOUBLE_EQ(pan.GetInputProperty(olive::PanNode::kPanningInput, + pan.get_standard_value(olive::PanNode::k_panning_input).toDouble(), 0.0); + EXPECT_DOUBLE_EQ(pan.get_input_property(olive::PanNode::k_panning_input, QStringLiteral("min")) .toDouble(), -1.0); - EXPECT_DOUBLE_EQ(pan.GetInputProperty(olive::PanNode::kPanningInput, + EXPECT_DOUBLE_EQ(pan.get_input_property(olive::PanNode::k_panning_input, QStringLiteral("max")) .toDouble(), 1.0); - EXPECT_EQ(int(pan.GetInputProperty(olive::PanNode::kPanningInput, + EXPECT_EQ(int(pan.get_input_property(olive::PanNode::k_panning_input, QStringLiteral("view")) .toInt()), - int(olive::FloatSlider::kPercentage)); + int(olive::FloatSlider::k_percentage)); } TEST(PanNode, RetranslateSetsInputNames) { olive::PanNode pan; - pan.Retranslate(); + pan.retranslate(); - EXPECT_EQ(pan.GetInputName(olive::PanNode::kSamplesInput), + EXPECT_EQ(pan.get_input_name(olive::PanNode::k_samples_input), QStringLiteral("Samples")); - EXPECT_EQ(pan.GetInputName(olive::PanNode::kPanningInput), + EXPECT_EQ(pan.get_input_name(olive::PanNode::k_panning_input), QStringLiteral("Pan")); } TEST(PanNode, StaticCenterPanLeavesSamplesUnchanged) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::PanNode *pan = AddNode(&project); - ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput); + olive::PanNode *pan = add_node(&project); + connect_test_samples(&project, pan, olive::PanNode::k_samples_input); // Pan 0 is a no-op, but the (unmodified) buffer is still pushed - const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0)); + const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0)); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); ASSERT_EQ(out.sample_count(), 4u); for (int i = 0; i < 4; i++) { @@ -265,17 +265,17 @@ TEST(PanNode, StaticCenterPanLeavesSamplesUnchanged) TEST(PanNode, StaticRightPanAttenuatesLeftChannel) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::PanNode *pan = AddNode(&project); - pan->SetStandardValue(olive::PanNode::kPanningInput, 0.5); - ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput); + olive::PanNode *pan = add_node(&project); + pan->set_standard_value(olive::PanNode::k_panning_input, 0.5); + connect_test_samples(&project, pan, olive::PanNode::k_samples_input); - const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0)); + const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0)); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); for (int i = 0; i < 4; i++) { EXPECT_FLOAT_EQ(out.data(0)[i], float(i + 1) * 0.5f); @@ -285,17 +285,17 @@ TEST(PanNode, StaticRightPanAttenuatesLeftChannel) TEST(PanNode, StaticLeftPanAttenuatesRightChannel) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::PanNode *pan = AddNode(&project); - pan->SetStandardValue(olive::PanNode::kPanningInput, -0.5); - ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput); + olive::PanNode *pan = add_node(&project); + pan->set_standard_value(olive::PanNode::k_panning_input, -0.5); + connect_test_samples(&project, pan, olive::PanNode::k_samples_input); - const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0)); + const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0)); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); for (int i = 0; i < 4; i++) { EXPECT_FLOAT_EQ(out.data(0)[i], float(i + 1)); @@ -305,17 +305,17 @@ TEST(PanNode, StaticLeftPanAttenuatesRightChannel) TEST(PanNode, StaticFullRightPanSilencesLeftChannel) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::PanNode *pan = AddNode(&project); - pan->SetStandardValue(olive::PanNode::kPanningInput, 1.0); - ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput); + olive::PanNode *pan = add_node(&project); + pan->set_standard_value(olive::PanNode::k_panning_input, 1.0); + connect_test_samples(&project, pan, olive::PanNode::k_samples_input); - const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0)); + const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0)); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); for (int i = 0; i < 4; i++) { EXPECT_FLOAT_EQ(out.data(0)[i], 0.0f); @@ -325,22 +325,22 @@ TEST(PanNode, StaticFullRightPanSilencesLeftChannel) TEST(PanNode, NonStereoSamplesPassThroughUnchanged) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::PanNode *pan = AddNode(&project); - pan->SetStandardValue(olive::PanNode::kPanningInput, 0.5); + olive::PanNode *pan = add_node(&project); + pan->set_standard_value(olive::PanNode::k_panning_input, 0.5); - ConstantValueNode *samples = AddConstant( - &project, SampleValue(MakeMonoBuffer({ 1.0f, -2.0f, 3.0f }))); - olive::Node::ConnectEdge( - samples, olive::NodeInput(pan, olive::PanNode::kSamplesInput)); + ConstantValueNode *samples = add_constant( + &project, sample_value(make_mono_buffer({ 1.0f, -2.0f, 3.0f }))); + olive::Node::connect_edge( + samples, olive::NodeInput(pan, olive::PanNode::k_samples_input)); // Pan only supports stereo: a mono buffer is pushed through untouched - const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0)); + const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0)); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); ASSERT_EQ(out.audio_params().channel_count(), 1); ASSERT_EQ(out.sample_count(), 3u); @@ -351,50 +351,50 @@ TEST(PanNode, NonStereoSamplesPassThroughUnchanged) TEST(PanNode, NoSamplesInputProducesNoOutput) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::PanNode *pan = AddNode(&project); - pan->SetStandardValue(olive::PanNode::kPanningInput, 0.5); + olive::PanNode *pan = add_node(&project); + pan->set_standard_value(olive::PanNode::k_panning_input, 0.5); // Without an allocated buffer on the samples input, Value() pushes nothing - const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0)); - EXPECT_EQ(table.Get(olive::NodeValue::kSamples).type(), - olive::NodeValue::kNone); + const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0)); + EXPECT_EQ(table.get(olive::NodeValue::k_samples).type(), + olive::NodeValue::k_none); } TEST(PanNode, KeyframedPanProducesSampleJobWithPanValue) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::PanNode *pan = AddNode(&project); - ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput); + olive::PanNode *pan = add_node(&project); + connect_test_samples(&project, pan, olive::PanNode::k_samples_input); // A non-static (keyframed) pan makes Value() push a SampleJob instead of // processing the buffer immediately - pan->SetInputIsKeyframing(olive::PanNode::kPanningInput, true); - AddKey(pan, olive::PanNode::kPanningInput, olive::core::rational(0), 1.0); + pan->set_input_is_keyframing(olive::PanNode::k_panning_input, true); + add_key(pan, olive::PanNode::k_panning_input, olive::core::Rational(0), 1.0); - const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0)); - olive::NodeValue result = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(result.type(), olive::NodeValue::kSamples); + const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0)); + olive::NodeValue result = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(result.type(), olive::NodeValue::k_samples); ASSERT_TRUE(result.canConvert()); // Like VolumeNode, PanNode::Value() inserts the panning value into the // SampleJob so ProcessSamples() sees the keyframed pan const olive::SampleJob job = result.value(); - ASSERT_TRUE(job.GetValues().contains(olive::PanNode::kPanningInput)); - EXPECT_DOUBLE_EQ(job.GetValues().value(olive::PanNode::kPanningInput).toDouble(), + ASSERT_TRUE(job.get_values().contains(olive::PanNode::k_panning_input)); + EXPECT_DOUBLE_EQ(job.get_values().value(olive::PanNode::k_panning_input).to_double(), 1.0); SampleResolvingTraverser resolver; - resolver.Resolve(result); + resolver.resolve(result); // Pan 1.0 (full right) silences the left channel and leaves the right - const olive::core::SampleBuffer out = result.toSamples(); + const olive::core::SampleBuffer out = result.to_samples(); ASSERT_TRUE(out.is_allocated()); ASSERT_EQ(out.sample_count(), 4u); for (int i = 0; i < 4; i++) { @@ -408,18 +408,18 @@ TEST(PanNode, ProcessSamplesAppliesPanPerSample) olive::PanNode pan; olive::NodeValueRow row; - row.insert(olive::PanNode::kPanningInput, - olive::NodeValue(olive::NodeValue::kFloat, 0.5)); + row.insert(olive::PanNode::k_panning_input, + olive::NodeValue(olive::NodeValue::k_float, 0.5)); - olive::core::SampleBuffer input(StereoParams(), 2); - olive::core::SampleBuffer output(StereoParams(), 2); + olive::core::SampleBuffer input(stereo_params(), 2); + olive::core::SampleBuffer output(stereo_params(), 2); input.data(0)[0] = 1.5f; input.data(0)[1] = -2.0f; input.data(1)[0] = 0.25f; input.data(1)[1] = 8.0f; - pan.ProcessSamples(row, input, output, 0); - pan.ProcessSamples(row, input, output, 1); + pan.process_samples(row, input, output, 0); + pan.process_samples(row, input, output, 1); // Panning right attenuates the left channel only EXPECT_FLOAT_EQ(output.data(0)[0], 0.75f); @@ -428,9 +428,9 @@ TEST(PanNode, ProcessSamplesAppliesPanPerSample) EXPECT_FLOAT_EQ(output.data(1)[1], 8.0f); // Panning left attenuates the right channel only - row.insert(olive::PanNode::kPanningInput, - olive::NodeValue(olive::NodeValue::kFloat, -0.25)); - pan.ProcessSamples(row, input, output, 0); + row.insert(olive::PanNode::k_panning_input, + olive::NodeValue(olive::NodeValue::k_float, -0.25)); + pan.process_samples(row, input, output, 0); EXPECT_FLOAT_EQ(output.data(0)[0], 1.5f); EXPECT_FLOAT_EQ(output.data(1)[0], 0.1875f); @@ -443,12 +443,12 @@ TEST(PanNode, ProcessSamplesWithoutPanValueCopiesInput) // No panning value in the row: samples are copied unchanged olive::NodeValueRow row; - olive::core::SampleBuffer input(StereoParams(), 1); - olive::core::SampleBuffer output(StereoParams(), 1); + olive::core::SampleBuffer input(stereo_params(), 1); + olive::core::SampleBuffer output(stereo_params(), 1); input.data(0)[0] = 3.0f; input.data(1)[0] = -4.0f; - pan.ProcessSamples(row, input, output, 0); + pan.process_samples(row, input, output, 0); EXPECT_FLOAT_EQ(output.data(0)[0], 3.0f); EXPECT_FLOAT_EQ(output.data(1)[0], -4.0f); @@ -458,65 +458,65 @@ TEST(VolumeNode, Metadata) { olive::VolumeNode volume; - EXPECT_EQ(volume.Name(), QStringLiteral("Volume")); + EXPECT_EQ(volume.name(), QStringLiteral("Volume")); EXPECT_EQ(volume.id(), QStringLiteral("org.olivevideoeditor.Olive.volume")); - EXPECT_FALSE(volume.Description().isEmpty()); - EXPECT_TRUE(volume.Category().contains(olive::Node::kCategoryFilter)); + EXPECT_FALSE(volume.description().isEmpty()); + EXPECT_TRUE(volume.category().contains(olive::Node::k_category_filter)); - EXPECT_TRUE(volume.GetFlags() & olive::Node::kAudioEffect); - EXPECT_EQ(volume.GetEffectInputID(), olive::VolumeNode::kSamplesInput); + EXPECT_TRUE(volume.get_flags() & olive::Node::k_audio_effect); + EXPECT_EQ(volume.get_effect_input_id(), olive::VolumeNode::k_samples_input); } TEST(VolumeNode, InputDefaults) { olive::VolumeNode volume; - EXPECT_EQ(volume.GetInputDataType(olive::VolumeNode::kSamplesInput), - olive::NodeValue::kSamples); - EXPECT_FALSE(volume.IsInputKeyframable(olive::VolumeNode::kSamplesInput)); + EXPECT_EQ(volume.get_input_data_type(olive::VolumeNode::k_samples_input), + olive::NodeValue::k_samples); + EXPECT_FALSE(volume.is_input_keyframable(olive::VolumeNode::k_samples_input)); - EXPECT_EQ(volume.GetInputDataType(olive::VolumeNode::kVolumeInput), - olive::NodeValue::kFloat); - EXPECT_TRUE(volume.IsInputKeyframable(olive::VolumeNode::kVolumeInput)); + EXPECT_EQ(volume.get_input_data_type(olive::VolumeNode::k_volume_input), + olive::NodeValue::k_float); + EXPECT_TRUE(volume.is_input_keyframable(olive::VolumeNode::k_volume_input)); EXPECT_DOUBLE_EQ( - volume.GetStandardValue(olive::VolumeNode::kVolumeInput).toDouble(), + volume.get_standard_value(olive::VolumeNode::k_volume_input).toDouble(), 1.0); - EXPECT_DOUBLE_EQ(volume.GetInputProperty(olive::VolumeNode::kVolumeInput, + EXPECT_DOUBLE_EQ(volume.get_input_property(olive::VolumeNode::k_volume_input, QStringLiteral("min")) .toDouble(), 0.0); - EXPECT_EQ(int(volume.GetInputProperty(olive::VolumeNode::kVolumeInput, + EXPECT_EQ(int(volume.get_input_property(olive::VolumeNode::k_volume_input, QStringLiteral("view")) .toInt()), - int(olive::FloatSlider::kDecibel)); + int(olive::FloatSlider::k_decibel)); } TEST(VolumeNode, RetranslateSetsInputNames) { olive::VolumeNode volume; - volume.Retranslate(); + volume.retranslate(); - EXPECT_EQ(volume.GetInputName(olive::VolumeNode::kSamplesInput), + EXPECT_EQ(volume.get_input_name(olive::VolumeNode::k_samples_input), QStringLiteral("Samples")); - EXPECT_EQ(volume.GetInputName(olive::VolumeNode::kVolumeInput), + EXPECT_EQ(volume.get_input_name(olive::VolumeNode::k_volume_input), QStringLiteral("Volume")); } TEST(VolumeNode, StaticVolumeScalesSamples) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::VolumeNode *volume = AddNode(&project); - volume->SetStandardValue(olive::VolumeNode::kVolumeInput, 2.0); - ConnectTestSamples(&project, volume, olive::VolumeNode::kSamplesInput); + olive::VolumeNode *volume = add_node(&project); + volume->set_standard_value(olive::VolumeNode::k_volume_input, 2.0); + connect_test_samples(&project, volume, olive::VolumeNode::k_samples_input); - const olive::NodeValueTable table = GenerateTableAt(volume, olive::core::rational(0)); + const olive::NodeValueTable table = generate_table_at(volume, olive::core::Rational(0)); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); ASSERT_EQ(out.sample_count(), 4u); for (int i = 0; i < 4; i++) { @@ -527,18 +527,18 @@ TEST(VolumeNode, StaticVolumeScalesSamples) TEST(VolumeNode, StaticUnityVolumeLeavesSamplesUnchanged) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::VolumeNode *volume = AddNode(&project); - volume->SetStandardValue(olive::VolumeNode::kVolumeInput, 1.0); - ConnectTestSamples(&project, volume, olive::VolumeNode::kSamplesInput); + olive::VolumeNode *volume = add_node(&project); + volume->set_standard_value(olive::VolumeNode::k_volume_input, 1.0); + connect_test_samples(&project, volume, olive::VolumeNode::k_samples_input); // Volume 1 is a no-op, but the (unmodified) buffer is still pushed - const olive::NodeValueTable table = GenerateTableAt(volume, olive::core::rational(0)); + const olive::NodeValueTable table = generate_table_at(volume, olive::core::Rational(0)); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); for (int i = 0; i < 4; i++) { EXPECT_FLOAT_EQ(out.data(0)[i], float(i + 1)); @@ -548,17 +548,17 @@ TEST(VolumeNode, StaticUnityVolumeLeavesSamplesUnchanged) TEST(VolumeNode, StaticZeroVolumeSilencesSamples) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::VolumeNode *volume = AddNode(&project); - volume->SetStandardValue(olive::VolumeNode::kVolumeInput, 0.0); - ConnectTestSamples(&project, volume, olive::VolumeNode::kSamplesInput); + olive::VolumeNode *volume = add_node(&project); + volume->set_standard_value(olive::VolumeNode::k_volume_input, 0.0); + connect_test_samples(&project, volume, olive::VolumeNode::k_samples_input); - const olive::NodeValueTable table = GenerateTableAt(volume, olive::core::rational(0)); + const olive::NodeValueTable table = generate_table_at(volume, olive::core::Rational(0)); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); for (int i = 0; i < 4; i++) { EXPECT_FLOAT_EQ(out.data(0)[i], 0.0f); @@ -568,36 +568,36 @@ TEST(VolumeNode, StaticZeroVolumeSilencesSamples) TEST(VolumeNode, KeyframedVolumeProducesSampleJobWithInterpolatedValue) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::VolumeNode *volume = AddNode(&project); - ConnectTestSamples(&project, volume, olive::VolumeNode::kSamplesInput); + olive::VolumeNode *volume = add_node(&project); + connect_test_samples(&project, volume, olive::VolumeNode::k_samples_input); // A non-static (keyframed) volume makes Value() push a SampleJob carrying // the volume value instead of processing the buffer immediately - volume->SetInputIsKeyframing(olive::VolumeNode::kVolumeInput, true); - AddKey(volume, olive::VolumeNode::kVolumeInput, olive::core::rational(0), + volume->set_input_is_keyframing(olive::VolumeNode::k_volume_input, true); + add_key(volume, olive::VolumeNode::k_volume_input, olive::core::Rational(0), 1.0); - AddKey(volume, olive::VolumeNode::kVolumeInput, olive::core::rational(1), + add_key(volume, olive::VolumeNode::k_volume_input, olive::core::Rational(1), 3.0); // At t=0.5 the linear ramp 1.0 -> 3.0 interpolates to 2.0 - const olive::NodeValueTable table = GenerateTableAt(volume, olive::core::rational(1, 2)); - olive::NodeValue result = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(result.type(), olive::NodeValue::kSamples); + const olive::NodeValueTable table = generate_table_at(volume, olive::core::Rational(1, 2)); + olive::NodeValue result = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(result.type(), olive::NodeValue::k_samples); ASSERT_TRUE(result.canConvert()); const olive::SampleJob job = result.value(); - ASSERT_TRUE(job.GetValues().contains(olive::VolumeNode::kVolumeInput)); - EXPECT_DOUBLE_EQ(job.Get(olive::VolumeNode::kVolumeInput).toDouble(), 2.0); + ASSERT_TRUE(job.get_values().contains(olive::VolumeNode::k_volume_input)); + EXPECT_DOUBLE_EQ(job.get(olive::VolumeNode::k_volume_input).to_double(), 2.0); // Resolve the job on the CPU and verify the scaled samples SampleResolvingTraverser resolver; - resolver.Resolve(result); + resolver.resolve(result); - const olive::core::SampleBuffer out = result.toSamples(); + const olive::core::SampleBuffer out = result.to_samples(); ASSERT_TRUE(out.is_allocated()); ASSERT_EQ(out.sample_count(), 4u); for (int i = 0; i < 4; i++) { @@ -611,18 +611,18 @@ TEST(VolumeNode, ProcessSamplesMultipliesPerSample) olive::VolumeNode volume; olive::NodeValueRow row; - row.insert(olive::VolumeNode::kVolumeInput, - olive::NodeValue(olive::NodeValue::kFloat, 2.0)); + row.insert(olive::VolumeNode::k_volume_input, + olive::NodeValue(olive::NodeValue::k_float, 2.0)); - olive::core::SampleBuffer input(StereoParams(), 2); - olive::core::SampleBuffer output(StereoParams(), 2); + olive::core::SampleBuffer input(stereo_params(), 2); + olive::core::SampleBuffer output(stereo_params(), 2); input.data(0)[0] = 1.5f; input.data(0)[1] = -2.0f; input.data(1)[0] = 0.25f; input.data(1)[1] = 8.0f; - volume.ProcessSamples(row, input, output, 0); - volume.ProcessSamples(row, input, output, 1); + volume.process_samples(row, input, output, 0); + volume.process_samples(row, input, output, 1); EXPECT_FLOAT_EQ(output.data(0)[0], 3.0f); EXPECT_FLOAT_EQ(output.data(0)[1], -4.0f); @@ -638,13 +638,13 @@ TEST(VolumeNode, ProcessSamplesWithoutVolumeLeavesOutputUntouched) // must not be written olive::NodeValueRow row; - olive::core::SampleBuffer input(StereoParams(), 1); - olive::core::SampleBuffer output(StereoParams(), 1); + olive::core::SampleBuffer input(stereo_params(), 1); + olive::core::SampleBuffer output(stereo_params(), 1); input.data(0)[0] = 10.0f; output.data(0)[0] = 123.0f; output.data(1)[0] = 45.0f; - volume.ProcessSamples(row, input, output, 0); + volume.process_samples(row, input, output, 0); EXPECT_FLOAT_EQ(output.data(0)[0], 123.0f); EXPECT_FLOAT_EQ(output.data(1)[0], 45.0f); @@ -654,72 +654,72 @@ TEST(TimeInput, Metadata) { olive::TimeInput time; - EXPECT_EQ(time.Name(), QStringLiteral("Time")); + EXPECT_EQ(time.name(), QStringLiteral("Time")); EXPECT_EQ(time.id(), QStringLiteral("org.olivevideoeditor.Olive.time")); - EXPECT_FALSE(time.Description().isEmpty()); - EXPECT_TRUE(time.Category().contains(olive::Node::kCategoryTime)); + EXPECT_FALSE(time.description().isEmpty()); + EXPECT_TRUE(time.category().contains(olive::Node::k_category_time)); } TEST(TimeInput, ValuePushesCurrentTimeInSeconds) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::TimeInput *time = AddNode(&project); + olive::TimeInput *time = add_node(&project); - olive::NodeValueTable table = GenerateTableAt(time, olive::core::rational(0)); - olive::NodeValue result = table.Get(olive::NodeValue::kFloat); - ASSERT_EQ(result.type(), olive::NodeValue::kFloat); - EXPECT_DOUBLE_EQ(result.toDouble(), 0.0); + olive::NodeValueTable table = generate_table_at(time, olive::core::Rational(0)); + olive::NodeValue result = table.get(olive::NodeValue::k_float); + ASSERT_EQ(result.type(), olive::NodeValue::k_float); + EXPECT_DOUBLE_EQ(result.to_double(), 0.0); - table = GenerateTableAt(time, olive::core::rational(5, 2)); - result = table.Get(olive::NodeValue::kFloat); - ASSERT_EQ(result.type(), olive::NodeValue::kFloat); - EXPECT_DOUBLE_EQ(result.toDouble(), 2.5); + table = generate_table_at(time, olive::core::Rational(5, 2)); + result = table.get(olive::NodeValue::k_float); + ASSERT_EQ(result.type(), olive::NodeValue::k_float); + EXPECT_DOUBLE_EQ(result.to_double(), 2.5); } TEST(ValueNode, Metadata) { olive::ValueNode value; - EXPECT_EQ(value.Name(), QStringLiteral("Value")); + EXPECT_EQ(value.name(), QStringLiteral("Value")); EXPECT_EQ(value.id(), QStringLiteral("org.olivevideoeditor.Olive.value")); - EXPECT_FALSE(value.Description().isEmpty()); - EXPECT_TRUE(value.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_FALSE(value.description().isEmpty()); + EXPECT_TRUE(value.category().contains(olive::Node::k_category_generator)); } TEST(ValueNode, InputDefaults) { olive::ValueNode value; - EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kTypeInput), - olive::NodeValue::kCombo); - EXPECT_FALSE(value.IsInputConnectable(olive::ValueNode::kTypeInput)); - EXPECT_FALSE(value.IsInputKeyframable(olive::ValueNode::kTypeInput)); - EXPECT_EQ(value.GetStandardValue(olive::ValueNode::kTypeInput).toInt(), 0); + EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_type_input), + olive::NodeValue::k_combo); + EXPECT_FALSE(value.is_input_connectable(olive::ValueNode::k_type_input)); + EXPECT_FALSE(value.is_input_keyframable(olive::ValueNode::k_type_input)); + EXPECT_EQ(value.get_standard_value(olive::ValueNode::k_type_input).toInt(), 0); // The value input starts out as a float (the first supported type) - EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput), - olive::NodeValue::kFloat); - EXPECT_FALSE(value.IsInputConnectable(olive::ValueNode::kValueInput)); - EXPECT_TRUE(value.IsInputKeyframable(olive::ValueNode::kValueInput)); + EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input), + olive::NodeValue::k_float); + EXPECT_FALSE(value.is_input_connectable(olive::ValueNode::k_value_input)); + EXPECT_TRUE(value.is_input_keyframable(olive::ValueNode::k_value_input)); } TEST(ValueNode, RetranslateSetsInputNamesAndTypeCombo) { olive::ValueNode value; - value.Retranslate(); + value.retranslate(); - EXPECT_EQ(value.GetInputName(olive::ValueNode::kTypeInput), + EXPECT_EQ(value.get_input_name(olive::ValueNode::k_type_input), QStringLiteral("Type")); - EXPECT_EQ(value.GetInputName(olive::ValueNode::kValueInput), + EXPECT_EQ(value.get_input_name(olive::ValueNode::k_value_input), QStringLiteral("Value")); // The type combo lists the pretty name of every supported type, in order const QStringList types = - value.GetInputProperty(olive::ValueNode::kTypeInput, + value.get_input_property(olive::ValueNode::k_type_input, QStringLiteral("combo_str")) .toStringList(); ASSERT_EQ(types.size(), 11); @@ -740,62 +740,62 @@ TEST(ValueNode, ChangingTypeSwitchesValueInputDataType) { olive::ValueNode value; - EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput), - olive::NodeValue::kFloat); + EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input), + olive::NodeValue::k_float); - value.SetStandardValue(olive::ValueNode::kTypeInput, 1); - EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput), - olive::NodeValue::kInt); + value.set_standard_value(olive::ValueNode::k_type_input, 1); + EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input), + olive::NodeValue::k_int); - value.SetStandardValue(olive::ValueNode::kTypeInput, 3); - EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput), - olive::NodeValue::kVec2); + value.set_standard_value(olive::ValueNode::k_type_input, 3); + EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input), + olive::NodeValue::k_vec2); - value.SetStandardValue(olive::ValueNode::kTypeInput, 6); - EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput), - olive::NodeValue::kColor); + value.set_standard_value(olive::ValueNode::k_type_input, 6); + EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input), + olive::NodeValue::k_color); - value.SetStandardValue(olive::ValueNode::kTypeInput, 10); - EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput), - olive::NodeValue::kBoolean); + value.set_standard_value(olive::ValueNode::k_type_input, 10); + EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input), + olive::NodeValue::k_boolean); - value.SetStandardValue(olive::ValueNode::kTypeInput, 0); - EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput), - olive::NodeValue::kFloat); + value.set_standard_value(olive::ValueNode::k_type_input, 0); + EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input), + olive::NodeValue::k_float); } TEST(ValueNode, ValuePassesThroughFloat) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::ValueNode *value = AddNode(&project); - value->SetStandardValue(olive::ValueNode::kValueInput, 3.5); + olive::ValueNode *value = add_node(&project); + value->set_standard_value(olive::ValueNode::k_value_input, 3.5); - const olive::NodeValueTable table = GenerateTableAt(value, olive::core::rational(0)); - const olive::NodeValue result = table.Get(olive::NodeValue::kFloat); - ASSERT_EQ(result.type(), olive::NodeValue::kFloat); - EXPECT_DOUBLE_EQ(result.toDouble(), 3.5); + const olive::NodeValueTable table = generate_table_at(value, olive::core::Rational(0)); + const olive::NodeValue result = table.get(olive::NodeValue::k_float); + ASSERT_EQ(result.type(), olive::NodeValue::k_float); + EXPECT_DOUBLE_EQ(result.to_double(), 3.5); } TEST(ValueNode, ValuePassesThroughVectorAfterTypeSwitch) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::ValueNode *value = AddNode(&project); + olive::ValueNode *value = add_node(&project); // Switch the value input to kVec3 (index 4) and set a vector value - value->SetStandardValue(olive::ValueNode::kTypeInput, 4); - value->SetStandardValue(olive::ValueNode::kValueInput, + value->set_standard_value(olive::ValueNode::k_type_input, 4); + value->set_standard_value(olive::ValueNode::k_value_input, QVector3D(1.0f, 2.0f, 3.0f)); - const olive::NodeValueTable table = GenerateTableAt(value, olive::core::rational(0)); - const olive::NodeValue result = table.Get(olive::NodeValue::kVec3); - ASSERT_EQ(result.type(), olive::NodeValue::kVec3); - const QVector3D vec = result.toVec3(); + const olive::NodeValueTable table = generate_table_at(value, olive::core::Rational(0)); + const olive::NodeValue result = table.get(olive::NodeValue::k_vec3); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec3); + const QVector3D vec = result.to_vec3(); EXPECT_FLOAT_EQ(vec.x(), 1.0f); EXPECT_FLOAT_EQ(vec.y(), 2.0f); EXPECT_FLOAT_EQ(vec.z(), 3.0f); diff --git a/tests/gtest/node_color_test.cpp b/tests/gtest/node_color_test.cpp index ed0dd71cd..ff169886e 100644 --- a/tests/gtest/node_color_test.cpp +++ b/tests/gtest/node_color_test.cpp @@ -19,29 +19,29 @@ namespace // A "dummy" texture has no renderer backend and is therefore safe to pass // around in a headless, CPU-only test. -olive::TexturePtr MakeDummyTexture() +olive::TexturePtr make_dummy_texture() { return std::make_shared( - olive::VideoParams(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count)); } -olive::NodeValueRow MakeTextureRow(const QString &input, +olive::NodeValueRow make_texture_row(const QString &input, const olive::TexturePtr &tex) { olive::NodeValueRow row; - row.insert(input, olive::NodeValue(olive::NodeValue::kTexture, tex)); + row.insert(input, olive::NodeValue(olive::NodeValue::k_texture, tex)); return row; } -olive::NodeValue Vec4Value(const QVector4D &v) +olive::NodeValue vec4_value(const QVector4D &v) { - return olive::NodeValue(olive::NodeValue::kVec4, v); + return olive::NodeValue(olive::NodeValue::k_vec4, v); } -olive::NodeValue BoolValue(bool b) +olive::NodeValue bool_value(bool b) { - return olive::NodeValue(olive::NodeValue::kBoolean, b); + return olive::NodeValue(olive::NodeValue::k_boolean, b); } } // namespace @@ -56,17 +56,17 @@ TEST(OCIOBaseNode, PassesTextureThroughWhenProcessorMissing) { olive::DisplayTransformNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OCIOBaseNode::kTextureInput, tex); + make_texture_row(olive::OCIOBaseNode::k_texture_input, tex); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::NodeValue out = table.Get(olive::NodeValue::kTexture); - EXPECT_EQ(out.type(), olive::NodeValue::kTexture); - EXPECT_EQ(out.toTexture(), tex); + ASSERT_EQ(table.count(), 1); + const olive::NodeValue out = table.get(olive::NodeValue::k_texture); + EXPECT_EQ(out.type(), olive::NodeValue::k_texture); + EXPECT_EQ(out.to_texture(), tex); } TEST(OCIOBaseNode, PushesNothingWhenTextureInputEmpty) @@ -74,9 +74,9 @@ TEST(OCIOBaseNode, PushesNothingWhenTextureInputEmpty) olive::DisplayTransformNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } // ----------------------------------------------------------------------------- @@ -87,45 +87,45 @@ TEST(DisplayTransformNode, InputDefinitions) { olive::DisplayTransformNode node; - EXPECT_TRUE(node.HasInputWithID(olive::OCIOBaseNode::kTextureInput)); - EXPECT_TRUE(node.HasInputWithID(olive::DisplayTransformNode::kDisplayInput)); - EXPECT_TRUE(node.HasInputWithID(olive::DisplayTransformNode::kViewInput)); + EXPECT_TRUE(node.has_input_with_id(olive::OCIOBaseNode::k_texture_input)); + EXPECT_TRUE(node.has_input_with_id(olive::DisplayTransformNode::k_display_input)); + EXPECT_TRUE(node.has_input_with_id(olive::DisplayTransformNode::k_view_input)); EXPECT_TRUE( - node.HasInputWithID(olive::DisplayTransformNode::kDirectionInput)); + node.has_input_with_id(olive::DisplayTransformNode::k_direction_input)); - EXPECT_EQ(node.GetInputDataType(olive::DisplayTransformNode::kDisplayInput), - olive::NodeValue::kCombo); - EXPECT_EQ(node.GetInputDataType(olive::DisplayTransformNode::kViewInput), - olive::NodeValue::kCombo); + EXPECT_EQ(node.get_input_data_type(olive::DisplayTransformNode::k_display_input), + olive::NodeValue::k_combo); + EXPECT_EQ(node.get_input_data_type(olive::DisplayTransformNode::k_view_input), + olive::NodeValue::k_combo); EXPECT_EQ( - node.GetInputDataType(olive::DisplayTransformNode::kDirectionInput), - olive::NodeValue::kCombo); + node.get_input_data_type(olive::DisplayTransformNode::k_direction_input), + olive::NodeValue::k_combo); // Combo inputs are static UI choices: neither keyframable nor connectable. EXPECT_FALSE( - node.IsInputKeyframable(olive::DisplayTransformNode::kDisplayInput)); + node.is_input_keyframable(olive::DisplayTransformNode::k_display_input)); EXPECT_FALSE( - node.IsInputConnectable(olive::DisplayTransformNode::kDisplayInput)); + node.is_input_connectable(olive::DisplayTransformNode::k_display_input)); EXPECT_FALSE( - node.IsInputKeyframable(olive::DisplayTransformNode::kViewInput)); + node.is_input_keyframable(olive::DisplayTransformNode::k_view_input)); EXPECT_FALSE( - node.IsInputConnectable(olive::DisplayTransformNode::kViewInput)); + node.is_input_connectable(olive::DisplayTransformNode::k_view_input)); EXPECT_FALSE( - node.IsInputKeyframable(olive::DisplayTransformNode::kDirectionInput)); + node.is_input_keyframable(olive::DisplayTransformNode::k_direction_input)); EXPECT_FALSE( - node.IsInputConnectable(olive::DisplayTransformNode::kDirectionInput)); + node.is_input_connectable(olive::DisplayTransformNode::k_direction_input)); - EXPECT_EQ(node.GetStandardValue(olive::DisplayTransformNode::kDisplayInput) + EXPECT_EQ(node.get_standard_value(olive::DisplayTransformNode::k_display_input) .toInt(), 0); - EXPECT_EQ(node.GetStandardValue(olive::DisplayTransformNode::kViewInput) + EXPECT_EQ(node.get_standard_value(olive::DisplayTransformNode::k_view_input) .toInt(), 0); - EXPECT_EQ(node.GetStandardValue(olive::DisplayTransformNode::kDirectionInput) + EXPECT_EQ(node.get_standard_value(olive::DisplayTransformNode::k_direction_input) .toInt(), 0); - EXPECT_EQ(node.GetEffectInputID(), olive::OCIOBaseNode::kTextureInput); + EXPECT_EQ(node.get_effect_input_id(), olive::OCIOBaseNode::k_texture_input); } TEST(DisplayTransformNode, Identity) @@ -134,11 +134,11 @@ TEST(DisplayTransformNode, Identity) EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.displaytransform")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryColor)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_color)); } TEST(DisplayTransformNode, DisplayAndViewEmptyWithoutProject) @@ -146,52 +146,52 @@ TEST(DisplayTransformNode, DisplayAndViewEmptyWithoutProject) olive::DisplayTransformNode node; // No ColorManager is attached, so display/view cannot be resolved. - EXPECT_TRUE(node.GetDisplay().isEmpty()); - EXPECT_TRUE(node.GetView().isEmpty()); - EXPECT_EQ(int(node.GetDirection()), int(olive::ColorProcessor::kNormal)); + EXPECT_TRUE(node.get_display().isEmpty()); + EXPECT_TRUE(node.get_view().isEmpty()); + EXPECT_EQ(int(node.get_direction()), int(olive::ColorProcessor::k_normal)); } TEST(DisplayTransformNode, ResolvesDisplayAndViewInProject) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::ColorManager *manager = project.color_manager(); ASSERT_NE(manager, nullptr); - const QStringList displays = manager->ListAvailableDisplays(); + const QStringList displays = manager->list_available_displays(); ASSERT_FALSE(displays.isEmpty()); auto *node = new olive::DisplayTransformNode(); node->setParent(&project); // Combo index 0 must resolve to the first available display/view. - EXPECT_EQ(node->GetDisplay(), displays.first()); + EXPECT_EQ(node->get_display(), displays.first()); - const QStringList views = manager->ListAvailableViews(node->GetDisplay()); + const QStringList views = manager->list_available_views(node->get_display()); ASSERT_FALSE(views.isEmpty()); - EXPECT_EQ(node->GetView(), views.first()); + EXPECT_EQ(node->get_view(), views.first()); - EXPECT_EQ(int(node->GetDirection()), int(olive::ColorProcessor::kNormal)); + EXPECT_EQ(int(node->get_direction()), int(olive::ColorProcessor::k_normal)); - node->SetStandardValue(olive::DisplayTransformNode::kDirectionInput, 1); - EXPECT_EQ(int(node->GetDirection()), int(olive::ColorProcessor::kInverse)); + node->set_standard_value(olive::DisplayTransformNode::k_direction_input, 1); + EXPECT_EQ(int(node->get_direction()), int(olive::ColorProcessor::k_inverse)); } TEST(DisplayTransformNode, RetranslateSetsInputNames) { olive::DisplayTransformNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::OCIOBaseNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::OCIOBaseNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::DisplayTransformNode::kDisplayInput), + EXPECT_EQ(node.get_input_name(olive::DisplayTransformNode::k_display_input), QStringLiteral("Display")); - EXPECT_EQ(node.GetInputName(olive::DisplayTransformNode::kViewInput), + EXPECT_EQ(node.get_input_name(olive::DisplayTransformNode::k_view_input), QStringLiteral("View")); - EXPECT_EQ(node.GetInputName(olive::DisplayTransformNode::kDirectionInput), + EXPECT_EQ(node.get_input_name(olive::DisplayTransformNode::k_direction_input), QStringLiteral("Direction")); } @@ -204,7 +204,7 @@ TEST(ThreeWayColorNode, ShaderCodeLoadsFragmentResource) olive::ThreeWayColorNode node; const olive::ShaderCode code = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("test"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("test"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.vert_code().isEmpty()); @@ -215,38 +215,38 @@ TEST(ThreeWayColorNode, ValueWithoutTexturePushesNothing) olive::ThreeWayColorNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(ThreeWayColorNode, ValuePushesShaderJobWithDefaultLumaCoefficients) { olive::ThreeWayColorNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::ThreeWayColorNode::kTextureInput, tex); + make_texture_row(olive::ThreeWayColorNode::k_texture_input, tex); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); - const olive::NodeValueRow &values = job->GetValues(); - EXPECT_TRUE(values.contains(olive::ThreeWayColorNode::kTextureInput)); - ASSERT_TRUE(values.contains(olive::ThreeWayColorNode::kLumaCoefficientsInput)); + const olive::NodeValueRow &values = job->get_values(); + EXPECT_TRUE(values.contains(olive::ThreeWayColorNode::k_texture_input)); + ASSERT_TRUE(values.contains(olive::ThreeWayColorNode::k_luma_coefficients_input)); // Without a project the node falls back to Rec. 709 luma coefficients. const QVector3D coeffs = - values.value(olive::ThreeWayColorNode::kLumaCoefficientsInput).toVec3(); + values.value(olive::ThreeWayColorNode::k_luma_coefficients_input).to_vec3(); EXPECT_NEAR(coeffs.x(), 0.2126f, 0.0001f); EXPECT_NEAR(coeffs.y(), 0.7152f, 0.0001f); EXPECT_NEAR(coeffs.z(), 0.0722f, 0.0001f); @@ -257,30 +257,30 @@ TEST(ThreeWayColorNode, AmountInputsDefaultToFull) olive::ThreeWayColorNode node; EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ThreeWayColorNode::kShadowsAmountInput) + node.get_standard_value(olive::ThreeWayColorNode::k_shadows_amount_input) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ThreeWayColorNode::kMidtonesAmountInput) + node.get_standard_value(olive::ThreeWayColorNode::k_midtones_amount_input) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ThreeWayColorNode::kHighlightsAmountInput) + node.get_standard_value(olive::ThreeWayColorNode::k_highlights_amount_input) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ThreeWayColorNode::kShadowsAmountInput, + node.get_input_property(olive::ThreeWayColorNode::k_shadows_amount_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ThreeWayColorNode::kMidtonesAmountInput, + node.get_input_property(olive::ThreeWayColorNode::k_midtones_amount_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ThreeWayColorNode::kHighlightsAmountInput, + node.get_input_property(olive::ThreeWayColorNode::k_highlights_amount_input, QStringLiteral("min")) .toDouble(), 0.0); @@ -289,25 +289,25 @@ TEST(ThreeWayColorNode, AmountInputsDefaultToFull) TEST(ThreeWayColorNode, RetranslateSetsInputNames) { olive::ThreeWayColorNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::ThreeWayColorNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::ThreeWayColorNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::ThreeWayColorNode::kShadowsColorInput), + EXPECT_EQ(node.get_input_name(olive::ThreeWayColorNode::k_shadows_color_input), QStringLiteral("Shadows")); - EXPECT_EQ(node.GetInputName(olive::ThreeWayColorNode::kMidtonesColorInput), + EXPECT_EQ(node.get_input_name(olive::ThreeWayColorNode::k_midtones_color_input), QStringLiteral("Midtones")); EXPECT_EQ( - node.GetInputName(olive::ThreeWayColorNode::kHighlightsColorInput), + node.get_input_name(olive::ThreeWayColorNode::k_highlights_color_input), QStringLiteral("Highlights")); EXPECT_EQ( - node.GetInputName(olive::ThreeWayColorNode::kShadowsAmountInput), + node.get_input_name(olive::ThreeWayColorNode::k_shadows_amount_input), QStringLiteral("Shadows Amount")); EXPECT_EQ( - node.GetInputName(olive::ThreeWayColorNode::kMidtonesAmountInput), + node.get_input_name(olive::ThreeWayColorNode::k_midtones_amount_input), QStringLiteral("Midtones Amount")); EXPECT_EQ( - node.GetInputName(olive::ThreeWayColorNode::kHighlightsAmountInput), + node.get_input_name(olive::ThreeWayColorNode::k_highlights_amount_input), QStringLiteral("Highlights Amount")); } @@ -321,8 +321,8 @@ TEST(GradingTransformLinear, InputDefaults) olive::OCIOGradingTransformLinearNode node; const QVector4D contrast = - node.GetStandardValue( - olive::OCIOGradingTransformLinearNode::kContrastInput) + node.get_standard_value( + olive::OCIOGradingTransformLinearNode::k_contrast_input) .value(); EXPECT_FLOAT_EQ(contrast.x(), 1.0f); EXPECT_FLOAT_EQ(contrast.y(), 1.0f); @@ -330,7 +330,7 @@ TEST(GradingTransformLinear, InputDefaults) EXPECT_FLOAT_EQ(contrast.w(), 1.0f); const QVector4D offset = - node.GetStandardValue(olive::OCIOGradingTransformLinearNode::kOffsetInput) + node.get_standard_value(olive::OCIOGradingTransformLinearNode::k_offset_input) .value(); EXPECT_FLOAT_EQ(offset.x(), 0.0f); EXPECT_FLOAT_EQ(offset.y(), 0.0f); @@ -338,8 +338,8 @@ TEST(GradingTransformLinear, InputDefaults) EXPECT_FLOAT_EQ(offset.w(), 0.0f); const QVector4D exposure = - node.GetStandardValue( - olive::OCIOGradingTransformLinearNode::kExposureInput) + node.get_standard_value( + olive::OCIOGradingTransformLinearNode::k_exposure_input) .value(); EXPECT_FLOAT_EQ(exposure.x(), 0.0f); EXPECT_FLOAT_EQ(exposure.y(), 0.0f); @@ -347,43 +347,43 @@ TEST(GradingTransformLinear, InputDefaults) EXPECT_FLOAT_EQ(exposure.w(), 0.0f); EXPECT_DOUBLE_EQ( - node.GetStandardValue( - olive::OCIOGradingTransformLinearNode::kSaturationInput) + node.get_standard_value( + olive::OCIOGradingTransformLinearNode::k_saturation_input) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::OCIOGradingTransformLinearNode::kPivotInput) + node.get_standard_value(olive::OCIOGradingTransformLinearNode::k_pivot_input) .toDouble(), 0.18); EXPECT_FALSE( - node.GetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackEnableInput) + node.get_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_enable_input) .toBool()); EXPECT_FALSE( - node.GetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampWhiteEnableInput) + node.get_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_white_enable_input) .toBool()); EXPECT_DOUBLE_EQ( - node.GetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackInput) + node.get_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput) + node.get_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input) .toDouble(), 1.0); // Clamp value inputs start out disabled, matching the enable toggles. EXPECT_FALSE( - node.GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampBlackInput, + node.get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input, QStringLiteral("enabled")) .toBool()); EXPECT_FALSE( - node.GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, + node.get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, QStringLiteral("enabled")) .toBool()); } @@ -395,38 +395,38 @@ TEST(GradingTransformLinear, Identity) EXPECT_EQ(node.id(), QStringLiteral( "org.olivevideoeditor.Olive.ociogradingtransformlinear")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryColor)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_color)); } TEST(GradingTransformLinear, ClampEnableTogglesEnabledProperty) { olive::OCIOGradingTransformLinearNode node; - node.SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampWhiteEnableInput, true); + node.set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_white_enable_input, true); EXPECT_TRUE( - node.GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, + node.get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, QStringLiteral("enabled")) .toBool()); - node.SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackEnableInput, true); + node.set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_enable_input, true); EXPECT_TRUE( - node.GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampBlackInput, + node.get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input, QStringLiteral("enabled")) .toBool()); - node.SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampWhiteEnableInput, false); + node.set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_white_enable_input, false); EXPECT_FALSE( - node.GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, + node.get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, QStringLiteral("enabled")) .toBool()); } @@ -437,17 +437,17 @@ TEST(GradingTransformLinear, WhiteClampMinimumFollowsStaticBlackClamp) // Constructor seeds the white clamp minimum just above the black clamp. EXPECT_DOUBLE_EQ( - node.GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, + node.get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, QStringLiteral("min")) .toDouble(), 0.000001); - node.SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackInput, 0.5); + node.set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input, 0.5); EXPECT_DOUBLE_EQ( - node.GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, + node.get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, QStringLiteral("min")) .toDouble(), 0.5 + 0.000001); @@ -459,14 +459,14 @@ TEST(GradingTransformLinear, WhiteClampMinimumNotUpdatedWhenBlackKeyframed) // With the black clamp keyframing, the static UI minimum can no longer // follow it; the invariant is enforced per frame in Value() instead. - node.SetInputIsKeyframing( - olive::OCIOGradingTransformLinearNode::kClampBlackInput, true); - node.SetStandardValue( - olive::OCIOGradingTransformLinearNode::kClampBlackInput, 0.5); + node.set_input_is_keyframing( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input, true); + node.set_standard_value( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input, 0.5); EXPECT_DOUBLE_EQ( - node.GetInputProperty( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput, + node.get_input_property( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input, QStringLiteral("min")) .toDouble(), 0.000001); @@ -478,151 +478,151 @@ TEST(GradingTransformLinear, ValueWithoutProcessorPushesNothing) // generated and Value() must push nothing even with a valid texture. olive::OCIOGradingTransformLinearNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OCIOBaseNode::kTextureInput, tex); + make_texture_row(olive::OCIOBaseNode::k_texture_input, tex); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(GradingTransformLinear, ValueInProjectPushesColorTransformJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::OCIOGradingTransformLinearNode(); node->setParent(&project); - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OCIOBaseNode::kTextureInput, tex); - row.insert(olive::OCIOGradingTransformLinearNode::kOffsetInput, - Vec4Value(QVector4D(0.0f, 0.0f, 0.0f, 0.0f))); - row.insert(olive::OCIOGradingTransformLinearNode::kExposureInput, - Vec4Value(QVector4D(0.0f, 0.0f, 0.0f, 0.0f))); - row.insert(olive::OCIOGradingTransformLinearNode::kContrastInput, - Vec4Value(QVector4D(1.0f, 1.0f, 1.0f, 1.0f))); - row.insert(olive::OCIOGradingTransformLinearNode::kClampBlackEnableInput, - BoolValue(false)); - row.insert(olive::OCIOGradingTransformLinearNode::kClampWhiteEnableInput, - BoolValue(false)); + make_texture_row(olive::OCIOBaseNode::k_texture_input, tex); + row.insert(olive::OCIOGradingTransformLinearNode::k_offset_input, + vec4_value(QVector4D(0.0f, 0.0f, 0.0f, 0.0f))); + row.insert(olive::OCIOGradingTransformLinearNode::k_exposure_input, + vec4_value(QVector4D(0.0f, 0.0f, 0.0f, 0.0f))); + row.insert(olive::OCIOGradingTransformLinearNode::k_contrast_input, + vec4_value(QVector4D(1.0f, 1.0f, 1.0f, 1.0f))); + row.insert(olive::OCIOGradingTransformLinearNode::k_clamp_black_enable_input, + bool_value(false)); + row.insert(olive::OCIOGradingTransformLinearNode::k_clamp_white_enable_input, + bool_value(false)); olive::NodeValueTable table; - node->Value(row, olive::NodeGlobals(), &table); + node->value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); - EXPECT_NE(job->GetColorProcessor(), nullptr); + EXPECT_NE(job->get_color_processor(), nullptr); - const olive::NodeValueRow &values = job->GetValues(); + const olive::NodeValueRow &values = job->get_values(); // Defaults convert to neutral vec3s for OCIO. const QVector3D offset = - values.value(olive::OCIOGradingTransformLinearNode::kOffsetInput) - .toVec3(); + values.value(olive::OCIOGradingTransformLinearNode::k_offset_input) + .to_vec3(); EXPECT_FLOAT_EQ(offset.x(), 0.0f); EXPECT_FLOAT_EQ(offset.y(), 0.0f); EXPECT_FLOAT_EQ(offset.z(), 0.0f); const QVector3D exposure = - values.value(olive::OCIOGradingTransformLinearNode::kExposureInput) - .toVec3(); + values.value(olive::OCIOGradingTransformLinearNode::k_exposure_input) + .to_vec3(); EXPECT_FLOAT_EQ(exposure.x(), 1.0f); EXPECT_FLOAT_EQ(exposure.y(), 1.0f); EXPECT_FLOAT_EQ(exposure.z(), 1.0f); const QVector3D contrast = - values.value(olive::OCIOGradingTransformLinearNode::kContrastInput) - .toVec3(); + values.value(olive::OCIOGradingTransformLinearNode::k_contrast_input) + .to_vec3(); EXPECT_FLOAT_EQ(contrast.x(), 1.0f); EXPECT_FLOAT_EQ(contrast.y(), 1.0f); EXPECT_FLOAT_EQ(contrast.z(), 1.0f); // Disabled clamps are replaced with OCIO's "no clamp" sentinels. ASSERT_TRUE( - values.contains(olive::OCIOGradingTransformLinearNode::kClampBlackInput)); + values.contains(olive::OCIOGradingTransformLinearNode::k_clamp_black_input)); EXPECT_LT(values - .value(olive::OCIOGradingTransformLinearNode::kClampBlackInput) - .toDouble(), + .value(olive::OCIOGradingTransformLinearNode::k_clamp_black_input) + .to_double(), -1e300); ASSERT_TRUE( - values.contains(olive::OCIOGradingTransformLinearNode::kClampWhiteInput)); + values.contains(olive::OCIOGradingTransformLinearNode::k_clamp_white_input)); EXPECT_GT(values - .value(olive::OCIOGradingTransformLinearNode::kClampWhiteInput) - .toDouble(), + .value(olive::OCIOGradingTransformLinearNode::k_clamp_white_input) + .to_double(), 1e300); } TEST(GradingTransformLinear, ValueAppliesMasterChannelMath) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::OCIOGradingTransformLinearNode(); node->setParent(&project); - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OCIOBaseNode::kTextureInput, tex); + make_texture_row(olive::OCIOBaseNode::k_texture_input, tex); // Layout is {master, red, green, blue}. - row.insert(olive::OCIOGradingTransformLinearNode::kOffsetInput, - Vec4Value(QVector4D(0.1f, 0.2f, 0.3f, 0.4f))); - row.insert(olive::OCIOGradingTransformLinearNode::kExposureInput, - Vec4Value(QVector4D(1.0f, 0.0f, 0.0f, 0.0f))); - row.insert(olive::OCIOGradingTransformLinearNode::kContrastInput, - Vec4Value(QVector4D(2.0f, 0.5f, 1.0f, 1.0f))); - row.insert(olive::OCIOGradingTransformLinearNode::kClampBlackEnableInput, - BoolValue(false)); - row.insert(olive::OCIOGradingTransformLinearNode::kClampWhiteEnableInput, - BoolValue(false)); + row.insert(olive::OCIOGradingTransformLinearNode::k_offset_input, + vec4_value(QVector4D(0.1f, 0.2f, 0.3f, 0.4f))); + row.insert(olive::OCIOGradingTransformLinearNode::k_exposure_input, + vec4_value(QVector4D(1.0f, 0.0f, 0.0f, 0.0f))); + row.insert(olive::OCIOGradingTransformLinearNode::k_contrast_input, + vec4_value(QVector4D(2.0f, 0.5f, 1.0f, 1.0f))); + row.insert(olive::OCIOGradingTransformLinearNode::k_clamp_black_enable_input, + bool_value(false)); + row.insert(olive::OCIOGradingTransformLinearNode::k_clamp_white_enable_input, + bool_value(false)); olive::NodeValueTable table; - node->Value(row, olive::NodeGlobals(), &table); + node->value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); - const olive::NodeValueRow &values = job->GetValues(); + const olive::NodeValueRow &values = job->get_values(); // Offset: master is added to each channel. const QVector3D offset = - values.value(olive::OCIOGradingTransformLinearNode::kOffsetInput) - .toVec3(); + values.value(olive::OCIOGradingTransformLinearNode::k_offset_input) + .to_vec3(); EXPECT_NEAR(offset.x(), 0.3f, 0.0001f); EXPECT_NEAR(offset.y(), 0.4f, 0.0001f); EXPECT_NEAR(offset.z(), 0.5f, 0.0001f); // Exposure: channels become 2^(master + channel) gain values. const QVector3D exposure = - values.value(olive::OCIOGradingTransformLinearNode::kExposureInput) - .toVec3(); + values.value(olive::OCIOGradingTransformLinearNode::k_exposure_input) + .to_vec3(); EXPECT_NEAR(exposure.x(), 2.0f, 0.0001f); EXPECT_NEAR(exposure.y(), 2.0f, 0.0001f); EXPECT_NEAR(exposure.z(), 2.0f, 0.0001f); // Contrast: master multiplies each channel. const QVector3D contrast = - values.value(olive::OCIOGradingTransformLinearNode::kContrastInput) - .toVec3(); + values.value(olive::OCIOGradingTransformLinearNode::k_contrast_input) + .to_vec3(); EXPECT_NEAR(contrast.x(), 1.0f, 0.0001f); EXPECT_NEAR(contrast.y(), 2.0f, 0.0001f); EXPECT_NEAR(contrast.z(), 2.0f, 0.0001f); @@ -631,40 +631,40 @@ TEST(GradingTransformLinear, ValueAppliesMasterChannelMath) TEST(GradingTransformLinear, RetranslateSetsInputNames) { olive::OCIOGradingTransformLinearNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::OCIOBaseNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::OCIOBaseNode::k_texture_input), QStringLiteral("Input")); EXPECT_EQ( - node.GetInputName(olive::OCIOGradingTransformLinearNode::kContrastInput), + node.get_input_name(olive::OCIOGradingTransformLinearNode::k_contrast_input), QStringLiteral("Contrast")); EXPECT_EQ( - node.GetInputName(olive::OCIOGradingTransformLinearNode::kOffsetInput), + node.get_input_name(olive::OCIOGradingTransformLinearNode::k_offset_input), QStringLiteral("Offset")); EXPECT_EQ( - node.GetInputName(olive::OCIOGradingTransformLinearNode::kExposureInput), + node.get_input_name(olive::OCIOGradingTransformLinearNode::k_exposure_input), QStringLiteral("Exposure")); EXPECT_EQ( - node.GetInputName( - olive::OCIOGradingTransformLinearNode::kSaturationInput), + node.get_input_name( + olive::OCIOGradingTransformLinearNode::k_saturation_input), QStringLiteral("Saturation")); EXPECT_EQ( - node.GetInputName(olive::OCIOGradingTransformLinearNode::kPivotInput), + node.get_input_name(olive::OCIOGradingTransformLinearNode::k_pivot_input), QStringLiteral("Pivot")); EXPECT_EQ( - node.GetInputName( - olive::OCIOGradingTransformLinearNode::kClampBlackEnableInput), + node.get_input_name( + olive::OCIOGradingTransformLinearNode::k_clamp_black_enable_input), QStringLiteral("Enable Black Clamp")); EXPECT_EQ( - node.GetInputName( - olive::OCIOGradingTransformLinearNode::kClampBlackInput), + node.get_input_name( + olive::OCIOGradingTransformLinearNode::k_clamp_black_input), QStringLiteral("Black Clamp")); EXPECT_EQ( - node.GetInputName( - olive::OCIOGradingTransformLinearNode::kClampWhiteEnableInput), + node.get_input_name( + olive::OCIOGradingTransformLinearNode::k_clamp_white_enable_input), QStringLiteral("Enable White Clamp")); EXPECT_EQ( - node.GetInputName( - olive::OCIOGradingTransformLinearNode::kClampWhiteInput), + node.get_input_name( + olive::OCIOGradingTransformLinearNode::k_clamp_white_input), QStringLiteral("White Clamp")); } diff --git a/tests/gtest/node_core_test.cpp b/tests/gtest/node_core_test.cpp index 6ef2f6425..117a26751 100644 --- a/tests/gtest/node_core_test.cpp +++ b/tests/gtest/node_core_test.cpp @@ -27,12 +27,12 @@ class RecordingNode : public olive::Node { public: RecordingNode() { - AddInput(kTestInput, olive::NodeValue::kFloat, 0.0); + add_input(k_test_input, olive::NodeValue::k_float, 0.0); } NODE_DEFAULT_FUNCTIONS(RecordingNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Recording"); } @@ -42,17 +42,17 @@ public: return QStringLiteral("org.oak.test.recording"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryMath }; + return { k_category_math }; } - virtual void InvalidateCache( + virtual void invalidate_cache( const olive::TimeRange &range, const QString &from, int element, olive::Node::InvalidateCacheOptions options) override { invalidations.append({ range, from, element }); - olive::Node::InvalidateCache(range, from, element, options); + olive::Node::invalidate_cache(range, from, element, options); } struct Invalidation { @@ -63,10 +63,10 @@ public: QVector invalidations; - static const QString kTestInput; + static const QString k_test_input; }; -const QString RecordingNode::kTestInput = QStringLiteral("test_in"); +const QString RecordingNode::k_test_input = QStringLiteral("test_in"); } // namespace @@ -74,13 +74,13 @@ class NodeCoreTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - template T *AddNode() + template T *add_node() { T *node = new T(); node->setParent(project_.get()); @@ -92,8 +92,8 @@ protected: TEST_F(NodeCoreTest, InputArrayResizeEmitsSignals) { - auto *node = AddNode(); - const int base = node->InputArraySize(olive::TextGeneratorV3::kArgsInput); + auto *node = add_node(); + const int base = node->input_array_size(olive::TextGeneratorV3::k_args_input); struct ResizeEvent { QString input; @@ -101,88 +101,88 @@ TEST_F(NodeCoreTest, InputArrayResizeEmitsSignals) int new_size; }; QVector resizes; - QObject::connect(node, &olive::Node::InputArraySizeChanged, + QObject::connect(node, &olive::Node::input_array_size_changed, [&resizes](const QString &input, int old_size, int new_size) { resizes.append({ input, old_size, new_size }); }); int value_changed = 0; - QObject::connect(node, &olive::Node::ValueChanged, + QObject::connect(node, &olive::Node::value_changed, [&value_changed](const olive::NodeInput &, const olive::TimeRange &) { ++value_changed; }); - node->InputArrayAppend(olive::TextGeneratorV3::kArgsInput); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), + node->input_array_append(olive::TextGeneratorV3::k_args_input); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base + 1); ASSERT_EQ(resizes.size(), 1); - EXPECT_EQ(resizes.first().input, olive::TextGeneratorV3::kArgsInput); + EXPECT_EQ(resizes.first().input, olive::TextGeneratorV3::k_args_input); EXPECT_EQ(resizes.first().old_size, base); EXPECT_EQ(resizes.first().new_size, base + 1); EXPECT_EQ(value_changed, 1); // Resizing to the current size is a no-op - node->InputArrayResize(olive::TextGeneratorV3::kArgsInput, base + 1); + node->input_array_resize(olive::TextGeneratorV3::k_args_input, base + 1); EXPECT_EQ(resizes.size(), 1); EXPECT_EQ(value_changed, 1); - node->InputArrayResize(olive::TextGeneratorV3::kArgsInput, base + 3); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), + node->input_array_resize(olive::TextGeneratorV3::k_args_input, base + 3); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base + 3); ASSERT_EQ(resizes.size(), 2); EXPECT_EQ(resizes.at(1).old_size, base + 1); EXPECT_EQ(resizes.at(1).new_size, base + 3); - node->InputArrayRemoveLast(olive::TextGeneratorV3::kArgsInput); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), + node->input_array_remove_last(olive::TextGeneratorV3::k_args_input); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base + 2); - node->InputArrayPrepend(olive::TextGeneratorV3::kArgsInput); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), + node->input_array_prepend(olive::TextGeneratorV3::k_args_input); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base + 3); } TEST_F(NodeCoreTest, InputArrayInsertShiftsConnectionsAndValues) { - auto *node = AddNode(); - auto *output = AddNode(); + auto *node = add_node(); + auto *output = add_node(); - node->InputArrayResize(olive::TextGeneratorV3::kArgsInput, 2); - node->SetStandardValue( - olive::NodeInput(node, olive::TextGeneratorV3::kArgsInput, 0), + node->input_array_resize(olive::TextGeneratorV3::k_args_input, 2); + node->set_standard_value( + olive::NodeInput(node, olive::TextGeneratorV3::k_args_input, 0), QStringLiteral("zero")); - node->SetStandardValue( - olive::NodeInput(node, olive::TextGeneratorV3::kArgsInput, 1), + node->set_standard_value( + olive::NodeInput(node, olive::TextGeneratorV3::k_args_input, 1), QStringLiteral("one")); - olive::Node::ConnectEdge( - output, olive::NodeInput(node, olive::TextGeneratorV3::kArgsInput, 0)); + olive::Node::connect_edge( + output, olive::NodeInput(node, olive::TextGeneratorV3::k_args_input, 0)); - node->InputArrayInsert(olive::TextGeneratorV3::kArgsInput, 0); + node->input_array_insert(olive::TextGeneratorV3::k_args_input, 0); - ASSERT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), 3); + ASSERT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), 3); // The connection moved down along with its element - EXPECT_EQ(node->GetConnectedOutput(olive::TextGeneratorV3::kArgsInput, 0), + EXPECT_EQ(node->get_connected_output(olive::TextGeneratorV3::k_args_input, 0), nullptr); - EXPECT_EQ(node->GetConnectedOutput(olive::TextGeneratorV3::kArgsInput, 1), + EXPECT_EQ(node->get_connected_output(olive::TextGeneratorV3::k_args_input, 1), output); ASSERT_EQ(output->output_connections().size(), 1); EXPECT_EQ(output->output_connections().front().second, - olive::NodeInput(node, olive::TextGeneratorV3::kArgsInput, 1)); + olive::NodeInput(node, olive::TextGeneratorV3::k_args_input, 1)); // Values moved down too; the inserted element holds the default value - EXPECT_TRUE(node->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, + EXPECT_TRUE(node->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 0) .at(0) .toString() .isEmpty()); - EXPECT_EQ(node->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, + EXPECT_EQ(node->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 1) .at(0) .toString(), QStringLiteral("zero")); - EXPECT_EQ(node->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, + EXPECT_EQ(node->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 2) .at(0) .toString(), @@ -191,51 +191,51 @@ TEST_F(NodeCoreTest, InputArrayInsertShiftsConnectionsAndValues) TEST_F(NodeCoreTest, InputArrayRemoveShiftsConnectionsAndValues) { - auto *node = AddNode(); - auto *output = AddNode(); + auto *node = add_node(); + auto *output = add_node(); - node->InputArrayResize(olive::TextGeneratorV3::kArgsInput, 3); - node->SetStandardValue( - olive::NodeInput(node, olive::TextGeneratorV3::kArgsInput, 0), + node->input_array_resize(olive::TextGeneratorV3::k_args_input, 3); + node->set_standard_value( + olive::NodeInput(node, olive::TextGeneratorV3::k_args_input, 0), QStringLiteral("zero")); - node->SetStandardValue( - olive::NodeInput(node, olive::TextGeneratorV3::kArgsInput, 1), + node->set_standard_value( + olive::NodeInput(node, olive::TextGeneratorV3::k_args_input, 1), QStringLiteral("one")); - node->SetStandardValue( - olive::NodeInput(node, olive::TextGeneratorV3::kArgsInput, 2), + node->set_standard_value( + olive::NodeInput(node, olive::TextGeneratorV3::k_args_input, 2), QStringLiteral("two")); - olive::Node::ConnectEdge( - output, olive::NodeInput(node, olive::TextGeneratorV3::kArgsInput, 1)); + olive::Node::connect_edge( + output, olive::NodeInput(node, olive::TextGeneratorV3::k_args_input, 1)); - node->InputArrayRemove(olive::TextGeneratorV3::kArgsInput, 0); + node->input_array_remove(olive::TextGeneratorV3::k_args_input, 0); - ASSERT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), 2); + ASSERT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), 2); // The connection moved up along with its element - EXPECT_EQ(node->GetConnectedOutput(olive::TextGeneratorV3::kArgsInput, 0), + EXPECT_EQ(node->get_connected_output(olive::TextGeneratorV3::k_args_input, 0), output); - EXPECT_EQ(node->GetConnectedOutput(olive::TextGeneratorV3::kArgsInput, 1), + EXPECT_EQ(node->get_connected_output(olive::TextGeneratorV3::k_args_input, 1), nullptr); // Values moved up too - EXPECT_EQ(node->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, + EXPECT_EQ(node->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 0) .at(0) .toString(), QStringLiteral("one")); - EXPECT_EQ(node->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, + EXPECT_EQ(node->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 1) .at(0) .toString(), QStringLiteral("two")); // Removing the element an edge points at drops the edge entirely - node->InputArrayRemove(olive::TextGeneratorV3::kArgsInput, 0); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), 1); - EXPECT_EQ(node->GetConnectedOutput(olive::TextGeneratorV3::kArgsInput, 0), + node->input_array_remove(olive::TextGeneratorV3::k_args_input, 0); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), 1); + EXPECT_EQ(node->get_connected_output(olive::TextGeneratorV3::k_args_input, 0), nullptr); EXPECT_TRUE(output->output_connections().empty()); - EXPECT_EQ(node->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, + EXPECT_EQ(node->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 0) .at(0) .toString(), @@ -244,33 +244,33 @@ TEST_F(NodeCoreTest, InputArrayRemoveShiftsConnectionsAndValues) TEST_F(NodeCoreTest, InputFlagsReflectDeclaration) { - auto *math = AddNode(); - EXPECT_TRUE(math->IsInputConnectable(olive::MathNode::kParamAIn)); - EXPECT_TRUE(math->IsInputKeyframable(olive::MathNode::kParamAIn)); - EXPECT_FALSE(math->IsInputHidden(olive::MathNode::kParamAIn)); - EXPECT_FALSE(math->InputIsArray(olive::MathNode::kParamAIn)); + auto *math = add_node(); + EXPECT_TRUE(math->is_input_connectable(olive::MathNode::k_param_a_in)); + EXPECT_TRUE(math->is_input_keyframable(olive::MathNode::k_param_a_in)); + EXPECT_FALSE(math->is_input_hidden(olive::MathNode::k_param_a_in)); + EXPECT_FALSE(math->input_is_array(olive::MathNode::k_param_a_in)); // kMethodIn is declared not-connectable and not-keyframable - EXPECT_FALSE(math->IsInputConnectable(olive::MathNode::kMethodIn)); - EXPECT_FALSE(math->IsInputKeyframable(olive::MathNode::kMethodIn)); + EXPECT_FALSE(math->is_input_connectable(olive::MathNode::k_method_in)); + EXPECT_FALSE(math->is_input_keyframable(olive::MathNode::k_method_in)); - auto *text = AddNode(); + auto *text = add_node(); EXPECT_TRUE( - text->IsInputHidden(olive::TextGeneratorV3::kVerticalAlignmentInput)); - EXPECT_FALSE(text->IsInputConnectable( - olive::TextGeneratorV3::kVerticalAlignmentInput)); - EXPECT_TRUE(text->InputIsArray(olive::TextGeneratorV3::kArgsInput)); - EXPECT_FALSE(text->InputIsArray(olive::TextGeneratorV3::kTextInput)); + text->is_input_hidden(olive::TextGeneratorV3::k_vertical_alignment_input)); + EXPECT_FALSE(text->is_input_connectable( + olive::TextGeneratorV3::k_vertical_alignment_input)); + EXPECT_TRUE(text->input_is_array(olive::TextGeneratorV3::k_args_input)); + EXPECT_FALSE(text->input_is_array(olive::TextGeneratorV3::k_text_input)); } TEST_F(NodeCoreTest, SetInputFlagTogglesAndEmits) { - auto *node = AddNode(); + auto *node = add_node(); int emissions = 0; QString last_input; uint64_t last_flags = 0; - QObject::connect(node, &olive::Node::InputFlagsChanged, + QObject::connect(node, &olive::Node::input_flags_changed, [&emissions, &last_input, &last_flags](const QString &input, const olive::InputFlags &flags) { @@ -279,32 +279,32 @@ TEST_F(NodeCoreTest, SetInputFlagTogglesAndEmits) last_flags = flags.value(); }); - node->SetInputFlag(olive::MathNode::kParamAIn, olive::kInputFlagHidden); - EXPECT_TRUE(node->IsInputHidden(olive::MathNode::kParamAIn)); + node->set_input_flag(olive::MathNode::k_param_a_in, olive::k_input_flag_hidden); + EXPECT_TRUE(node->is_input_hidden(olive::MathNode::k_param_a_in)); EXPECT_EQ(emissions, 1); - EXPECT_EQ(last_input, olive::MathNode::kParamAIn); - EXPECT_TRUE(last_flags & olive::kInputFlagHidden); + EXPECT_EQ(last_input, olive::MathNode::k_param_a_in); + EXPECT_TRUE(last_flags & olive::k_input_flag_hidden); // Setting another flag preserves the flags already set - node->SetInputFlag(olive::MathNode::kParamAIn, - olive::kInputFlagNotConnectable); - EXPECT_FALSE(node->IsInputConnectable(olive::MathNode::kParamAIn)); - EXPECT_TRUE(node->IsInputHidden(olive::MathNode::kParamAIn)); + node->set_input_flag(olive::MathNode::k_param_a_in, + olive::k_input_flag_not_connectable); + EXPECT_FALSE(node->is_input_connectable(olive::MathNode::k_param_a_in)); + EXPECT_TRUE(node->is_input_hidden(olive::MathNode::k_param_a_in)); EXPECT_EQ(emissions, 2); - node->SetInputFlag(olive::MathNode::kParamAIn, olive::kInputFlagHidden, + node->set_input_flag(olive::MathNode::k_param_a_in, olive::k_input_flag_hidden, false); - EXPECT_FALSE(node->IsInputHidden(olive::MathNode::kParamAIn)); + EXPECT_FALSE(node->is_input_hidden(olive::MathNode::k_param_a_in)); EXPECT_EQ(emissions, 3); } TEST_F(NodeCoreTest, SetKeyframingOnNonKeyframableInputIsIgnored) { - auto *node = AddNode(); - ASSERT_FALSE(node->IsInputKeyframable(olive::MathNode::kMethodIn)); + auto *node = add_node(); + ASSERT_FALSE(node->is_input_keyframable(olive::MathNode::k_method_in)); - node->SetInputIsKeyframing(olive::MathNode::kMethodIn, true); - EXPECT_FALSE(node->IsInputKeyframing(olive::MathNode::kMethodIn)); + node->set_input_is_keyframing(olive::MathNode::k_method_in, true); + EXPECT_FALSE(node->is_input_keyframing(olive::MathNode::k_method_in)); } TEST_F(NodeCoreTest, UnknownInputAccessorsFallBackSafely) @@ -314,137 +314,137 @@ TEST_F(NodeCoreTest, UnknownInputAccessorsFallBackSafely) // All of these go through GetInternalInputData(), which must handle the // input not existing without crashing - EXPECT_EQ(node.GetInputFlags(bogus).value(), - static_cast(olive::kInputFlagNormal)); - EXPECT_EQ(node.GetInputDataType(bogus), olive::NodeValue::kNone); - EXPECT_TRUE(node.GetInputName(bogus).isEmpty()); - EXPECT_EQ(node.GetImmediate(bogus, -1), nullptr); - EXPECT_EQ(node.GetConnectedOutput(bogus), nullptr); - EXPECT_FALSE(node.IsInputKeyframing(bogus)); - EXPECT_FALSE(node.HasInputProperty(bogus, QStringLiteral("x"))); - EXPECT_TRUE(node.GetInputProperties(bogus).isEmpty()); - EXPECT_TRUE(node.GetSplitStandardValue(bogus).isEmpty()); - EXPECT_TRUE(node.GetSplitDefaultValue(bogus).isEmpty()); - EXPECT_EQ(node.InputArraySize(bogus), 0); + EXPECT_EQ(node.get_input_flags(bogus).value(), + static_cast(olive::k_input_flag_normal)); + EXPECT_EQ(node.get_input_data_type(bogus), olive::NodeValue::k_none); + EXPECT_TRUE(node.get_input_name(bogus).isEmpty()); + EXPECT_EQ(node.get_immediate(bogus, -1), nullptr); + EXPECT_EQ(node.get_connected_output(bogus), nullptr); + EXPECT_FALSE(node.is_input_keyframing(bogus)); + EXPECT_FALSE(node.has_input_property(bogus, QStringLiteral("x"))); + EXPECT_TRUE(node.get_input_properties(bogus).isEmpty()); + EXPECT_TRUE(node.get_split_standard_value(bogus).isEmpty()); + EXPECT_TRUE(node.get_split_default_value(bogus).isEmpty()); + EXPECT_EQ(node.input_array_size(bogus), 0); } TEST_F(NodeCoreTest, InputNameTypePropertiesAndDefaults) { - auto *node = AddNode(); + auto *node = add_node(); // Default values round-trip through the split representation EXPECT_DOUBLE_EQ( - node->GetDefaultValue(olive::MathNode::kParamAIn).toDouble(), 0.0); - node->SetDefaultValue(olive::MathNode::kParamAIn, 1.5); + node->get_default_value(olive::MathNode::k_param_a_in).toDouble(), 0.0); + node->set_default_value(olive::MathNode::k_param_a_in, 1.5); EXPECT_DOUBLE_EQ( - node->GetDefaultValue(olive::MathNode::kParamAIn).toDouble(), 1.5); - EXPECT_DOUBLE_EQ(node->GetSplitDefaultValue(olive::MathNode::kParamAIn) + node->get_default_value(olive::MathNode::k_param_a_in).toDouble(), 1.5); + EXPECT_DOUBLE_EQ(node->get_split_default_value(olive::MathNode::k_param_a_in) .at(0) .toDouble(), 1.5); // Declared data type, keyframe track count and input properties - EXPECT_EQ(node->GetInputDataType(olive::MathNode::kParamAIn), - olive::NodeValue::kFloat); - EXPECT_EQ(node->GetNumberOfKeyframeTracks(olive::MathNode::kParamAIn), 1); - EXPECT_EQ(node->GetInputProperty(olive::MathNode::kParamAIn, + EXPECT_EQ(node->get_input_data_type(olive::MathNode::k_param_a_in), + olive::NodeValue::k_float); + EXPECT_EQ(node->get_number_of_keyframe_tracks(olive::MathNode::k_param_a_in), 1); + EXPECT_EQ(node->get_input_property(olive::MathNode::k_param_a_in, QStringLiteral("decimalplaces")) .toInt(), 8); - auto *solid = AddNode(); + auto *solid = add_node(); EXPECT_EQ( - solid->GetNumberOfKeyframeTracks(olive::SolidGenerator::kColorInput), + solid->get_number_of_keyframe_tracks(olive::SolidGenerator::k_color_input), 4); int name_emissions = 0; int type_emissions = 0; int property_emissions = 0; - QObject::connect(node, &olive::Node::InputNameChanged, + QObject::connect(node, &olive::Node::input_name_changed, [&name_emissions](const QString &, const QString &) { ++name_emissions; }); - QObject::connect(node, &olive::Node::InputDataTypeChanged, + QObject::connect(node, &olive::Node::input_data_type_changed, [&type_emissions](const QString &, olive::NodeValue::Type) { ++type_emissions; }); - QObject::connect(node, &olive::Node::InputPropertyChanged, + QObject::connect(node, &olive::Node::input_property_changed, [&property_emissions](const QString &, const QString &, const QVariant &) { ++property_emissions; }); - node->SetInputName(olive::MathNode::kParamAIn, QStringLiteral("Custom")); - EXPECT_EQ(node->GetInputName(olive::MathNode::kParamAIn), + node->set_input_name(olive::MathNode::k_param_a_in, QStringLiteral("Custom")); + EXPECT_EQ(node->get_input_name(olive::MathNode::k_param_a_in), QStringLiteral("Custom")); EXPECT_EQ(name_emissions, 1); - node->SetInputDataType(olive::MathNode::kParamAIn, olive::NodeValue::kInt); - EXPECT_EQ(node->GetInputDataType(olive::MathNode::kParamAIn), - olive::NodeValue::kInt); + node->set_input_data_type(olive::MathNode::k_param_a_in, olive::NodeValue::k_int); + EXPECT_EQ(node->get_input_data_type(olive::MathNode::k_param_a_in), + olive::NodeValue::k_int); EXPECT_EQ(type_emissions, 1); - node->SetInputProperty(olive::MathNode::kParamAIn, QStringLiteral("mykey"), + node->set_input_property(olive::MathNode::k_param_a_in, QStringLiteral("mykey"), 42); - EXPECT_TRUE(node->HasInputProperty(olive::MathNode::kParamAIn, + EXPECT_TRUE(node->has_input_property(olive::MathNode::k_param_a_in, QStringLiteral("mykey"))); - EXPECT_EQ(node->GetInputProperty(olive::MathNode::kParamAIn, + EXPECT_EQ(node->get_input_property(olive::MathNode::k_param_a_in, QStringLiteral("mykey")) .toInt(), 42); - EXPECT_TRUE(node->GetInputProperties(olive::MathNode::kParamAIn) + EXPECT_TRUE(node->get_input_properties(olive::MathNode::k_param_a_in) .contains(QStringLiteral("decimalplaces"))); EXPECT_EQ(property_emissions, 1); } TEST_F(NodeCoreTest, ContextPositionLifecycleEmitsSignals) { - auto *node = AddNode(); - auto *context = AddNode(); + auto *node = add_node(); + auto *context = add_node(); int added_count = 0; int removed_count = 0; QVector positions; - QObject::connect(context, &olive::Node::NodeAddedToContext, + QObject::connect(context, &olive::Node::node_added_to_context, [&added_count](olive::Node *) { ++added_count; }); - QObject::connect(context, &olive::Node::NodeRemovedFromContext, + QObject::connect(context, &olive::Node::node_removed_from_context, [&removed_count](olive::Node *) { ++removed_count; }); - QObject::connect(context, &olive::Node::NodePositionInContextChanged, + QObject::connect(context, &olive::Node::node_position_in_context_changed, [&positions](olive::Node *, const QPointF &pos) { positions.append(pos); }); - EXPECT_FALSE(context->ContextContainsNode(node)); - EXPECT_TRUE(context->GetContextPositions().isEmpty()); + EXPECT_FALSE(context->context_contains_node(node)); + EXPECT_TRUE(context->get_context_positions().isEmpty()); // First insertion reports that the node was added - EXPECT_TRUE(context->SetNodePositionInContext( + EXPECT_TRUE(context->set_node_position_in_context( node, olive::Node::Position(QPointF(3.0, 4.0), true))); - EXPECT_TRUE(context->ContextContainsNode(node)); - EXPECT_EQ(context->GetNodePositionInContext(node), QPointF(3.0, 4.0)); - EXPECT_TRUE(context->IsNodeExpandedInContext(node)); + EXPECT_TRUE(context->context_contains_node(node)); + EXPECT_EQ(context->get_node_position_in_context(node), QPointF(3.0, 4.0)); + EXPECT_TRUE(context->is_node_expanded_in_context(node)); EXPECT_EQ(added_count, 1); ASSERT_EQ(positions.size(), 1); EXPECT_EQ(positions.first(), QPointF(3.0, 4.0)); // Updating an existing entry reports no addition and keeps the expanded // state - EXPECT_FALSE(context->SetNodePositionInContext(node, QPointF(5.0, 6.0))); - EXPECT_EQ(context->GetNodePositionInContext(node), QPointF(5.0, 6.0)); - EXPECT_TRUE(context->IsNodeExpandedInContext(node)); + EXPECT_FALSE(context->set_node_position_in_context(node, QPointF(5.0, 6.0))); + EXPECT_EQ(context->get_node_position_in_context(node), QPointF(5.0, 6.0)); + EXPECT_TRUE(context->is_node_expanded_in_context(node)); EXPECT_EQ(added_count, 1); ASSERT_EQ(positions.size(), 2); EXPECT_EQ(positions.at(1), QPointF(5.0, 6.0)); - context->SetNodeExpandedInContext(node, false); - EXPECT_FALSE(context->IsNodeExpandedInContext(node)); + context->set_node_expanded_in_context(node, false); + EXPECT_FALSE(context->is_node_expanded_in_context(node)); - EXPECT_TRUE(context->RemoveNodeFromContext(node)); - EXPECT_FALSE(context->ContextContainsNode(node)); + EXPECT_TRUE(context->remove_node_from_context(node)); + EXPECT_FALSE(context->context_contains_node(node)); EXPECT_EQ(removed_count, 1); // Removing a node that is not in the context is a no-op - EXPECT_FALSE(context->RemoveNodeFromContext(node)); + EXPECT_FALSE(context->remove_node_from_context(node)); EXPECT_EQ(removed_count, 1); } @@ -491,29 +491,29 @@ TEST_F(NodeCoreTest, ContextPositionSaveLoadAndOperators) TEST_F(NodeCoreTest, LinkAndUnlinkLifecycle) { - auto *a = AddNode(); - auto *b = AddNode(); + auto *a = add_node(); + auto *b = add_node(); int a_changes = 0; int b_changes = 0; - QObject::connect(a, &olive::Node::LinksChanged, + QObject::connect(a, &olive::Node::links_changed, [&a_changes]() { ++a_changes; }); - QObject::connect(b, &olive::Node::LinksChanged, + QObject::connect(b, &olive::Node::links_changed, [&b_changes]() { ++b_changes; }); - EXPECT_FALSE(olive::Node::AreLinked(a, b)); - EXPECT_FALSE(a->HasLinks()); - EXPECT_FALSE(b->HasLinks()); + EXPECT_FALSE(olive::Node::are_linked(a, b)); + EXPECT_FALSE(a->has_links()); + EXPECT_FALSE(b->has_links()); // Invalid pairs are rejected - EXPECT_FALSE(olive::Node::Link(a, a)); - EXPECT_FALSE(olive::Node::Link(a, nullptr)); - EXPECT_FALSE(olive::Node::Link(nullptr, b)); + EXPECT_FALSE(olive::Node::link(a, a)); + EXPECT_FALSE(olive::Node::link(a, nullptr)); + EXPECT_FALSE(olive::Node::link(nullptr, b)); - EXPECT_TRUE(olive::Node::Link(a, b)); - EXPECT_TRUE(olive::Node::AreLinked(a, b)); - EXPECT_TRUE(olive::Node::AreLinked(b, a)); - EXPECT_TRUE(a->HasLinks()); + EXPECT_TRUE(olive::Node::link(a, b)); + EXPECT_TRUE(olive::Node::are_linked(a, b)); + EXPECT_TRUE(olive::Node::are_linked(b, a)); + EXPECT_TRUE(a->has_links()); ASSERT_EQ(a->links().size(), 1); EXPECT_EQ(a->links().first(), b); EXPECT_EQ(b->links().first(), a); @@ -521,91 +521,91 @@ TEST_F(NodeCoreTest, LinkAndUnlinkLifecycle) EXPECT_EQ(b_changes, 1); // Linking an already-linked pair does nothing - EXPECT_FALSE(olive::Node::Link(a, b)); + EXPECT_FALSE(olive::Node::link(a, b)); EXPECT_EQ(a_changes, 1); EXPECT_EQ(b_changes, 1); - EXPECT_TRUE(olive::Node::Unlink(a, b)); - EXPECT_FALSE(olive::Node::AreLinked(a, b)); - EXPECT_FALSE(a->HasLinks()); + EXPECT_TRUE(olive::Node::unlink(a, b)); + EXPECT_FALSE(olive::Node::are_linked(a, b)); + EXPECT_FALSE(a->has_links()); EXPECT_EQ(a_changes, 2); EXPECT_EQ(b_changes, 2); // Unlinking an unlinked pair does nothing - EXPECT_FALSE(olive::Node::Unlink(a, b)); + EXPECT_FALSE(olive::Node::unlink(a, b)); EXPECT_EQ(a_changes, 2); EXPECT_EQ(b_changes, 2); } TEST_F(NodeCoreTest, OverrideColorEmitsOnlyOnChange) { - auto *node = AddNode(); - ASSERT_EQ(node->GetOverrideColor(), -1); + auto *node = add_node(); + ASSERT_EQ(node->get_override_color(), -1); int emissions = 0; - QObject::connect(node, &olive::Node::ColorChanged, + QObject::connect(node, &olive::Node::color_changed, [&emissions]() { ++emissions; }); - node->SetOverrideColor(4); - EXPECT_EQ(node->GetOverrideColor(), 4); + node->set_override_color(4); + EXPECT_EQ(node->get_override_color(), 4); EXPECT_EQ(emissions, 1); // Setting the same color again is not a change - node->SetOverrideColor(4); + node->set_override_color(4); EXPECT_EQ(emissions, 1); - node->SetOverrideColor(-1); - EXPECT_EQ(node->GetOverrideColor(), -1); + node->set_override_color(-1); + EXPECT_EQ(node->get_override_color(), -1); EXPECT_EQ(emissions, 2); } TEST_F(NodeCoreTest, ValueHintAccessorsEmitSignal) { - auto *node = AddNode(); + auto *node = add_node(); // The default hint is empty const olive::Node::ValueHint def = - node->GetValueHintForInput(olive::MathNode::kParamAIn); + node->get_value_hint_for_input(olive::MathNode::k_param_a_in); EXPECT_TRUE(def.types().isEmpty()); EXPECT_EQ(def.index(), -1); EXPECT_TRUE(def.tag().isEmpty()); QVector hinted; - QObject::connect(node, &olive::Node::InputValueHintChanged, + QObject::connect(node, &olive::Node::input_value_hint_changed, [&hinted](const olive::NodeInput &input) { hinted.append(input); }); - const olive::Node::ValueHint hint({ olive::NodeValue::kVec2 }, 3, + const olive::Node::ValueHint hint({ olive::NodeValue::k_vec2 }, 3, QStringLiteral("tag")); - node->SetValueHintForInput(olive::MathNode::kParamAIn, hint); + node->set_value_hint_for_input(olive::MathNode::k_param_a_in, hint); const olive::Node::ValueHint stored = - node->GetValueHintForInput(olive::MathNode::kParamAIn); + node->get_value_hint_for_input(olive::MathNode::k_param_a_in); ASSERT_EQ(stored.types().size(), 1); - EXPECT_EQ(stored.types().first(), olive::NodeValue::kVec2); + EXPECT_EQ(stored.types().first(), olive::NodeValue::k_vec2); EXPECT_EQ(stored.index(), 3); EXPECT_EQ(stored.tag(), QStringLiteral("tag")); ASSERT_EQ(hinted.size(), 1); EXPECT_EQ(hinted.first(), - olive::NodeInput(node, olive::MathNode::kParamAIn, -1)); - EXPECT_FALSE(node->GetValueHints().isEmpty()); + olive::NodeInput(node, olive::MathNode::k_param_a_in, -1)); + EXPECT_FALSE(node->get_value_hints().isEmpty()); // Hints are tracked per element - node->SetValueHintForInput(olive::MathNode::kParamAIn, + node->set_value_hint_for_input(olive::MathNode::k_param_a_in, olive::Node::ValueHint(QStringLiteral("elem")), 2); - EXPECT_EQ(node->GetValueHintForInput(olive::MathNode::kParamAIn, 2).tag(), + EXPECT_EQ(node->get_value_hint_for_input(olive::MathNode::k_param_a_in, 2).tag(), QStringLiteral("elem")); - EXPECT_EQ(node->GetValueHintForInput(olive::MathNode::kParamAIn, 1).index(), + EXPECT_EQ(node->get_value_hint_for_input(olive::MathNode::k_param_a_in, 1).index(), -1); } TEST_F(NodeCoreTest, ValueHintSaveLoadRoundTrip) { const olive::Node::ValueHint hint( - { olive::NodeValue::kVec2, olive::NodeValue::kTexture }, 7, + { olive::NodeValue::k_vec2, olive::NodeValue::k_texture }, 7, QStringLiteral("mytag")); QString xml; @@ -623,8 +623,8 @@ TEST_F(NodeCoreTest, ValueHintSaveLoadRoundTrip) olive::Node::ValueHint loaded; ASSERT_TRUE(loaded.load(&reader)); ASSERT_EQ(loaded.types().size(), 2); - EXPECT_EQ(loaded.types().at(0), olive::NodeValue::kVec2); - EXPECT_EQ(loaded.types().at(1), olive::NodeValue::kTexture); + EXPECT_EQ(loaded.types().at(0), olive::NodeValue::k_vec2); + EXPECT_EQ(loaded.types().at(1), olive::NodeValue::k_texture); EXPECT_EQ(loaded.index(), 7); EXPECT_EQ(loaded.tag(), QStringLiteral("mytag")); @@ -648,39 +648,39 @@ TEST_F(NodeCoreTest, ValueHintSaveLoadRoundTrip) TEST_F(NodeCoreTest, EdgeAndValueChangesPropagateInvalidateCache) { - auto *src = AddNode(); - auto *dst = AddNode(); - const olive::NodeInput dst_input(dst, RecordingNode::kTestInput); + auto *src = add_node(); + auto *dst = add_node(); + const olive::NodeInput dst_input(dst, RecordingNode::k_test_input); - const olive::rational kMin(INT_MIN); - const olive::rational kMax(INT_MAX); + const olive::Rational k_min(INT_MIN); + const olive::Rational k_max(INT_MAX); QVector value_changed_inputs; - QObject::connect(src, &olive::Node::ValueChanged, + QObject::connect(src, &olive::Node::value_changed, [&value_changed_inputs](const olive::NodeInput &input, const olive::TimeRange &) { value_changed_inputs.append(input); }); // Connecting an edge invalidates the destination over the full range - olive::Node::ConnectEdge(src, dst_input); + olive::Node::connect_edge(src, dst_input); ASSERT_EQ(dst->invalidations.size(), 1); - EXPECT_EQ(dst->invalidations.first().from, RecordingNode::kTestInput); + EXPECT_EQ(dst->invalidations.first().from, RecordingNode::k_test_input); EXPECT_EQ(dst->invalidations.first().element, -1); - EXPECT_EQ(dst->invalidations.first().range.in(), kMin); - EXPECT_EQ(dst->invalidations.first().range.out(), kMax); + EXPECT_EQ(dst->invalidations.first().range.in(), k_min); + EXPECT_EQ(dst->invalidations.first().range.out(), k_max); // Changing a value upstream emits ValueChanged and invalidates downstream - src->SetStandardValue(olive::MathNode::kParamAIn, 2.0); + src->set_standard_value(olive::MathNode::k_param_a_in, 2.0); ASSERT_EQ(value_changed_inputs.size(), 1); EXPECT_EQ(value_changed_inputs.first(), - olive::NodeInput(src, olive::MathNode::kParamAIn)); + olive::NodeInput(src, olive::MathNode::k_param_a_in)); ASSERT_EQ(dst->invalidations.size(), 2); - EXPECT_EQ(dst->invalidations.at(1).range.in(), kMin); - EXPECT_EQ(dst->invalidations.at(1).range.out(), kMax); + EXPECT_EQ(dst->invalidations.at(1).range.in(), k_min); + EXPECT_EQ(dst->invalidations.at(1).range.out(), k_max); // Disconnecting the edge invalidates the destination again - olive::Node::DisconnectEdge(src, dst_input); + olive::Node::disconnect_edge(src, dst_input); ASSERT_EQ(dst->invalidations.size(), 3); EXPECT_TRUE(dst->input_connections().empty()); EXPECT_TRUE(src->output_connections().empty()); @@ -688,84 +688,84 @@ TEST_F(NodeCoreTest, EdgeAndValueChangesPropagateInvalidateCache) TEST_F(NodeCoreTest, IgnoreInvalidationsFlagSuppressesInvalidation) { - auto *src = AddNode(); - auto *dst = AddNode(); - const olive::NodeInput dst_input(dst, RecordingNode::kTestInput); + auto *src = add_node(); + auto *dst = add_node(); + const olive::NodeInput dst_input(dst, RecordingNode::k_test_input); // The flag on the destination input suppresses connect/disconnect // invalidation - dst->SetInputFlag(RecordingNode::kTestInput, - olive::kInputFlagIgnoreInvalidations); - olive::Node::ConnectEdge(src, dst_input); + dst->set_input_flag(RecordingNode::k_test_input, + olive::k_input_flag_ignore_invalidations); + olive::Node::connect_edge(src, dst_input); EXPECT_TRUE(dst->invalidations.isEmpty()); // The flag on the source input suppresses value-change propagation, but // the ValueChanged signal is still emitted int value_changed_count = 0; - QObject::connect(src, &olive::Node::ValueChanged, + QObject::connect(src, &olive::Node::value_changed, [&value_changed_count](const olive::NodeInput &, const olive::TimeRange &) { ++value_changed_count; }); - src->SetInputFlag(olive::MathNode::kParamAIn, - olive::kInputFlagIgnoreInvalidations); - src->SetStandardValue(olive::MathNode::kParamAIn, 5.0); + src->set_input_flag(olive::MathNode::k_param_a_in, + olive::k_input_flag_ignore_invalidations); + src->set_standard_value(olive::MathNode::k_param_a_in, 5.0); EXPECT_EQ(value_changed_count, 1); EXPECT_TRUE(dst->invalidations.isEmpty()); - olive::Node::DisconnectEdge(src, dst_input); + olive::Node::disconnect_edge(src, dst_input); EXPECT_TRUE(dst->invalidations.isEmpty()); } TEST_F(NodeCoreTest, InvalidateAllRelaysThroughGraph) { - auto *src = AddNode(); - auto *mid = AddNode(); - auto *dst = AddNode(); - olive::Node::ConnectEdge( - src, olive::NodeInput(mid, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge( - mid, olive::NodeInput(dst, RecordingNode::kTestInput)); + auto *src = add_node(); + auto *mid = add_node(); + auto *dst = add_node(); + olive::Node::connect_edge( + src, olive::NodeInput(mid, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge( + mid, olive::NodeInput(dst, RecordingNode::k_test_input)); dst->invalidations.clear(); - const olive::rational kMin(INT_MIN); - const olive::rational kMax(INT_MAX); + const olive::Rational k_min(INT_MIN); + const olive::Rational k_max(INT_MAX); // InvalidateAll propagates the full time range across multiple hops - src->InvalidateAll(olive::MathNode::kParamAIn); + src->invalidate_all(olive::MathNode::k_param_a_in); ASSERT_EQ(dst->invalidations.size(), 1); - EXPECT_EQ(dst->invalidations.first().from, RecordingNode::kTestInput); + EXPECT_EQ(dst->invalidations.first().from, RecordingNode::k_test_input); EXPECT_EQ(dst->invalidations.first().element, -1); - EXPECT_EQ(dst->invalidations.first().range.in(), kMin); - EXPECT_EQ(dst->invalidations.first().range.out(), kMax); + EXPECT_EQ(dst->invalidations.first().range.in(), k_min); + EXPECT_EQ(dst->invalidations.first().range.out(), k_max); // A zero-length range touches no caches but is still relayed - src->InvalidateCache( - olive::TimeRange(olive::rational(3), olive::rational(3)), - olive::MathNode::kParamAIn, -1); + src->invalidate_cache( + olive::TimeRange(olive::Rational(3), olive::Rational(3)), + olive::MathNode::k_param_a_in, -1); ASSERT_EQ(dst->invalidations.size(), 2); - EXPECT_EQ(dst->invalidations.at(1).range.in(), olive::rational(3)); - EXPECT_EQ(dst->invalidations.at(1).range.out(), olive::rational(3)); + EXPECT_EQ(dst->invalidations.at(1).range.in(), olive::Rational(3)); + EXPECT_EQ(dst->invalidations.at(1).range.out(), olive::Rational(3)); // Disabled caches skip cache invalidation, but propagation continues - EXPECT_TRUE(src->AreCachesEnabled()); - src->SetCachesEnabled(false); - EXPECT_FALSE(src->AreCachesEnabled()); - src->InvalidateAll(olive::MathNode::kParamAIn); + EXPECT_TRUE(src->are_caches_enabled()); + src->set_caches_enabled(false); + EXPECT_FALSE(src->are_caches_enabled()); + src->invalidate_all(olive::MathNode::k_param_a_in); ASSERT_EQ(dst->invalidations.size(), 3); - EXPECT_EQ(dst->invalidations.at(2).range.in(), kMin); + EXPECT_EQ(dst->invalidations.at(2).range.in(), k_min); } TEST_F(NodeCoreTest, KeyframeAddAndRemovalEmitSignals) { - auto *node = AddNode(); + auto *node = add_node(); - const olive::rational kMin(INT_MIN); - const olive::rational kMax(INT_MAX); + const olive::Rational k_min(INT_MIN); + const olive::Rational k_max(INT_MAX); int enable_changed = 0; bool last_enabled = false; - QObject::connect(node, &olive::Node::KeyframeEnableChanged, + QObject::connect(node, &olive::Node::keyframe_enable_changed, [&enable_changed, &last_enabled](const olive::NodeInput &, bool enabled) { ++enable_changed; @@ -773,86 +773,86 @@ TEST_F(NodeCoreTest, KeyframeAddAndRemovalEmitSignals) }); int added = 0; int removed = 0; - QObject::connect(node, &olive::Node::KeyframeAdded, + QObject::connect(node, &olive::Node::keyframe_added, [&added](olive::NodeKeyframe *) { ++added; }); - QObject::connect(node, &olive::Node::KeyframeRemoved, + QObject::connect(node, &olive::Node::keyframe_removed, [&removed](olive::NodeKeyframe *) { ++removed; }); QVector changed_ranges; - QObject::connect(node, &olive::Node::ValueChanged, + QObject::connect(node, &olive::Node::value_changed, [&changed_ranges](const olive::NodeInput &, const olive::TimeRange &range) { changed_ranges.append(range); }); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); EXPECT_EQ(enable_changed, 1); EXPECT_TRUE(last_enabled); // The first keyframe on a track invalidates the whole range auto *first = new olive::NodeKeyframe( - olive::rational(5), 1.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + olive::Rational(5), 1.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); first->setParent(node); EXPECT_EQ(added, 1); ASSERT_EQ(changed_ranges.size(), 1); - EXPECT_EQ(changed_ranges.first().in(), kMin); - EXPECT_EQ(changed_ranges.first().out(), kMax); + EXPECT_EQ(changed_ranges.first().in(), k_min); + EXPECT_EQ(changed_ranges.first().out(), k_max); // A later keyframe only invalidates from the previous keyframe onward auto *second = new olive::NodeKeyframe( - olive::rational(10), 2.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + olive::Rational(10), 2.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); second->setParent(node); EXPECT_EQ(added, 2); ASSERT_EQ(changed_ranges.size(), 2); - EXPECT_EQ(changed_ranges.at(1).in(), olive::rational(5)); - EXPECT_EQ(changed_ranges.at(1).out(), kMax); + EXPECT_EQ(changed_ranges.at(1).in(), olive::Rational(5)); + EXPECT_EQ(changed_ranges.at(1).out(), k_max); // Removing the later keyframe invalidates from the remaining one onward second->setParent(nullptr); EXPECT_EQ(removed, 1); ASSERT_EQ(changed_ranges.size(), 3); - EXPECT_EQ(changed_ranges.at(2).in(), olive::rational(5)); - EXPECT_EQ(changed_ranges.at(2).out(), kMax); + EXPECT_EQ(changed_ranges.at(2).in(), olive::Rational(5)); + EXPECT_EQ(changed_ranges.at(2).out(), k_max); delete second; // Removing the last keyframe invalidates everything again first->setParent(nullptr); EXPECT_EQ(removed, 2); ASSERT_EQ(changed_ranges.size(), 4); - EXPECT_EQ(changed_ranges.at(3).in(), kMin); - EXPECT_EQ(changed_ranges.at(3).out(), kMax); + EXPECT_EQ(changed_ranges.at(3).in(), k_min); + EXPECT_EQ(changed_ranges.at(3).out(), k_max); delete first; - EXPECT_TRUE(node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1) .at(0) .isEmpty()); } TEST_F(NodeCoreTest, KeyframeTimeChangeResortsTrackAndEmits) { - auto *node = AddNode(); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + auto *node = add_node(); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); auto *first = new olive::NodeKeyframe( - olive::rational(0), 0.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + olive::Rational(0), 0.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); first->setParent(node); auto *second = new olive::NodeKeyframe( - olive::rational(10), 10.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + olive::Rational(10), 10.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); second->setParent(node); const QVector &tracks = - node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1); + node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1); ASSERT_EQ(tracks.at(0).size(), 2); EXPECT_EQ(tracks.at(0).first(), first); - EXPECT_EQ(node->GetEarliestKeyframe(olive::MathNode::kParamAIn), first); - EXPECT_EQ(node->GetLatestKeyframe(olive::MathNode::kParamAIn), second); + EXPECT_EQ(node->get_earliest_keyframe(olive::MathNode::k_param_a_in), first); + EXPECT_EQ(node->get_latest_keyframe(olive::MathNode::k_param_a_in), second); int time_changed = 0; olive::NodeKeyframe *last_changed = nullptr; - QObject::connect(node, &olive::Node::KeyframeTimeChanged, + QObject::connect(node, &olive::Node::keyframe_time_changed, [&time_changed, &last_changed](olive::NodeKeyframe *key) { ++time_changed; @@ -860,238 +860,238 @@ TEST_F(NodeCoreTest, KeyframeTimeChangeResortsTrackAndEmits) }); // Moving the first keyframe past the second resorts the track - first->set_time(olive::rational(20)); + first->set_time(olive::Rational(20)); EXPECT_EQ(time_changed, 1); EXPECT_EQ(last_changed, first); ASSERT_EQ(tracks.at(0).size(), 2); EXPECT_EQ(tracks.at(0).first(), second); EXPECT_EQ(tracks.at(0).last(), first); - EXPECT_EQ(node->GetEarliestKeyframe(olive::MathNode::kParamAIn), second); - EXPECT_EQ(node->GetLatestKeyframe(olive::MathNode::kParamAIn), first); - EXPECT_EQ(node->GetClosestKeyframeBeforeTime(olive::MathNode::kParamAIn, - olive::rational(15)), + EXPECT_EQ(node->get_earliest_keyframe(olive::MathNode::k_param_a_in), second); + EXPECT_EQ(node->get_latest_keyframe(olive::MathNode::k_param_a_in), first); + EXPECT_EQ(node->get_closest_keyframe_before_time(olive::MathNode::k_param_a_in, + olive::Rational(15)), second); - EXPECT_EQ(node->GetClosestKeyframeAfterTime(olive::MathNode::kParamAIn, - olive::rational(15)), + EXPECT_EQ(node->get_closest_keyframe_after_time(olive::MathNode::k_param_a_in, + olive::Rational(15)), first); - EXPECT_TRUE(node->HasKeyframeAtTime(olive::MathNode::kParamAIn, - olive::rational(20))); - EXPECT_EQ(node->GetKeyframeAtTimeOnTrack(olive::MathNode::kParamAIn, - olive::rational(10), 0), + EXPECT_TRUE(node->has_keyframe_at_time(olive::MathNode::k_param_a_in, + olive::Rational(20))); + EXPECT_EQ(node->get_keyframe_at_time_on_track(olive::MathNode::k_param_a_in, + olive::Rational(10), 0), second); - EXPECT_EQ(node->GetKeyframesAtTime(olive::MathNode::kParamAIn, - olive::rational(20)) + EXPECT_EQ(node->get_keyframes_at_time(olive::MathNode::k_param_a_in, + olive::Rational(20)) .size(), 1); } TEST_F(NodeCoreTest, GetValueAtTimeUsesStandardValueWhenStatic) { - auto *node = AddNode(); - node->SetStandardValue(olive::MathNode::kParamAIn, 2.5); + auto *node = add_node(); + node->set_standard_value(olive::MathNode::k_param_a_in, 2.5); // A static input returns its standard value at any time - EXPECT_DOUBLE_EQ(node->GetValueAtTime(olive::MathNode::kParamAIn, - olive::rational(-100)) + EXPECT_DOUBLE_EQ(node->get_value_at_time(olive::MathNode::k_param_a_in, + olive::Rational(-100)) .toDouble(), 2.5); EXPECT_DOUBLE_EQ( - node->GetValueAtTime(olive::MathNode::kParamAIn, olive::rational(0)) + node->get_value_at_time(olive::MathNode::k_param_a_in, olive::Rational(0)) .toDouble(), 2.5); - EXPECT_DOUBLE_EQ(node->GetValueAtTime(olive::MathNode::kParamAIn, - olive::rational(100)) + EXPECT_DOUBLE_EQ(node->get_value_at_time(olive::MathNode::k_param_a_in, + olive::Rational(100)) .toDouble(), 2.5); // Same result through the NodeInput convenience overload - EXPECT_DOUBLE_EQ(node->GetValueAtTime( - olive::NodeInput(node, olive::MathNode::kParamAIn), - olive::rational(3)) + EXPECT_DOUBLE_EQ(node->get_value_at_time( + olive::NodeInput(node, olive::MathNode::k_param_a_in), + olive::Rational(3)) .toDouble(), 2.5); } TEST_F(NodeCoreTest, GetValueAtTimeInterpolatesLinearKeyframes) { - auto *node = AddNode(); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + auto *node = add_node(); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); auto *first = new olive::NodeKeyframe( - olive::rational(0), 0.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + olive::Rational(0), 0.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); first->setParent(node); auto *second = new olive::NodeKeyframe( - olive::rational(10), 10.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + olive::Rational(10), 10.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); second->setParent(node); // Outside the keyed range the nearest keyframe value holds - EXPECT_DOUBLE_EQ(node->GetValueAtTime(olive::MathNode::kParamAIn, - olive::rational(-5)) + EXPECT_DOUBLE_EQ(node->get_value_at_time(olive::MathNode::k_param_a_in, + olive::Rational(-5)) .toDouble(), 0.0); - EXPECT_DOUBLE_EQ(node->GetValueAtTime(olive::MathNode::kParamAIn, - olive::rational(15)) + EXPECT_DOUBLE_EQ(node->get_value_at_time(olive::MathNode::k_param_a_in, + olive::Rational(15)) .toDouble(), 10.0); // Exactly on a keyframe the value is exact EXPECT_DOUBLE_EQ( - node->GetValueAtTime(olive::MathNode::kParamAIn, olive::rational(0)) + node->get_value_at_time(olive::MathNode::k_param_a_in, olive::Rational(0)) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node->GetValueAtTime(olive::MathNode::kParamAIn, olive::rational(10)) + node->get_value_at_time(olive::MathNode::k_param_a_in, olive::Rational(10)) .toDouble(), 10.0); // Between two linear keys the value interpolates linearly EXPECT_DOUBLE_EQ( - node->GetValueAtTime(olive::MathNode::kParamAIn, olive::rational(5)) + node->get_value_at_time(olive::MathNode::k_param_a_in, olive::Rational(5)) .toDouble(), 5.0); const olive::SplitValue split = - node->GetSplitValueAtTime(olive::MathNode::kParamAIn, - olive::rational(5)); + node->get_split_value_at_time(olive::MathNode::k_param_a_in, + olive::Rational(5)); ASSERT_EQ(split.size(), 1); EXPECT_DOUBLE_EQ(split.at(0).toDouble(), 5.0); } TEST_F(NodeCoreTest, GetValueAtTimeRespectsHoldKeyframes) { - auto *node = AddNode(); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + auto *node = add_node(); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); auto *hold = new olive::NodeKeyframe( - olive::rational(0), 1.0, olive::NodeKeyframe::kHold, 0, -1, - olive::MathNode::kParamAIn); + olive::Rational(0), 1.0, olive::NodeKeyframe::k_hold, 0, -1, + olive::MathNode::k_param_a_in); hold->setParent(node); auto *linear = new olive::NodeKeyframe( - olive::rational(10), 3.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + olive::Rational(10), 3.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); linear->setParent(node); // A hold keyframe keeps its value until the next keyframe's time EXPECT_DOUBLE_EQ( - node->GetValueAtTime(olive::MathNode::kParamAIn, olive::rational(0)) + node->get_value_at_time(olive::MathNode::k_param_a_in, olive::Rational(0)) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node->GetValueAtTime(olive::MathNode::kParamAIn, olive::rational(5)) + node->get_value_at_time(olive::MathNode::k_param_a_in, olive::Rational(5)) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node->GetValueAtTime(olive::MathNode::kParamAIn, olive::rational(9)) + node->get_value_at_time(olive::MathNode::k_param_a_in, olive::Rational(9)) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node->GetValueAtTime(olive::MathNode::kParamAIn, olive::rational(10)) + node->get_value_at_time(olive::MathNode::k_param_a_in, olive::Rational(10)) .toDouble(), 3.0); } TEST_F(NodeCoreTest, CopyInputsCopiesValuesKeyframesLabelAndColor) { - auto *src = AddNode(); - auto *dst = AddNode(); + auto *src = add_node(); + auto *dst = add_node(); - src->SetStandardValue(olive::MathNode::kParamAIn, 3.5); - src->SetOperation(olive::MathNode::kOpMultiply); - src->SetLabel(QStringLiteral("source label")); - src->SetOverrideColor(2); - src->SetValueHintForInput( - olive::MathNode::kParamAIn, - olive::Node::ValueHint({ olive::NodeValue::kVec2 }, 1, + src->set_standard_value(olive::MathNode::k_param_a_in, 3.5); + src->set_operation(olive::MathNode::k_op_multiply); + src->set_label(QStringLiteral("source label")); + src->set_override_color(2); + src->set_value_hint_for_input( + olive::MathNode::k_param_a_in, + olive::Node::ValueHint({ olive::NodeValue::k_vec2 }, 1, QStringLiteral("hint"))); - src->SetInputIsKeyframing(olive::MathNode::kParamBIn, true); + src->set_input_is_keyframing(olive::MathNode::k_param_b_in, true); auto *key = new olive::NodeKeyframe( - olive::rational(4), 8.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamBIn); + olive::Rational(4), 8.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_b_in); key->setParent(src); - olive::Node::CopyInputs(src, dst, false); + olive::Node::copy_inputs(src, dst, false); EXPECT_DOUBLE_EQ( - dst->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 3.5); - EXPECT_EQ(dst->GetOperation(), olive::MathNode::kOpMultiply); - EXPECT_EQ(dst->GetLabel(), QStringLiteral("source label")); - EXPECT_EQ(dst->GetOverrideColor(), 2); - EXPECT_EQ(dst->GetValueHintForInput(olive::MathNode::kParamAIn).tag(), + dst->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 3.5); + EXPECT_EQ(dst->get_operation(), olive::MathNode::k_op_multiply); + EXPECT_EQ(dst->get_label(), QStringLiteral("source label")); + EXPECT_EQ(dst->get_override_color(), 2); + EXPECT_EQ(dst->get_value_hint_for_input(olive::MathNode::k_param_a_in).tag(), QStringLiteral("hint")); - EXPECT_TRUE(dst->IsInputKeyframing(olive::MathNode::kParamBIn)); + EXPECT_TRUE(dst->is_input_keyframing(olive::MathNode::k_param_b_in)); const QVector &tracks = - dst->GetKeyframeTracks(olive::MathNode::kParamBIn, -1); + dst->get_keyframe_tracks(olive::MathNode::k_param_b_in, -1); ASSERT_EQ(tracks.at(0).size(), 1); - EXPECT_EQ(tracks.at(0).first()->time(), olive::rational(4)); + EXPECT_EQ(tracks.at(0).first()->time(), olive::Rational(4)); EXPECT_DOUBLE_EQ(tracks.at(0).first()->value().toDouble(), 8.0); // The copied keyframe belongs to the destination, not the source EXPECT_EQ(tracks.at(0).first()->parent(), dst); EXPECT_NE(tracks.at(0).first(), key); // Copied values are independent of the source - src->SetStandardValue(olive::MathNode::kParamAIn, 9.0); + src->set_standard_value(olive::MathNode::k_param_a_in, 9.0); EXPECT_DOUBLE_EQ( - dst->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 3.5); + dst->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 3.5); } TEST_F(NodeCoreTest, CopyInputsCopiesConnectionsWhenRequested) { - auto *output = AddNode(); - auto *src = AddNode(); - auto *dst = AddNode(); - olive::Node::ConnectEdge( - output, olive::NodeInput(src, olive::MathNode::kParamAIn)); + auto *output = add_node(); + auto *src = add_node(); + auto *dst = add_node(); + olive::Node::connect_edge( + output, olive::NodeInput(src, olive::MathNode::k_param_a_in)); // Without connections requested, the destination stays unconnected - olive::Node::CopyInputs(src, dst, false); - EXPECT_EQ(dst->GetConnectedOutput(olive::MathNode::kParamAIn), nullptr); + olive::Node::copy_inputs(src, dst, false); + EXPECT_EQ(dst->get_connected_output(olive::MathNode::k_param_a_in), nullptr); // With connections requested, the destination connects to the same output - olive::Node::CopyInputs(src, dst, true); - EXPECT_EQ(dst->GetConnectedOutput(olive::MathNode::kParamAIn), output); + olive::Node::copy_inputs(src, dst, true); + EXPECT_EQ(dst->get_connected_output(olive::MathNode::k_param_a_in), output); } TEST_F(NodeCoreTest, CopyInputsCopiesArrayElements) { - auto *src = AddNode(); - auto *dst = AddNode(); + auto *src = add_node(); + auto *dst = add_node(); - src->InputArrayResize(olive::TextGeneratorV3::kArgsInput, 2); - src->SetStandardValue( - olive::NodeInput(src, olive::TextGeneratorV3::kArgsInput, 0), + src->input_array_resize(olive::TextGeneratorV3::k_args_input, 2); + src->set_standard_value( + olive::NodeInput(src, olive::TextGeneratorV3::k_args_input, 0), QStringLiteral("first")); - src->SetStandardValue( - olive::NodeInput(src, olive::TextGeneratorV3::kArgsInput, 1), + src->set_standard_value( + olive::NodeInput(src, olive::TextGeneratorV3::k_args_input, 1), QStringLiteral("second")); - src->SetInputIsKeyframing(olive::TextGeneratorV3::kArgsInput, true, 1); + src->set_input_is_keyframing(olive::TextGeneratorV3::k_args_input, true, 1); auto *key = new olive::NodeKeyframe( - olive::rational(2), QStringLiteral("keyed"), olive::NodeKeyframe::kLinear, - 0, 1, olive::TextGeneratorV3::kArgsInput); + olive::Rational(2), QStringLiteral("keyed"), olive::NodeKeyframe::k_linear, + 0, 1, olive::TextGeneratorV3::k_args_input); key->setParent(src); - olive::Node::CopyInputs(src, dst, false); + olive::Node::copy_inputs(src, dst, false); - EXPECT_EQ(dst->InputArraySize(olive::TextGeneratorV3::kArgsInput), 2); - EXPECT_EQ(dst->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, 0) + EXPECT_EQ(dst->input_array_size(olive::TextGeneratorV3::k_args_input), 2); + EXPECT_EQ(dst->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 0) .at(0) .toString(), QStringLiteral("first")); - EXPECT_EQ(dst->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, 1) + EXPECT_EQ(dst->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 1) .at(0) .toString(), QStringLiteral("second")); - EXPECT_TRUE(dst->IsInputKeyframing(olive::TextGeneratorV3::kArgsInput, 1)); - EXPECT_FALSE(dst->IsInputKeyframing(olive::TextGeneratorV3::kArgsInput, 0)); - ASSERT_EQ(dst->GetKeyframeTracks(olive::TextGeneratorV3::kArgsInput, 1) + EXPECT_TRUE(dst->is_input_keyframing(olive::TextGeneratorV3::k_args_input, 1)); + EXPECT_FALSE(dst->is_input_keyframing(olive::TextGeneratorV3::k_args_input, 0)); + ASSERT_EQ(dst->get_keyframe_tracks(olive::TextGeneratorV3::k_args_input, 1) .at(0) .size(), 1); - EXPECT_EQ(dst->GetKeyframeTracks(olive::TextGeneratorV3::kArgsInput, 1) + EXPECT_EQ(dst->get_keyframe_tracks(olive::TextGeneratorV3::k_args_input, 1) .at(0) .first() ->value() @@ -1101,16 +1101,16 @@ TEST_F(NodeCoreTest, CopyInputsCopiesArrayElements) TEST_F(NodeCoreTest, CopyDependencyGraphClonesAndReconnects) { - auto *solid = AddNode(); - auto *math = AddNode(); - math->SetStandardValue(olive::MathNode::kParamAIn, 6.0); - olive::Node::ConnectEdge( - solid, olive::NodeInput(math, olive::MathNode::kParamAIn)); - math->SetValueHintForInput(olive::MathNode::kParamAIn, + auto *solid = add_node(); + auto *math = add_node(); + math->set_standard_value(olive::MathNode::k_param_a_in, 6.0); + olive::Node::connect_edge( + solid, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + math->set_value_hint_for_input(olive::MathNode::k_param_a_in, olive::Node::ValueHint(QStringLiteral("tagged"))); const QVector copies = - olive::Node::CopyDependencyGraph({ solid, math }, nullptr); + olive::Node::copy_dependency_graph({ solid, math }, nullptr); ASSERT_EQ(copies.size(), 2); olive::Node *solid_copy = copies.at(0); @@ -1123,14 +1123,14 @@ TEST_F(NodeCoreTest, CopyDependencyGraphClonesAndReconnects) EXPECT_EQ(math_copy->project(), project_.get()); // The clone is wired to the cloned upstream node, not the original - EXPECT_EQ(math_copy->GetConnectedOutput(olive::MathNode::kParamAIn), + EXPECT_EQ(math_copy->get_connected_output(olive::MathNode::k_param_a_in), solid_copy); - EXPECT_EQ(math->GetConnectedOutput(olive::MathNode::kParamAIn), solid); + EXPECT_EQ(math->get_connected_output(olive::MathNode::k_param_a_in), solid); // ...and carries the source's values and hints EXPECT_DOUBLE_EQ( - math_copy->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), + math_copy->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 6.0); - EXPECT_EQ(math_copy->GetValueHintForInput(olive::MathNode::kParamAIn).tag(), + EXPECT_EQ(math_copy->get_value_hint_for_input(olive::MathNode::k_param_a_in).tag(), QStringLiteral("tagged")); } diff --git a/tests/gtest/node_distort_test.cpp b/tests/gtest/node_distort_test.cpp index d1029d7a0..603b4bd59 100644 --- a/tests/gtest/node_distort_test.cpp +++ b/tests/gtest/node_distort_test.cpp @@ -41,7 +41,7 @@ public: NODE_DEFAULT_FUNCTIONS(ConstantTextureNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Test Texture"); } @@ -51,98 +51,98 @@ public: return QStringLiteral("org.oak.test.distort_texture"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryGenerator }; + return { k_category_generator }; } - void SetTexture(const olive::TexturePtr &texture) + void set_texture(const olive::TexturePtr &texture) { texture_ = texture; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { Q_UNUSED(value) Q_UNUSED(globals) - table->Push(olive::NodeValue(olive::NodeValue::kTexture, texture_, this)); + table->push(olive::NodeValue(olive::NodeValue::k_texture, texture_, this)); } private: olive::TexturePtr texture_; }; -template T *AddNode(olive::Project *project) +template T *add_node(olive::Project *project) { T *node = new T(); node->setParent(project); return node; } -olive::TimeRange FirstFrame() +olive::TimeRange first_frame() { - return olive::TimeRange(olive::rational(0), olive::rational(1, 30)); + return olive::TimeRange(olive::Rational(0), olive::Rational(1, 30)); } // A fresh traverser per call: NodeTraverser caches tables per node/range, so // reusing one would return stale results after changing standard values. -olive::NodeValueTable GenerateTable(const olive::Node *node, +olive::NodeValueTable generate_table(const olive::Node *node, const olive::VideoParams &vparams) { olive::NodeTraverser traverser; - traverser.SetCacheVideoParams(vparams); - return traverser.GenerateTable(node, FirstFrame()); + traverser.set_cache_video_params(vparams); + return traverser.generate_table(node, first_frame()); } // A "dummy" texture has no renderer backend and is therefore safe to pass // around in a headless, CPU-only test. -olive::TexturePtr MakeDummyTexture(int width, int height) +olive::TexturePtr make_dummy_texture(int width, int height) { return std::make_shared( - olive::VideoParams(width, height, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(width, height, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); } -olive::VideoParams SequenceParams(int width, int height) +olive::VideoParams sequence_params(int width, int height) { - return olive::VideoParams(width, height, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + return olive::VideoParams(width, height, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); } -olive::NodeValue TextureValue(const olive::TexturePtr &texture) +olive::NodeValue texture_value(const olive::TexturePtr &texture) { - return olive::NodeValue(olive::NodeValue::kTexture, texture); + return olive::NodeValue(olive::NodeValue::k_texture, texture); } -olive::NodeValue FloatValue(double v) +olive::NodeValue float_value(double v) { - return olive::NodeValue(olive::NodeValue::kFloat, v); + return olive::NodeValue(olive::NodeValue::k_float, v); } -olive::NodeValue BoolValue(bool b) +olive::NodeValue bool_value(bool b) { - return olive::NodeValue(olive::NodeValue::kBoolean, b); + return olive::NodeValue(olive::NodeValue::k_boolean, b); } -olive::NodeValue Vec2Value(const QVector2D &v) +olive::NodeValue vec2_value(const QVector2D &v) { - return olive::NodeValue(olive::NodeValue::kVec2, v); + return olive::NodeValue(olive::NodeValue::k_vec2, v); } -olive::NodeValueRow MakeTextureRow(const QString &input, +olive::NodeValueRow make_texture_row(const QString &input, const olive::TexturePtr &tex) { olive::NodeValueRow row; - row.insert(input, TextureValue(tex)); + row.insert(input, texture_value(tex)); return row; } -olive::TexturePtr GetOutputTexture(const olive::NodeValueTable &table) +olive::TexturePtr get_output_texture(const olive::NodeValueTable &table) { - return table.Get(olive::NodeValue::kTexture).toTexture(); + return table.get(olive::NodeValue::k_texture).to_texture(); } } // namespace @@ -155,14 +155,14 @@ TEST(TransformDistortNode, MetadataIsCorrect) { olive::TransformDistortNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.transform")); - EXPECT_EQ(node.Name(), QStringLiteral("Transform")); + EXPECT_EQ(node.name(), QStringLiteral("Transform")); // ShortName() overrides MatrixGenerator's "Ortho" - EXPECT_EQ(node.ShortName(), QStringLiteral("Transform")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_EQ(node.short_name(), QStringLiteral("Transform")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::TransformDistortNode::kTextureInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::TransformDistortNode::k_texture_input); } TEST(TransformDistortNode, InputDefinitionsAndDefaults) @@ -171,83 +171,83 @@ TEST(TransformDistortNode, InputDefinitionsAndDefaults) // Texture is prepended, so it is the primary effect input and cannot be // keyframed - ASSERT_TRUE(node.HasInputWithID(olive::TransformDistortNode::kTextureInput)); - EXPECT_EQ(int(node.GetInputDataType(olive::TransformDistortNode::kTextureInput)), - int(olive::NodeValue::kTexture)); + ASSERT_TRUE(node.has_input_with_id(olive::TransformDistortNode::k_texture_input)); + EXPECT_EQ(int(node.get_input_data_type(olive::TransformDistortNode::k_texture_input)), + int(olive::NodeValue::k_texture)); EXPECT_FALSE( - node.IsInputKeyframable(olive::TransformDistortNode::kTextureInput)); + node.is_input_keyframable(olive::TransformDistortNode::k_texture_input)); - ASSERT_TRUE(node.HasInputWithID(olive::TransformDistortNode::kParentInput)); - EXPECT_EQ(int(node.GetInputDataType(olive::TransformDistortNode::kParentInput)), - int(olive::NodeValue::kMatrix)); + ASSERT_TRUE(node.has_input_with_id(olive::TransformDistortNode::k_parent_input)); + EXPECT_EQ(int(node.get_input_data_type(olive::TransformDistortNode::k_parent_input)), + int(olive::NodeValue::k_matrix)); - ASSERT_TRUE(node.HasInputWithID(olive::TransformDistortNode::kAutoscaleInput)); + ASSERT_TRUE(node.has_input_with_id(olive::TransformDistortNode::k_autoscale_input)); EXPECT_EQ( - int(node.GetInputDataType(olive::TransformDistortNode::kAutoscaleInput)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(node.GetStandardValue(olive::TransformDistortNode::kAutoscaleInput) + int(node.get_input_data_type(olive::TransformDistortNode::k_autoscale_input)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(node.get_standard_value(olive::TransformDistortNode::k_autoscale_input) .toInt(), - int(olive::TransformDistortNode::kAutoScaleNone)); + int(olive::TransformDistortNode::k_auto_scale_none)); ASSERT_TRUE( - node.HasInputWithID(olive::TransformDistortNode::kInterpolationInput)); - EXPECT_EQ(int(node.GetInputDataType( - olive::TransformDistortNode::kInterpolationInput)), - int(olive::NodeValue::kCombo)); + node.has_input_with_id(olive::TransformDistortNode::k_interpolation_input)); + EXPECT_EQ(int(node.get_input_data_type( + olive::TransformDistortNode::k_interpolation_input)), + int(olive::NodeValue::k_combo)); // 2 = mipmapped bilinear - EXPECT_EQ(node.GetStandardValue( - olive::TransformDistortNode::kInterpolationInput) + EXPECT_EQ(node.get_standard_value( + olive::TransformDistortNode::k_interpolation_input) .toInt(), - int(olive::Texture::kMipmappedLinear)); + int(olive::Texture::k_mipmapped_linear)); // MatrixGenerator inputs are inherited - EXPECT_TRUE(node.HasInputWithID(olive::MatrixGenerator::kPositionInput)); - EXPECT_TRUE(node.HasInputWithID(olive::MatrixGenerator::kRotationInput)); - EXPECT_TRUE(node.HasInputWithID(olive::MatrixGenerator::kScaleInput)); - EXPECT_TRUE(node.HasInputWithID(olive::MatrixGenerator::kUniformScaleInput)); - EXPECT_TRUE(node.HasInputWithID(olive::MatrixGenerator::kAnchorInput)); + EXPECT_TRUE(node.has_input_with_id(olive::MatrixGenerator::k_position_input)); + EXPECT_TRUE(node.has_input_with_id(olive::MatrixGenerator::k_rotation_input)); + EXPECT_TRUE(node.has_input_with_id(olive::MatrixGenerator::k_scale_input)); + EXPECT_TRUE(node.has_input_with_id(olive::MatrixGenerator::k_uniform_scale_input)); + EXPECT_TRUE(node.has_input_with_id(olive::MatrixGenerator::k_anchor_input)); } TEST(TransformDistortNode, RetranslateSetsNamesAndComboStrings) { olive::TransformDistortNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::TransformDistortNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::TransformDistortNode::k_texture_input), QStringLiteral("Texture")); - EXPECT_EQ(node.GetInputName(olive::TransformDistortNode::kParentInput), + EXPECT_EQ(node.get_input_name(olive::TransformDistortNode::k_parent_input), QStringLiteral("Parent")); - EXPECT_EQ(node.GetInputName(olive::TransformDistortNode::kAutoscaleInput), + EXPECT_EQ(node.get_input_name(olive::TransformDistortNode::k_autoscale_input), QStringLiteral("Auto-Scale")); - EXPECT_EQ(node.GetInputName(olive::TransformDistortNode::kInterpolationInput), + EXPECT_EQ(node.get_input_name(olive::TransformDistortNode::k_interpolation_input), QStringLiteral("Interpolation")); // Inherited names from MatrixGenerator - EXPECT_EQ(node.GetInputName(olive::MatrixGenerator::kPositionInput), + EXPECT_EQ(node.get_input_name(olive::MatrixGenerator::k_position_input), QStringLiteral("Position")); - EXPECT_EQ(node.GetInputName(olive::MatrixGenerator::kAnchorInput), + EXPECT_EQ(node.get_input_name(olive::MatrixGenerator::k_anchor_input), QStringLiteral("Anchor Point")); - const QStringList autoscale = node.GetComboBoxStrings( - olive::TransformDistortNode::kAutoscaleInput); + const QStringList autoscale = node.get_combo_box_strings( + olive::TransformDistortNode::k_autoscale_input); ASSERT_EQ(autoscale.size(), 4); - EXPECT_EQ(autoscale.at(int(olive::TransformDistortNode::kAutoScaleNone)), + EXPECT_EQ(autoscale.at(int(olive::TransformDistortNode::k_auto_scale_none)), QStringLiteral("None")); - EXPECT_EQ(autoscale.at(int(olive::TransformDistortNode::kAutoScaleFit)), + EXPECT_EQ(autoscale.at(int(olive::TransformDistortNode::k_auto_scale_fit)), QStringLiteral("Fit")); - EXPECT_EQ(autoscale.at(int(olive::TransformDistortNode::kAutoScaleFill)), + EXPECT_EQ(autoscale.at(int(olive::TransformDistortNode::k_auto_scale_fill)), QStringLiteral("Fill")); - EXPECT_EQ(autoscale.at(int(olive::TransformDistortNode::kAutoScaleStretch)), + EXPECT_EQ(autoscale.at(int(olive::TransformDistortNode::k_auto_scale_stretch)), QStringLiteral("Stretch")); - const QStringList interpolation = node.GetComboBoxStrings( - olive::TransformDistortNode::kInterpolationInput); + const QStringList interpolation = node.get_combo_box_strings( + olive::TransformDistortNode::k_interpolation_input); ASSERT_EQ(interpolation.size(), 3); - EXPECT_EQ(interpolation.at(int(olive::Texture::kNearest)), + EXPECT_EQ(interpolation.at(int(olive::Texture::k_nearest)), QStringLiteral("Nearest Neighbor")); - EXPECT_EQ(interpolation.at(int(olive::Texture::kLinear)), + EXPECT_EQ(interpolation.at(int(olive::Texture::k_linear)), QStringLiteral("Bilinear")); - EXPECT_EQ(interpolation.at(int(olive::Texture::kMipmappedLinear)), + EXPECT_EQ(interpolation.at(int(olive::Texture::k_mipmapped_linear)), QStringLiteral("Mipmapped Bilinear")); } @@ -257,7 +257,7 @@ TEST(TransformDistortNode, GetShaderCodeReturnsEmptyCode) // The transform is applied through the ove_mvpmat uniform of the default // shader, so the node provides no shader code of its own - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_TRUE(code.frag_code().isEmpty()); EXPECT_TRUE(code.vert_code().isEmpty()); @@ -268,9 +268,9 @@ TEST(TransformDistortNode, AdjustMatrixByResolutionsIdentityWhenMatching) // With identical sequence and texture resolutions, no offset and an // identity input matrix, the adjusted matrix must remain identity (the // scale to clip space and back cancels out) - const QMatrix4x4 adjusted = olive::TransformDistortNode::AdjustMatrixByResolutions( + const QMatrix4x4 adjusted = olive::TransformDistortNode::adjust_matrix_by_resolutions( QMatrix4x4(), QVector2D(1024.0f, 1024.0f), QVector2D(1024.0f, 1024.0f), - QVector2D(0.0f, 0.0f), olive::TransformDistortNode::kAutoScaleNone); + QVector2D(0.0f, 0.0f), olive::TransformDistortNode::k_auto_scale_none); EXPECT_TRUE(adjusted.isIdentity()); } @@ -279,9 +279,9 @@ TEST(TransformDistortNode, AdjustMatrixByResolutionsAppliesOffset) // The offset lives in texture pixel space: with matching 1024x1024 // resolutions, offsetting by (128, 256) maps the origin to clip space // (128*2/1024, 256*2/1024) = (0.25, 0.5) - const QMatrix4x4 adjusted = olive::TransformDistortNode::AdjustMatrixByResolutions( + const QMatrix4x4 adjusted = olive::TransformDistortNode::adjust_matrix_by_resolutions( QMatrix4x4(), QVector2D(1024.0f, 1024.0f), QVector2D(1024.0f, 1024.0f), - QVector2D(128.0f, 256.0f), olive::TransformDistortNode::kAutoScaleNone); + QVector2D(128.0f, 256.0f), olive::TransformDistortNode::k_auto_scale_none); const QVector3D mapped = adjusted.map(QVector3D(0.0f, 0.0f, 0.0f)); EXPECT_FLOAT_EQ(mapped.x(), 0.25f); @@ -293,9 +293,9 @@ TEST(TransformDistortNode, AdjustMatrixByResolutionsScalesToClipSpace) { // Without auto-scale a 512x256 texture in a 1024x512 sequence covers only // half the frame in each axis - const QMatrix4x4 adjusted = olive::TransformDistortNode::AdjustMatrixByResolutions( + const QMatrix4x4 adjusted = olive::TransformDistortNode::adjust_matrix_by_resolutions( QMatrix4x4(), QVector2D(1024.0f, 512.0f), QVector2D(512.0f, 256.0f), - QVector2D(0.0f, 0.0f), olive::TransformDistortNode::kAutoScaleNone); + QVector2D(0.0f, 0.0f), olive::TransformDistortNode::k_auto_scale_none); const QVector3D corner = adjusted.map(QVector3D(1.0f, 1.0f, 0.0f)); EXPECT_FLOAT_EQ(corner.x(), 0.5f); @@ -305,9 +305,9 @@ TEST(TransformDistortNode, AdjustMatrixByResolutionsScalesToClipSpace) TEST(TransformDistortNode, AdjustMatrixByResolutionsStretchFillsSequence) { // Stretch distorts the texture to the sequence aspect ratio exactly - const QMatrix4x4 adjusted = olive::TransformDistortNode::AdjustMatrixByResolutions( + const QMatrix4x4 adjusted = olive::TransformDistortNode::adjust_matrix_by_resolutions( QMatrix4x4(), QVector2D(1024.0f, 512.0f), QVector2D(512.0f, 256.0f), - QVector2D(0.0f, 0.0f), olive::TransformDistortNode::kAutoScaleStretch); + QVector2D(0.0f, 0.0f), olive::TransformDistortNode::k_auto_scale_stretch); const QVector3D corner = adjusted.map(QVector3D(1.0f, 1.0f, 0.0f)); EXPECT_FLOAT_EQ(corner.x(), 1.0f); @@ -318,9 +318,9 @@ TEST(TransformDistortNode, AdjustMatrixByResolutionsFitWideFootage) { // Footage wider than the sequence (AR 4.0 in AR 2.0) is scaled by width, // leaving letterbox bars: the vertical clip extent shrinks to 0.5 - const QMatrix4x4 fit = olive::TransformDistortNode::AdjustMatrixByResolutions( + const QMatrix4x4 fit = olive::TransformDistortNode::adjust_matrix_by_resolutions( QMatrix4x4(), QVector2D(1024.0f, 512.0f), QVector2D(1024.0f, 256.0f), - QVector2D(0.0f, 0.0f), olive::TransformDistortNode::kAutoScaleFit); + QVector2D(0.0f, 0.0f), olive::TransformDistortNode::k_auto_scale_fit); const QVector3D corner = fit.map(QVector3D(1.0f, 1.0f, 0.0f)); EXPECT_FLOAT_EQ(corner.x(), 1.0f); @@ -330,9 +330,9 @@ TEST(TransformDistortNode, AdjustMatrixByResolutionsFitWideFootage) TEST(TransformDistortNode, AdjustMatrixByResolutionsFillWideFootage) { // Fill scales the same footage by height instead, cropping the sides - const QMatrix4x4 fill = olive::TransformDistortNode::AdjustMatrixByResolutions( + const QMatrix4x4 fill = olive::TransformDistortNode::adjust_matrix_by_resolutions( QMatrix4x4(), QVector2D(1024.0f, 512.0f), QVector2D(1024.0f, 256.0f), - QVector2D(0.0f, 0.0f), olive::TransformDistortNode::kAutoScaleFill); + QVector2D(0.0f, 0.0f), olive::TransformDistortNode::k_auto_scale_fill); const QVector3D corner = fill.map(QVector3D(1.0f, 1.0f, 0.0f)); EXPECT_FLOAT_EQ(corner.x(), 2.0f); @@ -343,9 +343,9 @@ TEST(TransformDistortNode, AdjustMatrixByResolutionsFitTallFootage) { // Footage narrower than the sequence (AR 0.5 in AR 2.0) is scaled by // height, leaving pillarbox bars - const QMatrix4x4 fit = olive::TransformDistortNode::AdjustMatrixByResolutions( + const QMatrix4x4 fit = olive::TransformDistortNode::adjust_matrix_by_resolutions( QMatrix4x4(), QVector2D(1024.0f, 512.0f), QVector2D(256.0f, 512.0f), - QVector2D(0.0f, 0.0f), olive::TransformDistortNode::kAutoScaleFit); + QVector2D(0.0f, 0.0f), olive::TransformDistortNode::k_auto_scale_fit); const QVector3D corner = fit.map(QVector3D(1.0f, 1.0f, 0.0f)); EXPECT_FLOAT_EQ(corner.x(), 0.25f); @@ -354,71 +354,71 @@ TEST(TransformDistortNode, AdjustMatrixByResolutionsFitTallFootage) TEST(TransformDistortNode, ValueWithoutTexturePushesMatrixOnly) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - olive::NodeValueTable table = GenerateTable(node, SequenceParams(1920, 1080)); + olive::NodeValueTable table = generate_table(node, sequence_params(1920, 1080)); // The generated matrix is always pushed; with no texture connected the // re-pushed texture value is a null texture - const olive::NodeValue matrix = table.Get(olive::NodeValue::kMatrix); - ASSERT_EQ(int(matrix.type()), int(olive::NodeValue::kMatrix)); - EXPECT_TRUE(matrix.toMatrix().isIdentity()); + const olive::NodeValue matrix = table.get(olive::NodeValue::k_matrix); + ASSERT_EQ(int(matrix.type()), int(olive::NodeValue::k_matrix)); + EXPECT_TRUE(matrix.to_matrix().isIdentity()); - EXPECT_TRUE(table.Get(olive::NodeValue::kTexture).toTexture() == nullptr); + EXPECT_TRUE(table.get(olive::NodeValue::k_texture).to_texture() == nullptr); } TEST(TransformDistortNode, ValueWithIdentityTransformPassesTextureThrough) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - auto *constant = AddNode(&project); + auto *node = add_node(&project); + auto *constant = add_node(&project); // Texture matching the sequence resolution with default transform values // produces an identity adjusted matrix, which the node treats as a no-op - const olive::TexturePtr base = MakeDummyTexture(1024, 1024); - constant->SetTexture(base); - olive::Node::ConnectEdge( + const olive::TexturePtr base = make_dummy_texture(1024, 1024); + constant->set_texture(base); + olive::Node::connect_edge( constant, - olive::NodeInput(node, olive::TransformDistortNode::kTextureInput)); + olive::NodeInput(node, olive::TransformDistortNode::k_texture_input)); - olive::NodeValueTable table = GenerateTable(node, SequenceParams(1024, 1024)); + olive::NodeValueTable table = generate_table(node, sequence_params(1024, 1024)); - const olive::TexturePtr out = GetOutputTexture(table); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); EXPECT_EQ(out, base); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); - EXPECT_TRUE(table.Get(olive::NodeValue::kMatrix).toMatrix().isIdentity()); + EXPECT_TRUE(table.get(olive::NodeValue::k_matrix).to_matrix().isIdentity()); } TEST(TransformDistortNode, ValueWithTexturePushesMatrixJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - auto *constant = AddNode(&project); + auto *node = add_node(&project); + auto *constant = add_node(&project); // A 64x48 texture in a 1920x1080 sequence yields a non-identity matrix - const olive::TexturePtr base = MakeDummyTexture(64, 48); - constant->SetTexture(base); - olive::Node::ConnectEdge( + const olive::TexturePtr base = make_dummy_texture(64, 48); + constant->set_texture(base); + olive::Node::connect_edge( constant, - olive::NodeInput(node, olive::TransformDistortNode::kTextureInput)); + olive::NodeInput(node, olive::TransformDistortNode::k_texture_input)); - olive::NodeValueTable table = GenerateTable(node, SequenceParams(1920, 1080)); + olive::NodeValueTable table = generate_table(node, sequence_params(1920, 1080)); - olive::TexturePtr out = GetOutputTexture(table); + olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); // The job adopts the sequence resolution, not the texture's, since the // transform may change the apparent size @@ -429,68 +429,68 @@ TEST(TransformDistortNode, ValueWithTexturePushesMatrixJob) ASSERT_TRUE(job); // The original texture is fed in as ove_maintex - EXPECT_EQ(job->Get(QStringLiteral("ove_maintex")).toTexture(), base); + EXPECT_EQ(job->get(QStringLiteral("ove_maintex")).to_texture(), base); // The mvp matrix scales the texture into sequence clip space: // 64/1920 on X and 48/1080 on Y - const QMatrix4x4 mvp = job->Get(QStringLiteral("ove_mvpmat")).toMatrix(); + const QMatrix4x4 mvp = job->get(QStringLiteral("ove_mvpmat")).to_matrix(); EXPECT_NEAR(mvp(0, 0), 64.0 / 1920.0, 1e-6); EXPECT_NEAR(mvp(1, 1), 48.0 / 1080.0, 1e-6); EXPECT_FLOAT_EQ(mvp(2, 2), 1.0f); EXPECT_FLOAT_EQ(mvp(3, 3), 1.0f); // The raw generated matrix (identity here) is pushed alongside the job - EXPECT_TRUE(table.Get(olive::NodeValue::kMatrix).toMatrix().isIdentity()); + EXPECT_TRUE(table.get(olive::NodeValue::k_matrix).to_matrix().isIdentity()); // Interpolation defaults to mipmapped bilinear and follows the input - EXPECT_EQ(int(job->GetInterpolation(QStringLiteral("ove_maintex"))), - int(olive::Texture::kMipmappedLinear)); + EXPECT_EQ(int(job->get_interpolation(QStringLiteral("ove_maintex"))), + int(olive::Texture::k_mipmapped_linear)); - node->SetStandardValue(olive::TransformDistortNode::kInterpolationInput, - int(olive::Texture::kNearest)); - table = GenerateTable(node, SequenceParams(1920, 1080)); - out = GetOutputTexture(table); + node->set_standard_value(olive::TransformDistortNode::k_interpolation_input, + int(olive::Texture::k_nearest)); + table = generate_table(node, sequence_params(1920, 1080)); + out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_EQ(int(job->GetInterpolation(QStringLiteral("ove_maintex"))), - int(olive::Texture::kNearest)); + EXPECT_EQ(int(job->get_interpolation(QStringLiteral("ove_maintex"))), + int(olive::Texture::k_nearest)); } TEST(TransformDistortNode, ValueBakesPositionIntoJobMatrix) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::MatrixGenerator::kPositionInput, + auto *node = add_node(&project); + node->set_standard_value(olive::MatrixGenerator::k_position_input, QVector2D(100.0f, 50.0f)); - auto *constant = AddNode(&project); - constant->SetTexture(MakeDummyTexture(64, 48)); - olive::Node::ConnectEdge( + auto *constant = add_node(&project); + constant->set_texture(make_dummy_texture(64, 48)); + olive::Node::connect_edge( constant, - olive::NodeInput(node, olive::TransformDistortNode::kTextureInput)); + olive::NodeInput(node, olive::TransformDistortNode::k_texture_input)); - olive::NodeValueTable table = GenerateTable(node, SequenceParams(1920, 1080)); + olive::NodeValueTable table = generate_table(node, sequence_params(1920, 1080)); // The table matrix is the pure transform: a 100x50 pixel translation - const QMatrix4x4 generated = table.Get(olive::NodeValue::kMatrix).toMatrix(); + const QMatrix4x4 generated = table.get(olive::NodeValue::k_matrix).to_matrix(); const QVector3D raw = generated.map(QVector3D(0.0f, 0.0f, 0.0f)); EXPECT_FLOAT_EQ(raw.x(), 100.0f); EXPECT_FLOAT_EQ(raw.y(), 50.0f); // The job matrix expresses the same translation in clip space - const olive::TexturePtr out = GetOutputTexture(table); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - const QVector3D clip = job->Get(QStringLiteral("ove_mvpmat")) - .toMatrix() + const QVector3D clip = job->get(QStringLiteral("ove_mvpmat")) + .to_matrix() .map(QVector3D(0.0f, 0.0f, 0.0f)); EXPECT_NEAR(clip.x(), 100.0 * 2.0 / 1920.0, 1e-6); EXPECT_NEAR(clip.y(), 50.0 * 2.0 / 1080.0, 1e-6); @@ -504,42 +504,42 @@ TEST(CropDistortNode, MetadataIsCorrect) { olive::CropDistortNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.crop")); - EXPECT_EQ(node.Name(), QStringLiteral("Crop")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_EQ(node.name(), QStringLiteral("Crop")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::CropDistortNode::kTextureInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::CropDistortNode::k_texture_input); } TEST(CropDistortNode, InputDefinitionsAndDefaults) { olive::CropDistortNode node; - EXPECT_EQ(int(node.GetInputDataType(olive::CropDistortNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable(olive::CropDistortNode::kTextureInput)); + EXPECT_EQ(int(node.get_input_data_type(olive::CropDistortNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable(olive::CropDistortNode::k_texture_input)); // All four sides are 0..1 percentage sliders defaulting to zero - const QString sides[] = { olive::CropDistortNode::kLeftInput, - olive::CropDistortNode::kTopInput, - olive::CropDistortNode::kRightInput, - olive::CropDistortNode::kBottomInput }; + const QString sides[] = { olive::CropDistortNode::k_left_input, + olive::CropDistortNode::k_top_input, + olive::CropDistortNode::k_right_input, + olive::CropDistortNode::k_bottom_input }; for (const QString &side : sides) { - EXPECT_EQ(int(node.GetInputDataType(side)), int(olive::NodeValue::kFloat)); - EXPECT_DOUBLE_EQ(node.GetStandardValue(side).toDouble(), 0.0); + EXPECT_EQ(int(node.get_input_data_type(side)), int(olive::NodeValue::k_float)); + EXPECT_DOUBLE_EQ(node.get_standard_value(side).toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(side, QStringLiteral("min")).toDouble(), 0.0); + node.get_input_property(side, QStringLiteral("min")).toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(side, QStringLiteral("max")).toDouble(), 1.0); - EXPECT_EQ(node.GetInputProperty(side, QStringLiteral("view")).toInt(), - int(olive::FloatSlider::kPercentage)); + node.get_input_property(side, QStringLiteral("max")).toDouble(), 1.0); + EXPECT_EQ(node.get_input_property(side, QStringLiteral("view")).toInt(), + int(olive::FloatSlider::k_percentage)); } EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::CropDistortNode::kFeatherInput).toDouble(), + node.get_standard_value(olive::CropDistortNode::k_feather_input).toDouble(), 0.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::CropDistortNode::kFeatherInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::CropDistortNode::k_feather_input, QStringLiteral("min")) .toDouble(), 0.0); @@ -548,19 +548,19 @@ TEST(CropDistortNode, InputDefinitionsAndDefaults) TEST(CropDistortNode, RetranslateSetsInputNames) { olive::CropDistortNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::CropDistortNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::CropDistortNode::k_texture_input), QStringLiteral("Texture")); - EXPECT_EQ(node.GetInputName(olive::CropDistortNode::kLeftInput), + EXPECT_EQ(node.get_input_name(olive::CropDistortNode::k_left_input), QStringLiteral("Left")); - EXPECT_EQ(node.GetInputName(olive::CropDistortNode::kTopInput), + EXPECT_EQ(node.get_input_name(olive::CropDistortNode::k_top_input), QStringLiteral("Top")); - EXPECT_EQ(node.GetInputName(olive::CropDistortNode::kRightInput), + EXPECT_EQ(node.get_input_name(olive::CropDistortNode::k_right_input), QStringLiteral("Right")); - EXPECT_EQ(node.GetInputName(olive::CropDistortNode::kBottomInput), + EXPECT_EQ(node.get_input_name(olive::CropDistortNode::k_bottom_input), QStringLiteral("Bottom")); - EXPECT_EQ(node.GetInputName(olive::CropDistortNode::kFeatherInput), + EXPECT_EQ(node.get_input_name(olive::CropDistortNode::k_feather_input), QStringLiteral("Feather")); } @@ -568,7 +568,7 @@ TEST(CropDistortNode, GetShaderCodeLoadsCropShader) { olive::CropDistortNode node; - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("left_in"))); @@ -581,25 +581,25 @@ TEST(CropDistortNode, ValueWithoutTexturePushesNothing) olive::CropDistortNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(CropDistortNode, ValueWithZeroCropPassesTextureThrough) { olive::CropDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(120, 80); + const olive::TexturePtr tex = make_dummy_texture(120, 80); olive::NodeValueTable table; - node.Value(MakeTextureRow(olive::CropDistortNode::kTextureInput, tex), + node.value(make_texture_row(olive::CropDistortNode::k_texture_input, tex), olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(CropDistortNode, ValueWithOnlyFeatherPassesTextureThrough) @@ -608,37 +608,37 @@ TEST(CropDistortNode, ValueWithOnlyFeatherPassesTextureThrough) // NOTE: the node only checks the four crop sides when deciding to run the // shader; a feather without any crop is silently ignored - const olive::TexturePtr tex = MakeDummyTexture(120, 80); + const olive::TexturePtr tex = make_dummy_texture(120, 80); olive::NodeValueRow row = - MakeTextureRow(olive::CropDistortNode::kTextureInput, tex); - row.insert(olive::CropDistortNode::kFeatherInput, FloatValue(5.0)); + make_texture_row(olive::CropDistortNode::k_texture_input, tex); + row.insert(olive::CropDistortNode::k_feather_input, float_value(5.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(CropDistortNode, ValueWithCropPushesShaderJob) { olive::CropDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(120, 80); + const olive::TexturePtr tex = make_dummy_texture(120, 80); olive::NodeValueRow row = - MakeTextureRow(olive::CropDistortNode::kTextureInput, tex); - row.insert(olive::CropDistortNode::kLeftInput, FloatValue(0.25)); + make_texture_row(olive::CropDistortNode::k_texture_input, tex); + row.insert(olive::CropDistortNode::k_left_input, float_value(0.25)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); // The job reuses the input texture's params EXPECT_EQ(out->params().width(), tex->params().width()); @@ -646,9 +646,9 @@ TEST(CropDistortNode, ValueWithCropPushesShaderJob) auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_DOUBLE_EQ(job->Get(olive::CropDistortNode::kLeftInput).toDouble(), + EXPECT_DOUBLE_EQ(job->get(olive::CropDistortNode::k_left_input).to_double(), 0.25); - EXPECT_EQ(job->Get(QStringLiteral("resolution_in")).toVec2(), + EXPECT_EQ(job->get(QStringLiteral("resolution_in")).to_vec2(), QVector2D(120.0f, 80.0f)); } @@ -662,43 +662,43 @@ TEST(FlipDistortNode, MetadataIsCorrect) // NOTE: unlike most Olive nodes ("org.olivevideoeditor.Olive.*"), the // domain (inconsistent ID, documented here as a suspected bug) EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.flip")); - EXPECT_EQ(node.Name(), QStringLiteral("Flip")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_EQ(node.name(), QStringLiteral("Flip")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::FlipDistortNode::kTextureInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::FlipDistortNode::k_texture_input); } TEST(FlipDistortNode, InputDefaults) { olive::FlipDistortNode node; - EXPECT_EQ(int(node.GetInputDataType(olive::FlipDistortNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable(olive::FlipDistortNode::kTextureInput)); + EXPECT_EQ(int(node.get_input_data_type(olive::FlipDistortNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable(olive::FlipDistortNode::k_texture_input)); EXPECT_EQ( - int(node.GetInputDataType(olive::FlipDistortNode::kHorizontalInput)), - int(olive::NodeValue::kBoolean)); - EXPECT_FALSE(node.GetStandardValue(olive::FlipDistortNode::kHorizontalInput) + int(node.get_input_data_type(olive::FlipDistortNode::k_horizontal_input)), + int(olive::NodeValue::k_boolean)); + EXPECT_FALSE(node.get_standard_value(olive::FlipDistortNode::k_horizontal_input) .toBool()); - EXPECT_EQ(int(node.GetInputDataType(olive::FlipDistortNode::kVerticalInput)), - int(olive::NodeValue::kBoolean)); - EXPECT_FALSE(node.GetStandardValue(olive::FlipDistortNode::kVerticalInput) + EXPECT_EQ(int(node.get_input_data_type(olive::FlipDistortNode::k_vertical_input)), + int(olive::NodeValue::k_boolean)); + EXPECT_FALSE(node.get_standard_value(olive::FlipDistortNode::k_vertical_input) .toBool()); } TEST(FlipDistortNode, RetranslateSetsInputNames) { olive::FlipDistortNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::FlipDistortNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::FlipDistortNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::FlipDistortNode::kHorizontalInput), + EXPECT_EQ(node.get_input_name(olive::FlipDistortNode::k_horizontal_input), QStringLiteral("Horizontal")); - EXPECT_EQ(node.GetInputName(olive::FlipDistortNode::kVerticalInput), + EXPECT_EQ(node.get_input_name(olive::FlipDistortNode::k_vertical_input), QStringLiteral("Vertical")); } @@ -706,7 +706,7 @@ TEST(FlipDistortNode, GetShaderCodeLoadsFlipShader) { olive::FlipDistortNode node; - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("horiz_in"))); @@ -718,65 +718,65 @@ TEST(FlipDistortNode, ValueWithoutTexturePushesNothing) olive::FlipDistortNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(FlipDistortNode, ValueWithNoFlipPassesTextureThrough) { olive::FlipDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueTable table; - node.Value(MakeTextureRow(olive::FlipDistortNode::kTextureInput, tex), + node.value(make_texture_row(olive::FlipDistortNode::k_texture_input, tex), olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(FlipDistortNode, ValueWithFlipPushesShaderJob) { olive::FlipDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueRow row = - MakeTextureRow(olive::FlipDistortNode::kTextureInput, tex); - row.insert(olive::FlipDistortNode::kHorizontalInput, BoolValue(true)); + make_texture_row(olive::FlipDistortNode::k_texture_input, tex); + row.insert(olive::FlipDistortNode::k_horizontal_input, bool_value(true)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); EXPECT_EQ(out->params().width(), tex->params().width()); auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_TRUE(job->Get(olive::FlipDistortNode::kHorizontalInput).toBool()); - EXPECT_FALSE(job->Get(olive::FlipDistortNode::kVerticalInput).toBool()); + EXPECT_TRUE(job->get(olive::FlipDistortNode::k_horizontal_input).to_bool()); + EXPECT_FALSE(job->get(olive::FlipDistortNode::k_vertical_input).to_bool()); // Vertical flip on its own also triggers the shader - row.insert(olive::FlipDistortNode::kHorizontalInput, BoolValue(false)); - row.insert(olive::FlipDistortNode::kVerticalInput, BoolValue(true)); + row.insert(olive::FlipDistortNode::k_horizontal_input, bool_value(false)); + row.insert(olive::FlipDistortNode::k_vertical_input, bool_value(true)); olive::NodeValueTable vertical_table; - node.Value(row, olive::NodeGlobals(), &vertical_table); + node.value(row, olive::NodeGlobals(), &vertical_table); - ASSERT_EQ(vertical_table.Count(), 1); - out = GetOutputTexture(vertical_table); + ASSERT_EQ(vertical_table.count(), 1); + out = get_output_texture(vertical_table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_FALSE(job->Get(olive::FlipDistortNode::kHorizontalInput).toBool()); - EXPECT_TRUE(job->Get(olive::FlipDistortNode::kVerticalInput).toBool()); + EXPECT_FALSE(job->get(olive::FlipDistortNode::k_horizontal_input).to_bool()); + EXPECT_TRUE(job->get(olive::FlipDistortNode::k_vertical_input).to_bool()); } // ----------------------------------------------------------------------------- @@ -787,12 +787,12 @@ TEST(CornerPinDistortNode, MetadataIsCorrect) { olive::CornerPinDistortNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.cornerpin")); - EXPECT_EQ(node.Name(), QStringLiteral("Corner Pin")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_EQ(node.name(), QStringLiteral("Corner Pin")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::CornerPinDistortNode::kTextureInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::CornerPinDistortNode::k_texture_input); } TEST(CornerPinDistortNode, InputDefaults) @@ -800,28 +800,28 @@ TEST(CornerPinDistortNode, InputDefaults) olive::CornerPinDistortNode node; EXPECT_EQ( - int(node.GetInputDataType(olive::CornerPinDistortNode::kTextureInput)), - int(olive::NodeValue::kTexture)); + int(node.get_input_data_type(olive::CornerPinDistortNode::k_texture_input)), + int(olive::NodeValue::k_texture)); EXPECT_FALSE( - node.IsInputKeyframable(olive::CornerPinDistortNode::kTextureInput)); + node.is_input_keyframable(olive::CornerPinDistortNode::k_texture_input)); - EXPECT_EQ(int(node.GetInputDataType( - olive::CornerPinDistortNode::kPerspectiveInput)), - int(olive::NodeValue::kBoolean)); - EXPECT_TRUE(node.GetStandardValue( - olive::CornerPinDistortNode::kPerspectiveInput) + EXPECT_EQ(int(node.get_input_data_type( + olive::CornerPinDistortNode::k_perspective_input)), + int(olive::NodeValue::k_boolean)); + EXPECT_TRUE(node.get_standard_value( + olive::CornerPinDistortNode::k_perspective_input) .toBool()); // All four corners are pixel offsets relative to their respective image // corner and default to no offset - const QString corners[] = { olive::CornerPinDistortNode::kTopLeftInput, - olive::CornerPinDistortNode::kTopRightInput, - olive::CornerPinDistortNode::kBottomRightInput, - olive::CornerPinDistortNode::kBottomLeftInput }; + const QString corners[] = { olive::CornerPinDistortNode::k_top_left_input, + olive::CornerPinDistortNode::k_top_right_input, + olive::CornerPinDistortNode::k_bottom_right_input, + olive::CornerPinDistortNode::k_bottom_left_input }; for (const QString &corner : corners) { - EXPECT_EQ(int(node.GetInputDataType(corner)), - int(olive::NodeValue::kVec2)); - EXPECT_EQ(node.GetStandardValue(corner).value(), + EXPECT_EQ(int(node.get_input_data_type(corner)), + int(olive::NodeValue::k_vec2)); + EXPECT_EQ(node.get_standard_value(corner).value(), QVector2D(0.0f, 0.0f)); } } @@ -829,19 +829,19 @@ TEST(CornerPinDistortNode, InputDefaults) TEST(CornerPinDistortNode, RetranslateSetsInputNames) { olive::CornerPinDistortNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::CornerPinDistortNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::CornerPinDistortNode::k_texture_input), QStringLiteral("Texture")); - EXPECT_EQ(node.GetInputName(olive::CornerPinDistortNode::kPerspectiveInput), + EXPECT_EQ(node.get_input_name(olive::CornerPinDistortNode::k_perspective_input), QStringLiteral("Perspective")); - EXPECT_EQ(node.GetInputName(olive::CornerPinDistortNode::kTopLeftInput), + EXPECT_EQ(node.get_input_name(olive::CornerPinDistortNode::k_top_left_input), QStringLiteral("Top Left")); - EXPECT_EQ(node.GetInputName(olive::CornerPinDistortNode::kTopRightInput), + EXPECT_EQ(node.get_input_name(olive::CornerPinDistortNode::k_top_right_input), QStringLiteral("Top Right")); - EXPECT_EQ(node.GetInputName(olive::CornerPinDistortNode::kBottomRightInput), + EXPECT_EQ(node.get_input_name(olive::CornerPinDistortNode::k_bottom_right_input), QStringLiteral("Bottom Right")); - EXPECT_EQ(node.GetInputName(olive::CornerPinDistortNode::kBottomLeftInput), + EXPECT_EQ(node.get_input_name(olive::CornerPinDistortNode::k_bottom_left_input), QStringLiteral("Bottom Left")); } @@ -849,7 +849,7 @@ TEST(CornerPinDistortNode, GetShaderCodeLoadsFragAndVertShaders) { olive::CornerPinDistortNode node; - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("perspective_in"))); @@ -863,34 +863,34 @@ TEST(CornerPinDistortNode, ValueToPixelConvertsOffsetsToPixels) olive::CornerPinDistortNode node; olive::NodeValueRow row; - row.insert(olive::CornerPinDistortNode::kTopLeftInput, - Vec2Value(QVector2D(10.0f, 20.0f))); - row.insert(olive::CornerPinDistortNode::kTopRightInput, - Vec2Value(QVector2D(-30.0f, 40.0f))); - row.insert(olive::CornerPinDistortNode::kBottomRightInput, - Vec2Value(QVector2D(-50.0f, -60.0f))); - row.insert(olive::CornerPinDistortNode::kBottomLeftInput, - Vec2Value(QVector2D(70.0f, -80.0f))); + row.insert(olive::CornerPinDistortNode::k_top_left_input, + vec2_value(QVector2D(10.0f, 20.0f))); + row.insert(olive::CornerPinDistortNode::k_top_right_input, + vec2_value(QVector2D(-30.0f, 40.0f))); + row.insert(olive::CornerPinDistortNode::k_bottom_right_input, + vec2_value(QVector2D(-50.0f, -60.0f))); + row.insert(olive::CornerPinDistortNode::k_bottom_left_input, + vec2_value(QVector2D(70.0f, -80.0f))); const QVector2D resolution(200.0f, 100.0f); // Top-left offsets are relative to (0, 0) - const QPointF top_left = node.ValueToPixel(0, row, resolution); + const QPointF top_left = node.value_to_pixel(0, row, resolution); EXPECT_DOUBLE_EQ(top_left.x(), 10.0); EXPECT_DOUBLE_EQ(top_left.y(), 20.0); // Top-right offsets are relative to (width, 0) - const QPointF top_right = node.ValueToPixel(1, row, resolution); + const QPointF top_right = node.value_to_pixel(1, row, resolution); EXPECT_DOUBLE_EQ(top_right.x(), 170.0); EXPECT_DOUBLE_EQ(top_right.y(), 40.0); // Bottom-right offsets are relative to (width, height) - const QPointF bottom_right = node.ValueToPixel(2, row, resolution); + const QPointF bottom_right = node.value_to_pixel(2, row, resolution); EXPECT_DOUBLE_EQ(bottom_right.x(), 150.0); EXPECT_DOUBLE_EQ(bottom_right.y(), 40.0); // Bottom-left offsets are relative to (0, height) - const QPointF bottom_left = node.ValueToPixel(3, row, resolution); + const QPointF bottom_left = node.value_to_pixel(3, row, resolution); EXPECT_DOUBLE_EQ(bottom_left.x(), 70.0); EXPECT_DOUBLE_EQ(bottom_left.y(), 20.0); } @@ -900,55 +900,55 @@ TEST(CornerPinDistortNode, ValueWithoutTexturePushesNothing) olive::CornerPinDistortNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(CornerPinDistortNode, ValueWithDefaultCornersPassesTextureThrough) { olive::CornerPinDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(100, 100); + const olive::TexturePtr tex = make_dummy_texture(100, 100); olive::NodeValueTable table; - node.Value(MakeTextureRow(olive::CornerPinDistortNode::kTextureInput, tex), + node.value(make_texture_row(olive::CornerPinDistortNode::k_texture_input, tex), olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(CornerPinDistortNode, ValueWithMovedCornerPushesVertexCoordinates) { olive::CornerPinDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(100, 100); + const olive::TexturePtr tex = make_dummy_texture(100, 100); olive::NodeValueRow row = - MakeTextureRow(olive::CornerPinDistortNode::kTextureInput, tex); - row.insert(olive::CornerPinDistortNode::kTopLeftInput, - Vec2Value(QVector2D(10.0f, 20.0f))); + make_texture_row(olive::CornerPinDistortNode::k_texture_input, tex); + row.insert(olive::CornerPinDistortNode::k_top_left_input, + vec2_value(QVector2D(10.0f, 20.0f))); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); EXPECT_EQ(out->params().width(), tex->params().width()); auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_EQ(job->Get(QStringLiteral("resolution_in")).toVec2(), + EXPECT_EQ(job->get(QStringLiteral("resolution_in")).to_vec2(), QVector2D(100.0f, 100.0f)); // Slider offsets are converted to pixel positions and then to clip space // (-1..1): top-left (10, 20) -> (-0.8, -0.6), the untouched corners land // on the default quad - const QVector &vertices = job->GetVertexCoordinates(); + const QVector &vertices = job->get_vertex_coordinates(); ASSERT_EQ(int(vertices.size()), 18); // First triangle @@ -979,13 +979,13 @@ TEST(MaskDistortNode, MetadataIsCorrect) { olive::MaskDistortNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.mask")); - EXPECT_EQ(node.Name(), QStringLiteral("Mask")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_EQ(node.name(), QStringLiteral("Mask")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); // From GeneratorWithMerge: the base texture is the effect input - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::GeneratorWithMerge::kBaseInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::GeneratorWithMerge::k_base_input); } TEST(MaskDistortNode, InputDefinitionsAndDefaults) @@ -993,46 +993,46 @@ TEST(MaskDistortNode, InputDefinitionsAndDefaults) olive::MaskDistortNode node; EXPECT_EQ( - int(node.GetInputDataType(olive::MaskDistortNode::kInvertInput)), - int(olive::NodeValue::kBoolean)); - EXPECT_FALSE(node.GetStandardValue(olive::MaskDistortNode::kInvertInput) + int(node.get_input_data_type(olive::MaskDistortNode::k_invert_input)), + int(olive::NodeValue::k_boolean)); + EXPECT_FALSE(node.get_standard_value(olive::MaskDistortNode::k_invert_input) .toBool()); EXPECT_EQ( - int(node.GetInputDataType(olive::MaskDistortNode::kFeatherInput)), - int(olive::NodeValue::kFloat)); + int(node.get_input_data_type(olive::MaskDistortNode::k_feather_input)), + int(olive::NodeValue::k_float)); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::MaskDistortNode::kFeatherInput).toDouble(), + node.get_standard_value(olive::MaskDistortNode::k_feather_input).toDouble(), 0.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::MaskDistortNode::kFeatherInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::MaskDistortNode::k_feather_input, QStringLiteral("min")) .toDouble(), 0.0); // From PolygonGenerator: the color is hidden because the mask must stay // white for the multiply to work, and the shape defaults to a pentagon - EXPECT_TRUE(node.IsInputHidden(olive::PolygonGenerator::kColorInput)); - EXPECT_TRUE(node.InputIsArray(olive::PolygonGenerator::kPointsInput)); - EXPECT_EQ(node.InputArraySize(olive::PolygonGenerator::kPointsInput), 5); + EXPECT_TRUE(node.is_input_hidden(olive::PolygonGenerator::k_color_input)); + EXPECT_TRUE(node.input_is_array(olive::PolygonGenerator::k_points_input)); + EXPECT_EQ(node.input_array_size(olive::PolygonGenerator::k_points_input), 5); } TEST(MaskDistortNode, RetranslateSetsInputNames) { olive::MaskDistortNode node; - node.Retranslate(); + node.retranslate(); // The base input is renamed from GeneratorWithMerge's "Base" - EXPECT_EQ(node.GetInputName(olive::GeneratorWithMerge::kBaseInput), + EXPECT_EQ(node.get_input_name(olive::GeneratorWithMerge::k_base_input), QStringLiteral("Texture")); - EXPECT_EQ(node.GetInputName(olive::MaskDistortNode::kInvertInput), + EXPECT_EQ(node.get_input_name(olive::MaskDistortNode::k_invert_input), QStringLiteral("Invert")); - EXPECT_EQ(node.GetInputName(olive::MaskDistortNode::kFeatherInput), + EXPECT_EQ(node.get_input_name(olive::MaskDistortNode::k_feather_input), QStringLiteral("Feather")); // Inherited names from PolygonGenerator - EXPECT_EQ(node.GetInputName(olive::PolygonGenerator::kPointsInput), + EXPECT_EQ(node.get_input_name(olive::PolygonGenerator::k_points_input), QStringLiteral("Points")); - EXPECT_EQ(node.GetInputName(olive::PolygonGenerator::kColorInput), + EXPECT_EQ(node.get_input_name(olive::PolygonGenerator::k_color_input), QStringLiteral("Color")); } @@ -1040,28 +1040,28 @@ TEST(MaskDistortNode, GetShaderCodeSelectsShaderByRequestId) { olive::MaskDistortNode node; - const olive::ShaderCode merge = node.GetShaderCode( + const olive::ShaderCode merge = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("mrg"))); EXPECT_FALSE(merge.frag_code().isEmpty()); EXPECT_TRUE(merge.frag_code().contains(QStringLiteral("tex_a"))); - const olive::ShaderCode feather = node.GetShaderCode( + const olive::ShaderCode feather = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("feather"))); EXPECT_FALSE(feather.frag_code().isEmpty()); EXPECT_TRUE(feather.frag_code().contains(QStringLiteral("radius_in"))); - const olive::ShaderCode invert = node.GetShaderCode( + const olive::ShaderCode invert = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("invert"))); EXPECT_FALSE(invert.frag_code().isEmpty()); EXPECT_TRUE(invert.frag_code().contains(QStringLiteral("tex_in"))); // Unknown ids fall through to PolygonGenerator, which serves "rgb" - const olive::ShaderCode rgb = node.GetShaderCode( + const olive::ShaderCode rgb = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("rgb"))); EXPECT_FALSE(rgb.frag_code().isEmpty()); EXPECT_TRUE(rgb.frag_code().contains(QStringLiteral("texture_in"))); - const olive::ShaderCode unknown = node.GetShaderCode( + const olive::ShaderCode unknown = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("bogus"))); EXPECT_TRUE(unknown.frag_code().isEmpty()); EXPECT_TRUE(unknown.vert_code().isEmpty()); @@ -1069,30 +1069,30 @@ TEST(MaskDistortNode, GetShaderCodeSelectsShaderByRequestId) TEST(MaskDistortNode, ValueWithoutTexturePushesGeneratePipeline) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - const olive::VideoParams vparams = SequenceParams(320, 240); - olive::NodeValueTable table = GenerateTable(node, vparams); + const olive::VideoParams vparams = sequence_params(320, 240); + olive::NodeValueTable table = generate_table(node, vparams); // Without a base the mask still generates its polygon, wrapped in the // "rgb" conversion job - const olive::TexturePtr out = GetOutputTexture(table); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); EXPECT_EQ(out->params().width(), vparams.width()); EXPECT_EQ(out->params().height(), vparams.height()); auto *rgb = dynamic_cast(out->job()); ASSERT_TRUE(rgb); - EXPECT_EQ(rgb->GetShaderID(), QStringLiteral("rgb")); + EXPECT_EQ(rgb->get_shader_id(), QStringLiteral("rgb")); // The polygon color is forced to white const olive::core::Color color = - rgb->Get(QStringLiteral("color_in")).toColor(); + rgb->get(QStringLiteral("color_in")).to_color(); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_FLOAT_EQ(color.green(), 1.0f); EXPECT_FLOAT_EQ(color.blue(), 1.0f); @@ -1100,121 +1100,121 @@ TEST(MaskDistortNode, ValueWithoutTexturePushesGeneratePipeline) // The nested generation job renders to an 8-bit buffer const olive::TexturePtr generate = - rgb->Get(QStringLiteral("texture_in")).toTexture(); + rgb->get(QStringLiteral("texture_in")).to_texture(); ASSERT_TRUE(generate); - ASSERT_TRUE(generate->IsJob()); - EXPECT_EQ(int(generate->params().format()), int(olive::core::PixelFormat::U8)); + ASSERT_TRUE(generate->is_job()); + EXPECT_EQ(int(generate->params().format()), int(olive::core::PixelFormat::u8)); EXPECT_TRUE(dynamic_cast(generate->job())); } TEST(MaskDistortNode, ValueWithInvertWrapsGenerationInInvertJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::MaskDistortNode::kInvertInput, true); + auto *node = add_node(&project); + node->set_standard_value(olive::MaskDistortNode::k_invert_input, true); - olive::NodeValueTable table = GenerateTable(node, SequenceParams(320, 240)); + olive::NodeValueTable table = generate_table(node, sequence_params(320, 240)); - const olive::TexturePtr out = GetOutputTexture(table); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *invert = dynamic_cast(out->job()); ASSERT_TRUE(invert); - EXPECT_EQ(invert->GetShaderID(), QStringLiteral("invert")); + EXPECT_EQ(invert->get_shader_id(), QStringLiteral("invert")); // The inverted texture is the usual rgb generation pipeline const olive::TexturePtr rgb_tex = - invert->Get(QStringLiteral("tex_in")).toTexture(); + invert->get(QStringLiteral("tex_in")).to_texture(); ASSERT_TRUE(rgb_tex); - ASSERT_TRUE(rgb_tex->IsJob()); + ASSERT_TRUE(rgb_tex->is_job()); auto *rgb = dynamic_cast(rgb_tex->job()); ASSERT_TRUE(rgb); - EXPECT_EQ(rgb->GetShaderID(), QStringLiteral("rgb")); + EXPECT_EQ(rgb->get_shader_id(), QStringLiteral("rgb")); } TEST(MaskDistortNode, ValueWithTexturePushesMergeJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - auto *constant = AddNode(&project); + auto *node = add_node(&project); + auto *constant = add_node(&project); - const olive::TexturePtr base = MakeDummyTexture(64, 48); - constant->SetTexture(base); - olive::Node::ConnectEdge( - constant, olive::NodeInput(node, olive::GeneratorWithMerge::kBaseInput)); + const olive::TexturePtr base = make_dummy_texture(64, 48); + constant->set_texture(base); + olive::Node::connect_edge( + constant, olive::NodeInput(node, olive::GeneratorWithMerge::k_base_input)); - olive::NodeValueTable table = GenerateTable(node, SequenceParams(320, 240)); + olive::NodeValueTable table = generate_table(node, sequence_params(320, 240)); // With a base the mask multiplies it by the generated polygon - const olive::TexturePtr out = GetOutputTexture(table); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); EXPECT_EQ(out->params().width(), base->params().width()); EXPECT_EQ(out->params().height(), base->params().height()); auto *merge = dynamic_cast(out->job()); ASSERT_TRUE(merge); - EXPECT_EQ(merge->GetShaderID(), QStringLiteral("mrg")); - EXPECT_EQ(merge->Get(QStringLiteral("tex_a")).toTexture(), base); + EXPECT_EQ(merge->get_shader_id(), QStringLiteral("mrg")); + EXPECT_EQ(merge->get(QStringLiteral("tex_a")).to_texture(), base); // Without a feather, tex_b is the rgb generation pipeline directly const olive::TexturePtr tex_b = - merge->Get(QStringLiteral("tex_b")).toTexture(); + merge->get(QStringLiteral("tex_b")).to_texture(); ASSERT_TRUE(tex_b); - ASSERT_TRUE(tex_b->IsJob()); + ASSERT_TRUE(tex_b->is_job()); auto *rgb = dynamic_cast(tex_b->job()); ASSERT_TRUE(rgb); - EXPECT_EQ(rgb->GetShaderID(), QStringLiteral("rgb")); + EXPECT_EQ(rgb->get_shader_id(), QStringLiteral("rgb")); } TEST(MaskDistortNode, ValueWithFeatherNestsBlurJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::MaskDistortNode::kFeatherInput, 10.0); + auto *node = add_node(&project); + node->set_standard_value(olive::MaskDistortNode::k_feather_input, 10.0); - auto *constant = AddNode(&project); - const olive::TexturePtr base = MakeDummyTexture(64, 48); - constant->SetTexture(base); - olive::Node::ConnectEdge( - constant, olive::NodeInput(node, olive::GeneratorWithMerge::kBaseInput)); + auto *constant = add_node(&project); + const olive::TexturePtr base = make_dummy_texture(64, 48); + constant->set_texture(base); + olive::Node::connect_edge( + constant, olive::NodeInput(node, olive::GeneratorWithMerge::k_base_input)); - olive::NodeValueTable table = GenerateTable(node, SequenceParams(320, 240)); + olive::NodeValueTable table = generate_table(node, sequence_params(320, 240)); - const olive::TexturePtr out = GetOutputTexture(table); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *merge = dynamic_cast(out->job()); ASSERT_TRUE(merge); - EXPECT_EQ(merge->GetShaderID(), QStringLiteral("mrg")); + EXPECT_EQ(merge->get_shader_id(), QStringLiteral("mrg")); // With a feather, tex_b becomes a two-iteration gaussian blur of the mask const olive::TexturePtr tex_b = - merge->Get(QStringLiteral("tex_b")).toTexture(); + merge->get(QStringLiteral("tex_b")).to_texture(); ASSERT_TRUE(tex_b); - ASSERT_TRUE(tex_b->IsJob()); + ASSERT_TRUE(tex_b->is_job()); auto *feather = dynamic_cast(tex_b->job()); ASSERT_TRUE(feather); - EXPECT_EQ(feather->GetShaderID(), QStringLiteral("feather")); - EXPECT_EQ(feather->GetIterationCount(), 2); - EXPECT_EQ(feather->GetIterativeInput(), olive::BlurFilterNode::kTextureInput); + EXPECT_EQ(feather->get_shader_id(), QStringLiteral("feather")); + EXPECT_EQ(feather->get_iteration_count(), 2); + EXPECT_EQ(feather->get_iterative_input(), olive::BlurFilterNode::k_texture_input); EXPECT_DOUBLE_EQ( - feather->Get(olive::BlurFilterNode::kRadiusInput).toDouble(), 10.0); - EXPECT_EQ(feather->Get(olive::BlurFilterNode::kMethodInput).toInt(), - int(olive::BlurFilterNode::kGaussian)); - EXPECT_EQ(feather->Get(QStringLiteral("resolution_in")).toVec2(), + feather->get(olive::BlurFilterNode::k_radius_input).to_double(), 10.0); + EXPECT_EQ(feather->get(olive::BlurFilterNode::k_method_input).to_int(), + int(olive::BlurFilterNode::k_gaussian)); + EXPECT_EQ(feather->get(QStringLiteral("resolution_in")).to_vec2(), base->virtual_resolution()); } @@ -1226,12 +1226,12 @@ TEST(RippleDistortNode, MetadataIsCorrect) { olive::RippleDistortNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.ripple")); - EXPECT_EQ(node.Name(), QStringLiteral("Ripple")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_EQ(node.name(), QStringLiteral("Ripple")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::RippleDistortNode::kTextureInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::RippleDistortNode::k_texture_input); } TEST(RippleDistortNode, InputDefaults) @@ -1239,46 +1239,46 @@ TEST(RippleDistortNode, InputDefaults) olive::RippleDistortNode node; EXPECT_EQ( - int(node.GetInputDataType(olive::RippleDistortNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable(olive::RippleDistortNode::kTextureInput)); + int(node.get_input_data_type(olive::RippleDistortNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable(olive::RippleDistortNode::k_texture_input)); - EXPECT_DOUBLE_EQ(node.GetStandardValue(olive::RippleDistortNode::kEvolutionInput) + EXPECT_DOUBLE_EQ(node.get_standard_value(olive::RippleDistortNode::k_evolution_input) .toDouble(), 0.0); - EXPECT_DOUBLE_EQ(node.GetStandardValue(olive::RippleDistortNode::kIntensityInput) + EXPECT_DOUBLE_EQ(node.get_standard_value(olive::RippleDistortNode::k_intensity_input) .toDouble(), 100.0); - EXPECT_DOUBLE_EQ(node.GetStandardValue(olive::RippleDistortNode::kFrequencyInput) + EXPECT_DOUBLE_EQ(node.get_standard_value(olive::RippleDistortNode::k_frequency_input) .toDouble(), 1.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::RippleDistortNode::kFrequencyInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::RippleDistortNode::k_frequency_input, QStringLiteral("base")) .toDouble(), 0.01); - EXPECT_EQ(node.GetStandardValue(olive::RippleDistortNode::kPositionInput) + EXPECT_EQ(node.get_standard_value(olive::RippleDistortNode::k_position_input) .value(), QVector2D(0.0f, 0.0f)); - EXPECT_FALSE(node.GetStandardValue(olive::RippleDistortNode::kStretchInput) + EXPECT_FALSE(node.get_standard_value(olive::RippleDistortNode::k_stretch_input) .toBool()); } TEST(RippleDistortNode, RetranslateSetsInputNames) { olive::RippleDistortNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::RippleDistortNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::RippleDistortNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::RippleDistortNode::kFrequencyInput), + EXPECT_EQ(node.get_input_name(olive::RippleDistortNode::k_frequency_input), QStringLiteral("Frequency")); - EXPECT_EQ(node.GetInputName(olive::RippleDistortNode::kIntensityInput), + EXPECT_EQ(node.get_input_name(olive::RippleDistortNode::k_intensity_input), QStringLiteral("Intensity")); - EXPECT_EQ(node.GetInputName(olive::RippleDistortNode::kEvolutionInput), + EXPECT_EQ(node.get_input_name(olive::RippleDistortNode::k_evolution_input), QStringLiteral("Evolution")); - EXPECT_EQ(node.GetInputName(olive::RippleDistortNode::kPositionInput), + EXPECT_EQ(node.get_input_name(olive::RippleDistortNode::k_position_input), QStringLiteral("Position")); - EXPECT_EQ(node.GetInputName(olive::RippleDistortNode::kStretchInput), + EXPECT_EQ(node.get_input_name(olive::RippleDistortNode::k_stretch_input), QStringLiteral("Stretch")); } @@ -1286,7 +1286,7 @@ TEST(RippleDistortNode, GetShaderCodeLoadsRippleShader) { olive::RippleDistortNode node; - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("evolution_in"))); @@ -1298,28 +1298,28 @@ TEST(RippleDistortNode, ValueWithoutTexturePushesNothing) olive::RippleDistortNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(RippleDistortNode, ValueWithZeroIntensityPassesTextureThrough) { olive::RippleDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueRow row = - MakeTextureRow(olive::RippleDistortNode::kTextureInput, tex); - row.insert(olive::RippleDistortNode::kIntensityInput, FloatValue(0.0)); + make_texture_row(olive::RippleDistortNode::k_texture_input, tex); + row.insert(olive::RippleDistortNode::k_intensity_input, float_value(0.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(RippleDistortNode, ValueWithIntensityPushesShaderJob) @@ -1328,25 +1328,25 @@ TEST(RippleDistortNode, ValueWithIntensityPushesShaderJob) // With a non-zero intensity the shader runs and receives the texture's // virtual resolution - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueRow row = - MakeTextureRow(olive::RippleDistortNode::kTextureInput, tex); - row.insert(olive::RippleDistortNode::kIntensityInput, FloatValue(100.0)); + make_texture_row(olive::RippleDistortNode::k_texture_input, tex); + row.insert(olive::RippleDistortNode::k_intensity_input, float_value(100.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); EXPECT_EQ(out->params().width(), tex->params().width()); auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_DOUBLE_EQ(job->Get(olive::RippleDistortNode::kIntensityInput).toDouble(), + EXPECT_DOUBLE_EQ(job->get(olive::RippleDistortNode::k_intensity_input).to_double(), 100.0); - EXPECT_EQ(job->Get(QStringLiteral("resolution_in")).toVec2(), + EXPECT_EQ(job->get(QStringLiteral("resolution_in")).to_vec2(), tex->virtual_resolution()); } @@ -1358,38 +1358,38 @@ TEST(SwirlDistortNode, MetadataIsCorrect) { olive::SwirlDistortNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.swirl")); - EXPECT_EQ(node.Name(), QStringLiteral("Swirl")); - EXPECT_EQ(node.Description(), + EXPECT_EQ(node.name(), QStringLiteral("Swirl")); + EXPECT_EQ(node.description(), QStringLiteral("Distorts an image by swirling it around a center point.")); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::SwirlDistortNode::kTextureInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::SwirlDistortNode::k_texture_input); } TEST(SwirlDistortNode, InputDefaults) { olive::SwirlDistortNode node; - EXPECT_EQ(int(node.GetInputDataType(olive::SwirlDistortNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable(olive::SwirlDistortNode::kTextureInput)); + EXPECT_EQ(int(node.get_input_data_type(olive::SwirlDistortNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable(olive::SwirlDistortNode::k_texture_input)); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::SwirlDistortNode::kRadiusInput).toDouble(), + node.get_standard_value(olive::SwirlDistortNode::k_radius_input).toDouble(), 200.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::SwirlDistortNode::kRadiusInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::SwirlDistortNode::k_radius_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::SwirlDistortNode::kAngleInput).toDouble(), + node.get_standard_value(olive::SwirlDistortNode::k_angle_input).toDouble(), 10.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::SwirlDistortNode::kAngleInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::SwirlDistortNode::k_angle_input, QStringLiteral("base")) .toDouble(), 0.1); - EXPECT_EQ(node.GetStandardValue(olive::SwirlDistortNode::kPositionInput) + EXPECT_EQ(node.get_standard_value(olive::SwirlDistortNode::k_position_input) .value(), QVector2D(0.0f, 0.0f)); } @@ -1397,15 +1397,15 @@ TEST(SwirlDistortNode, InputDefaults) TEST(SwirlDistortNode, RetranslateSetsInputNames) { olive::SwirlDistortNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::SwirlDistortNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::SwirlDistortNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::SwirlDistortNode::kRadiusInput), + EXPECT_EQ(node.get_input_name(olive::SwirlDistortNode::k_radius_input), QStringLiteral("Radius")); - EXPECT_EQ(node.GetInputName(olive::SwirlDistortNode::kAngleInput), + EXPECT_EQ(node.get_input_name(olive::SwirlDistortNode::k_angle_input), QStringLiteral("Angle")); - EXPECT_EQ(node.GetInputName(olive::SwirlDistortNode::kPositionInput), + EXPECT_EQ(node.get_input_name(olive::SwirlDistortNode::k_position_input), QStringLiteral("Position")); } @@ -1413,7 +1413,7 @@ TEST(SwirlDistortNode, GetShaderCodeLoadsSwirlShader) { olive::SwirlDistortNode node; - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("radius_in"))); @@ -1425,38 +1425,38 @@ TEST(SwirlDistortNode, ValueWithoutTexturePushesNothing) olive::SwirlDistortNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(SwirlDistortNode, ValueWithZeroAngleOrRadiusPassesTextureThrough) { olive::SwirlDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); // Zero angle neutralizes the swirl olive::NodeValueRow row = - MakeTextureRow(olive::SwirlDistortNode::kTextureInput, tex); - row.insert(olive::SwirlDistortNode::kAngleInput, FloatValue(0.0)); - row.insert(olive::SwirlDistortNode::kRadiusInput, FloatValue(200.0)); + make_texture_row(olive::SwirlDistortNode::k_texture_input, tex); + row.insert(olive::SwirlDistortNode::k_angle_input, float_value(0.0)); + row.insert(olive::SwirlDistortNode::k_radius_input, float_value(200.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - EXPECT_EQ(GetOutputTexture(table), tex); + ASSERT_EQ(table.count(), 1); + EXPECT_EQ(get_output_texture(table), tex); // So does a zero radius - row.insert(olive::SwirlDistortNode::kAngleInput, FloatValue(10.0)); - row.insert(olive::SwirlDistortNode::kRadiusInput, FloatValue(0.0)); + row.insert(olive::SwirlDistortNode::k_angle_input, float_value(10.0)); + row.insert(olive::SwirlDistortNode::k_radius_input, float_value(0.0)); olive::NodeValueTable zero_radius_table; - node.Value(row, olive::NodeGlobals(), &zero_radius_table); + node.value(row, olive::NodeGlobals(), &zero_radius_table); - ASSERT_EQ(zero_radius_table.Count(), 1); - EXPECT_EQ(GetOutputTexture(zero_radius_table), tex); + ASSERT_EQ(zero_radius_table.count(), 1); + EXPECT_EQ(get_output_texture(zero_radius_table), tex); } TEST(SwirlDistortNode, ValueWithAngleAndRadiusPushesShaderJob) @@ -1465,25 +1465,25 @@ TEST(SwirlDistortNode, ValueWithAngleAndRadiusPushesShaderJob) // With a non-zero angle and radius the shader runs and receives the // texture's virtual resolution - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueRow row = - MakeTextureRow(olive::SwirlDistortNode::kTextureInput, tex); - row.insert(olive::SwirlDistortNode::kAngleInput, FloatValue(10.0)); - row.insert(olive::SwirlDistortNode::kRadiusInput, FloatValue(200.0)); + make_texture_row(olive::SwirlDistortNode::k_texture_input, tex); + row.insert(olive::SwirlDistortNode::k_angle_input, float_value(10.0)); + row.insert(olive::SwirlDistortNode::k_radius_input, float_value(200.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_DOUBLE_EQ(job->Get(olive::SwirlDistortNode::kAngleInput).toDouble(), + EXPECT_DOUBLE_EQ(job->get(olive::SwirlDistortNode::k_angle_input).to_double(), 10.0); - EXPECT_EQ(job->Get(QStringLiteral("resolution_in")).toVec2(), + EXPECT_EQ(job->get(QStringLiteral("resolution_in")).to_vec2(), tex->virtual_resolution()); } @@ -1495,70 +1495,70 @@ TEST(TileDistortNode, MetadataIsCorrect) { olive::TileDistortNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.tile")); - EXPECT_EQ(node.Name(), QStringLiteral("Tile")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_EQ(node.name(), QStringLiteral("Tile")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::TileDistortNode::kTextureInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::TileDistortNode::k_texture_input); } TEST(TileDistortNode, InputDefaults) { olive::TileDistortNode node; - EXPECT_EQ(int(node.GetInputDataType(olive::TileDistortNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable(olive::TileDistortNode::kTextureInput)); + EXPECT_EQ(int(node.get_input_data_type(olive::TileDistortNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable(olive::TileDistortNode::k_texture_input)); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::TileDistortNode::kScaleInput).toDouble(), + node.get_standard_value(olive::TileDistortNode::k_scale_input).toDouble(), 0.5); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::TileDistortNode::kScaleInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::TileDistortNode::k_scale_input, QStringLiteral("min")) .toDouble(), 0.0); - EXPECT_EQ(node.GetInputProperty(olive::TileDistortNode::kScaleInput, + EXPECT_EQ(node.get_input_property(olive::TileDistortNode::k_scale_input, QStringLiteral("view")) .toInt(), - int(olive::FloatSlider::kPercentage)); + int(olive::FloatSlider::k_percentage)); - EXPECT_EQ(node.GetStandardValue(olive::TileDistortNode::kPositionInput) + EXPECT_EQ(node.get_standard_value(olive::TileDistortNode::k_position_input) .value(), QVector2D(0.0f, 0.0f)); - EXPECT_EQ(int(node.GetInputDataType(olive::TileDistortNode::kAnchorInput)), - int(olive::NodeValue::kCombo)); + EXPECT_EQ(int(node.get_input_data_type(olive::TileDistortNode::k_anchor_input)), + int(olive::NodeValue::k_combo)); // The Anchor enum is private; 4 is kMiddleCenter - EXPECT_EQ(node.GetStandardValue(olive::TileDistortNode::kAnchorInput).toInt(), + EXPECT_EQ(node.get_standard_value(olive::TileDistortNode::k_anchor_input).toInt(), 4); - EXPECT_FALSE(node.GetStandardValue(olive::TileDistortNode::kMirrorXInput) + EXPECT_FALSE(node.get_standard_value(olive::TileDistortNode::k_mirror_x_input) .toBool()); - EXPECT_FALSE(node.GetStandardValue(olive::TileDistortNode::kMirrorYInput) + EXPECT_FALSE(node.get_standard_value(olive::TileDistortNode::k_mirror_y_input) .toBool()); } TEST(TileDistortNode, RetranslateSetsNamesAndAnchorComboStrings) { olive::TileDistortNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::TileDistortNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::TileDistortNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::TileDistortNode::kScaleInput), + EXPECT_EQ(node.get_input_name(olive::TileDistortNode::k_scale_input), QStringLiteral("Scale")); - EXPECT_EQ(node.GetInputName(olive::TileDistortNode::kPositionInput), + EXPECT_EQ(node.get_input_name(olive::TileDistortNode::k_position_input), QStringLiteral("Position")); - EXPECT_EQ(node.GetInputName(olive::TileDistortNode::kAnchorInput), + EXPECT_EQ(node.get_input_name(olive::TileDistortNode::k_anchor_input), QStringLiteral("Anchor")); - EXPECT_EQ(node.GetInputName(olive::TileDistortNode::kMirrorXInput), + EXPECT_EQ(node.get_input_name(olive::TileDistortNode::k_mirror_x_input), QStringLiteral("Mirror Horizontally")); - EXPECT_EQ(node.GetInputName(olive::TileDistortNode::kMirrorYInput), + EXPECT_EQ(node.get_input_name(olive::TileDistortNode::k_mirror_y_input), QStringLiteral("Mirror Vertically")); const QStringList anchors = - node.GetComboBoxStrings(olive::TileDistortNode::kAnchorInput); + node.get_combo_box_strings(olive::TileDistortNode::k_anchor_input); ASSERT_EQ(anchors.size(), 9); EXPECT_EQ(anchors.at(0), QStringLiteral("Top-Left")); EXPECT_EQ(anchors.at(1), QStringLiteral("Top-Center")); @@ -1575,7 +1575,7 @@ TEST(TileDistortNode, GetShaderCodeLoadsTileShader) { olive::TileDistortNode node; - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("mirrorx_in"))); @@ -1587,9 +1587,9 @@ TEST(TileDistortNode, ValueWithoutTexturePushesNothing) olive::TileDistortNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(TileDistortNode, ValueWithUnitScalePassesTextureThrough) @@ -1597,19 +1597,19 @@ TEST(TileDistortNode, ValueWithUnitScalePassesTextureThrough) olive::TileDistortNode node; // A scale of exactly 1.0 is a no-op - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueRow row = - MakeTextureRow(olive::TileDistortNode::kTextureInput, tex); - row.insert(olive::TileDistortNode::kScaleInput, FloatValue(1.0)); + make_texture_row(olive::TileDistortNode::k_texture_input, tex); + row.insert(olive::TileDistortNode::k_scale_input, float_value(1.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(TileDistortNode, ValueWithNonUnitScalePushesShaderJob) @@ -1617,24 +1617,24 @@ TEST(TileDistortNode, ValueWithNonUnitScalePushesShaderJob) olive::TileDistortNode node; // Any scale other than 1.0 runs the shader - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueRow row = - MakeTextureRow(olive::TileDistortNode::kTextureInput, tex); - row.insert(olive::TileDistortNode::kScaleInput, FloatValue(0.5)); + make_texture_row(olive::TileDistortNode::k_texture_input, tex); + row.insert(olive::TileDistortNode::k_scale_input, float_value(0.5)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_DOUBLE_EQ(job->Get(olive::TileDistortNode::kScaleInput).toDouble(), + EXPECT_DOUBLE_EQ(job->get(olive::TileDistortNode::k_scale_input).to_double(), 0.5); - EXPECT_EQ(job->Get(QStringLiteral("resolution_in")).toVec2(), + EXPECT_EQ(job->get(QStringLiteral("resolution_in")).to_vec2(), tex->virtual_resolution()); } @@ -1646,56 +1646,56 @@ TEST(WaveDistortNode, MetadataIsCorrect) { olive::WaveDistortNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.wave")); - EXPECT_EQ(node.Name(), QStringLiteral("Wave")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryDistort)); + EXPECT_EQ(node.name(), QStringLiteral("Wave")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_distort)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::WaveDistortNode::kTextureInput); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::WaveDistortNode::k_texture_input); } TEST(WaveDistortNode, InputDefaults) { olive::WaveDistortNode node; - EXPECT_EQ(int(node.GetInputDataType(olive::WaveDistortNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable(olive::WaveDistortNode::kTextureInput)); + EXPECT_EQ(int(node.get_input_data_type(olive::WaveDistortNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable(olive::WaveDistortNode::k_texture_input)); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::WaveDistortNode::kFrequencyInput).toDouble(), + node.get_standard_value(olive::WaveDistortNode::k_frequency_input).toDouble(), 10.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::WaveDistortNode::kIntensityInput).toDouble(), + node.get_standard_value(olive::WaveDistortNode::k_intensity_input).toDouble(), 10.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::WaveDistortNode::kEvolutionInput).toDouble(), + node.get_standard_value(olive::WaveDistortNode::k_evolution_input).toDouble(), 0.0); - EXPECT_EQ(int(node.GetInputDataType(olive::WaveDistortNode::kVerticalInput)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(node.GetStandardValue(olive::WaveDistortNode::kVerticalInput).toInt(), + EXPECT_EQ(int(node.get_input_data_type(olive::WaveDistortNode::k_vertical_input)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(node.get_standard_value(olive::WaveDistortNode::k_vertical_input).toInt(), 0); } TEST(WaveDistortNode, RetranslateSetsNamesAndComboStrings) { olive::WaveDistortNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::WaveDistortNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::WaveDistortNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::WaveDistortNode::kFrequencyInput), + EXPECT_EQ(node.get_input_name(olive::WaveDistortNode::k_frequency_input), QStringLiteral("Frequency")); - EXPECT_EQ(node.GetInputName(olive::WaveDistortNode::kIntensityInput), + EXPECT_EQ(node.get_input_name(olive::WaveDistortNode::k_intensity_input), QStringLiteral("Intensity")); - EXPECT_EQ(node.GetInputName(olive::WaveDistortNode::kEvolutionInput), + EXPECT_EQ(node.get_input_name(olive::WaveDistortNode::k_evolution_input), QStringLiteral("Evolution")); - EXPECT_EQ(node.GetInputName(olive::WaveDistortNode::kVerticalInput), + EXPECT_EQ(node.get_input_name(olive::WaveDistortNode::k_vertical_input), QStringLiteral("Direction")); const QStringList directions = - node.GetComboBoxStrings(olive::WaveDistortNode::kVerticalInput); + node.get_combo_box_strings(olive::WaveDistortNode::k_vertical_input); ASSERT_EQ(directions.size(), 2); EXPECT_EQ(directions.at(0), QStringLiteral("Horizontal")); EXPECT_EQ(directions.at(1), QStringLiteral("Vertical")); @@ -1705,7 +1705,7 @@ TEST(WaveDistortNode, GetShaderCodeLoadsWaveShader) { olive::WaveDistortNode node; - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("vertical_in"))); @@ -1717,28 +1717,28 @@ TEST(WaveDistortNode, ValueWithoutTexturePushesNothing) olive::WaveDistortNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(WaveDistortNode, ValueWithZeroIntensityPassesTextureThrough) { olive::WaveDistortNode node; - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueRow row = - MakeTextureRow(olive::WaveDistortNode::kTextureInput, tex); - row.insert(olive::WaveDistortNode::kIntensityInput, FloatValue(0.0)); + make_texture_row(olive::WaveDistortNode::k_texture_input, tex); + row.insert(olive::WaveDistortNode::k_intensity_input, float_value(0.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(WaveDistortNode, ValueWithIntensityPushesShaderJob) @@ -1746,18 +1746,18 @@ TEST(WaveDistortNode, ValueWithIntensityPushesShaderJob) olive::WaveDistortNode node; // With a non-zero intensity the shader runs - const olive::TexturePtr tex = MakeDummyTexture(64, 48); + const olive::TexturePtr tex = make_dummy_texture(64, 48); olive::NodeValueRow row = - MakeTextureRow(olive::WaveDistortNode::kTextureInput, tex); - row.insert(olive::WaveDistortNode::kIntensityInput, FloatValue(10.0)); + make_texture_row(olive::WaveDistortNode::k_texture_input, tex); + row.insert(olive::WaveDistortNode::k_intensity_input, float_value(10.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); - const olive::TexturePtr out = GetOutputTexture(table); + ASSERT_EQ(table.count(), 1); + const olive::TexturePtr out = get_output_texture(table); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); // Unlike the other distorters, WaveDistortNode does not insert a // resolution_in; the job simply carries the row values with the input @@ -1767,7 +1767,7 @@ TEST(WaveDistortNode, ValueWithIntensityPushesShaderJob) auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_DOUBLE_EQ(job->Get(olive::WaveDistortNode::kIntensityInput).toDouble(), + EXPECT_DOUBLE_EQ(job->get(olive::WaveDistortNode::k_intensity_input).to_double(), 10.0); - EXPECT_TRUE(job->Get(QStringLiteral("resolution_in")).toVec2().isNull()); + EXPECT_TRUE(job->get(QStringLiteral("resolution_in")).to_vec2().isNull()); } diff --git a/tests/gtest/node_filter_keying_test.cpp b/tests/gtest/node_filter_keying_test.cpp index 8a3842841..5cce133b8 100644 --- a/tests/gtest/node_filter_keying_test.cpp +++ b/tests/gtest/node_filter_keying_test.cpp @@ -26,43 +26,43 @@ namespace // A "dummy" texture has no renderer backend and is therefore safe to pass // around in a headless, CPU-only test. -olive::TexturePtr MakeDummyTexture() +olive::TexturePtr make_dummy_texture() { return std::make_shared( - olive::VideoParams(16, 16, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(16, 16, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count)); } -olive::NodeValue TextureValue(const olive::TexturePtr &tex) +olive::NodeValue texture_value(const olive::TexturePtr &tex) { - return olive::NodeValue(olive::NodeValue::kTexture, tex); + return olive::NodeValue(olive::NodeValue::k_texture, tex); } -olive::NodeValue FloatValue(double d) +olive::NodeValue float_value(double d) { - return olive::NodeValue(olive::NodeValue::kFloat, d); + return olive::NodeValue(olive::NodeValue::k_float, d); } -olive::NodeValue BoolValue(bool b) +olive::NodeValue bool_value(bool b) { - return olive::NodeValue(olive::NodeValue::kBoolean, b); + return olive::NodeValue(olive::NodeValue::k_boolean, b); } -olive::NodeValue ComboValue(int i) +olive::NodeValue combo_value(int i) { - return olive::NodeValue(olive::NodeValue::kCombo, i); + return olive::NodeValue(olive::NodeValue::k_combo, i); } -olive::NodeValue Vec2Value(const QVector2D &v) +olive::NodeValue vec2_value(const QVector2D &v) { - return olive::NodeValue(olive::NodeValue::kVec2, v); + return olive::NodeValue(olive::NodeValue::k_vec2, v); } -olive::NodeValueRow MakeTextureRow(const QString &input, +olive::NodeValueRow make_texture_row(const QString &input, const olive::TexturePtr &tex) { olive::NodeValueRow row; - row.insert(input, TextureValue(tex)); + row.insert(input, texture_value(tex)); return row; } @@ -76,34 +76,34 @@ TEST(OpacityEffect, InputDefinitionsAndDefaults) { olive::OpacityEffect node; - EXPECT_TRUE(node.HasInputWithID(olive::OpacityEffect::kTextureInput)); - EXPECT_TRUE(node.HasInputWithID(olive::OpacityEffect::kValueInput)); + EXPECT_TRUE(node.has_input_with_id(olive::OpacityEffect::k_texture_input)); + EXPECT_TRUE(node.has_input_with_id(olive::OpacityEffect::k_value_input)); - EXPECT_EQ(int(node.GetInputDataType(olive::OpacityEffect::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_EQ(int(node.GetInputDataType(olive::OpacityEffect::kValueInput)), - int(olive::NodeValue::kFloat)); + EXPECT_EQ(int(node.get_input_data_type(olive::OpacityEffect::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_EQ(int(node.get_input_data_type(olive::OpacityEffect::k_value_input)), + int(olive::NodeValue::k_float)); // The texture input is a static effect input: not keyframable. - EXPECT_FALSE(node.IsInputKeyframable(olive::OpacityEffect::kTextureInput)); - EXPECT_EQ(node.GetEffectInputID(), olive::OpacityEffect::kTextureInput); + EXPECT_FALSE(node.is_input_keyframable(olive::OpacityEffect::k_texture_input)); + EXPECT_EQ(node.get_effect_input_id(), olive::OpacityEffect::k_texture_input); // Opacity is a 0-100% slider defaulting to fully opaque. EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::OpacityEffect::kValueInput).toDouble(), + node.get_standard_value(olive::OpacityEffect::k_value_input).toDouble(), 1.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::OpacityEffect::kValueInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::OpacityEffect::k_value_input, QStringLiteral("min")) .toDouble(), 0.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::OpacityEffect::kValueInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::OpacityEffect::k_value_input, QStringLiteral("max")) .toDouble(), 1.0); - EXPECT_EQ(node.GetInputProperty(olive::OpacityEffect::kValueInput, + EXPECT_EQ(node.get_input_property(olive::OpacityEffect::k_value_input, QStringLiteral("view")) .toInt(), - int(olive::FloatSlider::kPercentage)); + int(olive::FloatSlider::k_percentage)); } TEST(OpacityEffect, Identity) @@ -111,21 +111,21 @@ TEST(OpacityEffect, Identity) olive::OpacityEffect node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.opacity")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryFilter)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_filter)); } TEST(OpacityEffect, RetranslateSetsInputNames) { olive::OpacityEffect node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::OpacityEffect::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::OpacityEffect::k_texture_input), QStringLiteral("Texture")); - EXPECT_EQ(node.GetInputName(olive::OpacityEffect::kValueInput), + EXPECT_EQ(node.get_input_name(olive::OpacityEffect::k_value_input), QStringLiteral("Opacity")); } @@ -134,12 +134,12 @@ TEST(OpacityEffect, ShaderCodeSelectsFragmentById) olive::OpacityEffect node; const olive::ShaderCode mult = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("rgbmult"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("rgbmult"))); EXPECT_FALSE(mult.frag_code().isEmpty()); EXPECT_TRUE(mult.vert_code().isEmpty()); const olive::ShaderCode plain = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("other"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("other"))); EXPECT_FALSE(plain.frag_code().isEmpty()); EXPECT_TRUE(plain.vert_code().isEmpty()); @@ -152,61 +152,61 @@ TEST(OpacityEffect, ValueWithoutTexturePushesNothing) olive::OpacityEffect node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(OpacityEffect, ValueWithFullOpacityPassesTextureThrough) { olive::OpacityEffect node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OpacityEffect::kTextureInput, tex); - row.insert(olive::OpacityEffect::kValueInput, FloatValue(1.0)); + make_texture_row(olive::OpacityEffect::k_texture_input, tex); + row.insert(olive::OpacityEffect::k_value_input, float_value(1.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); // 1.0 is a no-op: the input texture is pushed unchanged, not a job. - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(OpacityEffect, ValueWithFractionalOpacityPushesShaderJob) { olive::OpacityEffect node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OpacityEffect::kTextureInput, tex); - row.insert(olive::OpacityEffect::kValueInput, FloatValue(0.5)); + make_texture_row(olive::OpacityEffect::k_texture_input, tex); + row.insert(olive::OpacityEffect::k_value_input, float_value(0.5)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // The default shader (no special ID) is used for a plain float multiply. - EXPECT_TRUE(job->GetShaderID().isEmpty()); + EXPECT_TRUE(job->get_shader_id().isEmpty()); - const olive::NodeValueRow &values = job->GetValues(); - ASSERT_TRUE(values.contains(olive::OpacityEffect::kValueInput)); - EXPECT_DOUBLE_EQ(values.value(olive::OpacityEffect::kValueInput).toDouble(), + const olive::NodeValueRow &values = job->get_values(); + ASSERT_TRUE(values.contains(olive::OpacityEffect::k_value_input)); + EXPECT_DOUBLE_EQ(values.value(olive::OpacityEffect::k_value_input).to_double(), 0.5); - EXPECT_EQ(values.value(olive::OpacityEffect::kTextureInput).toTexture(), + EXPECT_EQ(values.value(olive::OpacityEffect::k_texture_input).to_texture(), tex); } @@ -214,29 +214,29 @@ TEST(OpacityEffect, ValueWithTextureOpacityPushesRgbMultJob) { olive::OpacityEffect node; - olive::TexturePtr tex = MakeDummyTexture(); - olive::TexturePtr opacity_tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); + olive::TexturePtr opacity_tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OpacityEffect::kTextureInput, tex); - row.insert(olive::OpacityEffect::kValueInput, TextureValue(opacity_tex)); + make_texture_row(olive::OpacityEffect::k_texture_input, tex); + row.insert(olive::OpacityEffect::k_value_input, texture_value(opacity_tex)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // A texture-valued opacity selects the rgbmult shader. - EXPECT_EQ(job->GetShaderID(), QStringLiteral("rgbmult")); - EXPECT_EQ(job->GetValues() - .value(olive::OpacityEffect::kValueInput) - .toTexture(), + EXPECT_EQ(job->get_shader_id(), QStringLiteral("rgbmult")); + EXPECT_EQ(job->get_values() + .value(olive::OpacityEffect::k_value_input) + .to_texture(), opacity_tex); } @@ -248,41 +248,41 @@ TEST(BlurFilterNode, InputDefinitionsAndDefaults) { olive::BlurFilterNode node; - EXPECT_EQ(int(node.GetInputDataType(olive::BlurFilterNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable(olive::BlurFilterNode::kTextureInput)); - EXPECT_EQ(node.GetEffectInputID(), olive::BlurFilterNode::kTextureInput); + EXPECT_EQ(int(node.get_input_data_type(olive::BlurFilterNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable(olive::BlurFilterNode::k_texture_input)); + EXPECT_EQ(node.get_effect_input_id(), olive::BlurFilterNode::k_texture_input); // Method is a static UI choice defaulting to Gaussian. - EXPECT_EQ(int(node.GetInputDataType(olive::BlurFilterNode::kMethodInput)), - int(olive::NodeValue::kCombo)); - EXPECT_FALSE(node.IsInputKeyframable(olive::BlurFilterNode::kMethodInput)); - EXPECT_FALSE(node.IsInputConnectable(olive::BlurFilterNode::kMethodInput)); - EXPECT_EQ(node.GetStandardValue(olive::BlurFilterNode::kMethodInput).toInt(), - int(olive::BlurFilterNode::kGaussian)); - EXPECT_EQ(int(node.GetMethod()), int(olive::BlurFilterNode::kGaussian)); + EXPECT_EQ(int(node.get_input_data_type(olive::BlurFilterNode::k_method_input)), + int(olive::NodeValue::k_combo)); + EXPECT_FALSE(node.is_input_keyframable(olive::BlurFilterNode::k_method_input)); + EXPECT_FALSE(node.is_input_connectable(olive::BlurFilterNode::k_method_input)); + EXPECT_EQ(node.get_standard_value(olive::BlurFilterNode::k_method_input).toInt(), + int(olive::BlurFilterNode::k_gaussian)); + EXPECT_EQ(int(node.get_method()), int(olive::BlurFilterNode::k_gaussian)); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::BlurFilterNode::kRadiusInput).toDouble(), + node.get_standard_value(olive::BlurFilterNode::k_radius_input).toDouble(), 10.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::BlurFilterNode::kRadiusInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::BlurFilterNode::k_radius_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_TRUE( - node.GetStandardValue(olive::BlurFilterNode::kHorizInput).toBool()); + node.get_standard_value(olive::BlurFilterNode::k_horiz_input).toBool()); EXPECT_TRUE( - node.GetStandardValue(olive::BlurFilterNode::kVertInput).toBool()); + node.get_standard_value(olive::BlurFilterNode::k_vert_input).toBool()); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::BlurFilterNode::kDirectionalDegreesInput) + node.get_standard_value(olive::BlurFilterNode::k_directional_degrees_input) .toDouble(), 0.0); - EXPECT_EQ(node.GetStandardValue(olive::BlurFilterNode::kRadialCenterInput) + EXPECT_EQ(node.get_standard_value(olive::BlurFilterNode::k_radial_center_input) .value(), QVector2D(0.0f, 0.0f)); - EXPECT_TRUE(node.GetStandardValue( - olive::BlurFilterNode::kRepeatEdgePixelsInput) + EXPECT_TRUE(node.get_standard_value( + olive::BlurFilterNode::k_repeat_edge_pixels_input) .toBool()); } @@ -291,39 +291,39 @@ TEST(BlurFilterNode, Identity) olive::BlurFilterNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.blur")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryFilter)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_filter)); } TEST(BlurFilterNode, RetranslateSetsInputNamesAndComboStrings) { olive::BlurFilterNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::BlurFilterNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::BlurFilterNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::BlurFilterNode::kMethodInput), + EXPECT_EQ(node.get_input_name(olive::BlurFilterNode::k_method_input), QStringLiteral("Method")); - EXPECT_EQ(node.GetComboBoxStrings(olive::BlurFilterNode::kMethodInput), + EXPECT_EQ(node.get_combo_box_strings(olive::BlurFilterNode::k_method_input), QStringList({ QStringLiteral("Box"), QStringLiteral("Gaussian"), QStringLiteral("Directional"), QStringLiteral("Radial") })); - EXPECT_EQ(node.GetInputName(olive::BlurFilterNode::kRadiusInput), + EXPECT_EQ(node.get_input_name(olive::BlurFilterNode::k_radius_input), QStringLiteral("Radius")); - EXPECT_EQ(node.GetInputName(olive::BlurFilterNode::kHorizInput), + EXPECT_EQ(node.get_input_name(olive::BlurFilterNode::k_horiz_input), QStringLiteral("Horizontal")); - EXPECT_EQ(node.GetInputName(olive::BlurFilterNode::kVertInput), + EXPECT_EQ(node.get_input_name(olive::BlurFilterNode::k_vert_input), QStringLiteral("Vertical")); EXPECT_EQ( - node.GetInputName(olive::BlurFilterNode::kRepeatEdgePixelsInput), + node.get_input_name(olive::BlurFilterNode::k_repeat_edge_pixels_input), QStringLiteral("Repeat Edge Pixels")); EXPECT_EQ( - node.GetInputName(olive::BlurFilterNode::kDirectionalDegreesInput), + node.get_input_name(olive::BlurFilterNode::k_directional_degrees_input), QStringLiteral("Direction")); - EXPECT_EQ(node.GetInputName(olive::BlurFilterNode::kRadialCenterInput), + EXPECT_EQ(node.get_input_name(olive::BlurFilterNode::k_radial_center_input), QStringLiteral("Center")); } @@ -332,35 +332,35 @@ TEST(BlurFilterNode, MethodSwitchTogglesInputVisibility) olive::BlurFilterNode node; // Default method (Gaussian) shows the axis toggles only. - EXPECT_FALSE(node.IsInputHidden(olive::BlurFilterNode::kHorizInput)); - EXPECT_FALSE(node.IsInputHidden(olive::BlurFilterNode::kVertInput)); + EXPECT_FALSE(node.is_input_hidden(olive::BlurFilterNode::k_horiz_input)); + EXPECT_FALSE(node.is_input_hidden(olive::BlurFilterNode::k_vert_input)); EXPECT_TRUE( - node.IsInputHidden(olive::BlurFilterNode::kDirectionalDegreesInput)); - EXPECT_TRUE(node.IsInputHidden(olive::BlurFilterNode::kRadialCenterInput)); + node.is_input_hidden(olive::BlurFilterNode::k_directional_degrees_input)); + EXPECT_TRUE(node.is_input_hidden(olive::BlurFilterNode::k_radial_center_input)); - node.SetStandardValue(olive::BlurFilterNode::kMethodInput, - int(olive::BlurFilterNode::kDirectional)); - EXPECT_TRUE(node.IsInputHidden(olive::BlurFilterNode::kHorizInput)); - EXPECT_TRUE(node.IsInputHidden(olive::BlurFilterNode::kVertInput)); + node.set_standard_value(olive::BlurFilterNode::k_method_input, + int(olive::BlurFilterNode::k_directional)); + EXPECT_TRUE(node.is_input_hidden(olive::BlurFilterNode::k_horiz_input)); + EXPECT_TRUE(node.is_input_hidden(olive::BlurFilterNode::k_vert_input)); EXPECT_FALSE( - node.IsInputHidden(olive::BlurFilterNode::kDirectionalDegreesInput)); - EXPECT_TRUE(node.IsInputHidden(olive::BlurFilterNode::kRadialCenterInput)); + node.is_input_hidden(olive::BlurFilterNode::k_directional_degrees_input)); + EXPECT_TRUE(node.is_input_hidden(olive::BlurFilterNode::k_radial_center_input)); - node.SetStandardValue(olive::BlurFilterNode::kMethodInput, - int(olive::BlurFilterNode::kRadial)); - EXPECT_TRUE(node.IsInputHidden(olive::BlurFilterNode::kHorizInput)); - EXPECT_TRUE(node.IsInputHidden(olive::BlurFilterNode::kVertInput)); + node.set_standard_value(olive::BlurFilterNode::k_method_input, + int(olive::BlurFilterNode::k_radial)); + EXPECT_TRUE(node.is_input_hidden(olive::BlurFilterNode::k_horiz_input)); + EXPECT_TRUE(node.is_input_hidden(olive::BlurFilterNode::k_vert_input)); EXPECT_TRUE( - node.IsInputHidden(olive::BlurFilterNode::kDirectionalDegreesInput)); - EXPECT_FALSE(node.IsInputHidden(olive::BlurFilterNode::kRadialCenterInput)); + node.is_input_hidden(olive::BlurFilterNode::k_directional_degrees_input)); + EXPECT_FALSE(node.is_input_hidden(olive::BlurFilterNode::k_radial_center_input)); - node.SetStandardValue(olive::BlurFilterNode::kMethodInput, - int(olive::BlurFilterNode::kBox)); - EXPECT_FALSE(node.IsInputHidden(olive::BlurFilterNode::kHorizInput)); - EXPECT_FALSE(node.IsInputHidden(olive::BlurFilterNode::kVertInput)); + node.set_standard_value(olive::BlurFilterNode::k_method_input, + int(olive::BlurFilterNode::k_box)); + EXPECT_FALSE(node.is_input_hidden(olive::BlurFilterNode::k_horiz_input)); + EXPECT_FALSE(node.is_input_hidden(olive::BlurFilterNode::k_vert_input)); EXPECT_TRUE( - node.IsInputHidden(olive::BlurFilterNode::kDirectionalDegreesInput)); - EXPECT_TRUE(node.IsInputHidden(olive::BlurFilterNode::kRadialCenterInput)); + node.is_input_hidden(olive::BlurFilterNode::k_directional_degrees_input)); + EXPECT_TRUE(node.is_input_hidden(olive::BlurFilterNode::k_radial_center_input)); } TEST(BlurFilterNode, ShaderCodeLoadsFragmentResource) @@ -368,7 +368,7 @@ TEST(BlurFilterNode, ShaderCodeLoadsFragmentResource) olive::BlurFilterNode node; const olive::ShaderCode code = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("test"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("test"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.vert_code().isEmpty()); @@ -379,156 +379,156 @@ TEST(BlurFilterNode, ValueWithoutTexturePushesNothing) olive::BlurFilterNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(BlurFilterNode, ValueWithZeroRadiusPassesTextureThrough) { olive::BlurFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::BlurFilterNode::kTextureInput, tex); - row.insert(olive::BlurFilterNode::kMethodInput, - ComboValue(int(olive::BlurFilterNode::kGaussian))); - row.insert(olive::BlurFilterNode::kRadiusInput, FloatValue(0.0)); - row.insert(olive::BlurFilterNode::kHorizInput, BoolValue(true)); - row.insert(olive::BlurFilterNode::kVertInput, BoolValue(true)); + make_texture_row(olive::BlurFilterNode::k_texture_input, tex); + row.insert(olive::BlurFilterNode::k_method_input, + combo_value(int(olive::BlurFilterNode::k_gaussian))); + row.insert(olive::BlurFilterNode::k_radius_input, float_value(0.0)); + row.insert(olive::BlurFilterNode::k_horiz_input, bool_value(true)); + row.insert(olive::BlurFilterNode::k_vert_input, bool_value(true)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); // No radius means no blur: the texture passes through unchanged. - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(BlurFilterNode, ValueWithBothAxesPushesTwoIterationJob) { olive::BlurFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::BlurFilterNode::kTextureInput, tex); - row.insert(olive::BlurFilterNode::kMethodInput, - ComboValue(int(olive::BlurFilterNode::kGaussian))); - row.insert(olive::BlurFilterNode::kRadiusInput, FloatValue(10.0)); - row.insert(olive::BlurFilterNode::kHorizInput, BoolValue(true)); - row.insert(olive::BlurFilterNode::kVertInput, BoolValue(true)); + make_texture_row(olive::BlurFilterNode::k_texture_input, tex); + row.insert(olive::BlurFilterNode::k_method_input, + combo_value(int(olive::BlurFilterNode::k_gaussian))); + row.insert(olive::BlurFilterNode::k_radius_input, float_value(10.0)); + row.insert(olive::BlurFilterNode::k_horiz_input, bool_value(true)); + row.insert(olive::BlurFilterNode::k_vert_input, bool_value(true)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // Blurring both axes runs the shader twice, feeding the texture input. - EXPECT_EQ(job->GetIterationCount(), 2); - EXPECT_EQ(job->GetIterativeInput(), olive::BlurFilterNode::kTextureInput); + EXPECT_EQ(job->get_iteration_count(), 2); + EXPECT_EQ(job->get_iterative_input(), olive::BlurFilterNode::k_texture_input); - const olive::NodeValueRow &values = job->GetValues(); + const olive::NodeValueRow &values = job->get_values(); ASSERT_TRUE(values.contains(QStringLiteral("resolution_in"))); - EXPECT_EQ(values.value(QStringLiteral("resolution_in")).toVec2(), + EXPECT_EQ(values.value(QStringLiteral("resolution_in")).to_vec2(), QVector2D(16.0f, 16.0f)); EXPECT_DOUBLE_EQ( - values.value(olive::BlurFilterNode::kRadiusInput).toDouble(), 10.0); + values.value(olive::BlurFilterNode::k_radius_input).to_double(), 10.0); } TEST(BlurFilterNode, ValueWithSingleAxisPushesOneIterationJob) { olive::BlurFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::BlurFilterNode::kTextureInput, tex); - row.insert(olive::BlurFilterNode::kMethodInput, - ComboValue(int(olive::BlurFilterNode::kGaussian))); - row.insert(olive::BlurFilterNode::kRadiusInput, FloatValue(10.0)); - row.insert(olive::BlurFilterNode::kHorizInput, BoolValue(true)); - row.insert(olive::BlurFilterNode::kVertInput, BoolValue(false)); + make_texture_row(olive::BlurFilterNode::k_texture_input, tex); + row.insert(olive::BlurFilterNode::k_method_input, + combo_value(int(olive::BlurFilterNode::k_gaussian))); + row.insert(olive::BlurFilterNode::k_radius_input, float_value(10.0)); + row.insert(olive::BlurFilterNode::k_horiz_input, bool_value(true)); + row.insert(olive::BlurFilterNode::k_vert_input, bool_value(false)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); - EXPECT_EQ(job->GetIterationCount(), 1); - EXPECT_EQ(job->GetIterativeInput(), olive::BlurFilterNode::kTextureInput); + EXPECT_EQ(job->get_iteration_count(), 1); + EXPECT_EQ(job->get_iterative_input(), olive::BlurFilterNode::k_texture_input); } TEST(BlurFilterNode, ValueWithNoAxesPassesTextureThrough) { olive::BlurFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::BlurFilterNode::kTextureInput, tex); - row.insert(olive::BlurFilterNode::kMethodInput, - ComboValue(int(olive::BlurFilterNode::kGaussian))); - row.insert(olive::BlurFilterNode::kRadiusInput, FloatValue(10.0)); - row.insert(olive::BlurFilterNode::kHorizInput, BoolValue(false)); - row.insert(olive::BlurFilterNode::kVertInput, BoolValue(false)); + make_texture_row(olive::BlurFilterNode::k_texture_input, tex); + row.insert(olive::BlurFilterNode::k_method_input, + combo_value(int(olive::BlurFilterNode::k_gaussian))); + row.insert(olive::BlurFilterNode::k_radius_input, float_value(10.0)); + row.insert(olive::BlurFilterNode::k_horiz_input, bool_value(false)); + row.insert(olive::BlurFilterNode::k_vert_input, bool_value(false)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); // Both axes unchecked disables the blur entirely. - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(BlurFilterNode, ValueWithDirectionalMethodPushesJob) { olive::BlurFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::BlurFilterNode::kTextureInput, tex); - row.insert(olive::BlurFilterNode::kMethodInput, - ComboValue(int(olive::BlurFilterNode::kDirectional))); - row.insert(olive::BlurFilterNode::kRadiusInput, FloatValue(10.0)); - row.insert(olive::BlurFilterNode::kDirectionalDegreesInput, - FloatValue(45.0)); + make_texture_row(olive::BlurFilterNode::k_texture_input, tex); + row.insert(olive::BlurFilterNode::k_method_input, + combo_value(int(olive::BlurFilterNode::k_directional))); + row.insert(olive::BlurFilterNode::k_radius_input, float_value(10.0)); + row.insert(olive::BlurFilterNode::k_directional_degrees_input, + float_value(45.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); // Directional blur ignores the axis toggles and always runs once. - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); - EXPECT_EQ(job->GetIterationCount(), 1); + EXPECT_EQ(job->get_iteration_count(), 1); EXPECT_DOUBLE_EQ( - job->GetValues() - .value(olive::BlurFilterNode::kDirectionalDegreesInput) - .toDouble(), + job->get_values() + .value(olive::BlurFilterNode::k_directional_degrees_input) + .to_double(), 45.0); } @@ -536,34 +536,34 @@ TEST(BlurFilterNode, RadialGizmoFollowsCenterAndHalfResolution) { olive::BlurFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); - ASSERT_EQ(node.GetGizmos().size(), 1); - auto *gizmo = static_cast(node.GetGizmos().first()); + ASSERT_EQ(node.get_gizmos().size(), 1); + auto *gizmo = static_cast(node.get_gizmos().first()); ASSERT_NE(gizmo, nullptr); olive::NodeValueRow row = - MakeTextureRow(olive::BlurFilterNode::kTextureInput, tex); - row.insert(olive::BlurFilterNode::kMethodInput, - ComboValue(int(olive::BlurFilterNode::kRadial))); - row.insert(olive::BlurFilterNode::kRadialCenterInput, - Vec2Value(QVector2D(3.0f, -2.0f))); + make_texture_row(olive::BlurFilterNode::k_texture_input, tex); + row.insert(olive::BlurFilterNode::k_method_input, + combo_value(int(olive::BlurFilterNode::k_radial))); + row.insert(olive::BlurFilterNode::k_radial_center_input, + vec2_value(QVector2D(3.0f, -2.0f))); - node.UpdateGizmoPositions(row, olive::NodeGlobals()); + node.update_gizmo_positions(row, olive::NodeGlobals()); // The gizmo sits at the center offset from half the texture resolution. - EXPECT_TRUE(gizmo->IsVisible()); - EXPECT_EQ(gizmo->GetPoint(), QPointF(11.0, 6.0)); - EXPECT_EQ(node.GetInputProperty(olive::BlurFilterNode::kRadialCenterInput, + EXPECT_TRUE(gizmo->is_visible()); + EXPECT_EQ(gizmo->get_point(), QPointF(11.0, 6.0)); + EXPECT_EQ(node.get_input_property(olive::BlurFilterNode::k_radial_center_input, QStringLiteral("offset")) .value(), QVector2D(8.0f, 8.0f)); // Any other method hides the gizmo again. - row[olive::BlurFilterNode::kMethodInput] = - ComboValue(int(olive::BlurFilterNode::kGaussian)); - node.UpdateGizmoPositions(row, olive::NodeGlobals()); - EXPECT_FALSE(gizmo->IsVisible()); + row[olive::BlurFilterNode::k_method_input] = + combo_value(int(olive::BlurFilterNode::k_gaussian)); + node.update_gizmo_positions(row, olive::NodeGlobals()); + EXPECT_FALSE(gizmo->is_visible()); } // ----------------------------------------------------------------------------- @@ -574,15 +574,15 @@ TEST(DropShadowFilter, InputDefinitionsAndDefaults) { olive::DropShadowFilter node; - EXPECT_EQ(int(node.GetInputDataType(olive::DropShadowFilter::kTextureInput)), - int(olive::NodeValue::kTexture)); + EXPECT_EQ(int(node.get_input_data_type(olive::DropShadowFilter::k_texture_input)), + int(olive::NodeValue::k_texture)); EXPECT_FALSE( - node.IsInputKeyframable(olive::DropShadowFilter::kTextureInput)); - EXPECT_EQ(node.GetEffectInputID(), olive::DropShadowFilter::kTextureInput); + node.is_input_keyframable(olive::DropShadowFilter::k_texture_input)); + EXPECT_EQ(node.get_effect_input_id(), olive::DropShadowFilter::k_texture_input); // The default shadow is black. const olive::core::Color color = - node.GetStandardValue(olive::DropShadowFilter::kColorInput) + node.get_standard_value(olive::DropShadowFilter::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 0.0f); EXPECT_FLOAT_EQ(color.green(), 0.0f); @@ -590,35 +590,35 @@ TEST(DropShadowFilter, InputDefinitionsAndDefaults) EXPECT_FLOAT_EQ(color.alpha(), 1.0f); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::DropShadowFilter::kDistanceInput) + node.get_standard_value(olive::DropShadowFilter::k_distance_input) .toDouble(), 10.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::DropShadowFilter::kAngleInput).toDouble(), + node.get_standard_value(olive::DropShadowFilter::k_angle_input).toDouble(), 135.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::DropShadowFilter::kSoftnessInput) + node.get_standard_value(olive::DropShadowFilter::k_softness_input) .toDouble(), 10.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::DropShadowFilter::kSoftnessInput, + node.get_input_property(olive::DropShadowFilter::k_softness_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::DropShadowFilter::kOpacityInput) + node.get_standard_value(olive::DropShadowFilter::k_opacity_input) .toDouble(), 1.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::DropShadowFilter::kOpacityInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::DropShadowFilter::k_opacity_input, QStringLiteral("min")) .toDouble(), 0.0); - EXPECT_EQ(node.GetInputProperty(olive::DropShadowFilter::kOpacityInput, + EXPECT_EQ(node.get_input_property(olive::DropShadowFilter::k_opacity_input, QStringLiteral("view")) .toInt(), - int(olive::FloatSlider::kPercentage)); + int(olive::FloatSlider::k_percentage)); EXPECT_FALSE( - node.GetStandardValue(olive::DropShadowFilter::kFastInput).toBool()); + node.get_standard_value(olive::DropShadowFilter::k_fast_input).toBool()); } TEST(DropShadowFilter, Identity) @@ -627,31 +627,31 @@ TEST(DropShadowFilter, Identity) EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.dropshadow")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryFilter)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_filter)); } TEST(DropShadowFilter, RetranslateSetsInputNames) { olive::DropShadowFilter node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::DropShadowFilter::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::DropShadowFilter::k_texture_input), QStringLiteral("Texture")); - EXPECT_EQ(node.GetInputName(olive::DropShadowFilter::kColorInput), + EXPECT_EQ(node.get_input_name(olive::DropShadowFilter::k_color_input), QStringLiteral("Color")); - EXPECT_EQ(node.GetInputName(olive::DropShadowFilter::kDistanceInput), + EXPECT_EQ(node.get_input_name(olive::DropShadowFilter::k_distance_input), QStringLiteral("Distance")); - EXPECT_EQ(node.GetInputName(olive::DropShadowFilter::kAngleInput), + EXPECT_EQ(node.get_input_name(olive::DropShadowFilter::k_angle_input), QStringLiteral("Angle")); - EXPECT_EQ(node.GetInputName(olive::DropShadowFilter::kSoftnessInput), + EXPECT_EQ(node.get_input_name(olive::DropShadowFilter::k_softness_input), QStringLiteral("Softness")); - EXPECT_EQ(node.GetInputName(olive::DropShadowFilter::kOpacityInput), + EXPECT_EQ(node.get_input_name(olive::DropShadowFilter::k_opacity_input), QStringLiteral("Opacity")); - EXPECT_EQ(node.GetInputName(olive::DropShadowFilter::kFastInput), + EXPECT_EQ(node.get_input_name(olive::DropShadowFilter::k_fast_input), QStringLiteral("Faster (Lower Quality)")); } @@ -660,7 +660,7 @@ TEST(DropShadowFilter, ShaderCodeLoadsFragmentResource) olive::DropShadowFilter node; const olive::ShaderCode code = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("test"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("test"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.vert_code().isEmpty()); @@ -671,41 +671,41 @@ TEST(DropShadowFilter, ValueWithoutTexturePushesNothing) olive::DropShadowFilter node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(DropShadowFilter, ValueWithZeroSoftnessPushesSingleIterationJob) { olive::DropShadowFilter node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::DropShadowFilter::kTextureInput, tex); - row.insert(olive::DropShadowFilter::kSoftnessInput, FloatValue(0.0)); + make_texture_row(olive::DropShadowFilter::k_texture_input, tex); + row.insert(olive::DropShadowFilter::k_softness_input, float_value(0.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // Zero softness skips the blur passes: a single shader iteration remains. - EXPECT_EQ(job->GetIterationCount(), 1); + EXPECT_EQ(job->get_iteration_count(), 1); - const olive::NodeValueRow &values = job->GetValues(); - EXPECT_EQ(values.value(QStringLiteral("resolution_in")).toVec2(), + const olive::NodeValueRow &values = job->get_values(); + EXPECT_EQ(values.value(QStringLiteral("resolution_in")).to_vec2(), QVector2D(16.0f, 16.0f)); // The previous-iteration input is always seeded with the source texture. EXPECT_EQ(values.value(QStringLiteral("previous_iteration_in")) - .toTexture(), + .to_texture(), tex); } @@ -713,26 +713,26 @@ TEST(DropShadowFilter, ValueWithSoftnessPushesThreeIterationJob) { olive::DropShadowFilter node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::DropShadowFilter::kTextureInput, tex); - row.insert(olive::DropShadowFilter::kSoftnessInput, FloatValue(10.0)); + make_texture_row(olive::DropShadowFilter::k_texture_input, tex); + row.insert(olive::DropShadowFilter::k_softness_input, float_value(10.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // Non-zero softness blurs iteratively over the previous pass. - EXPECT_EQ(job->GetIterationCount(), 3); - EXPECT_EQ(job->GetIterativeInput(), + EXPECT_EQ(job->get_iteration_count(), 3); + EXPECT_EQ(job->get_iterative_input(), QStringLiteral("previous_iteration_in")); } @@ -745,23 +745,23 @@ TEST(MosaicFilterNode, InputDefinitionsAndDefaults) olive::MosaicFilterNode node; EXPECT_EQ( - int(node.GetInputDataType(olive::MosaicFilterNode::kTextureInput)), - int(olive::NodeValue::kTexture)); + int(node.get_input_data_type(olive::MosaicFilterNode::k_texture_input)), + int(olive::NodeValue::k_texture)); EXPECT_FALSE( - node.IsInputKeyframable(olive::MosaicFilterNode::kTextureInput)); - EXPECT_EQ(node.GetEffectInputID(), olive::MosaicFilterNode::kTextureInput); + node.is_input_keyframable(olive::MosaicFilterNode::k_texture_input)); + EXPECT_EQ(node.get_effect_input_id(), olive::MosaicFilterNode::k_texture_input); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::MosaicFilterNode::kHorizInput).toDouble(), + node.get_standard_value(olive::MosaicFilterNode::k_horiz_input).toDouble(), 32.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::MosaicFilterNode::kHorizInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::MosaicFilterNode::k_horiz_input, QStringLiteral("min")) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::MosaicFilterNode::kVertInput).toDouble(), + node.get_standard_value(olive::MosaicFilterNode::k_vert_input).toDouble(), 18.0); - EXPECT_DOUBLE_EQ(node.GetInputProperty(olive::MosaicFilterNode::kVertInput, + EXPECT_DOUBLE_EQ(node.get_input_property(olive::MosaicFilterNode::k_vert_input, QStringLiteral("min")) .toDouble(), 1.0); @@ -773,23 +773,23 @@ TEST(MosaicFilterNode, Identity) EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.mosaicfilter")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryFilter)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_filter)); } TEST(MosaicFilterNode, RetranslateSetsInputNames) { olive::MosaicFilterNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::MosaicFilterNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::MosaicFilterNode::k_texture_input), QStringLiteral("Texture")); - EXPECT_EQ(node.GetInputName(olive::MosaicFilterNode::kHorizInput), + EXPECT_EQ(node.get_input_name(olive::MosaicFilterNode::k_horiz_input), QStringLiteral("Horizontal")); - EXPECT_EQ(node.GetInputName(olive::MosaicFilterNode::kVertInput), + EXPECT_EQ(node.get_input_name(olive::MosaicFilterNode::k_vert_input), QStringLiteral("Vertical")); } @@ -798,7 +798,7 @@ TEST(MosaicFilterNode, ShaderCodeLoadsFragmentResource) olive::MosaicFilterNode node; const olive::ShaderCode code = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("test"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("test"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.vert_code().isEmpty()); @@ -809,9 +809,9 @@ TEST(MosaicFilterNode, ValueWithoutTexturePushesNothing) olive::MosaicFilterNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(MosaicFilterNode, ValueWithMatchingResolutionPassesTextureThrough) @@ -819,21 +819,21 @@ TEST(MosaicFilterNode, ValueWithMatchingResolutionPassesTextureThrough) olive::MosaicFilterNode node; // A mosaic block size equal to the texture size is a no-op. - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::MosaicFilterNode::kTextureInput, tex); - row.insert(olive::MosaicFilterNode::kHorizInput, FloatValue(16.0)); - row.insert(olive::MosaicFilterNode::kVertInput, FloatValue(16.0)); + make_texture_row(olive::MosaicFilterNode::k_texture_input, tex); + row.insert(olive::MosaicFilterNode::k_horiz_input, float_value(16.0)); + row.insert(olive::MosaicFilterNode::k_vert_input, float_value(16.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(MosaicFilterNode, ValueWithSingleAxisMatchingResolutionRunsJob) @@ -842,47 +842,47 @@ TEST(MosaicFilterNode, ValueWithSingleAxisMatchingResolutionRunsJob) // Only one axis matching the texture size still changes the image, so // the effect must run; passthrough requires BOTH axes to match. - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::MosaicFilterNode::kTextureInput, tex); - row.insert(olive::MosaicFilterNode::kHorizInput, FloatValue(16.0)); - row.insert(olive::MosaicFilterNode::kVertInput, FloatValue(8.0)); + make_texture_row(olive::MosaicFilterNode::k_texture_input, tex); + row.insert(olive::MosaicFilterNode::k_horiz_input, float_value(16.0)); + row.insert(olive::MosaicFilterNode::k_vert_input, float_value(8.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - EXPECT_TRUE(out->IsJob()); + EXPECT_TRUE(out->is_job()); } TEST(MosaicFilterNode, ValuePushesJobWithLinearInterpolation) { olive::MosaicFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::MosaicFilterNode::kTextureInput, tex); - row.insert(olive::MosaicFilterNode::kHorizInput, FloatValue(32.0)); - row.insert(olive::MosaicFilterNode::kVertInput, FloatValue(18.0)); + make_texture_row(olive::MosaicFilterNode::k_texture_input, tex); + row.insert(olive::MosaicFilterNode::k_horiz_input, float_value(32.0)); + row.insert(olive::MosaicFilterNode::k_vert_input, float_value(18.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // Mipmapping would smear the blocks, so the mosaic forces bilinear lookup. - EXPECT_EQ(int(job->GetInterpolation(olive::MosaicFilterNode::kTextureInput)), - int(olive::Texture::kLinear)); + EXPECT_EQ(int(job->get_interpolation(olive::MosaicFilterNode::k_texture_input)), + int(olive::Texture::k_linear)); } // ----------------------------------------------------------------------------- @@ -893,15 +893,15 @@ TEST(StrokeFilterNode, InputDefinitionsAndDefaults) { olive::StrokeFilterNode node; - EXPECT_EQ(int(node.GetInputDataType(olive::StrokeFilterNode::kTextureInput)), - int(olive::NodeValue::kTexture)); + EXPECT_EQ(int(node.get_input_data_type(olive::StrokeFilterNode::k_texture_input)), + int(olive::NodeValue::k_texture)); EXPECT_FALSE( - node.IsInputKeyframable(olive::StrokeFilterNode::kTextureInput)); - EXPECT_EQ(node.GetEffectInputID(), olive::StrokeFilterNode::kTextureInput); + node.is_input_keyframable(olive::StrokeFilterNode::k_texture_input)); + EXPECT_EQ(node.get_effect_input_id(), olive::StrokeFilterNode::k_texture_input); // The default stroke is opaque white. const olive::core::Color color = - node.GetStandardValue(olive::StrokeFilterNode::kColorInput) + node.get_standard_value(olive::StrokeFilterNode::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_FLOAT_EQ(color.green(), 1.0f); @@ -909,33 +909,33 @@ TEST(StrokeFilterNode, InputDefinitionsAndDefaults) EXPECT_FLOAT_EQ(color.alpha(), 1.0f); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::StrokeFilterNode::kRadiusInput).toDouble(), + node.get_standard_value(olive::StrokeFilterNode::k_radius_input).toDouble(), 10.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::StrokeFilterNode::kRadiusInput, + node.get_input_property(olive::StrokeFilterNode::k_radius_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::StrokeFilterNode::kOpacityInput) + node.get_standard_value(olive::StrokeFilterNode::k_opacity_input) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::StrokeFilterNode::kOpacityInput, + node.get_input_property(olive::StrokeFilterNode::k_opacity_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::StrokeFilterNode::kOpacityInput, + node.get_input_property(olive::StrokeFilterNode::k_opacity_input, QStringLiteral("max")) .toDouble(), 1.0); - EXPECT_EQ(node.GetInputProperty(olive::StrokeFilterNode::kOpacityInput, + EXPECT_EQ(node.get_input_property(olive::StrokeFilterNode::k_opacity_input, QStringLiteral("view")) .toInt(), - int(olive::FloatSlider::kPercentage)); + int(olive::FloatSlider::k_percentage)); EXPECT_FALSE( - node.GetStandardValue(olive::StrokeFilterNode::kInnerInput).toBool()); + node.get_standard_value(olive::StrokeFilterNode::k_inner_input).toBool()); } TEST(StrokeFilterNode, Identity) @@ -943,27 +943,27 @@ TEST(StrokeFilterNode, Identity) olive::StrokeFilterNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.stroke")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryFilter)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_filter)); } TEST(StrokeFilterNode, RetranslateSetsInputNames) { olive::StrokeFilterNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::StrokeFilterNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::StrokeFilterNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::StrokeFilterNode::kColorInput), + EXPECT_EQ(node.get_input_name(olive::StrokeFilterNode::k_color_input), QStringLiteral("Color")); - EXPECT_EQ(node.GetInputName(olive::StrokeFilterNode::kRadiusInput), + EXPECT_EQ(node.get_input_name(olive::StrokeFilterNode::k_radius_input), QStringLiteral("Radius")); - EXPECT_EQ(node.GetInputName(olive::StrokeFilterNode::kOpacityInput), + EXPECT_EQ(node.get_input_name(olive::StrokeFilterNode::k_opacity_input), QStringLiteral("Opacity")); - EXPECT_EQ(node.GetInputName(olive::StrokeFilterNode::kInnerInput), + EXPECT_EQ(node.get_input_name(olive::StrokeFilterNode::k_inner_input), QStringLiteral("Inner")); } @@ -972,7 +972,7 @@ TEST(StrokeFilterNode, ShaderCodeLoadsFragmentResource) olive::StrokeFilterNode node; const olive::ShaderCode code = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("test"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("test"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.vert_code().isEmpty()); @@ -983,35 +983,35 @@ TEST(StrokeFilterNode, ValueWithoutTexturePushesNothing) olive::StrokeFilterNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(StrokeFilterNode, ValueWithRadiusAndOpacityPushesJob) { olive::StrokeFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::StrokeFilterNode::kTextureInput, tex); - row.insert(olive::StrokeFilterNode::kRadiusInput, FloatValue(10.0)); - row.insert(olive::StrokeFilterNode::kOpacityInput, FloatValue(1.0)); + make_texture_row(olive::StrokeFilterNode::k_texture_input, tex); + row.insert(olive::StrokeFilterNode::k_radius_input, float_value(10.0)); + row.insert(olive::StrokeFilterNode::k_opacity_input, float_value(1.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); - EXPECT_EQ(job->GetValues() + EXPECT_EQ(job->get_values() .value(QStringLiteral("resolution_in")) - .toVec2(), + .to_vec2(), QVector2D(16.0f, 16.0f)); } @@ -1019,42 +1019,42 @@ TEST(StrokeFilterNode, ValueWithZeroRadiusPassesTextureThrough) { olive::StrokeFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::StrokeFilterNode::kTextureInput, tex); - row.insert(olive::StrokeFilterNode::kRadiusInput, FloatValue(0.0)); - row.insert(olive::StrokeFilterNode::kOpacityInput, FloatValue(1.0)); + make_texture_row(olive::StrokeFilterNode::k_texture_input, tex); + row.insert(olive::StrokeFilterNode::k_radius_input, float_value(0.0)); + row.insert(olive::StrokeFilterNode::k_opacity_input, float_value(1.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } TEST(StrokeFilterNode, ValueWithZeroOpacityPassesTextureThrough) { olive::StrokeFilterNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::StrokeFilterNode::kTextureInput, tex); - row.insert(olive::StrokeFilterNode::kRadiusInput, FloatValue(10.0)); - row.insert(olive::StrokeFilterNode::kOpacityInput, FloatValue(0.0)); + make_texture_row(olive::StrokeFilterNode::k_texture_input, tex); + row.insert(olive::StrokeFilterNode::k_radius_input, float_value(10.0)); + row.insert(olive::StrokeFilterNode::k_opacity_input, float_value(0.0)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); EXPECT_EQ(out, tex); - EXPECT_FALSE(out->IsJob()); + EXPECT_FALSE(out->is_job()); } // ----------------------------------------------------------------------------- @@ -1066,12 +1066,12 @@ TEST(ChromaKeyNode, InputDefinitionsAndDefaults) olive::ChromaKeyNode node; // The texture input comes from OCIOBaseNode and is the effect input. - EXPECT_TRUE(node.HasInputWithID(olive::OCIOBaseNode::kTextureInput)); - EXPECT_EQ(node.GetEffectInputID(), olive::OCIOBaseNode::kTextureInput); + EXPECT_TRUE(node.has_input_with_id(olive::OCIOBaseNode::k_texture_input)); + EXPECT_EQ(node.get_effect_input_id(), olive::OCIOBaseNode::k_texture_input); // The default key color is pure green. const olive::core::Color color = - node.GetStandardValue(olive::ChromaKeyNode::kColorInput) + node.get_standard_value(olive::ChromaKeyNode::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 0.0f); EXPECT_FLOAT_EQ(color.green(), 1.0f); @@ -1079,51 +1079,51 @@ TEST(ChromaKeyNode, InputDefinitionsAndDefaults) EXPECT_FLOAT_EQ(color.alpha(), 1.0f); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ChromaKeyNode::kLowerToleranceInput) + node.get_standard_value(olive::ChromaKeyNode::k_lower_tolerance_input) .toDouble(), 5.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ChromaKeyNode::kLowerToleranceInput, + node.get_input_property(olive::ChromaKeyNode::k_lower_tolerance_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ChromaKeyNode::kLowerToleranceInput, + node.get_input_property(olive::ChromaKeyNode::k_lower_tolerance_input, QStringLiteral("base")) .toDouble(), 0.1); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ChromaKeyNode::kUpperToleranceInput) + node.get_standard_value(olive::ChromaKeyNode::k_upper_tolerance_input) .toDouble(), 25.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ChromaKeyNode::kUpperToleranceInput, + node.get_input_property(olive::ChromaKeyNode::k_upper_tolerance_input, QStringLiteral("base")) .toDouble(), 0.1); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ChromaKeyNode::kHighlightsInput) + node.get_standard_value(olive::ChromaKeyNode::k_highlights_input) .toDouble(), 100.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ChromaKeyNode::kShadowsInput).toDouble(), + node.get_standard_value(olive::ChromaKeyNode::k_shadows_input).toDouble(), 100.0); - EXPECT_EQ(int(node.GetInputDataType( - olive::ChromaKeyNode::kGarbageMatteInput)), - int(olive::NodeValue::kTexture)); + EXPECT_EQ(int(node.get_input_data_type( + olive::ChromaKeyNode::k_garbage_matte_input)), + int(olive::NodeValue::k_texture)); EXPECT_FALSE( - node.IsInputKeyframable(olive::ChromaKeyNode::kGarbageMatteInput)); + node.is_input_keyframable(olive::ChromaKeyNode::k_garbage_matte_input)); EXPECT_EQ( - int(node.GetInputDataType(olive::ChromaKeyNode::kCoreMatteInput)), - int(olive::NodeValue::kTexture)); + int(node.get_input_data_type(olive::ChromaKeyNode::k_core_matte_input)), + int(olive::NodeValue::k_texture)); EXPECT_FALSE( - node.IsInputKeyframable(olive::ChromaKeyNode::kCoreMatteInput)); + node.is_input_keyframable(olive::ChromaKeyNode::k_core_matte_input)); EXPECT_FALSE( - node.GetStandardValue(olive::ChromaKeyNode::kInvertInput).toBool()); + node.get_standard_value(olive::ChromaKeyNode::k_invert_input).toBool()); EXPECT_FALSE( - node.GetStandardValue(olive::ChromaKeyNode::kMaskOnlyInput).toBool()); + node.get_standard_value(olive::ChromaKeyNode::k_mask_only_input).toBool()); } TEST(ChromaKeyNode, Identity) @@ -1132,37 +1132,37 @@ TEST(ChromaKeyNode, Identity) EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.chromakey")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryKeying)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_keying)); } TEST(ChromaKeyNode, RetranslateSetsInputNames) { olive::ChromaKeyNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::OCIOBaseNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::OCIOBaseNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kGarbageMatteInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_garbage_matte_input), QStringLiteral("Garbage Matte")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kCoreMatteInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_core_matte_input), QStringLiteral("Core Matte")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kColorInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_color_input), QStringLiteral("Key Color")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kShadowsInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_shadows_input), QStringLiteral("Shadows")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kHighlightsInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_highlights_input), QStringLiteral("Highlights")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kUpperToleranceInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_upper_tolerance_input), QStringLiteral("Upper Tolerance")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kLowerToleranceInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_lower_tolerance_input), QStringLiteral("Lower Tolerance")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kInvertInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_invert_input), QStringLiteral("Invert Mask")); - EXPECT_EQ(node.GetInputName(olive::ChromaKeyNode::kMaskOnlyInput), + EXPECT_EQ(node.get_input_name(olive::ChromaKeyNode::k_mask_only_input), QStringLiteral("Show Mask Only")); } @@ -1172,13 +1172,13 @@ TEST(ChromaKeyNode, ShaderCodeSubstitutesStub) // The fragment shader contains a %1 placeholder for OCIO-generated code, // which GetShaderCode fills with the request's stub. - const olive::ShaderCode with_stub = node.GetShaderCode( + const olive::ShaderCode with_stub = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("test"), QStringLiteral("OAK_TEST_STUB"))); EXPECT_TRUE(with_stub.frag_code().contains(QStringLiteral("OAK_TEST_STUB"))); const olive::ShaderCode no_stub = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("test"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("test"))); EXPECT_FALSE(no_stub.frag_code().isEmpty()); EXPECT_FALSE(no_stub.frag_code().contains(QStringLiteral("%1"))); } @@ -1189,48 +1189,48 @@ TEST(ChromaKeyNode, ValueWithoutProcessorPushesNothing) // generated and Value() must push nothing even with a valid texture. olive::ChromaKeyNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OCIOBaseNode::kTextureInput, tex); + make_texture_row(olive::OCIOBaseNode::k_texture_input, tex); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(ChromaKeyNode, ValueInProjectPushesColorTransformJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::ChromaKeyNode(); node->setParent(&project); - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::OCIOBaseNode::kTextureInput, tex); + make_texture_row(olive::OCIOBaseNode::k_texture_input, tex); olive::NodeValueTable table; - node->Value(row, olive::NodeGlobals(), &table); + node->value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // Adding the node to the project generates its XYZ processor. - EXPECT_NE(job->GetColorProcessor(), nullptr); - EXPECT_EQ(job->GetFunctionName(), + EXPECT_NE(job->get_color_processor(), nullptr); + EXPECT_EQ(job->get_function_name(), QStringLiteral("SceneLinearToCIEXYZ_d65")); - EXPECT_EQ(job->CustomShaderSource(), node); - EXPECT_EQ(job->GetInputTexture().toTexture(), tex); + EXPECT_EQ(job->custom_shader_source(), node); + EXPECT_EQ(job->get_input_texture().to_texture(), tex); } // ----------------------------------------------------------------------------- @@ -1241,60 +1241,60 @@ TEST(ColorDifferenceKeyNode, InputDefinitionsAndDefaults) { olive::ColorDifferenceKeyNode node; - EXPECT_EQ(int(node.GetInputDataType( - olive::ColorDifferenceKeyNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable( - olive::ColorDifferenceKeyNode::kTextureInput)); - EXPECT_EQ(node.GetEffectInputID(), - olive::ColorDifferenceKeyNode::kTextureInput); + EXPECT_EQ(int(node.get_input_data_type( + olive::ColorDifferenceKeyNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable( + olive::ColorDifferenceKeyNode::k_texture_input)); + EXPECT_EQ(node.get_effect_input_id(), + olive::ColorDifferenceKeyNode::k_texture_input); - EXPECT_EQ(int(node.GetInputDataType( - olive::ColorDifferenceKeyNode::kGarbageMatteInput)), - int(olive::NodeValue::kTexture)); - EXPECT_EQ(int(node.GetInputDataType( - olive::ColorDifferenceKeyNode::kCoreMatteInput)), - int(olive::NodeValue::kTexture)); + EXPECT_EQ(int(node.get_input_data_type( + olive::ColorDifferenceKeyNode::k_garbage_matte_input)), + int(olive::NodeValue::k_texture)); + EXPECT_EQ(int(node.get_input_data_type( + olive::ColorDifferenceKeyNode::k_core_matte_input)), + int(olive::NodeValue::k_texture)); // Key color is a static combo defaulting to the first entry (green). - EXPECT_EQ(int(node.GetInputDataType( - olive::ColorDifferenceKeyNode::kColorInput)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(node.GetStandardValue(olive::ColorDifferenceKeyNode::kColorInput) + EXPECT_EQ(int(node.get_input_data_type( + olive::ColorDifferenceKeyNode::k_color_input)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(node.get_standard_value(olive::ColorDifferenceKeyNode::k_color_input) .toInt(), 0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ColorDifferenceKeyNode::kHighlightsInput) + node.get_standard_value(olive::ColorDifferenceKeyNode::k_highlights_input) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ColorDifferenceKeyNode::kHighlightsInput, + node.get_input_property(olive::ColorDifferenceKeyNode::k_highlights_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ColorDifferenceKeyNode::kHighlightsInput, + node.get_input_property(olive::ColorDifferenceKeyNode::k_highlights_input, QStringLiteral("base")) .toDouble(), 0.01); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::ColorDifferenceKeyNode::kShadowsInput) + node.get_standard_value(olive::ColorDifferenceKeyNode::k_shadows_input) .toDouble(), 1.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ColorDifferenceKeyNode::kShadowsInput, + node.get_input_property(olive::ColorDifferenceKeyNode::k_shadows_input, QStringLiteral("min")) .toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetInputProperty(olive::ColorDifferenceKeyNode::kShadowsInput, + node.get_input_property(olive::ColorDifferenceKeyNode::k_shadows_input, QStringLiteral("base")) .toDouble(), 0.01); - EXPECT_FALSE(node.GetStandardValue( - olive::ColorDifferenceKeyNode::kMaskOnlyInput) + EXPECT_FALSE(node.get_standard_value( + olive::ColorDifferenceKeyNode::k_mask_only_input) .toBool()); } @@ -1304,37 +1304,37 @@ TEST(ColorDifferenceKeyNode, Identity) EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.colordifferencekey")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryKeying)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_keying)); } TEST(ColorDifferenceKeyNode, RetranslateSetsInputNamesAndComboStrings) { olive::ColorDifferenceKeyNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::ColorDifferenceKeyNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::ColorDifferenceKeyNode::k_texture_input), QStringLiteral("Input")); EXPECT_EQ( - node.GetInputName(olive::ColorDifferenceKeyNode::kGarbageMatteInput), + node.get_input_name(olive::ColorDifferenceKeyNode::k_garbage_matte_input), QStringLiteral("Garbage Matte")); - EXPECT_EQ(node.GetInputName(olive::ColorDifferenceKeyNode::kCoreMatteInput), + EXPECT_EQ(node.get_input_name(olive::ColorDifferenceKeyNode::k_core_matte_input), QStringLiteral("Core Matte")); - EXPECT_EQ(node.GetInputName(olive::ColorDifferenceKeyNode::kColorInput), + EXPECT_EQ(node.get_input_name(olive::ColorDifferenceKeyNode::k_color_input), QStringLiteral("Key Color")); - EXPECT_EQ(node.GetComboBoxStrings( - olive::ColorDifferenceKeyNode::kColorInput), + EXPECT_EQ(node.get_combo_box_strings( + olive::ColorDifferenceKeyNode::k_color_input), QStringList( { QStringLiteral("Green"), QStringLiteral("Blue") })); - EXPECT_EQ(node.GetInputName(olive::ColorDifferenceKeyNode::kShadowsInput), + EXPECT_EQ(node.get_input_name(olive::ColorDifferenceKeyNode::k_shadows_input), QStringLiteral("Shadows")); EXPECT_EQ( - node.GetInputName(olive::ColorDifferenceKeyNode::kHighlightsInput), + node.get_input_name(olive::ColorDifferenceKeyNode::k_highlights_input), QStringLiteral("Highlights")); - EXPECT_EQ(node.GetInputName(olive::ColorDifferenceKeyNode::kMaskOnlyInput), + EXPECT_EQ(node.get_input_name(olive::ColorDifferenceKeyNode::k_mask_only_input), QStringLiteral("Show Mask Only")); } @@ -1343,7 +1343,7 @@ TEST(ColorDifferenceKeyNode, ShaderCodeLoadsFragmentResource) olive::ColorDifferenceKeyNode node; const olive::ShaderCode code = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("test"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("test"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.vert_code().isEmpty()); @@ -1354,42 +1354,42 @@ TEST(ColorDifferenceKeyNode, ValueWithoutTexturePushesNothing) olive::ColorDifferenceKeyNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(ColorDifferenceKeyNode, ValuePushesShaderJobWithRowValues) { olive::ColorDifferenceKeyNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::ColorDifferenceKeyNode::kTextureInput, tex); - row.insert(olive::ColorDifferenceKeyNode::kColorInput, ComboValue(1)); - row.insert(olive::ColorDifferenceKeyNode::kMaskOnlyInput, BoolValue(true)); + make_texture_row(olive::ColorDifferenceKeyNode::k_texture_input, tex); + row.insert(olive::ColorDifferenceKeyNode::k_color_input, combo_value(1)); + row.insert(olive::ColorDifferenceKeyNode::k_mask_only_input, bool_value(true)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // The whole input row is forwarded into the job. - const olive::NodeValueRow &values = job->GetValues(); - EXPECT_EQ(values.value(olive::ColorDifferenceKeyNode::kTextureInput) - .toTexture(), + const olive::NodeValueRow &values = job->get_values(); + EXPECT_EQ(values.value(olive::ColorDifferenceKeyNode::k_texture_input) + .to_texture(), tex); - EXPECT_EQ(values.value(olive::ColorDifferenceKeyNode::kColorInput).toInt(), + EXPECT_EQ(values.value(olive::ColorDifferenceKeyNode::k_color_input).to_int(), 1); - EXPECT_TRUE(values.value(olive::ColorDifferenceKeyNode::kMaskOnlyInput) - .toBool()); + EXPECT_TRUE(values.value(olive::ColorDifferenceKeyNode::k_mask_only_input) + .to_bool()); } // ----------------------------------------------------------------------------- @@ -1400,21 +1400,21 @@ TEST(DespillNode, InputDefinitionsAndDefaults) { olive::DespillNode node; - EXPECT_EQ(int(node.GetInputDataType(olive::DespillNode::kTextureInput)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node.IsInputKeyframable(olive::DespillNode::kTextureInput)); - EXPECT_EQ(node.GetEffectInputID(), olive::DespillNode::kTextureInput); + EXPECT_EQ(int(node.get_input_data_type(olive::DespillNode::k_texture_input)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node.is_input_keyframable(olive::DespillNode::k_texture_input)); + EXPECT_EQ(node.get_effect_input_id(), olive::DespillNode::k_texture_input); - EXPECT_EQ(int(node.GetInputDataType(olive::DespillNode::kColorInput)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(node.GetStandardValue(olive::DespillNode::kColorInput).toInt(), + EXPECT_EQ(int(node.get_input_data_type(olive::DespillNode::k_color_input)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(node.get_standard_value(olive::DespillNode::k_color_input).toInt(), 0); - EXPECT_EQ(int(node.GetInputDataType(olive::DespillNode::kMethodInput)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(node.GetStandardValue(olive::DespillNode::kMethodInput).toInt(), + EXPECT_EQ(int(node.get_input_data_type(olive::DespillNode::k_method_input)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(node.get_standard_value(olive::DespillNode::k_method_input).toInt(), 0); - EXPECT_FALSE(node.GetStandardValue( - olive::DespillNode::kPreserveLuminanceInput) + EXPECT_FALSE(node.get_standard_value( + olive::DespillNode::k_preserve_luminance_input) .toBool()); } @@ -1423,33 +1423,33 @@ TEST(DespillNode, Identity) olive::DespillNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.despill")); - EXPECT_FALSE(node.Name().isEmpty()); - EXPECT_FALSE(node.Description().isEmpty()); + EXPECT_FALSE(node.name().isEmpty()); + EXPECT_FALSE(node.description().isEmpty()); - ASSERT_EQ(node.Category().size(), 1); - EXPECT_EQ(int(node.Category().first()), int(olive::Node::kCategoryKeying)); + ASSERT_EQ(node.category().size(), 1); + EXPECT_EQ(int(node.category().first()), int(olive::Node::k_category_keying)); } TEST(DespillNode, RetranslateSetsInputNamesAndComboStrings) { olive::DespillNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::DespillNode::kTextureInput), + EXPECT_EQ(node.get_input_name(olive::DespillNode::k_texture_input), QStringLiteral("Input")); - EXPECT_EQ(node.GetInputName(olive::DespillNode::kColorInput), + EXPECT_EQ(node.get_input_name(olive::DespillNode::k_color_input), QStringLiteral("Key Color")); - EXPECT_EQ(node.GetComboBoxStrings(olive::DespillNode::kColorInput), + EXPECT_EQ(node.get_combo_box_strings(olive::DespillNode::k_color_input), QStringList( { QStringLiteral("Green"), QStringLiteral("Blue") })); - EXPECT_EQ(node.GetInputName(olive::DespillNode::kMethodInput), + EXPECT_EQ(node.get_input_name(olive::DespillNode::k_method_input), QStringLiteral("Method")); - EXPECT_EQ(node.GetComboBoxStrings(olive::DespillNode::kMethodInput), + EXPECT_EQ(node.get_combo_box_strings(olive::DespillNode::k_method_input), QStringList({ QStringLiteral("Average"), QStringLiteral("Double Red Average"), QStringLiteral("Double Average"), QStringLiteral("Limit") })); - EXPECT_EQ(node.GetInputName(olive::DespillNode::kPreserveLuminanceInput), + EXPECT_EQ(node.get_input_name(olive::DespillNode::k_preserve_luminance_input), QStringLiteral("Preserve Luminance")); } @@ -1458,7 +1458,7 @@ TEST(DespillNode, ShaderCodeLoadsFragmentResource) olive::DespillNode node; const olive::ShaderCode code = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("test"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("test"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.vert_code().isEmpty()); @@ -1466,59 +1466,59 @@ TEST(DespillNode, ShaderCodeLoadsFragmentResource) TEST(DespillNode, ValueInProjectWithoutTexturePushesNothing) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::DespillNode(); node->setParent(&project); olive::NodeValueTable table; - node->Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node->value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(DespillNode, ValueInProjectPushesJobWithLumaCoefficients) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::DespillNode(); node->setParent(&project); - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::DespillNode::kTextureInput, tex); + make_texture_row(olive::DespillNode::k_texture_input, tex); olive::NodeValueTable table; - node->Value(row, olive::NodeGlobals(), &table); + node->value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); // The job carries the color manager's default luma coefficients. double expected[3] = { 0.0, 0.0, 0.0 }; - project.color_manager()->GetDefaultLumaCoefs(expected); + project.color_manager()->get_default_luma_coefs(expected); - const olive::NodeValueRow &values = job->GetValues(); + const olive::NodeValueRow &values = job->get_values(); ASSERT_TRUE(values.contains(QStringLiteral("luma_coeffs"))); const QVector3D coeffs = - values.value(QStringLiteral("luma_coeffs")).toVec3(); + values.value(QStringLiteral("luma_coeffs")).to_vec3(); EXPECT_FLOAT_EQ(coeffs.x(), float(expected[0])); EXPECT_FLOAT_EQ(coeffs.y(), float(expected[1])); EXPECT_FLOAT_EQ(coeffs.z(), float(expected[2])); - EXPECT_EQ(values.value(olive::DespillNode::kTextureInput).toTexture(), + EXPECT_EQ(values.value(olive::DespillNode::k_texture_input).to_texture(), tex); } @@ -1528,26 +1528,26 @@ TEST(DespillNode, ValueWithoutProjectUsesRec709LumaFallback) // Rec. 709 luma coefficients instead of crashing. olive::DespillNode node; - olive::TexturePtr tex = MakeDummyTexture(); + olive::TexturePtr tex = make_dummy_texture(); olive::NodeValueRow row = - MakeTextureRow(olive::DespillNode::kTextureInput, tex); + make_texture_row(olive::DespillNode::k_texture_input, tex); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - ASSERT_EQ(table.Count(), 1); + ASSERT_EQ(table.count(), 1); const olive::TexturePtr out = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = static_cast(out->job()); ASSERT_NE(job, nullptr); - const olive::NodeValueRow &values = job->GetValues(); + const olive::NodeValueRow &values = job->get_values(); ASSERT_TRUE(values.contains(QStringLiteral("luma_coeffs"))); const QVector3D coeffs = - values.value(QStringLiteral("luma_coeffs")).toVec3(); + values.value(QStringLiteral("luma_coeffs")).to_vec3(); EXPECT_NEAR(coeffs.x(), 0.2126f, 0.0001f); EXPECT_NEAR(coeffs.y(), 0.7152f, 0.0001f); EXPECT_NEAR(coeffs.z(), 0.0722f, 0.0001f); diff --git a/tests/gtest/node_generator_test.cpp b/tests/gtest/node_generator_test.cpp index 11644cba8..f3d91ccf9 100644 --- a/tests/gtest/node_generator_test.cpp +++ b/tests/gtest/node_generator_test.cpp @@ -32,7 +32,7 @@ public: NODE_DEFAULT_FUNCTIONS(ConstantTextureNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Test Texture"); } @@ -42,73 +42,73 @@ public: return QStringLiteral("org.oak.test.constant_texture"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryGenerator }; + return { k_category_generator }; } - void SetTexture(const olive::TexturePtr &texture) + void set_texture(const olive::TexturePtr &texture) { texture_ = texture; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { Q_UNUSED(value) Q_UNUSED(globals) - table->Push(olive::NodeValue(olive::NodeValue::kTexture, texture_, this)); + table->push(olive::NodeValue(olive::NodeValue::k_texture, texture_, this)); } private: olive::TexturePtr texture_; }; -template T *AddNode(olive::Project *project) +template T *add_node(olive::Project *project) { T *node = new T(); node->setParent(project); return node; } -olive::TimeRange FirstFrame() +olive::TimeRange first_frame() { - return olive::TimeRange(olive::rational(0), olive::rational(1, 30)); + return olive::TimeRange(olive::Rational(0), olive::Rational(1, 30)); } -olive::VideoParams TestVideoParams() +olive::VideoParams test_video_params() { - return olive::VideoParams(320, 240, olive::core::PixelFormat::U8, 4); + return olive::VideoParams(320, 240, olive::core::PixelFormat::u8, 4); } // A fresh traverser per call: NodeTraverser caches tables per node/range, so // reusing one would return stale results after changing standard values. -olive::NodeValueTable GenerateTable(const olive::Node *node) +olive::NodeValueTable generate_table(const olive::Node *node) { olive::NodeTraverser traverser; - return traverser.GenerateTable(node, FirstFrame()); + return traverser.generate_table(node, first_frame()); } -olive::NodeValueTable GenerateTable(const olive::Node *node, +olive::NodeValueTable generate_table(const olive::Node *node, const olive::VideoParams &vparams, const olive::TimeRange &range) { olive::NodeTraverser traverser; - traverser.SetCacheVideoParams(vparams); - return traverser.GenerateTable(node, range); + traverser.set_cache_video_params(vparams); + return traverser.generate_table(node, range); } -olive::NodeValueTable GenerateTable(const olive::Node *node, +olive::NodeValueTable generate_table(const olive::Node *node, const olive::VideoParams &vparams) { - return GenerateTable(node, vparams, FirstFrame()); + return generate_table(node, vparams, first_frame()); } -olive::TexturePtr GetOutputTexture(const olive::NodeValueTable &table) +olive::TexturePtr get_output_texture(const olive::NodeValueTable &table) { - return table.Get(olive::NodeValue::kTexture).toTexture(); + return table.get(olive::NodeValue::k_texture).to_texture(); } } // namespace @@ -117,150 +117,150 @@ TEST(MatrixGenerator, MetadataIsCorrect) { olive::MatrixGenerator node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.ortho")); - EXPECT_EQ(node.Name(), QStringLiteral("Orthographic Matrix")); - EXPECT_EQ(node.ShortName(), QStringLiteral("Ortho")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryGenerator)); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryMath)); + EXPECT_EQ(node.name(), QStringLiteral("Orthographic Matrix")); + EXPECT_EQ(node.short_name(), QStringLiteral("Ortho")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_generator)); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_math)); } TEST(MatrixGenerator, InputDefaultsAndProperties) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - ASSERT_TRUE(node->HasInputWithID(olive::MatrixGenerator::kPositionInput)); - ASSERT_TRUE(node->HasInputWithID(olive::MatrixGenerator::kRotationInput)); - ASSERT_TRUE(node->HasInputWithID(olive::MatrixGenerator::kScaleInput)); + ASSERT_TRUE(node->has_input_with_id(olive::MatrixGenerator::k_position_input)); + ASSERT_TRUE(node->has_input_with_id(olive::MatrixGenerator::k_rotation_input)); + ASSERT_TRUE(node->has_input_with_id(olive::MatrixGenerator::k_scale_input)); ASSERT_TRUE( - node->HasInputWithID(olive::MatrixGenerator::kUniformScaleInput)); - ASSERT_TRUE(node->HasInputWithID(olive::MatrixGenerator::kAnchorInput)); + node->has_input_with_id(olive::MatrixGenerator::k_uniform_scale_input)); + ASSERT_TRUE(node->has_input_with_id(olive::MatrixGenerator::k_anchor_input)); - EXPECT_EQ(int(node->GetInputDataType(olive::MatrixGenerator::kPositionInput)), - int(olive::NodeValue::kVec2)); - EXPECT_EQ(int(node->GetInputDataType(olive::MatrixGenerator::kRotationInput)), - int(olive::NodeValue::kFloat)); - EXPECT_EQ(int(node->GetInputDataType(olive::MatrixGenerator::kScaleInput)), - int(olive::NodeValue::kVec2)); + EXPECT_EQ(int(node->get_input_data_type(olive::MatrixGenerator::k_position_input)), + int(olive::NodeValue::k_vec2)); + EXPECT_EQ(int(node->get_input_data_type(olive::MatrixGenerator::k_rotation_input)), + int(olive::NodeValue::k_float)); + EXPECT_EQ(int(node->get_input_data_type(olive::MatrixGenerator::k_scale_input)), + int(olive::NodeValue::k_vec2)); EXPECT_EQ( - int(node->GetInputDataType(olive::MatrixGenerator::kUniformScaleInput)), - int(olive::NodeValue::kBoolean)); - EXPECT_EQ(int(node->GetInputDataType(olive::MatrixGenerator::kAnchorInput)), - int(olive::NodeValue::kVec2)); + int(node->get_input_data_type(olive::MatrixGenerator::k_uniform_scale_input)), + int(olive::NodeValue::k_boolean)); + EXPECT_EQ(int(node->get_input_data_type(olive::MatrixGenerator::k_anchor_input)), + int(olive::NodeValue::k_vec2)); - EXPECT_EQ(node->GetStandardValue(olive::MatrixGenerator::kPositionInput) + EXPECT_EQ(node->get_standard_value(olive::MatrixGenerator::k_position_input) .value(), QVector2D(0.0f, 0.0f)); - EXPECT_EQ(node->GetStandardValue(olive::MatrixGenerator::kRotationInput) + EXPECT_EQ(node->get_standard_value(olive::MatrixGenerator::k_rotation_input) .toDouble(), 0.0); EXPECT_EQ( - node->GetStandardValue(olive::MatrixGenerator::kScaleInput).value(), + node->get_standard_value(olive::MatrixGenerator::k_scale_input).value(), QVector2D(1.0f, 1.0f)); - EXPECT_TRUE(node->GetStandardValue(olive::MatrixGenerator::kUniformScaleInput) + EXPECT_TRUE(node->get_standard_value(olive::MatrixGenerator::k_uniform_scale_input) .toBool()); - EXPECT_EQ(node->GetStandardValue(olive::MatrixGenerator::kAnchorInput) + EXPECT_EQ(node->get_standard_value(olive::MatrixGenerator::k_anchor_input) .value(), QVector2D(0.0f, 0.0f)); // Scale slider is percentage-based, floored at zero, and starts with its // second track disabled because uniform scale defaults to on - EXPECT_EQ(node->GetInputProperty(olive::MatrixGenerator::kScaleInput, + EXPECT_EQ(node->get_input_property(olive::MatrixGenerator::k_scale_input, QStringLiteral("view")) .toInt(), - int(olive::FloatSlider::kPercentage)); - EXPECT_EQ(node->GetInputProperty(olive::MatrixGenerator::kScaleInput, + int(olive::FloatSlider::k_percentage)); + EXPECT_EQ(node->get_input_property(olive::MatrixGenerator::k_scale_input, QStringLiteral("min")) .value(), QVector2D(0.0f, 0.0f)); - EXPECT_TRUE(node->GetInputProperty(olive::MatrixGenerator::kScaleInput, + EXPECT_TRUE(node->get_input_property(olive::MatrixGenerator::k_scale_input, QStringLiteral("disable1")) .toBool()); // Uniform scale is a UI toggle, not a renderable parameter - EXPECT_FALSE(node->IsInputConnectable( - olive::MatrixGenerator::kUniformScaleInput)); - EXPECT_FALSE(node->IsInputKeyframable( - olive::MatrixGenerator::kUniformScaleInput)); + EXPECT_FALSE(node->is_input_connectable( + olive::MatrixGenerator::k_uniform_scale_input)); + EXPECT_FALSE(node->is_input_keyframable( + olive::MatrixGenerator::k_uniform_scale_input)); EXPECT_TRUE( - node->IsInputConnectable(olive::MatrixGenerator::kPositionInput)); + node->is_input_connectable(olive::MatrixGenerator::k_position_input)); EXPECT_TRUE( - node->IsInputKeyframable(olive::MatrixGenerator::kPositionInput)); + node->is_input_keyframable(olive::MatrixGenerator::k_position_input)); } TEST(MatrixGenerator, RetranslateSetsInputNames) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->Retranslate(); + auto *node = add_node(&project); + node->retranslate(); - EXPECT_EQ(node->GetInputName(olive::MatrixGenerator::kPositionInput), + EXPECT_EQ(node->get_input_name(olive::MatrixGenerator::k_position_input), QStringLiteral("Position")); - EXPECT_EQ(node->GetInputName(olive::MatrixGenerator::kRotationInput), + EXPECT_EQ(node->get_input_name(olive::MatrixGenerator::k_rotation_input), QStringLiteral("Rotation")); - EXPECT_EQ(node->GetInputName(olive::MatrixGenerator::kScaleInput), + EXPECT_EQ(node->get_input_name(olive::MatrixGenerator::k_scale_input), QStringLiteral("Scale")); - EXPECT_EQ(node->GetInputName(olive::MatrixGenerator::kUniformScaleInput), + EXPECT_EQ(node->get_input_name(olive::MatrixGenerator::k_uniform_scale_input), QStringLiteral("Uniform Scale")); - EXPECT_EQ(node->GetInputName(olive::MatrixGenerator::kAnchorInput), + EXPECT_EQ(node->get_input_name(olive::MatrixGenerator::k_anchor_input), QStringLiteral("Anchor Point")); } TEST(MatrixGenerator, UniformScaleTogglesScaleSecondTrack) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - EXPECT_TRUE(node->GetInputProperty(olive::MatrixGenerator::kScaleInput, + auto *node = add_node(&project); + EXPECT_TRUE(node->get_input_property(olive::MatrixGenerator::k_scale_input, QStringLiteral("disable1")) .toBool()); - node->SetStandardValue(olive::MatrixGenerator::kUniformScaleInput, false); - EXPECT_FALSE(node->GetInputProperty(olive::MatrixGenerator::kScaleInput, + node->set_standard_value(olive::MatrixGenerator::k_uniform_scale_input, false); + EXPECT_FALSE(node->get_input_property(olive::MatrixGenerator::k_scale_input, QStringLiteral("disable1")) .toBool()); - node->SetStandardValue(olive::MatrixGenerator::kUniformScaleInput, true); - EXPECT_TRUE(node->GetInputProperty(olive::MatrixGenerator::kScaleInput, + node->set_standard_value(olive::MatrixGenerator::k_uniform_scale_input, true); + EXPECT_TRUE(node->get_input_property(olive::MatrixGenerator::k_scale_input, QStringLiteral("disable1")) .toBool()); } TEST(MatrixGenerator, DefaultValueIsIdentityMatrix) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - olive::NodeValueTable table = GenerateTable(node); - olive::NodeValue value = table.Get(olive::NodeValue::kMatrix); - ASSERT_EQ(int(value.type()), int(olive::NodeValue::kMatrix)); - EXPECT_TRUE(value.toMatrix().isIdentity()); + olive::NodeValueTable table = generate_table(node); + olive::NodeValue value = table.get(olive::NodeValue::k_matrix); + ASSERT_EQ(int(value.type()), int(olive::NodeValue::k_matrix)); + EXPECT_TRUE(value.to_matrix().isIdentity()); } TEST(MatrixGenerator, PositionTranslatesMatrix) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::MatrixGenerator::kPositionInput, + auto *node = add_node(&project); + node->set_standard_value(olive::MatrixGenerator::k_position_input, QVector2D(100.0f, 50.0f)); - olive::NodeValueTable table = GenerateTable(node); + olive::NodeValueTable table = generate_table(node); const QVector3D mapped = - table.Get(olive::NodeValue::kMatrix).toMatrix().map(QVector3D(0, 0, 0)); + table.get(olive::NodeValue::k_matrix).to_matrix().map(QVector3D(0, 0, 0)); EXPECT_FLOAT_EQ(mapped.x(), 100.0f); EXPECT_FLOAT_EQ(mapped.y(), 50.0f); EXPECT_FLOAT_EQ(mapped.z(), 0.0f); @@ -268,16 +268,16 @@ TEST(MatrixGenerator, PositionTranslatesMatrix) TEST(MatrixGenerator, RotationAppliesAroundZAxis) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::MatrixGenerator::kRotationInput, 90.0); + auto *node = add_node(&project); + node->set_standard_value(olive::MatrixGenerator::k_rotation_input, 90.0); - olive::NodeValueTable table = GenerateTable(node); + olive::NodeValueTable table = generate_table(node); const QVector3D mapped = - table.Get(olive::NodeValue::kMatrix).toMatrix().map(QVector3D(1, 0, 0)); + table.get(olive::NodeValue::k_matrix).to_matrix().map(QVector3D(1, 0, 0)); EXPECT_NEAR(mapped.x(), 0.0f, 1e-5f); EXPECT_NEAR(mapped.y(), 1.0f, 1e-5f); EXPECT_NEAR(mapped.z(), 0.0f, 1e-5f); @@ -285,63 +285,63 @@ TEST(MatrixGenerator, RotationAppliesAroundZAxis) TEST(MatrixGenerator, PositionAppliesBeforeRotation) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::MatrixGenerator::kPositionInput, + auto *node = add_node(&project); + node->set_standard_value(olive::MatrixGenerator::k_position_input, QVector2D(10.0f, 0.0f)); - node->SetStandardValue(olive::MatrixGenerator::kRotationInput, 90.0); + node->set_standard_value(olive::MatrixGenerator::k_rotation_input, 90.0); // The transform chain is translate * rotate, so (1,0) is first rotated to // (0,1) and then shifted by the position - olive::NodeValueTable table = GenerateTable(node); + olive::NodeValueTable table = generate_table(node); const QVector3D mapped = - table.Get(olive::NodeValue::kMatrix).toMatrix().map(QVector3D(1, 0, 0)); + table.get(olive::NodeValue::k_matrix).to_matrix().map(QVector3D(1, 0, 0)); EXPECT_NEAR(mapped.x(), 10.0f, 1e-5f); EXPECT_NEAR(mapped.y(), 1.0f, 1e-5f); } TEST(MatrixGenerator, UniformScaleUsesXForBothAxes) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::MatrixGenerator::kScaleInput, + auto *node = add_node(&project); + node->set_standard_value(olive::MatrixGenerator::k_scale_input, QVector2D(2.0f, 3.0f)); // Uniform scale on: the X component drives both axes - node->SetStandardValue(olive::MatrixGenerator::kUniformScaleInput, true); - olive::NodeValueTable table = GenerateTable(node); + node->set_standard_value(olive::MatrixGenerator::k_uniform_scale_input, true); + olive::NodeValueTable table = generate_table(node); QVector3D mapped = - table.Get(olive::NodeValue::kMatrix).toMatrix().map(QVector3D(1, 1, 0)); + table.get(olive::NodeValue::k_matrix).to_matrix().map(QVector3D(1, 1, 0)); EXPECT_FLOAT_EQ(mapped.x(), 2.0f); EXPECT_FLOAT_EQ(mapped.y(), 2.0f); // Uniform scale off: each axis uses its own component - node->SetStandardValue(olive::MatrixGenerator::kUniformScaleInput, false); - table = GenerateTable(node); + node->set_standard_value(olive::MatrixGenerator::k_uniform_scale_input, false); + table = generate_table(node); mapped = - table.Get(olive::NodeValue::kMatrix).toMatrix().map(QVector3D(1, 1, 0)); + table.get(olive::NodeValue::k_matrix).to_matrix().map(QVector3D(1, 1, 0)); EXPECT_FLOAT_EQ(mapped.x(), 2.0f); EXPECT_FLOAT_EQ(mapped.y(), 3.0f); } TEST(MatrixGenerator, AnchorPointShiftsMatrix) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::MatrixGenerator::kAnchorInput, + auto *node = add_node(&project); + node->set_standard_value(olive::MatrixGenerator::k_anchor_input, QVector2D(10.0f, 20.0f)); - olive::NodeValueTable table = GenerateTable(node); - const QMatrix4x4 mat = table.Get(olive::NodeValue::kMatrix).toMatrix(); + olive::NodeValueTable table = generate_table(node); + const QMatrix4x4 mat = table.get(olive::NodeValue::k_matrix).to_matrix(); // The anchor itself maps back to the origin const QVector3D anchor = mat.map(QVector3D(10.0f, 20.0f, 0.0f)); @@ -358,36 +358,36 @@ TEST(ShapeNode, MetadataIsCorrect) { olive::ShapeNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.shape")); - EXPECT_EQ(node.Name(), QStringLiteral("Shape")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_EQ(node.name(), QStringLiteral("Shape")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_generator)); } TEST(ShapeNode, InputDefaults) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); // From GeneratorWithMerge: base texture is the effect input - EXPECT_EQ(node->GetEffectInputID(), olive::GeneratorWithMerge::kBaseInput); - EXPECT_TRUE(node->GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(int(node->GetInputDataType(olive::GeneratorWithMerge::kBaseInput)), - int(olive::NodeValue::kTexture)); + EXPECT_EQ(node->get_effect_input_id(), olive::GeneratorWithMerge::k_base_input); + EXPECT_TRUE(node->get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(int(node->get_input_data_type(olive::GeneratorWithMerge::k_base_input)), + int(olive::NodeValue::k_texture)); EXPECT_FALSE( - node->IsInputKeyframable(olive::GeneratorWithMerge::kBaseInput)); + node->is_input_keyframable(olive::GeneratorWithMerge::k_base_input)); // From ShapeNodeBase: position, size and color - EXPECT_EQ(node->GetStandardValue(olive::ShapeNodeBase::kPositionInput) + EXPECT_EQ(node->get_standard_value(olive::ShapeNodeBase::k_position_input) .value(), QVector2D(0.0f, 0.0f)); - EXPECT_EQ(node->GetStandardValue(olive::ShapeNodeBase::kSizeInput) + EXPECT_EQ(node->get_standard_value(olive::ShapeNodeBase::k_size_input) .value(), QVector2D(100.0f, 100.0f)); const olive::core::Color color = - node->GetStandardValue(olive::ShapeNodeBase::kColorInput) + node->get_standard_value(olive::ShapeNodeBase::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_FLOAT_EQ(color.green(), 0.0f); @@ -395,13 +395,13 @@ TEST(ShapeNode, InputDefaults) EXPECT_FLOAT_EQ(color.alpha(), 1.0f); // Shape-specific: type combo defaults to rectangle, radius to 20 - EXPECT_EQ(int(node->GetInputDataType(olive::ShapeNode::kTypeInput)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(node->GetStandardValue(olive::ShapeNode::kTypeInput).toInt(), - int(olive::ShapeNode::kRectangle)); - EXPECT_EQ(node->GetStandardValue(olive::ShapeNode::kRadiusInput).toDouble(), + EXPECT_EQ(int(node->get_input_data_type(olive::ShapeNode::k_type_input)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(node->get_standard_value(olive::ShapeNode::k_type_input).toInt(), + int(olive::ShapeNode::k_rectangle)); + EXPECT_EQ(node->get_standard_value(olive::ShapeNode::k_radius_input).toDouble(), 20.0); - EXPECT_EQ(node->GetInputProperty(olive::ShapeNode::kRadiusInput, + EXPECT_EQ(node->get_input_property(olive::ShapeNode::k_radius_input, QStringLiteral("min")) .toDouble(), 0.0); @@ -409,75 +409,75 @@ TEST(ShapeNode, InputDefaults) TEST(ShapeNode, RetranslateSetsNamesAndComboStrings) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->Retranslate(); + auto *node = add_node(&project); + node->retranslate(); - EXPECT_EQ(node->GetInputName(olive::ShapeNode::kTypeInput), + EXPECT_EQ(node->get_input_name(olive::ShapeNode::k_type_input), QStringLiteral("Type")); - EXPECT_EQ(node->GetInputName(olive::ShapeNode::kRadiusInput), + EXPECT_EQ(node->get_input_name(olive::ShapeNode::k_radius_input), QStringLiteral("Radius")); - EXPECT_EQ(node->GetInputName(olive::ShapeNodeBase::kPositionInput), + EXPECT_EQ(node->get_input_name(olive::ShapeNodeBase::k_position_input), QStringLiteral("Position")); - EXPECT_EQ(node->GetInputName(olive::ShapeNodeBase::kSizeInput), + EXPECT_EQ(node->get_input_name(olive::ShapeNodeBase::k_size_input), QStringLiteral("Size")); - EXPECT_EQ(node->GetInputName(olive::ShapeNodeBase::kColorInput), + EXPECT_EQ(node->get_input_name(olive::ShapeNodeBase::k_color_input), QStringLiteral("Color")); - EXPECT_EQ(node->GetInputName(olive::GeneratorWithMerge::kBaseInput), + EXPECT_EQ(node->get_input_name(olive::GeneratorWithMerge::k_base_input), QStringLiteral("Base")); const QStringList types = - node->GetComboBoxStrings(olive::ShapeNode::kTypeInput); + node->get_combo_box_strings(olive::ShapeNode::k_type_input); ASSERT_EQ(types.size(), 3); - EXPECT_EQ(types.at(int(olive::ShapeNode::kRectangle)), + EXPECT_EQ(types.at(int(olive::ShapeNode::k_rectangle)), QStringLiteral("Rectangle")); - EXPECT_EQ(types.at(int(olive::ShapeNode::kEllipse)), + EXPECT_EQ(types.at(int(olive::ShapeNode::k_ellipse)), QStringLiteral("Ellipse")); - EXPECT_EQ(types.at(int(olive::ShapeNode::kRoundedRectangle)), + EXPECT_EQ(types.at(int(olive::ShapeNode::k_rounded_rectangle)), QStringLiteral("Rounded Rectangle")); } TEST(ShapeNode, RadiusHiddenUnlessRoundedRectangle) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - node->SetStandardValue(olive::ShapeNode::kTypeInput, - int(olive::ShapeNode::kRoundedRectangle)); - EXPECT_FALSE(node->IsInputHidden(olive::ShapeNode::kRadiusInput)); + node->set_standard_value(olive::ShapeNode::k_type_input, + int(olive::ShapeNode::k_rounded_rectangle)); + EXPECT_FALSE(node->is_input_hidden(olive::ShapeNode::k_radius_input)); - node->SetStandardValue(olive::ShapeNode::kTypeInput, - int(olive::ShapeNode::kEllipse)); - EXPECT_TRUE(node->IsInputHidden(olive::ShapeNode::kRadiusInput)); + node->set_standard_value(olive::ShapeNode::k_type_input, + int(olive::ShapeNode::k_ellipse)); + EXPECT_TRUE(node->is_input_hidden(olive::ShapeNode::k_radius_input)); - node->SetStandardValue(olive::ShapeNode::kTypeInput, - int(olive::ShapeNode::kRectangle)); - EXPECT_TRUE(node->IsInputHidden(olive::ShapeNode::kRadiusInput)); + node->set_standard_value(olive::ShapeNode::k_type_input, + int(olive::ShapeNode::k_rectangle)); + EXPECT_TRUE(node->is_input_hidden(olive::ShapeNode::k_radius_input)); } TEST(ShapeNode, ShaderCodeLoadsShapeAndMergeShaders) { olive::ShapeNode node; - const olive::ShaderCode shape = node.GetShaderCode( + const olive::ShaderCode shape = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("shape"))); EXPECT_FALSE(shape.frag_code().isEmpty()); EXPECT_TRUE(shape.frag_code().contains(QStringLiteral("type_in"))); // The merge shader comes from GeneratorWithMerge - const olive::ShaderCode merge = node.GetShaderCode( + const olive::ShaderCode merge = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("mrg"))); EXPECT_FALSE(merge.frag_code().isEmpty()); EXPECT_TRUE(merge.frag_code().contains(QStringLiteral("blend_in"))); // Unknown requests produce no code - const olive::ShaderCode unknown = node.GetShaderCode( + const olive::ShaderCode unknown = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("bogus"))); EXPECT_TRUE(unknown.frag_code().isEmpty()); EXPECT_TRUE(unknown.vert_code().isEmpty()); @@ -485,72 +485,72 @@ TEST(ShapeNode, ShaderCodeLoadsShapeAndMergeShaders) TEST(ShapeNode, ValueWithoutBasePushesShapeJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - const olive::VideoParams vparams = TestVideoParams(); - olive::NodeValueTable table = GenerateTable(node, vparams); + const olive::VideoParams vparams = test_video_params(); + olive::NodeValueTable table = generate_table(node, vparams); - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), vparams.width()); EXPECT_EQ(texture->params().height(), vparams.height()); auto *job = dynamic_cast(texture->job()); ASSERT_TRUE(job); - EXPECT_EQ(job->GetShaderID(), QStringLiteral("shape")); - EXPECT_EQ(job->Get(QStringLiteral("resolution_in")).toVec2(), + EXPECT_EQ(job->get_shader_id(), QStringLiteral("shape")); + EXPECT_EQ(job->get(QStringLiteral("resolution_in")).to_vec2(), vparams.square_resolution()); - EXPECT_EQ(job->Get(olive::ShapeNode::kTypeInput).toInt(), - int(olive::ShapeNode::kRectangle)); - EXPECT_EQ(job->Get(olive::ShapeNode::kRadiusInput).toDouble(), 20.0); + EXPECT_EQ(job->get(olive::ShapeNode::k_type_input).to_int(), + int(olive::ShapeNode::k_rectangle)); + EXPECT_EQ(job->get(olive::ShapeNode::k_radius_input).to_double(), 20.0); } TEST(ShapeNode, ValueWithBasePushesMergeJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - auto *constant = AddNode(&project); + auto *node = add_node(&project); + auto *constant = add_node(&project); const olive::TexturePtr base = std::make_shared( - olive::VideoParams(64, 48, olive::core::PixelFormat::U8, 4)); - constant->SetTexture(base); - olive::Node::ConnectEdge(constant, + olive::VideoParams(64, 48, olive::core::PixelFormat::u8, 4)); + constant->set_texture(base); + olive::Node::connect_edge(constant, olive::NodeInput( - node, olive::GeneratorWithMerge::kBaseInput)); + node, olive::GeneratorWithMerge::k_base_input)); - olive::NodeValueTable table = GenerateTable(node, TestVideoParams()); + olive::NodeValueTable table = generate_table(node, test_video_params()); // With a base connected the generator composites onto it via the "mrg" // merge shader - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), base->params().width()); EXPECT_EQ(texture->params().height(), base->params().height()); auto *merge = dynamic_cast(texture->job()); ASSERT_TRUE(merge); - EXPECT_EQ(merge->GetShaderID(), QStringLiteral("mrg")); - EXPECT_EQ(merge->Get(olive::MergeNode::kBaseIn).toTexture(), base); + EXPECT_EQ(merge->get_shader_id(), QStringLiteral("mrg")); + EXPECT_EQ(merge->get(olive::MergeNode::k_base_in).to_texture(), base); // The blend input carries the shape generation job, sized after the base olive::TexturePtr blend = - merge->Get(olive::MergeNode::kBlendIn).toTexture(); + merge->get(olive::MergeNode::k_blend_in).to_texture(); ASSERT_TRUE(blend); - ASSERT_TRUE(blend->IsJob()); + ASSERT_TRUE(blend->is_job()); EXPECT_EQ(blend->params().width(), base->params().width()); auto *shape_job = dynamic_cast(blend->job()); ASSERT_TRUE(shape_job); - EXPECT_EQ(shape_job->GetShaderID(), QStringLiteral("shape")); - EXPECT_EQ(shape_job->Get(QStringLiteral("resolution_in")).toVec2(), + EXPECT_EQ(shape_job->get_shader_id(), QStringLiteral("shape")); + EXPECT_EQ(shape_job->get(QStringLiteral("resolution_in")).to_vec2(), base->virtual_resolution()); } @@ -559,23 +559,23 @@ TEST(SolidGenerator, MetadataIsCorrect) olive::SolidGenerator node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.solidgenerator")); - EXPECT_EQ(node.Name(), QStringLiteral("Solid")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_EQ(node.name(), QStringLiteral("Solid")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_generator)); } TEST(SolidGenerator, DefaultColorIsRed) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - EXPECT_EQ(int(node->GetInputDataType(olive::SolidGenerator::kColorInput)), - int(olive::NodeValue::kColor)); + auto *node = add_node(&project); + EXPECT_EQ(int(node->get_input_data_type(olive::SolidGenerator::k_color_input)), + int(olive::NodeValue::k_color)); const olive::core::Color color = - node->GetStandardValue(olive::SolidGenerator::kColorInput) + node->get_standard_value(olive::SolidGenerator::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_FLOAT_EQ(color.green(), 0.0f); @@ -585,14 +585,14 @@ TEST(SolidGenerator, DefaultColorIsRed) TEST(SolidGenerator, RetranslateSetsInputName) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->Retranslate(); + auto *node = add_node(&project); + node->retranslate(); - EXPECT_EQ(node->GetInputName(olive::SolidGenerator::kColorInput), + EXPECT_EQ(node->get_input_name(olive::SolidGenerator::k_color_input), QStringLiteral("Color")); } @@ -601,7 +601,7 @@ TEST(SolidGenerator, ShaderCodeContainsColorUniform) olive::SolidGenerator node; // The request is ignored, the solid shader is always returned - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("color_in"))); @@ -609,30 +609,30 @@ TEST(SolidGenerator, ShaderCodeContainsColorUniform) TEST(SolidGenerator, ValuePushesShaderJobWithColor) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue( - olive::SolidGenerator::kColorInput, + auto *node = add_node(&project); + node->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::core::Color(0.25f, 0.5f, 0.75f, 1.0f))); - const olive::VideoParams vparams = TestVideoParams(); - olive::NodeValueTable table = GenerateTable(node, vparams); + const olive::VideoParams vparams = test_video_params(); + olive::NodeValueTable table = generate_table(node, vparams); - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), vparams.width()); EXPECT_EQ(texture->params().height(), vparams.height()); EXPECT_EQ(int(texture->params().format()), - int(olive::core::PixelFormat::U8)); + int(olive::core::PixelFormat::u8)); auto *job = dynamic_cast(texture->job()); ASSERT_TRUE(job); const olive::core::Color color = - job->Get(olive::SolidGenerator::kColorInput).toColor(); + job->get(olive::SolidGenerator::k_color_input).to_color(); EXPECT_FLOAT_EQ(color.red(), 0.25f); EXPECT_FLOAT_EQ(color.green(), 0.5f); EXPECT_FLOAT_EQ(color.blue(), 0.75f); @@ -643,61 +643,61 @@ TEST(NoiseGenerator, MetadataAndEffectFlags) { olive::NoiseGeneratorNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.noise")); - EXPECT_EQ(node.Name(), QStringLiteral("Noise")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_EQ(node.name(), QStringLiteral("Noise")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_generator)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kVideoEffect); - EXPECT_EQ(node.GetEffectInputID(), olive::NoiseGeneratorNode::kBaseIn); + EXPECT_TRUE(node.get_flags() & olive::Node::k_video_effect); + EXPECT_EQ(node.get_effect_input_id(), olive::NoiseGeneratorNode::k_base_in); } TEST(NoiseGenerator, InputDefaults) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - EXPECT_EQ(int(node->GetInputDataType(olive::NoiseGeneratorNode::kBaseIn)), - int(olive::NodeValue::kTexture)); - EXPECT_FALSE(node->IsInputKeyframable(olive::NoiseGeneratorNode::kBaseIn)); + EXPECT_EQ(int(node->get_input_data_type(olive::NoiseGeneratorNode::k_base_in)), + int(olive::NodeValue::k_texture)); + EXPECT_FALSE(node->is_input_keyframable(olive::NoiseGeneratorNode::k_base_in)); EXPECT_EQ( - int(node->GetInputDataType(olive::NoiseGeneratorNode::kStrengthInput)), - int(olive::NodeValue::kFloat)); - EXPECT_EQ(node->GetStandardValue(olive::NoiseGeneratorNode::kStrengthInput) + int(node->get_input_data_type(olive::NoiseGeneratorNode::k_strength_input)), + int(olive::NodeValue::k_float)); + EXPECT_EQ(node->get_standard_value(olive::NoiseGeneratorNode::k_strength_input) .toDouble(), 0.2); - EXPECT_EQ(node->GetInputProperty(olive::NoiseGeneratorNode::kStrengthInput, + EXPECT_EQ(node->get_input_property(olive::NoiseGeneratorNode::k_strength_input, QStringLiteral("min")) .toInt(), 0); - EXPECT_EQ(node->GetInputProperty(olive::NoiseGeneratorNode::kStrengthInput, + EXPECT_EQ(node->get_input_property(olive::NoiseGeneratorNode::k_strength_input, QStringLiteral("view")) .toInt(), - int(olive::FloatSlider::kPercentage)); + int(olive::FloatSlider::k_percentage)); - EXPECT_EQ(int(node->GetInputDataType(olive::NoiseGeneratorNode::kColorInput)), - int(olive::NodeValue::kBoolean)); - EXPECT_FALSE(node->GetStandardValue(olive::NoiseGeneratorNode::kColorInput) + EXPECT_EQ(int(node->get_input_data_type(olive::NoiseGeneratorNode::k_color_input)), + int(olive::NodeValue::k_boolean)); + EXPECT_FALSE(node->get_standard_value(olive::NoiseGeneratorNode::k_color_input) .toBool()); } TEST(NoiseGenerator, RetranslateSetsInputNames) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->Retranslate(); + auto *node = add_node(&project); + node->retranslate(); - EXPECT_EQ(node->GetInputName(olive::NoiseGeneratorNode::kBaseIn), + EXPECT_EQ(node->get_input_name(olive::NoiseGeneratorNode::k_base_in), QStringLiteral("Base")); - EXPECT_EQ(node->GetInputName(olive::NoiseGeneratorNode::kStrengthInput), + EXPECT_EQ(node->get_input_name(olive::NoiseGeneratorNode::k_strength_input), QStringLiteral("Strength")); - EXPECT_EQ(node->GetInputName(olive::NoiseGeneratorNode::kColorInput), + EXPECT_EQ(node->get_input_name(olive::NoiseGeneratorNode::k_color_input), QStringLiteral("Color")); } @@ -705,7 +705,7 @@ TEST(NoiseGenerator, ShaderCodeLoads) { olive::NoiseGeneratorNode node; - const olive::ShaderCode code = node.GetShaderCode( + const olive::ShaderCode code = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("anything"))); EXPECT_FALSE(code.frag_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains(QStringLiteral("strength_in"))); @@ -713,19 +713,19 @@ TEST(NoiseGenerator, ShaderCodeLoads) TEST(NoiseGenerator, ValueInsertsTimeAndUsesCacheParams) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - const olive::VideoParams vparams = TestVideoParams(); - const olive::TimeRange range(olive::rational(1, 2), olive::rational(3, 4)); - olive::NodeValueTable table = GenerateTable(node, vparams, range); + const olive::VideoParams vparams = test_video_params(); + const olive::TimeRange range(olive::Rational(1, 2), olive::Rational(3, 4)); + olive::NodeValueTable table = generate_table(node, vparams, range); - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), vparams.width()); EXPECT_EQ(texture->params().height(), vparams.height()); @@ -733,34 +733,34 @@ TEST(NoiseGenerator, ValueInsertsTimeAndUsesCacheParams) ASSERT_TRUE(job); // The noise is animated by the current time - const olive::NodeValue time = job->Get(QStringLiteral("time_in")); - ASSERT_EQ(int(time.type()), int(olive::NodeValue::kFloat)); - EXPECT_DOUBLE_EQ(time.toDouble(), range.in().toDouble()); + const olive::NodeValue time = job->get(QStringLiteral("time_in")); + ASSERT_EQ(int(time.type()), int(olive::NodeValue::k_float)); + EXPECT_DOUBLE_EQ(time.to_double(), range.in().to_double()); - EXPECT_DOUBLE_EQ(job->Get(olive::NoiseGeneratorNode::kStrengthInput) - .toDouble(), + EXPECT_DOUBLE_EQ(job->get(olive::NoiseGeneratorNode::k_strength_input) + .to_double(), 0.2); } TEST(NoiseGenerator, ValueWithBaseUsesBaseParams) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - auto *constant = AddNode(&project); + auto *node = add_node(&project); + auto *constant = add_node(&project); const olive::TexturePtr base = std::make_shared( - olive::VideoParams(64, 48, olive::core::PixelFormat::U8, 4)); - constant->SetTexture(base); - olive::Node::ConnectEdge( - constant, olive::NodeInput(node, olive::NoiseGeneratorNode::kBaseIn)); + olive::VideoParams(64, 48, olive::core::PixelFormat::u8, 4)); + constant->set_texture(base); + olive::Node::connect_edge( + constant, olive::NodeInput(node, olive::NoiseGeneratorNode::k_base_in)); - olive::NodeValueTable table = GenerateTable(node, TestVideoParams()); + olive::NodeValueTable table = generate_table(node, test_video_params()); // The generated noise adopts the base texture's params, not the sequence's - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); EXPECT_EQ(texture->params().width(), base->params().width()); EXPECT_EQ(texture->params().height(), base->params().height()); @@ -770,97 +770,97 @@ TEST(TextGeneratorV3, MetadataIsCorrect) { olive::TextGeneratorV3 node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.text3")); - EXPECT_EQ(node.Name(), QStringLiteral("Text")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_EQ(node.name(), QStringLiteral("Text")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_generator)); } TEST(TextGeneratorV3, InputDefaultsAndFlags) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); // The default text is a formatted HTML paragraph with the placeholder // already substituted ("Sample Text" replaces %1 at construction) const QString text = - node->GetStandardValue(olive::TextGeneratorV3::kTextInput).toString(); + node->get_standard_value(olive::TextGeneratorV3::k_text_input).toString(); EXPECT_TRUE(text.contains(QStringLiteral("Sample Text"))); EXPECT_TRUE(text.contains(QStringLiteral("

GetStandardValue(olive::ShapeNodeBase::kSizeInput) + EXPECT_EQ(node->get_standard_value(olive::ShapeNodeBase::k_size_input) .value(), QVector2D(400.0f, 300.0f)); // Alignment and argument inputs are hidden, non-rendered UI state - EXPECT_TRUE(node->IsInputHidden(olive::TextGeneratorV3::kVerticalAlignmentInput)); + EXPECT_TRUE(node->is_input_hidden(olive::TextGeneratorV3::k_vertical_alignment_input)); EXPECT_TRUE( - node->GetInputFlags(olive::TextGeneratorV3::kVerticalAlignmentInput) & - olive::kInputFlagStatic); - EXPECT_EQ(node->GetStandardValue(olive::TextGeneratorV3::kVerticalAlignmentInput) + node->get_input_flags(olive::TextGeneratorV3::k_vertical_alignment_input) & + olive::k_input_flag_static); + EXPECT_EQ(node->get_standard_value(olive::TextGeneratorV3::k_vertical_alignment_input) .toInt(), - int(olive::TextGeneratorV3::kVAlignTop)); + int(olive::TextGeneratorV3::k_v_align_top)); - EXPECT_TRUE(node->IsInputHidden(olive::TextGeneratorV3::kUseArgsInput)); - EXPECT_TRUE(node->GetInputFlags(olive::TextGeneratorV3::kUseArgsInput) & - olive::kInputFlagStatic); - EXPECT_TRUE(node->GetStandardValue(olive::TextGeneratorV3::kUseArgsInput) + EXPECT_TRUE(node->is_input_hidden(olive::TextGeneratorV3::k_use_args_input)); + EXPECT_TRUE(node->get_input_flags(olive::TextGeneratorV3::k_use_args_input) & + olive::k_input_flag_static); + EXPECT_TRUE(node->get_standard_value(olive::TextGeneratorV3::k_use_args_input) .toBool()); - EXPECT_TRUE(node->InputIsArray(olive::TextGeneratorV3::kArgsInput)); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), 0); - EXPECT_EQ(node->GetInputProperty(olive::TextGeneratorV3::kArgsInput, + EXPECT_TRUE(node->input_is_array(olive::TextGeneratorV3::k_args_input)); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), 0); + EXPECT_EQ(node->get_input_property(olive::TextGeneratorV3::k_args_input, QStringLiteral("arraystart")) .toInt(), 1); // TextGeneratorV3 has no color input, unlike ShapeNode - EXPECT_FALSE(node->HasInputWithID(olive::ShapeNodeBase::kColorInput)); + EXPECT_FALSE(node->has_input_with_id(olive::ShapeNodeBase::k_color_input)); } TEST(TextGeneratorV3, RetranslateSetsNamesAndComboStrings) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->Retranslate(); + auto *node = add_node(&project); + node->retranslate(); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV3::kTextInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV3::k_text_input), QStringLiteral("Text")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV3::kVerticalAlignmentInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV3::k_vertical_alignment_input), QStringLiteral("Vertical Alignment")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV3::kArgsInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV3::k_args_input), QStringLiteral("Arguments")); - const QStringList aligns = node->GetComboBoxStrings( - olive::TextGeneratorV3::kVerticalAlignmentInput); + const QStringList aligns = node->get_combo_box_strings( + olive::TextGeneratorV3::k_vertical_alignment_input); ASSERT_EQ(aligns.size(), 3); - EXPECT_EQ(aligns.at(int(olive::TextGeneratorV3::kVAlignTop)), + EXPECT_EQ(aligns.at(int(olive::TextGeneratorV3::k_v_align_top)), QStringLiteral("Top")); - EXPECT_EQ(aligns.at(int(olive::TextGeneratorV3::kVAlignMiddle)), + EXPECT_EQ(aligns.at(int(olive::TextGeneratorV3::k_v_align_middle)), QStringLiteral("Middle")); - EXPECT_EQ(aligns.at(int(olive::TextGeneratorV3::kVAlignBottom)), + EXPECT_EQ(aligns.at(int(olive::TextGeneratorV3::k_v_align_bottom)), QStringLiteral("Bottom")); } TEST(TextGeneratorV3, FormatStringSubstitutesArguments) { - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("Hello %1"), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("Hello %1"), { QStringLiteral("world") }), QStringLiteral("Hello world")); - EXPECT_EQ(olive::TextGeneratorV3::FormatString( + EXPECT_EQ(olive::TextGeneratorV3::format_string( QStringLiteral("%1 %2 %1"), { QStringLiteral("a"), QStringLiteral("b") }), QStringLiteral("a b a")); - EXPECT_EQ(olive::TextGeneratorV3::FormatString( + EXPECT_EQ(olive::TextGeneratorV3::format_string( QStringLiteral("%1%2"), { QStringLiteral("a"), QStringLiteral("b") }), QStringLiteral("ab")); @@ -870,9 +870,9 @@ TEST(TextGeneratorV3, FormatStringSubstitutesArguments) for (int i = 0; i < 12; i++) { args.append(QString::number(i + 1)); } - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("%12"), args), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("%12"), args), QStringLiteral("12")); - EXPECT_EQ(olive::TextGeneratorV3::FormatString( + EXPECT_EQ(olive::TextGeneratorV3::format_string( QStringLiteral("%01"), { QStringLiteral("x") }), QStringLiteral("x")); } @@ -880,192 +880,192 @@ TEST(TextGeneratorV3, FormatStringSubstitutesArguments) TEST(TextGeneratorV3, FormatStringHandlesEdgeCases) { // Double percent escapes to a literal one, even without arguments - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("100%%"), {}), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("100%%"), {}), QStringLiteral("100%")); - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("%%"), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("%%"), { QStringLiteral("x") }), QStringLiteral("%")); - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("%%%1"), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("%%%1"), { QStringLiteral("x") }), QStringLiteral("%x")); // Out-of-range and zero indices expand to nothing - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("%1"), {}), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("%1"), {}), QStringLiteral("")); - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("%5"), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("%5"), { QStringLiteral("a") }), QStringLiteral("")); - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("%0"), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("%0"), { QStringLiteral("a") }), QStringLiteral("")); // A percent not followed by a digit or percent is kept literally - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("%x"), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("%x"), { QStringLiteral("a") }), QStringLiteral("%x")); - EXPECT_EQ(olive::TextGeneratorV3::FormatString(QStringLiteral("end%"), + EXPECT_EQ(olive::TextGeneratorV3::format_string(QStringLiteral("end%"), { QStringLiteral("a") }), QStringLiteral("end%")); } TEST(TextGeneratorV3, AlignmentConversions) { - EXPECT_EQ(olive::TextGeneratorV3::GetQtAlignmentFromOurs( - olive::TextGeneratorV3::kVAlignTop), + EXPECT_EQ(olive::TextGeneratorV3::get_qt_alignment_from_ours( + olive::TextGeneratorV3::k_v_align_top), Qt::AlignTop); - EXPECT_EQ(olive::TextGeneratorV3::GetQtAlignmentFromOurs( - olive::TextGeneratorV3::kVAlignMiddle), + EXPECT_EQ(olive::TextGeneratorV3::get_qt_alignment_from_ours( + olive::TextGeneratorV3::k_v_align_middle), Qt::AlignVCenter); - EXPECT_EQ(olive::TextGeneratorV3::GetQtAlignmentFromOurs( - olive::TextGeneratorV3::kVAlignBottom), + EXPECT_EQ(olive::TextGeneratorV3::get_qt_alignment_from_ours( + olive::TextGeneratorV3::k_v_align_bottom), Qt::AlignBottom); // Unknown values map to no alignment - EXPECT_EQ(olive::TextGeneratorV3::GetQtAlignmentFromOurs( + EXPECT_EQ(olive::TextGeneratorV3::get_qt_alignment_from_ours( static_cast(-1)), Qt::Alignment()); - EXPECT_EQ(int(olive::TextGeneratorV3::GetOurAlignmentFromQts(Qt::AlignTop)), - int(olive::TextGeneratorV3::kVAlignTop)); + EXPECT_EQ(int(olive::TextGeneratorV3::get_our_alignment_from_qts(Qt::AlignTop)), + int(olive::TextGeneratorV3::k_v_align_top)); EXPECT_EQ( - int(olive::TextGeneratorV3::GetOurAlignmentFromQts(Qt::AlignVCenter)), - int(olive::TextGeneratorV3::kVAlignMiddle)); + int(olive::TextGeneratorV3::get_our_alignment_from_qts(Qt::AlignVCenter)), + int(olive::TextGeneratorV3::k_v_align_middle)); EXPECT_EQ( - int(olive::TextGeneratorV3::GetOurAlignmentFromQts(Qt::AlignBottom)), - int(olive::TextGeneratorV3::kVAlignBottom)); + int(olive::TextGeneratorV3::get_our_alignment_from_qts(Qt::AlignBottom)), + int(olive::TextGeneratorV3::k_v_align_bottom)); // Anything without a vertical component defaults to top - EXPECT_EQ(int(olive::TextGeneratorV3::GetOurAlignmentFromQts(Qt::AlignLeft)), - int(olive::TextGeneratorV3::kVAlignTop)); + EXPECT_EQ(int(olive::TextGeneratorV3::get_our_alignment_from_qts(Qt::AlignLeft)), + int(olive::TextGeneratorV3::k_v_align_top)); EXPECT_EQ( - int(olive::TextGeneratorV3::GetOurAlignmentFromQts(Qt::AlignHCenter)), - int(olive::TextGeneratorV3::kVAlignTop)); + int(olive::TextGeneratorV3::get_our_alignment_from_qts(Qt::AlignHCenter)), + int(olive::TextGeneratorV3::k_v_align_top)); } TEST(TextGeneratorV3, GetVerticalAlignmentFollowsInput) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - EXPECT_EQ(int(node->GetVerticalAlignment()), - int(olive::TextGeneratorV3::kVAlignTop)); + auto *node = add_node(&project); + EXPECT_EQ(int(node->get_vertical_alignment()), + int(olive::TextGeneratorV3::k_v_align_top)); - node->SetStandardValue(olive::TextGeneratorV3::kVerticalAlignmentInput, - int(olive::TextGeneratorV3::kVAlignBottom)); - EXPECT_EQ(int(node->GetVerticalAlignment()), - int(olive::TextGeneratorV3::kVAlignBottom)); + node->set_standard_value(olive::TextGeneratorV3::k_vertical_alignment_input, + int(olive::TextGeneratorV3::k_v_align_bottom)); + EXPECT_EQ(int(node->get_vertical_alignment()), + int(olive::TextGeneratorV3::k_v_align_bottom)); - node->SetStandardValue(olive::TextGeneratorV3::kVerticalAlignmentInput, - int(olive::TextGeneratorV3::kVAlignMiddle)); - EXPECT_EQ(int(node->GetVerticalAlignment()), - int(olive::TextGeneratorV3::kVAlignMiddle)); + node->set_standard_value(olive::TextGeneratorV3::k_vertical_alignment_input, + int(olive::TextGeneratorV3::k_v_align_middle)); + EXPECT_EQ(int(node->get_vertical_alignment()), + int(olive::TextGeneratorV3::k_v_align_middle)); } TEST(TextGeneratorV3, ValueFormatsTextIntoGenerateJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TextGeneratorV3::kTextInput, + auto *node = add_node(&project); + node->set_standard_value(olive::TextGeneratorV3::k_text_input, QStringLiteral("A %1 B %2")); - node->InputArrayResize(olive::TextGeneratorV3::kArgsInput, 2); - node->SetStandardValue(olive::TextGeneratorV3::kArgsInput, + node->input_array_resize(olive::TextGeneratorV3::k_args_input, 2); + node->set_standard_value(olive::TextGeneratorV3::k_args_input, QStringLiteral("x"), 0); - node->SetStandardValue(olive::TextGeneratorV3::kArgsInput, + node->set_standard_value(olive::TextGeneratorV3::k_args_input, QStringLiteral("y"), 1); // Text is always rendered to an 8-bit buffer regardless of sequence depth - const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::F32, 4); - olive::NodeValueTable table = GenerateTable(node, vparams); + const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::f32, 4); + olive::NodeValueTable table = generate_table(node, vparams); - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), vparams.width()); EXPECT_EQ(int(texture->params().format()), - int(olive::core::PixelFormat::U8)); + int(olive::core::PixelFormat::u8)); auto *job = dynamic_cast(texture->job()); ASSERT_TRUE(job); - EXPECT_EQ(job->Get(olive::TextGeneratorV3::kTextInput).toString(), + EXPECT_EQ(job->get(olive::TextGeneratorV3::k_text_input).to_string(), QStringLiteral("A x B y")); } TEST(TextGeneratorV3, EmptyTextOutputsNoTextureWithoutBase) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TextGeneratorV3::kTextInput, QString()); + auto *node = add_node(&project); + node->set_standard_value(olive::TextGeneratorV3::k_text_input, QString()); - olive::NodeValueTable table = GenerateTable(node, TestVideoParams()); + olive::NodeValueTable table = generate_table(node, test_video_params()); // No text and no base: nothing renderable comes out - EXPECT_TRUE(GetOutputTexture(table) == nullptr); + EXPECT_TRUE(get_output_texture(table) == nullptr); } TEST(TextGeneratorV3, EmptyTextPassesBaseThrough) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TextGeneratorV3::kTextInput, QString()); + auto *node = add_node(&project); + node->set_standard_value(olive::TextGeneratorV3::k_text_input, QString()); - auto *constant = AddNode(&project); + auto *constant = add_node(&project); const olive::TexturePtr base = std::make_shared( - olive::VideoParams(64, 48, olive::core::PixelFormat::U8, 4)); - constant->SetTexture(base); - olive::Node::ConnectEdge(constant, + olive::VideoParams(64, 48, olive::core::PixelFormat::u8, 4)); + constant->set_texture(base); + olive::Node::connect_edge(constant, olive::NodeInput( - node, olive::GeneratorWithMerge::kBaseInput)); + node, olive::GeneratorWithMerge::k_base_input)); - olive::NodeValueTable table = GenerateTable(node, TestVideoParams()); + olive::NodeValueTable table = generate_table(node, test_video_params()); // With empty text the base is passed through untouched instead of running // the text generation job - EXPECT_EQ(GetOutputTexture(table), base); + EXPECT_EQ(get_output_texture(table), base); } TEST(PolygonGenerator, MetadataIsCorrect) { olive::PolygonGenerator node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.polygon")); - EXPECT_EQ(node.Name(), QStringLiteral("Polygon")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_EQ(node.name(), QStringLiteral("Polygon")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_generator)); } TEST(PolygonGenerator, DefaultPentagonPoints) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - EXPECT_TRUE(node->InputIsArray(olive::PolygonGenerator::kPointsInput)); - ASSERT_EQ(node->InputArraySize(olive::PolygonGenerator::kPointsInput), 5); + EXPECT_TRUE(node->input_is_array(olive::PolygonGenerator::k_points_input)); + ASSERT_EQ(node->input_array_size(olive::PolygonGenerator::k_points_input), 5); // "The Default Pentagon(tm)", as named in the implementation const double expected[5][2] = { { 0, -135 }, { 135, -45 }, { 90, 120 }, { -90, 120 }, { -135, -45 } }; for (int i = 0; i < 5; i++) { - EXPECT_DOUBLE_EQ(node->GetSplitStandardValueOnTrack( - olive::PolygonGenerator::kPointsInput, 0, i) + EXPECT_DOUBLE_EQ(node->get_split_standard_value_on_track( + olive::PolygonGenerator::k_points_input, 0, i) .toDouble(), expected[i][0]) << "Wrong X for point " << i; - EXPECT_DOUBLE_EQ(node->GetSplitStandardValueOnTrack( - olive::PolygonGenerator::kPointsInput, 1, i) + EXPECT_DOUBLE_EQ(node->get_split_standard_value_on_track( + olive::PolygonGenerator::k_points_input, 1, i) .toDouble(), expected[i][1]) << "Wrong Y for point " << i; @@ -1073,7 +1073,7 @@ TEST(PolygonGenerator, DefaultPentagonPoints) // Polygons default to white const olive::core::Color color = - node->GetStandardValue(olive::PolygonGenerator::kColorInput) + node->get_standard_value(olive::PolygonGenerator::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_FLOAT_EQ(color.green(), 1.0f); @@ -1083,18 +1083,18 @@ TEST(PolygonGenerator, DefaultPentagonPoints) TEST(PolygonGenerator, RetranslateSetsInputNames) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->Retranslate(); + auto *node = add_node(&project); + node->retranslate(); - EXPECT_EQ(node->GetInputName(olive::PolygonGenerator::kPointsInput), + EXPECT_EQ(node->get_input_name(olive::PolygonGenerator::k_points_input), QStringLiteral("Points")); - EXPECT_EQ(node->GetInputName(olive::PolygonGenerator::kColorInput), + EXPECT_EQ(node->get_input_name(olive::PolygonGenerator::k_color_input), QStringLiteral("Color")); - EXPECT_EQ(node->GetInputName(olive::GeneratorWithMerge::kBaseInput), + EXPECT_EQ(node->get_input_name(olive::GeneratorWithMerge::k_base_input), QStringLiteral("Base")); } @@ -1103,17 +1103,17 @@ TEST(PolygonGenerator, ShaderCodeLoadsRgbAndMergeShaders) olive::PolygonGenerator node; // The generated alpha mask is tinted through the rgb shader - const olive::ShaderCode rgb = node.GetShaderCode( + const olive::ShaderCode rgb = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("rgb"))); EXPECT_FALSE(rgb.frag_code().isEmpty()); EXPECT_TRUE(rgb.frag_code().contains(QStringLiteral("texture_in"))); - const olive::ShaderCode merge = node.GetShaderCode( + const olive::ShaderCode merge = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("mrg"))); EXPECT_FALSE(merge.frag_code().isEmpty()); EXPECT_TRUE(merge.frag_code().contains(QStringLiteral("blend_in"))); - const olive::ShaderCode unknown = node.GetShaderCode( + const olive::ShaderCode unknown = node.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("bogus"))); EXPECT_TRUE(unknown.frag_code().isEmpty()); EXPECT_TRUE(unknown.vert_code().isEmpty()); @@ -1121,38 +1121,38 @@ TEST(PolygonGenerator, ShaderCodeLoadsRgbAndMergeShaders) TEST(PolygonGenerator, ValueWithoutBasePushesNestedGenerateJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::F32, 4); - olive::NodeValueTable table = GenerateTable(node, vparams); + const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::f32, 4); + olive::NodeValueTable table = generate_table(node, vparams); // Without a base, the output is the rgb tint job at sequence params - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), vparams.width()); EXPECT_EQ(int(texture->params().format()), - int(olive::core::PixelFormat::F32)); + int(olive::core::PixelFormat::f32)); auto *rgb = dynamic_cast(texture->job()); ASSERT_TRUE(rgb); - EXPECT_EQ(rgb->GetShaderID(), QStringLiteral("rgb")); + EXPECT_EQ(rgb->get_shader_id(), QStringLiteral("rgb")); const olive::core::Color color = - rgb->Get(olive::PolygonGenerator::kColorInput).toColor(); + rgb->get(olive::PolygonGenerator::k_color_input).to_color(); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_FLOAT_EQ(color.green(), 1.0f); EXPECT_FLOAT_EQ(color.blue(), 1.0f); EXPECT_FLOAT_EQ(color.alpha(), 1.0f); // Its texture input is the polygon's CPU-side GenerateJob, always 8-bit - olive::TexturePtr mask = rgb->Get(QStringLiteral("texture_in")).toTexture(); + olive::TexturePtr mask = rgb->get(QStringLiteral("texture_in")).to_texture(); ASSERT_TRUE(mask); - ASSERT_TRUE(mask->IsJob()); - EXPECT_EQ(int(mask->params().format()), int(olive::core::PixelFormat::U8)); + ASSERT_TRUE(mask->is_job()); + EXPECT_EQ(int(mask->params().format()), int(olive::core::PixelFormat::u8)); EXPECT_TRUE(dynamic_cast(mask->job())); } diff --git a/tests/gtest/node_globals_test.cpp b/tests/gtest/node_globals_test.cpp index fbde9ac09..d1bfd7041 100644 --- a/tests/gtest/node_globals_test.cpp +++ b/tests/gtest/node_globals_test.cpp @@ -14,35 +14,35 @@ TEST(NodeGlobals, DefaultConstruction) TEST(NodeGlobals, ConstructedWithParams) { - olive::VideoParams video_params(1920, 1080, olive::PixelFormat::F32, 4); + olive::VideoParams video_params(1920, 1080, olive::PixelFormat::f32, 4); olive::AudioParams audio_params; audio_params.set_sample_rate(48000); - audio_params.set_channel_layout(olive::core::kChannelLayoutStereo); + audio_params.set_channel_layout(olive::core::k_channel_layout_stereo); - olive::TimeRange time(olive::core::rational(1, 24), - olive::core::rational(2, 24)); + olive::TimeRange time(olive::core::Rational(1, 24), + olive::core::Rational(2, 24)); olive::NodeGlobals globals(video_params, audio_params, time, - olive::LoopMode::kLoopModeLoop); + olive::LoopMode::k_loop_mode_loop); EXPECT_EQ(globals.vparams().width(), 1920); EXPECT_EQ(globals.vparams().height(), 1080); EXPECT_EQ(globals.aparams().sample_rate(), 48000); - EXPECT_EQ(globals.loop_mode(), olive::LoopMode::kLoopModeLoop); - EXPECT_EQ(globals.time().in(), olive::core::rational(1, 24)); - EXPECT_EQ(globals.time().out(), olive::core::rational(2, 24)); + EXPECT_EQ(globals.loop_mode(), olive::LoopMode::k_loop_mode_loop); + EXPECT_EQ(globals.time().in(), olive::core::Rational(1, 24)); + EXPECT_EQ(globals.time().out(), olive::core::Rational(2, 24)); } TEST(NodeGlobals, RationalConstructorExpandsToFrame) { - olive::VideoParams video_params(1280, 720, olive::PixelFormat::F32, 4); + olive::VideoParams video_params(1280, 720, olive::PixelFormat::f32, 4); video_params.set_frame_rate(24); olive::AudioParams audio_params; audio_params.set_sample_rate(44100); olive::NodeGlobals globals(video_params, audio_params, - olive::core::rational(0, 1), - olive::LoopMode::kLoopModeClamp); + olive::core::Rational(0, 1), + olive::LoopMode::k_loop_mode_clamp); - EXPECT_EQ(globals.time().in(), olive::core::rational(0, 1)); - EXPECT_EQ(globals.time().out(), olive::core::rational(1, 24)); + EXPECT_EQ(globals.time().in(), olive::core::Rational(0, 1)); + EXPECT_EQ(globals.time().out(), olive::core::Rational(1, 24)); } diff --git a/tests/gtest/node_group_test.cpp b/tests/gtest/node_group_test.cpp index 6d6a6e11b..f11fa0b5c 100644 --- a/tests/gtest/node_group_test.cpp +++ b/tests/gtest/node_group_test.cpp @@ -17,12 +17,12 @@ class NodeGroupTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - template T *AddNode() + template T *add_node() { T *node = new T(); node->setParent(project_.get()); @@ -31,11 +31,11 @@ protected: // AddInputPassthrough()/SetOutputPassthrough() assert that the inner node // is part of the group's context, so tests always place it there first - olive::NodeGroup *AddGroupWithInnerMath(olive::MathNode **math) + olive::NodeGroup *add_group_with_inner_math(olive::MathNode **math) { - olive::NodeGroup *group = AddNode(); - *math = AddNode(); - group->SetNodePositionInContext(*math, olive::Node::Position()); + olive::NodeGroup *group = add_node(); + *math = add_node(); + group->set_node_position_in_context(*math, olive::Node::Position()); return group; } @@ -47,53 +47,53 @@ TEST_F(NodeGroupTest, MetadataIsCorrect) olive::NodeGroup group; EXPECT_EQ(group.id(), QStringLiteral("org.olivevideoeditor.Olive.group")); - EXPECT_EQ(group.Name(), QStringLiteral("Group")); - EXPECT_TRUE(group.Category().contains(olive::Node::kCategoryUnknown)); - EXPECT_FALSE(group.Description().isEmpty()); - EXPECT_TRUE(group.GetFlags() & olive::Node::kDontShowInCreateMenu); + EXPECT_EQ(group.name(), QStringLiteral("Group")); + EXPECT_TRUE(group.category().contains(olive::Node::k_category_unknown)); + EXPECT_FALSE(group.description().isEmpty()); + EXPECT_TRUE(group.get_flags() & olive::Node::k_dont_show_in_create_menu); // A fresh group has no passthroughs of either kind - EXPECT_EQ(group.GetOutputPassthrough(), nullptr); - EXPECT_TRUE(group.GetInputPassthroughs().isEmpty()); + EXPECT_EQ(group.get_output_passthrough(), nullptr); + EXPECT_TRUE(group.get_input_passthroughs().isEmpty()); } TEST_F(NodeGroupTest, AddInputPassthroughRegistersMirroredInput) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); + olive::NodeGroup *group = add_group_with_inner_math(&math); - QSignalSpy added_spy(group, &olive::NodeGroup::InputPassthroughAdded); + QSignalSpy added_spy(group, &olive::NodeGroup::input_passthrough_added); ASSERT_TRUE(added_spy.isValid()); - const olive::NodeInput input(math, olive::MathNode::kParamAIn); - const QString id = group->AddInputPassthrough(input); + const olive::NodeInput input(math, olive::MathNode::k_param_a_in); + const QString id = group->add_input_passthrough(input); // The first passthrough of an input reuses the inner input's ID - EXPECT_EQ(id, olive::MathNode::kParamAIn); - EXPECT_TRUE(group->HasInputWithID(id)); + EXPECT_EQ(id, olive::MathNode::k_param_a_in); + EXPECT_TRUE(group->has_input_with_id(id)); // The group input mirrors the inner input's type, default and flags - EXPECT_EQ(group->GetInputDataType(id), olive::NodeValue::kFloat); - EXPECT_DOUBLE_EQ(group->GetDefaultValue(id).toDouble(), 0.0); - EXPECT_EQ(group->GetInputFlags(id).value(), - math->GetInputFlags(olive::MathNode::kParamAIn).value()); + EXPECT_EQ(group->get_input_data_type(id), olive::NodeValue::k_float); + EXPECT_DOUBLE_EQ(group->get_default_value(id).toDouble(), 0.0); + EXPECT_EQ(group->get_input_flags(id).value(), + math->get_input_flags(olive::MathNode::k_param_a_in).value()); // The passthrough is registered for lookup in both directions - ASSERT_EQ(group->GetInputPassthroughs().size(), 1); - EXPECT_EQ(group->GetInputPassthroughs().first().first, id); - EXPECT_EQ(group->GetInputPassthroughs().first().second, input); - EXPECT_TRUE(group->ContainsInputPassthrough(input)); - EXPECT_FALSE(group->ContainsInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamBIn))); - EXPECT_EQ(group->GetIDOfPassthrough(input), id); - EXPECT_EQ(group->GetInputFromID(id), input); + ASSERT_EQ(group->get_input_passthroughs().size(), 1); + EXPECT_EQ(group->get_input_passthroughs().first().first, id); + EXPECT_EQ(group->get_input_passthroughs().first().second, input); + EXPECT_TRUE(group->contains_input_passthrough(input)); + EXPECT_FALSE(group->contains_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_b_in))); + EXPECT_EQ(group->get_id_of_passthrough(input), id); + EXPECT_EQ(group->get_input_from_id(id), input); // Unknown lookups return empty/invalid results - EXPECT_TRUE(group->GetIDOfPassthrough( - olive::NodeInput(math, olive::MathNode::kParamBIn)) + EXPECT_TRUE(group->get_id_of_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_b_in)) .isEmpty()); EXPECT_FALSE( - group->GetInputFromID(QStringLiteral("no_such_input")).IsValid()); + group->get_input_from_id(QStringLiteral("no_such_input")).is_valid()); ASSERT_EQ(added_spy.count(), 1); EXPECT_EQ(added_spy.takeFirst().at(1).value(), input); @@ -102,281 +102,281 @@ TEST_F(NodeGroupTest, AddInputPassthroughRegistersMirroredInput) TEST_F(NodeGroupTest, AddInputPassthroughIsIdempotentForSameInput) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); + olive::NodeGroup *group = add_group_with_inner_math(&math); - const olive::NodeInput input(math, olive::MathNode::kParamAIn); - const QString first = group->AddInputPassthrough(input); + const olive::NodeInput input(math, olive::MathNode::k_param_a_in); + const QString first = group->add_input_passthrough(input); - QSignalSpy added_spy(group, &olive::NodeGroup::InputPassthroughAdded); - const QString second = group->AddInputPassthrough(input); + QSignalSpy added_spy(group, &olive::NodeGroup::input_passthrough_added); + const QString second = group->add_input_passthrough(input); // Passing the same input through twice returns the existing ID EXPECT_EQ(first, second); - EXPECT_EQ(group->GetInputPassthroughs().size(), 1); + EXPECT_EQ(group->get_input_passthroughs().size(), 1); EXPECT_EQ(added_spy.count(), 0); } TEST_F(NodeGroupTest, AddInputPassthroughGeneratesUniqueIdForDuplicateInputId) { - auto *math_a = AddNode(); - auto *math_b = AddNode(); - auto *group = AddNode(); - group->SetNodePositionInContext(math_a, olive::Node::Position()); - group->SetNodePositionInContext(math_b, olive::Node::Position()); + auto *math_a = add_node(); + auto *math_b = add_node(); + auto *group = add_node(); + group->set_node_position_in_context(math_a, olive::Node::Position()); + group->set_node_position_in_context(math_b, olive::Node::Position()); - const QString id_a = group->AddInputPassthrough( - olive::NodeInput(math_a, olive::MathNode::kParamAIn)); - EXPECT_EQ(id_a, olive::MathNode::kParamAIn); + const QString id_a = group->add_input_passthrough( + olive::NodeInput(math_a, olive::MathNode::k_param_a_in)); + EXPECT_EQ(id_a, olive::MathNode::k_param_a_in); // A second passthrough of the same input ID (on a different node) must // not collide with the first; the suffix is derived from the input ID - const QString id_b = group->AddInputPassthrough( - olive::NodeInput(math_b, olive::MathNode::kParamAIn)); + const QString id_b = group->add_input_passthrough( + olive::NodeInput(math_b, olive::MathNode::k_param_a_in)); EXPECT_NE(id_a, id_b); EXPECT_EQ(id_b, QStringLiteral("param_a_in_2")); - ASSERT_EQ(group->GetInputPassthroughs().size(), 2); - EXPECT_TRUE(group->HasInputWithID(id_b)); - EXPECT_EQ(group->GetInputFromID(id_b), - olive::NodeInput(math_b, olive::MathNode::kParamAIn)); - EXPECT_EQ(group->GetIDOfPassthrough( - olive::NodeInput(math_a, olive::MathNode::kParamAIn)), + ASSERT_EQ(group->get_input_passthroughs().size(), 2); + EXPECT_TRUE(group->has_input_with_id(id_b)); + EXPECT_EQ(group->get_input_from_id(id_b), + olive::NodeInput(math_b, olive::MathNode::k_param_a_in)); + EXPECT_EQ(group->get_id_of_passthrough( + olive::NodeInput(math_a, olive::MathNode::k_param_a_in)), id_a); } TEST_F(NodeGroupTest, AddInputPassthroughHonorsForcedIdAndMirrorsFlags) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); + olive::NodeGroup *group = add_group_with_inner_math(&math); // kMethodIn is declared with kInputFlagNotConnectable | // kInputFlagNotKeyframable, exercising the flag mirroring - const QString id = group->AddInputPassthrough( - olive::NodeInput(math, olive::MathNode::kMethodIn), + const QString id = group->add_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_method_in), QStringLiteral("forced_method")); EXPECT_EQ(id, QStringLiteral("forced_method")); - EXPECT_TRUE(group->HasInputWithID(id)); - EXPECT_EQ(group->GetInputDataType(id), olive::NodeValue::kCombo); - EXPECT_EQ(group->GetInputFlags(id).value(), - math->GetInputFlags(olive::MathNode::kMethodIn).value()); - EXPECT_FALSE(group->IsInputConnectable(id)); - EXPECT_FALSE(group->IsInputKeyframable(id)); - EXPECT_EQ(group->GetInputFromID(id), - olive::NodeInput(math, olive::MathNode::kMethodIn)); + EXPECT_TRUE(group->has_input_with_id(id)); + EXPECT_EQ(group->get_input_data_type(id), olive::NodeValue::k_combo); + EXPECT_EQ(group->get_input_flags(id).value(), + math->get_input_flags(olive::MathNode::k_method_in).value()); + EXPECT_FALSE(group->is_input_connectable(id)); + EXPECT_FALSE(group->is_input_keyframable(id)); + EXPECT_EQ(group->get_input_from_id(id), + olive::NodeInput(math, olive::MathNode::k_method_in)); } TEST_F(NodeGroupTest, RemoveInputPassthroughMirrorsInputDeletion) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); + olive::NodeGroup *group = add_group_with_inner_math(&math); - const olive::NodeInput input(math, olive::MathNode::kParamAIn); - const QString id = group->AddInputPassthrough(input); + const olive::NodeInput input(math, olive::MathNode::k_param_a_in); + const QString id = group->add_input_passthrough(input); - QSignalSpy removed_spy(group, &olive::NodeGroup::InputPassthroughRemoved); + QSignalSpy removed_spy(group, &olive::NodeGroup::input_passthrough_removed); ASSERT_TRUE(removed_spy.isValid()); - group->RemoveInputPassthrough(input); + group->remove_input_passthrough(input); EXPECT_EQ(removed_spy.count(), 1); - EXPECT_TRUE(group->GetInputPassthroughs().isEmpty()); - EXPECT_FALSE(group->ContainsInputPassthrough(input)); - EXPECT_FALSE(group->HasInputWithID(id)); - EXPECT_TRUE(group->GetIDOfPassthrough(input).isEmpty()); - EXPECT_FALSE(group->GetInputFromID(id).IsValid()); + EXPECT_TRUE(group->get_input_passthroughs().isEmpty()); + EXPECT_FALSE(group->contains_input_passthrough(input)); + EXPECT_FALSE(group->has_input_with_id(id)); + EXPECT_TRUE(group->get_id_of_passthrough(input).isEmpty()); + EXPECT_FALSE(group->get_input_from_id(id).is_valid()); } TEST_F(NodeGroupTest, RemoveInputPassthroughIgnoresUnknownInput) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); + olive::NodeGroup *group = add_group_with_inner_math(&math); - const QString id = group->AddInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamAIn)); + const QString id = group->add_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_a_in)); - QSignalSpy removed_spy(group, &olive::NodeGroup::InputPassthroughRemoved); + QSignalSpy removed_spy(group, &olive::NodeGroup::input_passthrough_removed); // An input that was never passed through must be a harmless no-op - group->RemoveInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamBIn)); - group->RemoveInputPassthrough(olive::NodeInput()); + group->remove_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_b_in)); + group->remove_input_passthrough(olive::NodeInput()); EXPECT_EQ(removed_spy.count(), 0); - EXPECT_EQ(group->GetInputPassthroughs().size(), 1); - EXPECT_TRUE(group->HasInputWithID(id)); + EXPECT_EQ(group->get_input_passthroughs().size(), 1); + EXPECT_TRUE(group->has_input_with_id(id)); } TEST_F(NodeGroupTest, SetOutputPassthroughUpdatesAndEmits) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); - ASSERT_EQ(group->GetOutputPassthrough(), nullptr); + olive::NodeGroup *group = add_group_with_inner_math(&math); + ASSERT_EQ(group->get_output_passthrough(), nullptr); - QSignalSpy output_spy(group, &olive::NodeGroup::OutputPassthroughChanged); + QSignalSpy output_spy(group, &olive::NodeGroup::output_passthrough_changed); ASSERT_TRUE(output_spy.isValid()); - group->SetOutputPassthrough(math); - EXPECT_EQ(group->GetOutputPassthrough(), math); + group->set_output_passthrough(math); + EXPECT_EQ(group->get_output_passthrough(), math); EXPECT_EQ(output_spy.count(), 1); // Clearing the passthrough is allowed - group->SetOutputPassthrough(nullptr); - EXPECT_EQ(group->GetOutputPassthrough(), nullptr); + group->set_output_passthrough(nullptr); + EXPECT_EQ(group->get_output_passthrough(), nullptr); EXPECT_EQ(output_spy.count(), 2); } TEST_F(NodeGroupTest, PassthroughInputAcceptsExternalEdges) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); - const QString id = group->AddInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::NodeGroup *group = add_group_with_inner_math(&math); + const QString id = group->add_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_a_in)); // The mirrored input is a real input on the group and can be connected // from nodes outside the group - auto *external = AddNode(); + auto *external = add_node(); const olive::NodeInput group_input(group, id); - EXPECT_FALSE(group_input.IsConnected()); + EXPECT_FALSE(group_input.is_connected()); - olive::Node::ConnectEdge(external, group_input); - EXPECT_TRUE(group_input.IsConnected()); - EXPECT_EQ(group_input.GetConnectedOutput(), external); + olive::Node::connect_edge(external, group_input); + EXPECT_TRUE(group_input.is_connected()); + EXPECT_EQ(group_input.get_connected_output(), external); EXPECT_EQ(external->output_connections().size(), 1); - olive::Node::DisconnectEdge(external, group_input); - EXPECT_FALSE(group_input.IsConnected()); + olive::Node::disconnect_edge(external, group_input); + EXPECT_FALSE(group_input.is_connected()); EXPECT_TRUE(external->output_connections().empty()); } TEST_F(NodeGroupTest, GetInputNameFallsThroughToInnerNode) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); - math->Retranslate(); + olive::NodeGroup *group = add_group_with_inner_math(&math); + math->retranslate(); - const QString id = group->AddInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamAIn)); + const QString id = group->add_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_a_in)); // Without an override the name comes from the inner node's input - EXPECT_EQ(group->GetInputName(id), QStringLiteral("Value")); + EXPECT_EQ(group->get_input_name(id), QStringLiteral("Value")); // An explicit override takes precedence - group->SetInputName(id, QStringLiteral("Custom Name")); - EXPECT_EQ(group->GetInputName(id), QStringLiteral("Custom Name")); + group->set_input_name(id, QStringLiteral("Custom Name")); + EXPECT_EQ(group->get_input_name(id), QStringLiteral("Custom Name")); // Clearing the override restores the fall-through - group->SetInputName(id, QString()); - EXPECT_EQ(group->GetInputName(id), QStringLiteral("Value")); + group->set_input_name(id, QString()); + EXPECT_EQ(group->get_input_name(id), QStringLiteral("Value")); } TEST_F(NodeGroupTest, GetInputNameResolvesThroughNestedGroups) { - auto *math = AddNode(); - math->Retranslate(); + auto *math = add_node(); + math->retranslate(); - auto *inner = AddNode(); - inner->SetNodePositionInContext(math, olive::Node::Position()); - const QString inner_id = inner->AddInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamAIn)); + auto *inner = add_node(); + inner->set_node_position_in_context(math, olive::Node::Position()); + const QString inner_id = inner->add_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_a_in)); - auto *outer = AddNode(); - outer->SetNodePositionInContext(inner, olive::Node::Position()); - const QString outer_id = outer->AddInputPassthrough( + auto *outer = add_node(); + outer->set_node_position_in_context(inner, olive::Node::Position()); + const QString outer_id = outer->add_input_passthrough( olive::NodeInput(inner, inner_id)); // The outer group asks the inner group, which asks the math node - EXPECT_EQ(outer->GetInputName(outer_id), QStringLiteral("Value")); + EXPECT_EQ(outer->get_input_name(outer_id), QStringLiteral("Value")); } TEST_F(NodeGroupTest, ResolveInputUnwrapsNestedGroups) { - auto *math = AddNode(); + auto *math = add_node(); - auto *inner = AddNode(); - inner->SetNodePositionInContext(math, olive::Node::Position()); - const QString inner_id = inner->AddInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamAIn)); + auto *inner = add_node(); + inner->set_node_position_in_context(math, olive::Node::Position()); + const QString inner_id = inner->add_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_a_in)); - auto *outer = AddNode(); - outer->SetNodePositionInContext(inner, olive::Node::Position()); - const QString outer_id = outer->AddInputPassthrough( + auto *outer = add_node(); + outer->set_node_position_in_context(inner, olive::Node::Position()); + const QString outer_id = outer->add_input_passthrough( olive::NodeInput(inner, inner_id)); // An input on the outer group resolves to the innermost real input - const olive::NodeInput resolved = olive::NodeGroup::ResolveInput( + const olive::NodeInput resolved = olive::NodeGroup::resolve_input( olive::NodeInput(outer, outer_id)); EXPECT_EQ(resolved.node(), math); - EXPECT_EQ(resolved.input(), olive::MathNode::kParamAIn); + EXPECT_EQ(resolved.input(), olive::MathNode::k_param_a_in); EXPECT_EQ(resolved.element(), -1); // Inputs on regular nodes are returned unchanged - const olive::NodeInput plain(math, olive::MathNode::kParamBIn); - EXPECT_EQ(olive::NodeGroup::ResolveInput(plain), plain); + const olive::NodeInput plain(math, olive::MathNode::k_param_b_in); + EXPECT_EQ(olive::NodeGroup::resolve_input(plain), plain); } TEST_F(NodeGroupTest, GetInnerRejectsNonGroupAndUnknownInputs) { - auto *math = AddNode(); + auto *math = add_node(); - auto *group = AddNode(); - group->SetNodePositionInContext(math, olive::Node::Position()); - const QString id = group->AddInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamAIn)); + auto *group = add_node(); + group->set_node_position_in_context(math, olive::Node::Position()); + const QString id = group->add_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_a_in)); // A node that is not a group has no inner input - olive::NodeInput non_group(math, olive::MathNode::kParamAIn); - EXPECT_FALSE(olive::NodeGroup::GetInner(&non_group)); + olive::NodeInput non_group(math, olive::MathNode::k_param_a_in); + EXPECT_FALSE(olive::NodeGroup::get_inner(&non_group)); EXPECT_EQ(non_group.node(), math); // An input ID that is not a passthrough is left unchanged olive::NodeInput unknown(group, QStringLiteral("does_not_exist")); - EXPECT_FALSE(olive::NodeGroup::GetInner(&unknown)); + EXPECT_FALSE(olive::NodeGroup::get_inner(&unknown)); EXPECT_EQ(unknown.node(), group); // One level of passthrough resolves to the inner node's input olive::NodeInput passthrough(group, id); - EXPECT_TRUE(olive::NodeGroup::GetInner(&passthrough)); + EXPECT_TRUE(olive::NodeGroup::get_inner(&passthrough)); EXPECT_EQ(passthrough.node(), math); - EXPECT_EQ(passthrough.input(), olive::MathNode::kParamAIn); + EXPECT_EQ(passthrough.input(), olive::MathNode::k_param_a_in); } TEST_F(NodeGroupTest, RetranslateRetranslatesContextNodes) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); - ASSERT_TRUE(math->GetInputName(olive::MathNode::kParamAIn).isEmpty()); + olive::NodeGroup *group = add_group_with_inner_math(&math); + ASSERT_TRUE(math->get_input_name(olive::MathNode::k_param_a_in).isEmpty()); - group->Retranslate(); + group->retranslate(); // The group retranslates itself and every node in its context - EXPECT_EQ(group->GetInputName(olive::Node::kEnabledInput), + EXPECT_EQ(group->get_input_name(olive::Node::k_enabled_input), QStringLiteral("Enabled")); - EXPECT_EQ(math->GetInputName(olive::MathNode::kParamAIn), + EXPECT_EQ(math->get_input_name(olive::MathNode::k_param_a_in), QStringLiteral("Value")); } TEST_F(NodeGroupTest, SaveCustomWritesInputPassthroughs) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); + olive::NodeGroup *group = add_group_with_inner_math(&math); - const QString id = group->AddInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamAIn), + const QString id = group->add_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_a_in), QStringLiteral("pt_float")); - group->SetInputName(id, QStringLiteral("Custom Name")); - group->SetDefaultValue(id, 2.5); - group->SetInputFlag(id, olive::kInputFlagHidden); - group->SetInputProperty(id, QStringLiteral("mykey"), + group->set_input_name(id, QStringLiteral("Custom Name")); + group->set_default_value(id, 2.5); + group->set_input_flag(id, olive::k_input_flag_hidden); + group->set_input_property(id, QStringLiteral("mykey"), QStringLiteral("myvalue")); - group->SetOutputPassthrough(math); + group->set_output_passthrough(math); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("custom")); - group->SaveCustom(&writer); + group->save_custom(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -385,7 +385,7 @@ TEST_F(NodeGroupTest, SaveCustomWritesInputPassthroughs) EXPECT_TRUE(xml.contains(QStringLiteral(""))); EXPECT_TRUE(xml.contains(QStringLiteral("%1").arg(ptr))); EXPECT_TRUE(xml.contains( - QStringLiteral("%1").arg(olive::MathNode::kParamAIn))); + QStringLiteral("%1").arg(olive::MathNode::k_param_a_in))); EXPECT_TRUE(xml.contains(QStringLiteral("-1"))); EXPECT_TRUE(xml.contains(QStringLiteral("pt_float"))); EXPECT_TRUE(xml.contains(QStringLiteral("Custom Name"))); @@ -403,7 +403,7 @@ TEST_F(NodeGroupTest, SaveCustomWritesInputPassthroughs) TEST_F(NodeGroupTest, LoadCustomCollectsGroupLinks) { - auto *group = AddNode(); + auto *group = add_node(); const QString xml = QStringLiteral( "" @@ -432,7 +432,7 @@ TEST_F(NodeGroupTest, LoadCustomCollectsGroupLinks) QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("custom")); - EXPECT_TRUE(group->LoadCustom(&reader, &data)); + EXPECT_TRUE(group->load_custom(&reader, &data)); // Loading only records the links; resolution happens in PostLoadEvent ASSERT_EQ(data.group_input_links.size(), 1); @@ -445,7 +445,7 @@ TEST_F(NodeGroupTest, LoadCustomCollectsGroupLinks) EXPECT_EQ(link.input_element, -1); EXPECT_EQ(link.custom_name, QStringLiteral("Custom A")); EXPECT_EQ(link.custom_flags.value(), uint64_t(8)); - EXPECT_EQ(link.data_type, olive::NodeValue::kFloat); + EXPECT_EQ(link.data_type, olive::NodeValue::k_float); EXPECT_DOUBLE_EQ(link.default_val.toDouble(), 2.5); EXPECT_EQ(link.custom_properties.value(QStringLiteral("mykey")) .toString(), @@ -456,14 +456,14 @@ TEST_F(NodeGroupTest, LoadCustomCollectsGroupLinks) static_cast(12345)); // Nothing has been applied to the group yet - EXPECT_TRUE(group->GetInputPassthroughs().isEmpty()); - EXPECT_EQ(group->GetOutputPassthrough(), nullptr); + EXPECT_TRUE(group->get_input_passthroughs().isEmpty()); + EXPECT_EQ(group->get_output_passthrough(), nullptr); } TEST_F(NodeGroupTest, PostLoadEventRecreatesPassthroughs) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); + olive::NodeGroup *group = add_group_with_inner_math(&math); const QString xml = QStringLiteral( "" @@ -491,54 +491,54 @@ TEST_F(NodeGroupTest, PostLoadEventRecreatesPassthroughs) olive::SerializedData data; QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); - ASSERT_TRUE(group->LoadCustom(&reader, &data)); + ASSERT_TRUE(group->load_custom(&reader, &data)); // Point the serialized node references at the real inner node data.node_ptrs.insert(static_cast(12345), math); group->PostLoadEvent(&data); // The passthrough input is recreated with all its serialized overrides - ASSERT_TRUE(group->HasInputWithID(QStringLiteral("pt_a"))); - EXPECT_TRUE(group->ContainsInputPassthrough( - olive::NodeInput(math, olive::MathNode::kParamAIn))); - EXPECT_EQ(group->GetInputDataType(QStringLiteral("pt_a")), - olive::NodeValue::kFloat); - EXPECT_EQ(group->GetInputName(QStringLiteral("pt_a")), + ASSERT_TRUE(group->has_input_with_id(QStringLiteral("pt_a"))); + EXPECT_TRUE(group->contains_input_passthrough( + olive::NodeInput(math, olive::MathNode::k_param_a_in))); + EXPECT_EQ(group->get_input_data_type(QStringLiteral("pt_a")), + olive::NodeValue::k_float); + EXPECT_EQ(group->get_input_name(QStringLiteral("pt_a")), QStringLiteral("Custom A")); - EXPECT_TRUE(group->IsInputHidden(QStringLiteral("pt_a"))); + EXPECT_TRUE(group->is_input_hidden(QStringLiteral("pt_a"))); EXPECT_DOUBLE_EQ( - group->GetDefaultValue(QStringLiteral("pt_a")).toDouble(), 2.5); + group->get_default_value(QStringLiteral("pt_a")).toDouble(), 2.5); EXPECT_EQ(group - ->GetInputProperty(QStringLiteral("pt_a"), + ->get_input_property(QStringLiteral("pt_a"), QStringLiteral("mykey")) .toString(), QStringLiteral("myvalue")); - EXPECT_EQ(group->GetOutputPassthrough(), math); + EXPECT_EQ(group->get_output_passthrough(), math); } TEST_F(NodeGroupTest, SaveLoadRoundTripPreservesPassthroughs) { olive::MathNode *math_a; - olive::NodeGroup *group_a = AddGroupWithInnerMath(&math_a); + olive::NodeGroup *group_a = add_group_with_inner_math(&math_a); - const QString id = group_a->AddInputPassthrough( - olive::NodeInput(math_a, olive::MathNode::kParamAIn), + const QString id = group_a->add_input_passthrough( + olive::NodeInput(math_a, olive::MathNode::k_param_a_in), QStringLiteral("pt_roundtrip")); - group_a->SetInputName(id, QStringLiteral("Original Name")); - group_a->SetOutputPassthrough(math_a); + group_a->set_input_name(id, QStringLiteral("Original Name")); + group_a->set_output_passthrough(math_a); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("custom")); - group_a->SaveCustom(&writer); + group_a->save_custom(&writer); writer.writeEndElement(); writer.writeEndDocument(); // Load into a fresh group whose inner node replaces the original one olive::MathNode *math_b; - olive::NodeGroup *group_b = AddGroupWithInnerMath(&math_b); + olive::NodeGroup *group_b = add_group_with_inner_math(&math_b); olive::SerializedData data; data.node_ptrs.insert(reinterpret_cast(math_a), math_b); @@ -546,76 +546,76 @@ TEST_F(NodeGroupTest, SaveLoadRoundTripPreservesPassthroughs) QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("custom")); - ASSERT_TRUE(group_b->LoadCustom(&reader, &data)); + ASSERT_TRUE(group_b->load_custom(&reader, &data)); group_b->PostLoadEvent(&data); - ASSERT_EQ(group_b->GetInputPassthroughs().size(), 1); - EXPECT_EQ(group_b->GetInputPassthroughs().first().first, id); - EXPECT_EQ(group_b->GetInputPassthroughs().first().second.node(), math_b); - EXPECT_EQ(group_b->GetInputPassthroughs().first().second.input(), - olive::MathNode::kParamAIn); - EXPECT_EQ(group_b->GetInputName(id), QStringLiteral("Original Name")); - EXPECT_EQ(group_b->GetOutputPassthrough(), math_b); + ASSERT_EQ(group_b->get_input_passthroughs().size(), 1); + EXPECT_EQ(group_b->get_input_passthroughs().first().first, id); + EXPECT_EQ(group_b->get_input_passthroughs().first().second.node(), math_b); + EXPECT_EQ(group_b->get_input_passthroughs().first().second.input(), + olive::MathNode::k_param_a_in); + EXPECT_EQ(group_b->get_input_name(id), QStringLiteral("Original Name")); + EXPECT_EQ(group_b->get_output_passthrough(), math_b); } TEST_F(NodeGroupTest, AddInputPassthroughCommandAddsAndRemoves) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); - const olive::NodeInput input(math, olive::MathNode::kParamAIn); + olive::NodeGroup *group = add_group_with_inner_math(&math); + const olive::NodeInput input(math, olive::MathNode::k_param_a_in); olive::NodeGroupAddInputPassthrough cmd(group, input); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(group->GetInputPassthroughs().size(), 1); - EXPECT_TRUE(group->ContainsInputPassthrough(input)); + ASSERT_EQ(group->get_input_passthroughs().size(), 1); + EXPECT_TRUE(group->contains_input_passthrough(input)); cmd.undo_now(); - EXPECT_TRUE(group->GetInputPassthroughs().isEmpty()); - EXPECT_FALSE(group->HasInputWithID(olive::MathNode::kParamAIn)); + EXPECT_TRUE(group->get_input_passthroughs().isEmpty()); + EXPECT_FALSE(group->has_input_with_id(olive::MathNode::k_param_a_in)); } TEST_F(NodeGroupTest, AddInputPassthroughCommandNoOpWhenAlreadyPresent) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); - const olive::NodeInput input(math, olive::MathNode::kParamAIn); - group->AddInputPassthrough(input); - ASSERT_EQ(group->GetInputPassthroughs().size(), 1); + olive::NodeGroup *group = add_group_with_inner_math(&math); + const olive::NodeInput input(math, olive::MathNode::k_param_a_in); + group->add_input_passthrough(input); + ASSERT_EQ(group->get_input_passthroughs().size(), 1); olive::NodeGroupAddInputPassthrough cmd(group, input); // Redo must not add a duplicate when the passthrough already exists cmd.redo_now(); - EXPECT_EQ(group->GetInputPassthroughs().size(), 1); + EXPECT_EQ(group->get_input_passthroughs().size(), 1); // And undo must not remove the pre-existing passthrough cmd.undo_now(); - EXPECT_EQ(group->GetInputPassthroughs().size(), 1); - EXPECT_TRUE(group->ContainsInputPassthrough(input)); + EXPECT_EQ(group->get_input_passthroughs().size(), 1); + EXPECT_TRUE(group->contains_input_passthrough(input)); } TEST_F(NodeGroupTest, SetOutputPassthroughCommandRestoresPreviousOutput) { olive::MathNode *math; - olive::NodeGroup *group = AddGroupWithInnerMath(&math); - auto *other = AddNode(); - group->SetNodePositionInContext(other, olive::Node::Position()); + olive::NodeGroup *group = add_group_with_inner_math(&math); + auto *other = add_node(); + group->set_node_position_in_context(other, olive::Node::Position()); olive::NodeGroupSetOutputPassthrough cmd(group, math); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(group->GetOutputPassthrough(), math); + EXPECT_EQ(group->get_output_passthrough(), math); // Replacing the output passthrough restores the previous one on undo olive::NodeGroupSetOutputPassthrough replace_cmd(group, other); replace_cmd.redo_now(); - EXPECT_EQ(group->GetOutputPassthrough(), other); + EXPECT_EQ(group->get_output_passthrough(), other); replace_cmd.undo_now(); - EXPECT_EQ(group->GetOutputPassthrough(), math); + EXPECT_EQ(group->get_output_passthrough(), math); cmd.undo_now(); - EXPECT_EQ(group->GetOutputPassthrough(), nullptr); + EXPECT_EQ(group->get_output_passthrough(), nullptr); } diff --git a/tests/gtest/node_inputimmediate_test.cpp b/tests/gtest/node_inputimmediate_test.cpp index 39b024022..d97ebfd9b 100644 --- a/tests/gtest/node_inputimmediate_test.cpp +++ b/tests/gtest/node_inputimmediate_test.cpp @@ -23,7 +23,7 @@ namespace // NodeInputImmediate is not a QObject, so keyframes inserted directly into it // (rather than through parenting to a Node) must be removed and deleted by // hand to avoid leaks. -void ClearImmediate(olive::NodeInputImmediate *imm) +void clear_immediate(olive::NodeInputImmediate *imm) { for (int i = 0; i < imm->keyframe_tracks().size(); i++) { const QVector keys = imm->keyframe_tracks().at(i); @@ -34,10 +34,10 @@ void ClearImmediate(olive::NodeInputImmediate *imm) } } -olive::NodeKeyframe *MakeKey(const olive::rational &time, const QVariant &value, +olive::NodeKeyframe *make_key(const olive::Rational &time, const QVariant &value, int track, olive::NodeKeyframe::Type type = - olive::NodeKeyframe::kLinear) + olive::NodeKeyframe::k_linear) { return new olive::NodeKeyframe(time, value, type, track, -1, QStringLiteral("test_in")); @@ -47,7 +47,7 @@ olive::NodeKeyframe *MakeKey(const olive::rational &time, const QVariant &value, TEST(NodeInputImmediate, StandardValueRoundTrip) { - olive::NodeInputImmediate imm(olive::NodeValue::kFloat, { 1.5 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_float, { 1.5 }); EXPECT_FALSE(imm.is_keyframing()); EXPECT_TRUE(imm.is_using_standard_value(0)); @@ -66,7 +66,7 @@ TEST(NodeInputImmediate, StandardValueRoundTrip) TEST(NodeInputImmediate, SetSplitStandardValueCopiesOnlyOverlappingTracks) { - olive::NodeInputImmediate imm(olive::NodeValue::kVec2, { 0.0, 0.0 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_vec2, { 0.0, 0.0 }); ASSERT_EQ(imm.get_split_standard_value().size(), 2); // A shorter split only overwrites the tracks it covers @@ -83,13 +83,13 @@ TEST(NodeInputImmediate, SetSplitStandardValueCopiesOnlyOverlappingTracks) TEST(NodeInputImmediate, SetDataTypeResizesTracksAndReappliesDefault) { - olive::NodeInputImmediate imm(olive::NodeValue::kFloat, { 7.0 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_float, { 7.0 }); ASSERT_EQ(imm.keyframe_tracks().size(), 1); ASSERT_EQ(imm.get_split_standard_value().size(), 1); // Growing to a four-track type keeps the default on the first track and // leaves the new tracks null, since the default split only has one entry - imm.set_data_type(olive::NodeValue::kVec4); + imm.set_data_type(olive::NodeValue::k_vec4); EXPECT_EQ(imm.keyframe_tracks().size(), 4); ASSERT_EQ(imm.get_split_standard_value().size(), 4); EXPECT_DOUBLE_EQ(imm.get_split_standard_value_on_track(0).toDouble(), 7.0); @@ -97,7 +97,7 @@ TEST(NodeInputImmediate, SetDataTypeResizesTracksAndReappliesDefault) EXPECT_TRUE(imm.get_split_standard_value_on_track(2).isNull()); EXPECT_TRUE(imm.get_split_standard_value_on_track(3).isNull()); - imm.set_data_type(olive::NodeValue::kFloat); + imm.set_data_type(olive::NodeValue::k_float); EXPECT_EQ(imm.keyframe_tracks().size(), 1); ASSERT_EQ(imm.get_split_standard_value().size(), 1); EXPECT_DOUBLE_EQ(imm.get_split_standard_value_on_track(0).toDouble(), 7.0); @@ -105,42 +105,42 @@ TEST(NodeInputImmediate, SetDataTypeResizesTracksAndReappliesDefault) TEST(NodeInputImmediate, KeyframeLookupRequiresKeyframingEnabled) { - olive::NodeInputImmediate imm(olive::NodeValue::kFloat, { 0.0 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_float, { 0.0 }); - olive::NodeKeyframe *key = MakeKey(olive::rational(2), 1.0, 0); + olive::NodeKeyframe *key = make_key(olive::Rational(2), 1.0, 0); imm.insert_keyframe(key); // Without keyframing enabled the track reports that it uses the standard // value and all keyframe lookups come back empty EXPECT_TRUE(imm.is_using_standard_value(0)); - EXPECT_FALSE(imm.has_keyframe_at_time(olive::rational(2))); - EXPECT_EQ(imm.get_keyframe_at_time_on_track(olive::rational(2), 0), + EXPECT_FALSE(imm.has_keyframe_at_time(olive::Rational(2))); + EXPECT_EQ(imm.get_keyframe_at_time_on_track(olive::Rational(2), 0), nullptr); - EXPECT_TRUE(imm.get_keyframe_at_time(olive::rational(2)).isEmpty()); - EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::rational(2), 0), + EXPECT_TRUE(imm.get_keyframe_at_time(olive::Rational(2)).isEmpty()); + EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::Rational(2), 0), nullptr); imm.set_is_keyframing(true); EXPECT_FALSE(imm.is_using_standard_value(0)); - EXPECT_TRUE(imm.has_keyframe_at_time(olive::rational(2))); - EXPECT_EQ(imm.get_keyframe_at_time_on_track(olive::rational(2), 0), key); - ASSERT_EQ(imm.get_keyframe_at_time(olive::rational(2)).size(), 1); - EXPECT_EQ(imm.get_keyframe_at_time(olive::rational(2)).first(), key); - EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::rational(2), 0), + EXPECT_TRUE(imm.has_keyframe_at_time(olive::Rational(2))); + EXPECT_EQ(imm.get_keyframe_at_time_on_track(olive::Rational(2), 0), key); + ASSERT_EQ(imm.get_keyframe_at_time(olive::Rational(2)).size(), 1); + EXPECT_EQ(imm.get_keyframe_at_time(olive::Rational(2)).first(), key); + EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::Rational(2), 0), key); - EXPECT_FALSE(imm.has_keyframe_at_time(olive::rational(3))); + EXPECT_FALSE(imm.has_keyframe_at_time(olive::Rational(3))); - ClearImmediate(&imm); + clear_immediate(&imm); } TEST(NodeInputImmediate, InsertKeyframeSortsByTimeAndLinksSiblings) { - olive::NodeInputImmediate imm(olive::NodeValue::kFloat, { 0.0 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_float, { 0.0 }); // Insert out of order; the track must stay sorted by time - olive::NodeKeyframe *key_late = MakeKey(olive::rational(10), 10.0, 0); - olive::NodeKeyframe *key_early = MakeKey(olive::rational(0), 0.0, 0); - olive::NodeKeyframe *key_mid = MakeKey(olive::rational(5), 5.0, 0); + olive::NodeKeyframe *key_late = make_key(olive::Rational(10), 10.0, 0); + olive::NodeKeyframe *key_early = make_key(olive::Rational(0), 0.0, 0); + olive::NodeKeyframe *key_mid = make_key(olive::Rational(5), 5.0, 0); imm.insert_keyframe(key_late); imm.insert_keyframe(key_early); imm.insert_keyframe(key_mid); @@ -171,142 +171,142 @@ TEST(NodeInputImmediate, InsertKeyframeSortsByTimeAndLinksSiblings) ASSERT_EQ(track.size(), 2); delete key_mid; - ClearImmediate(&imm); + clear_immediate(&imm); } TEST(NodeInputImmediate, ClosestKeyframeToTimeOnTrackClampsAndPicksNearest) { - olive::NodeInputImmediate imm(olive::NodeValue::kVec2, { 0.0, 0.0 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_vec2, { 0.0, 0.0 }); imm.set_is_keyframing(true); - olive::NodeKeyframe *key_a = MakeKey(olive::rational(0), 0.0, 0); - olive::NodeKeyframe *key_b = MakeKey(olive::rational(10), 10.0, 0); + olive::NodeKeyframe *key_a = make_key(olive::Rational(0), 0.0, 0); + olive::NodeKeyframe *key_b = make_key(olive::Rational(10), 10.0, 0); imm.insert_keyframe(key_a); imm.insert_keyframe(key_b); // Outside the keyed range the closest keyframe clamps to the ends - EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::rational(-3), 0), + EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::Rational(-3), 0), key_a); - EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::rational(20), 0), + EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::Rational(20), 0), key_b); // Between the keys the nearer one wins - EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::rational(3), 0), + EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::Rational(3), 0), key_a); - EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::rational(7), 0), + EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::Rational(7), 0), key_b); // Exactly halfway the earlier keyframe wins the tie - EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::rational(5), 0), + EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::Rational(5), 0), key_a); // A track with no keyframes still counts as using the standard value - EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::rational(5), 1), + EXPECT_EQ(imm.get_closest_keyframe_to_time_on_track(olive::Rational(5), 1), nullptr); - ClearImmediate(&imm); + clear_immediate(&imm); } TEST(NodeInputImmediate, ClosestKeyframeBeforeAfterSpansAllTracks) { - olive::NodeInputImmediate imm(olive::NodeValue::kVec2, { 0.0, 0.0 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_vec2, { 0.0, 0.0 }); imm.set_is_keyframing(true); - olive::NodeKeyframe *key_t0 = MakeKey(olive::rational(0), 0.0, 0); - olive::NodeKeyframe *key_t10 = MakeKey(olive::rational(10), 10.0, 0); - olive::NodeKeyframe *key_t4_track1 = MakeKey(olive::rational(4), 4.0, 1); + olive::NodeKeyframe *key_t0 = make_key(olive::Rational(0), 0.0, 0); + olive::NodeKeyframe *key_t10 = make_key(olive::Rational(10), 10.0, 0); + olive::NodeKeyframe *key_t4_track1 = make_key(olive::Rational(4), 4.0, 1); imm.insert_keyframe(key_t0); imm.insert_keyframe(key_t10); imm.insert_keyframe(key_t4_track1); // The closest keyframe before 5 is the one at 4 on the other track - EXPECT_EQ(imm.get_closest_keyframe_before_time(olive::rational(5)), + EXPECT_EQ(imm.get_closest_keyframe_before_time(olive::Rational(5)), key_t4_track1); - EXPECT_EQ(imm.get_closest_keyframe_after_time(olive::rational(5)), key_t10); + EXPECT_EQ(imm.get_closest_keyframe_after_time(olive::Rational(5)), key_t10); // Strictly before/after: nothing exists outside the keyed range - EXPECT_EQ(imm.get_closest_keyframe_before_time(olive::rational(0)), + EXPECT_EQ(imm.get_closest_keyframe_before_time(olive::Rational(0)), nullptr); - EXPECT_EQ(imm.get_closest_keyframe_after_time(olive::rational(10)), + EXPECT_EQ(imm.get_closest_keyframe_after_time(olive::Rational(10)), nullptr); - EXPECT_EQ(imm.get_closest_keyframe_before_time(olive::rational(4)), key_t0); - EXPECT_EQ(imm.get_closest_keyframe_after_time(olive::rational(4)), key_t10); + EXPECT_EQ(imm.get_closest_keyframe_before_time(olive::Rational(4)), key_t0); + EXPECT_EQ(imm.get_closest_keyframe_after_time(olive::Rational(4)), key_t10); - ClearImmediate(&imm); + clear_immediate(&imm); } TEST(NodeInputImmediate, BestKeyframeTypeForTimeFollowsClosestKey) { - olive::NodeInputImmediate imm(olive::NodeValue::kFloat, { 0.0 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_float, { 0.0 }); // With no keyframes there is no reference, so the default type is used - EXPECT_EQ(int(imm.get_best_keyframe_type_for_time(olive::rational(5), 0)), - int(olive::NodeKeyframe::kDefaultType)); + EXPECT_EQ(int(imm.get_best_keyframe_type_for_time(olive::Rational(5), 0)), + int(olive::NodeKeyframe::k_default_type)); olive::NodeKeyframe *key_hold = - MakeKey(olive::rational(0), 0.0, 0, olive::NodeKeyframe::kHold); - olive::NodeKeyframe *key_linear = MakeKey(olive::rational(10), 10.0, 0); + make_key(olive::Rational(0), 0.0, 0, olive::NodeKeyframe::k_hold); + olive::NodeKeyframe *key_linear = make_key(olive::Rational(10), 10.0, 0); imm.insert_keyframe(key_hold); imm.insert_keyframe(key_linear); imm.set_is_keyframing(true); - EXPECT_EQ(int(imm.get_best_keyframe_type_for_time(olive::rational(2), 0)), - int(olive::NodeKeyframe::kHold)); - EXPECT_EQ(int(imm.get_best_keyframe_type_for_time(olive::rational(8), 0)), - int(olive::NodeKeyframe::kLinear)); + EXPECT_EQ(int(imm.get_best_keyframe_type_for_time(olive::Rational(2), 0)), + int(olive::NodeKeyframe::k_hold)); + EXPECT_EQ(int(imm.get_best_keyframe_type_for_time(olive::Rational(8), 0)), + int(olive::NodeKeyframe::k_linear)); - ClearImmediate(&imm); + clear_immediate(&imm); } TEST(NodeInputImmediate, GetKeyframeAtTimeAggregatesAcrossTracks) { - olive::NodeInputImmediate imm(olive::NodeValue::kVec2, { 0.0, 0.0 }); + olive::NodeInputImmediate imm(olive::NodeValue::k_vec2, { 0.0, 0.0 }); imm.set_is_keyframing(true); - olive::NodeKeyframe *key_track0 = MakeKey(olive::rational(3), 1.0, 0); - olive::NodeKeyframe *key_track1 = MakeKey(olive::rational(3), 2.0, 1); - olive::NodeKeyframe *key_later = MakeKey(olive::rational(7), 3.0, 0); + olive::NodeKeyframe *key_track0 = make_key(olive::Rational(3), 1.0, 0); + olive::NodeKeyframe *key_track1 = make_key(olive::Rational(3), 2.0, 1); + olive::NodeKeyframe *key_later = make_key(olive::Rational(7), 3.0, 0); imm.insert_keyframe(key_track0); imm.insert_keyframe(key_track1); imm.insert_keyframe(key_later); // Both tracks have a keyframe at t=3 QVector at_three = - imm.get_keyframe_at_time(olive::rational(3)); + imm.get_keyframe_at_time(olive::Rational(3)); ASSERT_EQ(at_three.size(), 2); EXPECT_TRUE(at_three.contains(key_track0)); EXPECT_TRUE(at_three.contains(key_track1)); // Only track 0 has one at t=7, and there is nothing at t=99 - EXPECT_EQ(imm.get_keyframe_at_time(olive::rational(7)).size(), 1); - EXPECT_TRUE(imm.get_keyframe_at_time(olive::rational(99)).isEmpty()); + EXPECT_EQ(imm.get_keyframe_at_time(olive::Rational(7)).size(), 1); + EXPECT_TRUE(imm.get_keyframe_at_time(olive::Rational(99)).isEmpty()); - ClearImmediate(&imm); + clear_immediate(&imm); } class NodeInputImmediateNodeTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - template T *AddNode() + template T *add_node() { T *node = new T(); node->setParent(project_.get()); return node; } - olive::NodeKeyframe *AddKey(olive::Node *node, const QString &input, - const olive::rational &time, + olive::NodeKeyframe *add_key(olive::Node *node, const QString &input, + const olive::Rational &time, const QVariant &value, int track, olive::NodeKeyframe::Type type = - olive::NodeKeyframe::kLinear) + olive::NodeKeyframe::k_linear) { auto *key = new olive::NodeKeyframe(time, value, type, track, -1, input); key->setParent(node); @@ -318,34 +318,34 @@ protected: TEST_F(NodeInputImmediateNodeTest, SetValueAtTimeCreatesAndUpdatesKeyframes) { - auto *node = AddNode(); - const olive::NodeInput input(node, olive::MathNode::kParamAIn); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + auto *node = add_node(); + const olive::NodeInput input(node, olive::MathNode::k_param_a_in); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); // A new keyframe is inserted where none exists yet olive::MultiUndoCommand cmd; - olive::Node::SetValueAtTime(input, olive::rational(5), 42.0, 0, &cmd, true); + olive::Node::set_value_at_time(input, olive::Rational(5), 42.0, 0, &cmd, true); EXPECT_EQ(cmd.child_count(), 1); cmd.redo_now(); - olive::NodeKeyframe *key = node->GetKeyframeAtTimeOnTrack( - olive::MathNode::kParamAIn, olive::rational(5), 0); + olive::NodeKeyframe *key = node->get_keyframe_at_time_on_track( + olive::MathNode::k_param_a_in, olive::Rational(5), 0); ASSERT_NE(key, nullptr); EXPECT_DOUBLE_EQ(key->value().toDouble(), 42.0); - EXPECT_DOUBLE_EQ(node->GetValueAtTime(olive::MathNode::kParamAIn, - olive::rational(5)) + EXPECT_DOUBLE_EQ(node->get_value_at_time(olive::MathNode::k_param_a_in, + olive::Rational(5)) .toDouble(), 42.0); // Setting the same time again updates the existing keyframe in place olive::MultiUndoCommand update_cmd; - olive::Node::SetValueAtTime(input, olive::rational(5), 43.0, 0, + olive::Node::set_value_at_time(input, olive::Rational(5), 43.0, 0, &update_cmd, true); EXPECT_EQ(update_cmd.child_count(), 1); update_cmd.redo_now(); const QVector &tracks = - node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1); + node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1); ASSERT_EQ(tracks.at(0).size(), 1); EXPECT_EQ(tracks.at(0).first(), key); EXPECT_DOUBLE_EQ(key->value().toDouble(), 43.0); @@ -353,41 +353,41 @@ TEST_F(NodeInputImmediateNodeTest, SetValueAtTimeCreatesAndUpdatesKeyframes) TEST_F(NodeInputImmediateNodeTest, SetValueAtTimeWithoutKeyframingSetsStandardValue) { - auto *node = AddNode(); - const olive::NodeInput input(node, olive::MathNode::kParamAIn); + auto *node = add_node(); + const olive::NodeInput input(node, olive::MathNode::k_param_a_in); olive::MultiUndoCommand cmd; - olive::Node::SetValueAtTime(input, olive::rational(5), 9.0, 0, &cmd, true); + olive::Node::set_value_at_time(input, olive::Rational(5), 9.0, 0, &cmd, true); EXPECT_EQ(cmd.child_count(), 1); cmd.redo_now(); EXPECT_DOUBLE_EQ( - node->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 9.0); - EXPECT_TRUE(node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1) + node->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 9.0); + EXPECT_TRUE(node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1) .at(0) .isEmpty()); } TEST_F(NodeInputImmediateNodeTest, SetValueAtTimeInsertsOnAllTracksOnlyWhenAsked) { - auto *solid = AddNode(); - solid->SetInputIsKeyframing(olive::SolidGenerator::kColorInput, true); - const olive::NodeInput input(solid, olive::SolidGenerator::kColorInput); + auto *solid = add_node(); + solid->set_input_is_keyframing(olive::SolidGenerator::k_color_input, true); + const olive::NodeInput input(solid, olive::SolidGenerator::k_color_input); // With insert_on_all_tracks_if_no_key set, keyframes are created on every // track; sibling tracks capture the value they currently evaluate to (the // standard value red = (1, 0, 0, 1) here) olive::MultiUndoCommand cmd; - olive::Node::SetValueAtTime(input, olive::rational(5), 0.5, 2, &cmd, true); + olive::Node::set_value_at_time(input, olive::Rational(5), 0.5, 2, &cmd, true); EXPECT_EQ(cmd.child_count(), 4); cmd.redo_now(); const QVector &tracks = - solid->GetKeyframeTracks(olive::SolidGenerator::kColorInput, -1); + solid->get_keyframe_tracks(olive::SolidGenerator::k_color_input, -1); ASSERT_EQ(tracks.size(), 4); for (int i = 0; i < tracks.size(); i++) { ASSERT_EQ(tracks.at(i).size(), 1); - EXPECT_EQ(tracks.at(i).first()->time(), olive::rational(5)); + EXPECT_EQ(tracks.at(i).first()->time(), olive::Rational(5)); } EXPECT_DOUBLE_EQ(tracks.at(0).first()->value().toDouble(), 1.0); EXPECT_DOUBLE_EQ(tracks.at(1).first()->value().toDouble(), 0.0); @@ -395,8 +395,8 @@ TEST_F(NodeInputImmediateNodeTest, SetValueAtTimeInsertsOnAllTracksOnlyWhenAsked EXPECT_DOUBLE_EQ(tracks.at(3).first()->value().toDouble(), 1.0); const olive::Color c = - solid->GetValueAtTime(olive::SolidGenerator::kColorInput, - olive::rational(5)) + solid->get_value_at_time(olive::SolidGenerator::k_color_input, + olive::Rational(5)) .value(); EXPECT_FLOAT_EQ(c.red(), 1.0f); EXPECT_FLOAT_EQ(c.green(), 0.0f); @@ -404,19 +404,19 @@ TEST_F(NodeInputImmediateNodeTest, SetValueAtTimeInsertsOnAllTracksOnlyWhenAsked EXPECT_FLOAT_EQ(c.alpha(), 1.0f); // Without the flag only the requested track receives a keyframe - auto *single = AddNode(); - single->SetInputIsKeyframing(olive::SolidGenerator::kColorInput, true); + auto *single = add_node(); + single->set_input_is_keyframing(olive::SolidGenerator::k_color_input, true); const olive::NodeInput single_input(single, - olive::SolidGenerator::kColorInput); + olive::SolidGenerator::k_color_input); olive::MultiUndoCommand single_cmd; - olive::Node::SetValueAtTime(single_input, olive::rational(5), 0.5, 2, + olive::Node::set_value_at_time(single_input, olive::Rational(5), 0.5, 2, &single_cmd, false); EXPECT_EQ(single_cmd.child_count(), 1); single_cmd.redo_now(); const QVector &single_tracks = - single->GetKeyframeTracks(olive::SolidGenerator::kColorInput, -1); + single->get_keyframe_tracks(olive::SolidGenerator::k_color_input, -1); ASSERT_EQ(single_tracks.size(), 4); EXPECT_TRUE(single_tracks.at(0).isEmpty()); EXPECT_TRUE(single_tracks.at(1).isEmpty()); @@ -427,28 +427,28 @@ TEST_F(NodeInputImmediateNodeTest, SetValueAtTimeInsertsOnAllTracksOnlyWhenAsked TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeInterpolatesColorTracks) { - auto *solid = AddNode(); - solid->SetInputIsKeyframing(olive::SolidGenerator::kColorInput, true); + auto *solid = add_node(); + solid->set_input_is_keyframing(olive::SolidGenerator::k_color_input, true); // Black to white over ten seconds on all four tracks for (int track = 0; track < 4; track++) { - AddKey(solid, olive::SolidGenerator::kColorInput, olive::rational(0), + add_key(solid, olive::SolidGenerator::k_color_input, olive::Rational(0), 0.0, track); - AddKey(solid, olive::SolidGenerator::kColorInput, olive::rational(10), + add_key(solid, olive::SolidGenerator::k_color_input, olive::Rational(10), 1.0, track); } const olive::Color mid = - solid->GetValueAtTime(olive::SolidGenerator::kColorInput, - olive::rational(5)) + solid->get_value_at_time(olive::SolidGenerator::k_color_input, + olive::Rational(5)) .value(); EXPECT_FLOAT_EQ(mid.red(), 0.5f); EXPECT_FLOAT_EQ(mid.green(), 0.5f); EXPECT_FLOAT_EQ(mid.blue(), 0.5f); EXPECT_FLOAT_EQ(mid.alpha(), 0.5f); - const olive::SplitValue split = solid->GetSplitValueAtTime( - olive::SolidGenerator::kColorInput, olive::rational(5)); + const olive::SplitValue split = solid->get_split_value_at_time( + olive::SolidGenerator::k_color_input, olive::Rational(5)); ASSERT_EQ(split.size(), 4); for (int i = 0; i < split.size(); i++) { EXPECT_DOUBLE_EQ(split.at(i).toDouble(), 0.5); @@ -456,48 +456,48 @@ TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeInterpolatesColorTracks) // Outside the keyed range the end values hold const olive::Color before = - solid->GetValueAtTime(olive::SolidGenerator::kColorInput, - olive::rational(-2)) + solid->get_value_at_time(olive::SolidGenerator::k_color_input, + olive::Rational(-2)) .value(); EXPECT_FLOAT_EQ(before.red(), 0.0f); const olive::Color after = - solid->GetValueAtTime(olive::SolidGenerator::kColorInput, - olive::rational(20)) + solid->get_value_at_time(olive::SolidGenerator::k_color_input, + olive::Rational(20)) .value(); EXPECT_FLOAT_EQ(after.alpha(), 1.0f); } TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeInterpolatesVec2Tracks) { - auto *matrix = AddNode(); - matrix->SetInputIsKeyframing(olive::MatrixGenerator::kPositionInput, true); + auto *matrix = add_node(); + matrix->set_input_is_keyframing(olive::MatrixGenerator::k_position_input, true); - AddKey(matrix, olive::MatrixGenerator::kPositionInput, olive::rational(0), + add_key(matrix, olive::MatrixGenerator::k_position_input, olive::Rational(0), 0.0, 0); - AddKey(matrix, olive::MatrixGenerator::kPositionInput, olive::rational(10), + add_key(matrix, olive::MatrixGenerator::k_position_input, olive::Rational(10), 10.0, 0); - AddKey(matrix, olive::MatrixGenerator::kPositionInput, olive::rational(0), + add_key(matrix, olive::MatrixGenerator::k_position_input, olive::Rational(0), 10.0, 1); - AddKey(matrix, olive::MatrixGenerator::kPositionInput, olive::rational(10), + add_key(matrix, olive::MatrixGenerator::k_position_input, olive::Rational(10), 20.0, 1); const QVector2D mid = - matrix->GetValueAtTime(olive::MatrixGenerator::kPositionInput, - olive::rational(5)) + matrix->get_value_at_time(olive::MatrixGenerator::k_position_input, + olive::Rational(5)) .value(); EXPECT_FLOAT_EQ(mid.x(), 5.0f); EXPECT_FLOAT_EQ(mid.y(), 15.0f); // Each track clamps to its own end keyframes const QVector2D clamped_low = - matrix->GetValueAtTime(olive::MatrixGenerator::kPositionInput, - olive::rational(-5)) + matrix->get_value_at_time(olive::MatrixGenerator::k_position_input, + olive::Rational(-5)) .value(); EXPECT_FLOAT_EQ(clamped_low.x(), 0.0f); EXPECT_FLOAT_EQ(clamped_low.y(), 10.0f); const QVector2D clamped_high = - matrix->GetValueAtTime(olive::MatrixGenerator::kPositionInput, - olive::rational(15)) + matrix->get_value_at_time(olive::MatrixGenerator::k_position_input, + olive::Rational(15)) .value(); EXPECT_FLOAT_EQ(clamped_high.x(), 10.0f); EXPECT_FLOAT_EQ(clamped_high.y(), 20.0f); @@ -505,63 +505,63 @@ TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeInterpolatesVec2Tracks) TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeInterpolatesRationalAsRational) { - auto *offset = AddNode(); - offset->SetInputIsKeyframing(olive::TimeOffsetNode::kTimeInput, true); + auto *offset = add_node(); + offset->set_input_is_keyframing(olive::TimeOffsetNode::k_time_input, true); - AddKey(offset, olive::TimeOffsetNode::kTimeInput, olive::rational(0), - QVariant::fromValue(olive::rational(0)), 0); - AddKey(offset, olive::TimeOffsetNode::kTimeInput, olive::rational(10), - QVariant::fromValue(olive::rational(10)), 0); + add_key(offset, olive::TimeOffsetNode::k_time_input, olive::Rational(0), + QVariant::fromValue(olive::Rational(0)), 0); + add_key(offset, olive::TimeOffsetNode::k_time_input, olive::Rational(10), + QVariant::fromValue(olive::Rational(10)), 0); - // The interpolated value is converted back into a rational - const QVariant mid = offset->GetValueAtTime( - olive::TimeOffsetNode::kTimeInput, olive::rational(5)); - EXPECT_EQ(mid.value(), olive::rational(5)); + // The interpolated value is converted back into a Rational + const QVariant mid = offset->get_value_at_time( + olive::TimeOffsetNode::k_time_input, olive::Rational(5)); + EXPECT_EQ(mid.value(), olive::Rational(5)); - const QVariant one_tenth_in = offset->GetValueAtTime( - olive::TimeOffsetNode::kTimeInput, olive::rational(1)); - EXPECT_DOUBLE_EQ(one_tenth_in.value().toDouble(), 1.0); + const QVariant one_tenth_in = offset->get_value_at_time( + olive::TimeOffsetNode::k_time_input, olive::Rational(1)); + EXPECT_DOUBLE_EQ(one_tenth_in.value().to_double(), 1.0); } TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeHoldsRationalUntilNextKey) { - auto *offset = AddNode(); - offset->SetInputIsKeyframing(olive::TimeOffsetNode::kTimeInput, true); + auto *offset = add_node(); + offset->set_input_is_keyframing(olive::TimeOffsetNode::k_time_input, true); - AddKey(offset, olive::TimeOffsetNode::kTimeInput, olive::rational(0), - QVariant::fromValue(olive::rational(2, 3)), 0, - olive::NodeKeyframe::kHold); - AddKey(offset, olive::TimeOffsetNode::kTimeInput, olive::rational(10), - QVariant::fromValue(olive::rational(4, 3)), 0); + add_key(offset, olive::TimeOffsetNode::k_time_input, olive::Rational(0), + QVariant::fromValue(olive::Rational(2, 3)), 0, + olive::NodeKeyframe::k_hold); + add_key(offset, olive::TimeOffsetNode::k_time_input, olive::Rational(10), + QVariant::fromValue(olive::Rational(4, 3)), 0); - // A hold keyframe keeps its exact rational value until the next key - const QVariant held = offset->GetValueAtTime( - olive::TimeOffsetNode::kTimeInput, olive::rational(9)); - EXPECT_EQ(held.value(), olive::rational(2, 3)); + // A hold keyframe keeps its exact Rational value until the next key + const QVariant held = offset->get_value_at_time( + olive::TimeOffsetNode::k_time_input, olive::Rational(9)); + EXPECT_EQ(held.value(), olive::Rational(2, 3)); - const QVariant at_next = offset->GetValueAtTime( - olive::TimeOffsetNode::kTimeInput, olive::rational(10)); - EXPECT_EQ(at_next.value(), olive::rational(4, 3)); + const QVariant at_next = offset->get_value_at_time( + olive::TimeOffsetNode::k_time_input, olive::Rational(10)); + EXPECT_EQ(at_next.value(), olive::Rational(4, 3)); } TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeBezierHandlesBendCurve) { - auto *node = AddNode(); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + auto *node = add_node(); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); olive::NodeKeyframe *before = - AddKey(node, olive::MathNode::kParamAIn, olive::rational(0), 0.0, 0, - olive::NodeKeyframe::kBezier); + add_key(node, olive::MathNode::k_param_a_in, olive::Rational(0), 0.0, 0, + olive::NodeKeyframe::k_bezier); olive::NodeKeyframe *after = - AddKey(node, olive::MathNode::kParamAIn, olive::rational(10), 10.0, 0, - olive::NodeKeyframe::kBezier); + add_key(node, olive::MathNode::k_param_a_in, olive::Rational(10), 10.0, 0, + olive::NodeKeyframe::k_bezier); // Ease-in shape: the outgoing handle pulls the start of the curve flat before->set_bezier_control_out(QPointF(2.5, 0.0)); after->set_bezier_control_in(QPointF(0.0, 0.0)); - const double interpolated = node->GetValueAtTime( - olive::MathNode::kParamAIn, olive::rational(5)).toDouble(); + const double interpolated = node->get_value_at_time( + olive::MathNode::k_param_a_in, olive::Rational(5)).toDouble(); // Independent expectation, derived by hand from the control points // P0=(0,0), P1=(2.5,0), P2=(10,10), P3=(10,10): @@ -579,19 +579,19 @@ TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeBezierHandlesBendCurve) TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeQuadraticBezierWithOneHandle) { - auto *node = AddNode(); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + auto *node = add_node(); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); // Bezier into linear uses a quadratic curve with a single control point olive::NodeKeyframe *before = - AddKey(node, olive::MathNode::kParamAIn, olive::rational(0), 0.0, 0, - olive::NodeKeyframe::kBezier); - AddKey(node, olive::MathNode::kParamAIn, olive::rational(10), 10.0, 0, - olive::NodeKeyframe::kLinear); + add_key(node, olive::MathNode::k_param_a_in, olive::Rational(0), 0.0, 0, + olive::NodeKeyframe::k_bezier); + add_key(node, olive::MathNode::k_param_a_in, olive::Rational(10), 10.0, 0, + olive::NodeKeyframe::k_linear); before->set_bezier_control_out(QPointF(2.5, 0.0)); - const double interpolated = node->GetValueAtTime( - olive::MathNode::kParamAIn, olive::rational(5)).toDouble(); + const double interpolated = node->get_value_at_time( + olive::MathNode::k_param_a_in, olive::Rational(5)).toDouble(); // Independent expectation, derived by hand from the single control point // CP=(2.5,0) between P0=(0,0) and P2=(10,10): @@ -605,64 +605,64 @@ TEST_F(NodeInputImmediateNodeTest, GetValueAtTimeQuadraticBezierWithOneHandle) TEST_F(NodeInputImmediateNodeTest, IsUsingStandardValueTransitions) { - auto *node = AddNode(); - node->SetStandardValue(olive::MathNode::kParamAIn, 3.0); + auto *node = add_node(); + node->set_standard_value(olive::MathNode::k_param_a_in, 3.0); // Static input: standard value is always in use - EXPECT_TRUE(node->IsUsingStandardValue(olive::MathNode::kParamAIn, 0)); + EXPECT_TRUE(node->is_using_standard_value(olive::MathNode::k_param_a_in, 0)); // Keyframing enabled but no keyframes yet: still the standard value - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); - EXPECT_TRUE(node->IsUsingStandardValue(olive::MathNode::kParamAIn, 0)); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); + EXPECT_TRUE(node->is_using_standard_value(olive::MathNode::k_param_a_in, 0)); // With a keyframe present the track switches to the keyed value olive::NodeKeyframe *key = - AddKey(node, olive::MathNode::kParamAIn, olive::rational(5), 7.0, 0); - EXPECT_FALSE(node->IsUsingStandardValue(olive::MathNode::kParamAIn, 0)); + add_key(node, olive::MathNode::k_param_a_in, olive::Rational(5), 7.0, 0); + EXPECT_FALSE(node->is_using_standard_value(olive::MathNode::k_param_a_in, 0)); // Disabling keyframing hides the keyframes again - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, false); - EXPECT_TRUE(node->IsUsingStandardValue(olive::MathNode::kParamAIn, 0)); - EXPECT_DOUBLE_EQ(node->GetValueAtTime(olive::MathNode::kParamAIn, - olive::rational(5)) + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, false); + EXPECT_TRUE(node->is_using_standard_value(olive::MathNode::k_param_a_in, 0)); + EXPECT_DOUBLE_EQ(node->get_value_at_time(olive::MathNode::k_param_a_in, + olive::Rational(5)) .toDouble(), 3.0); // Removing the last keyframe returns the track to the standard value - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); - EXPECT_FALSE(node->IsUsingStandardValue(olive::MathNode::kParamAIn, 0)); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); + EXPECT_FALSE(node->is_using_standard_value(olive::MathNode::k_param_a_in, 0)); key->setParent(nullptr); delete key; - EXPECT_TRUE(node->IsUsingStandardValue(olive::MathNode::kParamAIn, 0)); - EXPECT_DOUBLE_EQ(node->GetValueAtTime(olive::MathNode::kParamAIn, - olive::rational(5)) + EXPECT_TRUE(node->is_using_standard_value(olive::MathNode::k_param_a_in, 0)); + EXPECT_DOUBLE_EQ(node->get_value_at_time(olive::MathNode::k_param_a_in, + olive::Rational(5)) .toDouble(), 3.0); } TEST_F(NodeInputImmediateNodeTest, PartiallyKeyedTrackFallsBackToStandardValue) { - auto *matrix = AddNode(); - matrix->SetStandardValue(olive::MatrixGenerator::kPositionInput, + auto *matrix = add_node(); + matrix->set_standard_value(olive::MatrixGenerator::k_position_input, QVector2D(1.0f, 2.0f)); - matrix->SetInputIsKeyframing(olive::MatrixGenerator::kPositionInput, true); + matrix->set_input_is_keyframing(olive::MatrixGenerator::k_position_input, true); // Only the X track is keyed; the Y track keeps its standard value - AddKey(matrix, olive::MatrixGenerator::kPositionInput, olive::rational(0), + add_key(matrix, olive::MatrixGenerator::k_position_input, olive::Rational(0), 0.0, 0); - AddKey(matrix, olive::MatrixGenerator::kPositionInput, olive::rational(10), + add_key(matrix, olive::MatrixGenerator::k_position_input, olive::Rational(10), 10.0, 0); EXPECT_FALSE( - matrix->IsUsingStandardValue(olive::MatrixGenerator::kPositionInput, + matrix->is_using_standard_value(olive::MatrixGenerator::k_position_input, 0)); EXPECT_TRUE( - matrix->IsUsingStandardValue(olive::MatrixGenerator::kPositionInput, + matrix->is_using_standard_value(olive::MatrixGenerator::k_position_input, 1)); const QVector2D value = - matrix->GetValueAtTime(olive::MatrixGenerator::kPositionInput, - olive::rational(5)) + matrix->get_value_at_time(olive::MatrixGenerator::k_position_input, + olive::Rational(5)) .value(); EXPECT_FLOAT_EQ(value.x(), 5.0f); EXPECT_FLOAT_EQ(value.y(), 2.0f); @@ -670,11 +670,11 @@ TEST_F(NodeInputImmediateNodeTest, PartiallyKeyedTrackFallsBackToStandardValue) TEST_F(NodeInputImmediateNodeTest, StandardValueCombinationAcrossTracks) { - auto *solid = AddNode(); + auto *solid = add_node(); // The declared default is opaque red olive::Color initial = - solid->GetStandardValue(olive::SolidGenerator::kColorInput) + solid->get_standard_value(olive::SolidGenerator::k_color_input) .value(); EXPECT_FLOAT_EQ(initial.red(), 1.0f); EXPECT_FLOAT_EQ(initial.green(), 0.0f); @@ -682,26 +682,26 @@ TEST_F(NodeInputImmediateNodeTest, StandardValueCombinationAcrossTracks) EXPECT_FLOAT_EQ(initial.alpha(), 1.0f); // Setting a normal value splits it across the four tracks - solid->SetStandardValue( - olive::SolidGenerator::kColorInput, + solid->set_standard_value( + olive::SolidGenerator::k_color_input, QVariant::fromValue(olive::Color(0.25f, 0.5f, 0.75f, 1.0f))); const olive::SplitValue split = - solid->GetSplitStandardValue(olive::SolidGenerator::kColorInput); + solid->get_split_standard_value(olive::SolidGenerator::k_color_input); ASSERT_EQ(split.size(), 4); EXPECT_DOUBLE_EQ(split.at(0).toDouble(), 0.25); EXPECT_DOUBLE_EQ(split.at(1).toDouble(), 0.5); EXPECT_DOUBLE_EQ(split.at(2).toDouble(), 0.75); EXPECT_DOUBLE_EQ(split.at(3).toDouble(), 1.0); - EXPECT_DOUBLE_EQ(solid->GetSplitStandardValueOnTrack( - olive::SolidGenerator::kColorInput, 2) + EXPECT_DOUBLE_EQ(solid->get_split_standard_value_on_track( + olive::SolidGenerator::k_color_input, 2) .toDouble(), 0.75); // A partial split only overwrites the leading tracks - solid->SetSplitStandardValue(olive::SolidGenerator::kColorInput, + solid->set_split_standard_value(olive::SolidGenerator::k_color_input, { 0.1, 0.2 }); const olive::Color combined = - solid->GetStandardValue(olive::SolidGenerator::kColorInput) + solid->get_standard_value(olive::SolidGenerator::k_color_input) .value(); EXPECT_FLOAT_EQ(combined.red(), 0.1f); EXPECT_FLOAT_EQ(combined.green(), 0.2f); @@ -711,16 +711,16 @@ TEST_F(NodeInputImmediateNodeTest, StandardValueCombinationAcrossTracks) TEST_F(NodeInputImmediateNodeTest, DeleteAllKeyframesReparentsOrDeletes) { - auto *node = AddNode(); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + auto *node = add_node(); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); olive::NodeKeyframe *key_a = - AddKey(node, olive::MathNode::kParamAIn, olive::rational(0), 1.0, 0); + add_key(node, olive::MathNode::k_param_a_in, olive::Rational(0), 1.0, 0); olive::NodeKeyframe *key_b = - AddKey(node, olive::MathNode::kParamAIn, olive::rational(1), 2.0, 0); + add_key(node, olive::MathNode::k_param_a_in, olive::Rational(1), 2.0, 0); olive::NodeInputImmediate *imm = - node->GetImmediate(olive::MathNode::kParamAIn, -1); + node->get_immediate(olive::MathNode::k_param_a_in, -1); ASSERT_NE(imm, nullptr); ASSERT_EQ(imm->keyframe_tracks().at(0).size(), 2); diff --git a/tests/gtest/node_keyframe_test.cpp b/tests/gtest/node_keyframe_test.cpp index 2ec440e32..4e5eed934 100644 --- a/tests/gtest/node_keyframe_test.cpp +++ b/tests/gtest/node_keyframe_test.cpp @@ -11,8 +11,8 @@ TEST(NodeKeyframe, SaveLoadRoundTrip) { olive::NodeKeyframe key; key.set_input(QStringLiteral("Value")); - key.set_time(olive::core::rational(1, 24)); - key.set_type(olive::NodeKeyframe::kLinear); + key.set_time(olive::core::Rational(1, 24)); + key.set_type(olive::NodeKeyframe::k_linear); key.set_value(42.0); key.set_bezier_control_in(QPointF(0.1, 0.2)); key.set_bezier_control_out(QPointF(0.3, 0.4)); @@ -23,7 +23,7 @@ TEST(NodeKeyframe, SaveLoadRoundTrip) QXmlStreamWriter writer(&buffer); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("key")); - key.save(&writer, olive::NodeValue::kFloat); + key.save(&writer, olive::NodeValue::k_float); writer.writeEndElement(); writer.writeEndDocument(); buffer.close(); @@ -35,10 +35,10 @@ TEST(NodeKeyframe, SaveLoadRoundTrip) EXPECT_EQ(reader.name().toString(), QStringLiteral("key")); olive::NodeKeyframe loaded; - EXPECT_TRUE(loaded.load(&reader, olive::NodeValue::kFloat)); + EXPECT_TRUE(loaded.load(&reader, olive::NodeValue::k_float)); EXPECT_EQ(loaded.input(), QStringLiteral("Value")); - EXPECT_EQ(loaded.time(), olive::core::rational(1, 24)); - EXPECT_EQ(loaded.type(), olive::NodeKeyframe::kLinear); + EXPECT_EQ(loaded.time(), olive::core::Rational(1, 24)); + EXPECT_EQ(loaded.type(), olive::NodeKeyframe::k_linear); EXPECT_DOUBLE_EQ(loaded.value().toDouble(), 42.0); EXPECT_DOUBLE_EQ(loaded.bezier_control_in().x(), 0.1); EXPECT_DOUBLE_EQ(loaded.bezier_control_in().y(), 0.2); @@ -50,16 +50,16 @@ TEST(NodeKeyframe, TypeEnumeration) { using olive::NodeKeyframe; - EXPECT_NE(NodeKeyframe::kLinear, NodeKeyframe::kHold); - EXPECT_NE(NodeKeyframe::kLinear, NodeKeyframe::kBezier); + EXPECT_NE(NodeKeyframe::k_linear, NodeKeyframe::k_hold); + EXPECT_NE(NodeKeyframe::k_linear, NodeKeyframe::k_bezier); } TEST(NodeKeyframe, DefaultState) { olive::NodeKeyframe key; EXPECT_TRUE(key.input().isEmpty()); - EXPECT_EQ(key.time(), olive::core::rational(0, 1)); - EXPECT_EQ(key.type(), olive::NodeKeyframe::kLinear); + EXPECT_EQ(key.time(), olive::core::Rational(0, 1)); + EXPECT_EQ(key.type(), olive::NodeKeyframe::k_linear); EXPECT_TRUE(key.value().isNull()); } diff --git a/tests/gtest/node_math_test.cpp b/tests/gtest/node_math_test.cpp index 8b32c7feb..b7c6de69b 100644 --- a/tests/gtest/node_math_test.cpp +++ b/tests/gtest/node_math_test.cpp @@ -33,7 +33,7 @@ public: NODE_DEFAULT_FUNCTIONS(ConstantValueNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Test Constant"); } @@ -43,24 +43,24 @@ public: return QStringLiteral("org.oak.test.constant"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryMath }; + return { k_category_math }; } - void SetOutput(const olive::NodeValue &value) + void set_output(const olive::NodeValue &value) { output_ = value; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { Q_UNUSED(value) Q_UNUSED(globals) - table->Push(output_); + table->push(output_); } private: @@ -71,20 +71,20 @@ private: // non-static number path of MathNode can be verified end to end. class SampleResolvingTraverser : public olive::NodeTraverser { public: - void Resolve(olive::NodeValue &value) + void resolve(olive::NodeValue &value) { - ResolveJobs(value); + resolve_jobs(value); } protected: virtual olive::core::SampleBuffer - CreateSampleBuffer(const olive::core::AudioParams ¶ms, + create_sample_buffer(const olive::core::AudioParams ¶ms, int sample_count) override { return olive::core::SampleBuffer(params, size_t(sample_count)); } - virtual void ProcessSamples(olive::core::SampleBuffer &destination, + virtual void process_samples(olive::core::SampleBuffer &destination, const olive::Node *node, const olive::TimeRange &range, const olive::SampleJob &job) override @@ -92,48 +92,48 @@ protected: Q_UNUSED(range) for (size_t i = 0; i < destination.sample_count(); i++) { - node->ProcessSamples(job.GetValues(), job.samples(), destination, + node->process_samples(job.get_values(), job.samples(), destination, int(i)); } } }; -olive::MathNode *CreateMathNode(olive::Project *project) +olive::MathNode *create_math_node(olive::Project *project) { auto *math = new olive::MathNode(); math->setParent(project); return math; } -ConstantValueNode *CreateConstant(olive::Project *project, +ConstantValueNode *create_constant(olive::Project *project, const olive::NodeValue &value) { auto *node = new ConstantValueNode(); node->setParent(project); - node->SetOutput(value); + node->set_output(value); return node; } -olive::NodeValueTable GenerateMathTable(olive::MathNode *math) +olive::NodeValueTable generate_math_table(olive::MathNode *math) { olive::NodeTraverser traverser; - return traverser.GenerateTable( - math, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); + return traverser.generate_table( + math, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); } -olive::core::AudioParams TestAudioParams() +olive::core::AudioParams test_audio_params() { - return olive::core::AudioParams(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + return olive::core::AudioParams(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); } // Creates a stereo buffer with the given per-channel samples. Both channels // must have the same number of samples. -olive::core::SampleBuffer MakeSampleBuffer(const std::vector &channel0, +olive::core::SampleBuffer make_sample_buffer(const std::vector &channel0, const std::vector &channel1) { - olive::core::SampleBuffer buffer(TestAudioParams(), channel0.size()); + olive::core::SampleBuffer buffer(test_audio_params(), channel0.size()); for (size_t i = 0; i < channel0.size(); i++) { buffer.data(0)[i] = channel0[i]; } @@ -143,9 +143,9 @@ olive::core::SampleBuffer MakeSampleBuffer(const std::vector &channel0, return buffer; } -olive::NodeValue SampleValue(const olive::core::SampleBuffer &buffer) +olive::NodeValue sample_value(const olive::core::SampleBuffer &buffer) { - return olive::NodeValue(olive::NodeValue::kSamples, + return olive::NodeValue(olive::NodeValue::k_samples, QVariant::fromValue(buffer)); } @@ -156,44 +156,44 @@ TEST(MathNode, MetadataIsCorrect) olive::MathNode unparented; EXPECT_EQ(unparented.id(), QStringLiteral("org.olivevideoeditor.Olive.math")); - EXPECT_FALSE(unparented.Description().isEmpty()); + EXPECT_FALSE(unparented.description().isEmpty()); EXPECT_TRUE( - unparented.Category().contains(olive::Node::kCategoryMath)); - EXPECT_EQ(unparented.GetOperation(), olive::MathNode::kOpAdd); + unparented.category().contains(olive::Node::k_category_math)); + EXPECT_EQ(unparented.get_operation(), olive::MathNode::k_op_add); // Without a parent the node is just called "Math" - EXPECT_EQ(unparented.Name(), QStringLiteral("Math")); + EXPECT_EQ(unparented.name(), QStringLiteral("Math")); // Parented nodes are named after their operation - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - EXPECT_EQ(math->Name(), QStringLiteral("Add")); + olive::MathNode *math = create_math_node(&project); + EXPECT_EQ(math->name(), QStringLiteral("Add")); - math->SetOperation(olive::MathNode::kOpSubtract); - EXPECT_EQ(math->GetOperation(), olive::MathNode::kOpSubtract); - EXPECT_EQ(math->Name(), QStringLiteral("Subtract")); + math->set_operation(olive::MathNode::k_op_subtract); + EXPECT_EQ(math->get_operation(), olive::MathNode::k_op_subtract); + EXPECT_EQ(math->name(), QStringLiteral("Subtract")); } TEST(MathNode, OperationNames) { - EXPECT_EQ(olive::MathNodeBase::GetOperationName(olive::MathNode::kOpAdd), + EXPECT_EQ(olive::MathNodeBase::get_operation_name(olive::MathNode::k_op_add), QStringLiteral("Add")); EXPECT_EQ( - olive::MathNodeBase::GetOperationName(olive::MathNode::kOpSubtract), + olive::MathNodeBase::get_operation_name(olive::MathNode::k_op_subtract), QStringLiteral("Subtract")); EXPECT_EQ( - olive::MathNodeBase::GetOperationName(olive::MathNode::kOpMultiply), + olive::MathNodeBase::get_operation_name(olive::MathNode::k_op_multiply), QStringLiteral("Multiply")); - EXPECT_EQ(olive::MathNodeBase::GetOperationName(olive::MathNode::kOpDivide), + EXPECT_EQ(olive::MathNodeBase::get_operation_name(olive::MathNode::k_op_divide), QStringLiteral("Divide")); - EXPECT_EQ(olive::MathNodeBase::GetOperationName(olive::MathNode::kOpPower), + EXPECT_EQ(olive::MathNodeBase::get_operation_name(olive::MathNode::k_op_power), QStringLiteral("Power")); // Out-of-range operations produce an empty name - EXPECT_TRUE(olive::MathNodeBase::GetOperationName( + EXPECT_TRUE(olive::MathNodeBase::get_operation_name( static_cast(-1)) .isEmpty()); } @@ -201,17 +201,17 @@ TEST(MathNode, OperationNames) TEST(MathNode, RetranslateSetsInputNamesAndComboStrings) { olive::MathNode math; - math.Retranslate(); + math.retranslate(); - EXPECT_EQ(math.GetInputName(olive::MathNode::kMethodIn), + EXPECT_EQ(math.get_input_name(olive::MathNode::k_method_in), QStringLiteral("Method")); - EXPECT_EQ(math.GetInputName(olive::MathNode::kParamAIn), + EXPECT_EQ(math.get_input_name(olive::MathNode::k_param_a_in), QStringLiteral("Value")); - EXPECT_EQ(math.GetInputName(olive::MathNode::kParamBIn), + EXPECT_EQ(math.get_input_name(olive::MathNode::k_param_b_in), QStringLiteral("Value")); const QStringList operations = - math.GetInputProperty(olive::MathNode::kMethodIn, + math.get_input_property(olive::MathNode::k_method_in, QStringLiteral("combo_str")) .toStringList(); ASSERT_EQ(operations.size(), 5); @@ -226,122 +226,122 @@ TEST(MathNode, RetranslateSetsInputNamesAndComboStrings) TEST(MathNode, AddNumbers) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpAdd); - math->SetStandardValue(olive::MathNode::kParamAIn, 2.0); - math->SetStandardValue(olive::MathNode::kParamBIn, 3.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_add); + math->set_standard_value(olive::MathNode::k_param_a_in, 2.0); + math->set_standard_value(olive::MathNode::k_param_b_in, 3.0); - olive::NodeValueTable table = GenerateMathTable(math); - EXPECT_FLOAT_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 5.0); + olive::NodeValueTable table = generate_math_table(math); + EXPECT_FLOAT_EQ(table.get(olive::NodeValue::k_float).to_double(), 5.0); } TEST(MathNode, SubtractNumbers) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpSubtract); - math->SetStandardValue(olive::MathNode::kParamAIn, 7.0); - math->SetStandardValue(olive::MathNode::kParamBIn, 10.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_subtract); + math->set_standard_value(olive::MathNode::k_param_a_in, 7.0); + math->set_standard_value(olive::MathNode::k_param_b_in, 10.0); - olive::NodeValueTable table = GenerateMathTable(math); - EXPECT_FLOAT_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), -3.0); + olive::NodeValueTable table = generate_math_table(math); + EXPECT_FLOAT_EQ(table.get(olive::NodeValue::k_float).to_double(), -3.0); } TEST(MathNode, MultiplyNumbers) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpMultiply); - math->SetStandardValue(olive::MathNode::kParamAIn, 2.5); - math->SetStandardValue(olive::MathNode::kParamBIn, 4.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_multiply); + math->set_standard_value(olive::MathNode::k_param_a_in, 2.5); + math->set_standard_value(olive::MathNode::k_param_b_in, 4.0); - olive::NodeValueTable table = GenerateMathTable(math); - EXPECT_FLOAT_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 10.0); + olive::NodeValueTable table = generate_math_table(math); + EXPECT_FLOAT_EQ(table.get(olive::NodeValue::k_float).to_double(), 10.0); } TEST(MathNode, DivideNumbers) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpDivide); - math->SetStandardValue(olive::MathNode::kParamAIn, 7.0); - math->SetStandardValue(olive::MathNode::kParamBIn, 2.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_divide); + math->set_standard_value(olive::MathNode::k_param_a_in, 7.0); + math->set_standard_value(olive::MathNode::k_param_b_in, 2.0); - olive::NodeValueTable table = GenerateMathTable(math); - EXPECT_FLOAT_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 3.5); + olive::NodeValueTable table = generate_math_table(math); + EXPECT_FLOAT_EQ(table.get(olive::NodeValue::k_float).to_double(), 3.5); } TEST(MathNode, PowerNumbers) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpPower); - math->SetStandardValue(olive::MathNode::kParamAIn, 2.0); - math->SetStandardValue(olive::MathNode::kParamBIn, 10.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_power); + math->set_standard_value(olive::MathNode::k_param_a_in, 2.0); + math->set_standard_value(olive::MathNode::k_param_b_in, 10.0); - olive::NodeValueTable table = GenerateMathTable(math); - EXPECT_FLOAT_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 1024.0); + olive::NodeValueTable table = generate_math_table(math); + EXPECT_FLOAT_EQ(table.get(olive::NodeValue::k_float).to_double(), 1024.0); } TEST(MathNode, DivideByZeroProducesInfinity) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpDivide); - math->SetStandardValue(olive::MathNode::kParamAIn, 1.0); - math->SetStandardValue(olive::MathNode::kParamBIn, 0.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_divide); + math->set_standard_value(olive::MathNode::k_param_a_in, 1.0); + math->set_standard_value(olive::MathNode::k_param_b_in, 0.0); - olive::NodeValueTable table = GenerateMathTable(math); - const double result = table.Get(olive::NodeValue::kFloat).toDouble(); + olive::NodeValueTable table = generate_math_table(math); + const double result = table.get(olive::NodeValue::k_float).to_double(); EXPECT_TRUE(std::isinf(result)); EXPECT_GT(result, 0.0); // 0 / 0 yields NaN - math->SetStandardValue(olive::MathNode::kParamAIn, 0.0); - table = GenerateMathTable(math); - EXPECT_TRUE(std::isnan(table.Get(olive::NodeValue::kFloat).toDouble())); + math->set_standard_value(olive::MathNode::k_param_a_in, 0.0); + table = generate_math_table(math); + EXPECT_TRUE(std::isnan(table.get(olive::NodeValue::k_float).to_double())); } TEST(MathNode, ChangingOperationChangesResult) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetStandardValue(olive::MathNode::kParamAIn, 2.0); - math->SetStandardValue(olive::MathNode::kParamBIn, 3.0); + olive::MathNode *math = create_math_node(&project); + math->set_standard_value(olive::MathNode::k_param_a_in, 2.0); + math->set_standard_value(olive::MathNode::k_param_b_in, 3.0); const olive::MathNode::Operation ops[] = { - olive::MathNode::kOpAdd, olive::MathNode::kOpSubtract, - olive::MathNode::kOpMultiply, olive::MathNode::kOpDivide, - olive::MathNode::kOpPower + olive::MathNode::k_op_add, olive::MathNode::k_op_subtract, + olive::MathNode::k_op_multiply, olive::MathNode::k_op_divide, + olive::MathNode::k_op_power }; const double expected[] = { 5.0, -1.0, 6.0, 2.0 / 3.0, 8.0 }; for (int i = 0; i < 5; i++) { - math->SetOperation(ops[i]); - olive::NodeValueTable table = GenerateMathTable(math); - EXPECT_NEAR(table.Get(olive::NodeValue::kFloat).toDouble(), expected[i], + math->set_operation(ops[i]); + olive::NodeValueTable table = generate_math_table(math); + EXPECT_NEAR(table.get(olive::NodeValue::k_float).to_double(), expected[i], 1e-6) << "Failed at operation index " << i; } @@ -349,203 +349,203 @@ TEST(MathNode, ChangingOperationChangesResult) TEST(MathNode, AddSubtractRationalsPreserveRationalType) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); + olive::MathNode *math = create_math_node(&project); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(1, 2)))); - ConstantValueNode *b = CreateConstant( + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(1, 2)))); + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(1, 4)))); + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(1, 4)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - math->SetOperation(olive::MathNode::kOpAdd); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kRational); - ASSERT_EQ(result.type(), olive::NodeValue::kRational); - EXPECT_EQ(result.toRational(), olive::core::rational(3, 4)); + math->set_operation(olive::MathNode::k_op_add); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_rational); + ASSERT_EQ(result.type(), olive::NodeValue::k_rational); + EXPECT_EQ(result.to_rational(), olive::core::Rational(3, 4)); - math->SetOperation(olive::MathNode::kOpSubtract); - table = GenerateMathTable(math); - result = table.Get(olive::NodeValue::kRational); - ASSERT_EQ(result.type(), olive::NodeValue::kRational); - EXPECT_EQ(result.toRational(), olive::core::rational(1, 4)); + math->set_operation(olive::MathNode::k_op_subtract); + table = generate_math_table(math); + result = table.get(olive::NodeValue::k_rational); + ASSERT_EQ(result.type(), olive::NodeValue::k_rational); + EXPECT_EQ(result.to_rational(), olive::core::Rational(1, 4)); } TEST(MathNode, MultiplyDivideRationalsPreserveRationalType) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); + olive::MathNode *math = create_math_node(&project); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(1, 2)))); - ConstantValueNode *b = CreateConstant( + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(1, 2)))); + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(1, 4)))); + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(1, 4)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - math->SetOperation(olive::MathNode::kOpMultiply); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kRational); - ASSERT_EQ(result.type(), olive::NodeValue::kRational); - EXPECT_EQ(result.toRational(), olive::core::rational(1, 8)); + math->set_operation(olive::MathNode::k_op_multiply); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_rational); + ASSERT_EQ(result.type(), olive::NodeValue::k_rational); + EXPECT_EQ(result.to_rational(), olive::core::Rational(1, 8)); - math->SetOperation(olive::MathNode::kOpDivide); - table = GenerateMathTable(math); - result = table.Get(olive::NodeValue::kRational); - ASSERT_EQ(result.type(), olive::NodeValue::kRational); - EXPECT_EQ(result.toRational(), olive::core::rational(2)); + math->set_operation(olive::MathNode::k_op_divide); + table = generate_math_table(math); + result = table.get(olive::NodeValue::k_rational); + ASSERT_EQ(result.type(), olive::NodeValue::k_rational); + EXPECT_EQ(result.to_rational(), olive::core::Rational(2)); } TEST(MathNode, PowerOnRationalsProducesFloat) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpPower); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_power); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(1, 2)))); - ConstantValueNode *b = CreateConstant( + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(1, 2)))); + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(2)))); + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(2)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); // Power is not supported on rationals, so the result falls back to float - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kFloat); - ASSERT_EQ(result.type(), olive::NodeValue::kFloat); - EXPECT_FLOAT_EQ(result.toDouble(), 0.25); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_float); + ASSERT_EQ(result.type(), olive::NodeValue::k_float); + EXPECT_FLOAT_EQ(result.to_double(), 0.25); } TEST(MathNode, RationalDividedByZeroProducesNaN) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpDivide); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_divide); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(1, 2)))); - ConstantValueNode *b = CreateConstant( + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(1, 2)))); + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(0)))); + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(0)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kRational); - ASSERT_EQ(result.type(), olive::NodeValue::kRational); - EXPECT_TRUE(result.toRational().isNaN()); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_rational); + ASSERT_EQ(result.type(), olive::NodeValue::k_rational); + EXPECT_TRUE(result.to_rational().isNaN()); } TEST(MathNode, MixedRationalAndFloatProducesFloat) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpAdd); - math->SetStandardValue(olive::MathNode::kParamBIn, 0.5); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_add); + math->set_standard_value(olive::MathNode::k_param_b_in, 0.5); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kRational, - QVariant::fromValue(olive::core::rational(1, 2)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::NodeValue(olive::NodeValue::k_rational, + QVariant::fromValue(olive::core::Rational(1, 2)))); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); - // Only rational+rational preserves the rational type - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kFloat); - ASSERT_EQ(result.type(), olive::NodeValue::kFloat); - EXPECT_FLOAT_EQ(result.toDouble(), 1.0); + // Only Rational+Rational preserves the Rational type + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_float); + ASSERT_EQ(result.type(), olive::NodeValue::k_float); + EXPECT_FLOAT_EQ(result.to_double(), 1.0); } TEST(MathNode, IntegerInputsProduceFloatResult) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); + olive::MathNode *math = create_math_node(&project); - ConstantValueNode *a = CreateConstant( - &project, olive::NodeValue(olive::NodeValue::kInt, int64_t(7))); - ConstantValueNode *b = CreateConstant( - &project, olive::NodeValue(olive::NodeValue::kInt, int64_t(6))); + ConstantValueNode *a = create_constant( + &project, olive::NodeValue(olive::NodeValue::k_int, int64_t(7))); + ConstantValueNode *b = create_constant( + &project, olive::NodeValue(olive::NodeValue::k_int, int64_t(6))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - math->SetOperation(olive::MathNode::kOpMultiply); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kFloat); - ASSERT_EQ(result.type(), olive::NodeValue::kFloat); - EXPECT_FLOAT_EQ(result.toDouble(), 42.0); + math->set_operation(olive::MathNode::k_op_multiply); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_float); + ASSERT_EQ(result.type(), olive::NodeValue::k_float); + EXPECT_FLOAT_EQ(result.to_double(), 42.0); // Mixed int and float - olive::Node::DisconnectEdge(b, - olive::NodeInput(math, olive::MathNode::kParamBIn)); - math->SetStandardValue(olive::MathNode::kParamBIn, 0.5); - math->SetOperation(olive::MathNode::kOpAdd); - table = GenerateMathTable(math); - EXPECT_FLOAT_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 7.5); + olive::Node::disconnect_edge(b, + olive::NodeInput(math, olive::MathNode::k_param_b_in)); + math->set_standard_value(olive::MathNode::k_param_b_in, 0.5); + math->set_operation(olive::MathNode::k_op_add); + table = generate_math_table(math); + EXPECT_FLOAT_EQ(table.get(olive::NodeValue::k_float).to_double(), 7.5); } TEST(MathNode, AddVectorsPromotesToLargerType) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpAdd); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_add); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec2, QVector2D(1.0f, 2.0f))); - ConstantValueNode *b = CreateConstant( + olive::NodeValue(olive::NodeValue::k_vec2, QVector2D(1.0f, 2.0f))); + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec3, + olive::NodeValue(olive::NodeValue::k_vec3, QVector3D(10.0f, 20.0f, 30.0f))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec3); - ASSERT_EQ(result.type(), olive::NodeValue::kVec3); - const QVector3D vec = result.toVec3(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec3); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec3); + const QVector3D vec = result.to_vec3(); EXPECT_FLOAT_EQ(vec.x(), 11.0f); EXPECT_FLOAT_EQ(vec.y(), 22.0f); EXPECT_FLOAT_EQ(vec.z(), 30.0f); @@ -553,29 +553,29 @@ TEST(MathNode, AddVectorsPromotesToLargerType) TEST(MathNode, SubtractVec4) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpSubtract); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_subtract); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec4, + olive::NodeValue(olive::NodeValue::k_vec4, QVector4D(5.0f, 7.0f, 9.0f, 11.0f))); - ConstantValueNode *b = CreateConstant( + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec4, + olive::NodeValue(olive::NodeValue::k_vec4, QVector4D(1.0f, 2.0f, 3.0f, 4.0f))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec4); - ASSERT_EQ(result.type(), olive::NodeValue::kVec4); - const QVector4D vec = result.toVec4(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec4); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec4); + const QVector4D vec = result.to_vec4(); EXPECT_FLOAT_EQ(vec.x(), 4.0f); EXPECT_FLOAT_EQ(vec.y(), 5.0f); EXPECT_FLOAT_EQ(vec.z(), 6.0f); @@ -584,85 +584,85 @@ TEST(MathNode, SubtractVec4) TEST(MathNode, MultiplyDivideVectorsComponentwise) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); + olive::MathNode *math = create_math_node(&project); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec2, QVector2D(2.0f, 3.0f))); - ConstantValueNode *b = CreateConstant( + olive::NodeValue(olive::NodeValue::k_vec2, QVector2D(2.0f, 3.0f))); + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec2, QVector2D(4.0f, 5.0f))); + olive::NodeValue(olive::NodeValue::k_vec2, QVector2D(4.0f, 5.0f))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - math->SetOperation(olive::MathNode::kOpMultiply); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec2); - ASSERT_EQ(result.type(), olive::NodeValue::kVec2); - EXPECT_FLOAT_EQ(result.toVec2().x(), 8.0f); - EXPECT_FLOAT_EQ(result.toVec2().y(), 15.0f); + math->set_operation(olive::MathNode::k_op_multiply); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec2); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec2); + EXPECT_FLOAT_EQ(result.to_vec2().x(), 8.0f); + EXPECT_FLOAT_EQ(result.to_vec2().y(), 15.0f); - math->SetOperation(olive::MathNode::kOpDivide); - table = GenerateMathTable(math); - result = table.Get(olive::NodeValue::kVec2); - ASSERT_EQ(result.type(), olive::NodeValue::kVec2); - EXPECT_FLOAT_EQ(result.toVec2().x(), 0.5f); - EXPECT_FLOAT_EQ(result.toVec2().y(), 0.6f); + math->set_operation(olive::MathNode::k_op_divide); + table = generate_math_table(math); + result = table.get(olive::NodeValue::k_vec2); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec2); + EXPECT_FLOAT_EQ(result.to_vec2().x(), 0.5f); + EXPECT_FLOAT_EQ(result.to_vec2().y(), 0.6f); } TEST(MathNode, VectorPowerReturnsFirstInputUnchanged) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpPower); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_power); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec2, QVector2D(2.0f, 3.0f))); - ConstantValueNode *b = CreateConstant( + olive::NodeValue(olive::NodeValue::k_vec2, QVector2D(2.0f, 3.0f))); + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec2, QVector2D(4.0f, 5.0f))); + olive::NodeValue(olive::NodeValue::k_vec2, QVector2D(4.0f, 5.0f))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); // Power is not implemented for vector/vector, the first vector is // returned unchanged - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec2); - ASSERT_EQ(result.type(), olive::NodeValue::kVec2); - EXPECT_FLOAT_EQ(result.toVec2().x(), 2.0f); - EXPECT_FLOAT_EQ(result.toVec2().y(), 3.0f); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec2); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec2); + EXPECT_FLOAT_EQ(result.to_vec2().x(), 2.0f); + EXPECT_FLOAT_EQ(result.to_vec2().y(), 3.0f); } TEST(MathNode, MultiplyVectorByNumber) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpMultiply); - math->SetStandardValue(olive::MathNode::kParamBIn, 2.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_multiply); + math->set_standard_value(olive::MathNode::k_param_b_in, 2.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec4, + olive::NodeValue(olive::NodeValue::k_vec4, QVector4D(1.0f, 2.0f, 3.0f, 4.0f))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec4); - ASSERT_EQ(result.type(), olive::NodeValue::kVec4); - const QVector4D vec = result.toVec4(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec4); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec4); + const QVector4D vec = result.to_vec4(); EXPECT_FLOAT_EQ(vec.x(), 2.0f); EXPECT_FLOAT_EQ(vec.y(), 4.0f); EXPECT_FLOAT_EQ(vec.z(), 6.0f); @@ -671,24 +671,24 @@ TEST(MathNode, MultiplyVectorByNumber) TEST(MathNode, DivideVectorByNumber) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpDivide); - math->SetStandardValue(olive::MathNode::kParamBIn, 2.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_divide); + math->set_standard_value(olive::MathNode::k_param_b_in, 2.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec3, + olive::NodeValue(olive::NodeValue::k_vec3, QVector3D(2.0f, 4.0f, 6.0f))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec3); - ASSERT_EQ(result.type(), olive::NodeValue::kVec3); - const QVector3D vec = result.toVec3(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec3); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec3); + const QVector3D vec = result.to_vec3(); EXPECT_FLOAT_EQ(vec.x(), 1.0f); EXPECT_FLOAT_EQ(vec.y(), 2.0f); EXPECT_FLOAT_EQ(vec.z(), 3.0f); @@ -696,51 +696,51 @@ TEST(MathNode, DivideVectorByNumber) TEST(MathNode, AddVectorAndNumberIsNoOp) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpAdd); - math->SetStandardValue(olive::MathNode::kParamBIn, 5.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_add); + math->set_standard_value(olive::MathNode::k_param_b_in, 5.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec2, QVector2D(1.0f, 2.0f))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::NodeValue(olive::NodeValue::k_vec2, QVector2D(1.0f, 2.0f))); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); // Only multiply/divide are implemented for vector+number; add returns // the vector unchanged - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec2); - ASSERT_EQ(result.type(), olive::NodeValue::kVec2); - EXPECT_FLOAT_EQ(result.toVec2().x(), 1.0f); - EXPECT_FLOAT_EQ(result.toVec2().y(), 2.0f); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec2); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec2); + EXPECT_FLOAT_EQ(result.to_vec2().x(), 1.0f); + EXPECT_FLOAT_EQ(result.to_vec2().y(), 2.0f); } TEST(MathNode, NumberTimesVectorScalesVector) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpMultiply); - math->SetStandardValue(olive::MathNode::kParamAIn, 2.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_multiply); + math->set_standard_value(olive::MathNode::k_param_a_in, 2.0); - ConstantValueNode *b = CreateConstant( + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec4, + olive::NodeValue(olive::NodeValue::k_vec4, QVector4D(1.0f, 2.0f, 3.0f, 4.0f))); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); // With the number in parameter A and the vector in parameter B, the // number is still picked as the number operand and the vector is scaled, // mirroring MultiplyVectorByNumber with the operands swapped - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec4); - ASSERT_EQ(result.type(), olive::NodeValue::kVec4); - const QVector4D vec = result.toVec4(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec4); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec4); + const QVector4D vec = result.to_vec4(); EXPECT_FLOAT_EQ(vec.x(), 2.0f); EXPECT_FLOAT_EQ(vec.y(), 4.0f); EXPECT_FLOAT_EQ(vec.z(), 6.0f); @@ -749,30 +749,30 @@ TEST(MathNode, NumberTimesVectorScalesVector) TEST(MathNode, MultiplyMatrixByVector) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpMultiply); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_multiply); QMatrix4x4 matrix; matrix.scale(2.0f, 3.0f, 4.0f); - ConstantValueNode *a = CreateConstant( - &project, olive::NodeValue(olive::NodeValue::kMatrix, matrix)); - ConstantValueNode *b = CreateConstant( + ConstantValueNode *a = create_constant( + &project, olive::NodeValue(olive::NodeValue::k_matrix, matrix)); + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kVec4, + olive::NodeValue(olive::NodeValue::k_vec4, QVector4D(1.0f, 2.0f, 3.0f, 1.0f))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kVec4); - ASSERT_EQ(result.type(), olive::NodeValue::kVec4); - const QVector4D vec = result.toVec4(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_vec4); + ASSERT_EQ(result.type(), olive::NodeValue::k_vec4); + const QVector4D vec = result.to_vec4(); EXPECT_FLOAT_EQ(vec.x(), 2.0f); EXPECT_FLOAT_EQ(vec.y(), 6.0f); EXPECT_FLOAT_EQ(vec.z(), 12.0f); @@ -781,40 +781,40 @@ TEST(MathNode, MultiplyMatrixByVector) TEST(MathNode, MatrixMatrixAddAndMultiply) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); + olive::MathNode *math = create_math_node(&project); QMatrix4x4 mat_a; mat_a.scale(2.0f, 3.0f, 4.0f); QMatrix4x4 mat_b; mat_b.scale(3.0f, 4.0f, 5.0f); - ConstantValueNode *a = CreateConstant( - &project, olive::NodeValue(olive::NodeValue::kMatrix, mat_a)); - ConstantValueNode *b = CreateConstant( - &project, olive::NodeValue(olive::NodeValue::kMatrix, mat_b)); + ConstantValueNode *a = create_constant( + &project, olive::NodeValue(olive::NodeValue::k_matrix, mat_a)); + ConstantValueNode *b = create_constant( + &project, olive::NodeValue(olive::NodeValue::k_matrix, mat_b)); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - math->SetOperation(olive::MathNode::kOpMultiply); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kMatrix); - ASSERT_EQ(result.type(), olive::NodeValue::kMatrix); - const QMatrix4x4 product = result.toMatrix(); + math->set_operation(olive::MathNode::k_op_multiply); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_matrix); + ASSERT_EQ(result.type(), olive::NodeValue::k_matrix); + const QMatrix4x4 product = result.to_matrix(); EXPECT_FLOAT_EQ(product(0, 0), 6.0f); EXPECT_FLOAT_EQ(product(1, 1), 12.0f); EXPECT_FLOAT_EQ(product(2, 2), 20.0f); EXPECT_FLOAT_EQ(product(3, 3), 1.0f); - math->SetOperation(olive::MathNode::kOpAdd); - table = GenerateMathTable(math); - result = table.Get(olive::NodeValue::kMatrix); - ASSERT_EQ(result.type(), olive::NodeValue::kMatrix); - const QMatrix4x4 sum = result.toMatrix(); + math->set_operation(olive::MathNode::k_op_add); + table = generate_math_table(math); + result = table.get(olive::NodeValue::k_matrix); + ASSERT_EQ(result.type(), olive::NodeValue::k_matrix); + const QMatrix4x4 sum = result.to_matrix(); EXPECT_FLOAT_EQ(sum(0, 0), 5.0f); EXPECT_FLOAT_EQ(sum(1, 1), 7.0f); EXPECT_FLOAT_EQ(sum(2, 2), 9.0f); @@ -823,31 +823,31 @@ TEST(MathNode, MatrixMatrixAddAndMultiply) TEST(MathNode, MatrixDivideReturnsFirstInputUnchanged) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpDivide); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_divide); QMatrix4x4 mat_a; mat_a.scale(2.0f, 3.0f, 4.0f); QMatrix4x4 mat_b; mat_b.scale(9.0f, 9.0f, 9.0f); - ConstantValueNode *a = CreateConstant( - &project, olive::NodeValue(olive::NodeValue::kMatrix, mat_a)); - ConstantValueNode *b = CreateConstant( - &project, olive::NodeValue(olive::NodeValue::kMatrix, mat_b)); + ConstantValueNode *a = create_constant( + &project, olive::NodeValue(olive::NodeValue::k_matrix, mat_a)); + ConstantValueNode *b = create_constant( + &project, olive::NodeValue(olive::NodeValue::k_matrix, mat_b)); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); // Divide is not implemented for matrices, the first matrix is returned - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kMatrix); - ASSERT_EQ(result.type(), olive::NodeValue::kMatrix); - const QMatrix4x4 out = result.toMatrix(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_matrix); + ASSERT_EQ(result.type(), olive::NodeValue::k_matrix); + const QMatrix4x4 out = result.to_matrix(); EXPECT_FLOAT_EQ(out(0, 0), 2.0f); EXPECT_FLOAT_EQ(out(1, 1), 3.0f); EXPECT_FLOAT_EQ(out(2, 2), 4.0f); @@ -855,41 +855,41 @@ TEST(MathNode, MatrixDivideReturnsFirstInputUnchanged) TEST(MathNode, AddAndSubtractColors) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); + olive::MathNode *math = create_math_node(&project); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kColor, + olive::NodeValue(olive::NodeValue::k_color, QVariant::fromValue( olive::core::Color(0.1f, 0.2f, 0.3f, 0.4f)))); - ConstantValueNode *b = CreateConstant( + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kColor, + olive::NodeValue(olive::NodeValue::k_color, QVariant::fromValue( olive::core::Color(0.4f, 0.3f, 0.2f, 0.1f)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - math->SetOperation(olive::MathNode::kOpAdd); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kColor); - ASSERT_EQ(result.type(), olive::NodeValue::kColor); - const olive::core::Color sum = result.toColor(); + math->set_operation(olive::MathNode::k_op_add); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_color); + ASSERT_EQ(result.type(), olive::NodeValue::k_color); + const olive::core::Color sum = result.to_color(); EXPECT_FLOAT_EQ(sum.red(), 0.5f); EXPECT_FLOAT_EQ(sum.green(), 0.5f); EXPECT_FLOAT_EQ(sum.blue(), 0.5f); EXPECT_FLOAT_EQ(sum.alpha(), 0.5f); - math->SetOperation(olive::MathNode::kOpSubtract); - table = GenerateMathTable(math); - result = table.Get(olive::NodeValue::kColor); - ASSERT_EQ(result.type(), olive::NodeValue::kColor); - const olive::core::Color diff = result.toColor(); + math->set_operation(olive::MathNode::k_op_subtract); + table = generate_math_table(math); + result = table.get(olive::NodeValue::k_color); + ASSERT_EQ(result.type(), olive::NodeValue::k_color); + const olive::core::Color diff = result.to_color(); EXPECT_FLOAT_EQ(diff.red(), -0.3f); EXPECT_FLOAT_EQ(diff.green(), -0.1f); EXPECT_FLOAT_EQ(diff.blue(), 0.1f); @@ -898,33 +898,33 @@ TEST(MathNode, AddAndSubtractColors) TEST(MathNode, MultiplyColorsReturnsFirstInputUnchanged) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpMultiply); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_multiply); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kColor, + olive::NodeValue(olive::NodeValue::k_color, QVariant::fromValue( olive::core::Color(0.1f, 0.2f, 0.3f, 1.0f)))); - ConstantValueNode *b = CreateConstant( + ConstantValueNode *b = create_constant( &project, - olive::NodeValue(olive::NodeValue::kColor, + olive::NodeValue(olive::NodeValue::k_color, QVariant::fromValue( olive::core::Color(0.4f, 0.5f, 0.6f, 1.0f)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); // Only add/subtract are implemented for colors, the first color is // returned unchanged - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kColor); - ASSERT_EQ(result.type(), olive::NodeValue::kColor); - const olive::core::Color out = result.toColor(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_color); + ASSERT_EQ(result.type(), olive::NodeValue::k_color); + const olive::core::Color out = result.to_color(); EXPECT_FLOAT_EQ(out.red(), 0.1f); EXPECT_FLOAT_EQ(out.green(), 0.2f); EXPECT_FLOAT_EQ(out.blue(), 0.3f); @@ -933,25 +933,25 @@ TEST(MathNode, MultiplyColorsReturnsFirstInputUnchanged) TEST(MathNode, MultiplyColorByNumber) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpMultiply); - math->SetStandardValue(olive::MathNode::kParamBIn, 4.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_multiply); + math->set_standard_value(olive::MathNode::k_param_b_in, 4.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kColor, + olive::NodeValue(olive::NodeValue::k_color, QVariant::fromValue( olive::core::Color(0.25f, 0.5f, 0.75f, 1.0f)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kColor); - ASSERT_EQ(result.type(), olive::NodeValue::kColor); - const olive::core::Color out = result.toColor(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_color); + ASSERT_EQ(result.type(), olive::NodeValue::k_color); + const olive::core::Color out = result.to_color(); EXPECT_FLOAT_EQ(out.red(), 1.0f); EXPECT_FLOAT_EQ(out.green(), 2.0f); EXPECT_FLOAT_EQ(out.blue(), 3.0f); @@ -960,27 +960,27 @@ TEST(MathNode, MultiplyColorByNumber) TEST(MathNode, DivideColorByNumberIsNoOp) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpDivide); - math->SetStandardValue(olive::MathNode::kParamBIn, 4.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_divide); + math->set_standard_value(olive::MathNode::k_param_b_in, 4.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - olive::NodeValue(olive::NodeValue::kColor, + olive::NodeValue(olive::NodeValue::k_color, QVariant::fromValue( olive::core::Color(0.25f, 0.5f, 0.75f, 1.0f)))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); // Only multiply is implemented for color+number, the color is returned // unchanged - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kColor); - ASSERT_EQ(result.type(), olive::NodeValue::kColor); - const olive::core::Color out = result.toColor(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_color); + ASSERT_EQ(result.type(), olive::NodeValue::k_color); + const olive::core::Color out = result.to_color(); EXPECT_FLOAT_EQ(out.red(), 0.25f); EXPECT_FLOAT_EQ(out.green(), 0.5f); EXPECT_FLOAT_EQ(out.blue(), 0.75f); @@ -989,65 +989,65 @@ TEST(MathNode, DivideColorByNumberIsNoOp) TEST(MathNode, NoPairingForNoneInputLeavesInputsUntouched) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpAdd); - math->SetStandardValue(olive::MathNode::kParamAIn, 42.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_add); + math->set_standard_value(olive::MathNode::k_param_a_in, 42.0); // A kNone value has no valid pairing, so Value() returns without pushing // a result; the inputs do not leak into the output table either - ConstantValueNode *b = CreateConstant(&project, olive::NodeValue()); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + ConstantValueNode *b = create_constant(&project, olive::NodeValue()); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); - olive::NodeValueTable table = GenerateMathTable(math); - EXPECT_EQ(table.Get(olive::NodeValue::kFloat).type(), - olive::NodeValue::kNone); - EXPECT_EQ(table.Get(olive::NodeValue::kVec4).type(), - olive::NodeValue::kNone); + olive::NodeValueTable table = generate_math_table(math); + EXPECT_EQ(table.get(olive::NodeValue::k_float).type(), + olive::NodeValue::k_none); + EXPECT_EQ(table.get(olive::NodeValue::k_vec4).type(), + olive::NodeValue::k_none); } TEST(MathNode, DisabledNodeDoesNotComputeResult) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpAdd); - math->SetStandardValue(olive::MathNode::kParamAIn, 2.0); - math->SetStandardValue(olive::MathNode::kParamBIn, 3.0); - math->SetStandardValue(olive::Node::kEnabledInput, false); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_add); + math->set_standard_value(olive::MathNode::k_param_a_in, 2.0); + math->set_standard_value(olive::MathNode::k_param_b_in, 3.0); + math->set_standard_value(olive::Node::k_enabled_input, false); // The node is bypassed, so the result is one of the inputs rather than // their sum (merged input order is unspecified) - olive::NodeValueTable table = GenerateMathTable(math); - const double result = table.Get(olive::NodeValue::kFloat).toDouble(); + olive::NodeValueTable table = generate_math_table(math); + const double result = table.get(olive::NodeValue::k_float).to_double(); EXPECT_TRUE(result == 2.0 || result == 3.0); } TEST(MathNode, MultiplySamplesByStaticNumber) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpMultiply); - math->SetStandardValue(olive::MathNode::kParamBIn, 2.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_multiply); + math->set_standard_value(olive::MathNode::k_param_b_in, 2.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - SampleValue(MakeSampleBuffer({ 1.0f, 2.0f, 3.0f, 4.0f }, + sample_value(make_sample_buffer({ 1.0f, 2.0f, 3.0f, 4.0f }, { 5.0f, 6.0f, 7.0f, 8.0f }))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(result.type(), olive::NodeValue::kSamples); - const olive::core::SampleBuffer out = result.toSamples(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(result.type(), olive::NodeValue::k_samples); + const olive::core::SampleBuffer out = result.to_samples(); ASSERT_TRUE(out.is_allocated()); ASSERT_EQ(out.sample_count(), 4u); for (int i = 0; i < 4; i++) { @@ -1058,25 +1058,25 @@ TEST(MathNode, MultiplySamplesByStaticNumber) TEST(MathNode, AddZeroToSamplesIsNoOpButStillPushesBuffer) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpAdd); - math->SetStandardValue(olive::MathNode::kParamBIn, 0.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_add); + math->set_standard_value(olive::MathNode::k_param_b_in, 0.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - SampleValue(MakeSampleBuffer({ 1.0f, 2.0f, 3.0f, 4.0f }, + sample_value(make_sample_buffer({ 1.0f, 2.0f, 3.0f, 4.0f }, { 5.0f, 6.0f, 7.0f, 8.0f }))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); // Adding 0 is a no-op, but the (unmodified) buffer is still pushed - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(result.type(), olive::NodeValue::kSamples); - const olive::core::SampleBuffer out = result.toSamples(); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(result.type(), olive::NodeValue::k_samples); + const olive::core::SampleBuffer out = result.to_samples(); ASSERT_TRUE(out.is_allocated()); for (int i = 0; i < 4; i++) { EXPECT_FLOAT_EQ(out.data(0)[i], float(i + 1)); @@ -1086,23 +1086,23 @@ TEST(MathNode, AddZeroToSamplesIsNoOpButStillPushesBuffer) TEST(MathNode, DivideSamplesByZeroProducesInfinity) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpDivide); - math->SetStandardValue(olive::MathNode::kParamBIn, 0.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_divide); + math->set_standard_value(olive::MathNode::k_param_b_in, 0.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - SampleValue(MakeSampleBuffer({ 1.0f, -1.0f, 0.0f, 2.0f }, + sample_value(make_sample_buffer({ 1.0f, -1.0f, 0.0f, 2.0f }, { 1.0f, -1.0f, 0.0f, 2.0f }))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); - olive::NodeValueTable table = GenerateMathTable(math); + olive::NodeValueTable table = generate_math_table(math); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); for (int channel = 0; channel < 2; channel++) { EXPECT_TRUE(std::isinf(out.data(channel)[0])); @@ -1114,23 +1114,23 @@ TEST(MathNode, DivideSamplesByZeroProducesInfinity) TEST(MathNode, PowerSamplesByStaticNumber) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpPower); - math->SetStandardValue(olive::MathNode::kParamBIn, 2.0); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_power); + math->set_standard_value(olive::MathNode::k_param_b_in, 2.0); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - SampleValue(MakeSampleBuffer({ 1.0f, 2.0f, 3.0f, 4.0f }, + sample_value(make_sample_buffer({ 1.0f, 2.0f, 3.0f, 4.0f }, { 5.0f, 6.0f, 7.0f, 8.0f }))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); - olive::NodeValueTable table = GenerateMathTable(math); + olive::NodeValueTable table = generate_math_table(math); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); for (int i = 0; i < 4; i++) { EXPECT_FLOAT_EQ(out.data(0)[i], std::pow(float(i + 1), 2.0f)); @@ -1140,29 +1140,29 @@ TEST(MathNode, PowerSamplesByStaticNumber) TEST(MathNode, AddSampleBuffersMixesAndKeepsRemainder) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpAdd); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_add); - ConstantValueNode *a = CreateConstant( + ConstantValueNode *a = create_constant( &project, - SampleValue(MakeSampleBuffer({ 1.0f, 2.0f, 3.0f, 4.0f }, + sample_value(make_sample_buffer({ 1.0f, 2.0f, 3.0f, 4.0f }, { 5.0f, 6.0f, 7.0f, 8.0f }))); - ConstantValueNode *b = CreateConstant( + ConstantValueNode *b = create_constant( &project, - SampleValue(MakeSampleBuffer({ 10.0f, 20.0f }, { 50.0f, 60.0f }))); + sample_value(make_sample_buffer({ 10.0f, 20.0f }, { 50.0f, 60.0f }))); - olive::Node::ConnectEdge(a, olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(b, olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(a, olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(b, olive::NodeInput(math, olive::MathNode::k_param_b_in)); // The output is as long as the longer buffer: overlapping samples are // mixed, the remainder is copied from the longer buffer - olive::NodeValueTable table = GenerateMathTable(math); + olive::NodeValueTable table = generate_math_table(math); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); ASSERT_EQ(out.sample_count(), 4u); EXPECT_FLOAT_EQ(out.data(0)[0], 11.0f); @@ -1177,37 +1177,37 @@ TEST(MathNode, AddSampleBuffersMixesAndKeepsRemainder) TEST(MathNode, ConnectedNumberProducesSampleJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - olive::MathNode *math = CreateMathNode(&project); - math->SetOperation(olive::MathNode::kOpMultiply); + olive::MathNode *math = create_math_node(&project); + math->set_operation(olive::MathNode::k_op_multiply); // A connected (non-static) number produces a SampleJob instead of // processing the buffer immediately - ConstantValueNode *number = CreateConstant( - &project, olive::NodeValue(olive::NodeValue::kFloat, 3.0)); - ConstantValueNode *samples = CreateConstant( + ConstantValueNode *number = create_constant( + &project, olive::NodeValue(olive::NodeValue::k_float, 3.0)); + ConstantValueNode *samples = create_constant( &project, - SampleValue(MakeSampleBuffer({ 1.0f, 2.0f, 3.0f, 4.0f }, + sample_value(make_sample_buffer({ 1.0f, 2.0f, 3.0f, 4.0f }, { 5.0f, 6.0f, 7.0f, 8.0f }))); - olive::Node::ConnectEdge(number, - olive::NodeInput(math, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge(samples, - olive::NodeInput(math, olive::MathNode::kParamBIn)); + olive::Node::connect_edge(number, + olive::NodeInput(math, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge(samples, + olive::NodeInput(math, olive::MathNode::k_param_b_in)); - olive::NodeValueTable table = GenerateMathTable(math); - olive::NodeValue result = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(result.type(), olive::NodeValue::kSamples); + olive::NodeValueTable table = generate_math_table(math); + olive::NodeValue result = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(result.type(), olive::NodeValue::k_samples); ASSERT_TRUE(result.canConvert()); // Resolve the job on the CPU and verify the processed samples SampleResolvingTraverser resolver; - resolver.Resolve(result); + resolver.resolve(result); - const olive::core::SampleBuffer out = result.toSamples(); + const olive::core::SampleBuffer out = result.to_samples(); ASSERT_TRUE(out.is_allocated()); ASSERT_EQ(out.sample_count(), 4u); for (int i = 0; i < 4; i++) { @@ -1219,21 +1219,21 @@ TEST(MathNode, ConnectedNumberProducesSampleJob) TEST(MathNode, ProcessSamplesAppliesOperationPerSample) { olive::MathNode math; - math.SetOperation(olive::MathNode::kOpMultiply); + math.set_operation(olive::MathNode::k_op_multiply); olive::NodeValueRow row; - row.insert(olive::MathNode::kParamAIn, - olive::NodeValue(olive::NodeValue::kFloat, 3.0)); + row.insert(olive::MathNode::k_param_a_in, + olive::NodeValue(olive::NodeValue::k_float, 3.0)); - olive::core::SampleBuffer input(TestAudioParams(), 2); - olive::core::SampleBuffer output(TestAudioParams(), 2); + olive::core::SampleBuffer input(test_audio_params(), 2); + olive::core::SampleBuffer output(test_audio_params(), 2); input.data(0)[0] = 1.5f; input.data(0)[1] = -2.0f; input.data(1)[0] = 0.25f; input.data(1)[1] = 8.0f; - math.ProcessSamples(row, input, output, 0); - math.ProcessSamples(row, input, output, 1); + math.process_samples(row, input, output, 0); + math.process_samples(row, input, output, 1); EXPECT_FLOAT_EQ(output.data(0)[0], 4.5f); EXPECT_FLOAT_EQ(output.data(0)[1], -6.0f); @@ -1244,18 +1244,18 @@ TEST(MathNode, ProcessSamplesAppliesOperationPerSample) TEST(MathNode, ProcessSamplesUsesSecondParamWhenFirstMissing) { olive::MathNode math; - math.SetOperation(olive::MathNode::kOpSubtract); + math.set_operation(olive::MathNode::k_op_subtract); olive::NodeValueRow row; - row.insert(olive::MathNode::kParamBIn, - olive::NodeValue(olive::NodeValue::kFloat, 4.0)); + row.insert(olive::MathNode::k_param_b_in, + olive::NodeValue(olive::NodeValue::k_float, 4.0)); - olive::core::SampleBuffer input(TestAudioParams(), 1); - olive::core::SampleBuffer output(TestAudioParams(), 1); + olive::core::SampleBuffer input(test_audio_params(), 1); + olive::core::SampleBuffer output(test_audio_params(), 1); input.data(0)[0] = 10.0f; input.data(1)[0] = 1.0f; - math.ProcessSamples(row, input, output, 0); + math.process_samples(row, input, output, 0); EXPECT_FLOAT_EQ(output.data(0)[0], 6.0f); EXPECT_FLOAT_EQ(output.data(1)[0], -3.0f); @@ -1264,18 +1264,18 @@ TEST(MathNode, ProcessSamplesUsesSecondParamWhenFirstMissing) TEST(MathNode, ProcessSamplesWithoutNumberLeavesOutputUntouched) { olive::MathNode math; - math.SetOperation(olive::MathNode::kOpMultiply); + math.set_operation(olive::MathNode::k_op_multiply); // Neither parameter carries a number: output must not be written olive::NodeValueRow row; - olive::core::SampleBuffer input(TestAudioParams(), 1); - olive::core::SampleBuffer output(TestAudioParams(), 1); + olive::core::SampleBuffer input(test_audio_params(), 1); + olive::core::SampleBuffer output(test_audio_params(), 1); input.data(0)[0] = 10.0f; output.data(0)[0] = 123.0f; output.data(1)[0] = 45.0f; - math.ProcessSamples(row, input, output, 0); + math.process_samples(row, input, output, 0); EXPECT_FLOAT_EQ(output.data(0)[0], 123.0f); EXPECT_FLOAT_EQ(output.data(1)[0], 45.0f); @@ -1286,7 +1286,7 @@ TEST(MathNode, ShaderCodeForNumberAdd) olive::MathNode math; const olive::ShaderCode code = - math.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("0.0.2.2"))); + math.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("0.0.2.2"))); EXPECT_TRUE(code.vert_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains( @@ -1303,7 +1303,7 @@ TEST(MathNode, ShaderCodeForTextureNumberPower) // kOpPower / kPairTextureNumber / kTexture / kFloat const olive::ShaderCode code = - math.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("4.8.10.2"))); + math.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("4.8.10.2"))); EXPECT_TRUE(code.vert_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains( @@ -1320,7 +1320,7 @@ TEST(MathNode, ShaderCodeForColorPairUsesVec4Uniforms) // kOpAdd / kPairColorColor / kColor / kColor const olive::ShaderCode code = - math.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("0.7.5.5"))); + math.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("0.7.5.5"))); EXPECT_TRUE(code.vert_code().isEmpty()); EXPECT_TRUE(code.frag_code().contains( @@ -1337,7 +1337,7 @@ TEST(MathNode, ShaderCodeForTextureMatrixMultiplyHasVertexShader) // kOpMultiply / kPairTextureMatrix / kTexture / kMatrix olive::ShaderCode code = - math.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("2.10.10.6"))); + math.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("2.10.10.6"))); EXPECT_TRUE(code.frag_code().contains( QStringLiteral("texture(param_a_in, ove_texcoord)"))); @@ -1347,7 +1347,7 @@ TEST(MathNode, ShaderCodeForTextureMatrixMultiplyHasVertexShader) QStringLiteral("gl_Position = param_b_in * a_position;"))); // Reversed operand order swaps the roles of the parameters - code = math.GetShaderCode( + code = math.get_shader_code( olive::Node::ShaderRequest(QStringLiteral("2.10.6.10"))); EXPECT_TRUE(code.frag_code().contains( diff --git a/tests/gtest/node_math_transition_test.cpp b/tests/gtest/node_math_transition_test.cpp index 61dd87655..caeb53956 100644 --- a/tests/gtest/node_math_transition_test.cpp +++ b/tests/gtest/node_math_transition_test.cpp @@ -26,27 +26,27 @@ namespace { -constexpr double kPi = 3.14159265358979323846; +constexpr double k_pi = 3.14159265358979323846; // A "dummy" texture has no renderer backend and is therefore safe to pass // around in a headless, CPU-only test. olive::TexturePtr -MakeDummyTexture(int channels = olive::VideoParams::kRGBAChannelCount) +make_dummy_texture(int channels = olive::VideoParams::k_rgba_channel_count) { return std::make_shared( - olive::VideoParams(64, 64, olive::core::PixelFormat::F32, channels)); + olive::VideoParams(64, 64, olive::core::PixelFormat::f32, channels)); } -olive::core::AudioParams TestAudioParams() +olive::core::AudioParams test_audio_params() { - return olive::core::AudioParams(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + return olive::core::AudioParams(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); } // Stereo buffer with every sample in both channels set to the same value -olive::core::SampleBuffer MakeConstantBuffer(float value, size_t sample_count) +olive::core::SampleBuffer make_constant_buffer(float value, size_t sample_count) { - olive::core::SampleBuffer buffer(TestAudioParams(), sample_count); + olive::core::SampleBuffer buffer(test_audio_params(), sample_count); for (size_t i = 0; i < sample_count; i++) { buffer.data(0)[i] = value; buffer.data(1)[i] = value; @@ -54,33 +54,33 @@ olive::core::SampleBuffer MakeConstantBuffer(float value, size_t sample_count) return buffer; } -olive::NodeValue SampleValue(const olive::core::SampleBuffer &buffer) +olive::NodeValue sample_value(const olive::core::SampleBuffer &buffer) { - return olive::NodeValue(olive::NodeValue::kSamples, + return olive::NodeValue(olive::NodeValue::k_samples, QVariant::fromValue(buffer)); } // Globals for the audio path of TransitionBlock::Value, mixing over [in, out) -olive::NodeGlobals AudioGlobals(const olive::core::rational &in, - const olive::core::rational &out) +olive::NodeGlobals audio_globals(const olive::core::Rational &in, + const olive::core::Rational &out) { - return olive::NodeGlobals(olive::VideoParams(), TestAudioParams(), + return olive::NodeGlobals(olive::VideoParams(), test_audio_params(), olive::TimeRange(in, out), - olive::LoopMode::kLoopModeOff); + olive::LoopMode::k_loop_mode_off); } // A fresh traverser per call: NodeTraverser caches tables per node/range, so // reusing one would return stale results after changing standard values. -double GenerateTrigResult(olive::TrigonometryNode *node) +double generate_trig_result(olive::TrigonometryNode *node) { olive::NodeTraverser traverser; - olive::NodeValueTable table = traverser.GenerateTable( - node, olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); - return table.Get(olive::NodeValue::kFloat).toDouble(); + olive::NodeValueTable table = traverser.generate_table( + node, olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); + return table.get(olive::NodeValue::k_float).to_double(); } -template T *AddNode(olive::Project *project) +template T *add_node(olive::Project *project) { T *node = new T(); node->setParent(project); @@ -95,7 +95,7 @@ public: NODE_DEFAULT_FUNCTIONS(GlobalsProbeNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Globals Probe"); } @@ -105,12 +105,12 @@ public: return QStringLiteral("org.oak.test.globalsprobe"); } - virtual QVector Category() const override + virtual QVector category() const override { return {}; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { @@ -118,7 +118,7 @@ public: last_vparams_ = globals.vparams(); last_aparams_ = globals.aparams(); - table->Push(olive::NodeValue::kFloat, 0.0, this); + table->push(olive::NodeValue::k_float, 0.0, this); } const olive::VideoParams &last_vparams() const @@ -148,40 +148,40 @@ TEST(TrigonometryNode, MetadataIsCorrect) EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.trigonometry")); - EXPECT_EQ(node.Name(), QStringLiteral("Trigonometry")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryMath)); + EXPECT_EQ(node.name(), QStringLiteral("Trigonometry")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_math)); - EXPECT_EQ(int(node.GetInputDataType(olive::TrigonometryNode::kMethodIn)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(int(node.GetInputDataType(olive::TrigonometryNode::kXIn)), - int(olive::NodeValue::kFloat)); + EXPECT_EQ(int(node.get_input_data_type(olive::TrigonometryNode::k_method_in)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(int(node.get_input_data_type(olive::TrigonometryNode::k_x_in)), + int(olive::NodeValue::k_float)); // Method defaults to sine, value defaults to zero - EXPECT_EQ(node.GetStandardValue(olive::TrigonometryNode::kMethodIn).toInt(), + EXPECT_EQ(node.get_standard_value(olive::TrigonometryNode::k_method_in).toInt(), 0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::TrigonometryNode::kXIn).toDouble(), 0.0); + node.get_standard_value(olive::TrigonometryNode::k_x_in).toDouble(), 0.0); // The method is a static UI choice: neither connectable nor keyframable EXPECT_FALSE( - node.IsInputConnectable(olive::TrigonometryNode::kMethodIn)); + node.is_input_connectable(olive::TrigonometryNode::k_method_in)); EXPECT_FALSE( - node.IsInputKeyframable(olive::TrigonometryNode::kMethodIn)); + node.is_input_keyframable(olive::TrigonometryNode::k_method_in)); } TEST(TrigonometryNode, RetranslateSetsInputNamesAndComboStrings) { olive::TrigonometryNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::TrigonometryNode::kMethodIn), + EXPECT_EQ(node.get_input_name(olive::TrigonometryNode::k_method_in), QStringLiteral("Method")); - EXPECT_EQ(node.GetInputName(olive::TrigonometryNode::kXIn), + EXPECT_EQ(node.get_input_name(olive::TrigonometryNode::k_x_in), QStringLiteral("Value")); const QStringList methods = - node.GetInputProperty(olive::TrigonometryNode::kMethodIn, + node.get_input_property(olive::TrigonometryNode::k_method_in, QStringLiteral("combo_str")) .toStringList(); ASSERT_EQ(methods.size(), 9); @@ -201,90 +201,90 @@ TEST(TrigonometryNode, RetranslateSetsInputNamesAndComboStrings) TEST(TrigonometryNode, SineCosineTangent) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 0); - node->SetStandardValue(olive::TrigonometryNode::kXIn, kPi / 2); - EXPECT_NEAR(GenerateTrigResult(node), 1.0, 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 0); + node->set_standard_value(olive::TrigonometryNode::k_x_in, k_pi / 2); + EXPECT_NEAR(generate_trig_result(node), 1.0, 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 1); - node->SetStandardValue(olive::TrigonometryNode::kXIn, kPi); - EXPECT_NEAR(GenerateTrigResult(node), -1.0, 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 1); + node->set_standard_value(olive::TrigonometryNode::k_x_in, k_pi); + EXPECT_NEAR(generate_trig_result(node), -1.0, 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 2); - node->SetStandardValue(olive::TrigonometryNode::kXIn, kPi / 4); - EXPECT_NEAR(GenerateTrigResult(node), 1.0, 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 2); + node->set_standard_value(olive::TrigonometryNode::k_x_in, k_pi / 4); + EXPECT_NEAR(generate_trig_result(node), 1.0, 1e-12); } TEST(TrigonometryNode, InverseOperations) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 3); - node->SetStandardValue(olive::TrigonometryNode::kXIn, 1.0); - EXPECT_NEAR(GenerateTrigResult(node), kPi / 2, 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 3); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 1.0); + EXPECT_NEAR(generate_trig_result(node), k_pi / 2, 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 4); - node->SetStandardValue(olive::TrigonometryNode::kXIn, -1.0); - EXPECT_NEAR(GenerateTrigResult(node), kPi, 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 4); + node->set_standard_value(olive::TrigonometryNode::k_x_in, -1.0); + EXPECT_NEAR(generate_trig_result(node), k_pi, 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 5); - node->SetStandardValue(olive::TrigonometryNode::kXIn, 1.0); - EXPECT_NEAR(GenerateTrigResult(node), kPi / 4, 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 5); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 1.0); + EXPECT_NEAR(generate_trig_result(node), k_pi / 4, 1e-12); } TEST(TrigonometryNode, HyperbolicOperations) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TrigonometryNode::kXIn, 1.0); + auto *node = add_node(&project); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 1.0); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 6); - EXPECT_NEAR(GenerateTrigResult(node), std::sinh(1.0), 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 6); + EXPECT_NEAR(generate_trig_result(node), std::sinh(1.0), 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 7); - EXPECT_NEAR(GenerateTrigResult(node), std::cosh(1.0), 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 7); + EXPECT_NEAR(generate_trig_result(node), std::cosh(1.0), 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 8); - EXPECT_NEAR(GenerateTrigResult(node), std::tanh(1.0), 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 8); + EXPECT_NEAR(generate_trig_result(node), std::tanh(1.0), 1e-12); } TEST(TrigonometryNode, ComboIndexMatchesOperationEnum) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); // The combo list has no separator entries, so a combo index selects the // Operation enum value with the same index - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 3); - node->SetStandardValue(olive::TrigonometryNode::kXIn, 0.5); - EXPECT_NEAR(GenerateTrigResult(node), std::asin(0.5), 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 3); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 0.5); + EXPECT_NEAR(generate_trig_result(node), std::asin(0.5), 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 4); - node->SetStandardValue(olive::TrigonometryNode::kXIn, 0.5); - EXPECT_NEAR(GenerateTrigResult(node), std::acos(0.5), 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 4); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 0.5); + EXPECT_NEAR(generate_trig_result(node), std::acos(0.5), 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 6); - node->SetStandardValue(olive::TrigonometryNode::kXIn, 1.0); - EXPECT_NEAR(GenerateTrigResult(node), std::sinh(1.0), 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 6); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 1.0); + EXPECT_NEAR(generate_trig_result(node), std::sinh(1.0), 1e-12); - node->SetStandardValue(olive::TrigonometryNode::kMethodIn, 8); - node->SetStandardValue(olive::TrigonometryNode::kXIn, 1.0); - EXPECT_NEAR(GenerateTrigResult(node), std::tanh(1.0), 1e-12); + node->set_standard_value(olive::TrigonometryNode::k_method_in, 8); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 1.0); + EXPECT_NEAR(generate_trig_result(node), std::tanh(1.0), 1e-12); } // ----------------------------------------------------------------------------- @@ -296,30 +296,30 @@ TEST(MergeNode, MetadataIsCorrect) olive::MergeNode node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.merge")); - EXPECT_EQ(node.Name(), QStringLiteral("Merge")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryMath)); + EXPECT_EQ(node.name(), QStringLiteral("Merge")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_math)); - EXPECT_EQ(int(node.GetInputDataType(olive::MergeNode::kBaseIn)), - int(olive::NodeValue::kTexture)); - EXPECT_EQ(int(node.GetInputDataType(olive::MergeNode::kBlendIn)), - int(olive::NodeValue::kTexture)); + EXPECT_EQ(int(node.get_input_data_type(olive::MergeNode::k_base_in)), + int(olive::NodeValue::k_texture)); + EXPECT_EQ(int(node.get_input_data_type(olive::MergeNode::k_blend_in)), + int(olive::NodeValue::k_texture)); // Textures cannot be keyframed, and the merge node is an internal // compositing building block hidden from the param view - EXPECT_FALSE(node.IsInputKeyframable(olive::MergeNode::kBaseIn)); - EXPECT_FALSE(node.IsInputKeyframable(olive::MergeNode::kBlendIn)); - EXPECT_TRUE(node.GetFlags() & olive::Node::kDontShowInParamView); + EXPECT_FALSE(node.is_input_keyframable(olive::MergeNode::k_base_in)); + EXPECT_FALSE(node.is_input_keyframable(olive::MergeNode::k_blend_in)); + EXPECT_TRUE(node.get_flags() & olive::Node::k_dont_show_in_param_view); } TEST(MergeNode, RetranslateSetsInputNames) { olive::MergeNode node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::MergeNode::kBaseIn), + EXPECT_EQ(node.get_input_name(olive::MergeNode::k_base_in), QStringLiteral("Base")); - EXPECT_EQ(node.GetInputName(olive::MergeNode::kBlendIn), + EXPECT_EQ(node.get_input_name(olive::MergeNode::k_blend_in), QStringLiteral("Blend")); } @@ -328,7 +328,7 @@ TEST(MergeNode, ShaderCodeLoadsAlphaOver) olive::MergeNode node; const olive::ShaderCode code = - node.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("x"))); + node.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("x"))); EXPECT_FALSE(code.frag_code().isEmpty()); } @@ -337,39 +337,39 @@ TEST(MergeNode, ValueWithNoTexturesPushesNothing) olive::MergeNode node; olive::NodeValueTable table; - node.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + node.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } TEST(MergeNode, ValueWithOnlyBasePassesBaseThrough) { olive::MergeNode node; - olive::TexturePtr base = MakeDummyTexture(); + olive::TexturePtr base = make_dummy_texture(); olive::NodeValueRow row; - row.insert(olive::MergeNode::kBaseIn, - olive::NodeValue(olive::NodeValue::kTexture, base)); + row.insert(olive::MergeNode::k_base_in, + olive::NodeValue(olive::NodeValue::k_texture, base)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - EXPECT_EQ(table.Get(olive::NodeValue::kTexture).toTexture(), base); + EXPECT_EQ(table.get(olive::NodeValue::k_texture).to_texture(), base); } TEST(MergeNode, ValueWithOnlyBlendPassesBlendThrough) { olive::MergeNode node; - olive::TexturePtr blend = MakeDummyTexture(); + olive::TexturePtr blend = make_dummy_texture(); olive::NodeValueRow row; - row.insert(olive::MergeNode::kBlendIn, - olive::NodeValue(olive::NodeValue::kTexture, blend)); + row.insert(olive::MergeNode::k_blend_in, + olive::NodeValue(olive::NodeValue::k_texture, blend)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - EXPECT_EQ(table.Get(olive::NodeValue::kTexture).toTexture(), blend); + EXPECT_EQ(table.get(olive::NodeValue::k_texture).to_texture(), blend); } TEST(MergeNode, ValueWithRgbBlendPassesBlendThrough) @@ -378,43 +378,43 @@ TEST(MergeNode, ValueWithRgbBlendPassesBlendThrough) // An RGB blend texture has no alpha channel, so alpha-over is skipped // and the blend passes through even when a base is present - olive::TexturePtr base = MakeDummyTexture(); - olive::TexturePtr blend = MakeDummyTexture(3); + olive::TexturePtr base = make_dummy_texture(); + olive::TexturePtr blend = make_dummy_texture(3); olive::NodeValueRow row; - row.insert(olive::MergeNode::kBaseIn, - olive::NodeValue(olive::NodeValue::kTexture, base)); - row.insert(olive::MergeNode::kBlendIn, - olive::NodeValue(olive::NodeValue::kTexture, blend)); + row.insert(olive::MergeNode::k_base_in, + olive::NodeValue(olive::NodeValue::k_texture, base)); + row.insert(olive::MergeNode::k_blend_in, + olive::NodeValue(olive::NodeValue::k_texture, blend)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - EXPECT_EQ(table.Get(olive::NodeValue::kTexture).toTexture(), blend); + EXPECT_EQ(table.get(olive::NodeValue::k_texture).to_texture(), blend); } TEST(MergeNode, ValueWithBaseAndRgbaBlendPushesAlphaOverJob) { olive::MergeNode node; - olive::TexturePtr base = MakeDummyTexture(); - olive::TexturePtr blend = MakeDummyTexture(); + olive::TexturePtr base = make_dummy_texture(); + olive::TexturePtr blend = make_dummy_texture(); olive::NodeValueRow row; - row.insert(olive::MergeNode::kBaseIn, - olive::NodeValue(olive::NodeValue::kTexture, base)); - row.insert(olive::MergeNode::kBlendIn, - olive::NodeValue(olive::NodeValue::kTexture, blend)); + row.insert(olive::MergeNode::k_base_in, + olive::NodeValue(olive::NodeValue::k_texture, base)); + row.insert(olive::MergeNode::k_blend_in, + olive::NodeValue(olive::NodeValue::k_texture, blend)); olive::NodeValueTable table; - node.Value(row, olive::NodeGlobals(), &table); + node.value(row, olive::NodeGlobals(), &table); - olive::TexturePtr out = table.Get(olive::NodeValue::kTexture).toTexture(); + olive::TexturePtr out = table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(out); - ASSERT_TRUE(out->IsJob()); + ASSERT_TRUE(out->is_job()); auto *job = dynamic_cast(out->job()); ASSERT_TRUE(job); - EXPECT_EQ(job->Get(olive::MergeNode::kBaseIn).toTexture(), base); - EXPECT_EQ(job->Get(olive::MergeNode::kBlendIn).toTexture(), blend); + EXPECT_EQ(job->get(olive::MergeNode::k_base_in).to_texture(), base); + EXPECT_EQ(job->get(olive::MergeNode::k_blend_in).to_texture(), blend); // The job texture inherits the base texture's parameters EXPECT_EQ(out->params().width(), base->params().width()); @@ -431,46 +431,46 @@ TEST(TransitionBlock, MetadataIsCorrect) olive::CrossDissolveTransition cross; EXPECT_EQ(cross.id(), QStringLiteral("org.olivevideoeditor.Olive.crossdissolve")); - EXPECT_EQ(cross.Name(), QStringLiteral("Cross Dissolve")); - EXPECT_FALSE(cross.Description().isEmpty()); - EXPECT_TRUE(cross.Category().contains(olive::Node::kCategoryTransition)); + EXPECT_EQ(cross.name(), QStringLiteral("Cross Dissolve")); + EXPECT_FALSE(cross.description().isEmpty()); + EXPECT_TRUE(cross.category().contains(olive::Node::k_category_transition)); olive::DipToColorTransition dip; EXPECT_EQ(dip.id(), QStringLiteral("org.olivevideoeditor.Olive.diptocolor")); - EXPECT_EQ(dip.Name(), QStringLiteral("Dip To Color")); - EXPECT_FALSE(dip.Description().isEmpty()); - EXPECT_TRUE(dip.Category().contains(olive::Node::kCategoryTransition)); + EXPECT_EQ(dip.name(), QStringLiteral("Dip To Color")); + EXPECT_FALSE(dip.description().isEmpty()); + EXPECT_TRUE(dip.category().contains(olive::Node::k_category_transition)); - EXPECT_EQ(int(cross.GetInputDataType( - olive::TransitionBlock::kOutBlockInput)), - int(olive::NodeValue::kNone)); - EXPECT_EQ(int(cross.GetInputDataType( - olive::TransitionBlock::kInBlockInput)), - int(olive::NodeValue::kNone)); + EXPECT_EQ(int(cross.get_input_data_type( + olive::TransitionBlock::k_out_block_input)), + int(olive::NodeValue::k_none)); + EXPECT_EQ(int(cross.get_input_data_type( + olive::TransitionBlock::k_in_block_input)), + int(olive::NodeValue::k_none)); EXPECT_EQ( - int(cross.GetInputDataType(olive::TransitionBlock::kCurveInput)), - int(olive::NodeValue::kCombo)); + int(cross.get_input_data_type(olive::TransitionBlock::k_curve_input)), + int(olive::NodeValue::k_combo)); EXPECT_EQ( - int(cross.GetInputDataType(olive::TransitionBlock::kCenterInput)), - int(olive::NodeValue::kRational)); + int(cross.get_input_data_type(olive::TransitionBlock::k_center_input)), + int(olive::NodeValue::k_rational)); // The curve is a static UI choice defaulting to linear EXPECT_FALSE( - cross.IsInputConnectable(olive::TransitionBlock::kCurveInput)); + cross.is_input_connectable(olive::TransitionBlock::k_curve_input)); EXPECT_FALSE( - cross.IsInputKeyframable(olive::TransitionBlock::kCurveInput)); - EXPECT_EQ(cross.GetStandardValue(olive::TransitionBlock::kCurveInput) + cross.is_input_keyframable(olive::TransitionBlock::k_curve_input)); + EXPECT_EQ(cross.get_standard_value(olive::TransitionBlock::k_curve_input) .toInt(), 0); - EXPECT_EQ(cross.offset_center(), olive::core::rational(0)); + EXPECT_EQ(cross.offset_center(), olive::core::Rational(0)); // Blocks hide from the param view by default, transitions re-enable it - EXPECT_FALSE(cross.GetFlags() & olive::Node::kDontShowInParamView); + EXPECT_FALSE(cross.get_flags() & olive::Node::k_dont_show_in_param_view); // Dip To Color adds a color parameter defaulting to black const olive::core::Color color = - dip.GetStandardValue(olive::DipToColorTransition::kColorInput) + dip.get_standard_value(olive::DipToColorTransition::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 0.0f); EXPECT_FLOAT_EQ(color.green(), 0.0f); @@ -480,19 +480,19 @@ TEST(TransitionBlock, MetadataIsCorrect) TEST(TransitionBlock, RetranslateSetsInputNamesAndCurveStrings) { olive::CrossDissolveTransition cross; - cross.Retranslate(); + cross.retranslate(); - EXPECT_EQ(cross.GetInputName(olive::TransitionBlock::kOutBlockInput), + EXPECT_EQ(cross.get_input_name(olive::TransitionBlock::k_out_block_input), QStringLiteral("From")); - EXPECT_EQ(cross.GetInputName(olive::TransitionBlock::kInBlockInput), + EXPECT_EQ(cross.get_input_name(olive::TransitionBlock::k_in_block_input), QStringLiteral("To")); - EXPECT_EQ(cross.GetInputName(olive::TransitionBlock::kCurveInput), + EXPECT_EQ(cross.get_input_name(olive::TransitionBlock::k_curve_input), QStringLiteral("Curve")); - EXPECT_EQ(cross.GetInputName(olive::TransitionBlock::kCenterInput), + EXPECT_EQ(cross.get_input_name(olive::TransitionBlock::k_center_input), QStringLiteral("Center Offset")); const QStringList curves = - cross.GetInputProperty(olive::TransitionBlock::kCurveInput, + cross.get_input_property(olive::TransitionBlock::k_curve_input, QStringLiteral("combo_str")) .toStringList(); ASSERT_EQ(curves.size(), 3); @@ -501,8 +501,8 @@ TEST(TransitionBlock, RetranslateSetsInputNamesAndCurveStrings) EXPECT_EQ(curves.at(2), QStringLiteral("Logarithmic")); olive::DipToColorTransition dip; - dip.Retranslate(); - EXPECT_EQ(dip.GetInputName(olive::DipToColorTransition::kColorInput), + dip.retranslate(); + EXPECT_EQ(dip.get_input_name(olive::DipToColorTransition::k_color_input), QStringLiteral("Color")); } @@ -510,13 +510,13 @@ TEST(TransitionBlock, ShaderCodeLoadsTransitionShaders) { olive::CrossDissolveTransition cross; EXPECT_FALSE( - cross.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("x"))) + cross.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("x"))) .frag_code() .isEmpty()); olive::DipToColorTransition dip; EXPECT_FALSE( - dip.GetShaderCode(olive::Node::ShaderRequest(QStringLiteral("x"))) + dip.get_shader_code(olive::Node::ShaderRequest(QStringLiteral("x"))) .frag_code() .isEmpty()); } @@ -524,299 +524,299 @@ TEST(TransitionBlock, ShaderCodeLoadsTransitionShaders) TEST(TransitionBlock, OffsetsWithoutConnectedBlocksAreZero) { olive::CrossDissolveTransition trans; - trans.set_length_and_media_out(olive::core::rational(2)); + trans.set_length_and_media_out(olive::core::Rational(2)); EXPECT_FALSE(trans.is_dual_transition()); EXPECT_EQ(trans.connected_out_block(), nullptr); EXPECT_EQ(trans.connected_in_block(), nullptr); - EXPECT_EQ(trans.in_offset(), olive::core::rational(0)); - EXPECT_EQ(trans.out_offset(), olive::core::rational(0)); + EXPECT_EQ(trans.in_offset(), olive::core::Rational(0)); + EXPECT_EQ(trans.out_offset(), olive::core::Rational(0)); // With zero offsets only the total progress is meaningful - EXPECT_DOUBLE_EQ(trans.GetTotalProgress(0.5), 0.25); - EXPECT_DOUBLE_EQ(trans.GetOutProgress(0.5), 0.0); - EXPECT_DOUBLE_EQ(trans.GetInProgress(0.5), 0.0); + EXPECT_DOUBLE_EQ(trans.get_total_progress(0.5), 0.25); + EXPECT_DOUBLE_EQ(trans.get_out_progress(0.5), 0.0); + EXPECT_DOUBLE_EQ(trans.get_in_progress(0.5), 0.0); } TEST(TransitionBlock, DualTransitionOffsetsAndProgress) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *trans = AddNode(&project); - auto *out_clip = AddNode(&project); - auto *in_clip = AddNode(&project); + auto *trans = add_node(&project); + auto *out_clip = add_node(&project); + auto *in_clip = add_node(&project); - trans->set_length_and_media_out(olive::core::rational(2)); + trans->set_length_and_media_out(olive::core::Rational(2)); - olive::Node::ConnectEdge( + olive::Node::connect_edge( out_clip, - olive::NodeInput(trans, olive::TransitionBlock::kOutBlockInput)); - olive::Node::ConnectEdge( - in_clip, olive::NodeInput(trans, olive::TransitionBlock::kInBlockInput)); + olive::NodeInput(trans, olive::TransitionBlock::k_out_block_input)); + olive::Node::connect_edge( + in_clip, olive::NodeInput(trans, olive::TransitionBlock::k_in_block_input)); ASSERT_TRUE(trans->is_dual_transition()); EXPECT_EQ(trans->connected_out_block(), out_clip); EXPECT_EQ(trans->connected_in_block(), in_clip); // A centered dual transition splits its length evenly on both sides - EXPECT_EQ(trans->in_offset(), olive::core::rational(1)); - EXPECT_EQ(trans->out_offset(), olive::core::rational(1)); + EXPECT_EQ(trans->in_offset(), olive::core::Rational(1)); + EXPECT_EQ(trans->out_offset(), olive::core::Rational(1)); - EXPECT_DOUBLE_EQ(trans->GetTotalProgress(0.0), 0.0); - EXPECT_DOUBLE_EQ(trans->GetTotalProgress(0.5), 0.25); - EXPECT_DOUBLE_EQ(trans->GetTotalProgress(1.5), 0.75); + EXPECT_DOUBLE_EQ(trans->get_total_progress(0.0), 0.0); + EXPECT_DOUBLE_EQ(trans->get_total_progress(0.5), 0.25); + EXPECT_DOUBLE_EQ(trans->get_total_progress(1.5), 0.75); // Out progress runs from 1 to 0 over the out offset - EXPECT_DOUBLE_EQ(trans->GetOutProgress(0.0), 1.0); - EXPECT_DOUBLE_EQ(trans->GetOutProgress(0.5), 0.5); - EXPECT_DOUBLE_EQ(trans->GetOutProgress(1.5), 0.0); + EXPECT_DOUBLE_EQ(trans->get_out_progress(0.0), 1.0); + EXPECT_DOUBLE_EQ(trans->get_out_progress(0.5), 0.5); + EXPECT_DOUBLE_EQ(trans->get_out_progress(1.5), 0.0); // In progress runs from 0 to 1 over the in offset and is clamped - EXPECT_DOUBLE_EQ(trans->GetInProgress(0.5), 0.0); - EXPECT_DOUBLE_EQ(trans->GetInProgress(1.5), 0.5); - EXPECT_DOUBLE_EQ(trans->GetInProgress(2.5), 1.0); + EXPECT_DOUBLE_EQ(trans->get_in_progress(0.5), 0.0); + EXPECT_DOUBLE_EQ(trans->get_in_progress(1.5), 0.5); + EXPECT_DOUBLE_EQ(trans->get_in_progress(2.5), 1.0); } TEST(TransitionBlock, OffsetCenterShiftsInOutOffsets) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *trans = AddNode(&project); - auto *out_clip = AddNode(&project); - auto *in_clip = AddNode(&project); + auto *trans = add_node(&project); + auto *out_clip = add_node(&project); + auto *in_clip = add_node(&project); - trans->set_length_and_media_out(olive::core::rational(2)); - olive::Node::ConnectEdge( + trans->set_length_and_media_out(olive::core::Rational(2)); + olive::Node::connect_edge( out_clip, - olive::NodeInput(trans, olive::TransitionBlock::kOutBlockInput)); - olive::Node::ConnectEdge( - in_clip, olive::NodeInput(trans, olive::TransitionBlock::kInBlockInput)); + olive::NodeInput(trans, olive::TransitionBlock::k_out_block_input)); + olive::Node::connect_edge( + in_clip, olive::NodeInput(trans, olive::TransitionBlock::k_in_block_input)); - trans->set_offset_center(olive::core::rational(1, 2)); - EXPECT_EQ(trans->offset_center(), olive::core::rational(1, 2)); + trans->set_offset_center(olive::core::Rational(1, 2)); + EXPECT_EQ(trans->offset_center(), olive::core::Rational(1, 2)); // A positive center offset moves the midpoint towards the out clip - EXPECT_EQ(trans->in_offset(), olive::core::rational(3, 2)); - EXPECT_EQ(trans->out_offset(), olive::core::rational(1, 2)); + EXPECT_EQ(trans->in_offset(), olive::core::Rational(3, 2)); + EXPECT_EQ(trans->out_offset(), olive::core::Rational(1, 2)); - EXPECT_DOUBLE_EQ(trans->GetOutProgress(0.25), 0.5); - EXPECT_DOUBLE_EQ(trans->GetInProgress(1.25), 0.5); + EXPECT_DOUBLE_EQ(trans->get_out_progress(0.25), 0.5); + EXPECT_DOUBLE_EQ(trans->get_in_progress(1.25), 0.5); } TEST(TransitionBlock, SingleSidedTransitionOffsets) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); // Only an outgoing clip: the whole length is the out offset (fade out) - auto *out_trans = AddNode(&project); - auto *out_clip = AddNode(&project); - out_trans->set_length_and_media_out(olive::core::rational(2)); - olive::Node::ConnectEdge( + auto *out_trans = add_node(&project); + auto *out_clip = add_node(&project); + out_trans->set_length_and_media_out(olive::core::Rational(2)); + olive::Node::connect_edge( out_clip, - olive::NodeInput(out_trans, olive::TransitionBlock::kOutBlockInput)); + olive::NodeInput(out_trans, olive::TransitionBlock::k_out_block_input)); EXPECT_FALSE(out_trans->is_dual_transition()); - EXPECT_EQ(out_trans->out_offset(), olive::core::rational(2)); - EXPECT_EQ(out_trans->in_offset(), olive::core::rational(0)); - EXPECT_DOUBLE_EQ(out_trans->GetOutProgress(1.0), 0.5); - EXPECT_DOUBLE_EQ(out_trans->GetInProgress(1.0), 0.0); + EXPECT_EQ(out_trans->out_offset(), olive::core::Rational(2)); + EXPECT_EQ(out_trans->in_offset(), olive::core::Rational(0)); + EXPECT_DOUBLE_EQ(out_trans->get_out_progress(1.0), 0.5); + EXPECT_DOUBLE_EQ(out_trans->get_in_progress(1.0), 0.0); // Only an incoming clip: the whole length is the in offset (fade in) - auto *in_trans = AddNode(&project); - auto *in_clip = AddNode(&project); - in_trans->set_length_and_media_out(olive::core::rational(2)); - olive::Node::ConnectEdge( + auto *in_trans = add_node(&project); + auto *in_clip = add_node(&project); + in_trans->set_length_and_media_out(olive::core::Rational(2)); + olive::Node::connect_edge( in_clip, - olive::NodeInput(in_trans, olive::TransitionBlock::kInBlockInput)); + olive::NodeInput(in_trans, olive::TransitionBlock::k_in_block_input)); EXPECT_FALSE(in_trans->is_dual_transition()); - EXPECT_EQ(in_trans->in_offset(), olive::core::rational(2)); - EXPECT_EQ(in_trans->out_offset(), olive::core::rational(0)); - EXPECT_DOUBLE_EQ(in_trans->GetInProgress(1.0), 0.5); - EXPECT_DOUBLE_EQ(in_trans->GetOutProgress(1.0), 0.0); + EXPECT_EQ(in_trans->in_offset(), olive::core::Rational(2)); + EXPECT_EQ(in_trans->out_offset(), olive::core::Rational(0)); + EXPECT_DOUBLE_EQ(in_trans->get_in_progress(1.0), 0.5); + EXPECT_DOUBLE_EQ(in_trans->get_out_progress(1.0), 0.0); } TEST(TransitionBlock, SetOffsetsAndLengthSetsLengthAndCenter) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *trans = AddNode(&project); - auto *out_clip = AddNode(&project); - auto *in_clip = AddNode(&project); - olive::Node::ConnectEdge( + auto *trans = add_node(&project); + auto *out_clip = add_node(&project); + auto *in_clip = add_node(&project); + olive::Node::connect_edge( out_clip, - olive::NodeInput(trans, olive::TransitionBlock::kOutBlockInput)); - olive::Node::ConnectEdge( - in_clip, olive::NodeInput(trans, olive::TransitionBlock::kInBlockInput)); + olive::NodeInput(trans, olive::TransitionBlock::k_out_block_input)); + olive::Node::connect_edge( + in_clip, olive::NodeInput(trans, olive::TransitionBlock::k_in_block_input)); - trans->set_offsets_and_length(olive::core::rational(1, 4), - olive::core::rational(3, 4)); + trans->set_offsets_and_length(olive::core::Rational(1, 4), + olive::core::Rational(3, 4)); // The length is always the sum of both offsets - EXPECT_EQ(trans->length(), olive::core::rational(1)); - EXPECT_EQ(trans->offset_center(), olive::core::rational(1, 4)); + EXPECT_EQ(trans->length(), olive::core::Rational(1)); + EXPECT_EQ(trans->offset_center(), olive::core::Rational(1, 4)); // The offset arguments are named from the adjoining clips' perspective // (OTIO convention): the in_offset argument describes the overlap with // the previous clip, which is the transition's out side - EXPECT_EQ(trans->out_offset(), olive::core::rational(1, 4)); - EXPECT_EQ(trans->in_offset(), olive::core::rational(3, 4)); + EXPECT_EQ(trans->out_offset(), olive::core::Rational(1, 4)); + EXPECT_EQ(trans->in_offset(), olive::core::Rational(3, 4)); } TEST(TransitionBlock, ConnectAndDisconnectUpdateLinkedClips) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *trans = AddNode(&project); - auto *clip = AddNode(&project); + auto *trans = add_node(&project); + auto *clip = add_node(&project); - olive::Node::ConnectEdge( - clip, olive::NodeInput(trans, olive::TransitionBlock::kOutBlockInput)); + olive::Node::connect_edge( + clip, olive::NodeInput(trans, olive::TransitionBlock::k_out_block_input)); EXPECT_EQ(trans->connected_out_block(), clip); EXPECT_EQ(clip->out_transition(), trans); - olive::Node::DisconnectEdge( - clip, olive::NodeInput(trans, olive::TransitionBlock::kOutBlockInput)); + olive::Node::disconnect_edge( + clip, olive::NodeInput(trans, olive::TransitionBlock::k_out_block_input)); EXPECT_EQ(trans->connected_out_block(), nullptr); EXPECT_EQ(clip->out_transition(), nullptr); // Connecting a node that is not a clip leaves the linked block null - auto *not_a_clip = AddNode(&project); - olive::Node::ConnectEdge( + auto *not_a_clip = add_node(&project); + olive::Node::connect_edge( not_a_clip, - olive::NodeInput(trans, olive::TransitionBlock::kOutBlockInput)); + olive::NodeInput(trans, olive::TransitionBlock::k_out_block_input)); EXPECT_EQ(trans->connected_out_block(), nullptr); - olive::Node::DisconnectEdge( + olive::Node::disconnect_edge( not_a_clip, - olive::NodeInput(trans, olive::TransitionBlock::kOutBlockInput)); + olive::NodeInput(trans, olive::TransitionBlock::k_out_block_input)); } TEST(TransitionBlock, TextureValuePushesJobWithTransitionProgress) { olive::CrossDissolveTransition trans; - trans.set_length_and_media_out(olive::core::rational(2)); + trans.set_length_and_media_out(olive::core::Rational(2)); - olive::TexturePtr out_tex = MakeDummyTexture(); - olive::TexturePtr in_tex = MakeDummyTexture(); + olive::TexturePtr out_tex = make_dummy_texture(); + olive::TexturePtr in_tex = make_dummy_texture(); olive::NodeValueRow row; - row.insert(olive::TransitionBlock::kOutBlockInput, - olive::NodeValue(olive::NodeValue::kTexture, out_tex)); - row.insert(olive::TransitionBlock::kInBlockInput, - olive::NodeValue(olive::NodeValue::kTexture, in_tex)); - row.insert(olive::TransitionBlock::kCurveInput, - olive::NodeValue(olive::NodeValue::kCombo, 0)); + row.insert(olive::TransitionBlock::k_out_block_input, + olive::NodeValue(olive::NodeValue::k_texture, out_tex)); + row.insert(olive::TransitionBlock::k_in_block_input, + olive::NodeValue(olive::NodeValue::k_texture, in_tex)); + row.insert(olive::TransitionBlock::k_curve_input, + olive::NodeValue(olive::NodeValue::k_combo, 0)); // Half-way through a two second transition const olive::NodeGlobals globals( - olive::VideoParams(64, 64, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount), + olive::VideoParams(64, 64, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count), olive::core::AudioParams(), - olive::TimeRange(olive::core::rational(1), olive::core::rational(2)), - olive::LoopMode::kLoopModeOff); + olive::TimeRange(olive::core::Rational(1), olive::core::Rational(2)), + olive::LoopMode::k_loop_mode_off); olive::NodeValueTable table; - trans.Value(row, globals, &table); + trans.value(row, globals, &table); olive::TexturePtr job_tex = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(job_tex); - ASSERT_TRUE(job_tex->IsJob()); + ASSERT_TRUE(job_tex->is_job()); EXPECT_EQ(job_tex->params().width(), 64); auto *job = dynamic_cast(job_tex->job()); ASSERT_TRUE(job); - EXPECT_EQ(job->Get(olive::TransitionBlock::kOutBlockInput).toTexture(), + EXPECT_EQ(job->get(olive::TransitionBlock::k_out_block_input).to_texture(), out_tex); - EXPECT_EQ(job->Get(olive::TransitionBlock::kInBlockInput).toTexture(), + EXPECT_EQ(job->get(olive::TransitionBlock::k_in_block_input).to_texture(), in_tex); - EXPECT_EQ(job->Get(olive::TransitionBlock::kCurveInput).toInt(), 0); + EXPECT_EQ(job->get(olive::TransitionBlock::k_curve_input).to_int(), 0); // Without connected clips the in/out offsets are zero, so only the total // transition progress is meaningful - EXPECT_DOUBLE_EQ(job->Get(QStringLiteral("ove_tprog_all")).toDouble(), + EXPECT_DOUBLE_EQ(job->get(QStringLiteral("ove_tprog_all")).to_double(), 0.5); - EXPECT_DOUBLE_EQ(job->Get(QStringLiteral("ove_tprog_out")).toDouble(), + EXPECT_DOUBLE_EQ(job->get(QStringLiteral("ove_tprog_out")).to_double(), 0.0); - EXPECT_DOUBLE_EQ(job->Get(QStringLiteral("ove_tprog_in")).toDouble(), + EXPECT_DOUBLE_EQ(job->get(QStringLiteral("ove_tprog_in")).to_double(), 0.0); } TEST(TransitionBlock, TextureValueInsertsNullTextureForMissingSide) { olive::CrossDissolveTransition trans; - trans.set_length_and_media_out(olive::core::rational(2)); + trans.set_length_and_media_out(olive::core::Rational(2)); - olive::TexturePtr in_tex = MakeDummyTexture(); + olive::TexturePtr in_tex = make_dummy_texture(); olive::NodeValueRow row; - row.insert(olive::TransitionBlock::kInBlockInput, - olive::NodeValue(olive::NodeValue::kTexture, in_tex)); - row.insert(olive::TransitionBlock::kCurveInput, - olive::NodeValue(olive::NodeValue::kCombo, 0)); + row.insert(olive::TransitionBlock::k_in_block_input, + olive::NodeValue(olive::NodeValue::k_texture, in_tex)); + row.insert(olive::TransitionBlock::k_curve_input, + olive::NodeValue(olive::NodeValue::k_combo, 0)); olive::NodeValueTable table; - trans.Value(row, olive::NodeGlobals(), &table); + trans.value(row, olive::NodeGlobals(), &table); olive::TexturePtr job_tex = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(job_tex); - ASSERT_TRUE(job_tex->IsJob()); + ASSERT_TRUE(job_tex->is_job()); auto *job = dynamic_cast(job_tex->job()); ASSERT_TRUE(job); - EXPECT_EQ(job->Get(olive::TransitionBlock::kInBlockInput).toTexture(), + EXPECT_EQ(job->get(olive::TransitionBlock::k_in_block_input).to_texture(), in_tex); // The missing "from" side is still inserted, as a null texture const olive::NodeValue out_side = - job->Get(olive::TransitionBlock::kOutBlockInput); - EXPECT_EQ(out_side.type(), olive::NodeValue::kTexture); - EXPECT_TRUE(out_side.toTexture() == nullptr); + job->get(olive::TransitionBlock::k_out_block_input); + EXPECT_EQ(out_side.type(), olive::NodeValue::k_texture); + EXPECT_TRUE(out_side.to_texture() == nullptr); } TEST(TransitionBlock, DipToColorValueInsertsColorIntoJob) { olive::DipToColorTransition trans; - trans.set_length_and_media_out(olive::core::rational(2)); + trans.set_length_and_media_out(olive::core::Rational(2)); - olive::TexturePtr out_tex = MakeDummyTexture(); - olive::TexturePtr in_tex = MakeDummyTexture(); + olive::TexturePtr out_tex = make_dummy_texture(); + olive::TexturePtr in_tex = make_dummy_texture(); olive::NodeValueRow row; - row.insert(olive::TransitionBlock::kOutBlockInput, - olive::NodeValue(olive::NodeValue::kTexture, out_tex)); - row.insert(olive::TransitionBlock::kInBlockInput, - olive::NodeValue(olive::NodeValue::kTexture, in_tex)); - row.insert(olive::TransitionBlock::kCurveInput, - olive::NodeValue(olive::NodeValue::kCombo, 0)); - row.insert(olive::DipToColorTransition::kColorInput, - olive::NodeValue(olive::NodeValue::kColor, + row.insert(olive::TransitionBlock::k_out_block_input, + olive::NodeValue(olive::NodeValue::k_texture, out_tex)); + row.insert(olive::TransitionBlock::k_in_block_input, + olive::NodeValue(olive::NodeValue::k_texture, in_tex)); + row.insert(olive::TransitionBlock::k_curve_input, + olive::NodeValue(olive::NodeValue::k_combo, 0)); + row.insert(olive::DipToColorTransition::k_color_input, + olive::NodeValue(olive::NodeValue::k_color, QVariant::fromValue(olive::core::Color( 0.25f, 0.5f, 0.75f, 1.0f)))); olive::NodeValueTable table; - trans.Value(row, olive::NodeGlobals(), &table); + trans.value(row, olive::NodeGlobals(), &table); olive::TexturePtr job_tex = - table.Get(olive::NodeValue::kTexture).toTexture(); + table.get(olive::NodeValue::k_texture).to_texture(); ASSERT_TRUE(job_tex); - ASSERT_TRUE(job_tex->IsJob()); + ASSERT_TRUE(job_tex->is_job()); auto *job = dynamic_cast(job_tex->job()); ASSERT_TRUE(job); const olive::core::Color color = - job->Get(olive::DipToColorTransition::kColorInput).toColor(); + job->get(olive::DipToColorTransition::k_color_input).to_color(); EXPECT_FLOAT_EQ(color.red(), 0.25f); EXPECT_FLOAT_EQ(color.green(), 0.5f); EXPECT_FLOAT_EQ(color.blue(), 0.75f); @@ -826,27 +826,27 @@ TEST(TransitionBlock, DipToColorValueInsertsColorIntoJob) TEST(TransitionBlock, AudioValueMixesLinearCrossfade) { olive::CrossDissolveTransition trans; - trans.set_length_and_media_out(olive::core::rational(1)); + trans.set_length_and_media_out(olive::core::Rational(1)); // Half a second at 48 kHz const size_t sample_count = 24000; const olive::core::SampleBuffer from = - MakeConstantBuffer(1.0f, sample_count); - const olive::core::SampleBuffer to = MakeConstantBuffer(0.5f, sample_count); + make_constant_buffer(1.0f, sample_count); + const olive::core::SampleBuffer to = make_constant_buffer(0.5f, sample_count); olive::NodeValueRow row; - row.insert(olive::TransitionBlock::kOutBlockInput, SampleValue(from)); - row.insert(olive::TransitionBlock::kInBlockInput, SampleValue(to)); + row.insert(olive::TransitionBlock::k_out_block_input, sample_value(from)); + row.insert(olive::TransitionBlock::k_in_block_input, sample_value(to)); olive::NodeValueTable table; - trans.Value(row, - AudioGlobals(olive::core::rational(0), - olive::core::rational(1, 2)), + trans.value(row, + audio_globals(olive::core::Rational(0), + olive::core::Rational(1, 2)), &table); - const olive::NodeValue out_val = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(out_val.type(), olive::NodeValue::kSamples); - const olive::core::SampleBuffer out = out_val.toSamples(); + const olive::NodeValue out_val = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(out_val.type(), olive::NodeValue::k_samples); + const olive::core::SampleBuffer out = out_val.to_samples(); ASSERT_TRUE(out.is_allocated()); EXPECT_EQ(out.sample_count(), sample_count); @@ -860,26 +860,26 @@ TEST(TransitionBlock, AudioValueMixesLinearCrossfade) TEST(TransitionBlock, AudioValueMixesExponentialCrossfade) { olive::CrossDissolveTransition trans; - trans.set_length_and_media_out(olive::core::rational(1)); - trans.SetStandardValue(olive::TransitionBlock::kCurveInput, 1); + trans.set_length_and_media_out(olive::core::Rational(1)); + trans.set_standard_value(olive::TransitionBlock::k_curve_input, 1); const size_t sample_count = 24000; const olive::core::SampleBuffer from = - MakeConstantBuffer(1.0f, sample_count); - const olive::core::SampleBuffer to = MakeConstantBuffer(0.5f, sample_count); + make_constant_buffer(1.0f, sample_count); + const olive::core::SampleBuffer to = make_constant_buffer(0.5f, sample_count); olive::NodeValueRow row; - row.insert(olive::TransitionBlock::kOutBlockInput, SampleValue(from)); - row.insert(olive::TransitionBlock::kInBlockInput, SampleValue(to)); + row.insert(olive::TransitionBlock::k_out_block_input, sample_value(from)); + row.insert(olive::TransitionBlock::k_in_block_input, sample_value(to)); olive::NodeValueTable table; - trans.Value(row, - AudioGlobals(olive::core::rational(0), - olive::core::rational(1, 2)), + trans.value(row, + audio_globals(olive::core::Rational(0), + olive::core::Rational(1, 2)), &table); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); // The exponential curve squares the linear progress: at 25% the mix is @@ -891,26 +891,26 @@ TEST(TransitionBlock, AudioValueMixesExponentialCrossfade) TEST(TransitionBlock, AudioValueMixesLogarithmicCrossfade) { olive::CrossDissolveTransition trans; - trans.set_length_and_media_out(olive::core::rational(1)); - trans.SetStandardValue(olive::TransitionBlock::kCurveInput, 2); + trans.set_length_and_media_out(olive::core::Rational(1)); + trans.set_standard_value(olive::TransitionBlock::k_curve_input, 2); const size_t sample_count = 24000; const olive::core::SampleBuffer from = - MakeConstantBuffer(1.0f, sample_count); - const olive::core::SampleBuffer to = MakeConstantBuffer(0.5f, sample_count); + make_constant_buffer(1.0f, sample_count); + const olive::core::SampleBuffer to = make_constant_buffer(0.5f, sample_count); olive::NodeValueRow row; - row.insert(olive::TransitionBlock::kOutBlockInput, SampleValue(from)); - row.insert(olive::TransitionBlock::kInBlockInput, SampleValue(to)); + row.insert(olive::TransitionBlock::k_out_block_input, sample_value(from)); + row.insert(olive::TransitionBlock::k_in_block_input, sample_value(to)); olive::NodeValueTable table; - trans.Value(row, - AudioGlobals(olive::core::rational(0), - olive::core::rational(1, 2)), + trans.value(row, + audio_globals(olive::core::Rational(0), + olive::core::Rational(1, 2)), &table); const olive::core::SampleBuffer out = - table.Get(olive::NodeValue::kSamples).toSamples(); + table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(out.is_allocated()); // The logarithmic curve square-roots the linear progress: at 25% the mix @@ -923,41 +923,41 @@ TEST(TransitionBlock, AudioValueWithSingleSideFades) { // Only a "from" buffer: fade out olive::CrossDissolveTransition fade_out; - fade_out.set_length_and_media_out(olive::core::rational(1)); + fade_out.set_length_and_media_out(olive::core::Rational(1)); const size_t sample_count = 24000; olive::NodeValueRow out_row; - out_row.insert(olive::TransitionBlock::kOutBlockInput, - SampleValue(MakeConstantBuffer(1.0f, sample_count))); + out_row.insert(olive::TransitionBlock::k_out_block_input, + sample_value(make_constant_buffer(1.0f, sample_count))); olive::NodeValueTable out_table; - fade_out.Value(out_row, - AudioGlobals(olive::core::rational(0), - olive::core::rational(1, 2)), + fade_out.value(out_row, + audio_globals(olive::core::Rational(0), + olive::core::Rational(1, 2)), &out_table); const olive::core::SampleBuffer faded_out = - out_table.Get(olive::NodeValue::kSamples).toSamples(); + out_table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(faded_out.is_allocated()); EXPECT_FLOAT_EQ(faded_out.data(0)[0], 1.0f); EXPECT_FLOAT_EQ(faded_out.data(0)[12000], 0.75f); // Only a "to" buffer: fade in olive::CrossDissolveTransition fade_in; - fade_in.set_length_and_media_out(olive::core::rational(1)); + fade_in.set_length_and_media_out(olive::core::Rational(1)); olive::NodeValueRow in_row; - in_row.insert(olive::TransitionBlock::kInBlockInput, - SampleValue(MakeConstantBuffer(0.5f, sample_count))); + in_row.insert(olive::TransitionBlock::k_in_block_input, + sample_value(make_constant_buffer(0.5f, sample_count))); olive::NodeValueTable in_table; - fade_in.Value(in_row, - AudioGlobals(olive::core::rational(0), - olive::core::rational(1, 2)), + fade_in.value(in_row, + audio_globals(olive::core::Rational(0), + olive::core::Rational(1, 2)), &in_table); const olive::core::SampleBuffer faded_in = - in_table.Get(olive::NodeValue::kSamples).toSamples(); + in_table.get(olive::NodeValue::k_samples).to_samples(); ASSERT_TRUE(faded_in.is_allocated()); EXPECT_FLOAT_EQ(faded_in.data(0)[0], 0.0f); EXPECT_FLOAT_EQ(faded_in.data(0)[12000], 0.125f); @@ -966,12 +966,12 @@ TEST(TransitionBlock, AudioValueWithSingleSideFades) TEST(TransitionBlock, ValueWithNoInputsPushesNothing) { olive::CrossDissolveTransition trans; - trans.set_length_and_media_out(olive::core::rational(1)); + trans.set_length_and_media_out(olive::core::Rational(1)); olive::NodeValueTable table; - trans.Value(olive::NodeValueRow(), olive::NodeGlobals(), &table); + trans.value(olive::NodeValueRow(), olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } // ----------------------------------------------------------------------------- @@ -984,55 +984,55 @@ TEST(SubtitleBlock, MetadataIsCorrect) EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.subtitle")); - EXPECT_EQ(node.Name(), QStringLiteral("Subtitle")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryTimeline)); + EXPECT_EQ(node.name(), QStringLiteral("Subtitle")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_timeline)); } TEST(SubtitleBlock, NameFollowsText) { olive::SubtitleBlock node; - EXPECT_TRUE(node.GetText().isEmpty()); - EXPECT_EQ(node.Name(), QStringLiteral("Subtitle")); + EXPECT_TRUE(node.get_text().isEmpty()); + EXPECT_EQ(node.name(), QStringLiteral("Subtitle")); - node.SetText(QStringLiteral("Hello World")); - EXPECT_EQ(node.GetText(), QStringLiteral("Hello World")); - EXPECT_EQ(node.Name(), QStringLiteral("Hello World")); + node.set_text(QStringLiteral("Hello World")); + EXPECT_EQ(node.get_text(), QStringLiteral("Hello World")); + EXPECT_EQ(node.name(), QStringLiteral("Hello World")); - node.SetText(QString()); - EXPECT_EQ(node.Name(), QStringLiteral("Subtitle")); + node.set_text(QString()); + EXPECT_EQ(node.name(), QStringLiteral("Subtitle")); } TEST(SubtitleBlock, TextInputFlagsAndHiddenClipInputs) { olive::SubtitleBlock node; - EXPECT_EQ(int(node.GetInputDataType(olive::SubtitleBlock::kTextIn)), - int(olive::NodeValue::kText)); + EXPECT_EQ(int(node.get_input_data_type(olive::SubtitleBlock::k_text_in)), + int(olive::NodeValue::k_text)); // The text is edited inline: neither connectable nor keyframable - EXPECT_FALSE(node.IsInputConnectable(olive::SubtitleBlock::kTextIn)); - EXPECT_FALSE(node.IsInputKeyframable(olive::SubtitleBlock::kTextIn)); + EXPECT_FALSE(node.is_input_connectable(olive::SubtitleBlock::k_text_in)); + EXPECT_FALSE(node.is_input_keyframable(olive::SubtitleBlock::k_text_in)); // The inherited clip inputs are meaningless for a subtitle and hidden - EXPECT_TRUE(node.IsInputHidden(olive::ClipBlock::kBufferIn)); - EXPECT_TRUE(node.IsInputHidden(olive::Block::kLengthInput)); - EXPECT_TRUE(node.IsInputHidden(olive::ClipBlock::kMediaInInput)); - EXPECT_TRUE(node.IsInputHidden(olive::ClipBlock::kSpeedInput)); - EXPECT_TRUE(node.IsInputHidden(olive::ClipBlock::kReverseInput)); - EXPECT_TRUE(node.IsInputHidden(olive::ClipBlock::kMaintainAudioPitchInput)); + EXPECT_TRUE(node.is_input_hidden(olive::ClipBlock::k_buffer_in)); + EXPECT_TRUE(node.is_input_hidden(olive::Block::k_length_input)); + EXPECT_TRUE(node.is_input_hidden(olive::ClipBlock::k_media_in_input)); + EXPECT_TRUE(node.is_input_hidden(olive::ClipBlock::k_speed_input)); + EXPECT_TRUE(node.is_input_hidden(olive::ClipBlock::k_reverse_input)); + EXPECT_TRUE(node.is_input_hidden(olive::ClipBlock::k_maintain_audio_pitch_input)); // Blocks hide from the param view by default, subtitles re-enable it - EXPECT_FALSE(node.GetFlags() & olive::Node::kDontShowInParamView); + EXPECT_FALSE(node.get_flags() & olive::Node::k_dont_show_in_param_view); } TEST(SubtitleBlock, RetranslateSetsInputName) { olive::SubtitleBlock node; - node.Retranslate(); + node.retranslate(); - EXPECT_EQ(node.GetInputName(olive::SubtitleBlock::kTextIn), + EXPECT_EQ(node.get_input_name(olive::SubtitleBlock::k_text_in), QStringLiteral("Text")); } @@ -1042,23 +1042,23 @@ TEST(SubtitleBlock, RetranslateSetsInputName) TEST(NodeTraverser, GenerateTablePassesCacheParamsToNodeGlobals) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *probe = AddNode(&project); + auto *probe = add_node(&project); olive::NodeTraverser traverser; - traverser.SetCacheVideoParams( - olive::VideoParams(1920, 1080, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount)); - traverser.SetCacheAudioParams( - olive::core::AudioParams(44100, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P)); + traverser.set_cache_video_params( + olive::VideoParams(1920, 1080, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count)); + traverser.set_cache_audio_params( + olive::core::AudioParams(44100, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p)); - traverser.GenerateTable(probe, - olive::TimeRange(olive::core::rational(0), - olive::core::rational(1, 30))); + traverser.generate_table(probe, + olive::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 30))); EXPECT_EQ(probe->last_vparams().width(), 1920); EXPECT_EQ(probe->last_vparams().height(), 1080); @@ -1067,37 +1067,37 @@ TEST(NodeTraverser, GenerateTablePassesCacheParamsToNodeGlobals) TEST(NodeTraverser, GenerateTableCachesResultsPerNodeAndRange) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TrigonometryNode::kXIn, 1.0); + auto *node = add_node(&project); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 1.0); - const olive::TimeRange range(olive::core::rational(0), - olive::core::rational(1, 30)); + const olive::TimeRange range(olive::core::Rational(0), + olive::core::Rational(1, 30)); olive::NodeTraverser traverser; const double first = - traverser.GenerateTable(node, range) - .Get(olive::NodeValue::kFloat) - .toDouble(); + traverser.generate_table(node, range) + .get(olive::NodeValue::k_float) + .to_double(); EXPECT_NEAR(first, std::sin(1.0), 1e-12); // The same traverser returns the cached table for the same node and // range, even after the node's inputs change - node->SetStandardValue(olive::TrigonometryNode::kXIn, 0.0); + node->set_standard_value(olive::TrigonometryNode::k_x_in, 0.0); const double cached = - traverser.GenerateTable(node, range) - .Get(olive::NodeValue::kFloat) - .toDouble(); + traverser.generate_table(node, range) + .get(olive::NodeValue::k_float) + .to_double(); EXPECT_DOUBLE_EQ(cached, first); // A fresh traverser recomputes olive::NodeTraverser fresh; const double updated = - fresh.GenerateTable(node, range) - .Get(olive::NodeValue::kFloat) - .toDouble(); + fresh.generate_table(node, range) + .get(olive::NodeValue::k_float) + .to_double(); EXPECT_DOUBLE_EQ(updated, 0.0); } diff --git a/tests/gtest/node_polygon_folder_test.cpp b/tests/gtest/node_polygon_folder_test.cpp index 34c571573..7f2052091 100644 --- a/tests/gtest/node_polygon_folder_test.cpp +++ b/tests/gtest/node_polygon_folder_test.cpp @@ -42,7 +42,7 @@ public: NODE_DEFAULT_FUNCTIONS(ConstantTextureNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Test Texture"); } @@ -52,71 +52,71 @@ public: return QStringLiteral("org.oak.test.constant_texture"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryGenerator }; + return { k_category_generator }; } - void SetTexture(const olive::TexturePtr &texture) + void set_texture(const olive::TexturePtr &texture) { texture_ = texture; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { Q_UNUSED(value) Q_UNUSED(globals) - table->Push(olive::NodeValue(olive::NodeValue::kTexture, texture_, this)); + table->push(olive::NodeValue(olive::NodeValue::k_texture, texture_, this)); } private: olive::TexturePtr texture_; }; -template T *AddNode(olive::Project *project) +template T *add_node(olive::Project *project) { T *node = new T(); node->setParent(project); return node; } -olive::TimeRange FirstFrame() +olive::TimeRange first_frame() { - return olive::TimeRange(olive::rational(0), olive::rational(1, 30)); + return olive::TimeRange(olive::Rational(0), olive::Rational(1, 30)); } // A fresh traverser per call: NodeTraverser caches tables per node/range, so // reusing one would return stale results after changing standard values. -olive::NodeValueTable GenerateTable(const olive::Node *node, +olive::NodeValueTable generate_table(const olive::Node *node, const olive::VideoParams &vparams) { olive::NodeTraverser traverser; - traverser.SetCacheVideoParams(vparams); - return traverser.GenerateTable(node, FirstFrame()); + traverser.set_cache_video_params(vparams); + return traverser.generate_table(node, first_frame()); } -olive::NodeValueRow GenerateRow(const olive::Node *node) +olive::NodeValueRow generate_row(const olive::Node *node) { olive::NodeTraverser traverser; - return traverser.GenerateRow(node, FirstFrame()); + return traverser.generate_row(node, first_frame()); } -olive::TexturePtr GetOutputTexture(const olive::NodeValueTable &table) +olive::TexturePtr get_output_texture(const olive::NodeValueTable &table) { - return table.Get(olive::NodeValue::kTexture).toTexture(); + return table.get(olive::NodeValue::k_texture).to_texture(); } // Project save/load touches the DiskManager singleton, which itself touches Core -void EnsureAppSingletons() +void ensure_app_singletons() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } @@ -126,34 +126,34 @@ TEST(Folder, MetadataAndChildInputDefinition) { olive::Folder folder; EXPECT_EQ(folder.id(), QStringLiteral("org.olivevideoeditor.Olive.folder")); - EXPECT_EQ(folder.Name(), QStringLiteral("Folder")); - EXPECT_FALSE(folder.Description().isEmpty()); - EXPECT_TRUE(folder.Category().contains(olive::Node::kCategoryProject)); - EXPECT_TRUE(folder.IsItem()); + EXPECT_EQ(folder.name(), QStringLiteral("Folder")); + EXPECT_FALSE(folder.description().isEmpty()); + EXPECT_TRUE(folder.category().contains(olive::Node::k_category_project)); + EXPECT_TRUE(folder.is_item()); // The child input is a non-keyframable array that accepts any node - EXPECT_TRUE(folder.HasInputWithID(olive::Folder::kChildInput)); - EXPECT_TRUE(folder.InputIsArray(olive::Folder::kChildInput)); - EXPECT_EQ(int(folder.GetInputDataType(olive::Folder::kChildInput)), - int(olive::NodeValue::kNone)); - EXPECT_FALSE(folder.IsInputKeyframable(olive::Folder::kChildInput)); + EXPECT_TRUE(folder.has_input_with_id(olive::Folder::k_child_input)); + EXPECT_TRUE(folder.input_is_array(olive::Folder::k_child_input)); + EXPECT_EQ(int(folder.get_input_data_type(olive::Folder::k_child_input)), + int(olive::NodeValue::k_none)); + EXPECT_FALSE(folder.is_input_keyframable(olive::Folder::k_child_input)); // Folders provide their own icon; every other data type falls through to // the Node base implementation - EXPECT_TRUE(folder.data(olive::Node::ICON).isValid()); - EXPECT_FALSE(folder.data(olive::Node::TOOLTIP).isValid()); + EXPECT_TRUE(folder.data(olive::Node::icon).isValid()); + EXPECT_FALSE(folder.data(olive::Node::tooltip).isValid()); } TEST(Folder, RetranslateSetsChildInputName) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *folder = AddNode(&project); - folder->Retranslate(); + auto *folder = add_node(&project); + folder->retranslate(); - EXPECT_EQ(folder->GetInputName(olive::Folder::kChildInput), + EXPECT_EQ(folder->get_input_name(olive::Folder::k_child_input), QStringLiteral("Children")); } @@ -164,20 +164,20 @@ TEST(Folder, AddChildAppendsAndEmitsSignals) QVector inserted_indices; int insert_ends = 0; - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::Folder *folder = project.root(); - auto *child = AddNode(&project); + auto *child = add_node(&project); - QObject::connect(folder, &olive::Folder::BeginInsertItem, + QObject::connect(folder, &olive::Folder::begin_insert_item, [&inserted_items, &inserted_indices](olive::Node *n, int index) { inserted_items.append(n); inserted_indices.append(index); }); - QObject::connect(folder, &olive::Folder::EndInsertItem, + QObject::connect(folder, &olive::Folder::end_insert_item, [&insert_ends]() { ++insert_ends; }); olive::FolderAddChild(folder, child).redo_now(); @@ -204,20 +204,20 @@ TEST(Folder, AddChildUndoRemovesChildAndEmitsSignals) QVector removed_indices; int remove_ends = 0; - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::Folder *folder = project.root(); - auto *child = AddNode(&project); + auto *child = add_node(&project); - QObject::connect(folder, &olive::Folder::BeginRemoveItem, + QObject::connect(folder, &olive::Folder::begin_remove_item, [&removed_items, &removed_indices](olive::Node *n, int index) { removed_items.append(n); removed_indices.append(index); }); - QObject::connect(folder, &olive::Folder::EndRemoveItem, + QObject::connect(folder, &olive::Folder::end_remove_item, [&remove_ends]() { ++remove_ends; }); olive::FolderAddChild add(folder, child); @@ -243,18 +243,18 @@ TEST(Folder, RemoveElementCommandRemovesAndRestores) QVector removed_items; QVector removed_indices; - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::Folder *folder = project.root(); - auto *first = AddNode(&project); - auto *second = AddNode(&project); + auto *first = add_node(&project); + auto *second = add_node(&project); olive::FolderAddChild(folder, first).redo_now(); olive::FolderAddChild(folder, second).redo_now(); ASSERT_EQ(folder->item_child_count(), 2); - QObject::connect(folder, &olive::Folder::BeginRemoveItem, + QObject::connect(folder, &olive::Folder::begin_remove_item, [&removed_items, &removed_indices](olive::Node *n, int index) { removed_items.append(n); @@ -288,13 +288,13 @@ TEST(Folder, RemoveElementCommandRemovesAndRestores) TEST(Folder, RemoveElementCommandIgnoresForeignChild) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::Folder *folder = project.root(); - auto *child = AddNode(&project); - auto *stranger = AddNode(&project); + auto *child = add_node(&project); + auto *stranger = add_node(&project); olive::FolderAddChild(folder, child).redo_now(); ASSERT_EQ(folder->item_child_count(), 1); @@ -311,58 +311,58 @@ TEST(Folder, RemoveElementCommandIgnoresForeignChild) TEST(Folder, GetChildWithNameFindsNestedChildren) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::Folder *folder = project.root(); - auto *sub = AddNode(&project); - sub->SetLabel(QStringLiteral("Sub")); - auto *nested = AddNode(&project); - nested->SetLabel(QStringLiteral("Nested")); + auto *sub = add_node(&project); + sub->set_label(QStringLiteral("Sub")); + auto *nested = add_node(&project); + nested->set_label(QStringLiteral("Nested")); olive::FolderAddChild(folder, sub).redo_now(); olive::FolderAddChild(sub, nested).redo_now(); // Lookup by label recurses into subfolders - EXPECT_EQ(folder->GetChildWithName(QStringLiteral("Sub")), sub); - EXPECT_EQ(folder->GetChildWithName(QStringLiteral("Nested")), nested); - EXPECT_TRUE(folder->ChildExistsWithName(QStringLiteral("Nested"))); + EXPECT_EQ(folder->get_child_with_name(QStringLiteral("Sub")), sub); + EXPECT_EQ(folder->get_child_with_name(QStringLiteral("Nested")), nested); + EXPECT_TRUE(folder->child_exists_with_name(QStringLiteral("Nested"))); - EXPECT_EQ(folder->GetChildWithName(QStringLiteral("Missing")), nullptr); - EXPECT_FALSE(folder->ChildExistsWithName(QStringLiteral("Missing"))); + EXPECT_EQ(folder->get_child_with_name(QStringLiteral("Missing")), nullptr); + EXPECT_FALSE(folder->child_exists_with_name(QStringLiteral("Missing"))); } TEST(Folder, HasChildRecursiveFindsNestedChildren) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::Folder *folder = project.root(); - auto *sub = AddNode(&project); - auto *nested = AddNode(&project); - auto *outsider = AddNode(&project); + auto *sub = add_node(&project); + auto *nested = add_node(&project); + auto *outsider = add_node(&project); olive::FolderAddChild(folder, sub).redo_now(); olive::FolderAddChild(sub, nested).redo_now(); - EXPECT_TRUE(folder->HasChildRecursive(sub)); - EXPECT_TRUE(folder->HasChildRecursive(nested)); - EXPECT_FALSE(folder->HasChildRecursive(outsider)); - EXPECT_FALSE(folder->HasChildRecursive(folder)); + EXPECT_TRUE(folder->has_child_recursive(sub)); + EXPECT_TRUE(folder->has_child_recursive(nested)); + EXPECT_FALSE(folder->has_child_recursive(outsider)); + EXPECT_FALSE(folder->has_child_recursive(folder)); } TEST(Folder, ListChildrenOfTypeRecursesIntoSubfolders) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); olive::Folder *folder = project.root(); - auto *sub = AddNode(&project); - auto *nested = AddNode(&project); - auto *item = AddNode(&project); + auto *sub = add_node(&project); + auto *nested = add_node(&project); + auto *item = add_node(&project); olive::FolderAddChild(folder, sub).redo_now(); olive::FolderAddChild(sub, nested).redo_now(); @@ -370,56 +370,56 @@ TEST(Folder, ListChildrenOfTypeRecursesIntoSubfolders) // Folders are collected recursively while other items are skipped const QVector folders = - folder->ListChildrenOfType(); + folder->list_children_of_type(); ASSERT_EQ(folders.size(), 2); EXPECT_TRUE(folders.contains(sub)); EXPECT_TRUE(folders.contains(nested)); EXPECT_FALSE(folders.contains(static_cast(item))); const QVector solids = - folder->ListChildrenOfType(); + folder->list_children_of_type(); ASSERT_EQ(solids.size(), 1); EXPECT_EQ(solids.first(), item); } TEST(Folder, ChildStructureSurvivesSerializationRoundTrip) { - EnsureAppSingletons(); - olive::ColorManager::SetUpDefaultConfig(); - olive::NodeFactory::Initialize(); + ensure_app_singletons(); + olive::ColorManager::set_up_default_config(); + olive::NodeFactory::initialize(); // Guard against serializer instances left over by another test - olive::ProjectSerializer::Destroy(); - olive::ProjectSerializer::Initialize(); + olive::ProjectSerializer::destroy(); + olive::ProjectSerializer::initialize(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *sub = AddNode(&project); - sub->SetLabel(QStringLiteral("Sub")); + auto *sub = add_node(&project); + sub->set_label(QStringLiteral("Sub")); olive::FolderAddChild(project.root(), sub).redo_now(); - auto *nested = AddNode(&project); - nested->SetLabel(QStringLiteral("Nested")); + auto *nested = add_node(&project); + nested->set_label(QStringLiteral("Nested")); olive::FolderAddChild(sub, nested).redo_now(); olive::ProjectSerializer::SaveData save_data( - olive::ProjectSerializer::kProject, &project, QString()); + olive::ProjectSerializer::k_project, &project, QString()); QByteArray xml; QBuffer buffer(&xml); buffer.open(QIODevice::WriteOnly); QXmlStreamWriter writer(&buffer); - ASSERT_EQ(olive::ProjectSerializer::Save(&writer, save_data).code(), - olive::ProjectSerializer::kSuccess); + ASSERT_EQ(olive::ProjectSerializer::save(&writer, save_data).code(), + olive::ProjectSerializer::k_success); buffer.close(); olive::Project loaded_project; QBuffer read_buffer(&xml); read_buffer.open(QIODevice::ReadOnly); QXmlStreamReader reader(&read_buffer); - olive::ProjectSerializer::Result result = olive::ProjectSerializer::Load( - &loaded_project, &reader, olive::ProjectSerializer::kProject); - ASSERT_EQ(result.code(), olive::ProjectSerializer::kSuccess); + olive::ProjectSerializer::Result result = olive::ProjectSerializer::load( + &loaded_project, &reader, olive::ProjectSerializer::k_project); + ASSERT_EQ(result.code(), olive::ProjectSerializer::k_success); // The child connections of kChildInput are re-established on load, // rebuilding the folder hierarchy @@ -428,44 +428,44 @@ TEST(Folder, ChildStructureSurvivesSerializationRoundTrip) ASSERT_EQ(loaded_root->item_child_count(), 1); olive::Node *loaded_sub = loaded_root->item_child(0); - EXPECT_EQ(loaded_sub->GetLabel(), QStringLiteral("Sub")); + EXPECT_EQ(loaded_sub->get_label(), QStringLiteral("Sub")); EXPECT_EQ(loaded_sub->folder(), loaded_root); auto *loaded_sub_folder = dynamic_cast(loaded_sub); ASSERT_NE(loaded_sub_folder, nullptr); ASSERT_EQ(loaded_sub_folder->item_child_count(), 1); - EXPECT_EQ(loaded_sub_folder->item_child(0)->GetLabel(), + EXPECT_EQ(loaded_sub_folder->item_child(0)->get_label(), QStringLiteral("Nested")); EXPECT_EQ(loaded_sub_folder->item_child(0)->folder(), loaded_sub_folder); - EXPECT_EQ(loaded_root->GetChildWithName(QStringLiteral("Nested")), + EXPECT_EQ(loaded_root->get_child_with_name(QStringLiteral("Nested")), loaded_sub_folder->item_child(0)); EXPECT_TRUE( - loaded_root->HasChildRecursive(loaded_sub_folder->item_child(0))); + loaded_root->has_child_recursive(loaded_sub_folder->item_child(0))); - olive::ProjectSerializer::Destroy(); + olive::ProjectSerializer::destroy(); } TEST(PolygonGenerator, GenerateFrameRasterizesDefaultPentagon) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::FramePtr frame = olive::Frame::Create(); + const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params(vparams); frame->allocate(); - node->GenerateFrame(frame, olive::GenerateJob(GenerateRow(node))); + node->generate_frame(frame, olive::GenerateJob(generate_row(node))); auto pixel = [&frame](int x, int y) -> const uchar * { return reinterpret_cast(frame->data()) + y * frame->linesize_bytes() + - x * olive::VideoParams::kRGBAChannelCount; + x * olive::VideoParams::k_rgba_channel_count; }; // The pentagon is filled white: the frame center is well inside it @@ -489,26 +489,26 @@ TEST(PolygonGenerator, GenerateFrameRasterizesDefaultPentagon) TEST(PolygonGenerator, UpdateGizmoPositionsCreatesHandlesForEachPoint) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); // Only the path gizmo exists before the first update - ASSERT_EQ(node->GetGizmos().size(), 1); + ASSERT_EQ(node->get_gizmos().size(), 1); - const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count); const olive::NodeGlobals globals(vparams, olive::core::AudioParams(), - olive::rational(0), - olive::LoopMode::kLoopModeOff); + olive::Rational(0), + olive::LoopMode::k_loop_mode_off); - node->UpdateGizmoPositions(GenerateRow(node), globals); + node->update_gizmo_positions(generate_row(node), globals); // Path gizmo + one position handle, two bezier handles and two bezier // lines per point of the default pentagon - ASSERT_EQ(node->GetGizmos().size(), 1 + 5 + 10 + 10); + ASSERT_EQ(node->get_gizmos().size(), 1 + 5 + 10 + 10); // Without a base texture the gizmos are anchored at half the sequence // resolution on top of each point @@ -517,171 +517,171 @@ TEST(PolygonGenerator, UpdateGizmoPositionsCreatesHandlesForEachPoint) }; for (int i = 0; i < 5; i++) { auto *position = - static_cast(node->GetGizmos().at(1 + i)); - EXPECT_EQ(position->GetPoint(), + static_cast(node->get_gizmos().at(1 + i)); + EXPECT_EQ(position->get_point(), QPointF(expected[i][0] + 160, expected[i][1] + 120)) << "Wrong position handle for point " << i; } // Bezier handles default to the point position (zero control point offsets) - auto *bezier = static_cast(node->GetGizmos().at(6)); - EXPECT_EQ(int(bezier->GetShape()), int(olive::PointGizmo::kCircle)); - EXPECT_EQ(bezier->GetPoint(), QPointF(160, -15)); + auto *bezier = static_cast(node->get_gizmos().at(6)); + EXPECT_EQ(int(bezier->get_shape()), int(olive::PointGizmo::k_circle)); + EXPECT_EQ(bezier->get_point(), QPointF(160, -15)); - auto *line = static_cast(node->GetGizmos().at(16)); - EXPECT_EQ(line->GetLine(), QLineF(QPointF(160, -15), QPointF(160, -15))); + auto *line = static_cast(node->get_gizmos().at(16)); + EXPECT_EQ(line->get_line(), QLineF(QPointF(160, -15), QPointF(160, -15))); - auto *path = dynamic_cast(node->GetGizmos().first()); + auto *path = dynamic_cast(node->get_gizmos().first()); ASSERT_NE(path, nullptr); // moveTo plus one cubic segment (3 elements) per edge of the pentagon - EXPECT_EQ(path->GetPath().elementCount(), 16); + EXPECT_EQ(path->get_path().elementCount(), 16); // Shrinking the point array shrinks the gizmo vectors with it - node->InputArrayResize(olive::PolygonGenerator::kPointsInput, 3); - node->UpdateGizmoPositions(GenerateRow(node), globals); - EXPECT_EQ(node->GetGizmos().size(), 1 + 3 + 6 + 6); + node->input_array_resize(olive::PolygonGenerator::k_points_input, 3); + node->update_gizmo_positions(generate_row(node), globals); + EXPECT_EQ(node->get_gizmos().size(), 1 + 3 + 6 + 6); // With a base texture connected the gizmos anchor at half the texture's // virtual resolution instead of the sequence's const olive::TexturePtr base = std::make_shared( - olive::VideoParams(64, 48, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); - olive::NodeValueRow row = GenerateRow(node); - row.insert(olive::GeneratorWithMerge::kBaseInput, - olive::NodeValue(olive::NodeValue::kTexture, base)); - node->UpdateGizmoPositions(row, globals); + olive::VideoParams(64, 48, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); + olive::NodeValueRow row = generate_row(node); + row.insert(olive::GeneratorWithMerge::k_base_input, + olive::NodeValue(olive::NodeValue::k_texture, base)); + node->update_gizmo_positions(row, globals); auto *position = - static_cast(node->GetGizmos().at(1)); - EXPECT_EQ(position->GetPoint(), QPointF(32, -111)); + static_cast(node->get_gizmos().at(1)); + EXPECT_EQ(position->get_point(), QPointF(32, -111)); } TEST(PolygonGenerator, DraggingPositionGizmoUpdatesPointTracks) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - const olive::NodeValueRow row = GenerateRow(node); - node->UpdateGizmoPositions(row, olive::NodeGlobals()); - ASSERT_EQ(node->GetGizmos().size(), 26); + const olive::NodeValueRow row = generate_row(node); + node->update_gizmo_positions(row, olive::NodeGlobals()); + ASSERT_EQ(node->get_gizmos().size(), 26); // The first position handle drives the X/Y tracks of the first point - auto *gizmo = static_cast(node->GetGizmos().at(1)); - gizmo->DragStart(row, 0, 0, olive::rational(0)); - gizmo->DragMove(10, -20, Qt::NoModifier); + auto *gizmo = static_cast(node->get_gizmos().at(1)); + gizmo->drag_start(row, 0, 0, olive::Rational(0)); + gizmo->drag_move(10, -20, Qt::NoModifier); - EXPECT_DOUBLE_EQ(node->GetSplitStandardValueOnTrack( - olive::PolygonGenerator::kPointsInput, 0, 0) + EXPECT_DOUBLE_EQ(node->get_split_standard_value_on_track( + olive::PolygonGenerator::k_points_input, 0, 0) .toDouble(), 10.0); - EXPECT_DOUBLE_EQ(node->GetSplitStandardValueOnTrack( - olive::PolygonGenerator::kPointsInput, 1, 0) + EXPECT_DOUBLE_EQ(node->get_split_standard_value_on_track( + olive::PolygonGenerator::k_points_input, 1, 0) .toDouble(), -155.0); // The other points are untouched - EXPECT_DOUBLE_EQ(node->GetSplitStandardValueOnTrack( - olive::PolygonGenerator::kPointsInput, 0, 1) + EXPECT_DOUBLE_EQ(node->get_split_standard_value_on_track( + olive::PolygonGenerator::k_points_input, 0, 1) .toDouble(), 135.0); olive::MultiUndoCommand command; - gizmo->DragEnd(&command); + gizmo->drag_end(&command); } TEST(TextGeneratorV2, MetadataIsCorrect) { olive::TextGeneratorV2 node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.text2")); - EXPECT_EQ(node.Name(), QStringLiteral("Text (Legacy)")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_EQ(node.name(), QStringLiteral("Text (Legacy)")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_generator)); // Hidden from the create menu: superseded by TextGeneratorV3 - EXPECT_TRUE(node.GetFlags() & olive::Node::kDontShowInCreateMenu); + EXPECT_TRUE(node.get_flags() & olive::Node::k_dont_show_in_create_menu); } TEST(TextGeneratorV2, InputDefaults) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - EXPECT_EQ(node->GetStandardValue(olive::TextGeneratorV2::kTextInput) + EXPECT_EQ(node->get_standard_value(olive::TextGeneratorV2::k_text_input) .toString(), QStringLiteral("Sample Text")); - EXPECT_EQ(int(node->GetInputDataType(olive::TextGeneratorV2::kHtmlInput)), - int(olive::NodeValue::kBoolean)); - EXPECT_FALSE(node->GetStandardValue(olive::TextGeneratorV2::kHtmlInput) + EXPECT_EQ(int(node->get_input_data_type(olive::TextGeneratorV2::k_html_input)), + int(olive::NodeValue::k_boolean)); + EXPECT_FALSE(node->get_standard_value(olive::TextGeneratorV2::k_html_input) .toBool()); - EXPECT_EQ(int(node->GetInputDataType(olive::TextGeneratorV2::kVAlignInput)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(node->GetStandardValue(olive::TextGeneratorV2::kVAlignInput) + EXPECT_EQ(int(node->get_input_data_type(olive::TextGeneratorV2::k_v_align_input)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(node->get_standard_value(olive::TextGeneratorV2::k_v_align_input) .toInt(), 0); - EXPECT_EQ(int(node->GetInputDataType(olive::TextGeneratorV2::kFontInput)), - int(olive::NodeValue::kFont)); + EXPECT_EQ(int(node->get_input_data_type(olive::TextGeneratorV2::k_font_input)), + int(olive::NodeValue::k_font)); EXPECT_EQ( - int(node->GetInputDataType(olive::TextGeneratorV2::kFontSizeInput)), - int(olive::NodeValue::kFloat)); - EXPECT_DOUBLE_EQ(node->GetStandardValue(olive::TextGeneratorV2::kFontSizeInput) + int(node->get_input_data_type(olive::TextGeneratorV2::k_font_size_input)), + int(olive::NodeValue::k_float)); + EXPECT_DOUBLE_EQ(node->get_standard_value(olive::TextGeneratorV2::k_font_size_input) .toDouble(), 72.0); // From ShapeNodeBase: white text on a 400x300 box const olive::core::Color color = - node->GetStandardValue(olive::ShapeNodeBase::kColorInput) + node->get_standard_value(olive::ShapeNodeBase::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_FLOAT_EQ(color.green(), 1.0f); EXPECT_FLOAT_EQ(color.blue(), 1.0f); EXPECT_FLOAT_EQ(color.alpha(), 1.0f); - EXPECT_EQ(node->GetStandardValue(olive::ShapeNodeBase::kSizeInput) + EXPECT_EQ(node->get_standard_value(olive::ShapeNodeBase::k_size_input) .value(), QVector2D(400.0f, 300.0f)); } TEST(TextGeneratorV2, RetranslateSetsNamesAndComboStrings) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->Retranslate(); + auto *node = add_node(&project); + node->retranslate(); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV2::kTextInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV2::k_text_input), QStringLiteral("Text")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV2::kHtmlInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV2::k_html_input), QStringLiteral("Enable HTML")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV2::kFontInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV2::k_font_input), QStringLiteral("Font")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV2::kFontSizeInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV2::k_font_size_input), QStringLiteral("Font Size")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV2::kVAlignInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV2::k_v_align_input), QStringLiteral("Vertical Align")); // Inherited names from ShapeNodeBase and GeneratorWithMerge - EXPECT_EQ(node->GetInputName(olive::ShapeNodeBase::kPositionInput), + EXPECT_EQ(node->get_input_name(olive::ShapeNodeBase::k_position_input), QStringLiteral("Position")); - EXPECT_EQ(node->GetInputName(olive::ShapeNodeBase::kSizeInput), + EXPECT_EQ(node->get_input_name(olive::ShapeNodeBase::k_size_input), QStringLiteral("Size")); - EXPECT_EQ(node->GetInputName(olive::ShapeNodeBase::kColorInput), + EXPECT_EQ(node->get_input_name(olive::ShapeNodeBase::k_color_input), QStringLiteral("Color")); - EXPECT_EQ(node->GetInputName(olive::GeneratorWithMerge::kBaseInput), + EXPECT_EQ(node->get_input_name(olive::GeneratorWithMerge::k_base_input), QStringLiteral("Base")); const QStringList aligns = - node->GetComboBoxStrings(olive::TextGeneratorV2::kVAlignInput); + node->get_combo_box_strings(olive::TextGeneratorV2::k_v_align_input); ASSERT_EQ(aligns.size(), 3); EXPECT_EQ(aligns.at(0), QStringLiteral("Top")); EXPECT_EQ(aligns.at(1), QStringLiteral("Center")); @@ -690,79 +690,79 @@ TEST(TextGeneratorV2, RetranslateSetsNamesAndComboStrings) TEST(TextGeneratorV2, ValuePushesFloatTextureWithGenerateJob) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::NodeValueTable table = GenerateTable(node, vparams); + const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::NodeValueTable table = generate_table(node, vparams); // Text always renders to a 32-bit float buffer regardless of sequence depth - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), vparams.width()); EXPECT_EQ(texture->params().height(), vparams.height()); EXPECT_EQ(int(texture->params().format()), - int(olive::core::PixelFormat::F32)); + int(olive::core::PixelFormat::f32)); auto *job = dynamic_cast(texture->job()); ASSERT_TRUE(job); - EXPECT_EQ(job->Get(olive::TextGeneratorV2::kTextInput).toString(), + EXPECT_EQ(job->get(olive::TextGeneratorV2::k_text_input).to_string(), QStringLiteral("Sample Text")); - EXPECT_DOUBLE_EQ(job->Get(olive::TextGeneratorV2::kFontSizeInput).toDouble(), + EXPECT_DOUBLE_EQ(job->get(olive::TextGeneratorV2::k_font_size_input).to_double(), 72.0); - EXPECT_EQ(job->Get(olive::TextGeneratorV2::kVAlignInput).toInt(), 0); - EXPECT_EQ(job->Get(olive::ShapeNodeBase::kSizeInput).toVec2(), + EXPECT_EQ(job->get(olive::TextGeneratorV2::k_v_align_input).to_int(), 0); + EXPECT_EQ(job->get(olive::ShapeNodeBase::k_size_input).to_vec2(), QVector2D(400.0f, 300.0f)); } TEST(TextGeneratorV2, EmptyTextPushesNothing) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TextGeneratorV2::kTextInput, QString()); + auto *node = add_node(&project); + node->set_standard_value(olive::TextGeneratorV2::k_text_input, QString()); - olive::NodeValueTable table = GenerateTable( - node, olive::VideoParams(320, 240, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + olive::NodeValueTable table = generate_table( + node, olive::VideoParams(320, 240, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); - EXPECT_TRUE(GetOutputTexture(table) == nullptr); + EXPECT_TRUE(get_output_texture(table) == nullptr); } TEST(TextGeneratorV2, ValueIgnoresBaseInput) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - auto *constant = AddNode(&project); + auto *node = add_node(&project); + auto *constant = add_node(&project); const olive::TexturePtr base = std::make_shared( - olive::VideoParams(64, 48, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); - constant->SetTexture(base); - olive::Node::ConnectEdge(constant, + olive::VideoParams(64, 48, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); + constant->set_texture(base); + olive::Node::connect_edge(constant, olive::NodeInput( - node, olive::GeneratorWithMerge::kBaseInput)); + node, olive::GeneratorWithMerge::k_base_input)); - olive::NodeValueTable table = GenerateTable( - node, olive::VideoParams(320, 240, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount)); + olive::NodeValueTable table = generate_table( + node, olive::VideoParams(320, 240, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count)); // Unlike TextGeneratorV3, which composites its text over the base input, // the legacy V2 node never looks at it: the output is its own generate // job at sequence params, not a merge with the base - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), 320); EXPECT_EQ(texture->params().height(), 240); EXPECT_TRUE(dynamic_cast(texture->job())); @@ -770,35 +770,35 @@ TEST(TextGeneratorV2, ValueIgnoresBaseInput) TEST(TextGeneratorV2, GenerateFrameWithEmptyTextLeavesFrameTransparent) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TextGeneratorV2::kTextInput, QString()); + auto *node = add_node(&project); + node->set_standard_value(olive::TextGeneratorV2::k_text_input, QString()); // Walk the vertical alignment switch and the HTML branch with empty text: // no glyphs are drawn, so the transplant loop writes pure zeros - olive::NodeValueRow row = GenerateRow(node); + olive::NodeValueRow row = generate_row(node); for (int valign = 0; valign <= 2; valign++) { for (int html = 0; html <= 1; html++) { - row[olive::TextGeneratorV2::kVAlignInput] = - olive::NodeValue(olive::NodeValue::kCombo, valign); - row[olive::TextGeneratorV2::kHtmlInput] = - olive::NodeValue(olive::NodeValue::kBoolean, bool(html)); + row[olive::TextGeneratorV2::k_v_align_input] = + olive::NodeValue(olive::NodeValue::k_combo, valign); + row[olive::TextGeneratorV2::k_html_input] = + olive::NodeValue(olive::NodeValue::k_boolean, bool(html)); - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params( - olive::VideoParams(64, 48, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(64, 48, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count)); frame->allocate(); - node->GenerateFrame(frame, olive::GenerateJob(row)); + node->generate_frame(frame, olive::GenerateJob(row)); const float *data = reinterpret_cast(frame->data()); const int pixel_count = frame->linesize_pixels() * frame->height() * - olive::VideoParams::kRGBAChannelCount; + olive::VideoParams::k_rgba_channel_count; float max_abs = 0.0f; for (int i = 0; i < pixel_count; i++) { max_abs = qMax(max_abs, qAbs(data[i])); @@ -811,22 +811,22 @@ TEST(TextGeneratorV2, GenerateFrameWithEmptyTextLeavesFrameTransparent) TEST(TextGeneratorV2, GenerateFrameRasterizesTextInColor) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue( - olive::ShapeNodeBase::kColorInput, + auto *node = add_node(&project); + node->set_standard_value( + olive::ShapeNodeBase::k_color_input, QVariant::fromValue(olive::core::Color(1.0f, 0.0f, 0.0f, 1.0f))); - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params( - olive::VideoParams(320, 240, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(320, 240, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count)); frame->allocate(); - node->GenerateFrame(frame, olive::GenerateJob(GenerateRow(node))); + node->generate_frame(frame, olive::GenerateJob(generate_row(node))); // The alpha mask of the rendered glyphs is tinted by the color input: // red premultiplied text has red == alpha and zero green/blue everywhere @@ -838,7 +838,7 @@ TEST(TextGeneratorV2, GenerateFrameRasterizesTextInColor) for (int x = 0; x < frame->width(); x++) { const float *px = data + (y * frame->linesize_pixels() + x) * - olive::VideoParams::kRGBAChannelCount; + olive::VideoParams::k_rgba_channel_count; any_alpha |= px[3] > 0.0f; any_green_or_blue |= (px[1] != 0.0f || px[2] != 0.0f); red_matches_alpha &= (px[0] == px[3]); @@ -854,35 +854,35 @@ TEST(TextGeneratorV1, MetadataIsCorrect) olive::TextGeneratorV1 node; EXPECT_EQ(node.id(), QStringLiteral("org.olivevideoeditor.Olive.textgenerator")); - EXPECT_EQ(node.Name(), QStringLiteral("Text (Legacy)")); - EXPECT_FALSE(node.Description().isEmpty()); - EXPECT_TRUE(node.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_EQ(node.name(), QStringLiteral("Text (Legacy)")); + EXPECT_FALSE(node.description().isEmpty()); + EXPECT_TRUE(node.category().contains(olive::Node::k_category_generator)); // Hidden from the create menu: superseded by TextGeneratorV3 - EXPECT_TRUE(node.GetFlags() & olive::Node::kDontShowInCreateMenu); + EXPECT_TRUE(node.get_flags() & olive::Node::k_dont_show_in_create_menu); } TEST(TextGeneratorV1, InputDefaults) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - EXPECT_EQ(node->GetStandardValue(olive::TextGeneratorV1::kTextInput) + EXPECT_EQ(node->get_standard_value(olive::TextGeneratorV1::k_text_input) .toString(), QStringLiteral("Sample Text")); - EXPECT_EQ(int(node->GetInputDataType(olive::TextGeneratorV1::kHtmlInput)), - int(olive::NodeValue::kBoolean)); - EXPECT_FALSE(node->GetStandardValue(olive::TextGeneratorV1::kHtmlInput) + EXPECT_EQ(int(node->get_input_data_type(olive::TextGeneratorV1::k_html_input)), + int(olive::NodeValue::k_boolean)); + EXPECT_FALSE(node->get_standard_value(olive::TextGeneratorV1::k_html_input) .toBool()); - EXPECT_EQ(int(node->GetInputDataType(olive::TextGeneratorV1::kColorInput)), - int(olive::NodeValue::kColor)); + EXPECT_EQ(int(node->get_input_data_type(olive::TextGeneratorV1::k_color_input)), + int(olive::NodeValue::k_color)); const olive::core::Color color = - node->GetStandardValue(olive::TextGeneratorV1::kColorInput) + node->get_standard_value(olive::TextGeneratorV1::k_color_input) .value(); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_FLOAT_EQ(color.green(), 1.0f); @@ -890,44 +890,44 @@ TEST(TextGeneratorV1, InputDefaults) EXPECT_FLOAT_EQ(color.alpha(), 1.0f); // Unlike V2, V1 defaults to centered vertical alignment - EXPECT_EQ(int(node->GetInputDataType(olive::TextGeneratorV1::kVAlignInput)), - int(olive::NodeValue::kCombo)); - EXPECT_EQ(node->GetStandardValue(olive::TextGeneratorV1::kVAlignInput) + EXPECT_EQ(int(node->get_input_data_type(olive::TextGeneratorV1::k_v_align_input)), + int(olive::NodeValue::k_combo)); + EXPECT_EQ(node->get_standard_value(olive::TextGeneratorV1::k_v_align_input) .toInt(), 1); EXPECT_EQ( - int(node->GetInputDataType(olive::TextGeneratorV1::kFontSizeInput)), - int(olive::NodeValue::kFloat)); - EXPECT_DOUBLE_EQ(node->GetStandardValue(olive::TextGeneratorV1::kFontSizeInput) + int(node->get_input_data_type(olive::TextGeneratorV1::k_font_size_input)), + int(olive::NodeValue::k_float)); + EXPECT_DOUBLE_EQ(node->get_standard_value(olive::TextGeneratorV1::k_font_size_input) .toDouble(), 72.0); } TEST(TextGeneratorV1, RetranslateSetsNamesAndComboStrings) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->Retranslate(); + auto *node = add_node(&project); + node->retranslate(); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV1::kTextInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV1::k_text_input), QStringLiteral("Text")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV1::kHtmlInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV1::k_html_input), QStringLiteral("Enable HTML")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV1::kFontInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV1::k_font_input), QStringLiteral("Font")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV1::kFontSizeInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV1::k_font_size_input), QStringLiteral("Font Size")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV1::kColorInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV1::k_color_input), QStringLiteral("Color")); - EXPECT_EQ(node->GetInputName(olive::TextGeneratorV1::kVAlignInput), + EXPECT_EQ(node->get_input_name(olive::TextGeneratorV1::k_v_align_input), QStringLiteral("Vertical Align")); const QStringList aligns = - node->GetComboBoxStrings(olive::TextGeneratorV1::kVAlignInput); + node->get_combo_box_strings(olive::TextGeneratorV1::k_v_align_input); ASSERT_EQ(aligns.size(), 3); EXPECT_EQ(aligns.at(0), QStringLiteral("Top")); EXPECT_EQ(aligns.at(1), QStringLiteral("Center")); @@ -936,80 +936,80 @@ TEST(TextGeneratorV1, RetranslateSetsNamesAndComboStrings) TEST(TextGeneratorV1, ValuePushesTextureAtSequenceParams) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::NodeValueTable table = GenerateTable(node, vparams); + const olive::VideoParams vparams(320, 240, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::NodeValueTable table = generate_table(node, vparams); // Unlike V2, V1 keeps the sequence pixel format for its output - olive::TexturePtr texture = GetOutputTexture(table); + olive::TexturePtr texture = get_output_texture(table); ASSERT_TRUE(texture); - ASSERT_TRUE(texture->IsJob()); + ASSERT_TRUE(texture->is_job()); EXPECT_EQ(texture->params().width(), vparams.width()); EXPECT_EQ(texture->params().height(), vparams.height()); EXPECT_EQ(int(texture->params().format()), - int(olive::core::PixelFormat::U8)); + int(olive::core::PixelFormat::u8)); auto *job = dynamic_cast(texture->job()); ASSERT_TRUE(job); - EXPECT_EQ(job->Get(olive::TextGeneratorV1::kTextInput).toString(), + EXPECT_EQ(job->get(olive::TextGeneratorV1::k_text_input).to_string(), QStringLiteral("Sample Text")); - EXPECT_DOUBLE_EQ(job->Get(olive::TextGeneratorV1::kFontSizeInput).toDouble(), + EXPECT_DOUBLE_EQ(job->get(olive::TextGeneratorV1::k_font_size_input).to_double(), 72.0); } TEST(TextGeneratorV1, EmptyTextPushesNothing) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TextGeneratorV1::kTextInput, QString()); + auto *node = add_node(&project); + node->set_standard_value(olive::TextGeneratorV1::k_text_input, QString()); - olive::NodeValueTable table = GenerateTable( - node, olive::VideoParams(320, 240, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + olive::NodeValueTable table = generate_table( + node, olive::VideoParams(320, 240, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); - EXPECT_TRUE(GetOutputTexture(table) == nullptr); + EXPECT_TRUE(get_output_texture(table) == nullptr); } TEST(TextGeneratorV1, GenerateFrameWithEmptyTextLeavesFrameBlack) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); - node->SetStandardValue(olive::TextGeneratorV1::kTextInput, QString()); + auto *node = add_node(&project); + node->set_standard_value(olive::TextGeneratorV1::k_text_input, QString()); // Walk the vertical alignment switch and the HTML branch with empty text: // no glyphs are drawn, so every pixel is set to transparent black - olive::NodeValueRow row = GenerateRow(node); + olive::NodeValueRow row = generate_row(node); for (int valign = 0; valign <= 2; valign++) { for (int html = 0; html <= 1; html++) { - row[olive::TextGeneratorV1::kVAlignInput] = - olive::NodeValue(olive::NodeValue::kCombo, valign); - row[olive::TextGeneratorV1::kHtmlInput] = - olive::NodeValue(olive::NodeValue::kBoolean, bool(html)); + row[olive::TextGeneratorV1::k_v_align_input] = + olive::NodeValue(olive::NodeValue::k_combo, valign); + row[olive::TextGeneratorV1::k_html_input] = + olive::NodeValue(olive::NodeValue::k_boolean, bool(html)); - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params( - olive::VideoParams(64, 48, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(64, 48, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count)); frame->allocate(); - node->GenerateFrame(frame, olive::GenerateJob(row)); + node->generate_frame(frame, olive::GenerateJob(row)); const float *data = reinterpret_cast(frame->data()); const int pixel_count = frame->linesize_pixels() * frame->height() * - olive::VideoParams::kRGBAChannelCount; + olive::VideoParams::k_rgba_channel_count; float max_abs = 0.0f; for (int i = 0; i < pixel_count; i++) { max_abs = qMax(max_abs, qAbs(data[i])); @@ -1022,19 +1022,19 @@ TEST(TextGeneratorV1, GenerateFrameWithEmptyTextLeavesFrameBlack) TEST(TextGeneratorV1, GenerateFrameRasterizesTextPixels) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); - auto *node = AddNode(&project); + auto *node = add_node(&project); - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params( - olive::VideoParams(320, 240, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(320, 240, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count)); frame->allocate(); - node->GenerateFrame(frame, olive::GenerateJob(GenerateRow(node))); + node->generate_frame(frame, olive::GenerateJob(generate_row(node))); // The default white text is written premultiplied: any covered pixel has // all channels equal to its alpha @@ -1045,7 +1045,7 @@ TEST(TextGeneratorV1, GenerateFrameRasterizesTextPixels) for (int x = 0; x < frame->width(); x++) { const float *px = data + (y * frame->linesize_pixels() + x) * - olive::VideoParams::kRGBAChannelCount; + olive::VideoParams::k_rgba_channel_count; any_alpha |= px[3] > 0.0f; channels_match_alpha &= (px[0] == px[3] && px[1] == px[3] && px[2] == px[3]); diff --git a/tests/gtest/node_project_test.cpp b/tests/gtest/node_project_test.cpp index 9f3e42194..bdf8e5ed2 100644 --- a/tests/gtest/node_project_test.cpp +++ b/tests/gtest/node_project_test.cpp @@ -16,7 +16,7 @@ TEST(NodeProject, DefaultsAfterConstruction) EXPECT_TRUE(project.is_new()); EXPECT_FALSE(project.is_modified()); EXPECT_TRUE(project.has_autorecovery_been_saved()); - EXPECT_FALSE(project.GetUuid().isNull()); + EXPECT_FALSE(project.get_uuid().isNull()); EXPECT_NE(project.color_manager(), nullptr); EXPECT_EQ(project.root(), nullptr); EXPECT_TRUE(project.nodes().isEmpty()); @@ -51,23 +51,23 @@ TEST(NodeProject, SettingsRoundTrip) { olive::Project project; - project.SetSetting( - olive::Project::kCacheLocationSettingKey, - QString::number(olive::Project::kCacheStoreAlongsideProject)); - EXPECT_EQ(project.GetCacheLocationSetting(), - olive::Project::kCacheStoreAlongsideProject); + project.set_setting( + olive::Project::k_cache_location_setting_key, + QString::number(olive::Project::k_cache_store_alongside_project)); + EXPECT_EQ(project.get_cache_location_setting(), + olive::Project::k_cache_store_alongside_project); - project.SetCustomCachePath(QStringLiteral("/tmp/cache")); - EXPECT_EQ(project.GetCustomCachePath(), QStringLiteral("/tmp/cache")); + project.set_custom_cache_path(QStringLiteral("/tmp/cache")); + EXPECT_EQ(project.get_custom_cache_path(), QStringLiteral("/tmp/cache")); - project.SetColorConfigFilename(QStringLiteral("config.ocio")); - EXPECT_EQ(project.GetColorConfigFilename(), QStringLiteral("config.ocio")); + project.set_color_config_filename(QStringLiteral("config.ocio")); + EXPECT_EQ(project.get_color_config_filename(), QStringLiteral("config.ocio")); - project.SetDefaultInputColorSpace(QStringLiteral("ACEScg")); - EXPECT_EQ(project.GetDefaultInputColorSpace(), QStringLiteral("ACEScg")); + project.set_default_input_color_space(QStringLiteral("ACEScg")); + EXPECT_EQ(project.get_default_input_color_space(), QStringLiteral("ACEScg")); - project.SetColorReferenceSpace(QStringLiteral("ACES - ACEScg")); - EXPECT_EQ(project.GetColorReferenceSpace(), + project.set_color_reference_space(QStringLiteral("ACES - ACEScg")); + EXPECT_EQ(project.get_color_reference_space(), QStringLiteral("ACES - ACEScg")); } @@ -76,38 +76,38 @@ TEST(NodeProject, InitializeCreatesRoot) olive::Project project; EXPECT_EQ(project.root(), nullptr); - project.Initialize(); + project.initialize(); EXPECT_NE(project.root(), nullptr); - EXPECT_EQ(project.root()->GetLabel(), QStringLiteral("Root")); + EXPECT_EQ(project.root()->get_label(), QStringLiteral("Root")); } TEST(NodeProject, UuidCanBeRegenerated) { olive::Project project; - const QUuid original = project.GetUuid(); + const QUuid original = project.get_uuid(); - project.RegenerateUuid(); - EXPECT_FALSE(project.GetUuid().isNull()); - EXPECT_NE(project.GetUuid(), original); + project.regenerate_uuid(); + EXPECT_FALSE(project.get_uuid().isNull()); + EXPECT_NE(project.get_uuid(), original); } TEST(NodeProject, GetProjectFromObject) { olive::Project project; olive::ColorManager *cm = project.color_manager(); - EXPECT_EQ(olive::Project::GetProjectFromObject(cm), &project); + EXPECT_EQ(olive::Project::get_project_from_object(cm), &project); } TEST(NodeProject, SaveProducesXml) { olive::Project project; - project.Initialize(); + project.initialize(); QByteArray xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("project")); - project.Save(&writer); + project.save(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -166,7 +166,7 @@ TEST(NodeProject, SaveProducesXml) // The project uuid round-trips as a valid uuid EXPECT_TRUE(saw_uuid); - EXPECT_EQ(uuid_text, project.GetUuid().toString()); + EXPECT_EQ(uuid_text, project.get_uuid().toString()); EXPECT_FALSE(QUuid(uuid_text).isNull()); // Initialize() created a root folder, so at least one node is serialized diff --git a/tests/gtest/node_save_load_test.cpp b/tests/gtest/node_save_load_test.cpp index 271501c02..c500c4526 100644 --- a/tests/gtest/node_save_load_test.cpp +++ b/tests/gtest/node_save_load_test.cpp @@ -30,20 +30,20 @@ namespace // Serializes a single node into a standalone XML document, mirroring how // Project::Save wraps Node::Save in a "node" element -QString SaveNodeXml(const olive::Node *node) +QString save_node_xml(const olive::Node *node) { QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("node")); - node->Save(&writer); + node->save(&writer); writer.writeEndElement(); // node writer.writeEndDocument(); return xml; } // Loads a document produced by SaveNodeXml into an existing node -bool LoadNodeXml(olive::Node *node, const QString &xml, +bool load_node_xml(olive::Node *node, const QString &xml, olive::SerializedData *data) { QXmlStreamReader reader(xml); @@ -53,10 +53,10 @@ bool LoadNodeXml(olive::Node *node, const QString &xml, if (reader.name() != QStringLiteral("node")) { return false; } - return node->Load(&reader, data); + return node->load(&reader, data); } -olive::Node *FindNodeById(olive::Project *project, const QString &id) +olive::Node *find_node_by_id(olive::Project *project, const QString &id) { for (olive::Node *n : project->nodes()) { if (n->id() == id) { @@ -72,12 +72,12 @@ class CustomDataNode : public olive::Node { public: CustomDataNode() { - AddInput(QStringLiteral("Value"), olive::NodeValue::kFloat); + add_input(QStringLiteral("Value"), olive::NodeValue::k_float); } NODE_DEFAULT_FUNCTIONS(CustomDataNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("CustomDataNode"); } @@ -87,34 +87,34 @@ public: return QStringLiteral("org.oak.test.customdatanode"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryUnknown }; + return { k_category_unknown }; } - virtual QString Description() const override + virtual QString description() const override { return QStringLiteral("Node with custom serialized data"); } - void Value(const olive::NodeValueRow &, const olive::NodeGlobals &, + void value(const olive::NodeValueRow &, const olive::NodeGlobals &, olive::NodeValueTable *) const override { } - virtual void SaveCustom(QXmlStreamWriter *writer) const override + virtual void save_custom(QXmlStreamWriter *writer) const override { - writer->writeTextElement(QStringLiteral("greeting"), greeting_); + writer->writeTextElement(QStringLiteral("greeting"), greeting); } - virtual bool LoadCustom(QXmlStreamReader *reader, + virtual bool load_custom(QXmlStreamReader *reader, olive::SerializedData *data) override { Q_UNUSED(data) - while (olive::XMLReadNextStartElement(reader)) { + while (olive::xml_read_next_start_element(reader)) { if (reader->name() == QStringLiteral("greeting")) { - greeting_ = reader->readElementText(); + greeting = reader->readElementText(); } else if (reader->name() == QStringLiteral("explode")) { reader->skipCurrentElement(); return false; @@ -128,11 +128,11 @@ public: virtual void LoadFinishedEvent() override { - load_finished_called_ = true; + load_finished_called = true; } - QString greeting_; - bool load_finished_called_ = false; + QString greeting; + bool load_finished_called = false; }; } // namespace @@ -141,7 +141,7 @@ class NodeSaveLoadTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); // Cache UUID changes resolve a cache path through the DiskManager // singleton, which itself touches Core (same pattern as @@ -150,14 +150,14 @@ protected: new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - template T *AddNode() + template T *add_node() { T *node = new T(); node->setParent(project_.get()); @@ -169,80 +169,80 @@ protected: TEST_F(NodeSaveLoadTest, StandardValuesLabelAndColorRoundTrip) { - auto *src = AddNode(); - src->SetLabel(QStringLiteral("Labeled")); - src->SetOverrideColor(3); - src->SetStandardValue(olive::MathNode::kParamAIn, 3.5); - src->SetStandardValue(olive::MathNode::kParamBIn, -2.25); - src->SetOperation(olive::MathNode::kOpMultiply); + auto *src = add_node(); + src->set_label(QStringLiteral("Labeled")); + src->set_override_color(3); + src->set_standard_value(olive::MathNode::k_param_a_in, 3.5); + src->set_standard_value(olive::MathNode::k_param_b_in, -2.25); + src->set_operation(olive::MathNode::k_op_multiply); - const QString xml = SaveNodeXml(src); + const QString xml = save_node_xml(src); EXPECT_TRUE(xml.contains(QStringLiteral("version=\"1\""))); EXPECT_TRUE(xml.contains( QStringLiteral("id=\"org.olivevideoeditor.Olive.math\""))); olive::MathNode loaded; olive::SerializedData data; - ASSERT_TRUE(LoadNodeXml(&loaded, xml, &data)); + ASSERT_TRUE(load_node_xml(&loaded, xml, &data)); - EXPECT_EQ(loaded.GetLabel(), QStringLiteral("Labeled")); - EXPECT_EQ(loaded.GetOverrideColor(), 3); + EXPECT_EQ(loaded.get_label(), QStringLiteral("Labeled")); + EXPECT_EQ(loaded.get_override_color(), 3); EXPECT_DOUBLE_EQ( - loaded.GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 3.5); + loaded.get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 3.5); EXPECT_DOUBLE_EQ( - loaded.GetStandardValue(olive::MathNode::kParamBIn).toDouble(), -2.25); - EXPECT_EQ(int(loaded.GetOperation()), int(olive::MathNode::kOpMultiply)); + loaded.get_standard_value(olive::MathNode::k_param_b_in).toDouble(), -2.25); + EXPECT_EQ(int(loaded.get_operation()), int(olive::MathNode::k_op_multiply)); // The "ptr" attribute maps the serialized address to the loaded instance EXPECT_EQ(data.node_ptrs.value(reinterpret_cast(src)), &loaded); // A non-keyframable input never reports keyframing after load - EXPECT_FALSE(loaded.IsInputKeyframing(olive::MathNode::kMethodIn)); + EXPECT_FALSE(loaded.is_input_keyframing(olive::MathNode::k_method_in)); } TEST_F(NodeSaveLoadTest, ArrayElementsAndPerElementKeyframingRoundTrip) { - auto *src = AddNode(); - src->InputArrayResize(olive::TextGeneratorV3::kArgsInput, 2); - src->SetStandardValue( - olive::NodeInput(src, olive::TextGeneratorV3::kArgsInput, 0), + auto *src = add_node(); + src->input_array_resize(olive::TextGeneratorV3::k_args_input, 2); + src->set_standard_value( + olive::NodeInput(src, olive::TextGeneratorV3::k_args_input, 0), QStringLiteral("first")); - src->SetStandardValue( - olive::NodeInput(src, olive::TextGeneratorV3::kArgsInput, 1), + src->set_standard_value( + olive::NodeInput(src, olive::TextGeneratorV3::k_args_input, 1), QStringLiteral("second")); // Only element 1 is keyframed - src->SetInputIsKeyframing(olive::TextGeneratorV3::kArgsInput, true, 1); + src->set_input_is_keyframing(olive::TextGeneratorV3::k_args_input, true, 1); auto *key = new olive::NodeKeyframe( - olive::rational(2), QStringLiteral("keyed"), olive::NodeKeyframe::kLinear, - 0, 1, olive::TextGeneratorV3::kArgsInput); + olive::Rational(2), QStringLiteral("keyed"), olive::NodeKeyframe::k_linear, + 0, 1, olive::TextGeneratorV3::k_args_input); key->setParent(src); - const QString xml = SaveNodeXml(src); + const QString xml = save_node_xml(src); olive::TextGeneratorV3 loaded; olive::SerializedData data; - ASSERT_TRUE(LoadNodeXml(&loaded, xml, &data)); + ASSERT_TRUE(load_node_xml(&loaded, xml, &data)); // The subelement count attribute resized the array on load - ASSERT_EQ(loaded.InputArraySize(olive::TextGeneratorV3::kArgsInput), 2); - EXPECT_EQ(loaded.GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, 0) + ASSERT_EQ(loaded.input_array_size(olive::TextGeneratorV3::k_args_input), 2); + EXPECT_EQ(loaded.get_split_standard_value(olive::TextGeneratorV3::k_args_input, 0) .at(0) .toString(), QStringLiteral("first")); - EXPECT_EQ(loaded.GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, 1) + EXPECT_EQ(loaded.get_split_standard_value(olive::TextGeneratorV3::k_args_input, 1) .at(0) .toString(), QStringLiteral("second")); EXPECT_FALSE( - loaded.IsInputKeyframing(olive::TextGeneratorV3::kArgsInput, 0)); - EXPECT_TRUE(loaded.IsInputKeyframing(olive::TextGeneratorV3::kArgsInput, 1)); + loaded.is_input_keyframing(olive::TextGeneratorV3::k_args_input, 0)); + EXPECT_TRUE(loaded.is_input_keyframing(olive::TextGeneratorV3::k_args_input, 1)); const QVector &tracks = - loaded.GetKeyframeTracks(olive::TextGeneratorV3::kArgsInput, 1); + loaded.get_keyframe_tracks(olive::TextGeneratorV3::k_args_input, 1); ASSERT_EQ(tracks.at(0).size(), 1); - EXPECT_EQ(tracks.at(0).first()->time(), olive::rational(2)); + EXPECT_EQ(tracks.at(0).first()->time(), olive::Rational(2)); EXPECT_EQ(tracks.at(0).first()->value().toString(), QStringLiteral("keyed")); EXPECT_EQ(tracks.at(0).first()->element(), 1); @@ -250,61 +250,61 @@ TEST_F(NodeSaveLoadTest, ArrayElementsAndPerElementKeyframingRoundTrip) TEST_F(NodeSaveLoadTest, KeyframesAllTypesAndColorPropertiesRoundTrip) { - auto *src = AddNode(); + auto *src = add_node(); olive::SplitValue color; color.append(0.25); color.append(0.5); color.append(0.75); color.append(1.0); - src->SetSplitStandardValue(olive::SolidGenerator::kColorInput, color, -1); + src->set_split_standard_value(olive::SolidGenerator::k_color_input, color, -1); - src->SetInputIsKeyframing(olive::SolidGenerator::kColorInput, true); + src->set_input_is_keyframing(olive::SolidGenerator::k_color_input, true); auto *linear = new olive::NodeKeyframe( - olive::rational(0), 0.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::SolidGenerator::kColorInput); + olive::Rational(0), 0.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::SolidGenerator::k_color_input); linear->setParent(src); auto *bezier = new olive::NodeKeyframe( - olive::rational(5), 1.0, olive::NodeKeyframe::kBezier, 0, -1, - olive::SolidGenerator::kColorInput); + olive::Rational(5), 1.0, olive::NodeKeyframe::k_bezier, 0, -1, + olive::SolidGenerator::k_color_input); bezier->setParent(src); bezier->set_bezier_control_in(QPointF(0.25, -1.5)); bezier->set_bezier_control_out(QPointF(2.5, 0.75)); auto *hold = new olive::NodeKeyframe( - olive::rational(3), 0.5, olive::NodeKeyframe::kHold, 2, -1, - olive::SolidGenerator::kColorInput); + olive::Rational(3), 0.5, olive::NodeKeyframe::k_hold, 2, -1, + olive::SolidGenerator::k_color_input); hold->setParent(src); // Color inputs additionally serialize their color management properties - src->SetInputProperty(olive::SolidGenerator::kColorInput, + src->set_input_property(olive::SolidGenerator::k_color_input, QStringLiteral("col_input"), QStringLiteral("ACEScg")); - src->SetInputProperty(olive::SolidGenerator::kColorInput, + src->set_input_property(olive::SolidGenerator::k_color_input, QStringLiteral("col_display"), QStringLiteral("sRGB")); - src->SetInputProperty(olive::SolidGenerator::kColorInput, + src->set_input_property(olive::SolidGenerator::k_color_input, QStringLiteral("col_view"), QStringLiteral("Filmic")); - src->SetInputProperty(olive::SolidGenerator::kColorInput, + src->set_input_property(olive::SolidGenerator::k_color_input, QStringLiteral("col_look"), QStringLiteral("None")); - const QString xml = SaveNodeXml(src); + const QString xml = save_node_xml(src); olive::SolidGenerator loaded; olive::SerializedData data; - ASSERT_TRUE(LoadNodeXml(&loaded, xml, &data)); + ASSERT_TRUE(load_node_xml(&loaded, xml, &data)); - EXPECT_TRUE(loaded.IsInputKeyframing(olive::SolidGenerator::kColorInput)); + EXPECT_TRUE(loaded.is_input_keyframing(olive::SolidGenerator::k_color_input)); const QVector &tracks = - loaded.GetKeyframeTracks(olive::SolidGenerator::kColorInput, -1); + loaded.get_keyframe_tracks(olive::SolidGenerator::k_color_input, -1); ASSERT_EQ(tracks.size(), 4); // Track 0 holds the linear and bezier keys, sorted by time ASSERT_EQ(tracks.at(0).size(), 2); - EXPECT_EQ(tracks.at(0).at(0)->time(), olive::rational(0)); - EXPECT_EQ(tracks.at(0).at(0)->type(), olive::NodeKeyframe::kLinear); + EXPECT_EQ(tracks.at(0).at(0)->time(), olive::Rational(0)); + EXPECT_EQ(tracks.at(0).at(0)->type(), olive::NodeKeyframe::k_linear); EXPECT_DOUBLE_EQ(tracks.at(0).at(0)->value().toDouble(), 0.0); - EXPECT_EQ(tracks.at(0).at(1)->time(), olive::rational(5)); - EXPECT_EQ(tracks.at(0).at(1)->type(), olive::NodeKeyframe::kBezier); + EXPECT_EQ(tracks.at(0).at(1)->time(), olive::Rational(5)); + EXPECT_EQ(tracks.at(0).at(1)->type(), olive::NodeKeyframe::k_bezier); EXPECT_DOUBLE_EQ(tracks.at(0).at(1)->value().toDouble(), 1.0); EXPECT_DOUBLE_EQ(tracks.at(0).at(1)->bezier_control_in().x(), 0.25); EXPECT_DOUBLE_EQ(tracks.at(0).at(1)->bezier_control_in().y(), -1.5); @@ -314,33 +314,33 @@ TEST_F(NodeSaveLoadTest, KeyframesAllTypesAndColorPropertiesRoundTrip) // Track 1 was left empty, track 2 holds the single hold key EXPECT_TRUE(tracks.at(1).isEmpty()); ASSERT_EQ(tracks.at(2).size(), 1); - EXPECT_EQ(tracks.at(2).first()->time(), olive::rational(3)); - EXPECT_EQ(tracks.at(2).first()->type(), olive::NodeKeyframe::kHold); + EXPECT_EQ(tracks.at(2).first()->time(), olive::Rational(3)); + EXPECT_EQ(tracks.at(2).first()->type(), olive::NodeKeyframe::k_hold); EXPECT_DOUBLE_EQ(tracks.at(2).first()->value().toDouble(), 0.5); EXPECT_TRUE(tracks.at(3).isEmpty()); // The per-track standard values survive as well const olive::SplitValue loaded_color = - loaded.GetSplitStandardValue(olive::SolidGenerator::kColorInput, -1); + loaded.get_split_standard_value(olive::SolidGenerator::k_color_input, -1); ASSERT_EQ(loaded_color.size(), 4); EXPECT_DOUBLE_EQ(loaded_color.at(0).toDouble(), 0.25); EXPECT_DOUBLE_EQ(loaded_color.at(1).toDouble(), 0.5); EXPECT_DOUBLE_EQ(loaded_color.at(2).toDouble(), 0.75); EXPECT_DOUBLE_EQ(loaded_color.at(3).toDouble(), 1.0); - EXPECT_EQ(loaded.GetInputProperty(olive::SolidGenerator::kColorInput, + EXPECT_EQ(loaded.get_input_property(olive::SolidGenerator::k_color_input, QStringLiteral("col_input")) .toString(), QStringLiteral("ACEScg")); - EXPECT_EQ(loaded.GetInputProperty(olive::SolidGenerator::kColorInput, + EXPECT_EQ(loaded.get_input_property(olive::SolidGenerator::k_color_input, QStringLiteral("col_display")) .toString(), QStringLiteral("sRGB")); - EXPECT_EQ(loaded.GetInputProperty(olive::SolidGenerator::kColorInput, + EXPECT_EQ(loaded.get_input_property(olive::SolidGenerator::k_color_input, QStringLiteral("col_view")) .toString(), QStringLiteral("Filmic")); - EXPECT_EQ(loaded.GetInputProperty(olive::SolidGenerator::kColorInput, + EXPECT_EQ(loaded.get_input_property(olive::SolidGenerator::k_color_input, QStringLiteral("col_look")) .toString(), QStringLiteral("None")); @@ -348,35 +348,35 @@ TEST_F(NodeSaveLoadTest, KeyframesAllTypesAndColorPropertiesRoundTrip) TEST_F(NodeSaveLoadTest, ValueHintsRoundTrip) { - auto *src = AddNode(); - src->SetValueHintForInput( - olive::MathNode::kParamAIn, + auto *src = add_node(); + src->set_value_hint_for_input( + olive::MathNode::k_param_a_in, olive::Node::ValueHint( - { olive::NodeValue::kVec2, olive::NodeValue::kTexture }, 3, + { olive::NodeValue::k_vec2, olive::NodeValue::k_texture }, 3, QStringLiteral("tag"))); - src->SetValueHintForInput(olive::MathNode::kParamBIn, + src->set_value_hint_for_input(olive::MathNode::k_param_b_in, olive::Node::ValueHint(QStringLiteral("elem")), 2); - const QString xml = SaveNodeXml(src); + const QString xml = save_node_xml(src); olive::MathNode loaded; olive::SerializedData data; - ASSERT_TRUE(LoadNodeXml(&loaded, xml, &data)); + ASSERT_TRUE(load_node_xml(&loaded, xml, &data)); const olive::Node::ValueHint hint = - loaded.GetValueHintForInput(olive::MathNode::kParamAIn); + loaded.get_value_hint_for_input(olive::MathNode::k_param_a_in); ASSERT_EQ(hint.types().size(), 2); - EXPECT_EQ(hint.types().at(0), olive::NodeValue::kVec2); - EXPECT_EQ(hint.types().at(1), olive::NodeValue::kTexture); + EXPECT_EQ(hint.types().at(0), olive::NodeValue::k_vec2); + EXPECT_EQ(hint.types().at(1), olive::NodeValue::k_texture); EXPECT_EQ(hint.index(), 3); EXPECT_EQ(hint.tag(), QStringLiteral("tag")); // Hints are tracked per element - EXPECT_EQ(loaded.GetValueHintForInput(olive::MathNode::kParamBIn, 2).tag(), + EXPECT_EQ(loaded.get_value_hint_for_input(olive::MathNode::k_param_b_in, 2).tag(), QStringLiteral("elem")); - EXPECT_EQ(loaded.GetValueHintForInput(olive::MathNode::kParamBIn, 1).tag(), + EXPECT_EQ(loaded.get_value_hint_for_input(olive::MathNode::k_param_b_in, 1).tag(), QString()); - EXPECT_EQ(loaded.GetValueHints().size(), 2); + EXPECT_EQ(loaded.get_value_hints().size(), 2); } TEST_F(NodeSaveLoadTest, CacheUuidsRoundTrip) @@ -392,37 +392,37 @@ TEST_F(NodeSaveLoadTest, CacheUuidsRoundTrip) const QUuid waveform_uuid( QStringLiteral("{44444444-4444-4444-4444-444444444444}")); - src.audio_playback_cache()->SetUuid(audio_uuid); - src.video_frame_cache()->SetUuid(video_uuid); - src.thumbnail_cache()->SetUuid(thumb_uuid); - src.waveform_cache()->SetUuid(waveform_uuid); + src.audio_playback_cache()->set_uuid(audio_uuid); + src.video_frame_cache()->set_uuid(video_uuid); + src.thumbnail_cache()->set_uuid(thumb_uuid); + src.waveform_cache()->set_uuid(waveform_uuid); - const QString xml = SaveNodeXml(&src); + const QString xml = save_node_xml(&src); olive::MathNode loaded; olive::SerializedData data; - ASSERT_TRUE(LoadNodeXml(&loaded, xml, &data)); + ASSERT_TRUE(load_node_xml(&loaded, xml, &data)); - EXPECT_EQ(loaded.audio_playback_cache()->GetUuid(), audio_uuid); - EXPECT_EQ(loaded.video_frame_cache()->GetUuid(), video_uuid); - EXPECT_EQ(loaded.thumbnail_cache()->GetUuid(), thumb_uuid); - EXPECT_EQ(loaded.waveform_cache()->GetUuid(), waveform_uuid); + EXPECT_EQ(loaded.audio_playback_cache()->get_uuid(), audio_uuid); + EXPECT_EQ(loaded.video_frame_cache()->get_uuid(), video_uuid); + EXPECT_EQ(loaded.thumbnail_cache()->get_uuid(), thumb_uuid); + EXPECT_EQ(loaded.waveform_cache()->get_uuid(), waveform_uuid); } TEST_F(NodeSaveLoadTest, CustomDataAndLoadFinishedEventRoundTrip) { CustomDataNode src; - src.greeting_ = QStringLiteral("hello custom"); + src.greeting = QStringLiteral("hello custom"); - const QString xml = SaveNodeXml(&src); + const QString xml = save_node_xml(&src); EXPECT_TRUE(xml.contains(QStringLiteral("hello custom"))); CustomDataNode loaded; olive::SerializedData data; - ASSERT_TRUE(LoadNodeXml(&loaded, xml, &data)); + ASSERT_TRUE(load_node_xml(&loaded, xml, &data)); - EXPECT_EQ(loaded.greeting_, QStringLiteral("hello custom")); - EXPECT_TRUE(loaded.load_finished_called_); + EXPECT_EQ(loaded.greeting, QStringLiteral("hello custom")); + EXPECT_TRUE(loaded.load_finished_called); // A LoadCustom failure propagates out of Node::Load const QString fail_xml = QStringLiteral( @@ -432,7 +432,7 @@ TEST_F(NodeSaveLoadTest, CustomDataAndLoadFinishedEventRoundTrip) QXmlStreamReader reader(fail_xml); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("node")); - EXPECT_FALSE(failing.Load(&reader, &fail_data)); + EXPECT_FALSE(failing.load(&reader, &fail_data)); } TEST_F(NodeSaveLoadTest, UnknownElementsAndVersionAreSkipped) @@ -465,20 +465,20 @@ TEST_F(NodeSaveLoadTest, UnknownElementsAndVersionAreSkipped) QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("node")); - EXPECT_TRUE(node.Load(&reader, &data)); + EXPECT_TRUE(node.load(&reader, &data)); - EXPECT_EQ(node.GetLabel(), QStringLiteral("kept")); + EXPECT_EQ(node.get_label(), QStringLiteral("kept")); // The one well-formed connection was still recorded ASSERT_EQ(data.desired_connections.size(), 1); EXPECT_EQ(data.desired_connections.first().input.input(), - olive::MathNode::kParamAIn); + olive::MathNode::k_param_a_in); EXPECT_EQ(data.desired_connections.first().input.element(), -1); EXPECT_EQ(data.desired_connections.first().output_node, quintptr(12345)); // The malformed input left the default value untouched EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 0.0); + node.get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 0.0); } TEST_F(NodeSaveLoadTest, LoadInputWithMissingOrUnknownIdIsSkipped) @@ -500,40 +500,40 @@ TEST_F(NodeSaveLoadTest, LoadInputWithMissingOrUnknownIdIsSkipped) QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("node")); - EXPECT_TRUE(node.Load(&reader, &data)); + EXPECT_TRUE(node.load(&reader, &data)); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 0.0); + node.get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 0.0); EXPECT_DOUBLE_EQ( - node.GetStandardValue(olive::MathNode::kParamBIn).toDouble(), 0.0); + node.get_standard_value(olive::MathNode::k_param_b_in).toDouble(), 0.0); } TEST_F(NodeSaveLoadTest, ConnectionsLinksAndPositionsResolveAfterProjectLoad) { - olive::NodeFactory::Initialize(); + olive::NodeFactory::initialize(); - auto *src = AddNode(); - auto *dst = AddNode(); - auto *text = AddNode(); - text->InputArrayResize(olive::TextGeneratorV3::kArgsInput, 2); + auto *src = add_node(); + auto *dst = add_node(); + auto *text = add_node(); + text->input_array_resize(olive::TextGeneratorV3::k_args_input, 2); - olive::Node::ConnectEdge( - src, olive::NodeInput(dst, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge( - dst, olive::NodeInput(text, olive::TextGeneratorV3::kArgsInput, 1)); - olive::Node::Link(src, dst); + olive::Node::connect_edge( + src, olive::NodeInput(dst, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge( + dst, olive::NodeInput(text, olive::TextGeneratorV3::k_args_input, 1)); + olive::Node::link(src, dst); olive::Folder *root = project_->root(); - root->SetNodePositionInContext( + root->set_node_position_in_context( src, olive::Node::Position(QPointF(10.0, 20.0), true)); - root->SetNodePositionInContext( + root->set_node_position_in_context( dst, olive::Node::Position(QPointF(-3.5, 7.25), false)); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("project")); - project_->Save(&writer); + project_->save(&writer); writer.writeEndElement(); // project writer.writeEndDocument(); @@ -545,15 +545,15 @@ TEST_F(NodeSaveLoadTest, ConnectionsLinksAndPositionsResolveAfterProjectLoad) QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("project")); - data = loaded.Load(&reader); + data = loaded.load(&reader); } // Root folder plus the three nodes created above ASSERT_EQ(loaded.nodes().size(), 4); - olive::Node *loaded_src = FindNodeById(&loaded, src->id()); - olive::Node *loaded_dst = FindNodeById(&loaded, dst->id()); - olive::Node *loaded_text = FindNodeById(&loaded, text->id()); + olive::Node *loaded_src = find_node_by_id(&loaded, src->id()); + olive::Node *loaded_dst = find_node_by_id(&loaded, dst->id()); + olive::Node *loaded_text = find_node_by_id(&loaded, text->id()); ASSERT_NE(loaded_src, nullptr); ASSERT_NE(loaded_dst, nullptr); ASSERT_NE(loaded_text, nullptr); @@ -565,12 +565,12 @@ TEST_F(NodeSaveLoadTest, ConnectionsLinksAndPositionsResolveAfterProjectLoad) bool found_text_edge = false; for (const auto &sc : data.desired_connections) { if (sc.input.node() == loaded_dst) { - EXPECT_EQ(sc.input.input(), olive::MathNode::kParamAIn); + EXPECT_EQ(sc.input.input(), olive::MathNode::k_param_a_in); EXPECT_EQ(sc.input.element(), -1); EXPECT_EQ(sc.output_node, reinterpret_cast(src)); found_math_edge = true; } else if (sc.input.node() == loaded_text) { - EXPECT_EQ(sc.input.input(), olive::TextGeneratorV3::kArgsInput); + EXPECT_EQ(sc.input.input(), olive::TextGeneratorV3::k_args_input); EXPECT_EQ(sc.input.element(), 1); EXPECT_EQ(sc.output_node, reinterpret_cast(dst)); found_text_edge = true; @@ -591,45 +591,45 @@ TEST_F(NodeSaveLoadTest, ConnectionsLinksAndPositionsResolveAfterProjectLoad) // ProjectSerializer230220::PostConnect does for (const auto &sc : data.desired_connections) { if (olive::Node *out = data.node_ptrs.value(sc.output_node)) { - olive::Node::ConnectEdge(out, sc.input); + olive::Node::connect_edge(out, sc.input); } } for (const auto &link : data.block_links) { - olive::Node::Link(link.block, data.node_ptrs.value(link.link)); + olive::Node::link(link.block, data.node_ptrs.value(link.link)); } for (olive::Node *n : loaded.nodes()) { n->PostLoadEvent(&data); } - EXPECT_EQ(loaded_dst->GetConnectedOutput(olive::MathNode::kParamAIn), + EXPECT_EQ(loaded_dst->get_connected_output(olive::MathNode::k_param_a_in), loaded_src); - EXPECT_EQ(loaded_text->GetConnectedOutput( - olive::TextGeneratorV3::kArgsInput, 1), + EXPECT_EQ(loaded_text->get_connected_output( + olive::TextGeneratorV3::k_args_input, 1), loaded_dst); - EXPECT_TRUE(olive::Node::AreLinked(loaded_src, loaded_dst)); - EXPECT_TRUE(olive::Node::AreLinked(loaded_dst, loaded_src)); + EXPECT_TRUE(olive::Node::are_linked(loaded_src, loaded_dst)); + EXPECT_TRUE(olive::Node::are_linked(loaded_dst, loaded_src)); - EXPECT_EQ(loaded_root->GetNodePositionInContext(loaded_src), + EXPECT_EQ(loaded_root->get_node_position_in_context(loaded_src), QPointF(10.0, 20.0)); - EXPECT_TRUE(loaded_root->IsNodeExpandedInContext(loaded_src)); - EXPECT_EQ(loaded_root->GetNodePositionInContext(loaded_dst), + EXPECT_TRUE(loaded_root->is_node_expanded_in_context(loaded_src)); + EXPECT_EQ(loaded_root->get_node_position_in_context(loaded_dst), QPointF(-3.5, 7.25)); - EXPECT_FALSE(loaded_root->IsNodeExpandedInContext(loaded_dst)); + EXPECT_FALSE(loaded_root->is_node_expanded_in_context(loaded_dst)); - olive::NodeFactory::Destroy(); + olive::NodeFactory::destroy(); } TEST_F(NodeSaveLoadTest, LegacyMisspelledChromaKeyIDsAreMapped) { - auto *src = AddNode(); - src->SetStandardValue(olive::ChromaKeyNode::kUpperToleranceInput, 42.0); - src->SetStandardValue(olive::ChromaKeyNode::kLowerToleranceInput, 7.0); + auto *src = add_node(); + src->set_standard_value(olive::ChromaKeyNode::k_upper_tolerance_input, 42.0); + src->set_standard_value(olive::ChromaKeyNode::k_lower_tolerance_input, 7.0); - auto *math = AddNode(); - olive::Node::ConnectEdge( - math, olive::NodeInput(src, olive::ChromaKeyNode::kUpperToleranceInput)); + auto *math = add_node(); + olive::Node::connect_edge( + math, olive::NodeInput(src, olive::ChromaKeyNode::k_upper_tolerance_input)); - QString xml = SaveNodeXml(src); + QString xml = save_node_xml(src); // Simulate an old project file written with the misspelled "tolerence" IDs xml.replace(QStringLiteral("upper_tolerance_in"), @@ -639,19 +639,19 @@ TEST_F(NodeSaveLoadTest, LegacyMisspelledChromaKeyIDsAreMapped) olive::ChromaKeyNode loaded; olive::SerializedData data; - ASSERT_TRUE(LoadNodeXml(&loaded, xml, &data)); + ASSERT_TRUE(load_node_xml(&loaded, xml, &data)); EXPECT_DOUBLE_EQ( - loaded.GetStandardValue(olive::ChromaKeyNode::kUpperToleranceInput) + loaded.get_standard_value(olive::ChromaKeyNode::k_upper_tolerance_input) .toDouble(), 42.0); EXPECT_DOUBLE_EQ( - loaded.GetStandardValue(olive::ChromaKeyNode::kLowerToleranceInput) + loaded.get_standard_value(olive::ChromaKeyNode::k_lower_tolerance_input) .toDouble(), 7.0); // Connections to the renamed inputs are remapped too ASSERT_EQ(data.desired_connections.size(), 1); EXPECT_EQ(data.desired_connections.first().input.input(), - olive::ChromaKeyNode::kUpperToleranceInput); + olive::ChromaKeyNode::k_upper_tolerance_input); } diff --git a/tests/gtest/node_serialization_test.cpp b/tests/gtest/node_serialization_test.cpp index 1d3cb82c1..0d688c3d7 100644 --- a/tests/gtest/node_serialization_test.cpp +++ b/tests/gtest/node_serialization_test.cpp @@ -16,10 +16,10 @@ class TestNode final : public olive::Node { public: TestNode() { - AddInput(QStringLiteral("Value"), olive::NodeValue::kFloat); + add_input(QStringLiteral("Value"), olive::NodeValue::k_float); olive::SplitValue value; value.append(3.5); - SetSplitStandardValue(QStringLiteral("Value"), value, -1); + set_split_standard_value(QStringLiteral("Value"), value, -1); } TestNode *copy() const override @@ -27,7 +27,7 @@ public: return new TestNode(); } - QString Name() const override + QString name() const override { return QStringLiteral("TestNode"); } @@ -37,17 +37,17 @@ public: return QStringLiteral("org.olivevideoeditor.TestNode"); } - QVector Category() const override + QVector category() const override { - return { kCategoryUnknown }; + return { k_category_unknown }; } - QString Description() const override + QString description() const override { return QStringLiteral("Test node for serialization"); } - void Value(const olive::NodeValueRow &, const olive::NodeGlobals &, + void value(const olive::NodeValueRow &, const olive::NodeGlobals &, olive::NodeValueTable *) const override { } @@ -59,12 +59,12 @@ TEST(NodeSerialization, SaveAndLoadInput) const bool created_disk_manager = (olive::DiskManager::instance() == nullptr); if (created_disk_manager) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } TestNode node; - node.SetLabel(QStringLiteral("MyNode")); - node.SetOverrideColor(2); + node.set_label(QStringLiteral("MyNode")); + node.set_override_color(2); QByteArray xml; QBuffer buffer(&xml); @@ -72,7 +72,7 @@ TEST(NodeSerialization, SaveAndLoadInput) QXmlStreamWriter writer(&buffer); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("node")); - node.Save(&writer); + node.save(&writer); writer.writeEndElement(); writer.writeEndDocument(); buffer.close(); @@ -84,16 +84,16 @@ TEST(NodeSerialization, SaveAndLoadInput) QXmlStreamReader reader(&read_buffer); EXPECT_TRUE(reader.readNextStartElement()); EXPECT_EQ(reader.name().toString(), QStringLiteral("node")); - EXPECT_TRUE(loaded.Load(&reader, &data)); + EXPECT_TRUE(loaded.load(&reader, &data)); - EXPECT_EQ(loaded.GetLabel(), QStringLiteral("MyNode")); - EXPECT_EQ(loaded.GetOverrideColor(), 2); - EXPECT_DOUBLE_EQ(loaded.GetSplitStandardValue(QStringLiteral("Value"), -1) + EXPECT_EQ(loaded.get_label(), QStringLiteral("MyNode")); + EXPECT_EQ(loaded.get_override_color(), 2); + EXPECT_DOUBLE_EQ(loaded.get_split_standard_value(QStringLiteral("Value"), -1) .first() .toDouble(), 3.5); if (created_disk_manager) { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } } diff --git a/tests/gtest/node_time_test.cpp b/tests/gtest/node_time_test.cpp index b7f996d22..2f8fb2afe 100644 --- a/tests/gtest/node_time_test.cpp +++ b/tests/gtest/node_time_test.cpp @@ -25,25 +25,25 @@ class NodeTimeTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - template T *AddNode() + template T *add_node() { T *node = new T(); node->setParent(project_.get()); return node; } - olive::NodeKeyframe *AddKey(olive::Node *node, const QString &input, - const olive::core::rational &time, + olive::NodeKeyframe *add_key(olive::Node *node, const QString &input, + const olive::core::Rational &time, const QVariant &value) { auto *key = new olive::NodeKeyframe( - time, value, olive::NodeKeyframe::kLinear, 0, -1, input); + time, value, olive::NodeKeyframe::k_linear, 0, -1, input); key->setParent(node); return key; } @@ -51,12 +51,12 @@ protected: // Generates the node's output table at a single time with a fresh // traverser (the traverser caches tables per node+range, so reusing one // would return stale values after the node's parameters change) - olive::NodeValueTable GenerateTable(const olive::Node *node, - const olive::core::rational &time) + olive::NodeValueTable generate_table(const olive::Node *node, + const olive::core::Rational &time) { olive::NodeTraverser traverser; - return traverser.GenerateTable( - node, olive::TimeRange(time, time + olive::core::rational(1, 30))); + return traverser.generate_table( + node, olive::TimeRange(time, time + olive::core::Rational(1, 30))); } std::unique_ptr project_; @@ -68,39 +68,39 @@ TEST(GapBlock, Metadata) { olive::GapBlock gap; - EXPECT_EQ(gap.Name(), QStringLiteral("Gap")); + EXPECT_EQ(gap.name(), QStringLiteral("Gap")); EXPECT_EQ(gap.id(), QStringLiteral("org.olivevideoeditor.Olive.gap")); - EXPECT_FALSE(gap.Description().isEmpty()); - EXPECT_TRUE(gap.Category().contains(olive::Node::kCategoryTimeline)); + EXPECT_FALSE(gap.description().isEmpty()); + EXPECT_TRUE(gap.category().contains(olive::Node::k_category_timeline)); } TEST(GapBlock, DefaultLengthIsZero) { olive::GapBlock gap; - EXPECT_EQ(gap.length(), olive::core::rational(0)); + EXPECT_EQ(gap.length(), olive::core::Rational(0)); } TEST_F(NodeTimeTest, GapBlockStoresRationalLength) { - auto *gap = AddNode(); + auto *gap = add_node(); - gap->set_length_and_media_out(olive::core::rational(7, 2)); - EXPECT_EQ(gap->length(), olive::core::rational(7, 2)); + gap->set_length_and_media_out(olive::core::Rational(7, 2)); + EXPECT_EQ(gap->length(), olive::core::Rational(7, 2)); - gap->set_length_and_media_out(olive::core::rational(0)); - EXPECT_EQ(gap->length(), olive::core::rational(0)); + gap->set_length_and_media_out(olive::core::Rational(0)); + EXPECT_EQ(gap->length(), olive::core::Rational(0)); } TEST(TimeOffsetNode, Metadata) { olive::TimeOffsetNode offset; - EXPECT_EQ(offset.Name(), QStringLiteral("Time Offset")); + EXPECT_EQ(offset.name(), QStringLiteral("Time Offset")); EXPECT_EQ(offset.id(), QStringLiteral("org.olivevideoeditor.Olive.timeoffset")); - EXPECT_FALSE(offset.Description().isEmpty()); - EXPECT_TRUE(offset.Category().contains(olive::Node::kCategoryTime)); + EXPECT_FALSE(offset.description().isEmpty()); + EXPECT_TRUE(offset.category().contains(olive::Node::k_category_time)); } TEST(TimeOffsetNode, InputFlags) @@ -108,365 +108,365 @@ TEST(TimeOffsetNode, InputFlags) olive::TimeOffsetNode offset; // The time parameter is keyframable but cannot take an edge - EXPECT_FALSE(offset.IsInputConnectable(olive::TimeOffsetNode::kTimeInput)); - EXPECT_TRUE(offset.IsInputKeyframable(olive::TimeOffsetNode::kTimeInput)); + EXPECT_FALSE(offset.is_input_connectable(olive::TimeOffsetNode::k_time_input)); + EXPECT_TRUE(offset.is_input_keyframable(olive::TimeOffsetNode::k_time_input)); // The data input takes an edge but cannot be keyframed - EXPECT_TRUE(offset.IsInputConnectable(olive::TimeOffsetNode::kInputInput)); - EXPECT_FALSE(offset.IsInputKeyframable(olive::TimeOffsetNode::kInputInput)); + EXPECT_TRUE(offset.is_input_connectable(olive::TimeOffsetNode::k_input_input)); + EXPECT_FALSE(offset.is_input_keyframable(olive::TimeOffsetNode::k_input_input)); // The time offset defaults to zero - EXPECT_EQ(offset.GetStandardValue(olive::TimeOffsetNode::kTimeInput) - .value(), - olive::core::rational(0)); + EXPECT_EQ(offset.get_standard_value(olive::TimeOffsetNode::k_time_input) + .value(), + olive::core::Rational(0)); } TEST(TimeOffsetNode, RetranslateSetsInputNames) { olive::TimeOffsetNode offset; - offset.Retranslate(); + offset.retranslate(); - EXPECT_EQ(offset.GetInputName(olive::TimeOffsetNode::kTimeInput), + EXPECT_EQ(offset.get_input_name(olive::TimeOffsetNode::k_time_input), QStringLiteral("Time")); - EXPECT_EQ(offset.GetInputName(olive::TimeOffsetNode::kInputInput), + EXPECT_EQ(offset.get_input_name(olive::TimeOffsetNode::k_input_input), QStringLiteral("Input")); } TEST_F(NodeTimeTest, TimeOffsetAppliesStaticOffset) { - auto *offset = AddNode(); - offset->SetStandardValue(olive::TimeOffsetNode::kTimeInput, - QVariant::fromValue(olive::core::rational(3))); + auto *offset = add_node(); + offset->set_standard_value(olive::TimeOffsetNode::k_time_input, + QVariant::fromValue(olive::core::Rational(3))); // The connected input is evaluated offset seconds later - EXPECT_EQ(offset->InputTimeAdjustment( - olive::TimeOffsetNode::kInputInput, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4)), + EXPECT_EQ(offset->input_time_adjustment( + olive::TimeOffsetNode::k_input_input, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)), true), - olive::TimeRange(olive::core::rational(5), - olive::core::rational(7))); + olive::TimeRange(olive::core::Rational(5), + olive::core::Rational(7))); // Any other input passes time through unchanged - const olive::TimeRange range(olive::core::rational(2), - olive::core::rational(4)); - EXPECT_EQ(offset->InputTimeAdjustment(olive::TimeOffsetNode::kTimeInput, + const olive::TimeRange range(olive::core::Rational(2), + olive::core::Rational(4)); + EXPECT_EQ(offset->input_time_adjustment(olive::TimeOffsetNode::k_time_input, -1, range, true), range); } TEST_F(NodeTimeTest, TimeOffsetAppliesNegativeOffset) { - auto *offset = AddNode(); - offset->SetStandardValue(olive::TimeOffsetNode::kTimeInput, - QVariant::fromValue(olive::core::rational(-3))); + auto *offset = add_node(); + offset->set_standard_value(olive::TimeOffsetNode::k_time_input, + QVariant::fromValue(olive::core::Rational(-3))); // Negative offsets move the requested time before the sequence time, // even across zero - EXPECT_EQ(offset->InputTimeAdjustment( - olive::TimeOffsetNode::kInputInput, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4)), + EXPECT_EQ(offset->input_time_adjustment( + olive::TimeOffsetNode::k_input_input, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)), true), - olive::TimeRange(olive::core::rational(-1), - olive::core::rational(1))); + olive::TimeRange(olive::core::Rational(-1), + olive::core::Rational(1))); } TEST_F(NodeTimeTest, TimeOffsetZeroOffsetIsIdentity) { - auto *offset = AddNode(); + auto *offset = add_node(); - const olive::TimeRange range(olive::core::rational(2), - olive::core::rational(4)); - EXPECT_EQ(offset->InputTimeAdjustment(olive::TimeOffsetNode::kInputInput, + const olive::TimeRange range(olive::core::Rational(2), + olive::core::Rational(4)); + EXPECT_EQ(offset->input_time_adjustment(olive::TimeOffsetNode::k_input_input, -1, range, true), range); } TEST_F(NodeTimeTest, TimeOffsetOutputAdjustmentAppliesInverseOffset) { - auto *offset = AddNode(); - offset->SetStandardValue(olive::TimeOffsetNode::kTimeInput, - QVariant::fromValue(olive::core::rational(3))); + auto *offset = add_node(); + offset->set_standard_value(olive::TimeOffsetNode::k_time_input, + QVariant::fromValue(olive::core::Rational(3))); // The inverse mapping subtracts the offset again: input-side times are // mapped back to the output by the negated offset - EXPECT_EQ(offset->OutputTimeAdjustment( - olive::TimeOffsetNode::kInputInput, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4))), - olive::TimeRange(olive::core::rational(-1), - olive::core::rational(1))); + EXPECT_EQ(offset->output_time_adjustment( + olive::TimeOffsetNode::k_input_input, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4))), + olive::TimeRange(olive::core::Rational(-1), + olive::core::Rational(1))); // Non-input inputs never adjust time - const olive::TimeRange range(olive::core::rational(2), - olive::core::rational(4)); - EXPECT_EQ(offset->OutputTimeAdjustment(olive::TimeOffsetNode::kTimeInput, + const olive::TimeRange range(olive::core::Rational(2), + olive::core::Rational(4)); + EXPECT_EQ(offset->output_time_adjustment(olive::TimeOffsetNode::k_time_input, -1, range), range); // Round trip through both adjustments returns the original range - EXPECT_EQ(offset->OutputTimeAdjustment( - olive::TimeOffsetNode::kInputInput, -1, - offset->InputTimeAdjustment( - olive::TimeOffsetNode::kInputInput, -1, range, true)), + EXPECT_EQ(offset->output_time_adjustment( + olive::TimeOffsetNode::k_input_input, -1, + offset->input_time_adjustment( + olive::TimeOffsetNode::k_input_input, -1, range, true)), range); } TEST_F(NodeTimeTest, TimeOffsetAppliesKeyframedOffset) { - auto *offset = AddNode(); - offset->SetInputIsKeyframing(olive::TimeOffsetNode::kTimeInput, true); + auto *offset = add_node(); + offset->set_input_is_keyframing(olive::TimeOffsetNode::k_time_input, true); - AddKey(offset, olive::TimeOffsetNode::kTimeInput, olive::core::rational(0), - QVariant::fromValue(olive::core::rational(0))); - AddKey(offset, olive::TimeOffsetNode::kTimeInput, - olive::core::rational(10), - QVariant::fromValue(olive::core::rational(10))); + add_key(offset, olive::TimeOffsetNode::k_time_input, olive::core::Rational(0), + QVariant::fromValue(olive::core::Rational(0))); + add_key(offset, olive::TimeOffsetNode::k_time_input, + olive::core::Rational(10), + QVariant::fromValue(olive::core::Rational(10))); // The offset is sampled per endpoint: 2 + 2 = 4 and 4 + 4 = 8 - EXPECT_EQ(offset->InputTimeAdjustment( - olive::TimeOffsetNode::kInputInput, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4)), + EXPECT_EQ(offset->input_time_adjustment( + olive::TimeOffsetNode::k_input_input, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)), true), - olive::TimeRange(olive::core::rational(4), - olive::core::rational(8))); + olive::TimeRange(olive::core::Rational(4), + olive::core::Rational(8))); } TEST_F(NodeTimeTest, TimeOffsetValuePassesConnectedInputThrough) { - auto *offset = AddNode(); - offset->SetStandardValue(olive::TimeOffsetNode::kTimeInput, - QVariant::fromValue(olive::core::rational(5))); + auto *offset = add_node(); + offset->set_standard_value(olive::TimeOffsetNode::k_time_input, + QVariant::fromValue(olive::core::Rational(5))); - auto *time = AddNode(); - olive::Node::ConnectEdge( - time, olive::NodeInput(offset, olive::TimeOffsetNode::kInputInput)); + auto *time = add_node(); + olive::Node::connect_edge( + time, olive::NodeInput(offset, olive::TimeOffsetNode::k_input_input)); // The connected node is evaluated at the offset time: 3 + 5 = 8 - const olive::NodeValueTable table = GenerateTable(offset, olive::core::rational(3)); - EXPECT_DOUBLE_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 8.0); + const olive::NodeValueTable table = generate_table(offset, olive::core::Rational(3)); + EXPECT_DOUBLE_EQ(table.get(olive::NodeValue::k_float).to_double(), 8.0); } TEST_F(NodeTimeTest, TimeOffsetValueWithoutConnectionProducesNoFloat) { - auto *offset = AddNode(); + auto *offset = add_node(); // With nothing connected the node pushes the (typeless) standard value - const olive::NodeValueTable table = GenerateTable(offset, olive::core::rational(3)); - EXPECT_EQ(table.Get(olive::NodeValue::kFloat).type(), - olive::NodeValue::kNone); + const olive::NodeValueTable table = generate_table(offset, olive::core::Rational(3)); + EXPECT_EQ(table.get(olive::NodeValue::k_float).type(), + olive::NodeValue::k_none); } TEST(TimeRemapNode, Metadata) { olive::TimeRemapNode remap; - EXPECT_EQ(remap.Name(), QStringLiteral("Time Remap")); + EXPECT_EQ(remap.name(), QStringLiteral("Time Remap")); EXPECT_EQ(remap.id(), QStringLiteral("org.olivevideoeditor.Olive.timeremap")); - EXPECT_FALSE(remap.Description().isEmpty()); - EXPECT_TRUE(remap.Category().contains(olive::Node::kCategoryTime)); + EXPECT_FALSE(remap.description().isEmpty()); + EXPECT_TRUE(remap.category().contains(olive::Node::k_category_time)); } TEST(TimeRemapNode, InputFlags) { olive::TimeRemapNode remap; - EXPECT_FALSE(remap.IsInputConnectable(olive::TimeRemapNode::kTimeInput)); - EXPECT_TRUE(remap.IsInputKeyframable(olive::TimeRemapNode::kTimeInput)); + EXPECT_FALSE(remap.is_input_connectable(olive::TimeRemapNode::k_time_input)); + EXPECT_TRUE(remap.is_input_keyframable(olive::TimeRemapNode::k_time_input)); - EXPECT_TRUE(remap.IsInputConnectable(olive::TimeRemapNode::kInputInput)); - EXPECT_FALSE(remap.IsInputKeyframable(olive::TimeRemapNode::kInputInput)); + EXPECT_TRUE(remap.is_input_connectable(olive::TimeRemapNode::k_input_input)); + EXPECT_FALSE(remap.is_input_keyframable(olive::TimeRemapNode::k_input_input)); - EXPECT_EQ(remap.GetStandardValue(olive::TimeRemapNode::kTimeInput) - .value(), - olive::core::rational(0)); + EXPECT_EQ(remap.get_standard_value(olive::TimeRemapNode::k_time_input) + .value(), + olive::core::Rational(0)); } TEST(TimeRemapNode, RetranslateSetsInputNames) { olive::TimeRemapNode remap; - remap.Retranslate(); + remap.retranslate(); - EXPECT_EQ(remap.GetInputName(olive::TimeRemapNode::kTimeInput), + EXPECT_EQ(remap.get_input_name(olive::TimeRemapNode::k_time_input), QStringLiteral("Time")); - EXPECT_EQ(remap.GetInputName(olive::TimeRemapNode::kInputInput), + EXPECT_EQ(remap.get_input_name(olive::TimeRemapNode::k_input_input), QStringLiteral("Input")); } TEST_F(NodeTimeTest, TimeRemapStaticTimeCollapsesRange) { - auto *remap = AddNode(); - remap->SetStandardValue(olive::TimeRemapNode::kTimeInput, - QVariant::fromValue(olive::core::rational(7))); + auto *remap = add_node(); + remap->set_standard_value(olive::TimeRemapNode::k_time_input, + QVariant::fromValue(olive::core::Rational(7))); // A constant remap maps every sequence time onto the same media time - const olive::TimeRange adjusted = remap->InputTimeAdjustment( - olive::TimeRemapNode::kInputInput, -1, - olive::TimeRange(olive::core::rational(2), olive::core::rational(4)), + const olive::TimeRange adjusted = remap->input_time_adjustment( + olive::TimeRemapNode::k_input_input, -1, + olive::TimeRange(olive::core::Rational(2), olive::core::Rational(4)), true); - EXPECT_EQ(adjusted.in(), olive::core::rational(7)); - EXPECT_EQ(adjusted.out(), olive::core::rational(7)); + EXPECT_EQ(adjusted.in(), olive::core::Rational(7)); + EXPECT_EQ(adjusted.out(), olive::core::Rational(7)); } TEST_F(NodeTimeTest, TimeRemapNonInputPassesThrough) { - auto *remap = AddNode(); - remap->SetStandardValue(olive::TimeRemapNode::kTimeInput, - QVariant::fromValue(olive::core::rational(7))); + auto *remap = add_node(); + remap->set_standard_value(olive::TimeRemapNode::k_time_input, + QVariant::fromValue(olive::core::Rational(7))); - const olive::TimeRange range(olive::core::rational(2), - olive::core::rational(4)); - EXPECT_EQ(remap->InputTimeAdjustment(olive::TimeRemapNode::kTimeInput, -1, + const olive::TimeRange range(olive::core::Rational(2), + olive::core::Rational(4)); + EXPECT_EQ(remap->input_time_adjustment(olive::TimeRemapNode::k_time_input, -1, range, true), range); - EXPECT_EQ(remap->OutputTimeAdjustment(olive::TimeRemapNode::kInputInput, + EXPECT_EQ(remap->output_time_adjustment(olive::TimeRemapNode::k_input_input, -1, range), range); - EXPECT_EQ(remap->OutputTimeAdjustment(olive::TimeRemapNode::kTimeInput, -1, + EXPECT_EQ(remap->output_time_adjustment(olive::TimeRemapNode::k_time_input, -1, range), range); } TEST_F(NodeTimeTest, TimeRemapAppliesKeyframedLinearRamp) { - auto *remap = AddNode(); - remap->SetInputIsKeyframing(olive::TimeRemapNode::kTimeInput, true); + auto *remap = add_node(); + remap->set_input_is_keyframing(olive::TimeRemapNode::k_time_input, true); - AddKey(remap, olive::TimeRemapNode::kTimeInput, olive::core::rational(0), - QVariant::fromValue(olive::core::rational(0))); - AddKey(remap, olive::TimeRemapNode::kTimeInput, olive::core::rational(10), - QVariant::fromValue(olive::core::rational(100))); + add_key(remap, olive::TimeRemapNode::k_time_input, olive::core::Rational(0), + QVariant::fromValue(olive::core::Rational(0))); + add_key(remap, olive::TimeRemapNode::k_time_input, olive::core::Rational(10), + QVariant::fromValue(olive::core::Rational(100))); // The linear ramp multiplies time by ten: 2 -> 20 and 4 -> 40 - EXPECT_EQ(remap->InputTimeAdjustment( - olive::TimeRemapNode::kInputInput, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4)), + EXPECT_EQ(remap->input_time_adjustment( + olive::TimeRemapNode::k_input_input, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)), true), - olive::TimeRange(olive::core::rational(20), - olive::core::rational(40))); + olive::TimeRange(olive::core::Rational(20), + olive::core::Rational(40))); } TEST_F(NodeTimeTest, TimeRemapReversedRampNormalizesRange) { - auto *remap = AddNode(); - remap->SetInputIsKeyframing(olive::TimeRemapNode::kTimeInput, true); + auto *remap = add_node(); + remap->set_input_is_keyframing(olive::TimeRemapNode::k_time_input, true); - AddKey(remap, olive::TimeRemapNode::kTimeInput, olive::core::rational(0), - QVariant::fromValue(olive::core::rational(10))); - AddKey(remap, olive::TimeRemapNode::kTimeInput, olive::core::rational(10), - QVariant::fromValue(olive::core::rational(0))); + add_key(remap, olive::TimeRemapNode::k_time_input, olive::core::Rational(0), + QVariant::fromValue(olive::core::Rational(10))); + add_key(remap, olive::TimeRemapNode::k_time_input, olive::core::Rational(10), + QVariant::fromValue(olive::core::Rational(0))); // Decreasing time values invert the range: 2 -> 8 and 4 -> 6, which // TimeRange normalizes back to [6, 8] - EXPECT_EQ(remap->InputTimeAdjustment( - olive::TimeRemapNode::kInputInput, -1, - olive::TimeRange(olive::core::rational(2), - olive::core::rational(4)), + EXPECT_EQ(remap->input_time_adjustment( + olive::TimeRemapNode::k_input_input, -1, + olive::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)), true), - olive::TimeRange(olive::core::rational(6), - olive::core::rational(8))); + olive::TimeRange(olive::core::Rational(6), + olive::core::Rational(8))); } TEST_F(NodeTimeTest, TimeRemapValuePassesConnectedInputThrough) { - auto *remap = AddNode(); - remap->SetInputIsKeyframing(olive::TimeRemapNode::kTimeInput, true); + auto *remap = add_node(); + remap->set_input_is_keyframing(olive::TimeRemapNode::k_time_input, true); - AddKey(remap, olive::TimeRemapNode::kTimeInput, olive::core::rational(0), - QVariant::fromValue(olive::core::rational(0))); - AddKey(remap, olive::TimeRemapNode::kTimeInput, olive::core::rational(10), - QVariant::fromValue(olive::core::rational(100))); + add_key(remap, olive::TimeRemapNode::k_time_input, olive::core::Rational(0), + QVariant::fromValue(olive::core::Rational(0))); + add_key(remap, olive::TimeRemapNode::k_time_input, olive::core::Rational(10), + QVariant::fromValue(olive::core::Rational(100))); - auto *time = AddNode(); - olive::Node::ConnectEdge( - time, olive::NodeInput(remap, olive::TimeRemapNode::kInputInput)); + auto *time = add_node(); + olive::Node::connect_edge( + time, olive::NodeInput(remap, olive::TimeRemapNode::k_input_input)); // The connected node is evaluated at the remapped time: 3 -> 30 - const olive::NodeValueTable table = GenerateTable(remap, olive::core::rational(3)); - EXPECT_DOUBLE_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 30.0); + const olive::NodeValueTable table = generate_table(remap, olive::core::Rational(3)); + EXPECT_DOUBLE_EQ(table.get(olive::NodeValue::k_float).to_double(), 30.0); } TEST(TimeFormatNode, Metadata) { olive::TimeFormatNode format; - EXPECT_EQ(format.Name(), QStringLiteral("Time Format")); + EXPECT_EQ(format.name(), QStringLiteral("Time Format")); EXPECT_EQ(format.id(), QStringLiteral("org.olivevideoeditor.Olive.timeformat")); - EXPECT_FALSE(format.Description().isEmpty()); - EXPECT_TRUE(format.Category().contains(olive::Node::kCategoryGenerator)); + EXPECT_FALSE(format.description().isEmpty()); + EXPECT_TRUE(format.category().contains(olive::Node::k_category_generator)); } TEST(TimeFormatNode, RetranslateSetsInputNames) { olive::TimeFormatNode format; - format.Retranslate(); + format.retranslate(); - EXPECT_EQ(format.GetInputName(olive::TimeFormatNode::kTimeInput), + EXPECT_EQ(format.get_input_name(olive::TimeFormatNode::k_time_input), QStringLiteral("Time")); - EXPECT_EQ(format.GetInputName(olive::TimeFormatNode::kFormatInput), + EXPECT_EQ(format.get_input_name(olive::TimeFormatNode::k_format_input), QStringLiteral("Format")); - EXPECT_EQ(format.GetInputName(olive::TimeFormatNode::kLocalTimeInput), + EXPECT_EQ(format.get_input_name(olive::TimeFormatNode::k_local_time_input), QStringLiteral("Interpret time as local time")); } TEST_F(NodeTimeTest, TimeFormatDefaultsToUtcEpoch) { - auto *format = AddNode(); + auto *format = add_node(); // Local time interpretation is off by default, keeping output // independent of the machine timezone - EXPECT_FALSE(format->GetStandardValue(olive::TimeFormatNode::kLocalTimeInput) + EXPECT_FALSE(format->get_standard_value(olive::TimeFormatNode::k_local_time_input) .toBool()); - EXPECT_EQ(format->GetStandardValue(olive::TimeFormatNode::kFormatInput) + EXPECT_EQ(format->get_standard_value(olive::TimeFormatNode::k_format_input) .toString(), QStringLiteral("hh:mm:ss")); // A null time value behaves as 0, the Unix epoch - const olive::NodeValueTable table = GenerateTable(format, olive::core::rational(0)); - EXPECT_EQ(table.Get(olive::NodeValue::kText).toString(), + const olive::NodeValueTable table = generate_table(format, olive::core::Rational(0)); + EXPECT_EQ(table.get(olive::NodeValue::k_text).to_string(), QStringLiteral("00:00:00")); } TEST_F(NodeTimeTest, TimeFormatFormatsUtcTime) { - auto *format = AddNode(); - format->SetStandardValue(olive::TimeFormatNode::kTimeInput, 3661.0); + auto *format = add_node(); + format->set_standard_value(olive::TimeFormatNode::k_time_input, 3661.0); - const olive::NodeValueTable table = GenerateTable(format, olive::core::rational(0)); - EXPECT_EQ(table.Get(olive::NodeValue::kText).toString(), + const olive::NodeValueTable table = generate_table(format, olive::core::Rational(0)); + EXPECT_EQ(table.get(olive::NodeValue::k_text).to_string(), QStringLiteral("01:01:01")); } TEST_F(NodeTimeTest, TimeFormatHonorsCustomFormat) { - auto *format = AddNode(); - format->SetStandardValue(olive::TimeFormatNode::kTimeInput, 3661.0); - format->SetStandardValue(olive::TimeFormatNode::kFormatInput, + auto *format = add_node(); + format->set_standard_value(olive::TimeFormatNode::k_time_input, 3661.0); + format->set_standard_value(olive::TimeFormatNode::k_format_input, QStringLiteral("yyyy-MM-dd mm:ss")); // The custom format replaces the default; 3661s = 01:01:01 UTC - const olive::NodeValueTable table = GenerateTable(format, olive::core::rational(0)); - EXPECT_EQ(table.Get(olive::NodeValue::kText).toString(), + const olive::NodeValueTable table = generate_table(format, olive::core::Rational(0)); + EXPECT_EQ(table.get(olive::NodeValue::k_text).to_string(), QStringLiteral("1970-01-01 01:01")); } TEST_F(NodeTimeTest, TimeFormatFormatsNegativeTimeBeforeEpoch) { - auto *format = AddNode(); - format->SetStandardValue(olive::TimeFormatNode::kTimeInput, -1.0); - format->SetStandardValue(olive::TimeFormatNode::kFormatInput, + auto *format = add_node(); + format->set_standard_value(olive::TimeFormatNode::k_time_input, -1.0); + format->set_standard_value(olive::TimeFormatNode::k_format_input, QStringLiteral("yyyy-MM-dd hh:mm:ss")); // One second before the epoch - const olive::NodeValueTable table = GenerateTable(format, olive::core::rational(0)); - EXPECT_EQ(table.Get(olive::NodeValue::kText).toString(), + const olive::NodeValueTable table = generate_table(format, olive::core::Rational(0)); + EXPECT_EQ(table.get(olive::NodeValue::k_text).to_string(), QStringLiteral("1969-12-31 23:59:59")); } diff --git a/tests/gtest/node_undo_test.cpp b/tests/gtest/node_undo_test.cpp index 48acfe41a..c73e33638 100644 --- a/tests/gtest/node_undo_test.cpp +++ b/tests/gtest/node_undo_test.cpp @@ -20,13 +20,13 @@ class NodeUndoTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - template T *AddNode() + template T *add_node() { T *node = new T(); node->setParent(project_.get()); @@ -44,9 +44,9 @@ TEST_F(NodeUndoTest, AddCommandAddsAndRemovesNodeFromProject) // The constructor takes ownership of the node without adding it to the graph EXPECT_FALSE(project_->nodes().contains(node)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); - cmd.PushToThread(QCoreApplication::instance()->thread()); + cmd.push_to_thread(QCoreApplication::instance()->thread()); cmd.redo_now(); EXPECT_TRUE(project_->nodes().contains(node)); @@ -60,32 +60,32 @@ TEST_F(NodeUndoTest, AddCommandAddsAndRemovesNodeFromProject) TEST_F(NodeUndoTest, RemoveAndDisconnectCommandRestoresGraphState) { - auto *src = AddNode(); - auto *mid = AddNode(); - auto *dst = AddNode(); - auto *link_peer = AddNode(); - auto *context = AddNode(); + auto *src = add_node(); + auto *mid = add_node(); + auto *dst = add_node(); + auto *link_peer = add_node(); + auto *context = add_node(); - olive::Node::ConnectEdge( - src, olive::NodeInput(mid, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge( - mid, olive::NodeInput(dst, olive::MathNode::kParamBIn)); - olive::Node::Link(mid, link_peer); - context->SetNodePositionInContext( + olive::Node::connect_edge( + src, olive::NodeInput(mid, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge( + mid, olive::NodeInput(dst, olive::MathNode::k_param_b_in)); + olive::Node::link(mid, link_peer); + context->set_node_position_in_context( mid, olive::Node::Position(QPointF(3.0, 4.0), true)); olive::NodeRemoveAndDisconnectCommand cmd(mid); cmd.redo_now(); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); EXPECT_EQ(mid->project(), nullptr); EXPECT_FALSE(project_->nodes().contains(mid)); EXPECT_TRUE(mid->input_connections().empty()); EXPECT_TRUE(mid->output_connections().empty()); EXPECT_TRUE(src->output_connections().empty()); EXPECT_TRUE(dst->input_connections().empty()); - EXPECT_FALSE(context->ContextContainsNode(mid)); - EXPECT_FALSE(mid->HasLinks()); + EXPECT_FALSE(context->context_contains_node(mid)); + EXPECT_FALSE(mid->has_links()); cmd.undo_now(); @@ -93,28 +93,28 @@ TEST_F(NodeUndoTest, RemoveAndDisconnectCommandRestoresGraphState) EXPECT_TRUE(project_->nodes().contains(mid)); ASSERT_EQ(src->output_connections().size(), 1); EXPECT_EQ(src->output_connections().front().second, - olive::NodeInput(mid, olive::MathNode::kParamAIn)); + olive::NodeInput(mid, olive::MathNode::k_param_a_in)); EXPECT_EQ(dst->input_connections().at( - olive::NodeInput(dst, olive::MathNode::kParamBIn)), + olive::NodeInput(dst, olive::MathNode::k_param_b_in)), mid); - ASSERT_TRUE(context->ContextContainsNode(mid)); - EXPECT_EQ(context->GetNodePositionInContext(mid), QPointF(3.0, 4.0)); - EXPECT_TRUE(olive::Node::AreLinked(mid, link_peer)); + ASSERT_TRUE(context->context_contains_node(mid)); + EXPECT_EQ(context->get_node_position_in_context(mid), QPointF(3.0, 4.0)); + EXPECT_TRUE(olive::Node::are_linked(mid, link_peer)); } TEST_F(NodeUndoTest, RemoveWithExclusiveDependenciesRemovesUpstreamChain) { - auto *src = AddNode(); - auto *dep = AddNode(); - auto *node = AddNode(); + auto *src = add_node(); + auto *dep = add_node(); + auto *node = add_node(); - olive::Node::ConnectEdge( - src, olive::NodeInput(dep, olive::MathNode::kParamAIn)); - olive::Node::ConnectEdge( - dep, olive::NodeInput(node, olive::MathNode::kParamAIn)); + olive::Node::connect_edge( + src, olive::NodeInput(dep, olive::MathNode::k_param_a_in)); + olive::Node::connect_edge( + dep, olive::NodeInput(node, olive::MathNode::k_param_a_in)); olive::NodeRemoveWithExclusiveDependenciesAndDisconnect cmd(node); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); @@ -125,7 +125,7 @@ TEST_F(NodeUndoTest, RemoveWithExclusiveDependenciesRemovesUpstreamChain) EXPECT_TRUE(node->input_connections().empty()); EXPECT_TRUE(dep->input_connections().empty()); EXPECT_TRUE(src->output_connections().empty()); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.undo_now(); @@ -133,219 +133,219 @@ TEST_F(NodeUndoTest, RemoveWithExclusiveDependenciesRemovesUpstreamChain) EXPECT_EQ(dep->project(), project_.get()); EXPECT_EQ(src->project(), project_.get()); EXPECT_EQ(node->input_connections().at( - olive::NodeInput(node, olive::MathNode::kParamAIn)), + olive::NodeInput(node, olive::MathNode::k_param_a_in)), dep); EXPECT_EQ(dep->input_connections().at( - olive::NodeInput(dep, olive::MathNode::kParamAIn)), + olive::NodeInput(dep, olive::MathNode::k_param_a_in)), src); } TEST_F(NodeUndoTest, EdgeAddCommandConnectsAndDisconnects) { - auto *output = AddNode(); - auto *input_node = AddNode(); - const olive::NodeInput input(input_node, olive::MathNode::kParamAIn); + auto *output = add_node(); + auto *input_node = add_node(); + const olive::NodeInput input(input_node, olive::MathNode::k_param_a_in); olive::NodeEdgeAddCommand cmd(output, input); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_TRUE(input.IsConnected()); - EXPECT_EQ(input.GetConnectedOutput(), output); + EXPECT_TRUE(input.is_connected()); + EXPECT_EQ(input.get_connected_output(), output); EXPECT_EQ(output->output_connections().size(), 1); cmd.undo_now(); - EXPECT_FALSE(input.IsConnected()); + EXPECT_FALSE(input.is_connected()); EXPECT_TRUE(output->output_connections().empty()); } TEST_F(NodeUndoTest, EdgeAddCommandReplacesExistingConnection) { - auto *first = AddNode(); - auto *second = AddNode(); - auto *input_node = AddNode(); - const olive::NodeInput input(input_node, olive::MathNode::kParamAIn); + auto *first = add_node(); + auto *second = add_node(); + auto *input_node = add_node(); + const olive::NodeInput input(input_node, olive::MathNode::k_param_a_in); - olive::Node::ConnectEdge(first, input); - ASSERT_EQ(input.GetConnectedOutput(), first); + olive::Node::connect_edge(first, input); + ASSERT_EQ(input.get_connected_output(), first); olive::NodeEdgeAddCommand cmd(second, input); cmd.redo_now(); // The previous edge must be disconnected before the new one is made - EXPECT_EQ(input.GetConnectedOutput(), second); + EXPECT_EQ(input.get_connected_output(), second); EXPECT_TRUE(first->output_connections().empty()); cmd.undo_now(); // Undoing must restore the connection that was replaced - EXPECT_EQ(input.GetConnectedOutput(), first); + EXPECT_EQ(input.get_connected_output(), first); EXPECT_TRUE(second->output_connections().empty()); } TEST_F(NodeUndoTest, EdgeRemoveCommandDisconnectsAndReconnects) { - auto *output = AddNode(); - auto *input_node = AddNode(); - const olive::NodeInput input(input_node, olive::MathNode::kParamBIn); + auto *output = add_node(); + auto *input_node = add_node(); + const olive::NodeInput input(input_node, olive::MathNode::k_param_b_in); - olive::Node::ConnectEdge(output, input); - ASSERT_TRUE(input.IsConnected()); + olive::Node::connect_edge(output, input); + ASSERT_TRUE(input.is_connected()); olive::NodeEdgeRemoveCommand cmd(output, input); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_FALSE(input.IsConnected()); + EXPECT_FALSE(input.is_connected()); EXPECT_TRUE(output->output_connections().empty()); cmd.undo_now(); - EXPECT_TRUE(input.IsConnected()); - EXPECT_EQ(input.GetConnectedOutput(), output); + EXPECT_TRUE(input.is_connected()); + EXPECT_EQ(input.get_connected_output(), output); } TEST_F(NodeUndoTest, SetPositionCommandAddsNodeToContext) { - auto *node = AddNode(); - auto *context = AddNode(); - ASSERT_FALSE(context->ContextContainsNode(node)); + auto *node = add_node(); + auto *context = add_node(); + ASSERT_FALSE(context->context_contains_node(node)); olive::NodeSetPositionCommand cmd( node, context, olive::Node::Position(QPointF(10.0, 20.0), true)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_TRUE(context->ContextContainsNode(node)); - EXPECT_EQ(context->GetNodePositionInContext(node), QPointF(10.0, 20.0)); - EXPECT_TRUE(context->IsNodeExpandedInContext(node)); + ASSERT_TRUE(context->context_contains_node(node)); + EXPECT_EQ(context->get_node_position_in_context(node), QPointF(10.0, 20.0)); + EXPECT_TRUE(context->is_node_expanded_in_context(node)); cmd.undo_now(); - EXPECT_FALSE(context->ContextContainsNode(node)); + EXPECT_FALSE(context->context_contains_node(node)); } TEST_F(NodeUndoTest, SetPositionCommandRestoresPreviousPosition) { - auto *node = AddNode(); - auto *context = AddNode(); - context->SetNodePositionInContext( + auto *node = add_node(); + auto *context = add_node(); + context->set_node_position_in_context( node, olive::Node::Position(QPointF(1.0, 2.0))); olive::NodeSetPositionCommand cmd( node, context, olive::Node::Position(QPointF(30.0, 40.0))); cmd.redo_now(); - EXPECT_EQ(context->GetNodePositionInContext(node), QPointF(30.0, 40.0)); + EXPECT_EQ(context->get_node_position_in_context(node), QPointF(30.0, 40.0)); cmd.undo_now(); - ASSERT_TRUE(context->ContextContainsNode(node)); - EXPECT_EQ(context->GetNodePositionInContext(node), QPointF(1.0, 2.0)); + ASSERT_TRUE(context->context_contains_node(node)); + EXPECT_EQ(context->get_node_position_in_context(node), QPointF(1.0, 2.0)); } TEST_F(NodeUndoTest, SetPositionAndDependenciesRecursivelyMovesNode) { - auto *dep = AddNode(); - auto *node = AddNode(); - auto *context = AddNode(); + auto *dep = add_node(); + auto *node = add_node(); + auto *context = add_node(); - olive::Node::ConnectEdge( - dep, olive::NodeInput(node, olive::MathNode::kParamAIn)); + olive::Node::connect_edge( + dep, olive::NodeInput(node, olive::MathNode::k_param_a_in)); - context->SetNodePositionInContext( + context->set_node_position_in_context( dep, olive::Node::Position(QPointF(1.0, 1.0))); - context->SetNodePositionInContext( + context->set_node_position_in_context( node, olive::Node::Position(QPointF(2.0, 3.0))); olive::NodeSetPositionAndDependenciesRecursivelyCommand cmd( node, context, olive::Node::Position(QPointF(8.0, 9.0))); cmd.redo_now(); - EXPECT_EQ(context->GetNodePositionInContext(node), QPointF(8.0, 9.0)); + EXPECT_EQ(context->get_node_position_in_context(node), QPointF(8.0, 9.0)); // The dependency moves by the same delta as the node - EXPECT_EQ(context->GetNodePositionInContext(dep), QPointF(7.0, 7.0)); + EXPECT_EQ(context->get_node_position_in_context(dep), QPointF(7.0, 7.0)); cmd.undo_now(); - EXPECT_EQ(context->GetNodePositionInContext(node), QPointF(2.0, 3.0)); - EXPECT_EQ(context->GetNodePositionInContext(dep), QPointF(1.0, 1.0)); + EXPECT_EQ(context->get_node_position_in_context(node), QPointF(2.0, 3.0)); + EXPECT_EQ(context->get_node_position_in_context(dep), QPointF(1.0, 1.0)); } TEST_F(NodeUndoTest, RemovePositionFromContextCommandRestoresPosition) { - auto *node = AddNode(); - auto *context = AddNode(); - context->SetNodePositionInContext( + auto *node = add_node(); + auto *context = add_node(); + context->set_node_position_in_context( node, olive::Node::Position(QPointF(5.0, 6.0))); olive::NodeRemovePositionFromContextCommand cmd(node, context); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_FALSE(context->ContextContainsNode(node)); + EXPECT_FALSE(context->context_contains_node(node)); cmd.undo_now(); - ASSERT_TRUE(context->ContextContainsNode(node)); - EXPECT_EQ(context->GetNodePositionInContext(node), QPointF(5.0, 6.0)); + ASSERT_TRUE(context->context_contains_node(node)); + EXPECT_EQ(context->get_node_position_in_context(node), QPointF(5.0, 6.0)); } TEST_F(NodeUndoTest, RemovePositionFromContextCommandNoOpWhenAbsent) { - auto *node = AddNode(); - auto *context = AddNode(); + auto *node = add_node(); + auto *context = add_node(); olive::NodeRemovePositionFromContextCommand cmd(node, context); cmd.redo_now(); - EXPECT_FALSE(context->ContextContainsNode(node)); + EXPECT_FALSE(context->context_contains_node(node)); cmd.undo_now(); - EXPECT_FALSE(context->ContextContainsNode(node)); + EXPECT_FALSE(context->context_contains_node(node)); } TEST_F(NodeUndoTest, RemovePositionFromAllContextsCommandRestoresAll) { - auto *node = AddNode(); - auto *ctx_a = AddNode(); - auto *ctx_b = AddNode(); - ctx_a->SetNodePositionInContext( + auto *node = add_node(); + auto *ctx_a = add_node(); + auto *ctx_b = add_node(); + ctx_a->set_node_position_in_context( node, olive::Node::Position(QPointF(1.0, 1.0))); - ctx_b->SetNodePositionInContext( + ctx_b->set_node_position_in_context( node, olive::Node::Position(QPointF(2.0, 2.0))); olive::NodeRemovePositionFromAllContextsCommand cmd(node); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_FALSE(ctx_a->ContextContainsNode(node)); - EXPECT_FALSE(ctx_b->ContextContainsNode(node)); + EXPECT_FALSE(ctx_a->context_contains_node(node)); + EXPECT_FALSE(ctx_b->context_contains_node(node)); cmd.undo_now(); - EXPECT_EQ(ctx_a->GetNodePositionInContext(node), QPointF(1.0, 1.0)); - EXPECT_EQ(ctx_b->GetNodePositionInContext(node), QPointF(2.0, 2.0)); + EXPECT_EQ(ctx_a->get_node_position_in_context(node), QPointF(1.0, 1.0)); + EXPECT_EQ(ctx_b->get_node_position_in_context(node), QPointF(2.0, 2.0)); } TEST_F(NodeUndoTest, RenameCommandSetsAndRestoresLabels) { - auto *a = AddNode(); - auto *b = AddNode(); - a->SetLabel(QStringLiteral("old_a")); - b->SetLabel(QStringLiteral("old_b")); + auto *a = add_node(); + auto *b = add_node(); + a->set_label(QStringLiteral("old_a")); + b->set_label(QStringLiteral("old_b")); olive::NodeRenameCommand cmd(a, QStringLiteral("new_a")); - cmd.AddNode(b, QStringLiteral("new_b")); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + cmd.add_node(b, QStringLiteral("new_b")); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(a->GetLabel(), QStringLiteral("new_a")); - EXPECT_EQ(b->GetLabel(), QStringLiteral("new_b")); + EXPECT_EQ(a->get_label(), QStringLiteral("new_a")); + EXPECT_EQ(b->get_label(), QStringLiteral("new_b")); cmd.undo_now(); - EXPECT_EQ(a->GetLabel(), QStringLiteral("old_a")); - EXPECT_EQ(b->GetLabel(), QStringLiteral("old_b")); + EXPECT_EQ(a->get_label(), QStringLiteral("old_a")); + EXPECT_EQ(b->get_label(), QStringLiteral("old_b")); } TEST_F(NodeUndoTest, RenameCommandEmptyHasNoProject) { olive::NodeRenameCommand cmd; - EXPECT_EQ(cmd.GetRelevantProject(), nullptr); + EXPECT_EQ(cmd.get_relevant_project(), nullptr); // redo/undo on an empty command must be harmless no-ops cmd.redo_now(); @@ -354,127 +354,127 @@ TEST_F(NodeUndoTest, RenameCommandEmptyHasNoProject) TEST_F(NodeUndoTest, OverrideColorCommandSetsAndRestoresColor) { - auto *node = AddNode(); - ASSERT_EQ(node->GetOverrideColor(), -1); + auto *node = add_node(); + ASSERT_EQ(node->get_override_color(), -1); olive::NodeOverrideColorCommand cmd(node, 5); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(node->GetOverrideColor(), 5); + EXPECT_EQ(node->get_override_color(), 5); cmd.undo_now(); - EXPECT_EQ(node->GetOverrideColor(), -1); + EXPECT_EQ(node->get_override_color(), -1); } TEST_F(NodeUndoTest, LinkCommandLinksAndUnlinks) { - auto *a = AddNode(); - auto *b = AddNode(); + auto *a = add_node(); + auto *b = add_node(); olive::NodeLinkCommand link_cmd(a, b, true); - EXPECT_EQ(link_cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(link_cmd.get_relevant_project(), project_.get()); link_cmd.redo_now(); - EXPECT_TRUE(olive::Node::AreLinked(a, b)); + EXPECT_TRUE(olive::Node::are_linked(a, b)); link_cmd.undo_now(); - EXPECT_FALSE(olive::Node::AreLinked(a, b)); + EXPECT_FALSE(olive::Node::are_linked(a, b)); - olive::Node::Link(a, b); + olive::Node::link(a, b); olive::NodeLinkCommand unlink_cmd(a, b, false); unlink_cmd.redo_now(); - EXPECT_FALSE(olive::Node::AreLinked(a, b)); + EXPECT_FALSE(olive::Node::are_linked(a, b)); unlink_cmd.undo_now(); - EXPECT_TRUE(olive::Node::AreLinked(a, b)); + EXPECT_TRUE(olive::Node::are_linked(a, b)); } TEST_F(NodeUndoTest, LinkCommandIgnoresAlreadyLinkedPair) { - auto *a = AddNode(); - auto *b = AddNode(); - olive::Node::Link(a, b); + auto *a = add_node(); + auto *b = add_node(); + olive::Node::link(a, b); olive::NodeLinkCommand cmd(a, b, true); cmd.redo_now(); - EXPECT_TRUE(olive::Node::AreLinked(a, b)); + EXPECT_TRUE(olive::Node::are_linked(a, b)); // Undo must not unlink a pair that redo did not link cmd.undo_now(); - EXPECT_TRUE(olive::Node::AreLinked(a, b)); + EXPECT_TRUE(olive::Node::are_linked(a, b)); } TEST_F(NodeUndoTest, UnlinkAllCommandRestoresAllLinks) { - auto *node = AddNode(); - auto *a = AddNode(); - auto *b = AddNode(); - olive::Node::Link(node, a); - olive::Node::Link(node, b); + auto *node = add_node(); + auto *a = add_node(); + auto *b = add_node(); + olive::Node::link(node, a); + olive::Node::link(node, b); ASSERT_EQ(node->links().size(), 2); olive::NodeUnlinkAllCommand cmd(node); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); EXPECT_TRUE(node->links().isEmpty()); - EXPECT_FALSE(olive::Node::AreLinked(node, a)); - EXPECT_FALSE(olive::Node::AreLinked(node, b)); + EXPECT_FALSE(olive::Node::are_linked(node, a)); + EXPECT_FALSE(olive::Node::are_linked(node, b)); cmd.undo_now(); EXPECT_EQ(node->links().size(), 2); - EXPECT_TRUE(olive::Node::AreLinked(node, a)); - EXPECT_TRUE(olive::Node::AreLinked(node, b)); + EXPECT_TRUE(olive::Node::are_linked(node, a)); + EXPECT_TRUE(olive::Node::are_linked(node, b)); } TEST_F(NodeUndoTest, LinkManyCommandLinksAndUnlinksAllPairs) { - auto *a = AddNode(); - auto *b = AddNode(); - auto *c = AddNode(); + auto *a = add_node(); + auto *b = add_node(); + auto *c = add_node(); olive::NodeLinkManyCommand cmd({ a, b, c }, true); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_TRUE(olive::Node::AreLinked(a, b)); - EXPECT_TRUE(olive::Node::AreLinked(a, c)); - EXPECT_TRUE(olive::Node::AreLinked(b, c)); + EXPECT_TRUE(olive::Node::are_linked(a, b)); + EXPECT_TRUE(olive::Node::are_linked(a, c)); + EXPECT_TRUE(olive::Node::are_linked(b, c)); cmd.undo_now(); - EXPECT_FALSE(olive::Node::AreLinked(a, b)); - EXPECT_FALSE(olive::Node::AreLinked(a, c)); - EXPECT_FALSE(olive::Node::AreLinked(b, c)); + EXPECT_FALSE(olive::Node::are_linked(a, b)); + EXPECT_FALSE(olive::Node::are_linked(a, c)); + EXPECT_FALSE(olive::Node::are_linked(b, c)); } TEST_F(NodeUndoTest, ViewDeleteCommandRemovesNodeAndEdges) { - auto *context = AddNode(); - auto *a = AddNode(); - auto *b = AddNode(); + auto *context = add_node(); + auto *a = add_node(); + auto *b = add_node(); - olive::Node::ConnectEdge( - a, olive::NodeInput(b, olive::MathNode::kParamAIn)); - context->SetNodePositionInContext( + olive::Node::connect_edge( + a, olive::NodeInput(b, olive::MathNode::k_param_a_in)); + context->set_node_position_in_context( a, olive::Node::Position(QPointF(1.0, 2.0))); - context->SetNodePositionInContext( + context->set_node_position_in_context( b, olive::Node::Position(QPointF(3.0, 4.0))); olive::NodeViewDeleteCommand cmd; - EXPECT_EQ(cmd.GetRelevantProject(), nullptr); + EXPECT_EQ(cmd.get_relevant_project(), nullptr); - cmd.AddNode(b, context); - EXPECT_TRUE(cmd.ContainsNode(b, context)); - EXPECT_FALSE(cmd.ContainsNode(a, context)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + cmd.add_node(b, context); + EXPECT_TRUE(cmd.contains_node(b, context)); + EXPECT_FALSE(cmd.contains_node(a, context)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); // b was only in this context and became fully disconnected, so it is // removed from the graph entirely - EXPECT_FALSE(context->ContextContainsNode(b)); + EXPECT_FALSE(context->context_contains_node(b)); EXPECT_EQ(b->project(), nullptr); EXPECT_TRUE(b->input_connections().empty()); EXPECT_TRUE(a->output_connections().empty()); @@ -482,162 +482,162 @@ TEST_F(NodeUndoTest, ViewDeleteCommandRemovesNodeAndEdges) cmd.undo_now(); EXPECT_EQ(b->project(), project_.get()); - ASSERT_TRUE(context->ContextContainsNode(b)); - EXPECT_EQ(context->GetNodePositionInContext(b), QPointF(3.0, 4.0)); + ASSERT_TRUE(context->context_contains_node(b)); + EXPECT_EQ(context->get_node_position_in_context(b), QPointF(3.0, 4.0)); ASSERT_EQ(a->output_connections().size(), 1); EXPECT_EQ(a->output_connections().front().second, - olive::NodeInput(b, olive::MathNode::kParamAIn)); + olive::NodeInput(b, olive::MathNode::k_param_a_in)); } TEST_F(NodeUndoTest, ViewDeleteCommandKeepsNodeConnectedOutsideContext) { - auto *context = AddNode(); - auto *a = AddNode(); - auto *outside = AddNode(); + auto *context = add_node(); + auto *a = add_node(); + auto *outside = add_node(); // "outside" is not in the context, so its edge keeps "a" in the graph - olive::Node::ConnectEdge( - a, olive::NodeInput(outside, olive::MathNode::kParamAIn)); - context->SetNodePositionInContext( + olive::Node::connect_edge( + a, olive::NodeInput(outside, olive::MathNode::k_param_a_in)); + context->set_node_position_in_context( a, olive::Node::Position(QPointF(7.0, 8.0))); olive::NodeViewDeleteCommand cmd; - cmd.AddNode(a, context); + cmd.add_node(a, context); cmd.redo_now(); - EXPECT_FALSE(context->ContextContainsNode(a)); + EXPECT_FALSE(context->context_contains_node(a)); EXPECT_EQ(a->project(), project_.get()); EXPECT_EQ(outside->input_connections().at( - olive::NodeInput(outside, olive::MathNode::kParamAIn)), + olive::NodeInput(outside, olive::MathNode::k_param_a_in)), a); cmd.undo_now(); - ASSERT_TRUE(context->ContextContainsNode(a)); - EXPECT_EQ(context->GetNodePositionInContext(a), QPointF(7.0, 8.0)); + ASSERT_TRUE(context->context_contains_node(a)); + EXPECT_EQ(context->get_node_position_in_context(a), QPointF(7.0, 8.0)); } TEST_F(NodeUndoTest, ParamSetKeyframingCommandTogglesKeyframing) { - auto *node = AddNode(); - const olive::NodeInput input(node, olive::MathNode::kParamAIn); - ASSERT_FALSE(input.IsKeyframing()); + auto *node = add_node(); + const olive::NodeInput input(node, olive::MathNode::k_param_a_in); + ASSERT_FALSE(input.is_keyframing()); olive::NodeParamSetKeyframingCommand cmd(input, true); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_TRUE(input.IsKeyframing()); + EXPECT_TRUE(input.is_keyframing()); cmd.undo_now(); - EXPECT_FALSE(input.IsKeyframing()); + EXPECT_FALSE(input.is_keyframing()); } TEST_F(NodeUndoTest, ParamInsertKeyframeCommandReparentsKeyframe) { - auto *node = AddNode(); + auto *node = add_node(); - auto *key = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *key = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); olive::NodeParamInsertKeyframeCommand cmd(node, key); // The constructor takes ownership of the keyframe without inserting it EXPECT_NE(key->parent(), node); - EXPECT_TRUE(node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1) .at(0) .isEmpty()); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); EXPECT_EQ(key->parent(), node); - EXPECT_TRUE(node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1) .at(0) .contains(key)); cmd.undo_now(); EXPECT_NE(key->parent(), node); - EXPECT_TRUE(node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1) .at(0) .isEmpty()); } TEST_F(NodeUndoTest, ParamRemoveKeyframeCommandRestoresKeyframe) { - auto *node = AddNode(); + auto *node = add_node(); - auto *key = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *key = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key->setParent(node); - ASSERT_TRUE(node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1) + ASSERT_TRUE(node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1) .at(0) .contains(key)); olive::NodeParamRemoveKeyframeCommand cmd(key); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); EXPECT_NE(key->parent(), node); - EXPECT_TRUE(node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1) .at(0) .isEmpty()); cmd.undo_now(); EXPECT_EQ(key->parent(), node); - EXPECT_TRUE(node->GetKeyframeTracks(olive::MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(olive::MathNode::k_param_a_in, -1) .at(0) .contains(key)); } TEST_F(NodeUndoTest, ParamSetKeyframeTimeCommandChangesTime) { - auto *node = AddNode(); - auto *key = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *node = add_node(); + auto *key = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key->setParent(node); - olive::NodeParamSetKeyframeTimeCommand cmd(key, olive::rational(1, 2)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::NodeParamSetKeyframeTimeCommand cmd(key, olive::Rational(1, 2)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(key->time(), olive::rational(1, 2)); + EXPECT_EQ(key->time(), olive::Rational(1, 2)); cmd.undo_now(); - EXPECT_EQ(key->time(), olive::rational(0)); + EXPECT_EQ(key->time(), olive::Rational(0)); } TEST_F(NodeUndoTest, ParamSetKeyframeTimeCommandExplicitTimes) { - auto *node = AddNode(); - auto *key = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *node = add_node(); + auto *key = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key->setParent(node); - olive::NodeParamSetKeyframeTimeCommand cmd(key, olive::rational(3, 4), - olive::rational(1, 4)); + olive::NodeParamSetKeyframeTimeCommand cmd(key, olive::Rational(3, 4), + olive::Rational(1, 4)); cmd.redo_now(); - EXPECT_EQ(key->time(), olive::rational(3, 4)); + EXPECT_EQ(key->time(), olive::Rational(3, 4)); cmd.undo_now(); - EXPECT_EQ(key->time(), olive::rational(1, 4)); + EXPECT_EQ(key->time(), olive::Rational(1, 4)); } TEST_F(NodeUndoTest, ParamSetKeyframeValueCommandChangesValue) { - auto *node = AddNode(); - auto *key = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *node = add_node(); + auto *key = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key->setParent(node); olive::NodeParamSetKeyframeValueCommand cmd(key, 5.0); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); EXPECT_DOUBLE_EQ(key->value().toDouble(), 5.0); @@ -648,10 +648,10 @@ TEST_F(NodeUndoTest, ParamSetKeyframeValueCommandChangesValue) TEST_F(NodeUndoTest, ParamSetKeyframeValueCommandExplicitValues) { - auto *node = AddNode(); - auto *key = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *node = add_node(); + auto *key = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key->setParent(node); olive::NodeParamSetKeyframeValueCommand cmd(key, 7.5, 2.5); @@ -665,30 +665,30 @@ TEST_F(NodeUndoTest, ParamSetKeyframeValueCommandExplicitValues) TEST_F(NodeUndoTest, ParamSetStandardValueCommandSetsAndRestoresValue) { - auto *node = AddNode(); + auto *node = add_node(); const olive::NodeKeyframeTrackReference ref( - olive::NodeInput(node, olive::MathNode::kParamAIn), 0); + olive::NodeInput(node, olive::MathNode::k_param_a_in), 0); ASSERT_DOUBLE_EQ( - node->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 0.0); + node->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 0.0); olive::NodeParamSetStandardValueCommand cmd(ref, 2.5); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); EXPECT_DOUBLE_EQ( - node->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 2.5); + node->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 2.5); cmd.undo_now(); EXPECT_DOUBLE_EQ( - node->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 0.0); + node->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 0.0); } TEST_F(NodeUndoTest, ParamSetStandardValueCommandExplicitOldValue) { - auto *node = AddNode(); - node->SetStandardValue(olive::MathNode::kParamAIn, 10.0); + auto *node = add_node(); + node->set_standard_value(olive::MathNode::k_param_a_in, 10.0); const olive::NodeKeyframeTrackReference ref( - olive::NodeInput(node, olive::MathNode::kParamAIn), 0); + olive::NodeInput(node, olive::MathNode::k_param_a_in), 0); // Three-argument form with an explicit old value, as used by // SpeedDurationDialog @@ -696,28 +696,28 @@ TEST_F(NodeUndoTest, ParamSetStandardValueCommandExplicitOldValue) cmd.redo_now(); EXPECT_DOUBLE_EQ( - node->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 20.0); + node->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 20.0); cmd.undo_now(); EXPECT_DOUBLE_EQ( - node->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), 10.0); + node->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), 10.0); } TEST_F(NodeUndoTest, ParamSetSplitStandardValueCommandSetsAndRestoresSplit) { - auto *node = AddNode(); - const olive::NodeInput input(node, olive::SolidGenerator::kColorInput); + auto *node = add_node(); + const olive::NodeInput input(node, olive::SolidGenerator::k_color_input); - const olive::SplitValue old_split = node->GetSplitStandardValue(input); + const olive::SplitValue old_split = node->get_split_standard_value(input); ASSERT_EQ(old_split.size(), 4); const olive::SplitValue new_split = { 0.25, 0.5, 0.75, 1.0 }; olive::NodeParamSetSplitStandardValueCommand cmd(input, new_split); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - const olive::SplitValue after = node->GetSplitStandardValue(input); + const olive::SplitValue after = node->get_split_standard_value(input); ASSERT_EQ(after.size(), 4); EXPECT_DOUBLE_EQ(after.at(0).toDouble(), 0.25); EXPECT_DOUBLE_EQ(after.at(1).toDouble(), 0.5); @@ -725,7 +725,7 @@ TEST_F(NodeUndoTest, ParamSetSplitStandardValueCommandSetsAndRestoresSplit) EXPECT_DOUBLE_EQ(after.at(3).toDouble(), 1.0); cmd.undo_now(); - const olive::SplitValue restored = node->GetSplitStandardValue(input); + const olive::SplitValue restored = node->get_split_standard_value(input); ASSERT_EQ(restored.size(), 4); for (int i = 0; i < restored.size(); ++i) { EXPECT_DOUBLE_EQ(restored.at(i).toDouble(), @@ -738,127 +738,127 @@ TEST_F(NodeUndoTest, ParamSetSplitStandardValueCommandSetsAndRestoresSplit) explicit_new, restored); explicit_cmd.redo_now(); - EXPECT_DOUBLE_EQ(node->GetSplitStandardValue(input).at(0).toDouble(), 1.0); + EXPECT_DOUBLE_EQ(node->get_split_standard_value(input).at(0).toDouble(), 1.0); explicit_cmd.undo_now(); - EXPECT_DOUBLE_EQ(node->GetSplitStandardValue(input).at(0).toDouble(), + EXPECT_DOUBLE_EQ(node->get_split_standard_value(input).at(0).toDouble(), restored.at(0).toDouble()); } TEST_F(NodeUndoTest, ParamArrayAppendCommandAppendsAndRemoves) { - auto *node = AddNode(); - const int base = node->InputArraySize(olive::TextGeneratorV3::kArgsInput); + auto *node = add_node(); + const int base = node->input_array_size(olive::TextGeneratorV3::k_args_input); olive::NodeParamArrayAppendCommand cmd(node, - olive::TextGeneratorV3::kArgsInput); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::TextGeneratorV3::k_args_input); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base + 1); cmd.undo_now(); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), base); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base); } TEST_F(NodeUndoTest, ArrayInsertCommandInsertsAndRemovesElement) { - auto *node = AddNode(); - node->InputArrayAppend(olive::TextGeneratorV3::kArgsInput); - const int base = node->InputArraySize(olive::TextGeneratorV3::kArgsInput); + auto *node = add_node(); + node->input_array_append(olive::TextGeneratorV3::k_args_input); + const int base = node->input_array_size(olive::TextGeneratorV3::k_args_input); - olive::NodeArrayInsertCommand cmd(node, olive::TextGeneratorV3::kArgsInput, + olive::NodeArrayInsertCommand cmd(node, olive::TextGeneratorV3::k_args_input, 0); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base + 1); cmd.undo_now(); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), base); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base); } TEST_F(NodeUndoTest, ArrayResizeCommandGrowAndShrink) { - auto *node = AddNode(); - const int base = node->InputArraySize(olive::TextGeneratorV3::kArgsInput); + auto *node = add_node(); + const int base = node->input_array_size(olive::TextGeneratorV3::k_args_input); - olive::NodeArrayResizeCommand cmd(node, olive::TextGeneratorV3::kArgsInput, + olive::NodeArrayResizeCommand cmd(node, olive::TextGeneratorV3::k_args_input, base + 3); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base + 3); cmd.undo_now(); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), base); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), base); } TEST_F(NodeUndoTest, ArrayResizeCommandShrinkDisconnectsAndRestoresEdges) { - auto *node = AddNode(); - auto *output = AddNode(); + auto *node = add_node(); + auto *output = add_node(); - node->InputArrayResize(olive::TextGeneratorV3::kArgsInput, 3); + node->input_array_resize(olive::TextGeneratorV3::k_args_input, 3); const olive::NodeInput connected(node, - olive::TextGeneratorV3::kArgsInput, 2); - olive::Node::ConnectEdge(output, connected); - ASSERT_TRUE(connected.IsConnected()); + olive::TextGeneratorV3::k_args_input, 2); + olive::Node::connect_edge(output, connected); + ASSERT_TRUE(connected.is_connected()); - olive::NodeArrayResizeCommand cmd(node, olive::TextGeneratorV3::kArgsInput, + olive::NodeArrayResizeCommand cmd(node, olive::TextGeneratorV3::k_args_input, 1); cmd.redo_now(); // Shrinking removed elements 1 and 2; the edge into element 2 is dropped - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), 1); - EXPECT_FALSE(connected.IsConnected()); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), 1); + EXPECT_FALSE(connected.is_connected()); EXPECT_TRUE(output->output_connections().empty()); cmd.undo_now(); // Undo restores both the array size and the removed connection - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), 3); - EXPECT_TRUE(connected.IsConnected()); - EXPECT_EQ(connected.GetConnectedOutput(), output); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), 3); + EXPECT_TRUE(connected.is_connected()); + EXPECT_EQ(connected.get_connected_output(), output); } TEST_F(NodeUndoTest, ArrayRemoveCommandPreservesKeyframesAndValues) { - auto *node = AddNode(); - node->InputArrayResize(olive::TextGeneratorV3::kArgsInput, 2); + auto *node = add_node(); + node->input_array_resize(olive::TextGeneratorV3::k_args_input, 2); - const olive::NodeInput element(node, olive::TextGeneratorV3::kArgsInput, + const olive::NodeInput element(node, olive::TextGeneratorV3::k_args_input, 1); - node->SetStandardValue(element, QStringLiteral("hello")); - node->SetInputIsKeyframing(element, true); + node->set_standard_value(element, QStringLiteral("hello")); + node->set_input_is_keyframing(element, true); auto *key = new olive::NodeKeyframe( - olive::rational(0), QStringLiteral("key"), olive::NodeKeyframe::kLinear, - 0, 1, olive::TextGeneratorV3::kArgsInput); + olive::Rational(0), QStringLiteral("key"), olive::NodeKeyframe::k_linear, + 0, 1, olive::TextGeneratorV3::k_args_input); key->setParent(node); - ASSERT_TRUE(node->GetKeyframeTracks(olive::TextGeneratorV3::kArgsInput, 1) + ASSERT_TRUE(node->get_keyframe_tracks(olive::TextGeneratorV3::k_args_input, 1) .at(0) .contains(key)); - olive::NodeArrayRemoveCommand cmd(node, olive::TextGeneratorV3::kArgsInput, + olive::NodeArrayRemoveCommand cmd(node, olive::TextGeneratorV3::k_args_input, 1); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), 1); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), 1); EXPECT_NE(key->parent(), node); cmd.undo_now(); - EXPECT_EQ(node->InputArraySize(olive::TextGeneratorV3::kArgsInput), 2); + EXPECT_EQ(node->input_array_size(olive::TextGeneratorV3::k_args_input), 2); EXPECT_EQ(key->parent(), node); - EXPECT_TRUE(node->GetKeyframeTracks(olive::TextGeneratorV3::kArgsInput, 1) + EXPECT_TRUE(node->get_keyframe_tracks(olive::TextGeneratorV3::k_args_input, 1) .at(0) .contains(key)); - EXPECT_TRUE(node->IsInputKeyframing(olive::TextGeneratorV3::kArgsInput, 1)); - EXPECT_EQ(node->GetSplitStandardValue(olive::TextGeneratorV3::kArgsInput, 1) + EXPECT_TRUE(node->is_input_keyframing(olive::TextGeneratorV3::k_args_input, 1)); + EXPECT_EQ(node->get_split_standard_value(olive::TextGeneratorV3::k_args_input, 1) .at(0) .toString(), QStringLiteral("hello")); @@ -866,28 +866,28 @@ TEST_F(NodeUndoTest, ArrayRemoveCommandPreservesKeyframesAndValues) TEST_F(NodeUndoTest, SetValueHintCommandSetsAndRestoresHint) { - auto *node = AddNode(); + auto *node = add_node(); const olive::Node::ValueHint old_hint = - node->GetValueHintForInput(olive::MathNode::kParamAIn, -1); + node->get_value_hint_for_input(olive::MathNode::k_param_a_in, -1); - const olive::Node::ValueHint new_hint({ olive::NodeValue::kVec2 }, 3, + const olive::Node::ValueHint new_hint({ olive::NodeValue::k_vec2 }, 3, QStringLiteral("tag")); - olive::NodeSetValueHintCommand cmd(node, olive::MathNode::kParamAIn, -1, + olive::NodeSetValueHintCommand cmd(node, olive::MathNode::k_param_a_in, -1, new_hint); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); const olive::Node::ValueHint after = - node->GetValueHintForInput(olive::MathNode::kParamAIn, -1); + node->get_value_hint_for_input(olive::MathNode::k_param_a_in, -1); ASSERT_EQ(after.types().size(), 1); - EXPECT_EQ(after.types().first(), olive::NodeValue::kVec2); + EXPECT_EQ(after.types().first(), olive::NodeValue::k_vec2); EXPECT_EQ(after.index(), 3); EXPECT_EQ(after.tag(), QStringLiteral("tag")); cmd.undo_now(); const olive::Node::ValueHint restored = - node->GetValueHintForInput(olive::MathNode::kParamAIn, -1); + node->get_value_hint_for_input(olive::MathNode::k_param_a_in, -1); EXPECT_EQ(restored.types().size(), old_hint.types().size()); EXPECT_EQ(restored.index(), old_hint.index()); EXPECT_EQ(restored.tag(), old_hint.tag()); @@ -895,25 +895,25 @@ TEST_F(NodeUndoTest, SetValueHintCommandSetsAndRestoresHint) TEST_F(NodeUndoTest, ImmediateRemoveAllKeyframesCommandRemovesKeys) { - auto *node = AddNode(); - node->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + auto *node = add_node(); + node->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); - auto *key_a = new olive::NodeKeyframe(olive::rational(0), 1.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *key_a = new olive::NodeKeyframe(olive::Rational(0), 1.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key_a->setParent(node); - auto *key_b = new olive::NodeKeyframe(olive::rational(1), 2.0, - olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn); + auto *key_b = new olive::NodeKeyframe(olive::Rational(1), 2.0, + olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in); key_b->setParent(node); olive::NodeInputImmediate *immediate = - node->GetImmediate(olive::MathNode::kParamAIn, -1); + node->get_immediate(olive::MathNode::k_param_a_in, -1); ASSERT_NE(immediate, nullptr); ASSERT_EQ(immediate->keyframe_tracks().at(0).size(), 2); olive::NodeImmediateRemoveAllKeyframesCommand cmd(immediate); - EXPECT_EQ(cmd.GetRelevantProject(), nullptr); + EXPECT_EQ(cmd.get_relevant_project(), nullptr); cmd.redo_now(); EXPECT_TRUE(immediate->keyframe_tracks().at(0).isEmpty()); diff --git a/tests/gtest/node_value_extended_test.cpp b/tests/gtest/node_value_extended_test.cpp index ad4c5fa48..36ca49a3a 100644 --- a/tests/gtest/node_value_extended_test.cpp +++ b/tests/gtest/node_value_extended_test.cpp @@ -19,82 +19,82 @@ TEST(NodeValueExtended, VectorAccessors) { - olive::NodeValue v2(olive::NodeValue::kVec2, QVector2D(1.5f, -2.5f)); - EXPECT_FLOAT_EQ(v2.toVec2().x(), 1.5f); - EXPECT_FLOAT_EQ(v2.toVec2().y(), -2.5f); + olive::NodeValue v2(olive::NodeValue::k_vec2, QVector2D(1.5f, -2.5f)); + EXPECT_FLOAT_EQ(v2.to_vec2().x(), 1.5f); + EXPECT_FLOAT_EQ(v2.to_vec2().y(), -2.5f); - olive::NodeValue v3(olive::NodeValue::kVec3, QVector3D(1.0f, 2.0f, 3.0f)); - EXPECT_FLOAT_EQ(v3.toVec3().x(), 1.0f); - EXPECT_FLOAT_EQ(v3.toVec3().y(), 2.0f); - EXPECT_FLOAT_EQ(v3.toVec3().z(), 3.0f); + olive::NodeValue v3(olive::NodeValue::k_vec3, QVector3D(1.0f, 2.0f, 3.0f)); + EXPECT_FLOAT_EQ(v3.to_vec3().x(), 1.0f); + EXPECT_FLOAT_EQ(v3.to_vec3().y(), 2.0f); + EXPECT_FLOAT_EQ(v3.to_vec3().z(), 3.0f); - olive::NodeValue v4(olive::NodeValue::kVec4, + olive::NodeValue v4(olive::NodeValue::k_vec4, QVector4D(1.0f, 2.0f, 3.0f, 4.0f)); - EXPECT_FLOAT_EQ(v4.toVec4().x(), 1.0f); - EXPECT_FLOAT_EQ(v4.toVec4().y(), 2.0f); - EXPECT_FLOAT_EQ(v4.toVec4().z(), 3.0f); - EXPECT_FLOAT_EQ(v4.toVec4().w(), 4.0f); + EXPECT_FLOAT_EQ(v4.to_vec4().x(), 1.0f); + EXPECT_FLOAT_EQ(v4.to_vec4().y(), 2.0f); + EXPECT_FLOAT_EQ(v4.to_vec4().z(), 3.0f); + EXPECT_FLOAT_EQ(v4.to_vec4().w(), 4.0f); } TEST(NodeValueExtended, ColorMatrixBezierAccessors) { - olive::NodeValue color(olive::NodeValue::kColor, + olive::NodeValue color(olive::NodeValue::k_color, olive::core::Color(0.1f, 0.2f, 0.3f, 0.4f)); - EXPECT_FLOAT_EQ(color.toColor().red(), 0.1f); - EXPECT_FLOAT_EQ(color.toColor().green(), 0.2f); - EXPECT_FLOAT_EQ(color.toColor().blue(), 0.3f); - EXPECT_FLOAT_EQ(color.toColor().alpha(), 0.4f); + EXPECT_FLOAT_EQ(color.to_color().red(), 0.1f); + EXPECT_FLOAT_EQ(color.to_color().green(), 0.2f); + EXPECT_FLOAT_EQ(color.to_color().blue(), 0.3f); + EXPECT_FLOAT_EQ(color.to_color().alpha(), 0.4f); QMatrix4x4 matrix; matrix.scale(2.0f, 3.0f, 4.0f); - olive::NodeValue mat(olive::NodeValue::kMatrix, matrix); - EXPECT_FLOAT_EQ(mat.toMatrix()(0, 0), 2.0f); - EXPECT_FLOAT_EQ(mat.toMatrix()(1, 1), 3.0f); - EXPECT_FLOAT_EQ(mat.toMatrix()(2, 2), 4.0f); + olive::NodeValue mat(olive::NodeValue::k_matrix, matrix); + EXPECT_FLOAT_EQ(mat.to_matrix()(0, 0), 2.0f); + EXPECT_FLOAT_EQ(mat.to_matrix()(1, 1), 3.0f); + EXPECT_FLOAT_EQ(mat.to_matrix()(2, 2), 4.0f); - olive::NodeValue bezier(olive::NodeValue::kBezier, + olive::NodeValue bezier(olive::NodeValue::k_bezier, olive::core::Bezier(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)); - EXPECT_DOUBLE_EQ(bezier.toBezier().x(), 1.0); - EXPECT_DOUBLE_EQ(bezier.toBezier().y(), 2.0); - EXPECT_DOUBLE_EQ(bezier.toBezier().cp1_x(), 3.0); - EXPECT_DOUBLE_EQ(bezier.toBezier().cp1_y(), 4.0); - EXPECT_DOUBLE_EQ(bezier.toBezier().cp2_x(), 5.0); - EXPECT_DOUBLE_EQ(bezier.toBezier().cp2_y(), 6.0); + EXPECT_DOUBLE_EQ(bezier.to_bezier().x(), 1.0); + EXPECT_DOUBLE_EQ(bezier.to_bezier().y(), 2.0); + EXPECT_DOUBLE_EQ(bezier.to_bezier().cp1_x(), 3.0); + EXPECT_DOUBLE_EQ(bezier.to_bezier().cp1_y(), 4.0); + EXPECT_DOUBLE_EQ(bezier.to_bezier().cp2_x(), 5.0); + EXPECT_DOUBLE_EQ(bezier.to_bezier().cp2_y(), 6.0); } TEST(NodeValueExtended, ScalarAccessors) { - olive::NodeValue boolean(olive::NodeValue::kBoolean, true); - EXPECT_TRUE(boolean.toBool()); + olive::NodeValue boolean(olive::NodeValue::k_boolean, true); + EXPECT_TRUE(boolean.to_bool()); - olive::NodeValue floating(olive::NodeValue::kFloat, 2.75); - EXPECT_DOUBLE_EQ(floating.toDouble(), 2.75); + olive::NodeValue floating(olive::NodeValue::k_float, 2.75); + EXPECT_DOUBLE_EQ(floating.to_double(), 2.75); - olive::NodeValue text(olive::NodeValue::kText, QStringLiteral("oak")); - EXPECT_EQ(text.toString(), QStringLiteral("oak")); + olive::NodeValue text(olive::NodeValue::k_text, QStringLiteral("oak")); + EXPECT_EQ(text.to_string(), QStringLiteral("oak")); - olive::NodeValue rational_value(olive::NodeValue::kRational, - olive::core::rational(3, 4)); - EXPECT_EQ(rational_value.toRational(), olive::core::rational(3, 4)); + olive::NodeValue rational_value(olive::NodeValue::k_rational, + olive::core::Rational(3, 4)); + EXPECT_EQ(rational_value.to_rational(), olive::core::Rational(3, 4)); olive::NodeValue audio( - olive::NodeValue::kAudioParams, - olive::core::AudioParams(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P)); - EXPECT_EQ(audio.toAudioParams().sample_rate(), 48000); + olive::NodeValue::k_audio_params, + olive::core::AudioParams(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p)); + EXPECT_EQ(audio.to_audio_params().sample_rate(), 48000); } TEST(NodeValueExtended, SamplesAccessorRoundTripsBuffer) { - olive::core::AudioParams params(48000, olive::core::kChannelLayoutMono, - olive::core::SampleFormat::F32P); + olive::core::AudioParams params(48000, olive::core::k_channel_layout_mono, + olive::core::SampleFormat::f32_p); olive::core::SampleBuffer buffer(params, size_t(4)); for (int i = 0; i < 4; i++) { buffer.data(0)[i] = 0.25f * float(i + 1); } - olive::NodeValue value(olive::NodeValue::kSamples, buffer); - olive::core::SampleBuffer out = value.toSamples(); + olive::NodeValue value(olive::NodeValue::k_samples, buffer); + olive::core::SampleBuffer out = value.to_samples(); ASSERT_EQ(out.sample_count(), size_t(4)); EXPECT_FLOAT_EQ(out.data(0)[0], 0.25f); EXPECT_FLOAT_EQ(out.data(0)[1], 0.5f); @@ -104,16 +104,16 @@ TEST(NodeValueExtended, SamplesAccessorRoundTripsBuffer) TEST(NodeValueExtended, MismatchedTypeAccessorsReturnDefaults) { - olive::NodeValue text(olive::NodeValue::kText, QStringLiteral("hello")); + olive::NodeValue text(olive::NodeValue::k_text, QStringLiteral("hello")); // Accessors do not validate the stored type; failed QVariant conversions // produce default-constructed values - EXPECT_EQ(text.toTexture(), nullptr); - EXPECT_FALSE(text.toSamples().is_allocated()); - EXPECT_TRUE(text.toVec4().isNull()); - EXPECT_TRUE(text.toMatrix().isIdentity()); + EXPECT_EQ(text.to_texture(), nullptr); + EXPECT_FALSE(text.to_samples().is_allocated()); + EXPECT_TRUE(text.to_vec4().isNull()); + EXPECT_TRUE(text.to_matrix().isIdentity()); - const olive::core::Color c = text.toColor(); + const olive::core::Color c = text.to_color(); EXPECT_FLOAT_EQ(c.red(), 0.0f); EXPECT_FLOAT_EQ(c.green(), 0.0f); EXPECT_FLOAT_EQ(c.blue(), 0.0f); @@ -123,17 +123,17 @@ TEST(NodeValueExtended, MismatchedTypeAccessorsReturnDefaults) TEST(NodeValueExtended, SourceArrayFlagAndEquality) { olive::MathNode node; // any Node works; only the pointer value is observed - olive::NodeValue value(olive::NodeValue::kFloat, 1.5, &node, true, + olive::NodeValue value(olive::NodeValue::k_float, 1.5, &node, true, QStringLiteral("tag")); EXPECT_EQ(value.source(), static_cast(&node)); EXPECT_TRUE(value.array()); EXPECT_EQ(value.tag(), QStringLiteral("tag")); - EXPECT_EQ(value.type(), olive::NodeValue::kFloat); + EXPECT_EQ(value.type(), olive::NodeValue::k_float); EXPECT_TRUE(value); // A default-constructed value carries no data olive::NodeValue empty; - EXPECT_EQ(empty.type(), olive::NodeValue::kNone); + EXPECT_EQ(empty.type(), olive::NodeValue::k_none); EXPECT_EQ(empty.source(), nullptr); EXPECT_FALSE(empty.array()); EXPECT_TRUE(empty.data().isNull()); @@ -141,32 +141,32 @@ TEST(NodeValueExtended, SourceArrayFlagAndEquality) // Equality compares type, tag, and data; the source pointer and the array // flag are ignored - olive::NodeValue same(olive::NodeValue::kFloat, 1.5, nullptr, false, + olive::NodeValue same(olive::NodeValue::k_float, 1.5, nullptr, false, QStringLiteral("tag")); EXPECT_TRUE(value == same); - olive::NodeValue different_tag(olive::NodeValue::kFloat, 1.5, &node, true, + olive::NodeValue different_tag(olive::NodeValue::k_float, 1.5, &node, true, QStringLiteral("other")); EXPECT_FALSE(value == different_tag); - olive::NodeValue different_data(olive::NodeValue::kFloat, 2.5, &node, true, + olive::NodeValue different_data(olive::NodeValue::k_float, 2.5, &node, true, QStringLiteral("tag")); EXPECT_FALSE(value == different_data); - olive::NodeValue different_type(olive::NodeValue::kInt, int64_t(1), &node, + olive::NodeValue different_type(olive::NodeValue::k_int, int64_t(1), &node, true, QStringLiteral("tag")); EXPECT_FALSE(value == different_type); } TEST(NodeValueExtended, CanConvertReflectsStoredData) { - olive::NodeValue integer(olive::NodeValue::kInt, int64_t(7)); + olive::NodeValue integer(olive::NodeValue::k_int, int64_t(7)); EXPECT_TRUE(integer.canConvert()); - olive::NodeValue text(olive::NodeValue::kText, QStringLiteral("hello")); + olive::NodeValue text(olive::NodeValue::k_text, QStringLiteral("hello")); EXPECT_TRUE(text.canConvert()); - olive::NodeValue vec(olive::NodeValue::kVec2, QVector2D(1.0f, 2.0f)); + olive::NodeValue vec(olive::NodeValue::k_vec2, QVector2D(1.0f, 2.0f)); EXPECT_TRUE(vec.canConvert()); EXPECT_FALSE(vec.canConvert()); } @@ -174,10 +174,10 @@ TEST(NodeValueExtended, CanConvertReflectsStoredData) TEST(NodeValueExtended, ColorStringRoundTrip) { const olive::core::Color c(0.25f, 0.5f, 0.75f, 1.0f); - QString encoded = olive::NodeValue::ValueToString( - olive::NodeValue::kColor, QVariant::fromValue(c), false); - QVariant decoded = olive::NodeValue::StringToValue( - olive::NodeValue::kColor, encoded, false); + QString encoded = olive::NodeValue::value_to_string( + olive::NodeValue::k_color, QVariant::fromValue(c), false); + QVariant decoded = olive::NodeValue::string_to_value( + olive::NodeValue::k_color, encoded, false); const olive::core::Color out = decoded.value(); EXPECT_FLOAT_EQ(out.red(), c.red()); EXPECT_FLOAT_EQ(out.green(), c.green()); @@ -188,10 +188,10 @@ TEST(NodeValueExtended, ColorStringRoundTrip) TEST(NodeValueExtended, BezierStringRoundTrip) { const olive::core::Bezier b(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - QString encoded = olive::NodeValue::ValueToString( - olive::NodeValue::kBezier, QVariant::fromValue(b), false); - QVariant decoded = olive::NodeValue::StringToValue( - olive::NodeValue::kBezier, encoded, false); + QString encoded = olive::NodeValue::value_to_string( + olive::NodeValue::k_bezier, QVariant::fromValue(b), false); + QVariant decoded = olive::NodeValue::string_to_value( + olive::NodeValue::k_bezier, encoded, false); const olive::core::Bezier out = decoded.value(); EXPECT_DOUBLE_EQ(out.x(), b.x()); EXPECT_DOUBLE_EQ(out.y(), b.y()); @@ -203,16 +203,16 @@ TEST(NodeValueExtended, BezierStringRoundTrip) TEST(NodeValueExtended, RationalStringRoundTrip) { - const olive::core::rational r(1, 24); - QString encoded = olive::NodeValue::ValueToString( - olive::NodeValue::kRational, QVariant::fromValue(r), false); + const olive::core::Rational r(1, 24); + QString encoded = olive::NodeValue::value_to_string( + olive::NodeValue::k_rational, QVariant::fromValue(r), false); EXPECT_EQ(encoded, QStringLiteral("1/24")); - QVariant decoded = olive::NodeValue::StringToValue( - olive::NodeValue::kRational, encoded, false); - EXPECT_EQ(decoded.value(), r); + QVariant decoded = olive::NodeValue::string_to_value( + olive::NodeValue::k_rational, encoded, false); + EXPECT_EQ(decoded.value(), r); - // The rational path applies to key track values too - EXPECT_EQ(olive::NodeValue::ValueToString(olive::NodeValue::kRational, + // The Rational path applies to key track values too + EXPECT_EQ(olive::NodeValue::value_to_string(olive::NodeValue::k_rational, QVariant::fromValue(r), true), QStringLiteral("1/24")); } @@ -220,17 +220,17 @@ TEST(NodeValueExtended, RationalStringRoundTrip) TEST(NodeValueExtended, IntStringRoundTrip) { const int64_t big = INT64_C(9223372036854775807); - QString encoded = olive::NodeValue::ValueToString( - olive::NodeValue::kInt, QVariant::fromValue(big), false); + QString encoded = olive::NodeValue::value_to_string( + olive::NodeValue::k_int, QVariant::fromValue(big), false); EXPECT_EQ(encoded, QStringLiteral("9223372036854775807")); - QVariant decoded = olive::NodeValue::StringToValue( - olive::NodeValue::kInt, encoded, false); + QVariant decoded = olive::NodeValue::string_to_value( + olive::NodeValue::k_int, encoded, false); EXPECT_EQ(decoded.value(), big); const int64_t small = -big - 1; - encoded = olive::NodeValue::ValueToString( - olive::NodeValue::kInt, QVariant::fromValue(small), false); - decoded = olive::NodeValue::StringToValue(olive::NodeValue::kInt, encoded, + encoded = olive::NodeValue::value_to_string( + olive::NodeValue::k_int, QVariant::fromValue(small), false); + decoded = olive::NodeValue::string_to_value(olive::NodeValue::k_int, encoded, false); EXPECT_EQ(decoded.value(), small); } @@ -238,15 +238,15 @@ TEST(NodeValueExtended, IntStringRoundTrip) TEST(NodeValueExtended, BufferAndNoneTypesSerializeToEmptyString) { // Textures, samples, and empty values have no XML representation - EXPECT_TRUE(olive::NodeValue::ValueToString( - olive::NodeValue::kTexture, + EXPECT_TRUE(olive::NodeValue::value_to_string( + olive::NodeValue::k_texture, QVariant::fromValue(olive::TexturePtr()), false) .isEmpty()); - EXPECT_TRUE(olive::NodeValue::ValueToString( - olive::NodeValue::kSamples, + EXPECT_TRUE(olive::NodeValue::value_to_string( + olive::NodeValue::k_samples, QVariant::fromValue(olive::core::SampleBuffer()), false) .isEmpty()); - EXPECT_TRUE(olive::NodeValue::ValueToString(olive::NodeValue::kNone, + EXPECT_TRUE(olive::NodeValue::value_to_string(olive::NodeValue::k_none, QVariant(), false) .isEmpty()); } @@ -255,30 +255,30 @@ TEST(NodeValueExtended, KeyTrackFlagFallsBackToPlainString) { // With the key-track flag set, values without a dedicated serialization // fall back to plain string conversion - EXPECT_EQ(olive::NodeValue::ValueToString(olive::NodeValue::kText, + EXPECT_EQ(olive::NodeValue::value_to_string(olive::NodeValue::k_text, QStringLiteral("hello"), true), QStringLiteral("hello")); - EXPECT_EQ(olive::NodeValue::ValueToString(olive::NodeValue::kFloat, 2.5, + EXPECT_EQ(olive::NodeValue::value_to_string(olive::NodeValue::k_float, 2.5, true), QStringLiteral("2.5")); // StringToValue() likewise leaves key-track values as raw strings - QVariant decoded = olive::NodeValue::StringToValue( - olive::NodeValue::kFloat, QStringLiteral("2.5"), true); + QVariant decoded = olive::NodeValue::string_to_value( + olive::NodeValue::k_float, QStringLiteral("2.5"), true); EXPECT_EQ(decoded.toString(), QStringLiteral("2.5")); } TEST(NodeValueExtended, ShortVectorStringIsZeroPadded) { - QVariant decoded = olive::NodeValue::StringToValue( - olive::NodeValue::kVec3, QStringLiteral("5:7"), false); + QVariant decoded = olive::NodeValue::string_to_value( + olive::NodeValue::k_vec3, QStringLiteral("5:7"), false); const QVector3D vec = decoded.value(); EXPECT_FLOAT_EQ(vec.x(), 5.0f); EXPECT_FLOAT_EQ(vec.y(), 7.0f); EXPECT_FLOAT_EQ(vec.z(), 0.0f); // Even an empty string yields a zero vector rather than crashing - decoded = olive::NodeValue::StringToValue(olive::NodeValue::kVec2, + decoded = olive::NodeValue::string_to_value(olive::NodeValue::k_vec2, QString(), false); const QVector2D vec2 = decoded.value(); EXPECT_FLOAT_EQ(vec2.x(), 0.0f); @@ -288,42 +288,42 @@ TEST(NodeValueExtended, ShortVectorStringIsZeroPadded) TEST(NodeValueExtended, KeyframeTrackCounts) { EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kVec2), + olive::NodeValue::k_vec2), 2); EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kVec3), + olive::NodeValue::k_vec3), 3); EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kVec4), + olive::NodeValue::k_vec4), 4); EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kColor), + olive::NodeValue::k_color), 4); EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kBezier), + olive::NodeValue::k_bezier), 6); // All scalar types live on a single track EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kFloat), + olive::NodeValue::k_float), 1); EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kInt), + olive::NodeValue::k_int), 1); EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kText), + olive::NodeValue::k_text), 1); EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kRational), + olive::NodeValue::k_rational), 1); EXPECT_EQ(olive::NodeValue::get_number_of_keyframe_tracks( - olive::NodeValue::kNone), + olive::NodeValue::k_none), 1); } TEST(NodeValueExtended, SplitVectorIntoTrackValues) { - olive::NodeValue value(olive::NodeValue::kVec3, + olive::NodeValue value(olive::NodeValue::k_vec3, QVector3D(1.0f, 2.0f, 3.0f)); const olive::SplitValue split = value.to_split_value(); ASSERT_EQ(split.size(), 3); @@ -334,7 +334,7 @@ TEST(NodeValueExtended, SplitVectorIntoTrackValues) // to_split_value() matches the underlying static helper const QVector manual = olive::NodeValue::split_normal_value_into_track_values( - olive::NodeValue::kVec3, + olive::NodeValue::k_vec3, QVariant::fromValue(QVector3D(1.0f, 2.0f, 3.0f))); ASSERT_EQ(manual.size(), 3); EXPECT_FLOAT_EQ(manual.at(2).toFloat(), 3.0f); @@ -342,7 +342,7 @@ TEST(NodeValueExtended, SplitVectorIntoTrackValues) TEST(NodeValueExtended, SplitColorAndBezierIntoTrackValues) { - olive::NodeValue color(olive::NodeValue::kColor, + olive::NodeValue color(olive::NodeValue::k_color, olive::core::Color(0.1f, 0.2f, 0.3f, 0.4f)); olive::SplitValue split = color.to_split_value(); ASSERT_EQ(split.size(), 4); @@ -351,7 +351,7 @@ TEST(NodeValueExtended, SplitColorAndBezierIntoTrackValues) EXPECT_FLOAT_EQ(split.at(2).toFloat(), 0.3f); EXPECT_FLOAT_EQ(split.at(3).toFloat(), 0.4f); - olive::NodeValue bezier(olive::NodeValue::kBezier, + olive::NodeValue bezier(olive::NodeValue::k_bezier, olive::core::Bezier(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)); split = bezier.to_split_value(); ASSERT_EQ(split.size(), 6); @@ -365,7 +365,7 @@ TEST(NodeValueExtended, SplitColorAndBezierIntoTrackValues) TEST(NodeValueExtended, SplitScalarStaysSingleValue) { - olive::NodeValue value(olive::NodeValue::kFloat, 4.75); + olive::NodeValue value(olive::NodeValue::k_float, 4.75); const olive::SplitValue split = value.to_split_value(); ASSERT_EQ(split.size(), 1); EXPECT_DOUBLE_EQ(split.at(0).toDouble(), 4.75); @@ -376,9 +376,9 @@ TEST(NodeValueExtended, CombineTrackValuesRebuildsValue) // Round trip through split/combine restores the original value const olive::core::Color c(0.25f, 0.5f, 0.75f, 1.0f); olive::SplitValue split = - olive::NodeValue(olive::NodeValue::kColor, c).to_split_value(); + olive::NodeValue(olive::NodeValue::k_color, c).to_split_value(); QVariant combined = olive::NodeValue::combine_track_values_into_normal_value( - olive::NodeValue::kColor, split); + olive::NodeValue::k_color, split); const olive::core::Color color_out = combined.value(); EXPECT_FLOAT_EQ(color_out.red(), c.red()); EXPECT_FLOAT_EQ(color_out.green(), c.green()); @@ -386,166 +386,166 @@ TEST(NodeValueExtended, CombineTrackValuesRebuildsValue) EXPECT_FLOAT_EQ(color_out.alpha(), c.alpha()); const QVector2D vec(1.5f, -2.5f); - split = olive::NodeValue(olive::NodeValue::kVec2, vec).to_split_value(); + split = olive::NodeValue(olive::NodeValue::k_vec2, vec).to_split_value(); combined = olive::NodeValue::combine_track_values_into_normal_value( - olive::NodeValue::kVec2, split); + olive::NodeValue::k_vec2, split); const QVector2D vec_out = combined.value(); EXPECT_FLOAT_EQ(vec_out.x(), vec.x()); EXPECT_FLOAT_EQ(vec_out.y(), vec.y()); // Scalar types return the first (only) track value QVariant scalar = olive::NodeValue::combine_track_values_into_normal_value( - olive::NodeValue::kFloat, { 4.5 }); + olive::NodeValue::k_float, { 4.5 }); EXPECT_DOUBLE_EQ(scalar.toDouble(), 4.5); // An empty split combines to a null variant EXPECT_TRUE(olive::NodeValue::combine_track_values_into_normal_value( - olive::NodeValue::kVec2, {}) + olive::NodeValue::k_vec2, {}) .isNull()); } TEST(NodeValueExtended, PrettyDataTypeNames) { - for (int i = olive::NodeValue::kNone; i < olive::NodeValue::kDataTypeCount; + for (int i = olive::NodeValue::k_none; i < olive::NodeValue::k_data_type_count; i++) { const auto type = static_cast(i); - EXPECT_FALSE(olive::NodeValue::GetPrettyDataTypeName(type).isEmpty()) + EXPECT_FALSE(olive::NodeValue::get_pretty_data_type_name(type).isEmpty()) << "type " << i; } - EXPECT_EQ(olive::NodeValue::GetPrettyDataTypeName( - olive::NodeValue::kDataTypeCount), + EXPECT_EQ(olive::NodeValue::get_pretty_data_type_name( + olive::NodeValue::k_data_type_count), QStringLiteral("Unknown")); // kStrCombo and kPushButton have dedicated pretty names like every other // type EXPECT_EQ( - olive::NodeValue::GetPrettyDataTypeName(olive::NodeValue::kStrCombo), + olive::NodeValue::get_pretty_data_type_name(olive::NodeValue::k_str_combo), QStringLiteral("String Combo")); EXPECT_EQ( - olive::NodeValue::GetPrettyDataTypeName(olive::NodeValue::kPushButton), + olive::NodeValue::get_pretty_data_type_name(olive::NodeValue::k_push_button), QStringLiteral("Push Button")); } TEST(NodeValueExtended, TypeClassificationRemainingCases) { EXPECT_TRUE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kVec2)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_vec2)); EXPECT_TRUE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kVec3)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_vec3)); EXPECT_TRUE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kVec4)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_vec4)); EXPECT_TRUE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kBezier)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_bezier)); EXPECT_TRUE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kRational)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_rational)); EXPECT_FALSE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kNone)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_none)); EXPECT_FALSE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kText)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_text)); EXPECT_FALSE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kTexture)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_texture)); EXPECT_FALSE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kSamples)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_samples)); EXPECT_FALSE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kBoolean)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_boolean)); - EXPECT_TRUE(olive::NodeValue::type_is_numeric(olive::NodeValue::kRational)); - EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::kVec2)); - EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::kColor)); - EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::kBoolean)); - EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::kNone)); + EXPECT_TRUE(olive::NodeValue::type_is_numeric(olive::NodeValue::k_rational)); + EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::k_vec2)); + EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::k_color)); + EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::k_boolean)); + EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::k_none)); - EXPECT_TRUE(olive::NodeValue::type_is_vector(olive::NodeValue::kVec4)); - EXPECT_FALSE(olive::NodeValue::type_is_vector(olive::NodeValue::kColor)); - EXPECT_FALSE(olive::NodeValue::type_is_vector(olive::NodeValue::kText)); + EXPECT_TRUE(olive::NodeValue::type_is_vector(olive::NodeValue::k_vec4)); + EXPECT_FALSE(olive::NodeValue::type_is_vector(olive::NodeValue::k_color)); + EXPECT_FALSE(olive::NodeValue::type_is_vector(olive::NodeValue::k_text)); - EXPECT_FALSE(olive::NodeValue::type_is_buffer(olive::NodeValue::kNone)); - EXPECT_FALSE(olive::NodeValue::type_is_buffer(olive::NodeValue::kFloat)); + EXPECT_FALSE(olive::NodeValue::type_is_buffer(olive::NodeValue::k_none)); + EXPECT_FALSE(olive::NodeValue::type_is_buffer(olive::NodeValue::k_float)); } TEST(NodeValueExtended, AllRealTypesHaveDataTypeNames) { - EXPECT_EQ(olive::NodeValue::GetDataTypeName(olive::NodeValue::kStrCombo), + EXPECT_EQ(olive::NodeValue::get_data_type_name(olive::NodeValue::k_str_combo), QStringLiteral("strcombo")); - EXPECT_EQ(olive::NodeValue::GetDataTypeName(olive::NodeValue::kPushButton), + EXPECT_EQ(olive::NodeValue::get_data_type_name(olive::NodeValue::k_push_button), QStringLiteral("pushbutton")); EXPECT_TRUE( - olive::NodeValue::GetDataTypeName(olive::NodeValue::kDataTypeCount) + olive::NodeValue::get_data_type_name(olive::NodeValue::k_data_type_count) .isEmpty()); - EXPECT_EQ(olive::NodeValue::GetDataTypeFromName( + EXPECT_EQ(olive::NodeValue::get_data_type_from_name( QStringLiteral("not-a-type")), - olive::NodeValue::kNone); + olive::NodeValue::k_none); // An empty name matches no type - EXPECT_EQ(olive::NodeValue::GetDataTypeFromName(QString()), - olive::NodeValue::kNone); + EXPECT_EQ(olive::NodeValue::get_data_type_from_name(QString()), + olive::NodeValue::k_none); // The newly named types round-trip EXPECT_EQ( - olive::NodeValue::GetDataTypeFromName(QStringLiteral("strcombo")), - olive::NodeValue::kStrCombo); + olive::NodeValue::get_data_type_from_name(QStringLiteral("strcombo")), + olive::NodeValue::k_str_combo); EXPECT_EQ( - olive::NodeValue::GetDataTypeFromName(QStringLiteral("pushbutton")), - olive::NodeValue::kPushButton); + olive::NodeValue::get_data_type_from_name(QStringLiteral("pushbutton")), + olive::NodeValue::k_push_button); } TEST(NodeValueExtended, ArrayValuesRoundTrip) { olive::NodeValueArray array; - array[0] = olive::NodeValue(olive::NodeValue::kInt, int64_t(4)); - array[5] = olive::NodeValue(olive::NodeValue::kText, + array[0] = olive::NodeValue(olive::NodeValue::k_int, int64_t(4)); + array[5] = olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("five")); - olive::NodeValue value(olive::NodeValue::kInt, array, nullptr, true); + olive::NodeValue value(olive::NodeValue::k_int, array, nullptr, true); EXPECT_TRUE(value.array()); - const olive::NodeValueArray round_trip = value.toArray(); + const olive::NodeValueArray round_trip = value.to_array(); ASSERT_EQ(round_trip.size(), size_t(2)); - EXPECT_EQ(round_trip.at(0).toInt(), 4); - EXPECT_EQ(round_trip.at(5).toString(), QStringLiteral("five")); + EXPECT_EQ(round_trip.at(0).to_int(), 4); + EXPECT_EQ(round_trip.at(5).to_string(), QStringLiteral("five")); } TEST(NodeValueTableExtended, GetReturnsNewestMatchingValue) { olive::NodeValueTable table; - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 1.0)); - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 2.0)); + table.push(olive::NodeValue(olive::NodeValue::k_float, 1.0)); + table.push(olive::NodeValue(olive::NodeValue::k_float, 2.0)); // Get() scans from the back, so the newest value wins and nothing is // removed - EXPECT_DOUBLE_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 2.0); - EXPECT_EQ(table.Count(), 2); + EXPECT_DOUBLE_EQ(table.get(olive::NodeValue::k_float).to_double(), 2.0); + EXPECT_EQ(table.count(), 2); } TEST(NodeValueTableExtended, GetWithTagSelectsMatchingValue) { olive::NodeValueTable table; - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 1.0, nullptr, + table.push(olive::NodeValue(olive::NodeValue::k_float, 1.0, nullptr, QStringLiteral("a"))); - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 2.0, nullptr, + table.push(olive::NodeValue(olive::NodeValue::k_float, 2.0, nullptr, QStringLiteral("b"))); - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 3.0)); + table.push(olive::NodeValue(olive::NodeValue::k_float, 3.0)); EXPECT_DOUBLE_EQ( - table.Get(olive::NodeValue::kFloat, QStringLiteral("a")).toDouble(), + table.get(olive::NodeValue::k_float, QStringLiteral("a")).to_double(), 1.0); EXPECT_DOUBLE_EQ( - table.Get(olive::NodeValue::kFloat, QStringLiteral("b")).toDouble(), + table.get(olive::NodeValue::k_float, QStringLiteral("b")).to_double(), 2.0); // Without a tag the newest value wins - EXPECT_DOUBLE_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 3.0); - EXPECT_EQ(table.GetValueIndex({ olive::NodeValue::kFloat }, + EXPECT_DOUBLE_EQ(table.get(olive::NodeValue::k_float).to_double(), 3.0); + EXPECT_EQ(table.get_value_index({ olive::NodeValue::k_float }, QStringLiteral("b")), 1); // An unknown tag yields an empty value; the fallback to the oldest value // of the type only applies when no tag is requested olive::NodeValue missing = - table.Get(olive::NodeValue::kFloat, QStringLiteral("missing")); - EXPECT_EQ(missing.type(), olive::NodeValue::kNone); - EXPECT_EQ(table.GetValueIndex({ olive::NodeValue::kFloat }, + table.get(olive::NodeValue::k_float, QStringLiteral("missing")); + EXPECT_EQ(missing.type(), olive::NodeValue::k_none); + EXPECT_EQ(table.get_value_index({ olive::NodeValue::k_float }, QStringLiteral("missing")), -1); } @@ -553,199 +553,199 @@ TEST(NodeValueTableExtended, GetWithTagSelectsMatchingValue) TEST(NodeValueTableExtended, GetWithMultipleTypes) { olive::NodeValueTable table; - table.Push( - olive::NodeValue(olive::NodeValue::kText, QStringLiteral("s"))); - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 2.5)); + table.push( + olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("s"))); + table.push(olive::NodeValue(olive::NodeValue::k_float, 2.5)); olive::NodeValue newest = - table.Get({ olive::NodeValue::kVec2, olive::NodeValue::kFloat }); - EXPECT_DOUBLE_EQ(newest.toDouble(), 2.5); + table.get({ olive::NodeValue::k_vec2, olive::NodeValue::k_float }); + EXPECT_DOUBLE_EQ(newest.to_double(), 2.5); olive::NodeValue text = - table.Get({ olive::NodeValue::kVec2, olive::NodeValue::kText }); - EXPECT_EQ(text.toString(), QStringLiteral("s")); + table.get({ olive::NodeValue::k_vec2, olive::NodeValue::k_text }); + EXPECT_EQ(text.to_string(), QStringLiteral("s")); // A type that was never pushed produces an empty (kNone) value - olive::NodeValue missing = table.Get(olive::NodeValue::kColor); - EXPECT_EQ(missing.type(), olive::NodeValue::kNone); + olive::NodeValue missing = table.get(olive::NodeValue::k_color); + EXPECT_EQ(missing.type(), olive::NodeValue::k_none); EXPECT_FALSE(missing); } TEST(NodeValueTableExtended, PrependAddsValueToFront) { olive::NodeValueTable table; - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 1.0)); - table.Prepend(olive::NodeValue(olive::NodeValue::kFloat, 2.0)); - table.Prepend(olive::NodeValue::kText, QStringLiteral("t"), nullptr, + table.push(olive::NodeValue(olive::NodeValue::k_float, 1.0)); + table.prepend(olive::NodeValue(olive::NodeValue::k_float, 2.0)); + table.prepend(olive::NodeValue::k_text, QStringLiteral("t"), nullptr, QStringLiteral("tag")); - ASSERT_EQ(table.Count(), 3); - EXPECT_EQ(table.at(0).type(), olive::NodeValue::kText); + ASSERT_EQ(table.count(), 3); + EXPECT_EQ(table.at(0).type(), olive::NodeValue::k_text); EXPECT_EQ(table.at(0).tag(), QStringLiteral("tag")); - EXPECT_DOUBLE_EQ(table.at(1).toDouble(), 2.0); - EXPECT_DOUBLE_EQ(table.at(2).toDouble(), 1.0); + EXPECT_DOUBLE_EQ(table.at(1).to_double(), 2.0); + EXPECT_DOUBLE_EQ(table.at(2).to_double(), 1.0); // Get() scans from the back, so prepended values are the lowest priority - EXPECT_DOUBLE_EQ(table.Get(olive::NodeValue::kFloat).toDouble(), 1.0); + EXPECT_DOUBLE_EQ(table.get(olive::NodeValue::k_float).to_double(), 1.0); } TEST(NodeValueTableExtended, TakeWithTagAndMissingType) { olive::NodeValueTable table; - table.Push(olive::NodeValue(olive::NodeValue::kText, QStringLiteral("a"), + table.push(olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("a"), nullptr, QStringLiteral("x"))); - table.Push(olive::NodeValue(olive::NodeValue::kText, QStringLiteral("b"), + table.push(olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("b"), nullptr, QStringLiteral("y"))); olive::NodeValue taken = - table.Take(olive::NodeValue::kText, QStringLiteral("x")); - EXPECT_EQ(taken.toString(), QStringLiteral("a")); - EXPECT_EQ(table.Count(), 1); + table.take(olive::NodeValue::k_text, QStringLiteral("x")); + EXPECT_EQ(taken.to_string(), QStringLiteral("a")); + EXPECT_EQ(table.count(), 1); // Taking a type that is not present returns an empty value and leaves the // table unchanged - olive::NodeValue absent = table.Take(olive::NodeValue::kColor); - EXPECT_EQ(absent.type(), olive::NodeValue::kNone); - EXPECT_EQ(table.Count(), 1); + olive::NodeValue absent = table.take(olive::NodeValue::k_color); + EXPECT_EQ(absent.type(), olive::NodeValue::k_none); + EXPECT_EQ(table.count(), 1); // Taking with an unmatched tag returns an empty value and leaves the table // unchanged; the oldest value of the type is not used as a fallback olive::NodeValue fallback = - table.Take(olive::NodeValue::kText, QStringLiteral("missing")); - EXPECT_EQ(fallback.type(), olive::NodeValue::kNone); - ASSERT_EQ(table.Count(), 1); - EXPECT_EQ(table.at(0).toString(), QStringLiteral("b")); + table.take(olive::NodeValue::k_text, QStringLiteral("missing")); + EXPECT_EQ(fallback.type(), olive::NodeValue::k_none); + ASSERT_EQ(table.count(), 1); + EXPECT_EQ(table.at(0).to_string(), QStringLiteral("b")); } TEST(NodeValueTableExtended, TakeWithMultipleTypes) { olive::NodeValueTable table; - table.Push( - olive::NodeValue(olive::NodeValue::kText, QStringLiteral("s"))); - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 1.5)); + table.push( + olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("s"))); + table.push(olive::NodeValue(olive::NodeValue::k_float, 1.5)); olive::NodeValue taken = - table.Take({ olive::NodeValue::kVec2, olive::NodeValue::kFloat }); - EXPECT_DOUBLE_EQ(taken.toDouble(), 1.5); - ASSERT_EQ(table.Count(), 1); - EXPECT_EQ(table.at(0).type(), olive::NodeValue::kText); + table.take({ olive::NodeValue::k_vec2, olive::NodeValue::k_float }); + EXPECT_DOUBLE_EQ(taken.to_double(), 1.5); + ASSERT_EQ(table.count(), 1); + EXPECT_EQ(table.at(0).type(), olive::NodeValue::k_text); } TEST(NodeValueTableExtended, TakeAtRemovesByIndex) { olive::NodeValueTable table; - table.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(1))); - table.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(2))); - table.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(3))); + table.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(1))); + table.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(2))); + table.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(3))); - olive::NodeValue taken = table.TakeAt(1); - EXPECT_EQ(taken.toInt(), 2); - ASSERT_EQ(table.Count(), 2); - EXPECT_EQ(table.at(0).toInt(), 1); - EXPECT_EQ(table.at(1).toInt(), 3); + olive::NodeValue taken = table.take_at(1); + EXPECT_EQ(taken.to_int(), 2); + ASSERT_EQ(table.count(), 2); + EXPECT_EQ(table.at(0).to_int(), 1); + EXPECT_EQ(table.at(1).to_int(), 3); } TEST(NodeValueTableExtended, RemoveDeletesNewestEqualValue) { olive::NodeValueTable table; - table.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(1))); - table.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(2))); - table.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(1))); + table.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(1))); + table.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(2))); + table.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(1))); // Remove() scans from the back and drops the newest equal value - table.Remove(olive::NodeValue(olive::NodeValue::kInt, int64_t(1))); - ASSERT_EQ(table.Count(), 2); - EXPECT_EQ(table.at(0).toInt(), 1); - EXPECT_EQ(table.at(1).toInt(), 2); + table.remove(olive::NodeValue(olive::NodeValue::k_int, int64_t(1))); + ASSERT_EQ(table.count(), 2); + EXPECT_EQ(table.at(0).to_int(), 1); + EXPECT_EQ(table.at(1).to_int(), 2); // Removing a value that is not present is a no-op - table.Remove(olive::NodeValue(olive::NodeValue::kInt, int64_t(99))); - EXPECT_EQ(table.Count(), 2); + table.remove(olive::NodeValue(olive::NodeValue::k_int, int64_t(99))); + EXPECT_EQ(table.count(), 2); } TEST(NodeValueTableExtended, HasUsesExactTypeMatch) { olive::NodeValueTable table; - table.Push(olive::NodeValue(olive::NodeValue::kFloat, 1.0)); - EXPECT_TRUE(table.Has(olive::NodeValue::kFloat)); - EXPECT_FALSE(table.Has(olive::NodeValue::kInt)); + table.push(olive::NodeValue(olive::NodeValue::k_float, 1.0)); + EXPECT_TRUE(table.has(olive::NodeValue::k_float)); + EXPECT_FALSE(table.has(olive::NodeValue::k_int)); // Type is a sequential enum, so no other type aliases kFloat - EXPECT_FALSE(table.Has(olive::NodeValue::kRational)); - EXPECT_FALSE(table.Has(olive::NodeValue::kText)); + EXPECT_FALSE(table.has(olive::NodeValue::k_rational)); + EXPECT_FALSE(table.has(olive::NodeValue::k_text)); // A table holding a kNone value reports it too olive::NodeValueTable none_table; - none_table.Push(olive::NodeValue()); - EXPECT_TRUE(none_table.Has(olive::NodeValue::kNone)); + none_table.push(olive::NodeValue()); + EXPECT_TRUE(none_table.has(olive::NodeValue::k_none)); } TEST(NodeValueTableExtended, PushTableAppendsAllValues) { olive::NodeValueTable first; - first.Push(olive::NodeValue(olive::NodeValue::kFloat, 1.0)); - first.Push( - olive::NodeValue(olive::NodeValue::kText, QStringLiteral("a"))); + first.push(olive::NodeValue(olive::NodeValue::k_float, 1.0)); + first.push( + olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("a"))); olive::NodeValueTable second; - second.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(7))); + second.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(7))); - first.Push(second); - ASSERT_EQ(first.Count(), 3); - EXPECT_EQ(first.at(2).toInt(), 7); + first.push(second); + ASSERT_EQ(first.count(), 3); + EXPECT_EQ(first.at(2).to_int(), 7); } TEST(NodeValueTableExtended, MergeSlipstreamsTables) { // A single table is returned as-is olive::NodeValueTable single; - single.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(9))); + single.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(9))); olive::NodeValueTable merged_single = - olive::NodeValueTable::Merge({ single }); - ASSERT_EQ(merged_single.Count(), 1); - EXPECT_EQ(merged_single.at(0).toInt(), 9); + olive::NodeValueTable::merge({ single }); + ASSERT_EQ(merged_single.count(), 1); + EXPECT_EQ(merged_single.at(0).to_int(), 9); // Merging no tables yields an empty table - EXPECT_TRUE(olive::NodeValueTable::Merge({}).isEmpty()); + EXPECT_TRUE(olive::NodeValueTable::merge({}).isEmpty()); // Rows are slipstreamed together from the back of each input table olive::NodeValueTable a; - a.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(1))); - a.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(3))); + a.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(1))); + a.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(3))); olive::NodeValueTable b; - b.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(2))); - b.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(4))); + b.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(2))); + b.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(4))); - olive::NodeValueTable merged = olive::NodeValueTable::Merge({ a, b }); - ASSERT_EQ(merged.Count(), 4); - EXPECT_EQ(merged.at(0).toInt(), 2); - EXPECT_EQ(merged.at(1).toInt(), 1); - EXPECT_EQ(merged.at(2).toInt(), 4); - EXPECT_EQ(merged.at(3).toInt(), 3); + olive::NodeValueTable merged = olive::NodeValueTable::merge({ a, b }); + ASSERT_EQ(merged.count(), 4); + EXPECT_EQ(merged.at(0).to_int(), 2); + EXPECT_EQ(merged.at(1).to_int(), 1); + EXPECT_EQ(merged.at(2).to_int(), 4); + EXPECT_EQ(merged.at(3).to_int(), 3); // A longer table's excess rows end up at the front olive::NodeValueTable c; - c.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(5))); - c.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(6))); - c.Push(olive::NodeValue(olive::NodeValue::kInt, int64_t(7))); + c.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(5))); + c.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(6))); + c.push(olive::NodeValue(olive::NodeValue::k_int, int64_t(7))); - olive::NodeValueTable merged_long = olive::NodeValueTable::Merge({ a, c }); - ASSERT_EQ(merged_long.Count(), 5); - EXPECT_EQ(merged_long.at(0).toInt(), 5); - EXPECT_EQ(merged_long.at(1).toInt(), 6); - EXPECT_EQ(merged_long.at(2).toInt(), 1); - EXPECT_EQ(merged_long.at(3).toInt(), 7); - EXPECT_EQ(merged_long.at(4).toInt(), 3); + olive::NodeValueTable merged_long = olive::NodeValueTable::merge({ a, c }); + ASSERT_EQ(merged_long.count(), 5); + EXPECT_EQ(merged_long.at(0).to_int(), 5); + EXPECT_EQ(merged_long.at(1).to_int(), 6); + EXPECT_EQ(merged_long.at(2).to_int(), 1); + EXPECT_EQ(merged_long.at(3).to_int(), 7); + EXPECT_EQ(merged_long.at(4).to_int(), 3); } TEST(NodeKeyframeExtended, FullConstructorInitializesFields) { - olive::NodeKeyframe key(olive::core::rational(1, 24), 42.0, - olive::NodeKeyframe::kBezier, 2, 3, + olive::NodeKeyframe key(olive::core::Rational(1, 24), 42.0, + olive::NodeKeyframe::k_bezier, 2, 3, QStringLiteral("input_name")); - EXPECT_EQ(key.time(), olive::core::rational(1, 24)); + EXPECT_EQ(key.time(), olive::core::Rational(1, 24)); EXPECT_DOUBLE_EQ(key.value().toDouble(), 42.0); - EXPECT_EQ(key.type(), olive::NodeKeyframe::kBezier); + EXPECT_EQ(key.type(), olive::NodeKeyframe::k_bezier); EXPECT_EQ(key.track(), 2); EXPECT_EQ(key.element(), 3); EXPECT_EQ(key.input(), QStringLiteral("input_name")); @@ -755,13 +755,13 @@ TEST(NodeKeyframeExtended, FullConstructorInitializesFields) EXPECT_EQ(key.next(), nullptr); EXPECT_EQ(key.parent(), nullptr); - EXPECT_EQ(olive::NodeKeyframe::kDefaultType, olive::NodeKeyframe::kLinear); + EXPECT_EQ(olive::NodeKeyframe::k_default_type, olive::NodeKeyframe::k_linear); } TEST(NodeKeyframeExtended, CopyDuplicatesAllFields) { - olive::NodeKeyframe key(olive::core::rational(1, 24), 3.5, - olive::NodeKeyframe::kBezier, 1, 2, + olive::NodeKeyframe key(olive::core::Rational(1, 24), 3.5, + olive::NodeKeyframe::k_bezier, 1, 2, QStringLiteral("in")); key.set_bezier_control_in(QPointF(0.1, 0.2)); key.set_bezier_control_out(QPointF(0.3, 0.4)); @@ -769,7 +769,7 @@ TEST(NodeKeyframeExtended, CopyDuplicatesAllFields) std::unique_ptr copy(key.copy()); EXPECT_EQ(copy->time(), key.time()); EXPECT_DOUBLE_EQ(copy->value().toDouble(), 3.5); - EXPECT_EQ(copy->type(), olive::NodeKeyframe::kBezier); + EXPECT_EQ(copy->type(), olive::NodeKeyframe::k_bezier); EXPECT_EQ(copy->track(), 1); EXPECT_EQ(copy->element(), 2); EXPECT_EQ(copy->input(), QStringLiteral("in")); @@ -792,38 +792,38 @@ TEST(NodeKeyframeExtended, SettersEmitSignals) { // QSignalSpy resolves signal argument types at runtime; the app normally // registers these in Core::Start(), which the test harness does not call - qRegisterMetaType(); + qRegisterMetaType(); qRegisterMetaType(); olive::NodeKeyframe key; - QSignalSpy time_spy(&key, &olive::NodeKeyframe::TimeChanged); - key.set_time(olive::core::rational(1, 2)); + QSignalSpy time_spy(&key, &olive::NodeKeyframe::time_changed); + key.set_time(olive::core::Rational(1, 2)); ASSERT_EQ(time_spy.count(), 1); - EXPECT_EQ(time_spy.first().at(0).value(), - olive::core::rational(1, 2)); + EXPECT_EQ(time_spy.first().at(0).value(), + olive::core::Rational(1, 2)); - QSignalSpy value_spy(&key, &olive::NodeKeyframe::ValueChanged); + QSignalSpy value_spy(&key, &olive::NodeKeyframe::value_changed); key.set_value(3.5); ASSERT_EQ(value_spy.count(), 1); EXPECT_DOUBLE_EQ(value_spy.first().at(0).toDouble(), 3.5); - QSignalSpy type_spy(&key, &olive::NodeKeyframe::TypeChanged); - key.set_type(olive::NodeKeyframe::kHold); + QSignalSpy type_spy(&key, &olive::NodeKeyframe::type_changed); + key.set_type(olive::NodeKeyframe::k_hold); ASSERT_EQ(type_spy.count(), 1); EXPECT_EQ(type_spy.first().at(0).value(), - olive::NodeKeyframe::kHold); + olive::NodeKeyframe::k_hold); // Setting the same type again does not re-emit - key.set_type(olive::NodeKeyframe::kHold); + key.set_type(olive::NodeKeyframe::k_hold); EXPECT_EQ(type_spy.count(), 1); - QSignalSpy in_spy(&key, &olive::NodeKeyframe::BezierControlInChanged); + QSignalSpy in_spy(&key, &olive::NodeKeyframe::bezier_control_in_changed); key.set_bezier_control_in(QPointF(0.25, -0.5)); ASSERT_EQ(in_spy.count(), 1); EXPECT_EQ(in_spy.first().at(0).toPointF(), QPointF(0.25, -0.5)); - QSignalSpy out_spy(&key, &olive::NodeKeyframe::BezierControlOutChanged); + QSignalSpy out_spy(&key, &olive::NodeKeyframe::bezier_control_out_changed); key.set_bezier_control_out(QPointF(-0.25, 0.5)); ASSERT_EQ(out_spy.count(), 1); EXPECT_EQ(out_spy.first().at(0).toPointF(), QPointF(-0.25, 0.5)); @@ -833,8 +833,8 @@ TEST(NodeKeyframeExtended, SetTypeToBezierInitializesHandles) { // Without neighbors the handles default to one second either way olive::NodeKeyframe lone; - lone.set_time(olive::core::rational(2)); - lone.set_type(olive::NodeKeyframe::kBezier); + lone.set_time(olive::core::Rational(2)); + lone.set_type(olive::NodeKeyframe::k_bezier); EXPECT_DOUBLE_EQ(lone.bezier_control_in().x(), -1.0); EXPECT_DOUBLE_EQ(lone.bezier_control_in().y(), 0.0); EXPECT_DOUBLE_EQ(lone.bezier_control_out().x(), 1.0); @@ -842,14 +842,14 @@ TEST(NodeKeyframeExtended, SetTypeToBezierInitializesHandles) // With neighbors the handles default to halfway to each neighbor's time olive::NodeKeyframe previous; - previous.set_time(olive::core::rational(-4)); + previous.set_time(olive::core::Rational(-4)); olive::NodeKeyframe next; - next.set_time(olive::core::rational(8)); + next.set_time(olive::core::Rational(8)); olive::NodeKeyframe key; - key.set_time(olive::core::rational(2)); + key.set_time(olive::core::Rational(2)); key.set_previous(&previous); key.set_next(&next); - key.set_type(olive::NodeKeyframe::kBezier); + key.set_type(olive::NodeKeyframe::k_bezier); EXPECT_DOUBLE_EQ(key.bezier_control_in().x(), -3.0); EXPECT_DOUBLE_EQ(key.bezier_control_in().y(), 0.0); EXPECT_DOUBLE_EQ(key.bezier_control_out().x(), 3.0); @@ -859,7 +859,7 @@ TEST(NodeKeyframeExtended, SetTypeToBezierInitializesHandles) olive::NodeKeyframe preset; preset.set_bezier_control_in(QPointF(-0.25, 0.5)); preset.set_bezier_control_out(QPointF(0.75, -0.5)); - preset.set_type(olive::NodeKeyframe::kBezier); + preset.set_type(olive::NodeKeyframe::k_bezier); EXPECT_EQ(preset.bezier_control_in(), QPointF(-0.25, 0.5)); EXPECT_EQ(preset.bezier_control_out(), QPointF(0.75, -0.5)); } @@ -869,14 +869,14 @@ TEST(NodeKeyframeExtended, SetTypeNoBezierAdjLeavesHandlesUntouched) olive::NodeKeyframe key; key.set_bezier_control_in(QPointF(0.5, 0.5)); key.set_bezier_control_out(QPointF(-0.5, -0.5)); - key.set_type_no_bezier_adj(olive::NodeKeyframe::kBezier); - EXPECT_EQ(key.type(), olive::NodeKeyframe::kBezier); + key.set_type_no_bezier_adj(olive::NodeKeyframe::k_bezier); + EXPECT_EQ(key.type(), olive::NodeKeyframe::k_bezier); EXPECT_EQ(key.bezier_control_in(), QPointF(0.5, 0.5)); EXPECT_EQ(key.bezier_control_out(), QPointF(-0.5, -0.5)); // Handles stay null when none were set olive::NodeKeyframe other; - other.set_type_no_bezier_adj(olive::NodeKeyframe::kBezier); + other.set_type_no_bezier_adj(olive::NodeKeyframe::k_bezier); EXPECT_TRUE(other.bezier_control_in().isNull()); EXPECT_TRUE(other.bezier_control_out().isNull()); } @@ -884,30 +884,30 @@ TEST(NodeKeyframeExtended, SetTypeNoBezierAdjLeavesHandlesUntouched) TEST(NodeKeyframeExtended, BezierControlAccessorsByHandleType) { olive::NodeKeyframe key; - key.set_bezier_control(olive::NodeKeyframe::kInHandle, + key.set_bezier_control(olive::NodeKeyframe::k_in_handle, QPointF(-0.5, 0.25)); - key.set_bezier_control(olive::NodeKeyframe::kOutHandle, + key.set_bezier_control(olive::NodeKeyframe::k_out_handle, QPointF(0.5, -0.25)); EXPECT_EQ(key.bezier_control_in(), QPointF(-0.5, 0.25)); EXPECT_EQ(key.bezier_control_out(), QPointF(0.5, -0.25)); - EXPECT_EQ(key.bezier_control(olive::NodeKeyframe::kInHandle), + EXPECT_EQ(key.bezier_control(olive::NodeKeyframe::k_in_handle), key.bezier_control_in()); - EXPECT_EQ(key.bezier_control(olive::NodeKeyframe::kOutHandle), + EXPECT_EQ(key.bezier_control(olive::NodeKeyframe::k_out_handle), key.bezier_control_out()); EXPECT_EQ(olive::NodeKeyframe::get_opposing_bezier_type( - olive::NodeKeyframe::kInHandle), - olive::NodeKeyframe::kOutHandle); + olive::NodeKeyframe::k_in_handle), + olive::NodeKeyframe::k_out_handle); EXPECT_EQ(olive::NodeKeyframe::get_opposing_bezier_type( - olive::NodeKeyframe::kOutHandle), - olive::NodeKeyframe::kInHandle); + olive::NodeKeyframe::k_out_handle), + olive::NodeKeyframe::k_in_handle); } TEST(NodeKeyframeExtended, ValidBezierControlsClampToNeighbors) { olive::NodeKeyframe key; - key.set_time(olive::core::rational(2)); + key.set_time(olive::core::Rational(2)); key.set_bezier_control_in(QPointF(-5.0, 0.5)); key.set_bezier_control_out(QPointF(5.0, -0.25)); @@ -916,9 +916,9 @@ TEST(NodeKeyframeExtended, ValidBezierControlsClampToNeighbors) EXPECT_EQ(key.valid_bezier_control_out(), QPointF(5.0, -0.25)); olive::NodeKeyframe previous; - previous.set_time(olive::core::rational(1)); + previous.set_time(olive::core::Rational(1)); olive::NodeKeyframe next; - next.set_time(olive::core::rational(3)); + next.set_time(olive::core::Rational(3)); key.set_previous(&previous); key.set_next(&next); @@ -932,8 +932,8 @@ TEST(NodeKeyframeExtended, ValidBezierControlsClampToNeighbors) TEST(NodeKeyframeExtended, KeyTrackRefReflectsInputTrackElement) { - olive::NodeKeyframe key(olive::core::rational(1, 24), 2.0, - olive::NodeKeyframe::kLinear, 2, 3, + olive::NodeKeyframe key(olive::core::Rational(1, 24), 2.0, + olive::NodeKeyframe::k_linear, 2, 3, QStringLiteral("my_input")); const olive::NodeKeyframeTrackReference ref = key.key_track_ref(); @@ -941,27 +941,27 @@ TEST(NodeKeyframeExtended, KeyTrackRefReflectsInputTrackElement) EXPECT_EQ(ref.input().input(), QStringLiteral("my_input")); EXPECT_EQ(ref.input().element(), 3); EXPECT_EQ(ref.input().node(), nullptr); - EXPECT_FALSE(ref.IsValid()); + EXPECT_FALSE(ref.is_valid()); } TEST(NodeKeyframeExtended, HasSiblingAtTimeDetectsOtherKeyframes) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *math = new olive::MathNode(); math->setParent(&project); // Keyframe lookups only apply to tracks with keyframing enabled - math->SetInputIsKeyframing(olive::MathNode::kParamAIn, true); + math->set_input_is_keyframing(olive::MathNode::k_param_a_in, true); auto *first = new olive::NodeKeyframe( - olive::core::rational(0), 1.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn, math); + olive::core::Rational(0), 1.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in, math); auto *second = new olive::NodeKeyframe( - olive::core::rational(1), 2.0, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn, math); + olive::core::Rational(1), 2.0, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in, math); // Parenting inserts the keyframes in time order and links the track EXPECT_EQ(first->next(), second); @@ -970,17 +970,17 @@ TEST(NodeKeyframeExtended, HasSiblingAtTimeDetectsOtherKeyframes) EXPECT_EQ(second->next(), nullptr); // A sibling exists wherever another keyframe holds the time - EXPECT_TRUE(second->has_sibling_at_time(olive::core::rational(0))); - EXPECT_FALSE(second->has_sibling_at_time(olive::core::rational(1))); - EXPECT_FALSE(first->has_sibling_at_time(olive::core::rational(2))); + EXPECT_TRUE(second->has_sibling_at_time(olive::core::Rational(0))); + EXPECT_FALSE(second->has_sibling_at_time(olive::core::Rational(1))); + EXPECT_FALSE(first->has_sibling_at_time(olive::core::Rational(2))); // Inserting out of order keeps the track sorted and relinks neighbors auto *middle = new olive::NodeKeyframe( - olive::core::rational(1, 2), 1.5, olive::NodeKeyframe::kLinear, 0, -1, - olive::MathNode::kParamAIn, math); + olive::core::Rational(1, 2), 1.5, olive::NodeKeyframe::k_linear, 0, -1, + olive::MathNode::k_param_a_in, math); EXPECT_EQ(first->next(), middle); EXPECT_EQ(middle->previous(), first); EXPECT_EQ(middle->next(), second); EXPECT_EQ(second->previous(), middle); - EXPECT_TRUE(middle->has_sibling_at_time(olive::core::rational(0))); + EXPECT_TRUE(middle->has_sibling_at_time(olive::core::Rational(0))); } diff --git a/tests/gtest/node_value_test.cpp b/tests/gtest/node_value_test.cpp index 9a7f56077..45f4e1900 100644 --- a/tests/gtest/node_value_test.cpp +++ b/tests/gtest/node_value_test.cpp @@ -9,18 +9,18 @@ TEST(NodeValue, VectorRoundTrip) { QVector2D v2(1.5f, -2.0f); - QString encoded = olive::NodeValue::ValueToString( - olive::NodeValue::kVec2, QVariant::fromValue(v2), false); - QVariant decoded = olive::NodeValue::StringToValue(olive::NodeValue::kVec2, + QString encoded = olive::NodeValue::value_to_string( + olive::NodeValue::k_vec2, QVariant::fromValue(v2), false); + QVariant decoded = olive::NodeValue::string_to_value(olive::NodeValue::k_vec2, encoded, false); QVector2D v2_out = decoded.value(); EXPECT_FLOAT_EQ(v2_out.x(), v2.x()); EXPECT_FLOAT_EQ(v2_out.y(), v2.y()); QVector3D v3(1.0f, 2.0f, 3.0f); - encoded = olive::NodeValue::ValueToString(olive::NodeValue::kVec3, + encoded = olive::NodeValue::value_to_string(olive::NodeValue::k_vec3, QVariant::fromValue(v3), false); - decoded = olive::NodeValue::StringToValue(olive::NodeValue::kVec3, encoded, + decoded = olive::NodeValue::string_to_value(olive::NodeValue::k_vec3, encoded, false); QVector3D v3_out = decoded.value(); EXPECT_FLOAT_EQ(v3_out.x(), v3.x()); @@ -28,9 +28,9 @@ TEST(NodeValue, VectorRoundTrip) EXPECT_FLOAT_EQ(v3_out.z(), v3.z()); QVector4D v4(1.0f, 2.0f, 3.0f, 4.0f); - encoded = olive::NodeValue::ValueToString(olive::NodeValue::kVec4, + encoded = olive::NodeValue::value_to_string(olive::NodeValue::k_vec4, QVariant::fromValue(v4), false); - decoded = olive::NodeValue::StringToValue(olive::NodeValue::kVec4, encoded, + decoded = olive::NodeValue::string_to_value(olive::NodeValue::k_vec4, encoded, false); QVector4D v4_out = decoded.value(); EXPECT_FLOAT_EQ(v4_out.x(), v4.x()); @@ -43,53 +43,53 @@ TEST(NodeValue, BinaryRoundTrip) { QByteArray data("OliveTest"); QString encoded = - olive::NodeValue::ValueToString(olive::NodeValue::kBinary, data, false); - QVariant decoded = olive::NodeValue::StringToValue( - olive::NodeValue::kBinary, encoded, false); + olive::NodeValue::value_to_string(olive::NodeValue::k_binary, data, false); + QVariant decoded = olive::NodeValue::string_to_value( + olive::NodeValue::k_binary, encoded, false); EXPECT_EQ(decoded.toByteArray(), data); } TEST(NodeValue, TypeClassification) { EXPECT_TRUE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kFloat)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_float)); EXPECT_TRUE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kColor)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_color)); EXPECT_FALSE( - olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kInt)); + olive::NodeValue::type_can_be_interpolated(olive::NodeValue::k_int)); - EXPECT_TRUE(olive::NodeValue::type_is_numeric(olive::NodeValue::kInt)); - EXPECT_TRUE(olive::NodeValue::type_is_numeric(olive::NodeValue::kFloat)); - EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::kText)); + EXPECT_TRUE(olive::NodeValue::type_is_numeric(olive::NodeValue::k_int)); + EXPECT_TRUE(olive::NodeValue::type_is_numeric(olive::NodeValue::k_float)); + EXPECT_FALSE(olive::NodeValue::type_is_numeric(olive::NodeValue::k_text)); - EXPECT_TRUE(olive::NodeValue::type_is_vector(olive::NodeValue::kVec2)); - EXPECT_TRUE(olive::NodeValue::type_is_vector(olive::NodeValue::kVec3)); - EXPECT_FALSE(olive::NodeValue::type_is_vector(olive::NodeValue::kFloat)); + EXPECT_TRUE(olive::NodeValue::type_is_vector(olive::NodeValue::k_vec2)); + EXPECT_TRUE(olive::NodeValue::type_is_vector(olive::NodeValue::k_vec3)); + EXPECT_FALSE(olive::NodeValue::type_is_vector(olive::NodeValue::k_float)); - EXPECT_TRUE(olive::NodeValue::type_is_buffer(olive::NodeValue::kTexture)); - EXPECT_TRUE(olive::NodeValue::type_is_buffer(olive::NodeValue::kSamples)); - EXPECT_FALSE(olive::NodeValue::type_is_buffer(olive::NodeValue::kColor)); + EXPECT_TRUE(olive::NodeValue::type_is_buffer(olive::NodeValue::k_texture)); + EXPECT_TRUE(olive::NodeValue::type_is_buffer(olive::NodeValue::k_samples)); + EXPECT_FALSE(olive::NodeValue::type_is_buffer(olive::NodeValue::k_color)); } TEST(NodeValue, DataTypeNameRoundTrip) { - for (int i = olive::NodeValue::kNone; i < olive::NodeValue::kDataTypeCount; + for (int i = olive::NodeValue::k_none; i < olive::NodeValue::k_data_type_count; ++i) { auto type = static_cast(i); - QString name = olive::NodeValue::GetDataTypeName(type); + QString name = olive::NodeValue::get_data_type_name(type); if (name.isEmpty()) { continue; } - EXPECT_EQ(olive::NodeValue::GetDataTypeFromName(name), type) + EXPECT_EQ(olive::NodeValue::get_data_type_from_name(name), type) << name.toStdString(); } } TEST(NodeValue, ConstructionAndAccessors) { - olive::NodeValue val(olive::NodeValue::kInt, static_cast(42)); - EXPECT_EQ(val.type(), olive::NodeValue::kInt); - EXPECT_EQ(val.toInt(), 42); + olive::NodeValue val(olive::NodeValue::k_int, static_cast(42)); + EXPECT_EQ(val.type(), olive::NodeValue::k_int); + EXPECT_EQ(val.to_int(), 42); EXPECT_TRUE(val); val.set_tag(QStringLiteral("tag")); @@ -99,36 +99,36 @@ TEST(NodeValue, ConstructionAndAccessors) TEST(NodeValueTable, PushAndGet) { olive::NodeValueTable table; - olive::NodeValue v(olive::NodeValue::kFloat, 3.14); - table.Push(v); + olive::NodeValue v(olive::NodeValue::k_float, 3.14); + table.push(v); - EXPECT_EQ(table.Count(), 1); + EXPECT_EQ(table.count(), 1); EXPECT_FALSE(table.isEmpty()); - EXPECT_TRUE(table.Has(olive::NodeValue::kFloat)); + EXPECT_TRUE(table.has(olive::NodeValue::k_float)); - olive::NodeValue got = table.Get(olive::NodeValue::kFloat); - EXPECT_DOUBLE_EQ(got.toDouble(), 3.14); + olive::NodeValue got = table.get(olive::NodeValue::k_float); + EXPECT_DOUBLE_EQ(got.to_double(), 3.14); } TEST(NodeValueTable, TakeRemovesValue) { olive::NodeValueTable table; - table.Push( - olive::NodeValue(olive::NodeValue::kInt, static_cast(1))); - table.Push( - olive::NodeValue(olive::NodeValue::kInt, static_cast(2))); + table.push( + olive::NodeValue(olive::NodeValue::k_int, static_cast(1))); + table.push( + olive::NodeValue(olive::NodeValue::k_int, static_cast(2))); - olive::NodeValue taken = table.Take(olive::NodeValue::kInt); - EXPECT_EQ(taken.toInt(), 2); - EXPECT_EQ(table.Count(), 1); + olive::NodeValue taken = table.take(olive::NodeValue::k_int); + EXPECT_EQ(taken.to_int(), 2); + EXPECT_EQ(table.count(), 1); } TEST(NodeValueTable, ClearEmptiesTable) { olive::NodeValueTable table; - table.Push( - olive::NodeValue(olive::NodeValue::kText, QStringLiteral("hello"))); - table.Clear(); + table.push( + olive::NodeValue(olive::NodeValue::k_text, QStringLiteral("hello"))); + table.clear(); EXPECT_TRUE(table.isEmpty()); - EXPECT_EQ(table.Count(), 0); + EXPECT_EQ(table.count(), 0); } diff --git a/tests/gtest/node_view_test.cpp b/tests/gtest/node_view_test.cpp index be107f532..c3246d594 100644 --- a/tests/gtest/node_view_test.cpp +++ b/tests/gtest/node_view_test.cpp @@ -12,10 +12,10 @@ class NodeViewTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } std::unique_ptr project_; @@ -24,8 +24,8 @@ protected: TEST_F(NodeViewTest, ConstructionCreatesEmptyView) { NodeView view; - EXPECT_TRUE(view.GetContexts().isEmpty()); - EXPECT_FALSE(view.IsGroupOverlay()); + EXPECT_TRUE(view.get_contexts().isEmpty()); + EXPECT_FALSE(view.is_group_overlay()); } TEST_F(NodeViewTest, SetContextsUpdatesContextList) @@ -34,10 +34,10 @@ TEST_F(NodeViewTest, SetContextsUpdatesContextList) solid->setParent(project_.get()); NodeView view; - view.SetContexts({ solid }); + view.set_contexts({ solid }); - EXPECT_EQ(view.GetContexts().size(), 1); - EXPECT_EQ(view.GetContexts().first(), solid); + EXPECT_EQ(view.get_contexts().size(), 1); + EXPECT_EQ(view.get_contexts().first(), solid); } TEST_F(NodeViewTest, ShowSelectedNodeInParamEditorNoSelectionIsNoOp) @@ -45,7 +45,7 @@ TEST_F(NodeViewTest, ShowSelectedNodeInParamEditorNoSelectionIsNoOp) NodeView view; QSignalSpy changed_with_ctx_spy( - &view, &NodeView::NodeSelectionChangedWithContexts); + &view, &NodeView::node_selection_changed_with_contexts); // The action must exist; silently skipping the trigger would make this // test pass without exercising anything @@ -71,9 +71,9 @@ TEST_F(NodeViewTest, ClearGraphRemovesContexts) solid->setParent(project_.get()); NodeView view; - view.SetContexts({ solid }); - EXPECT_FALSE(view.GetContexts().isEmpty()); + view.set_contexts({ solid }); + EXPECT_FALSE(view.get_contexts().isEmpty()); - view.ClearGraph(); - EXPECT_TRUE(view.GetContexts().isEmpty()); + view.clear_graph(); + EXPECT_TRUE(view.get_contexts().isEmpty()); } diff --git a/tests/gtest/opengl_readback_guard_test.cpp b/tests/gtest/opengl_readback_guard_test.cpp index 742f0c7f6..f14892a80 100644 --- a/tests/gtest/opengl_readback_guard_test.cpp +++ b/tests/gtest/opengl_readback_guard_test.cpp @@ -20,14 +20,14 @@ TEST(OpenGLRenderer, DownloadFromTextureWithoutCurrentContext) ASSERT_EQ(QOpenGLContext::currentContext(), nullptr); olive::OpenGLRenderer renderer; - renderer.Init(&context); + renderer.init(&context); - olive::VideoParams params(4, 4, olive::core::PixelFormat::U8, 4, - olive::core::rational(1, 1), - olive::VideoParams::kInterlaceNone, 1); + olive::VideoParams params(4, 4, olive::core::PixelFormat::u8, 4, + olive::core::Rational(1, 1), + olive::VideoParams::k_interlace_none, 1); unsigned char buffer[4 * 4 * 4] = {}; - renderer.DownloadFromTexture(QVariant::fromValue(0), params, buffer, + renderer.download_from_texture(QVariant::fromValue(0), params, buffer, 4 * 4); EXPECT_EQ(QOpenGLContext::currentContext(), nullptr); diff --git a/tests/gtest/panel_test.cpp b/tests/gtest/panel_test.cpp index b21ad7dca..2a869e08d 100644 --- a/tests/gtest/panel_test.cpp +++ b/tests/gtest/panel_test.cpp @@ -60,7 +60,7 @@ class PanelEnvironment { public: PanelEnvironment() { - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); if (!Core::instance()) { new Core(Core::CoreParams()); // intentionally leaked @@ -69,12 +69,12 @@ public: KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtWidgets); if (!PanelManager::instance()) { - PanelManager::CreateInstance(); + PanelManager::create_instance(); created_panel_manager_ = true; } if (!TaskManager::instance()) { - TaskManager::CreateInstance(); + TaskManager::create_instance(); created_task_manager_ = true; } @@ -82,15 +82,15 @@ public: // Another suite may have left an experimental backend in the // config; RenderManager needs a real one to create its cacher saved_backend_ = - Config::Current()[QStringLiteral("GraphicsBackend")]; - Config::Current()[QStringLiteral("GraphicsBackend")] = + Config::current()[QStringLiteral("GraphicsBackend")]; + Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("opengl"); - RenderManager::CreateInstance(); + RenderManager::create_instance(); created_render_manager_ = true; } if (!DiskManager::instance()) { - DiskManager::CreateInstance(); + DiskManager::create_instance(); created_disk_manager_ = true; } } @@ -99,19 +99,19 @@ public: { // Panels must be gone before the manager that tracks them if (created_panel_manager_) { - PanelManager::instance()->DeleteAllPanels(); - PanelManager::DestroyInstance(); + PanelManager::instance()->delete_all_panels(); + PanelManager::destroy_instance(); } if (created_task_manager_) { - TaskManager::DestroyInstance(); + TaskManager::destroy_instance(); } if (created_render_manager_) { - RenderManager::DestroyInstance(); - Config::Current()[QStringLiteral("GraphicsBackend")] = + RenderManager::destroy_instance(); + Config::current()[QStringLiteral("GraphicsBackend")] = saved_backend_; } if (created_disk_manager_) { - DiskManager::DestroyInstance(); + DiskManager::destroy_instance(); } } @@ -131,13 +131,13 @@ public: { } - using PanelWidget::SetSubtitle; - using PanelWidget::SetTitle; + using PanelWidget::set_subtitle; + using PanelWidget::set_title; }; class TestTimeBasedPanel : public TimeBasedPanel { public: - using TimeBasedPanel::SetTimeBasedWidget; + using TimeBasedPanel::set_time_based_widget; using TimeBasedPanel::TimeBasedPanel; }; @@ -145,11 +145,11 @@ class DummyTask : public Task { public: DummyTask() { - SetTitle(QStringLiteral("Panel Test Task")); + set_title(QStringLiteral("Panel Test Task")); } protected: - virtual bool Run() override + virtual bool run() override { return true; } @@ -169,7 +169,7 @@ protected: delete env_; } - template T *AddNode(Project *project) + template T *add_node(Project *project) { auto *node = new T(); node->setParent(project); @@ -184,14 +184,14 @@ TEST_F(PanelTest, PanelWidgetBaseTitleSubtitleFormatting) TestPanel panel(QStringLiteral("BaseTestPanel")); EXPECT_EQ(panel.objectName(), QStringLiteral("BaseTestPanel")); - panel.SetTitle(QStringLiteral("Title")); + panel.set_title(QStringLiteral("Title")); EXPECT_EQ(panel.title(), QStringLiteral("Title")); - panel.SetSubtitle(QStringLiteral("Sub")); + panel.set_subtitle(QStringLiteral("Sub")); EXPECT_EQ(panel.title(), QStringLiteral("Title: Sub")); // Clearing the subtitle falls back to the bare title - panel.SetSubtitle(QString()); + panel.set_subtitle(QString()); EXPECT_EQ(panel.title(), QStringLiteral("Title")); } @@ -203,13 +203,13 @@ TEST_F(PanelTest, PanelWidgetBaseRegistersWithPanelManager) auto *panel = new TestPanel(QStringLiteral("RegisteredPanel")); EXPECT_TRUE(manager->panels().contains(panel)); EXPECT_EQ(manager->panels().size(), panel_count_before + 1); - EXPECT_EQ(manager->GetPanelWithName(QStringLiteral("RegisteredPanel")), + EXPECT_EQ(manager->get_panel_with_name(QStringLiteral("RegisteredPanel")), panel); - EXPECT_TRUE(manager->GetPanelsOfType().contains(panel)); + EXPECT_TRUE(manager->get_panels_of_type().contains(panel)); delete panel; EXPECT_FALSE(manager->panels().contains(panel)); - EXPECT_EQ(manager->GetPanelWithName(QStringLiteral("RegisteredPanel")), + EXPECT_EQ(manager->get_panel_with_name(QStringLiteral("RegisteredPanel")), nullptr); } @@ -225,8 +225,8 @@ TEST_F(PanelTest, PanelWidgetBaseCloseBehavior) // With SetSignalInsteadOfClose the close is vetoed and CloseRequested is // emitted instead - panel.SetSignalInsteadOfClose(true); - QSignalSpy spy(&panel, &PanelWidget::CloseRequested); + panel.set_signal_instead_of_close(true); + QSignalSpy spy(&panel, &PanelWidget::close_requested); panel.show(); ASSERT_TRUE(panel.isVisible()); panel.close(); @@ -237,77 +237,77 @@ TEST_F(PanelTest, PanelWidgetBaseCloseBehavior) TEST_F(PanelTest, PanelWidgetBaseDefaultActionsLeaveStateUnchanged) { TestPanel panel(QStringLiteral("NoOpTestPanel")); - panel.SetTitle(QStringLiteral("NoOp")); + panel.set_title(QStringLiteral("NoOp")); panel.show(); ASSERT_TRUE(panel.isVisible()); // Default SaveData is empty and LoadData accepts anything - EXPECT_TRUE(panel.SaveData().empty()); - panel.LoadData(PanelWidget::Info()); + EXPECT_TRUE(panel.save_data().empty()); + panel.load_data(PanelWidget::Info()); // None of the default actions may request a close - QSignalSpy close_spy(&panel, &PanelWidget::CloseRequested); + QSignalSpy close_spy(&panel, &PanelWidget::close_requested); // All default actions are no-ops and must not crash - panel.ZoomIn(); - panel.ZoomOut(); - panel.GoToStart(); - panel.PrevFrame(); - panel.PlayPause(); - panel.PlayInToOut(); - panel.NextFrame(); - panel.GoToEnd(); - panel.SelectAll(); - panel.DeselectAll(); - panel.RippleToIn(); - panel.RippleToOut(); - panel.EditToIn(); - panel.EditToOut(); - panel.ShuttleLeft(); - panel.ShuttleStop(); - panel.ShuttleRight(); - panel.GoToPrevCut(); - panel.GoToNextCut(); - panel.RenameSelected(); - panel.DeleteSelected(); - panel.RippleDelete(); - panel.IncreaseTrackHeight(); - panel.DecreaseTrackHeight(); - panel.SetIn(); - panel.SetOut(); - panel.ResetIn(); - panel.ResetOut(); - panel.ClearInOut(); - panel.SetMarker(); - panel.ToggleLinks(); - panel.CutSelected(); - panel.CopySelected(); - panel.Paste(); - panel.PasteInsert(); - panel.ToggleShowAll(); - panel.GoToIn(); - panel.GoToOut(); - panel.DeleteInToOut(); - panel.RippleDeleteInToOut(); - panel.ToggleSelectedEnabled(); - panel.Duplicate(); - panel.SetColorLabel(1); - panel.NudgeLeft(); - panel.NudgeRight(); - panel.MoveInToPlayhead(); - panel.MoveOutToPlayhead(); + panel.zoom_in(); + panel.zoom_out(); + panel.go_to_start(); + panel.prev_frame(); + panel.play_pause(); + panel.play_in_to_out(); + panel.next_frame(); + panel.go_to_end(); + panel.select_all(); + panel.deselect_all(); + panel.ripple_to_in(); + panel.ripple_to_out(); + panel.edit_to_in(); + panel.edit_to_out(); + panel.shuttle_left(); + panel.shuttle_stop(); + panel.shuttle_right(); + panel.go_to_prev_cut(); + panel.go_to_next_cut(); + panel.rename_selected(); + panel.delete_selected(); + panel.ripple_delete(); + panel.increase_track_height(); + panel.decrease_track_height(); + panel.set_in(); + panel.set_out(); + panel.reset_in(); + panel.reset_out(); + panel.clear_in_out(); + panel.set_marker(); + panel.toggle_links(); + panel.cut_selected(); + panel.copy_selected(); + panel.paste(); + panel.paste_insert(); + panel.toggle_show_all(); + panel.go_to_in(); + panel.go_to_out(); + panel.delete_in_to_out(); + panel.ripple_delete_in_to_out(); + panel.toggle_selected_enabled(); + panel.duplicate(); + panel.set_color_label(1); + panel.nudge_left(); + panel.nudge_right(); + panel.move_in_to_playhead(); + panel.move_out_to_playhead(); // The sweep must not have altered any observable panel state EXPECT_EQ(panel.title(), QStringLiteral("NoOp")); EXPECT_TRUE(panel.isVisible()); - EXPECT_TRUE(panel.SaveData().empty()); + EXPECT_TRUE(panel.save_data().empty()); EXPECT_EQ(close_spy.count(), 0); } TEST_F(PanelTest, PanelWidgetBaseBorderAndFocus) { TestPanel panel(QStringLiteral("BorderTestPanel")); - panel.SetBorderVisible(true); + panel.set_border_visible(true); panel.show(); // The shown signal is wired to grab focus @@ -315,7 +315,7 @@ TEST_F(PanelTest, PanelWidgetBaseBorderAndFocus) emit panel.hidden(); // Focus history lookup by type works through PanelManager - EXPECT_EQ(PanelManager::instance()->MostRecentlyFocused(), + EXPECT_EQ(PanelManager::instance()->most_recently_focused(), &panel); } @@ -332,7 +332,7 @@ TEST_F(PanelTest, PixelSamplerPanelConstruction) // Feeding values through the slot updates the displayed components Color red(1.0, 0.0, 0.0, 1.0); Color green(0.0, 1.0, 0.0, 1.0); - panel.SetValues(red, green); + panel.set_values(red, green); // First child is the display view, second the reference view EXPECT_TRUE(samplers.at(0)->findChild()->text().contains( @@ -353,14 +353,14 @@ TEST_F(PanelTest, TaskManagerPanelReflectsTaskManager) // The panel's TaskView is wired to the TaskManager singleton auto *task = new DummyTask(); - TaskManager::instance()->AddTask(task); + TaskManager::instance()->add_task(task); auto *view = panel.findChild(); ASSERT_NE(view, nullptr); EXPECT_NE(view->findChild(), nullptr); // TaskManager owns the task now; cancel it and let the removal propagate - TaskManager::instance()->CancelTaskAndWait(task); + TaskManager::instance()->cancel_task_and_wait(task); QCoreApplication::processEvents(QEventLoop::AllEvents, 100); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); } @@ -370,28 +370,28 @@ TEST_F(PanelTest, CurvePanelConstructionAndScaling) CurvePanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("CurvePanel")); EXPECT_TRUE(panel.title().startsWith(QStringLiteral("Curve Editor"))); - ASSERT_NE(panel.GetTimeBasedWidget(), nullptr); + ASSERT_NE(panel.get_time_based_widget(), nullptr); - auto *curve = static_cast(panel.GetTimeBasedWidget()); + auto *curve = static_cast(panel.get_time_based_widget()); // Track height actions scale the curve view vertically - const double initial_scale = curve->GetVerticalScale(); - panel.IncreaseTrackHeight(); - EXPECT_DOUBLE_EQ(curve->GetVerticalScale(), initial_scale * 2); - panel.DecreaseTrackHeight(); - EXPECT_DOUBLE_EQ(curve->GetVerticalScale(), initial_scale); + const double initial_scale = curve->get_vertical_scale(); + panel.increase_track_height(); + EXPECT_DOUBLE_EQ(curve->get_vertical_scale(), initial_scale * 2); + panel.decrease_track_height(); + EXPECT_DOUBLE_EQ(curve->get_vertical_scale(), initial_scale); // Selection actions on an empty view are harmless - panel.SelectAll(); - panel.DeselectAll(); - panel.DeleteSelected(); + panel.select_all(); + panel.deselect_all(); + panel.delete_selected(); } TEST_F(PanelTest, CurvePanelSetNodes) { Project project; - project.Initialize(); - auto *math = AddNode(&project); + project.initialize(); + auto *math = add_node(&project); CurvePanel panel; auto *tree = panel.findChild(); @@ -401,76 +401,76 @@ TEST_F(PanelTest, CurvePanelSetNodes) // A single node appears as one top-level item listing its keyframable // inputs (MathNode has three: the base "enabled" input and parameters // A and B) - panel.SetNode(math); + panel.set_node(math); ASSERT_EQ(tree->topLevelItemCount(), 1); - EXPECT_EQ(tree->topLevelItem(0)->text(0), math->Name()); + EXPECT_EQ(tree->topLevelItem(0)->text(0), math->name()); EXPECT_EQ(tree->topLevelItem(0)->childCount(), 3); // A null node clears the tree again - panel.SetNode(nullptr); + panel.set_node(nullptr); EXPECT_EQ(tree->topLevelItemCount(), 0); // Same through the multi-node slot - panel.SetNodes({ math }); + panel.set_nodes({ math }); EXPECT_EQ(tree->topLevelItemCount(), 1); - panel.SetNodes({}); + panel.set_nodes({}); EXPECT_EQ(tree->topLevelItemCount(), 0); } TEST_F(PanelTest, ParamPanelConstructionAndContexts) { Project project; - project.Initialize(); + project.initialize(); ParamPanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("ParamPanel")); EXPECT_EQ(panel.title(), QStringLiteral("Parameter Editor")); - ASSERT_NE(panel.GetParamView(), nullptr); + ASSERT_NE(panel.get_param_view(), nullptr); - EXPECT_TRUE(panel.GetContexts().isEmpty()); - panel.SetContexts({ project.root() }); - ASSERT_EQ(panel.GetContexts().size(), 1); - EXPECT_EQ(panel.GetContexts().first(), project.root()); + EXPECT_TRUE(panel.get_contexts().isEmpty()); + panel.set_contexts({ project.root() }); + ASSERT_EQ(panel.get_contexts().size(), 1); + EXPECT_EQ(panel.get_contexts().first(), project.root()); // Selection slots on an empty selection are harmless - panel.SelectAll(); - panel.DeselectAll(); - panel.DeleteSelected(); + panel.select_all(); + panel.deselect_all(); + panel.delete_selected(); } TEST_F(PanelTest, ParamPanelForwardsViewSignals) { Project project; - project.Initialize(); - auto *math = AddNode(&project); + project.initialize(); + auto *math = add_node(&project); ParamPanel panel; - QSignalSpy focused_spy(&panel, &ParamPanel::FocusedNodeChanged); - emit panel.GetParamView()->FocusedNodeChanged(math); + QSignalSpy focused_spy(&panel, &ParamPanel::focused_node_changed); + emit panel.get_param_view()->focused_node_changed(math); ASSERT_EQ(focused_spy.count(), 1); EXPECT_EQ(focused_spy.first().first().value(), math); - QSignalSpy selected_spy(&panel, &ParamPanel::SelectedNodesChanged); - emit panel.GetParamView()->SelectedNodesChanged({ { math, nullptr } }); + QSignalSpy selected_spy(&panel, &ParamPanel::selected_nodes_changed); + emit panel.get_param_view()->selected_nodes_changed({ { math, nullptr } }); EXPECT_EQ(selected_spy.count(), 1); - QSignalSpy text_spy(&panel, &ParamPanel::RequestViewerToStartEditingText); - emit panel.GetParamView()->RequestViewerToStartEditingText(); + QSignalSpy text_spy(&panel, &ParamPanel::request_viewer_to_start_editing_text); + emit panel.get_param_view()->request_viewer_to_start_editing_text(); EXPECT_EQ(text_spy.count(), 1); } TEST_F(PanelTest, ProjectPanelTracksProject) { Project project; - project.Initialize(); + project.initialize(); project.set_filename(QStringLiteral("/tmp/panel_test_project.ove")); ProjectPanel panel(QStringLiteral("ProjectPanelTest")); EXPECT_EQ(panel.objectName(), QStringLiteral("ProjectPanelTest")); EXPECT_EQ(panel.project(), nullptr); - QSignalSpy name_spy(&panel, &ProjectPanel::ProjectNameChanged); + QSignalSpy name_spy(&panel, &ProjectPanel::project_name_changed); panel.set_project(&project); EXPECT_EQ(panel.project(), &project); EXPECT_EQ(name_spy.count(), 1); @@ -480,7 +480,7 @@ TEST_F(PanelTest, ProjectPanelTracksProject) EXPECT_TRUE(panel.title().contains(project.name())); // A child folder can become the shown root - auto *folder = AddNode(&project); + auto *folder = add_node(&project); FolderAddChild(project.root(), folder).redo_now(); panel.set_root(folder); EXPECT_EQ(panel.get_root(), folder); @@ -489,83 +489,83 @@ TEST_F(PanelTest, ProjectPanelTracksProject) TEST_F(PanelTest, ProjectPanelSelectsChildNodes) { Project project; - project.Initialize(); - auto *math = AddNode(&project); + project.initialize(); + auto *math = add_node(&project); FolderAddChild(project.root(), math).redo_now(); ProjectPanel panel(QStringLiteral("ProjectPanelSelectTest")); panel.set_project(&project); - QSignalSpy selection_spy(&panel, &ProjectPanel::SelectionChanged); + QSignalSpy selection_spy(&panel, &ProjectPanel::selection_changed); - ASSERT_TRUE(panel.SelectItem(math)); - EXPECT_TRUE(panel.SelectedItems().contains(math)); + ASSERT_TRUE(panel.select_item(math)); + EXPECT_TRUE(panel.selected_items().contains(math)); EXPECT_GT(selection_spy.count(), 0); } TEST_F(PanelTest, TimeBasedPanelSignalsAndTimebase) { TestTimeBasedPanel panel(QStringLiteral("TimeBasedTestPanel")); - panel.SetTimeBasedWidget(new TimeBasedWidget(false, false, &panel)); + panel.set_time_based_widget(new TimeBasedWidget(false, false, &panel)); - QSignalSpy play_pause_spy(&panel, &TimeBasedPanel::PlayPauseRequested); - panel.PlayPause(); + QSignalSpy play_pause_spy(&panel, &TimeBasedPanel::play_pause_requested); + panel.play_pause(); EXPECT_EQ(play_pause_spy.count(), 1); - QSignalSpy play_in_out_spy(&panel, &TimeBasedPanel::PlayInToOutRequested); - panel.PlayInToOut(); + QSignalSpy play_in_out_spy(&panel, &TimeBasedPanel::play_in_to_out_requested); + panel.play_in_to_out(); EXPECT_EQ(play_in_out_spy.count(), 1); - QSignalSpy shuttle_left_spy(&panel, &TimeBasedPanel::ShuttleLeftRequested); - panel.ShuttleLeft(); + QSignalSpy shuttle_left_spy(&panel, &TimeBasedPanel::shuttle_left_requested); + panel.shuttle_left(); EXPECT_EQ(shuttle_left_spy.count(), 1); - QSignalSpy shuttle_stop_spy(&panel, &TimeBasedPanel::ShuttleStopRequested); - panel.ShuttleStop(); + QSignalSpy shuttle_stop_spy(&panel, &TimeBasedPanel::shuttle_stop_requested); + panel.shuttle_stop(); EXPECT_EQ(shuttle_stop_spy.count(), 1); QSignalSpy shuttle_right_spy(&panel, - &TimeBasedPanel::ShuttleRightRequested); - panel.ShuttleRight(); + &TimeBasedPanel::shuttle_right_requested); + panel.shuttle_right(); EXPECT_EQ(shuttle_right_spy.count(), 1); - panel.SetTimebase(rational(1, 30)); - EXPECT_EQ(panel.timebase(), rational(1, 30)); + panel.set_timebase(Rational(1, 30)); + EXPECT_EQ(panel.timebase(), Rational(1, 30)); } TEST_F(PanelTest, TimeBasedPanelConnectViewerUpdatesSubtitle) { Project project; - project.Initialize(); - auto *viewer = AddNode(&project); - viewer->SetLabel(QStringLiteral("My Viewer")); + project.initialize(); + auto *viewer = add_node(&project); + viewer->set_label(QStringLiteral("My Viewer")); TestTimeBasedPanel panel(QStringLiteral("TimeBasedConnectPanel")); - panel.SetTimeBasedWidget(new TimeBasedWidget(false, false, &panel)); - EXPECT_EQ(panel.GetConnectedViewer(), nullptr); + panel.set_time_based_widget(new TimeBasedWidget(false, false, &panel)); + EXPECT_EQ(panel.get_connected_viewer(), nullptr); - panel.ConnectViewerNode(viewer); - EXPECT_EQ(panel.GetConnectedViewer(), viewer); + panel.connect_viewer_node(viewer); + EXPECT_EQ(panel.get_connected_viewer(), viewer); EXPECT_TRUE(panel.title().contains(QStringLiteral("My Viewer"))); // Label changes on the viewer propagate to the panel title - viewer->SetLabel(QStringLiteral("Renamed Viewer")); + viewer->set_label(QStringLiteral("Renamed Viewer")); EXPECT_TRUE(panel.title().contains(QStringLiteral("Renamed Viewer"))); - panel.DisconnectViewerNode(); - EXPECT_EQ(panel.GetConnectedViewer(), nullptr); + panel.disconnect_viewer_node(); + EXPECT_EQ(panel.get_connected_viewer(), nullptr); } TEST_F(PanelTest, NodeTablePanelConstruction) { Project project; - project.Initialize(); - auto *math = AddNode(&project); + project.initialize(); + auto *math = add_node(&project); NodeTablePanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("NodeTablePanel")); EXPECT_EQ(panel.title(), QStringLiteral("Table View")); - ASSERT_NE(panel.GetTimeBasedWidget(), nullptr); + ASSERT_NE(panel.get_time_based_widget(), nullptr); auto *view = panel.findChild(); ASSERT_NE(view, nullptr); @@ -574,12 +574,12 @@ TEST_F(PanelTest, NodeTablePanelConstruction) EXPECT_EQ(view->topLevelItemCount(), 0); // Selecting a node adds a top-level row labeled with the node - panel.SelectNodes({ math }); + panel.select_nodes({ math }); ASSERT_EQ(view->topLevelItemCount(), 1); - EXPECT_EQ(view->topLevelItem(0)->text(0), math->GetLabelAndName()); + EXPECT_EQ(view->topLevelItem(0)->text(0), math->get_label_and_name()); // Deselecting removes it again - panel.DeselectNodes({ math }); + panel.deselect_nodes({ math }); EXPECT_EQ(view->topLevelItemCount(), 0); } @@ -588,8 +588,8 @@ TEST_F(PanelTest, MulticamPanelConstruction) MulticamPanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("MultiCamPanel")); EXPECT_TRUE(panel.title().startsWith(QStringLiteral("Multi-Cam"))); - EXPECT_NE(panel.GetMulticamWidget(), nullptr); - EXPECT_EQ(panel.GetConnectedViewer(), nullptr); + EXPECT_NE(panel.get_multicam_widget(), nullptr); + EXPECT_EQ(panel.get_connected_viewer(), nullptr); } TEST_F(PanelTest, HistoryPanelReflectsUndoStack) @@ -607,86 +607,86 @@ TEST_F(PanelTest, HistoryPanelReflectsUndoStack) TEST_F(PanelTest, FootageViewerPanelConstruction) { Project project; - project.Initialize(); - auto *viewer = AddNode(&project); + project.initialize(); + auto *viewer = add_node(&project); FootageViewerPanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("FootageViewerPanel")); EXPECT_TRUE(panel.title().startsWith(QStringLiteral("Footage Viewer"))); - EXPECT_NE(panel.GetFootageViewerWidget(), nullptr); + EXPECT_NE(panel.get_footage_viewer_widget(), nullptr); // With nothing connected there is no selected footage - EXPECT_TRUE(panel.GetSelectedFootage().isEmpty()); + EXPECT_TRUE(panel.get_selected_footage().isEmpty()); - panel.ConnectViewerNode(viewer); - ASSERT_EQ(panel.GetSelectedFootage().size(), 1); - EXPECT_EQ(panel.GetSelectedFootage().first(), viewer); + panel.connect_viewer_node(viewer); + ASSERT_EQ(panel.get_selected_footage().size(), 1); + EXPECT_EQ(panel.get_selected_footage().first(), viewer); - panel.DisconnectViewerNode(); - EXPECT_TRUE(panel.GetSelectedFootage().isEmpty()); + panel.disconnect_viewer_node(); + EXPECT_TRUE(panel.get_selected_footage().isEmpty()); } TEST_F(PanelTest, NodePanelConstructionAndContexts) { Project project; - project.Initialize(); + project.initialize(); NodePanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("NodePanel")); EXPECT_EQ(panel.title(), QStringLiteral("Node Editor")); - EXPECT_NE(panel.GetNodeWidget(), nullptr); + EXPECT_NE(panel.get_node_widget(), nullptr); - EXPECT_TRUE(panel.GetContexts().isEmpty()); - panel.SetContexts({ project.root() }); - ASSERT_EQ(panel.GetContexts().size(), 1); - EXPECT_EQ(panel.GetContexts().first(), project.root()); + EXPECT_TRUE(panel.get_contexts().isEmpty()); + panel.set_contexts({ project.root() }); + ASSERT_EQ(panel.get_contexts().size(), 1); + EXPECT_EQ(panel.get_contexts().first(), project.root()); // Node selection actions on an empty scene are harmless - panel.SelectAll(); - panel.DeselectAll(); + panel.select_all(); + panel.deselect_all(); } TEST_F(PanelTest, NodePanelForwardsViewSignals) { Project project; - project.Initialize(); - auto *math = AddNode(&project); + project.initialize(); + auto *math = add_node(&project); NodePanel panel; - panel.SetContexts({ project.root() }); + panel.set_contexts({ project.root() }); - QSignalSpy selected_spy(&panel, &NodePanel::NodesSelected); - emit panel.GetNodeWidget()->view()->NodesSelected({ math }); + QSignalSpy selected_spy(&panel, &NodePanel::nodes_selected); + emit panel.get_node_widget()->view()->nodes_selected({ math }); ASSERT_EQ(selected_spy.count(), 1); - QSignalSpy deselected_spy(&panel, &NodePanel::NodesDeselected); - emit panel.GetNodeWidget()->view()->NodesDeselected({ math }); + QSignalSpy deselected_spy(&panel, &NodePanel::nodes_deselected); + emit panel.get_node_widget()->view()->nodes_deselected({ math }); EXPECT_EQ(deselected_spy.count(), 1); - QSignalSpy selection_spy(&panel, &NodePanel::NodeSelectionChanged); - emit panel.GetNodeWidget()->view()->NodeSelectionChanged({ math }); + QSignalSpy selection_spy(&panel, &NodePanel::node_selection_changed); + emit panel.get_node_widget()->view()->node_selection_changed({ math }); EXPECT_EQ(selection_spy.count(), 1); } TEST_F(PanelTest, TimelinePanelConstructionAndSequence) { Project project; - project.Initialize(); - auto *sequence = AddNode(&project); + project.initialize(); + auto *sequence = add_node(&project); TimelinePanel panel(QStringLiteral("TimelinePanelTest")); EXPECT_EQ(panel.objectName(), QStringLiteral("TimelinePanelTest")); EXPECT_NE(panel.timeline_widget(), nullptr); - EXPECT_EQ(panel.GetSequence(), nullptr); + EXPECT_EQ(panel.get_sequence(), nullptr); - panel.ConnectViewerNode(sequence); - EXPECT_EQ(panel.GetConnectedViewer(), sequence); - EXPECT_EQ(panel.GetSequence(), sequence); + panel.connect_viewer_node(sequence); + EXPECT_EQ(panel.get_connected_viewer(), sequence); + EXPECT_EQ(panel.get_sequence(), sequence); // Selection actions on an empty sequence are harmless - panel.SelectAll(); - panel.DeselectAll(); - EXPECT_TRUE(panel.GetSelectedBlocks().isEmpty()); + panel.select_all(); + panel.deselect_all(); + EXPECT_TRUE(panel.get_selected_blocks().isEmpty()); } TEST_F(PanelTest, TimelinePanelSaveLoadDataRoundTrip) @@ -706,7 +706,7 @@ TEST_F(PanelTest, TimelinePanelSaveLoadDataRoundTrip) splitter->setSizes({ 200, 400, 100 }); const QList saved_sizes = splitter->sizes(); - PanelWidget::Info info = panel.SaveData(); + PanelWidget::Info info = panel.save_data(); ASSERT_EQ(info.size(), 1); EXPECT_TRUE(info.count(QStringLiteral("splitter"))); @@ -715,14 +715,14 @@ TEST_F(PanelTest, TimelinePanelSaveLoadDataRoundTrip) ASSERT_NE(splitter->sizes(), saved_sizes); // LoadData must restore the splitter layout captured by SaveData - panel.LoadData(info); + panel.load_data(info); EXPECT_EQ(splitter->sizes(), saved_sizes); - EXPECT_EQ(panel.timeline_widget()->SaveSplitterState(), + EXPECT_EQ(panel.timeline_widget()->save_splitter_state(), QByteArray::fromBase64( info.at(QStringLiteral("splitter")).toUtf8())); // Loading twice is idempotent - panel.LoadData(info); + panel.load_data(info); EXPECT_EQ(splitter->sizes(), saved_sizes); } @@ -736,17 +736,17 @@ TEST_F(PanelTest, ToolPanelReflectsCoreToolState) ASSERT_NE(toolbar, nullptr); // The toolbar drives Core's active tool through the panel's connections - Core::instance()->SetTool(Tool::kPointer); - emit toolbar->ToolChanged(Tool::kHand); - EXPECT_EQ(Core::instance()->tool(), Tool::kHand); + Core::instance()->set_tool(Tool::k_pointer); + emit toolbar->tool_changed(Tool::k_hand); + EXPECT_EQ(Core::instance()->tool(), Tool::k_hand); // ...and snapping state - emit toolbar->SnappingChanged(false); + emit toolbar->snapping_changed(false); EXPECT_FALSE(Core::instance()->snapping()); - emit toolbar->SnappingChanged(true); + emit toolbar->snapping_changed(true); EXPECT_TRUE(Core::instance()->snapping()); - Core::instance()->SetTool(Tool::kPointer); + Core::instance()->set_tool(Tool::k_pointer); } TEST_F(PanelTest, ViewerPanelConstruction) @@ -754,8 +754,8 @@ TEST_F(PanelTest, ViewerPanelConstruction) ViewerPanel panel(QStringLiteral("ViewerPanelTest")); EXPECT_EQ(panel.objectName(), QStringLiteral("ViewerPanelTest")); EXPECT_TRUE(panel.title().startsWith(QStringLiteral("Viewer"))); - EXPECT_NE(panel.GetViewerWidget(), nullptr); - EXPECT_EQ(panel.GetConnectedViewer(), nullptr); + EXPECT_NE(panel.get_viewer_widget(), nullptr); + EXPECT_EQ(panel.get_connected_viewer(), nullptr); } TEST_F(PanelTest, SequenceViewerPanelConstruction) @@ -763,7 +763,7 @@ TEST_F(PanelTest, SequenceViewerPanelConstruction) SequenceViewerPanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("SequenceViewerPanel")); EXPECT_TRUE(panel.title().startsWith(QStringLiteral("Sequence Viewer"))); - EXPECT_NE(panel.GetViewerWidget(), nullptr); + EXPECT_NE(panel.get_viewer_widget(), nullptr); } TEST_F(PanelTest, ViewerPanelConnectTimeBasedPanel) @@ -773,17 +773,17 @@ TEST_F(PanelTest, ViewerPanelConnectTimeBasedPanel) // Routing playback commands from a timebased panel to the viewer must not // crash, even with nothing connected to the viewer - viewer_panel.ConnectTimeBasedPanel(&curve_panel); + viewer_panel.connect_time_based_panel(&curve_panel); - QSignalSpy spy(&curve_panel, &TimeBasedPanel::PlayPauseRequested); - curve_panel.PlayPause(); + QSignalSpy spy(&curve_panel, &TimeBasedPanel::play_pause_requested); + curve_panel.play_pause(); EXPECT_EQ(spy.count(), 1); - curve_panel.ShuttleLeft(); - curve_panel.ShuttleStop(); - curve_panel.ShuttleRight(); + curve_panel.shuttle_left(); + curve_panel.shuttle_stop(); + curve_panel.shuttle_right(); - viewer_panel.DisconnectTimeBasedPanel(&curve_panel); + viewer_panel.disconnect_time_based_panel(&curve_panel); } TEST_F(PanelTest, ScopePanelConstructionAndTypeSwitching) @@ -791,26 +791,26 @@ TEST_F(PanelTest, ScopePanelConstructionAndTypeSwitching) ScopePanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("ScopePanel")); EXPECT_EQ(panel.title(), QStringLiteral("Scopes")); - EXPECT_EQ(panel.GetConnectedViewerPanel(), nullptr); + EXPECT_EQ(panel.get_connected_viewer_panel(), nullptr); // Every scope type has a human readable name - for (int i = 0; i < ScopePanel::kTypeCount; i++) { + for (int i = 0; i < ScopePanel::k_type_count; i++) { EXPECT_FALSE( - ScopePanel::TypeToName(static_cast(i)).isEmpty()); + ScopePanel::type_to_name(static_cast(i)).isEmpty()); } auto *combo = panel.findChild(); auto *stack = panel.findChild(); ASSERT_NE(combo, nullptr); ASSERT_NE(stack, nullptr); - ASSERT_EQ(stack->count(), ScopePanel::kTypeCount); + ASSERT_EQ(stack->count(), ScopePanel::k_type_count); // SetType switches the visible scope through the combo box - panel.SetType(ScopePanel::kTypeHistogram); - EXPECT_EQ(combo->currentIndex(), ScopePanel::kTypeHistogram); + panel.set_type(ScopePanel::k_type_histogram); + EXPECT_EQ(combo->currentIndex(), ScopePanel::k_type_histogram); - panel.SetType(ScopePanel::kTypeVectorscope); - EXPECT_EQ(combo->currentIndex(), ScopePanel::kTypeVectorscope); + panel.set_type(ScopePanel::k_type_vectorscope); + EXPECT_EQ(combo->currentIndex(), ScopePanel::k_type_vectorscope); } TEST_F(PanelTest, ScopePanelViewerConnection) @@ -818,16 +818,16 @@ TEST_F(PanelTest, ScopePanelViewerConnection) ScopePanel scope_panel; ViewerPanel viewer_panel(QStringLiteral("ScopeSourcePanel")); - scope_panel.SetViewerPanel(&viewer_panel); - EXPECT_EQ(scope_panel.GetConnectedViewerPanel(), &viewer_panel); + scope_panel.set_viewer_panel(&viewer_panel); + EXPECT_EQ(scope_panel.get_connected_viewer_panel(), &viewer_panel); // Setting the same panel again is a no-op - scope_panel.SetViewerPanel(&viewer_panel); - EXPECT_EQ(scope_panel.GetConnectedViewerPanel(), &viewer_panel); + scope_panel.set_viewer_panel(&viewer_panel); + EXPECT_EQ(scope_panel.get_connected_viewer_panel(), &viewer_panel); // Disconnecting clears the reference buffer connection - scope_panel.SetViewerPanel(nullptr); - EXPECT_EQ(scope_panel.GetConnectedViewerPanel(), nullptr); + scope_panel.set_viewer_panel(nullptr); + EXPECT_EQ(scope_panel.get_connected_viewer_panel(), nullptr); } TEST_F(PanelTest, AudioMonitorPanelConstruction) @@ -835,8 +835,8 @@ TEST_F(PanelTest, AudioMonitorPanelConstruction) AudioMonitorPanel panel; EXPECT_EQ(panel.objectName(), QStringLiteral("AudioMonitor")); EXPECT_EQ(panel.title(), QStringLiteral("Audio Monitor")); - EXPECT_FALSE(panel.IsPlaying()); + EXPECT_FALSE(panel.is_playing()); - panel.SetParams(core::AudioParams(48000, core::kChannelLayoutStereo, - core::SampleFormat::F32P)); + panel.set_params(core::AudioParams(48000, core::k_channel_layout_stereo, + core::SampleFormat::f32_p)); } diff --git a/tests/gtest/plugin_format_conversion_test.cpp b/tests/gtest/plugin_format_conversion_test.cpp index 5bc45bc52..1db1191c1 100644 --- a/tests/gtest/plugin_format_conversion_test.cpp +++ b/tests/gtest/plugin_format_conversion_test.cpp @@ -17,10 +17,10 @@ using namespace olive; using namespace olive::core; // Test helper to create AVFrame with specific format -static AVFramePtr CreateTestFrame(int width, int height, int fmt, +static AVFramePtr create_test_frame(int width, int height, int fmt, uint32_t fill_color = 0xFF804020) { - AVFramePtr frame = CreateAVFramePtr(); + AVFramePtr frame = create_av_frame_ptr(); frame->set_width(width); frame->set_height(height); frame->set_format(fmt); @@ -39,7 +39,7 @@ static AVFramePtr CreateTestFrame(int width, int height, int fmt, uint8_t b = (fill_color >> 8) & 0xFF; uint8_t a = fill_color & 0xFF; - if (fmt == FB_PIX_FMT_RGBA) { + if (fmt == fb_pix_fmt_rgba) { for (int y = 0; y < height; ++y) { uint8_t *row = frame->data(0) + y * frame->linesize(0); for (int x = 0; x < width; ++x) { @@ -49,7 +49,7 @@ static AVFramePtr CreateTestFrame(int width, int height, int fmt, row[x * 4 + 3] = a; } } - } else if (fmt == FB_PIX_FMT_RGBA64LE) { + } else if (fmt == fb_pix_fmt_rgb_a64_le) { uint16_t r16 = (r << 8) | r; uint16_t g16 = (g << 8) | g; uint16_t b16 = (b << 8) | b; @@ -78,17 +78,17 @@ TEST(FormatConversion, U8ToU16) // Create U8 source frame AVFramePtr u8_frame = - CreateTestFrame(width, height, FB_PIX_FMT_RGBA, test_color); + create_test_frame(width, height, fb_pix_fmt_rgba, test_color); ASSERT_NE(u8_frame, nullptr); // Create U16 destination frame AVFramePtr u16_frame = - CreateTestFrame(width, height, FB_PIX_FMT_RGBA64LE, 0); + create_test_frame(width, height, fb_pix_fmt_rgb_a64_le, 0); ASSERT_NE(u16_frame, nullptr); // Use the bridge scaler to convert - FBScaler *sws_ctx = fb_scaler_create(width, height, FB_PIX_FMT_RGBA, width, - height, FB_PIX_FMT_RGBA64LE, + FBScaler *sws_ctx = fb_scaler_create(width, height, fb_pix_fmt_rgba, width, + height, fb_pix_fmt_rgb_a64_le, FB_SCALER_POINT); ASSERT_NE(sws_ctx, nullptr); @@ -127,16 +127,16 @@ TEST(FormatConversion, FFmpegU16ToU8) // Create U16 frame AVFramePtr u16_frame = - CreateTestFrame(width, height, FB_PIX_FMT_RGBA64LE, test_color); + create_test_frame(width, height, fb_pix_fmt_rgb_a64_le, test_color); ASSERT_NE(u16_frame, nullptr); // Create destination U8 frame - AVFramePtr u8_frame = CreateTestFrame(width, height, FB_PIX_FMT_RGBA, 0); + AVFramePtr u8_frame = create_test_frame(width, height, fb_pix_fmt_rgba, 0); ASSERT_NE(u8_frame, nullptr); // Use the bridge scaler to convert - FBScaler *sws_ctx = fb_scaler_create(width, height, FB_PIX_FMT_RGBA64LE, - width, height, FB_PIX_FMT_RGBA, + FBScaler *sws_ctx = fb_scaler_create(width, height, fb_pix_fmt_rgb_a64_le, + width, height, fb_pix_fmt_rgba, FB_SCALER_POINT); ASSERT_NE(sws_ctx, nullptr); @@ -168,28 +168,28 @@ TEST(FormatConversion, FFmpegU16ToU8) TEST(FormatConversion, VideoParamsToAVFormat) { // U8 RGBA - VideoParams u8_rgba(320, 240, PixelFormat::U8, 4); - int fmt_u8_rgba = FFmpegUtils::GetFFmpegPixelFormat( + VideoParams u8_rgba(320, 240, PixelFormat::u8, 4); + int fmt_u8_rgba = FFmpegUtils::get_f_fmpeg_pixel_format( u8_rgba.format(), u8_rgba.channel_count()); - EXPECT_EQ(fmt_u8_rgba, FB_PIX_FMT_RGBA); + EXPECT_EQ(fmt_u8_rgba, fb_pix_fmt_rgba); // U16 RGBA - VideoParams u16_rgba(320, 240, PixelFormat::U16, 4); - int fmt_u16_rgba = FFmpegUtils::GetFFmpegPixelFormat( + VideoParams u16_rgba(320, 240, PixelFormat::u16, 4); + int fmt_u16_rgba = FFmpegUtils::get_f_fmpeg_pixel_format( u16_rgba.format(), u16_rgba.channel_count()); - EXPECT_EQ(fmt_u16_rgba, FB_PIX_FMT_RGBA64LE); + EXPECT_EQ(fmt_u16_rgba, fb_pix_fmt_rgb_a64_le); // U8 RGB - VideoParams u8_rgb(320, 240, PixelFormat::U8, 3); - int fmt_u8_rgb = FFmpegUtils::GetFFmpegPixelFormat( + VideoParams u8_rgb(320, 240, PixelFormat::u8, 3); + int fmt_u8_rgb = FFmpegUtils::get_f_fmpeg_pixel_format( u8_rgb.format(), u8_rgb.channel_count()); - EXPECT_EQ(fmt_u8_rgb, FB_PIX_FMT_RGB24); + EXPECT_EQ(fmt_u8_rgb, fb_pix_fmt_rg_b24); // U16 RGB - VideoParams u16_rgb(320, 240, PixelFormat::U16, 3); - int fmt_u16_rgb = FFmpegUtils::GetFFmpegPixelFormat( + VideoParams u16_rgb(320, 240, PixelFormat::u16, 3); + int fmt_u16_rgb = FFmpegUtils::get_f_fmpeg_pixel_format( u16_rgb.format(), u16_rgb.channel_count()); - EXPECT_EQ(fmt_u16_rgb, FB_PIX_FMT_RGB48LE); + EXPECT_EQ(fmt_u16_rgb, fb_pix_fmt_rg_b48_le); } // Test row bytes calculation via VideoParams::GetBytesPerPixel @@ -198,16 +198,16 @@ TEST(FormatConversion, RowBytes) const int width = 320; // U8 RGBA: 4 bytes per pixel - EXPECT_EQ(width * VideoParams::GetBytesPerPixel(PixelFormat::U8, 4), 1280); + EXPECT_EQ(width * VideoParams::get_bytes_per_pixel(PixelFormat::u8, 4), 1280); // U16 RGBA: 8 bytes per pixel - EXPECT_EQ(width * VideoParams::GetBytesPerPixel(PixelFormat::U16, 4), 2560); + EXPECT_EQ(width * VideoParams::get_bytes_per_pixel(PixelFormat::u16, 4), 2560); // U8 RGB: 3 bytes per pixel - EXPECT_EQ(width * VideoParams::GetBytesPerPixel(PixelFormat::U8, 3), 960); + EXPECT_EQ(width * VideoParams::get_bytes_per_pixel(PixelFormat::u8, 3), 960); // U16 RGB: 6 bytes per pixel - EXPECT_EQ(width * VideoParams::GetBytesPerPixel(PixelFormat::U16, 3), 1920); + EXPECT_EQ(width * VideoParams::get_bytes_per_pixel(PixelFormat::u16, 3), 1920); } // Test that linesize may differ from width * bpp due to alignment @@ -216,10 +216,10 @@ TEST(FormatConversion, LinesizeAlignment) const int width = 10; const int height = 10; - AVFramePtr frame = CreateAVFramePtr(); + AVFramePtr frame = create_av_frame_ptr(); frame->set_width(width); frame->set_height(height); - frame->set_format(FB_PIX_FMT_RGBA); + frame->set_format(fb_pix_fmt_rgba); ASSERT_EQ(frame->get_buffer(0), 0); @@ -238,16 +238,16 @@ TEST(FormatConversion, LoadImageFile) .filePath(QStringLiteral("tests/img.png")); ASSERT_TRUE(QFileInfo::exists(img_path)); - DecoderPtr decoder = Decoder::CreateFromID(QStringLiteral("oiio")); + DecoderPtr decoder = Decoder::create_from_id(QStringLiteral("oiio")); ASSERT_TRUE(decoder); - ASSERT_TRUE(decoder->Open(Decoder::CodecStream(img_path, 0, nullptr))); + ASSERT_TRUE(decoder->open(Decoder::CodecStream(img_path, 0, nullptr))); Decoder::RetrieveVideoParams params; - params.time = rational(0); + params.time = Rational(0); params.divider = 1; - FramePtr frame = decoder->RetrieveVideoFrame(params); - decoder->Close(); + FramePtr frame = decoder->retrieve_video_frame(params); + decoder->close(); ASSERT_TRUE(frame); ASSERT_TRUE(frame->is_allocated()); @@ -255,7 +255,7 @@ TEST(FormatConversion, LoadImageFile) EXPECT_EQ(frame->height(), 1080); // Still images are decoded to F32 RGBA (channel values scaled by 1/255) - EXPECT_EQ(frame->format(), PixelFormat::F32); + EXPECT_EQ(frame->format(), PixelFormat::f32); EXPECT_EQ(frame->channel_count(), 4); // Spot-check decoded pixels against the known PNG content diff --git a/tests/gtest/plugin_node_test.cpp b/tests/gtest/plugin_node_test.cpp index 89f78d27a..9cda79c79 100644 --- a/tests/gtest/plugin_node_test.cpp +++ b/tests/gtest/plugin_node_test.cpp @@ -32,9 +32,9 @@ #include "ofxhImageEffect.h" #include "ofxhPluginCache.h" -#include "common/Current.h" -#include "node/plugins/Plugin.h" -#include "pluginSupport/OliveHost.h" +#include "common/current.h" +#include "node/plugins/plugin.h" +#include "pluginSupport/olivehost.h" #include "version.h" namespace @@ -43,10 +43,10 @@ namespace // Paths that never exist on disk: the PluginBinary stats the file, marks // itself invalid, and every code path used below tolerates that without ever // calling dlopen(). -constexpr char kFakeBundlePath[] = "/nonexistent/Fake.ofx.bundle"; -constexpr char kFakeBinaryPath[] = +constexpr char k_fake_bundle_path[] = "/nonexistent/Fake.ofx.bundle"; +constexpr char k_fake_binary_path[] = "/nonexistent/Fake.ofx.bundle/Contents/Linux-x86-64/Fake.ofx"; -constexpr char kFakePluginId[] = "com.oak.test.FakePlugin"; +constexpr char k_fake_plugin_id[] = "com.oak.test.FakePlugin"; // Builds an OliveHost, an ImageEffect::PluginCache bound to it (which sets // the global gImageEffectHost), an invalid PluginBinary, and a fake @@ -69,17 +69,17 @@ struct FakePluginHarness { HostGlobalSaver saver; olive::plugin::OliveHost host; OFX::Host::ImageEffect::PluginCache cache{ host }; - OFX::Host::PluginBinary binary{ kFakeBinaryPath, kFakeBundlePath, 0, 0 }; + OFX::Host::PluginBinary binary{ k_fake_binary_path, k_fake_bundle_path, 0, 0 }; OFX::Host::ImageEffect::ImageEffectPlugin plugin{ cache, &binary, 0, kOfxImageEffectPluginApi, 1, - kFakePluginId, - kFakePluginId, + k_fake_plugin_id, + k_fake_plugin_id, 1, 0 }; }; -OfxStatus CallVMessage(olive::plugin::OliveHost &host, const char *type, +OfxStatus call_v_message(olive::plugin::OliveHost &host, const char *type, const char *id, const char *format, ...) { va_list args; @@ -89,7 +89,7 @@ OfxStatus CallVMessage(olive::plugin::OliveHost &host, const char *type, return status; } -OfxStatus CallSetPersistentMessage(olive::plugin::OliveHost &host, +OfxStatus call_set_persistent_message(olive::plugin::OliveHost &host, const char *type, const char *id, const char *format, ...) { @@ -139,14 +139,14 @@ TEST(OliveHost, FakePluginExposesConstructionMetadata) { FakePluginHarness harness; - EXPECT_EQ(harness.plugin.getIdentifier(), kFakePluginId); + EXPECT_EQ(harness.plugin.getIdentifier(), k_fake_plugin_id); EXPECT_EQ(harness.plugin.getVersionMajor(), 1); EXPECT_EQ(harness.plugin.getVersionMinor(), 0); // Construction went through OliveHost::makeDescriptor(plugin), which // stamps the descriptor with the binary's bundle path. EXPECT_EQ(harness.plugin.getDescriptor().getProps().getStringProperty( kOfxPluginPropFilePath), - kFakeBundlePath); + k_fake_bundle_path); } // ============================================================================ @@ -190,7 +190,7 @@ TEST(OliveHost, MakeDescriptorFromRootContextCopiesProperties) "Root Label"); // ... while the file path is stamped from the plugin's own binary. EXPECT_EQ(desc->getProps().getStringProperty(kOfxPluginPropFilePath), - kFakeBundlePath); + k_fake_bundle_path); } // ============================================================================ @@ -200,7 +200,7 @@ TEST(OliveHost, MakeDescriptorFromRootContextCopiesProperties) TEST(OliveHost, DestroyInstanceIgnoresNull) { olive::plugin::OliveHost host; - EXPECT_NO_THROW(host.destroyInstance(nullptr)); + EXPECT_NO_THROW(host.destroy_instance(nullptr)); } // ============================================================================ @@ -215,17 +215,17 @@ TEST(OliveHost, DestroyInstanceIgnoresNull) TEST(OliveHost, VMessageRejectsNullArguments) { olive::plugin::OliveHost host; - EXPECT_EQ(CallVMessage(host, nullptr, "id", "%s", "x"), kOfxStatFailed); - EXPECT_EQ(CallVMessage(host, kOfxMessageError, "id", nullptr), + EXPECT_EQ(call_v_message(host, nullptr, "id", "%s", "x"), kOfxStatFailed); + EXPECT_EQ(call_v_message(host, kOfxMessageError, "id", nullptr), kOfxStatFailed); } TEST(OliveHost, SetPersistentMessageRejectsNullArguments) { olive::plugin::OliveHost host; - EXPECT_EQ(CallSetPersistentMessage(host, nullptr, "id", "%s", "x"), + EXPECT_EQ(call_set_persistent_message(host, nullptr, "id", "%s", "x"), kOfxStatFailed); - EXPECT_EQ(CallSetPersistentMessage(host, kOfxMessageError, "id", nullptr), + EXPECT_EQ(call_set_persistent_message(host, kOfxMessageError, "id", nullptr), kOfxStatFailed); } @@ -234,7 +234,7 @@ TEST(OliveHost, SetPersistentMessageRejectsUnknownType) olive::plugin::OliveHost host; // A type that is neither error, warning, nor message fails before any // dialog would be shown. - EXPECT_EQ(CallSetPersistentMessage(host, "OfxMessageBogus", "id", "%s", + EXPECT_EQ(call_set_persistent_message(host, "OfxMessageBogus", "id", "%s", "hello"), kOfxStatFailed); } @@ -248,14 +248,14 @@ TEST(OliveHost, VMessageOffscreenLogsInsteadOfDialog) olive::plugin::OliveHost host; // No modal dialog is shown on the offscreen platform; the message is // logged to stderr and acknowledged. - EXPECT_EQ(CallVMessage(host, kOfxMessageError, "id", "%s", "boom"), + EXPECT_EQ(call_v_message(host, kOfxMessageError, "id", "%s", "boom"), kOfxStatOK); - EXPECT_EQ(CallVMessage(host, kOfxMessageWarning, "id", "%s", "boom"), + EXPECT_EQ(call_v_message(host, kOfxMessageWarning, "id", "%s", "boom"), kOfxStatOK); - EXPECT_EQ(CallVMessage(host, kOfxMessageMessage, "id", "%s", "boom"), + EXPECT_EQ(call_v_message(host, kOfxMessageMessage, "id", "%s", "boom"), kOfxStatOK); // A question cannot be answered headlessly, so it is a "no". - EXPECT_EQ(CallVMessage(host, kOfxMessageQuestion, "id", "%s", "boom"), + EXPECT_EQ(call_v_message(host, kOfxMessageQuestion, "id", "%s", "boom"), kOfxStatReplyNo); } @@ -266,13 +266,13 @@ TEST(OliveHost, SetPersistentMessageOffscreenSucceeds) } olive::plugin::OliveHost host; - EXPECT_EQ(CallSetPersistentMessage(host, kOfxMessageError, "id", "%s", + EXPECT_EQ(call_set_persistent_message(host, kOfxMessageError, "id", "%s", "boom"), kOfxStatOK); - EXPECT_EQ(CallSetPersistentMessage(host, kOfxMessageWarning, "id", "%s", + EXPECT_EQ(call_set_persistent_message(host, kOfxMessageWarning, "id", "%s", "boom"), kOfxStatOK); - EXPECT_EQ(CallSetPersistentMessage(host, kOfxMessageMessage, "id", "%s", + EXPECT_EQ(call_set_persistent_message(host, kOfxMessageMessage, "id", "%s", "boom"), kOfxStatOK); } @@ -319,10 +319,10 @@ TEST(OliveHost, HostPropertiesIdentifyApplication) EXPECT_EQ(props.getStringProperty(kOfxPropName), "Oak Video Editor"); EXPECT_EQ(props.getStringProperty(kOfxPropLabel), "Oak Video Editor"); EXPECT_EQ(props.getStringProperty(kOfxPropVersionLabel), - olive::kAppVersion.toStdString()); + olive::k_app_version.toStdString()); const QStringList version_parts = - olive::kAppVersion.section(QLatin1Char('-'), 0, 0) + olive::k_app_version.section(QLatin1Char('-'), 0, 0) .split(QLatin1Char('.')); EXPECT_EQ(props.getIntProperty(kOfxPropVersion, 0), version_parts.value(0).toInt()); @@ -348,22 +348,22 @@ TEST(OliveHost, FlushOpenGLResourcesReportsFailure) TEST(OliveHost, LoadPluginsInitializesAndReusesCurrentHost) { - olive::plugin::loadPlugins(QString()); + olive::plugin::load_plugins(QString()); std::shared_ptr host = - Current::getInstance().pluginHost(); + Current::getInstance().plugin_host(); std::shared_ptr cache = - Current::getInstance().pluginCache(); + Current::getInstance().plugin_cache(); ASSERT_NE(host, nullptr); ASSERT_NE(cache, nullptr); // A second call must reuse the already-created host and cache. QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); - olive::plugin::loadPlugins(dir.path()); + olive::plugin::load_plugins(dir.path()); - EXPECT_EQ(Current::getInstance().pluginHost(), host); - EXPECT_EQ(Current::getInstance().pluginCache(), cache); + EXPECT_EQ(Current::getInstance().plugin_host(), host); + EXPECT_EQ(Current::getInstance().plugin_cache(), cache); } TEST(OliveHost, LoadPluginsScansBundleWithoutValidBinary) @@ -382,7 +382,7 @@ TEST(OliveHost, LoadPluginsScansBundleWithoutValidBinary) fake_binary.write("not a shared object"); fake_binary.close(); - EXPECT_NO_THROW(olive::plugin::loadPlugins(dir.path())); + EXPECT_NO_THROW(olive::plugin::load_plugins(dir.path())); EXPECT_NE(OFX::Host::PluginCache::getPluginCache(), nullptr); // The invalid bundle must not have registered any plugin. @@ -402,5 +402,5 @@ TEST(OliveHost, LoadPluginsScansBundleWithoutValidBinary) TEST(PluginNode, TextureInputFallbackIdIsStable) { - EXPECT_EQ(olive::plugin::kTextureInput, QStringLiteral("tex_in")); + EXPECT_EQ(olive::plugin::k_texture_input, QStringLiteral("tex_in")); } diff --git a/tests/gtest/plugin_ofx_integration_test.cpp b/tests/gtest/plugin_ofx_integration_test.cpp index 321f0b54a..434146ea5 100644 --- a/tests/gtest/plugin_ofx_integration_test.cpp +++ b/tests/gtest/plugin_ofx_integration_test.cpp @@ -4,8 +4,8 @@ #include "common/ffmpegutils.h" #include "node/value.h" -#include "pluginSupport/OliveHost.h" -#include "pluginSupport/OlivePluginInstance.h" +#include "pluginSupport/olivehost.h" +#include "pluginSupport/oliveplugininstance.h" #include "render/job/pluginjob.h" #include "render/plugin/pluginrenderer.h" #include "render/texture.h" @@ -14,14 +14,14 @@ namespace { -olive::TexturePtr CreateSolidTexture(const olive::VideoParams ¶ms) +olive::TexturePtr create_solid_texture(const olive::VideoParams ¶ms) { - olive::AVFramePtr frame = olive::CreateAVFramePtr(); - frame->set_format(olive::FFmpegUtils::GetFFmpegPixelFormat( + olive::AVFramePtr frame = olive::create_av_frame_ptr(); + frame->set_format(olive::FFmpegUtils::get_f_fmpeg_pixel_format( params.format(), params.channel_count())); frame->set_width(params.width()); frame->set_height(params.height()); - if (frame->format() == FB_PIX_FMT_NONE) { + if (frame->format() == fb_pix_fmt_none) { return nullptr; } if (frame->get_buffer(0) < 0) { @@ -37,7 +37,7 @@ olive::TexturePtr CreateSolidTexture(const olive::VideoParams ¶ms) } olive::TexturePtr texture = std::make_shared(params); - texture->handleFrame(frame); + texture->handle_frame(frame); return texture; } @@ -66,7 +66,7 @@ TEST(PluginIntegration, ChromaKeyerCreateAndRender) const QChar separator = QDir::listSeparator(); const QStringList paths = raw.split(separator, Qt::SkipEmptyParts); for (const QString &p : paths) { - olive::plugin::loadPlugins(p); + olive::plugin::load_plugins(p); } auto *cache = OFX::Host::PluginCache::getPluginCache(); @@ -101,23 +101,23 @@ TEST(PluginIntegration, ChromaKeyerCreateAndRender) ASSERT_TRUE(olive_instance); // Use U16 format as the ChromaKeyer plugin expects 16-bit input - olive::VideoParams params(320, 240, olive::core::PixelFormat::U16, 4); + olive::VideoParams params(320, 240, olive::core::PixelFormat::u16, 4); olive_instance->setVideoParam(params); - olive::TexturePtr input = CreateSolidTexture(params); + olive::TexturePtr input = create_solid_texture(params); ASSERT_TRUE(input); olive::NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - olive::NodeValue(olive::NodeValue::kTexture, input)); + olive::NodeValue(olive::NodeValue::k_texture, input)); row.insert(QStringLiteral("Bg"), - olive::NodeValue(olive::NodeValue::kTexture, input)); + olive::NodeValue(olive::NodeValue::k_texture, input)); olive::plugin::PluginJob job(instance, nullptr, row); olive::TexturePtr output = std::make_shared(params); olive::plugin::PluginRenderer renderer(nullptr); - renderer.RenderPlugin(input, job, output, params, true, false); + renderer.render_plugin(input, job, output, params, true, false); EXPECT_TRUE(output->frame()); } diff --git a/tests/gtest/plugin_ofx_misc_test.cpp b/tests/gtest/plugin_ofx_misc_test.cpp index d636cfec0..a50e92872 100644 --- a/tests/gtest/plugin_ofx_misc_test.cpp +++ b/tests/gtest/plugin_ofx_misc_test.cpp @@ -16,8 +16,8 @@ #include "common/ffmpegutils.h" #include "node/value.h" -#include "pluginSupport/OliveHost.h" -#include "pluginSupport/OlivePluginInstance.h" +#include "pluginSupport/olivehost.h" +#include "pluginSupport/oliveplugininstance.h" #include "render/job/pluginjob.h" #include "render/plugin/pluginrenderer.h" #include "render/texture.h" @@ -38,14 +38,14 @@ namespace // For U16: fill_value is 0-65535 // For Float: fill_value is 0.0-1.0 mapped to bytes template -TexturePtr CreateSolidTextureT(const VideoParams ¶ms, T fill_value) +TexturePtr create_solid_texture_t(const VideoParams ¶ms, T fill_value) { - AVFramePtr frame = CreateAVFramePtr(); - frame->set_format(FFmpegUtils::GetFFmpegPixelFormat(params.format(), + AVFramePtr frame = create_av_frame_ptr(); + frame->set_format(FFmpegUtils::get_f_fmpeg_pixel_format(params.format(), params.channel_count())); frame->set_width(params.width()); frame->set_height(params.height()); - if (frame->format() == FB_PIX_FMT_NONE) { + if (frame->format() == fb_pix_fmt_none) { return nullptr; } if (frame->get_buffer(0) < 0) { @@ -64,24 +64,24 @@ TexturePtr CreateSolidTextureT(const VideoParams ¶ms, T fill_value) } TexturePtr texture = std::make_shared(params); - texture->handleFrame(frame); + texture->handle_frame(frame); return texture; } -TexturePtr CreateSolidTexture(const VideoParams ¶ms, +TexturePtr create_solid_texture(const VideoParams ¶ms, uint32_t fill_value = 0x7f) { // Choose type based on pixel format switch (params.format()) { - case core::PixelFormat::U8: - return CreateSolidTextureT(params, + case core::PixelFormat::u8: + return create_solid_texture_t(params, static_cast(fill_value)); - case core::PixelFormat::U16: - return CreateSolidTextureT(params, + case core::PixelFormat::u16: + return create_solid_texture_t(params, static_cast(fill_value)); - case core::PixelFormat::F16: - case core::PixelFormat::F32: - return CreateSolidTextureT( + case core::PixelFormat::f16: + case core::PixelFormat::f32: + return create_solid_texture_t( params, static_cast(fill_value) / 255.0f); default: return nullptr; @@ -92,14 +92,14 @@ TexturePtr CreateSolidTexture(const VideoParams ¶ms, // For U8: gradient is 0-255 per byte // For Float: gradient is 0.0-1.0 per component template -TexturePtr CreateGradientTextureT(const VideoParams ¶ms, float scale) +TexturePtr create_gradient_texture_t(const VideoParams ¶ms, float scale) { - AVFramePtr frame = CreateAVFramePtr(); - frame->set_format(FFmpegUtils::GetFFmpegPixelFormat(params.format(), + AVFramePtr frame = create_av_frame_ptr(); + frame->set_format(FFmpegUtils::get_f_fmpeg_pixel_format(params.format(), params.channel_count())); frame->set_width(params.width()); frame->set_height(params.height()); - if (frame->format() == FB_PIX_FMT_NONE) { + if (frame->format() == fb_pix_fmt_none) { return nullptr; } if (frame->get_buffer(0) < 0) { @@ -119,27 +119,27 @@ TexturePtr CreateGradientTextureT(const VideoParams ¶ms, float scale) } TexturePtr texture = std::make_shared(params); - texture->handleFrame(frame); + texture->handle_frame(frame); return texture; } -TexturePtr CreateGradientTexture(const VideoParams ¶ms) +TexturePtr create_gradient_texture(const VideoParams ¶ms) { switch (params.format()) { - case core::PixelFormat::U8: - return CreateGradientTextureT(params, 255.0f); - case core::PixelFormat::U16: - return CreateGradientTextureT(params, 65535.0f); - case core::PixelFormat::F16: - case core::PixelFormat::F32: - return CreateGradientTextureT(params, 1.0f); + case core::PixelFormat::u8: + return create_gradient_texture_t(params, 255.0f); + case core::PixelFormat::u16: + return create_gradient_texture_t(params, 65535.0f); + case core::PixelFormat::f16: + case core::PixelFormat::f32: + return create_gradient_texture_t(params, 1.0f); default: return nullptr; } } // Helper function to find and render a plugin -bool RenderPlugin(const std::string &plugin_id, const VideoParams ¶ms, +bool render_plugin(const std::string &plugin_id, const VideoParams ¶ms, const NodeValueRow &inputs, bool verbose = false) { auto *cache = OFX::Host::PluginCache::getPluginCache(); @@ -199,7 +199,7 @@ bool RenderPlugin(const std::string &plugin_id, const VideoParams ¶ms, TexturePtr output = std::make_shared(params); PluginRenderer renderer(nullptr); - renderer.RenderPlugin(nullptr, job, output, params, true, false); + renderer.render_plugin(nullptr, job, output, params, true, false); bool has_frame = output->frame() != nullptr; if (!has_frame && verbose) { @@ -210,7 +210,7 @@ bool RenderPlugin(const std::string &plugin_id, const VideoParams ¶ms, } // Skip check function -bool ShouldSkipTest() +bool should_skip_test() { const char *itest = std::getenv("OAK_OFX_ITEST"); if (!itest || std::string(itest) != "1") { @@ -228,7 +228,7 @@ bool ShouldSkipTest() const QChar separator = QDir::listSeparator(); const QStringList paths = raw.split(separator, Qt::SkipEmptyParts); for (const QString &p : paths) { - loadPlugins(p); + load_plugins(p); } plugins_loaded = true; } @@ -244,20 +244,20 @@ bool ShouldSkipTest() TEST(PluginMisc, MirrorHorizontal) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } // Mirror plugin typically works with 8-bit - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateGradientTexture(params); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_gradient_texture(params); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.openfx.Mirror", params, row, true); + bool result = render_plugin("net.sf.openfx.Mirror", params, row, true); EXPECT_TRUE(result) << "Mirror plugin should produce output"; } @@ -267,20 +267,20 @@ TEST(PluginMisc, MirrorHorizontal) TEST(PluginMisc, TransformTranslate) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); bool result = - RenderPlugin("net.sf.openfx.TransformPlugin", params, row, true); + render_plugin("net.sf.openfx.TransformPlugin", params, row, true); EXPECT_TRUE(result) << "Transform plugin should produce output"; } @@ -290,39 +290,39 @@ TEST(PluginMisc, TransformTranslate) TEST(PluginMisc, ColorCorrect) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); bool result = - RenderPlugin("net.sf.openfx.ColorCorrectPlugin", params, row, true); + render_plugin("net.sf.openfx.ColorCorrectPlugin", params, row, true); EXPECT_TRUE(result) << "ColorCorrect plugin should produce output"; } TEST(PluginMisc, Saturation) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); bool result = - RenderPlugin("net.sf.openfx.SaturationPlugin", params, row, true); + render_plugin("net.sf.openfx.SaturationPlugin", params, row, true); EXPECT_TRUE(result) << "Saturation plugin should produce output"; } @@ -332,20 +332,20 @@ TEST(PluginMisc, Saturation) TEST(PluginMisc, GaussianBlur) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); // Use CImgBlur from the available plugin list - bool result = RenderPlugin("net.sf.cimg.CImgBlur", params, row, true); + bool result = render_plugin("net.sf.cimg.CImgBlur", params, row, true); EXPECT_TRUE(result) << "GaussianBlur plugin should produce output"; } @@ -355,37 +355,37 @@ TEST(PluginMisc, GaussianBlur) TEST(PluginMisc, Crop) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.openfx.CropPlugin", params, row, true); + bool result = render_plugin("net.sf.openfx.CropPlugin", params, row, true); EXPECT_TRUE(result) << "Crop plugin should produce output"; } TEST(PluginMisc, Grade) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.openfx.GradePlugin", params, row, true); + bool result = render_plugin("net.sf.openfx.GradePlugin", params, row, true); EXPECT_TRUE(result) << "Grade plugin should produce output"; } @@ -395,20 +395,20 @@ TEST(PluginMisc, Grade) TEST(PluginMisc, NonExistentPlugin) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); bool result = - RenderPlugin("net.sf.openfx.NonExistentPlugin", params, row, true); + render_plugin("net.sf.openfx.NonExistentPlugin", params, row, true); EXPECT_FALSE(result) << "Non-existent plugin should fail gracefully"; } @@ -418,55 +418,55 @@ TEST(PluginMisc, NonExistentPlugin) TEST(PluginMisc, CImgSharpen) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.cimg.CImgSharpen", params, row, true); + bool result = render_plugin("net.sf.cimg.CImgSharpen", params, row, true); EXPECT_TRUE(result) << "CImgSharpen plugin should produce output"; } TEST(PluginMisc, CImgDenoise) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.cimg.CImgDenoise", params, row, true); + bool result = render_plugin("net.sf.cimg.CImgDenoise", params, row, true); EXPECT_TRUE(result) << "CImgDenoise plugin should produce output"; } TEST(PluginMisc, CImgBilateral) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.cimg.CImgBilateral", params, row, true); + bool result = render_plugin("net.sf.cimg.CImgBilateral", params, row, true); EXPECT_TRUE(result) << "CImgBilateral plugin should produce output"; } @@ -476,20 +476,20 @@ TEST(PluginMisc, CImgBilateral) TEST(PluginMisc, MergeOver) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); - row.insert(QStringLiteral("Bg"), NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); + row.insert(QStringLiteral("Bg"), NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.openfx.MergePlugin", params, row, true); + bool result = render_plugin("net.sf.openfx.MergePlugin", params, row, true); EXPECT_TRUE(result) << "Merge plugin should produce output"; } @@ -499,19 +499,19 @@ TEST(PluginMisc, MergeOver) TEST(PluginMisc, Keyer) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.openfx.KeyerPlugin", params, row, true); + bool result = render_plugin("net.sf.openfx.KeyerPlugin", params, row, true); EXPECT_TRUE(result) << "Keyer plugin should produce output"; } @@ -521,39 +521,39 @@ TEST(PluginMisc, Keyer) TEST(PluginMisc, CornerPin) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); bool result = - RenderPlugin("net.sf.openfx.CornerPinPlugin", params, row, true); + render_plugin("net.sf.openfx.CornerPinPlugin", params, row, true); EXPECT_TRUE(result) << "CornerPin plugin should produce output"; } TEST(PluginMisc, LensDistortion) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); bool result = - RenderPlugin("net.sf.openfx.LensDistortion", params, row, true); + render_plugin("net.sf.openfx.LensDistortion", params, row, true); EXPECT_TRUE(result) << "LensDistortion plugin should produce output"; } @@ -563,37 +563,37 @@ TEST(PluginMisc, LensDistortion) TEST(PluginMisc, Invert) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.openfx.Invert", params, row, true); + bool result = render_plugin("net.sf.openfx.Invert", params, row, true); EXPECT_TRUE(result) << "Invert plugin should produce output"; } TEST(PluginMisc, Gamma) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr input = CreateSolidTexture(params, 0x80); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr input = create_solid_texture(params, 0x80); ASSERT_NE(input, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, input)); + NodeValue(NodeValue::k_texture, input)); - bool result = RenderPlugin("net.sf.openfx.GammaPlugin", params, row, true); + bool result = render_plugin("net.sf.openfx.GammaPlugin", params, row, true); EXPECT_TRUE(result) << "Gamma plugin should produce output"; } @@ -603,7 +603,7 @@ TEST(PluginMisc, Gamma) TEST(PluginMisc, ListAvailablePlugins) { - if (ShouldSkipTest()) { + if (should_skip_test()) { GTEST_SKIP() << "OFX integration test not enabled"; } @@ -625,23 +625,23 @@ TEST(PluginMisc, ListAvailablePlugins) TEST(PluginMisc, CImgBilateralGuided_MultiInput) { - if (ShouldSkipTest()) + if (should_skip_test()) GTEST_SKIP() << "OFX integration test not enabled"; // CImgBilateralGuided is a multi-input plugin (Source + Guide). // This test verifies that connecting both inputs does not trigger // the frame-rate mismatch exception in setupClipPreferencesArgs. - VideoParams params(320, 240, core::PixelFormat::F32, 4); - TexturePtr source = CreateSolidTexture(params, 0x80); - TexturePtr guide = CreateSolidTexture(params, 0x40); + VideoParams params(320, 240, core::PixelFormat::f32, 4); + TexturePtr source = create_solid_texture(params, 0x80); + TexturePtr guide = create_solid_texture(params, 0x40); ASSERT_NE(source, nullptr); ASSERT_NE(guide, nullptr); NodeValueRow row; row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName), - NodeValue(NodeValue::kTexture, source)); - row.insert(QStringLiteral("Guide"), NodeValue(NodeValue::kTexture, guide)); + NodeValue(NodeValue::k_texture, source)); + row.insert(QStringLiteral("Guide"), NodeValue(NodeValue::k_texture, guide)); bool result = - RenderPlugin("net.sf.cimg.CImgBilateralGuided", params, row, true); + render_plugin("net.sf.cimg.CImgBilateralGuided", params, row, true); EXPECT_TRUE(result) << "CImgBilateralGuided plugin should produce output with both Source and Guide connected"; } diff --git a/tests/gtest/plugin_paraminstance_test.cpp b/tests/gtest/plugin_paraminstance_test.cpp index a847cb4e4..4b9071fcc 100644 --- a/tests/gtest/plugin_paraminstance_test.cpp +++ b/tests/gtest/plugin_paraminstance_test.cpp @@ -8,14 +8,14 @@ #include "ofxhParam.h" #include "common/avframeptr.h" #include "common/ffmpegutils.h" -#include "pluginSupport/OliveClip.h" +#include "pluginSupport/oliveclip.h" #include "pluginSupport/image.h" #include "pluginSupport/paraminstance.h" #include "render/texture.h" namespace { -olive::VideoParams MakeParams(int width, int height, +olive::VideoParams make_params(int width, int height, olive::core::PixelFormat format, int channels, bool premultiplied) { @@ -28,10 +28,10 @@ olive::VideoParams MakeParams(int width, int height, return params; } -olive::AVFramePtr CreateFrame(const olive::VideoParams ¶ms) +olive::AVFramePtr create_frame(const olive::VideoParams ¶ms) { - olive::AVFramePtr frame = olive::CreateAVFramePtr(); - frame->set_format(olive::FFmpegUtils::GetFFmpegPixelFormat( + olive::AVFramePtr frame = olive::create_av_frame_ptr(); + frame->set_format(olive::FFmpegUtils::get_f_fmpeg_pixel_format( params.format(), params.channel_count())); frame->set_width(params.width()); frame->set_height(params.height()); @@ -57,32 +57,32 @@ TEST(PluginParamInstance, CoordinateSystemHelpers) "TestCoordinate"); // A bare descriptor has no coordinate-system property; the OFX property // suite reports an empty string which is treated as canonical. - EXPECT_FALSE(olive::plugin::IsNormalisedCoordinateSystem(descriptor)); + EXPECT_FALSE(olive::plugin::is_normalised_coordinate_system(descriptor)); descriptor.addStandardParamProps(kOfxParamTypeDouble); - EXPECT_FALSE(olive::plugin::IsNormalisedCoordinateSystem(descriptor)); + EXPECT_FALSE(olive::plugin::is_normalised_coordinate_system(descriptor)); descriptor.getProperties().setStringProperty( kOfxParamPropDefaultCoordinateSystem, kOfxParamCoordinatesNormalised); - EXPECT_TRUE(olive::plugin::IsNormalisedCoordinateSystem(descriptor)); + EXPECT_TRUE(olive::plugin::is_normalised_coordinate_system(descriptor)); - EXPECT_DOUBLE_EQ(olive::plugin::ToNormalised(960.0, 1920.0), 0.5); - EXPECT_DOUBLE_EQ(olive::plugin::ToCanonical(0.5, 1920.0), 960.0); + EXPECT_DOUBLE_EQ(olive::plugin::to_normalised(960.0, 1920.0), 0.5); + EXPECT_DOUBLE_EQ(olive::plugin::to_canonical(0.5, 1920.0), 960.0); // A non-positive extent passes the value through unchanged. - EXPECT_DOUBLE_EQ(olive::plugin::ToNormalised(7.5, 0.0), 7.5); - EXPECT_DOUBLE_EQ(olive::plugin::ToCanonical(7.5, 0.0), 7.5); + EXPECT_DOUBLE_EQ(olive::plugin::to_normalised(7.5, 0.0), 7.5); + EXPECT_DOUBLE_EQ(olive::plugin::to_canonical(7.5, 0.0), 7.5); } TEST(PluginParamInstance, ParamChangeLabelContainsParamName) { OFX::Host::Param::Descriptor descriptor(kOfxParamTypeDouble, "Gain"); - EXPECT_EQ(olive::plugin::ParamChangeLabel(descriptor), + EXPECT_EQ(olive::plugin::param_change_label(descriptor), QStringLiteral("Change Gain")); } TEST(PluginParamInstance, SubmitUndoCommandIgnoresNullCommand) { - EXPECT_NO_THROW(olive::plugin::SubmitUndoCommand( + EXPECT_NO_THROW(olive::plugin::submit_undo_command( nullptr, nullptr, QStringLiteral("Ignored"))); } @@ -104,7 +104,7 @@ TEST(PluginParamInstance, IntegerInstanceUsesDescriptorDefault) EXPECT_EQ(time_value, 42); // Rebinding to the same (null) node keeps the cached value. - instance.SetNode(nullptr); + instance.set_node(nullptr); EXPECT_EQ(instance.get(value), kOfxStatOK); EXPECT_EQ(value, 42); } @@ -392,7 +392,7 @@ TEST(PluginParamInstance, PushbuttonGroupAndPageInstancesExposeNames) "TestButton"); olive::plugin::PushbuttonInstance button(nullptr, "TestButton", button_desc); - button.SetNode(nullptr); + button.set_node(nullptr); EXPECT_EQ(button.getName(), "TestButton"); OFX::Host::Param::Descriptor group_desc(kOfxParamTypeGroup, "TestGroup"); @@ -416,18 +416,18 @@ TEST(PluginClipInstance, UnmappedBitDepthFallsBackToParams) const char *expected; }; const Case cases[] = { - { olive::core::PixelFormat::U8, kOfxBitDepthByte }, - { olive::core::PixelFormat::U10, kOfxBitDepthNone }, - { olive::core::PixelFormat::F16, kOfxBitDepthHalf }, - { olive::core::PixelFormat::F32, kOfxBitDepthFloat }, - { olive::core::PixelFormat::INVALID, kOfxBitDepthNone }, + { olive::core::PixelFormat::u8, kOfxBitDepthByte }, + { olive::core::PixelFormat::u10, kOfxBitDepthNone }, + { olive::core::PixelFormat::f16, kOfxBitDepthHalf }, + { olive::core::PixelFormat::f32, kOfxBitDepthFloat }, + { olive::core::PixelFormat::invalid, kOfxBitDepthNone }, }; for (size_t i = 0; i < sizeof(cases) / sizeof(cases[0]); ++i) { SCOPED_TRACE(i); OFX::Host::ImageEffect::ClipDescriptor desc( kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, cases[i].format, 4, false); + make_params(16, 16, cases[i].format, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); EXPECT_EQ(clip.getUnmappedBitDepth(), cases[i].expected); } @@ -437,7 +437,7 @@ TEST(PluginClipInstance, UnmappedBitDepthPrefersPluginChoice) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); clip.setPixelDepth(kOfxBitDepthFloat); @@ -466,8 +466,8 @@ TEST(PluginClipInstance, UnmappedComponentsFallsBackToParams) SCOPED_TRACE(i); OFX::Host::ImageEffect::ClipDescriptor desc( kOfxImageEffectOutputClipName); - olive::VideoParams params = MakeParams( - 16, 16, olive::core::PixelFormat::U8, cases[i].channels, false); + olive::VideoParams params = make_params( + 16, 16, olive::core::PixelFormat::u8, cases[i].channels, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); EXPECT_EQ(clip.getUnmappedComponents(), cases[i].expected); } @@ -477,7 +477,7 @@ TEST(PluginClipInstance, UnmappedComponentsPrefersPluginChoice) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); clip.setComponents(kOfxImageComponentAlpha); @@ -491,7 +491,7 @@ TEST(PluginClipInstance, PremultReflectsPremultipliedParams) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, true); + make_params(16, 16, olive::core::PixelFormat::u8, 4, true); olive::plugin::OliveClipInstance clip(nullptr, desc, params); EXPECT_EQ(clip.getPremult(), kOfxImagePreMultiplied); @@ -501,8 +501,8 @@ TEST(PluginClipInstance, AspectRatioDefaultsToOneForZeroPar) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); - params.set_pixel_aspect_ratio(olive::core::rational(0, 1)); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); + params.set_pixel_aspect_ratio(olive::core::Rational(0, 1)); olive::plugin::OliveClipInstance clip(nullptr, desc, params); EXPECT_DOUBLE_EQ(clip.getAspectRatio(), 1.0); @@ -514,15 +514,15 @@ TEST(PluginClipInstance, FieldOrderNoneAndLower) // PluginSupportClip.PropertyGetters. OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams progressive = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); - progressive.set_interlacing(olive::VideoParams::kInterlaceNone); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); + progressive.set_interlacing(olive::VideoParams::k_interlace_none); olive::plugin::OliveClipInstance progressive_clip(nullptr, desc, progressive); EXPECT_EQ(progressive_clip.getFieldOrder(), kOfxImageFieldNone); olive::VideoParams lower = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); - lower.set_interlacing(olive::VideoParams::kInterlacedBottomFirst); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); + lower.set_interlacing(olive::VideoParams::k_interlaced_bottom_first); olive::plugin::OliveClipInstance lower_clip(nullptr, desc, lower); EXPECT_EQ(lower_clip.getFieldOrder(), kOfxImageFieldLower); } @@ -531,8 +531,8 @@ TEST(PluginClipInstance, RegionOfDefinitionDefaultsToScaledFrame) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(100, 80, olive::core::PixelFormat::U8, 4, false); - params.set_pixel_aspect_ratio(olive::core::rational(2, 1)); + make_params(100, 80, olive::core::PixelFormat::u8, 4, false); + params.set_pixel_aspect_ratio(olive::core::Rational(2, 1)); olive::plugin::OliveClipInstance clip(nullptr, desc, params); OfxRectD rod = clip.getRegionOfDefinition(0.0); @@ -546,7 +546,7 @@ TEST(PluginClipInstance, RegionOfDefinitionPerTimeOverride) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(100, 80, olive::core::PixelFormat::U8, 4, false); + make_params(100, 80, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); OfxRectD custom = { 1.5, 2.5, 51.5, 21.0 }; @@ -573,7 +573,7 @@ TEST(PluginClipInstance, RegionOfDefinitionFallsBackToStoredDefault) // Zero-sized params yield no usable params-derived region, so the stored // default is used. olive::VideoParams empty_params = - MakeParams(0, 0, olive::core::PixelFormat::U8, 4, false); + make_params(0, 0, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance empty_clip(nullptr, desc, empty_params); OfxRectD stored = { 2.0, 4.0, 202.0, 104.0 }; @@ -587,7 +587,7 @@ TEST(PluginClipInstance, RegionOfDefinitionFallsBackToStoredDefault) // A params-derived region still takes precedence over the stored default. olive::VideoParams params = - MakeParams(100, 80, olive::core::PixelFormat::U8, 4, false); + make_params(100, 80, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); clip.setDefaultRegionOfDefinition(stored); @@ -602,7 +602,7 @@ TEST(PluginClipInstance, OutputImageBoundsFollowRegionOfDefinition) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(100, 80, olive::core::PixelFormat::U8, 4, false); + make_params(100, 80, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); OfxRectD custom = { 1.5, 2.5, 51.5, 21.0 }; @@ -620,7 +620,7 @@ TEST(PluginClipInstance, OutputImageCacheIsPerTime) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); OFX::Host::ImageEffect::Image *first = clip.getImage(1.0, nullptr); @@ -634,7 +634,7 @@ TEST(PluginClipInstance, GetOutputImageUsesCache) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); OFX::Host::ImageEffect::Image *created = clip.getOutputImage(1.0); @@ -655,15 +655,15 @@ TEST(PluginClipInstance, InputImageNullForInvalidParams) int channels; }; const Case cases[] = { - { 0, 10, olive::core::PixelFormat::U8, 4 }, - { 10, 0, olive::core::PixelFormat::U8, 4 }, - { 10, 10, olive::core::PixelFormat::INVALID, 4 }, - { 10, 10, olive::core::PixelFormat::U8, 0 }, + { 0, 10, olive::core::PixelFormat::u8, 4 }, + { 10, 0, olive::core::PixelFormat::u8, 4 }, + { 10, 10, olive::core::PixelFormat::invalid, 4 }, + { 10, 10, olive::core::PixelFormat::u8, 0 }, }; for (size_t i = 0; i < sizeof(cases) / sizeof(cases[0]); ++i) { SCOPED_TRACE(i); OFX::Host::ImageEffect::ClipDescriptor desc("Source"); - olive::VideoParams params = MakeParams(cases[i].width, cases[i].height, + olive::VideoParams params = make_params(cases[i].width, cases[i].height, cases[i].format, cases[i].channels, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); @@ -676,7 +676,7 @@ TEST(PluginClipInstance, ConnectedAfterImageBecomesAvailable) OFX::Host::ImageEffect::ClipDescriptor out_desc( kOfxImageEffectOutputClipName); olive::VideoParams out_params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance out_clip(nullptr, out_desc, out_params); EXPECT_FALSE(out_clip.getConnected()); ASSERT_NE(out_clip.getImage(0.0, nullptr), nullptr); @@ -684,7 +684,7 @@ TEST(PluginClipInstance, ConnectedAfterImageBecomesAvailable) OFX::Host::ImageEffect::ClipDescriptor src_desc("Source"); olive::VideoParams src_params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance src_clip(nullptr, src_desc, src_params); EXPECT_FALSE(src_clip.getConnected()); auto texture = std::make_shared(src_params); @@ -696,10 +696,10 @@ TEST(PluginClipInstance, SetInputTextureCopiesPixels) { OFX::Host::ImageEffect::ClipDescriptor desc("Source"); olive::VideoParams params = - MakeParams(4, 2, olive::core::PixelFormat::U8, 4, false); + make_params(4, 2, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); - olive::AVFramePtr frame = CreateFrame(params); + olive::AVFramePtr frame = create_frame(params); ASSERT_NE(frame, nullptr); ASSERT_NE(frame->data(0), nullptr); @@ -712,7 +712,7 @@ TEST(PluginClipInstance, SetInputTextureCopiesPixels) } auto texture = std::make_shared(params); - texture->handleFrame(frame); + texture->handle_frame(frame); clip.setInputTexture(texture, 1.0, true); auto *image = @@ -734,10 +734,10 @@ TEST(PluginClipInstance, SetInputTextureCopiesFloatPixels) { OFX::Host::ImageEffect::ClipDescriptor desc("Source"); olive::VideoParams params = - MakeParams(2, 1, olive::core::PixelFormat::F32, 4, false); + make_params(2, 1, olive::core::PixelFormat::f32, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); - olive::AVFramePtr frame = CreateFrame(params); + olive::AVFramePtr frame = create_frame(params); ASSERT_NE(frame, nullptr); ASSERT_NE(frame->data(0), nullptr); @@ -749,7 +749,7 @@ TEST(PluginClipInstance, SetInputTextureCopiesFloatPixels) } auto texture = std::make_shared(params); - texture->handleFrame(frame); + texture->handle_frame(frame); clip.setInputTexture(texture, 1.0, true); auto *image = @@ -767,10 +767,10 @@ TEST(PluginClipInstance, SetInputTextureScrubsNaNToBlack) { OFX::Host::ImageEffect::ClipDescriptor desc("Source"); olive::VideoParams params = - MakeParams(2, 2, olive::core::PixelFormat::F32, 4, false); + make_params(2, 2, olive::core::PixelFormat::f32, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); - olive::AVFramePtr frame = CreateFrame(params); + olive::AVFramePtr frame = create_frame(params); ASSERT_NE(frame, nullptr); ASSERT_NE(frame->data(0), nullptr); @@ -786,7 +786,7 @@ TEST(PluginClipInstance, SetInputTextureScrubsNaNToBlack) std::numeric_limits::quiet_NaN(); auto texture = std::make_shared(params); - texture->handleFrame(frame); + texture->handle_frame(frame); clip.setInputTexture(texture, 1.0, true); ASSERT_TRUE(clip.getConnected()); @@ -809,15 +809,15 @@ TEST(PluginClipInstance, PruneImagesCacheEvictsOldestInputImages) { OFX::Host::ImageEffect::ClipDescriptor desc("Source"); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); for (int t = 1; - t <= olive::plugin::OliveClipInstance::kMaxInputImageCache + 1; ++t) { + t <= olive::plugin::OliveClipInstance::k_max_input_image_cache + 1; ++t) { auto texture = std::make_shared(params); clip.setInputTexture(texture, static_cast(t), true); } - clip.pruneImagesCache(); + clip.prune_images_cache(); // The oldest entry (time 1) was evicted; its on-demand recreation is // cached again, while later entries remained cached throughout. @@ -839,18 +839,18 @@ TEST(PluginClipInstance, PruneImagesCacheKeepsOutputImages) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); for (int t = 1; - t <= olive::plugin::OliveClipInstance::kMaxInputImageCache + 1; ++t) { + t <= olive::plugin::OliveClipInstance::k_max_input_image_cache + 1; ++t) { clip.getImage(static_cast(t), nullptr); } OFX::Host::ImageEffect::Image *before = clip.getImage(1.0, nullptr); ASSERT_NE(before, nullptr); // Pruning is a no-op for the output clip. - clip.pruneImagesCache(); + clip.prune_images_cache(); EXPECT_EQ(clip.getImage(1.0, nullptr), before); } @@ -859,7 +859,7 @@ TEST(PluginClipInstance, LoadTextureReturnsNullWithoutGpuTexture) { OFX::Host::ImageEffect::ClipDescriptor src_desc("Source"); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance src_clip(nullptr, src_desc, params); // No texture was supplied at all. @@ -883,19 +883,19 @@ TEST(PluginClipInstance, SetParamsUpdatesClipAndPluginPreferences) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(16, 16, olive::core::PixelFormat::U8, 4, false); + make_params(16, 16, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); olive::VideoParams updated = - MakeParams(32, 24, olive::core::PixelFormat::F32, 4, false); - updated.set_frame_rate(olive::core::rational(60, 1)); + make_params(32, 24, olive::core::PixelFormat::f32, 4, false); + updated.set_frame_rate(olive::core::Rational(60, 1)); clip.setParams(updated); EXPECT_DOUBLE_EQ(clip.getFrameRate(), 60.0); EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthFloat); olive::VideoParams preferred = clip.getPluginPreferredParams(); - EXPECT_EQ(preferred.format(), olive::core::PixelFormat::F32); + EXPECT_EQ(preferred.format(), olive::core::PixelFormat::f32); EXPECT_EQ(preferred.channel_count(), 4); } @@ -903,11 +903,11 @@ TEST(PluginClipInstance, PluginPreferredParamsDefaultsToClipParams) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(64, 32, olive::core::PixelFormat::U16, 3, false); + make_params(64, 32, olive::core::PixelFormat::u16, 3, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); olive::VideoParams preferred = clip.getPluginPreferredParams(); - EXPECT_EQ(preferred.format(), olive::core::PixelFormat::U16); + EXPECT_EQ(preferred.format(), olive::core::PixelFormat::u16); EXPECT_EQ(preferred.channel_count(), 3); EXPECT_EQ(preferred.width(), 64); EXPECT_EQ(preferred.height(), 32); @@ -915,7 +915,7 @@ TEST(PluginClipInstance, PluginPreferredParamsDefaultsToClipParams) clip.setPixelDepth(kOfxBitDepthByte); clip.setComponents(kOfxImageComponentRGBA); preferred = clip.getPluginPreferredParams(); - EXPECT_EQ(preferred.format(), olive::core::PixelFormat::U8); + EXPECT_EQ(preferred.format(), olive::core::PixelFormat::u8); EXPECT_EQ(preferred.channel_count(), 4); EXPECT_EQ(preferred.width(), 64); } diff --git a/tests/gtest/plugin_render_pipeline_test.cpp b/tests/gtest/plugin_render_pipeline_test.cpp index 48e917892..629f41a27 100644 --- a/tests/gtest/plugin_render_pipeline_test.cpp +++ b/tests/gtest/plugin_render_pipeline_test.cpp @@ -11,9 +11,9 @@ namespace class PluginJobTraverser : public olive::NodeTraverser { public: - void Resolve(olive::NodeValue &value) + void resolve(olive::NodeValue &value) { - ResolveJobs(value); + resolve_jobs(value); } bool called() const @@ -22,7 +22,7 @@ public: } protected: - olive::TexturePtr ProcessPluginJob(olive::TexturePtr /*texture*/, + olive::TexturePtr process_plugin_job(olive::TexturePtr /*texture*/, olive::TexturePtr destination, const olive::Node * /*node*/) override { @@ -38,18 +38,18 @@ private: TEST(PluginRenderPipeline, PluginJobIsResolved) { - olive::VideoParams params(320, 240, olive::core::PixelFormat::U8, 4); + olive::VideoParams params(320, 240, olive::core::PixelFormat::u8, 4); olive::plugin::PluginJob job(nullptr, nullptr, olive::NodeValueRow()); - olive::TexturePtr job_tex = olive::Texture::Job(params, job); + olive::TexturePtr job_tex = olive::Texture::job(params, job); - olive::NodeValue val(olive::NodeValue::kTexture, job_tex); + olive::NodeValue val(olive::NodeValue::k_texture, job_tex); PluginJobTraverser traverser; - traverser.SetCacheVideoParams(params); - traverser.Resolve(val); + traverser.set_cache_video_params(params); + traverser.resolve(val); EXPECT_TRUE(traverser.called()); - ASSERT_TRUE(val.toTexture()); - EXPECT_NE(val.toTexture().get(), job_tex.get()); + ASSERT_TRUE(val.to_texture()); + EXPECT_NE(val.to_texture().get(), job_tex.get()); } diff --git a/tests/gtest/plugin_renderer_readback_test.cpp b/tests/gtest/plugin_renderer_readback_test.cpp index 959d46f13..c286f29c4 100644 --- a/tests/gtest/plugin_renderer_readback_test.cpp +++ b/tests/gtest/plugin_renderer_readback_test.cpp @@ -4,15 +4,15 @@ TEST(PluginRendererReadback, BytesToPixels) { - olive::VideoParams params(16, 16, olive::core::PixelFormat::U8, 4, - olive::core::rational(1, 1), - olive::VideoParams::kInterlaceNone, 1); + olive::VideoParams params(16, 16, olive::core::PixelFormat::u8, 4, + olive::core::Rational(1, 1), + olive::VideoParams::k_interlace_none, 1); - const int bytes_per_pixel = olive::VideoParams::GetBytesPerPixel( + const int bytes_per_pixel = olive::VideoParams::get_bytes_per_pixel( params.format(), params.channel_count()); ASSERT_EQ(bytes_per_pixel, 4); - EXPECT_EQ(olive::plugin::detail::BytesToPixels(64, params), 16); - EXPECT_EQ(olive::plugin::detail::BytesToPixels(0, params), 0); - EXPECT_EQ(olive::plugin::detail::BytesToPixels(-1, params), 0); + EXPECT_EQ(olive::plugin::detail::bytes_to_pixels(64, params), 16); + EXPECT_EQ(olive::plugin::detail::bytes_to_pixels(0, params), 0); + EXPECT_EQ(olive::plugin::detail::bytes_to_pixels(-1, params), 0); } diff --git a/tests/gtest/plugin_smoke_test.cpp b/tests/gtest/plugin_smoke_test.cpp index 398c796b1..026f97f7a 100644 --- a/tests/gtest/plugin_smoke_test.cpp +++ b/tests/gtest/plugin_smoke_test.cpp @@ -28,9 +28,9 @@ #include "ofxhImageEffect.h" // Plugin support headers -#include "pluginSupport/OliveHost.h" -#include "pluginSupport/OliveClip.h" -#include "pluginSupport/OlivePluginInstance.h" +#include "pluginSupport/olivehost.h" +#include "pluginSupport/oliveclip.h" +#include "pluginSupport/oliveplugininstance.h" #include "pluginSupport/image.h" // Node and render headers @@ -52,7 +52,7 @@ namespace test // Helper Functions // ============================================================================ -static VideoParams MakeVideoParams(int width, int height, +static VideoParams make_video_params(int width, int height, core::PixelFormat format, int channels, bool premultiplied = false) { @@ -62,20 +62,20 @@ static VideoParams MakeVideoParams(int width, int height, params.set_format(format); params.set_channel_count(channels); params.set_premultiplied_alpha(premultiplied); - params.set_pixel_aspect_ratio(core::rational(1, 1)); - params.set_frame_rate(core::rational(30, 1)); + params.set_pixel_aspect_ratio(core::Rational(1, 1)); + params.set_frame_rate(core::Rational(30, 1)); return params; } -static TexturePtr CreateTestTexture(const VideoParams ¶ms, +static TexturePtr create_test_texture(const VideoParams ¶ms, uint8_t fill_value = 0x7f) { - AVFramePtr frame = CreateAVFramePtr(); - frame->set_format(FFmpegUtils::GetFFmpegPixelFormat(params.format(), + AVFramePtr frame = create_av_frame_ptr(); + frame->set_format(FFmpegUtils::get_f_fmpeg_pixel_format(params.format(), params.channel_count())); frame->set_width(params.width()); frame->set_height(params.height()); - if (frame->format() == FB_PIX_FMT_NONE) { + if (frame->format() == fb_pix_fmt_none) { return nullptr; } if (frame->get_buffer(0) < 0) { @@ -91,7 +91,7 @@ static TexturePtr CreateTestTexture(const VideoParams ¶ms, } TexturePtr texture = std::make_shared(params); - texture->handleFrame(frame); + texture->handle_frame(frame); return texture; } @@ -109,14 +109,14 @@ TEST(PluginSmoke, HostSingletonExists) TEST(PluginSmoke, LoadPluginsEmptyPathNoCrash) { // Loading plugins from empty path should not crash - EXPECT_NO_THROW({ loadPlugins(QString()); }); + EXPECT_NO_THROW({ load_plugins(QString()); }); } TEST(PluginSmoke, LoadPluginsNonExistentPathNoCrash) { // Loading plugins from non-existent path should not crash EXPECT_NO_THROW( - { loadPlugins(QStringLiteral("/nonexistent/path/to/plugins")); }); + { load_plugins(QStringLiteral("/nonexistent/path/to/plugins")); }); } // ============================================================================ @@ -128,7 +128,7 @@ TEST(PluginSmokeJob, JobConstruction) NodeValueRow row; PluginJob job(nullptr, nullptr, row); - EXPECT_EQ(job.pluginInstance(), nullptr); + EXPECT_EQ(job.plugin_instance(), nullptr); EXPECT_EQ(job.node(), nullptr); EXPECT_DOUBLE_EQ(job.time_seconds(), 0.0); } @@ -136,7 +136,7 @@ TEST(PluginSmokeJob, JobConstruction) TEST(PluginSmokeJob, JobWithTime) { NodeValueRow row; - core::rational time(5, 1); // 5 seconds + core::Rational time(5, 1); // 5 seconds PluginJob job(nullptr, nullptr, row, time); EXPECT_DOUBLE_EQ(job.time_seconds(), 5.0); @@ -144,17 +144,17 @@ TEST(PluginSmokeJob, JobWithTime) TEST(PluginSmokeJob, JobWithTextureValue) { - VideoParams params(64, 64, core::PixelFormat::U8, 4); - TexturePtr tex = CreateTestTexture(params, 0x80); + VideoParams params(64, 64, core::PixelFormat::u8, 4); + TexturePtr tex = create_test_texture(params, 0x80); ASSERT_NE(tex, nullptr); NodeValueRow row; - row.insert(QStringLiteral("source"), NodeValue(NodeValue::kTexture, tex)); + row.insert(QStringLiteral("source"), NodeValue(NodeValue::k_texture, tex)); PluginJob job(nullptr, nullptr, row); // Job should have the values inserted - EXPECT_FALSE(job.GetValues().isEmpty()); + EXPECT_FALSE(job.get_values().isEmpty()); } // ============================================================================ @@ -174,14 +174,14 @@ TEST(PluginSmokeThread, ConcurrentImageAllocation) for (int i = 0; i < num_allocs_per_thread; ++i) { OFX::Host::ImageEffect::ClipDescriptor desc( kOfxImageEffectOutputClipName); - VideoParams params = MakeVideoParams( - 32 + t, 32 + i, core::PixelFormat::U8, 4, false); + VideoParams params = make_video_params( + 32 + t, 32 + i, core::PixelFormat::u8, 4, false); OliveClipInstance clip(nullptr, desc, params); Image image(clip); OfxRectI bounds = { 0, 0, 32 + t, 32 + i }; OfxRectI rod = bounds; - image.AllocateFromParams(params, bounds, rod, true); + image.allocate_from_params(params, bounds, rod, true); if (image.data() != nullptr && image.width() == 32 + t && image.height() == 32 + i) { diff --git a/tests/gtest/plugin_support_clip_test.cpp b/tests/gtest/plugin_support_clip_test.cpp index 8e077235a..2085105c9 100644 --- a/tests/gtest/plugin_support_clip_test.cpp +++ b/tests/gtest/plugin_support_clip_test.cpp @@ -2,11 +2,11 @@ #include "ofxImageEffect.h" #include "ofxhClip.h" -#include "pluginSupport/OliveClip.h" +#include "pluginSupport/oliveclip.h" namespace { -olive::VideoParams MakeParams(int width, int height, +olive::VideoParams make_params(int width, int height, olive::core::PixelFormat format, int channels, bool premultiplied) { @@ -24,12 +24,12 @@ TEST(PluginSupportClip, PropertyGetters) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(1920, 1080, olive::core::PixelFormat::U16, 3, false); - params.set_pixel_aspect_ratio(olive::core::rational(2, 1)); - params.set_frame_rate(olive::core::rational(30, 1)); + make_params(1920, 1080, olive::core::PixelFormat::u16, 3, false); + params.set_pixel_aspect_ratio(olive::core::Rational(2, 1)); + params.set_frame_rate(olive::core::Rational(30, 1)); params.set_start_time(2); params.set_duration(4); - params.set_interlacing(olive::VideoParams::kInterlacedTopFirst); + params.set_interlacing(olive::VideoParams::k_interlaced_top_first); olive::plugin::OliveClipInstance clip(nullptr, desc, params); @@ -60,7 +60,7 @@ TEST(PluginSupportClip, GetImageClampsBoundsAndCachesOutput) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(100, 80, olive::core::PixelFormat::U8, 4, true); + make_params(100, 80, olive::core::PixelFormat::u8, 4, true); olive::plugin::OliveClipInstance clip(nullptr, desc, params); OfxRectD optional_bounds = { -10.0, -10.0, 200.0, 200.0 }; @@ -79,7 +79,7 @@ TEST(PluginSupportClip, GetImageCachesImageForNonOutput) { OFX::Host::ImageEffect::ClipDescriptor desc("Source"); olive::VideoParams params = - MakeParams(64, 64, olive::core::PixelFormat::U8, 4, false); + make_params(64, 64, olive::core::PixelFormat::u8, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); EXPECT_FALSE(clip.getConnected()); diff --git a/tests/gtest/plugin_support_image_test.cpp b/tests/gtest/plugin_support_image_test.cpp index e8351a1fa..316fa4d61 100644 --- a/tests/gtest/plugin_support_image_test.cpp +++ b/tests/gtest/plugin_support_image_test.cpp @@ -2,12 +2,12 @@ #include "ofxImageEffect.h" #include "ofxhClip.h" -#include "pluginSupport/OliveClip.h" +#include "pluginSupport/oliveclip.h" #include "pluginSupport/image.h" namespace { -olive::VideoParams MakeParams(int width, int height, +olive::VideoParams make_params(int width, int height, olive::core::PixelFormat format, int channels, bool premultiplied) { @@ -25,19 +25,19 @@ TEST(PluginSupportImage, AllocateFromParamsSetsProperties) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(640, 480, olive::core::PixelFormat::U8, 4, true); + make_params(640, 480, olive::core::PixelFormat::u8, 4, true); olive::plugin::OliveClipInstance clip(nullptr, desc, params); olive::plugin::Image image(clip); OfxRectI bounds = { 0, 0, 640, 480 }; OfxRectI rod = bounds; - image.AllocateFromParams(params, bounds, rod, true); + image.allocate_from_params(params, bounds, rod, true); EXPECT_NE(image.data(), nullptr); EXPECT_EQ(image.width(), 640); EXPECT_EQ(image.height(), 480); EXPECT_EQ(image.row_bytes(), 640 * 4); - EXPECT_EQ(image.pixel_format(), olive::core::PixelFormat::U8); + EXPECT_EQ(image.pixel_format(), olive::core::PixelFormat::u8); EXPECT_EQ(image.channel_count(), 4); EXPECT_TRUE(image.premultiplied_alpha()); } @@ -46,21 +46,21 @@ TEST(PluginSupportImage, EnsureAllocatedFromParamsClearsAndResizes) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(64, 32, olive::core::PixelFormat::U8, 3, false); + make_params(64, 32, olive::core::PixelFormat::u8, 3, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); olive::plugin::Image image(clip); OfxRectI bounds = { 0, 0, 64, 32 }; OfxRectI rod = bounds; - image.AllocateFromParams(params, bounds, rod, true); + image.allocate_from_params(params, bounds, rod, true); ASSERT_NE(image.data(), nullptr); image.data()[0] = 0xAB; - image.EnsureAllocatedFromParams(params, bounds, rod, true); + image.ensure_allocated_from_params(params, bounds, rod, true); EXPECT_EQ(image.data()[0], 0); OfxRectI new_bounds = { 0, 0, 16, 16 }; - image.EnsureAllocatedFromParams(params, new_bounds, rod, false); + image.ensure_allocated_from_params(params, new_bounds, rod, false); EXPECT_EQ(image.width(), 16); EXPECT_EQ(image.height(), 16); } @@ -69,7 +69,7 @@ TEST(PluginSupportImage, PropertyFallbacks) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(1, 1, olive::core::PixelFormat::INVALID, 0, false); + make_params(1, 1, olive::core::PixelFormat::invalid, 0, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); olive::plugin::Image image(clip); @@ -83,7 +83,7 @@ TEST(PluginSupportImage, PropertyFallbacks) image.setIntProperty(kOfxImagePropBounds, 42, 2); image.setIntProperty(kOfxImagePropBounds, 70, 3); - EXPECT_EQ(image.pixel_format(), olive::core::PixelFormat::F16); + EXPECT_EQ(image.pixel_format(), olive::core::PixelFormat::f16); EXPECT_EQ(image.channel_count(), 3); EXPECT_TRUE(image.premultiplied_alpha()); EXPECT_EQ(image.width(), 32); @@ -94,13 +94,13 @@ TEST(PluginSupportImage, AllocateSetsOfxProperties) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(8, 6, olive::core::PixelFormat::F16, 4, false); + make_params(8, 6, olive::core::PixelFormat::f16, 4, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); olive::plugin::Image image(clip); OfxRectI bounds = { 2, 3, 10, 9 }; OfxRectI rod = { 0, 0, 12, 12 }; - image.Allocate(8, 6, olive::core::PixelFormat::F16, 4, false, bounds, rod, + image.allocate(8, 6, olive::core::PixelFormat::f16, 4, false, bounds, rod, true); EXPECT_NE(image.data(), nullptr); @@ -132,16 +132,16 @@ TEST(PluginSupportImage, EnsureAllocatedPreservesWithoutClear) { OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName); olive::VideoParams params = - MakeParams(4, 4, olive::core::PixelFormat::U8, 3, false); + make_params(4, 4, olive::core::PixelFormat::u8, 3, false); olive::plugin::OliveClipInstance clip(nullptr, desc, params); olive::plugin::Image image(clip); OfxRectI bounds = { 0, 0, 4, 4 }; OfxRectI rod = bounds; - image.AllocateFromParams(params, bounds, rod, true); + image.allocate_from_params(params, bounds, rod, true); ASSERT_NE(image.data(), nullptr); image.data()[0] = 0x5A; - image.EnsureAllocatedFromParams(params, bounds, rod, false); + image.ensure_allocated_from_params(params, bounds, rod, false); EXPECT_EQ(image.data()[0], 0x5A); } diff --git a/tests/gtest/plugin_support_test.cpp b/tests/gtest/plugin_support_test.cpp index 93517b0a9..25f5670ad 100644 --- a/tests/gtest/plugin_support_test.cpp +++ b/tests/gtest/plugin_support_test.cpp @@ -1,8 +1,8 @@ #include -#include "pluginSupport/OliveHost.h" +#include "pluginSupport/olivehost.h" TEST(PluginSupport, LoadPluginsEmptyPath) { - EXPECT_NO_THROW({ olive::plugin::loadPlugins(QString()); }); + EXPECT_NO_THROW({ olive::plugin::load_plugins(QString()); }); } diff --git a/tests/gtest/preferences_behavior_tab_test.cpp b/tests/gtest/preferences_behavior_tab_test.cpp index 362e2100c..5d3fac6b4 100644 --- a/tests/gtest/preferences_behavior_tab_test.cpp +++ b/tests/gtest/preferences_behavior_tab_test.cpp @@ -12,32 +12,32 @@ using namespace olive; TEST(PreferencesBehaviorTab, TimelineCategoryHasExpectedCheckboxes) { - PreferencesBehaviorTab tab(PreferencesBehaviorTab::kCategoryTimeline); + PreferencesBehaviorTab tab(PreferencesBehaviorTab::k_category_timeline); // 8 timeline behavior options EXPECT_EQ(tab.findChildren().size(), 8); } TEST(PreferencesBehaviorTab, PlaybackCategoryHasExpectedCheckboxes) { - PreferencesBehaviorTab tab(PreferencesBehaviorTab::kCategoryPlayback); + PreferencesBehaviorTab tab(PreferencesBehaviorTab::k_category_playback); EXPECT_EQ(tab.findChildren().size(), 2); } TEST(PreferencesBehaviorTab, ProjectCategoryHasExpectedCheckboxes) { - PreferencesBehaviorTab tab(PreferencesBehaviorTab::kCategoryProject); + PreferencesBehaviorTab tab(PreferencesBehaviorTab::k_category_project); EXPECT_EQ(tab.findChildren().size(), 1); } TEST(PreferencesBehaviorTab, NodesCategoryHasExpectedCheckboxes) { - PreferencesBehaviorTab tab(PreferencesBehaviorTab::kCategoryNodes); + PreferencesBehaviorTab tab(PreferencesBehaviorTab::k_category_nodes); EXPECT_EQ(tab.findChildren().size(), 3); } TEST(PreferencesBehaviorTab, RenderingCategoryHasGraphicsBackendCombobox) { - PreferencesBehaviorTab tab(PreferencesBehaviorTab::kCategoryRendering); + PreferencesBehaviorTab tab(PreferencesBehaviorTab::k_category_rendering); EXPECT_FALSE(tab.findChildren().isEmpty()); EXPECT_FALSE(tab.findChildren().isEmpty()); } @@ -49,16 +49,16 @@ TEST(PreferencesBehaviorTab, BehaviorPrefTrReturnsExactSourceStrings) // text unchanged. Pin the exact strings so accidental edits are caught // (they would silently change the translation keys and the cross-tab // lookups that rely on them). - EXPECT_EQ(PreferencesBehaviorTab::BehaviorPrefTr("Behavior"), + EXPECT_EQ(PreferencesBehaviorTab::behavior_pref_tr("Behavior"), QStringLiteral("Behavior")); - EXPECT_EQ(PreferencesBehaviorTab::BehaviorPrefTr("Enable hover focus"), + EXPECT_EQ(PreferencesBehaviorTab::behavior_pref_tr("Enable hover focus"), QStringLiteral("Enable hover focus")); - EXPECT_EQ(PreferencesBehaviorTab::BehaviorPrefTr("Enable slider ladder"), + EXPECT_EQ(PreferencesBehaviorTab::behavior_pref_tr("Enable slider ladder"), QStringLiteral("Enable slider ladder")); - EXPECT_EQ(PreferencesBehaviorTab::BehaviorPrefTr( + EXPECT_EQ(PreferencesBehaviorTab::behavior_pref_tr( "Scrolling zooms by default"), QStringLiteral("Scrolling zooms by default")); - EXPECT_EQ(PreferencesBehaviorTab::BehaviorPrefTr("Enable audio scrubbing"), + EXPECT_EQ(PreferencesBehaviorTab::behavior_pref_tr("Enable audio scrubbing"), QStringLiteral("Enable audio scrubbing")); } @@ -67,12 +67,12 @@ TEST(PreferencesBehaviorTab, RenderingCategoryContainsDefaultBackend) // Force the config back to the registered default so the selected entry // is deterministic regardless of test order const QVariant saved_backend = - Config::Current()[QStringLiteral("GraphicsBackend")]; - Config::Current()[QStringLiteral("GraphicsBackend")] = + Config::current()[QStringLiteral("GraphicsBackend")]; + Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("opengl"); { - PreferencesBehaviorTab tab(PreferencesBehaviorTab::kCategoryRendering); + PreferencesBehaviorTab tab(PreferencesBehaviorTab::k_category_rendering); QList boxes = tab.findChildren(); ASSERT_FALSE(boxes.isEmpty()); @@ -87,7 +87,7 @@ TEST(PreferencesBehaviorTab, RenderingCategoryContainsDefaultBackend) EXPECT_EQ(backend_box->currentIndex(), opengl_index); } - Config::Current()[QStringLiteral("GraphicsBackend")] = saved_backend; + Config::current()[QStringLiteral("GraphicsBackend")] = saved_backend; } TEST(PreferencesGeneralTab, ContainsHoverFocusOption) @@ -98,7 +98,7 @@ TEST(PreferencesGeneralTab, ContainsHoverFocusOption) bool found = false; foreach (QCheckBox *box, boxes) { if (box->text() == - PreferencesBehaviorTab::BehaviorPrefTr("Enable hover focus")) { + PreferencesBehaviorTab::behavior_pref_tr("Enable hover focus")) { found = true; break; } @@ -108,7 +108,7 @@ TEST(PreferencesGeneralTab, ContainsHoverFocusOption) TEST(PreferencesAudioTab, AudioScrubbingCheckboxUsesBehaviorTranslation) { - AudioManager::CreateInstance(); + AudioManager::create_instance(); { PreferencesAudioTab tab; @@ -116,7 +116,7 @@ TEST(PreferencesAudioTab, AudioScrubbingCheckboxUsesBehaviorTranslation) bool found = false; foreach (QCheckBox *box, boxes) { - if (box->text() == PreferencesBehaviorTab::BehaviorPrefTr( + if (box->text() == PreferencesBehaviorTab::behavior_pref_tr( "Enable audio scrubbing")) { found = true; break; @@ -125,7 +125,7 @@ TEST(PreferencesAudioTab, AudioScrubbingCheckboxUsesBehaviorTranslation) EXPECT_TRUE(found); } - AudioManager::DestroyInstance(); + AudioManager::destroy_instance(); } TEST(PreferencesGeneralTab, IncludesBehaviorOptions) @@ -137,7 +137,7 @@ TEST(PreferencesGeneralTab, IncludesBehaviorOptions) TEST(PreferencesAudioTab, IncludesAudioScrubbingOption) { - AudioManager::CreateInstance(); + AudioManager::create_instance(); { PreferencesAudioTab tab; @@ -154,8 +154,8 @@ TEST(PreferencesAudioTab, IncludesAudioScrubbingOption) // Its initial state mirrors the AudioScrubbing config entry EXPECT_EQ(scrubbing->isChecked(), - Config::Current()[QStringLiteral("AudioScrubbing")].toBool()); + Config::current()[QStringLiteral("AudioScrubbing")].toBool()); } - AudioManager::DestroyInstance(); + AudioManager::destroy_instance(); } diff --git a/tests/gtest/preview_autocacher_test.cpp b/tests/gtest/preview_autocacher_test.cpp index 8447be152..f4c1900c0 100644 --- a/tests/gtest/preview_autocacher_test.cpp +++ b/tests/gtest/preview_autocacher_test.cpp @@ -18,40 +18,40 @@ class PreviewAutoCacherTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); // Use the dummy render backend so PreviewAutoCacher can be exercised // without initializing OpenGL/Vulkan in the unit-test process. - OLIVE_CONFIG("GraphicsBackend") = QStringLiteral("dummy"); + OAK_CONFIG("GraphicsBackend") = QStringLiteral("dummy"); - DiskManager::CreateInstance(); - ConformManager::CreateInstance(); - RenderManager::CreateInstance(); + DiskManager::create_instance(); + ConformManager::create_instance(); + RenderManager::create_instance(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override { - RenderManager::DestroyInstance(); - ConformManager::DestroyInstance(); - DiskManager::DestroyInstance(); + RenderManager::destroy_instance(); + ConformManager::destroy_instance(); + DiskManager::destroy_instance(); } - ViewerOutput *CreateViewer() + ViewerOutput *create_viewer() { auto *viewer = new ViewerOutput(); viewer->setParent(project_.get()); return viewer; } - ViewerOutput *CreateViewerWithValidParams() + ViewerOutput *create_viewer_with_valid_params() { - ViewerOutput *viewer = CreateViewer(); - viewer->SetVideoParams( - VideoParams(64, 64, rational(1, 25), PixelFormat::U8, - VideoParams::kRGBAChannelCount)); + ViewerOutput *viewer = create_viewer(); + viewer->set_video_params( + VideoParams(64, 64, Rational(1, 25), PixelFormat::u8, + VideoParams::k_rgba_channel_count)); return viewer; } @@ -61,7 +61,7 @@ protected: TEST_F(PreviewAutoCacherTest, ConstructionInitializesDefaultState) { PreviewAutoCacher cacher; - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + EXPECT_FALSE(cacher.is_rendering_custom_range()); } // With a project set, a single-frame request is dispatched to the render @@ -70,113 +70,113 @@ TEST_F(PreviewAutoCacherTest, ConstructionInitializesDefaultState) // request cancels the previously queued one. TEST_F(PreviewAutoCacherTest, SetProjectToNullStopsSingleFrameDispatch) { - ViewerOutput *viewer = CreateViewerWithValidParams(); + ViewerOutput *viewer = create_viewer_with_valid_params(); // The single-frame path renders the node connected to the viewer's // texture input, so connect something the copier can duplicate. auto *solid = new SolidGenerator(); solid->setParent(project_.get()); - Node::ConnectEdge(solid, NodeInput(viewer, ViewerOutput::kTextureInput)); + Node::connect_edge(solid, NodeInput(viewer, ViewerOutput::k_texture_input)); PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); - RenderTicketPtr dispatched = cacher.GetSingleFrame(viewer, rational(0)); + RenderTicketPtr dispatched = cacher.get_single_frame(viewer, Rational(0)); ASSERT_NE(dispatched, nullptr); // A dispatched ticket is owned by the render pipeline; the next request // must leave it alone - RenderTicketPtr next = cacher.GetSingleFrame(viewer, rational(1)); + RenderTicketPtr next = cacher.get_single_frame(viewer, Rational(1)); ASSERT_NE(next, nullptr); - EXPECT_EQ(dispatched->GetFinishCount(), 0); - EXPECT_TRUE(dispatched->IsRunning()); + EXPECT_EQ(dispatched->get_finish_count(), 0); + EXPECT_TRUE(dispatched->is_running()); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); // Without a copied graph there is nothing to dispatch to: the request // stays queued and the next request cancels it - RenderTicketPtr queued = cacher.GetSingleFrame(viewer, rational(2)); + RenderTicketPtr queued = cacher.get_single_frame(viewer, Rational(2)); ASSERT_NE(queued, nullptr); - RenderTicketPtr cancelling = cacher.GetSingleFrame(viewer, rational(3)); + RenderTicketPtr cancelling = cacher.get_single_frame(viewer, Rational(3)); ASSERT_NE(cancelling, nullptr); - EXPECT_EQ(queued->GetFinishCount(), 1); - EXPECT_FALSE(queued->HasResult()); + EXPECT_EQ(queued->get_finish_count(), 1); + EXPECT_FALSE(queued->has_result()); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // While renders are paused, forced cache ranges must stay queued; unpausing // must dispatch them. TEST_F(PreviewAutoCacherTest, SetRendersPausedBlocksAndResumesCacheJobs) { - ViewerOutput *viewer = CreateViewerWithValidParams(); + ViewerOutput *viewer = create_viewer_with_valid_params(); PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); - QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::StopCacheProxyTasks); + QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::stop_cache_proxy_tasks); - cacher.SetRendersPaused(true); - cacher.ForceCacheRange(viewer, TimeRange(rational(0), rational(1, 25))); - EXPECT_TRUE(cacher.IsRenderingCustomRange()); + cacher.set_renders_paused(true); + cacher.force_cache_range(viewer, TimeRange(Rational(0), Rational(1, 25))); + EXPECT_TRUE(cacher.is_rendering_custom_range()); EXPECT_EQ(stop_spy.count(), 0); // The dummy backend finishes each ticket without a result, exhausting the // range as soon as it is dispatched - cacher.SetRendersPaused(false); - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + cacher.set_renders_paused(false); + EXPECT_FALSE(cacher.is_rendering_custom_range()); EXPECT_GE(stop_spy.count(), 1); // Deliver the queued RenderTicketWatcher::Finished emissions so the // completed watchers are reaped before teardown. QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // pause_thumbnails_ gates the same pending-video-job dispatch loop, so it is // observable the same way as pause_renders_. TEST_F(PreviewAutoCacherTest, SetThumbnailsPausedBlocksAndResumesCacheJobs) { - ViewerOutput *viewer = CreateViewerWithValidParams(); + ViewerOutput *viewer = create_viewer_with_valid_params(); PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); - QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::StopCacheProxyTasks); + QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::stop_cache_proxy_tasks); - cacher.SetThumbnailsPaused(true); - cacher.ForceCacheRange(viewer, TimeRange(rational(0), rational(1, 25))); - EXPECT_TRUE(cacher.IsRenderingCustomRange()); + cacher.set_thumbnails_paused(true); + cacher.force_cache_range(viewer, TimeRange(Rational(0), Rational(1, 25))); + EXPECT_TRUE(cacher.is_rendering_custom_range()); EXPECT_EQ(stop_spy.count(), 0); - cacher.SetThumbnailsPaused(false); - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + cacher.set_thumbnails_paused(false); + EXPECT_FALSE(cacher.is_rendering_custom_range()); EXPECT_GE(stop_spy.count(), 1); // Deliver the queued RenderTicketWatcher::Finished emissions so the // completed watchers are reaped before teardown. QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // ClearSingleFrameRenders only cancels already-dispatched passthrough renders; // a single-frame ticket that is still queued must be left untouched. TEST_F(PreviewAutoCacherTest, ClearSingleFrameRendersLeavesQueuedTicketPending) { - ViewerOutput *viewer = CreateViewer(); + ViewerOutput *viewer = create_viewer(); PreviewAutoCacher cacher; - RenderTicketPtr ticket = cacher.GetSingleFrame(viewer, rational(0)); + RenderTicketPtr ticket = cacher.get_single_frame(viewer, Rational(0)); ASSERT_NE(ticket, nullptr); - cacher.ClearSingleFrameRenders(); - cacher.ClearSingleFrameRendersThatArentRunning(); + cacher.clear_single_frame_renders(); + cacher.clear_single_frame_renders_that_arent_running(); - EXPECT_TRUE(ticket->IsRunning()); - EXPECT_EQ(ticket->GetFinishCount(), 0); - EXPECT_FALSE(ticket->HasResult()); + EXPECT_TRUE(ticket->is_running()); + EXPECT_EQ(ticket->get_finish_count(), 0); + EXPECT_FALSE(ticket->has_result()); } TEST_F(PreviewAutoCacherTest, GetSingleFrameWithoutProjectReturnsTicket) @@ -185,6 +185,6 @@ TEST_F(PreviewAutoCacherTest, GetSingleFrameWithoutProjectReturnsTicket) viewer->setParent(project_.get()); PreviewAutoCacher cacher; - RenderTicketPtr ticket = cacher.GetSingleFrame(viewer, rational(0)); + RenderTicketPtr ticket = cacher.get_single_frame(viewer, Rational(0)); EXPECT_NE(ticket, nullptr); } diff --git a/tests/gtest/project_factory_test.cpp b/tests/gtest/project_factory_test.cpp index 395426048..94dbcc6bc 100644 --- a/tests/gtest/project_factory_test.cpp +++ b/tests/gtest/project_factory_test.cpp @@ -36,11 +36,11 @@ namespace { -void CollectLeafActions(QMenu *menu, QList *leaves) +void collect_leaf_actions(QMenu *menu, QList *leaves) { for (QAction *action : menu->actions()) { if (action->menu()) { - CollectLeafActions(action->menu(), leaves); + collect_leaf_actions(action->menu(), leaves); } else if (!action->isSeparator()) { leaves->append(action); } @@ -50,13 +50,13 @@ void CollectLeafActions(QMenu *menu, QList *leaves) // Project save/load and cache paths go through the DiskManager singleton, // which itself touches Core -void EnsureAppSingletons() +void ensure_app_singletons() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } @@ -64,12 +64,12 @@ void EnsureAppSingletons() TEST(Project, FilenameNamePrettyAndSignals) { - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); olive::Project project; int name_changes = 0; - QObject::connect(&project, &olive::Project::NameChanged, + QObject::connect(&project, &olive::Project::name_changed, [&name_changes]() { ++name_changes; }); const QString filename = QStringLiteral("/tmp/some/dir/my_edit.ove"); @@ -86,8 +86,8 @@ TEST(Project, FilenameNamePrettyAndSignals) project.set_filename(filename); EXPECT_EQ(name_changes, 2); - project.SetSavedURL(QStringLiteral("/tmp/some/dir")); - EXPECT_EQ(project.GetSavedURL(), QStringLiteral("/tmp/some/dir")); + project.set_saved_url(QStringLiteral("/tmp/some/dir")); + EXPECT_EQ(project.get_saved_url(), QStringLiteral("/tmp/some/dir")); // A filename alone does not mark the project modified EXPECT_FALSE(project.is_modified()); @@ -95,12 +95,12 @@ TEST(Project, FilenameNamePrettyAndSignals) TEST(Project, ModifiedAndAutoRecoverySignals) { - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); olive::Project project; QVector states; - QObject::connect(&project, &olive::Project::ModifiedChanged, + QObject::connect(&project, &olive::Project::modified_changed, [&states](bool e) { states.append(e); }); project.set_modified(true); @@ -124,52 +124,52 @@ TEST(Project, ModifiedAndAutoRecoverySignals) TEST(Project, SettingsEmitSignalsAndColorSideEffects) { - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); olive::Project project; QVector changed_keys; - QObject::connect(&project, &olive::Project::SettingChanged, + QObject::connect(&project, &olive::Project::setting_changed, [&changed_keys](const QString &key, const QString &) { changed_keys.append(key); }); QString reference_space; QObject::connect(project.color_manager(), - &olive::ColorManager::ReferenceSpaceChanged, + &olive::ColorManager::reference_space_changed, [&reference_space](const QString &s) { reference_space = s; }); QString default_input; QObject::connect(project.color_manager(), - &olive::ColorManager::DefaultInputChanged, + &olive::ColorManager::default_input_changed, [&default_input](const QString &s) { default_input = s; }); - project.SetSetting(QStringLiteral("plain"), QStringLiteral("value")); - EXPECT_EQ(project.GetSetting(QStringLiteral("plain")), + project.set_setting(QStringLiteral("plain"), QStringLiteral("value")); + EXPECT_EQ(project.get_setting(QStringLiteral("plain")), QStringLiteral("value")); - project.SetColorReferenceSpace(QStringLiteral("ACES - ACEScg")); - EXPECT_EQ(project.GetColorReferenceSpace(), + project.set_color_reference_space(QStringLiteral("ACES - ACEScg")); + EXPECT_EQ(project.get_color_reference_space(), QStringLiteral("ACES - ACEScg")); EXPECT_EQ(reference_space, QStringLiteral("ACES - ACEScg")); - project.SetDefaultInputColorSpace(QStringLiteral("Linear Rec.709")); - EXPECT_EQ(project.GetDefaultInputColorSpace(), + project.set_default_input_color_space(QStringLiteral("Linear Rec.709")); + EXPECT_EQ(project.get_default_input_color_space(), QStringLiteral("Linear Rec.709")); EXPECT_EQ(default_input, QStringLiteral("Linear Rec.709")); // A nonexistent config filename is stored; the failed OCIO load inside // ColorManager::UpdateConfigFromFilename() is swallowed - project.SetColorConfigFilename(QStringLiteral("/nonexistent/config.ocio")); - EXPECT_EQ(project.GetColorConfigFilename(), + project.set_color_config_filename(QStringLiteral("/nonexistent/config.ocio")); + EXPECT_EQ(project.get_color_config_filename(), QStringLiteral("/nonexistent/config.ocio")); EXPECT_TRUE(changed_keys.contains(QStringLiteral("plain"))); - EXPECT_TRUE(changed_keys.contains(olive::Project::kColorReferenceSpace)); + EXPECT_TRUE(changed_keys.contains(olive::Project::k_color_reference_space)); EXPECT_TRUE( - changed_keys.contains(olive::Project::kDefaultInputColorSpaceKey)); - EXPECT_TRUE(changed_keys.contains(olive::Project::kColorConfigFilename)); + changed_keys.contains(olive::Project::k_default_input_color_space_key)); + EXPECT_TRUE(changed_keys.contains(olive::Project::k_color_config_filename)); } TEST(Project, CachePathModes) @@ -177,13 +177,13 @@ TEST(Project, CachePathModes) const bool created_disk_manager = (olive::DiskManager::instance() == nullptr); if (created_disk_manager) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } const QString default_path = - olive::DiskManager::instance()->GetDefaultCachePath(); + olive::DiskManager::instance()->get_default_cache_path(); - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); @@ -196,48 +196,48 @@ TEST(Project, CachePathModes) project.set_filename(filename); // Default mode always returns the application-wide cache path - project.SetCacheLocationSetting(olive::Project::kCacheUseDefaultLocation); - EXPECT_EQ(project.GetCacheLocationSetting(), - olive::Project::kCacheUseDefaultLocation); + project.set_cache_location_setting(olive::Project::k_cache_use_default_location); + EXPECT_EQ(project.get_cache_location_setting(), + olive::Project::k_cache_use_default_location); EXPECT_EQ(project.cache_path(), default_path); // Alongside mode returns a "cache" directory next to the project file - project.SetCacheLocationSetting( - olive::Project::kCacheStoreAlongsideProject); + project.set_cache_location_setting( + olive::Project::k_cache_store_alongside_project); EXPECT_EQ(project.get_cache_alongside_project_path(), alongside); EXPECT_EQ(project.cache_path(), alongside); // Without a filename there is no alongside location, so it falls back olive::Project unsaved; - unsaved.SetCacheLocationSetting( - olive::Project::kCacheStoreAlongsideProject); + unsaved.set_cache_location_setting( + olive::Project::k_cache_store_alongside_project); EXPECT_TRUE(unsaved.get_cache_alongside_project_path().isEmpty()); EXPECT_EQ(unsaved.cache_path(), default_path); // A non-empty custom path is used verbatim; an empty one falls back to // the default location (this branch used to be inverted) olive::Project custom; - custom.SetCacheLocationSetting(olive::Project::kCacheCustomPath); - custom.SetCustomCachePath(QStringLiteral("/tmp/oak-custom-cache")); - EXPECT_EQ(custom.GetCustomCachePath(), + custom.set_cache_location_setting(olive::Project::k_cache_custom_path); + custom.set_custom_cache_path(QStringLiteral("/tmp/oak-custom-cache")); + EXPECT_EQ(custom.get_custom_cache_path(), QStringLiteral("/tmp/oak-custom-cache")); EXPECT_EQ(custom.cache_path(), QStringLiteral("/tmp/oak-custom-cache")); olive::Project custom_empty; - custom_empty.SetCacheLocationSetting(olive::Project::kCacheCustomPath); + custom_empty.set_cache_location_setting(olive::Project::k_cache_custom_path); EXPECT_EQ(custom_empty.cache_path(), default_path); if (created_disk_manager) { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } } TEST(Project, NodeManagementSignalsAndClear) { - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); olive::Project project; - project.Initialize(); + project.initialize(); // The root folder created by Initialize() is part of the graph ASSERT_EQ(project.nodes().size(), 1); @@ -246,12 +246,12 @@ TEST(Project, NodeManagementSignalsAndClear) int added = 0; int removed = 0; olive::Node *last_added = nullptr; - QObject::connect(&project, &olive::Project::NodeAdded, + QObject::connect(&project, &olive::Project::node_added, [&added, &last_added](olive::Node *n) { ++added; last_added = n; }); - QObject::connect(&project, &olive::Project::NodeRemoved, + QObject::connect(&project, &olive::Project::node_removed, [&removed](olive::Node *) { ++removed; }); auto *math = new olive::MathNode(); @@ -272,7 +272,7 @@ TEST(Project, NodeManagementSignalsAndClear) auto *b = new olive::MathNode(); b->setParent(&project); ASSERT_EQ(project.nodes().size(), 3); - project.Clear(); + project.clear(); EXPECT_TRUE(project.nodes().isEmpty()); // One removal from the earlier delete, plus root + 2 nodes from Clear() EXPECT_EQ(removed, 4); @@ -280,53 +280,53 @@ TEST(Project, NodeManagementSignalsAndClear) TEST(Project, ContextCounting) { - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::MathNode(); node->setParent(&project); auto *folder = new olive::Folder(); folder->setParent(&project); - EXPECT_EQ(project.GetNumberOfContextsNodeIsIn(node), 0); + EXPECT_EQ(project.get_number_of_contexts_node_is_in(node), 0); - EXPECT_TRUE(folder->SetNodePositionInContext( + EXPECT_TRUE(folder->set_node_position_in_context( node, olive::Node::Position(QPointF(1.0, 2.0), true))); - EXPECT_EQ(project.GetNumberOfContextsNodeIsIn(node), 1); - EXPECT_EQ(project.GetNumberOfContextsNodeIsIn(node, true), 1); + EXPECT_EQ(project.get_number_of_contexts_node_is_in(node), 1); + EXPECT_EQ(project.get_number_of_contexts_node_is_in(node, true), 1); // except_itself only excludes the queried node when it acts as its own // context - node->SetNodePositionInContext(node, + node->set_node_position_in_context(node, olive::Node::Position(QPointF(), true)); - EXPECT_EQ(project.GetNumberOfContextsNodeIsIn(node, false), 2); - EXPECT_EQ(project.GetNumberOfContextsNodeIsIn(node, true), 1); + EXPECT_EQ(project.get_number_of_contexts_node_is_in(node, false), 2); + EXPECT_EQ(project.get_number_of_contexts_node_is_in(node, true), 1); } TEST(Project, CopySettingsCopiesEntireMap) { - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); olive::Project from; olive::Project to; - from.SetSetting(QStringLiteral("alpha"), QStringLiteral("1")); - from.SetCustomCachePath(QStringLiteral("/tmp/x")); + from.set_setting(QStringLiteral("alpha"), QStringLiteral("1")); + from.set_custom_cache_path(QStringLiteral("/tmp/x")); - EXPECT_TRUE(to.GetSetting(QStringLiteral("alpha")).isEmpty()); + EXPECT_TRUE(to.get_setting(QStringLiteral("alpha")).isEmpty()); - olive::Project::CopySettings(&from, &to); - EXPECT_EQ(to.GetSetting(QStringLiteral("alpha")), QStringLiteral("1")); - EXPECT_EQ(to.GetCustomCachePath(), QStringLiteral("/tmp/x")); + olive::Project::copy_settings(&from, &to); + EXPECT_EQ(to.get_setting(QStringLiteral("alpha")), QStringLiteral("1")); + EXPECT_EQ(to.get_custom_cache_path(), QStringLiteral("/tmp/x")); } TEST(Project, SaveLoadRoundTripPreservesUuidSettingsAndRoot) { - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); - olive::NodeFactory::Initialize(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); + olive::NodeFactory::initialize(); QTemporaryDir dir; ASSERT_TRUE(dir.isValid()); @@ -338,9 +338,9 @@ TEST(Project, SaveLoadRoundTripPreservesUuidSettingsAndRoot) { olive::Project project; - project.Initialize(); - project.SetUuid(fixed_uuid); - project.SetSetting(QStringLiteral("customkey"), + project.initialize(); + project.set_uuid(fixed_uuid); + project.set_setting(QStringLiteral("customkey"), QStringLiteral("customvalue")); QFile file(path); @@ -348,7 +348,7 @@ TEST(Project, SaveLoadRoundTripPreservesUuidSettingsAndRoot) QXmlStreamWriter writer(&file); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("project")); - project.Save(&writer); + project.save(&writer); writer.writeEndElement(); writer.writeEndDocument(); file.close(); @@ -363,29 +363,29 @@ TEST(Project, SaveLoadRoundTripPreservesUuidSettingsAndRoot) QXmlStreamReader reader(&in); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("project")); - olive::SerializedData data = loaded.Load(&reader); + olive::SerializedData data = loaded.load(&reader); in.close(); - EXPECT_EQ(loaded.GetUuid(), fixed_uuid); - EXPECT_EQ(loaded.GetSetting(QStringLiteral("customkey")), + EXPECT_EQ(loaded.get_uuid(), fixed_uuid); + EXPECT_EQ(loaded.get_setting(QStringLiteral("customkey")), QStringLiteral("customvalue")); // The root folder was re-created as a new instance and the root setting // now points at it ASSERT_NE(loaded.root(), nullptr); EXPECT_TRUE(loaded.nodes().contains(loaded.root())); - EXPECT_EQ(loaded.GetSetting(olive::Project::kRootKey), + EXPECT_EQ(loaded.get_setting(olive::Project::k_root_key), QString::number(reinterpret_cast(loaded.root()))); EXPECT_FALSE(data.node_ptrs.isEmpty()); - olive::NodeFactory::Destroy(); + olive::NodeFactory::destroy(); } TEST(Project, LoadSkipsUnknownAndEmptyNodeIds) { - olive::ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); - olive::NodeFactory::Initialize(); + olive::ColorManager::set_up_default_config(); + ensure_app_singletons(); + olive::NodeFactory::initialize(); const QString xml = QStringLiteral( "" @@ -400,24 +400,24 @@ TEST(Project, LoadSkipsUnknownAndEmptyNodeIds) QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); ASSERT_EQ(reader.name(), QStringLiteral("project")); - project.Load(&reader); + project.load(&reader); // Only the node with a known, non-empty id made it into the graph ASSERT_EQ(project.nodes().size(), 1); EXPECT_EQ(project.nodes().first()->id(), QStringLiteral("org.olivevideoeditor.Olive.math")); - olive::NodeFactory::Destroy(); + olive::NodeFactory::destroy(); } TEST(NodeFactory, CreateFromFactoryIndexReturnsNonNullUniqueIds) { QSet ids; - for (int i = 0; i < int(olive::NodeFactory::kInternalNodeCount); ++i) { + for (int i = 0; i < int(olive::NodeFactory::k_internal_node_count); ++i) { const olive::NodeFactory::InternalID factory_id = static_cast(i); olive::Node *node = - olive::NodeFactory::CreateFromFactoryIndex(factory_id); + olive::NodeFactory::create_from_factory_index(factory_id); ASSERT_NE(node, nullptr) << "factory index" << i << "returned null"; EXPECT_FALSE(node->id().isEmpty()); EXPECT_FALSE(ids.contains(node->id())) @@ -425,114 +425,114 @@ TEST(NodeFactory, CreateFromFactoryIndexReturnsNonNullUniqueIds) ids.insert(node->id()); delete node; } - EXPECT_EQ(ids.size(), int(olive::NodeFactory::kInternalNodeCount)); + EXPECT_EQ(ids.size(), int(olive::NodeFactory::k_internal_node_count)); } TEST(NodeFactory, CreateFromFactoryIndexReturnsExpectedTypes) { std::unique_ptr footage( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kProjectFootage)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_project_footage)); EXPECT_NE(dynamic_cast(footage.get()), nullptr); std::unique_ptr sequence( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kProjectSequence)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_project_sequence)); EXPECT_NE(dynamic_cast(sequence.get()), nullptr); std::unique_ptr folder( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kProjectFolder)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_project_folder)); EXPECT_NE(dynamic_cast(folder.get()), nullptr); std::unique_ptr track( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kTrackOutput)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_track_output)); EXPECT_NE(dynamic_cast(track.get()), nullptr); std::unique_ptr viewer( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kViewerOutput)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_viewer_output)); EXPECT_NE(dynamic_cast(viewer.get()), nullptr); std::unique_ptr solid( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kSolidGenerator)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_solid_generator)); EXPECT_NE(dynamic_cast(solid.get()), nullptr); std::unique_ptr math( - olive::NodeFactory::CreateFromFactoryIndex(olive::NodeFactory::kMath)); + olive::NodeFactory::create_from_factory_index(olive::NodeFactory::k_math)); EXPECT_NE(dynamic_cast(math.get()), nullptr); std::unique_ptr text( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kTextGeneratorV3)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_text_generator_v3)); EXPECT_NE(dynamic_cast(text.get()), nullptr); std::unique_ptr clip( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kClipBlock)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_clip_block)); EXPECT_NE(dynamic_cast(clip.get()), nullptr); std::unique_ptr gap( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kGapBlock)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_gap_block)); EXPECT_NE(dynamic_cast(gap.get()), nullptr); std::unique_ptr group( - olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kGroupNode)); + olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_group_node)); EXPECT_NE(dynamic_cast(group.get()), nullptr); } TEST(NodeFactory, CreateFromFactoryIndexCountReturnsNull) { - EXPECT_EQ(olive::NodeFactory::CreateFromFactoryIndex( - olive::NodeFactory::kInternalNodeCount), + EXPECT_EQ(olive::NodeFactory::create_from_factory_index( + olive::NodeFactory::k_internal_node_count), nullptr); } TEST(NodeFactory, LibraryRoundTripAfterInitialize) { - olive::NodeFactory::Initialize(); + olive::NodeFactory::initialize(); - for (int i = 0; i < int(olive::NodeFactory::kInternalNodeCount); ++i) { + for (int i = 0; i < int(olive::NodeFactory::k_internal_node_count); ++i) { std::unique_ptr probe( - olive::NodeFactory::CreateFromFactoryIndex( + olive::NodeFactory::create_from_factory_index( static_cast(i))); ASSERT_NE(probe, nullptr); // Every internal type must be retrievable from the library by id - EXPECT_EQ(olive::NodeFactory::GetNameFromID(probe->id()), - probe->Name()) + EXPECT_EQ(olive::NodeFactory::get_name_from_id(probe->id()), + probe->name()) << probe->id().toStdString(); std::unique_ptr copy( - olive::NodeFactory::CreateFromID(probe->id())); + olive::NodeFactory::create_from_id(probe->id())); ASSERT_NE(copy, nullptr) << probe->id().toStdString(); EXPECT_EQ(copy->id(), probe->id()); EXPECT_NE(copy.get(), probe.get()); } // Unknown and empty ids fail gracefully - EXPECT_EQ(olive::NodeFactory::CreateFromID( + EXPECT_EQ(olive::NodeFactory::create_from_id( QStringLiteral("org.example.nonexistent")), nullptr); - EXPECT_EQ(olive::NodeFactory::CreateFromID(QString()), nullptr); - EXPECT_TRUE(olive::NodeFactory::GetNameFromID( + EXPECT_EQ(olive::NodeFactory::create_from_id(QString()), nullptr); + EXPECT_TRUE(olive::NodeFactory::get_name_from_id( QStringLiteral("org.example.nonexistent")) .isEmpty()); - EXPECT_TRUE(olive::NodeFactory::GetNameFromID(QString()).isEmpty()); + EXPECT_TRUE(olive::NodeFactory::get_name_from_id(QString()).isEmpty()); - olive::NodeFactory::Destroy(); + olive::NodeFactory::destroy(); } TEST(NodeFactory, CreateMenuWithNoneItem) { - olive::NodeFactory::Initialize(); + olive::NodeFactory::initialize(); std::unique_ptr menu( - olive::NodeFactory::CreateMenu(nullptr, true)); + olive::NodeFactory::create_menu(nullptr, true)); ASSERT_NE(menu, nullptr); ASSERT_FALSE(menu->actions().isEmpty()); @@ -544,7 +544,7 @@ TEST(NodeFactory, CreateMenuWithNoneItem) // Leaf actions carry a library index that maps back to node ids QList leaves; - CollectLeafActions(menu.get(), &leaves); + collect_leaf_actions(menu.get(), &leaves); ASSERT_GT(leaves.size(), 1); int created = 0; @@ -562,35 +562,35 @@ TEST(NodeFactory, CreateMenuWithNoneItem) } EXPECT_GT(created, 0); - olive::NodeFactory::Destroy(); + olive::NodeFactory::destroy(); } TEST(NodeFactory, CreateMenuRestrictedToCategory) { - olive::NodeFactory::Initialize(); + olive::NodeFactory::initialize(); - std::unique_ptr menu(olive::NodeFactory::CreateMenu( - nullptr, false, olive::Node::kCategoryMath)); + std::unique_ptr menu(olive::NodeFactory::create_menu( + nullptr, false, olive::Node::k_category_math)); ASSERT_NE(menu, nullptr); QList leaves; - CollectLeafActions(menu.get(), &leaves); + collect_leaf_actions(menu.get(), &leaves); ASSERT_FALSE(leaves.isEmpty()); for (QAction *leaf : leaves) { std::unique_ptr node( olive::NodeFactory::CreateFromMenuAction(leaf)); ASSERT_NE(node, nullptr); - EXPECT_TRUE(node->Category().contains(olive::Node::kCategoryMath)) + EXPECT_TRUE(node->category().contains(olive::Node::k_category_math)) << node->id().toStdString(); } - olive::NodeFactory::Destroy(); + olive::NodeFactory::destroy(); } TEST(NodeFactory, LegacyDistortIdsResolveToRenamedNodes) { - olive::NodeFactory::Initialize(); + olive::NodeFactory::initialize(); const QList> legacy_ids = { { QStringLiteral("org.oliveeditor.Olive.flip"), @@ -607,16 +607,16 @@ TEST(NodeFactory, LegacyDistortIdsResolveToRenamedNodes) for (const auto &pair : legacy_ids) { std::unique_ptr node( - olive::NodeFactory::CreateFromID(pair.first)); + olive::NodeFactory::create_from_id(pair.first)); ASSERT_NE(node, nullptr) << pair.first.toStdString(); EXPECT_EQ(node->id(), pair.second); // The current id resolves directly as well std::unique_ptr current( - olive::NodeFactory::CreateFromID(pair.second)); + olive::NodeFactory::create_from_id(pair.second)); ASSERT_NE(current, nullptr) << pair.second.toStdString(); EXPECT_EQ(current->id(), pair.second); } - olive::NodeFactory::Destroy(); + olive::NodeFactory::destroy(); } diff --git a/tests/gtest/project_serializer_test.cpp b/tests/gtest/project_serializer_test.cpp index e827afd38..6fd871d41 100644 --- a/tests/gtest/project_serializer_test.cpp +++ b/tests/gtest/project_serializer_test.cpp @@ -16,48 +16,48 @@ TEST(ProjectSerializer, SaveLoadProjectRoundTrip) const bool created_disk_manager = (olive::DiskManager::instance() == nullptr); if (created_disk_manager) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } - olive::ColorManager::SetUpDefaultConfig(); - olive::NodeFactory::Initialize(); - olive::ProjectSerializer::Initialize(); + olive::ColorManager::set_up_default_config(); + olive::NodeFactory::initialize(); + olive::ProjectSerializer::initialize(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::TimeInput(); - node->SetLabel(QStringLiteral("TimeInput")); + node->set_label(QStringLiteral("TimeInput")); node->setParent(&project); olive::ProjectSerializer::SaveData save_data( - olive::ProjectSerializer::kProject, &project, QString()); + olive::ProjectSerializer::k_project, &project, QString()); QByteArray xml; QBuffer buffer(&xml); buffer.open(QIODevice::WriteOnly); QXmlStreamWriter writer(&buffer); olive::ProjectSerializer::Result save_result = - olive::ProjectSerializer::Save(&writer, save_data); - EXPECT_EQ(save_result.code(), olive::ProjectSerializer::kSuccess); + olive::ProjectSerializer::save(&writer, save_data); + EXPECT_EQ(save_result.code(), olive::ProjectSerializer::k_success); buffer.close(); olive::Project loaded_project; QBuffer read_buffer(&xml); read_buffer.open(QIODevice::ReadOnly); QXmlStreamReader reader(&read_buffer); - olive::ProjectSerializer::Result result = olive::ProjectSerializer::Load( - &loaded_project, &reader, olive::ProjectSerializer::kProject); - EXPECT_EQ(result.code(), olive::ProjectSerializer::kSuccess); + olive::ProjectSerializer::Result result = olive::ProjectSerializer::load( + &loaded_project, &reader, olive::ProjectSerializer::k_project); + EXPECT_EQ(result.code(), olive::ProjectSerializer::k_success); EXPECT_FALSE(loaded_project.nodes().isEmpty()); - ASSERT_TRUE(result.GetLoadData().node_ptrs.contains( + ASSERT_TRUE(result.get_load_data().node_ptrs.contains( reinterpret_cast(node))); EXPECT_TRUE( - loaded_project.nodes().contains(result.GetLoadData().node_ptrs.value( + loaded_project.nodes().contains(result.get_load_data().node_ptrs.value( reinterpret_cast(node)))); - olive::ProjectSerializer::Destroy(); + olive::ProjectSerializer::destroy(); if (created_disk_manager) { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } } diff --git a/tests/gtest/proxy_dialog_test.cpp b/tests/gtest/proxy_dialog_test.cpp index da6876bbe..3403e5fe6 100644 --- a/tests/gtest/proxy_dialog_test.cpp +++ b/tests/gtest/proxy_dialog_test.cpp @@ -11,9 +11,9 @@ namespace { -QVariant ProxyDialogConfigValue(const char *key) +QVariant proxy_dialog_config_value(const char *key) { - return olive::Config::Current()[QString::fromUtf8(key)]; + return olive::Config::current()[QString::fromUtf8(key)]; } } // namespace @@ -23,18 +23,18 @@ TEST(ProxyDialog, ConstructsInGlobalModeWithNullParent) olive::ProxyDialog dialog(nullptr); // The global settings editors must reflect the current config values - EXPECT_EQ(dialog.ProxyWidth(), - ProxyDialogConfigValue("ProxyWidth").value()); - EXPECT_EQ(dialog.ProxyHeight(), - ProxyDialogConfigValue("ProxyHeight").value()); - EXPECT_EQ(dialog.ProxyCRF(), - ProxyDialogConfigValue("ProxyCRF").value()); - EXPECT_EQ(dialog.ProxyPreset(), - ProxyDialogConfigValue("ProxyPreset").toString()); - EXPECT_EQ(dialog.ProxyIncludeAudio(), - ProxyDialogConfigValue("ProxyIncludeAudio").toBool()); - EXPECT_EQ(dialog.FFmpegPath(), - ProxyDialogConfigValue("FFmpegPath").toString()); + EXPECT_EQ(dialog.proxy_width(), + proxy_dialog_config_value("ProxyWidth").value()); + EXPECT_EQ(dialog.proxy_height(), + proxy_dialog_config_value("ProxyHeight").value()); + EXPECT_EQ(dialog.proxy_crf(), + proxy_dialog_config_value("ProxyCRF").value()); + EXPECT_EQ(dialog.proxy_preset(), + proxy_dialog_config_value("ProxyPreset").toString()); + EXPECT_EQ(dialog.proxy_include_audio(), + proxy_dialog_config_value("ProxyIncludeAudio").toBool()); + EXPECT_EQ(dialog.f_fmpeg_path(), + proxy_dialog_config_value("FFmpegPath").toString()); } TEST(ProxyDialog, ConstructsWithFootageList) @@ -82,29 +82,29 @@ TEST(ProxyDialog, ConstructsWithFootageList) TEST(ProxyDialog, AcceptSavesGlobalSettingsToConfig) { - const int old_width = ProxyDialogConfigValue("ProxyWidth").value(); + const int old_width = proxy_dialog_config_value("ProxyWidth").value(); const bool old_include_audio = - ProxyDialogConfigValue("ProxyIncludeAudio").toBool(); + proxy_dialog_config_value("ProxyIncludeAudio").toBool(); const QString old_ffmpeg_path = - ProxyDialogConfigValue("FFmpegPath").toString(); + proxy_dialog_config_value("FFmpegPath").toString(); { olive::ProxyDialog dialog(nullptr); - dialog.SetProxyWidth(640); - dialog.SetProxyIncludeAudio(!old_include_audio); - dialog.SetFFmpegPath(QStringLiteral("/tmp/oak-test-ffmpeg")); + dialog.set_proxy_width(640); + dialog.set_proxy_include_audio(!old_include_audio); + dialog.set_f_fmpeg_path(QStringLiteral("/tmp/oak-test-ffmpeg")); dialog.accept(); } - EXPECT_EQ(ProxyDialogConfigValue("ProxyWidth").value(), 640); - EXPECT_EQ(ProxyDialogConfigValue("ProxyIncludeAudio").toBool(), + EXPECT_EQ(proxy_dialog_config_value("ProxyWidth").value(), 640); + EXPECT_EQ(proxy_dialog_config_value("ProxyIncludeAudio").toBool(), !old_include_audio); - EXPECT_EQ(ProxyDialogConfigValue("FFmpegPath").toString(), + EXPECT_EQ(proxy_dialog_config_value("FFmpegPath").toString(), QStringLiteral("/tmp/oak-test-ffmpeg")); // Restore previous config values so other tests are unaffected - olive::Config::Current()[QStringLiteral("ProxyWidth")] = old_width; - olive::Config::Current()[QStringLiteral("ProxyIncludeAudio")] = + olive::Config::current()[QStringLiteral("ProxyWidth")] = old_width; + olive::Config::current()[QStringLiteral("ProxyIncludeAudio")] = old_include_audio; - olive::Config::Current()[QStringLiteral("FFmpegPath")] = old_ffmpeg_path; + olive::Config::current()[QStringLiteral("FFmpegPath")] = old_ffmpeg_path; } diff --git a/tests/gtest/proxy_manager_test.cpp b/tests/gtest/proxy_manager_test.cpp index cedd6806c..35b742c2a 100644 --- a/tests/gtest/proxy_manager_test.cpp +++ b/tests/gtest/proxy_manager_test.cpp @@ -20,9 +20,9 @@ namespace { -QVariant ProxyConfigValue(const char *key) +QVariant proxy_config_value(const char *key) { - return olive::Config::Current()[QString::fromUtf8(key)]; + return olive::Config::current()[QString::fromUtf8(key)]; } } // namespace @@ -34,13 +34,13 @@ TEST(ProxyManager, BuildsStableProxyFilename) params.height = 720; params.version = 1; - const QString first = olive::ProxyManager::GetProxyFilename( + const QString first = olive::ProxyManager::get_proxy_filename( QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"), 0, params); - const QString second = olive::ProxyManager::GetProxyFilename( + const QString second = olive::ProxyManager::get_proxy_filename( QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"), 0, params); - const QString other_stream = olive::ProxyManager::GetProxyFilename( + const QString other_stream = olive::ProxyManager::get_proxy_filename( QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"), 1, params); @@ -64,10 +64,10 @@ TEST(ProxyManager, ProxyFilenameIncludesPresetParameters) mov_540p.version = 2; mov_540p.extension = QStringLiteral("mov"); - const QString first = olive::ProxyManager::GetProxyFilename( + const QString first = olive::ProxyManager::get_proxy_filename( QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"), 0, mp4_720p); - const QString second = olive::ProxyManager::GetProxyFilename( + const QString second = olive::ProxyManager::get_proxy_filename( QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"), 0, mov_540p); @@ -84,20 +84,20 @@ TEST(ProxyManager, DetectsProxyState) const QString proxy = QDir(dir.path()).filePath(QStringLiteral("proxy-file.mp4")); - EXPECT_EQ(olive::ProxyManager::GetProxyState(proxy), - olive::ProxyManager::kProxyMissing); + EXPECT_EQ(olive::ProxyManager::get_proxy_state(proxy), + olive::ProxyManager::k_proxy_missing); - QFile working(olive::ProxyManager::GetWorkingProxyFilename(proxy)); + QFile working(olive::ProxyManager::get_working_proxy_filename(proxy)); ASSERT_TRUE(working.open(QFile::WriteOnly)); working.close(); - EXPECT_EQ(olive::ProxyManager::GetProxyState(proxy), - olive::ProxyManager::kProxyGenerating); + EXPECT_EQ(olive::ProxyManager::get_proxy_state(proxy), + olive::ProxyManager::k_proxy_generating); QFile ready(proxy); ASSERT_TRUE(ready.open(QFile::WriteOnly)); ready.close(); - EXPECT_EQ(olive::ProxyManager::GetProxyState(proxy), - olive::ProxyManager::kProxyReady); + EXPECT_EQ(olive::ProxyManager::get_proxy_state(proxy), + olive::ProxyManager::k_proxy_ready); } TEST(ProxyManager, ReadyStateTakesPrecedenceOverWorkingFile) @@ -111,44 +111,44 @@ TEST(ProxyManager, ReadyStateTakesPrecedenceOverWorkingFile) ASSERT_TRUE(ready.open(QFile::WriteOnly)); ready.close(); - QFile working(olive::ProxyManager::GetWorkingProxyFilename(proxy)); + QFile working(olive::ProxyManager::get_working_proxy_filename(proxy)); ASSERT_TRUE(working.open(QFile::WriteOnly)); working.close(); - EXPECT_EQ(olive::ProxyManager::GetProxyState(proxy), - olive::ProxyManager::kProxyReady); + EXPECT_EQ(olive::ProxyManager::get_proxy_state(proxy), + olive::ProxyManager::k_proxy_ready); } TEST(ProxyManager, ConvertsProxyStateToAndFromStrings) { - EXPECT_EQ(olive::ProxyManager::ProxyStateToString( - olive::ProxyManager::kProxyMissing), + EXPECT_EQ(olive::ProxyManager::proxy_state_to_string( + olive::ProxyManager::k_proxy_missing), QStringLiteral("missing")); - EXPECT_EQ(olive::ProxyManager::ProxyStateToString( - olive::ProxyManager::kProxyGenerating), + EXPECT_EQ(olive::ProxyManager::proxy_state_to_string( + olive::ProxyManager::k_proxy_generating), QStringLiteral("generating")); - EXPECT_EQ(olive::ProxyManager::ProxyStateToString( - olive::ProxyManager::kProxyReady), + EXPECT_EQ(olive::ProxyManager::proxy_state_to_string( + olive::ProxyManager::k_proxy_ready), QStringLiteral("ready")); - EXPECT_EQ(olive::ProxyManager::ProxyStateToString( - olive::ProxyManager::kProxyFailed), + EXPECT_EQ(olive::ProxyManager::proxy_state_to_string( + olive::ProxyManager::k_proxy_failed), QStringLiteral("failed")); EXPECT_EQ( - olive::ProxyManager::ProxyStateFromString(QStringLiteral("missing")), - olive::ProxyManager::kProxyMissing); + olive::ProxyManager::proxy_state_from_string(QStringLiteral("missing")), + olive::ProxyManager::k_proxy_missing); EXPECT_EQ( - olive::ProxyManager::ProxyStateFromString(QStringLiteral("generating")), - olive::ProxyManager::kProxyGenerating); + olive::ProxyManager::proxy_state_from_string(QStringLiteral("generating")), + olive::ProxyManager::k_proxy_generating); EXPECT_EQ( - olive::ProxyManager::ProxyStateFromString(QStringLiteral("ready")), - olive::ProxyManager::kProxyReady); + olive::ProxyManager::proxy_state_from_string(QStringLiteral("ready")), + olive::ProxyManager::k_proxy_ready); EXPECT_EQ( - olive::ProxyManager::ProxyStateFromString(QStringLiteral("failed")), - olive::ProxyManager::kProxyFailed); + olive::ProxyManager::proxy_state_from_string(QStringLiteral("failed")), + olive::ProxyManager::k_proxy_failed); EXPECT_EQ( - olive::ProxyManager::ProxyStateFromString(QStringLiteral("unknown")), - olive::ProxyManager::kProxyMissing); + olive::ProxyManager::proxy_state_from_string(QStringLiteral("unknown")), + olive::ProxyManager::k_proxy_missing); } TEST(ProxyManager, FootagePersistsProxyMetadata) @@ -173,10 +173,10 @@ TEST(ProxyManager, FootagePersistsProxyMetadata) ASSERT_EQ(reader.name(), QStringLiteral("custom")); olive::Footage footage; - ASSERT_TRUE(footage.LoadCustom(&reader, nullptr)); + ASSERT_TRUE(footage.load_custom(&reader, nullptr)); EXPECT_TRUE(footage.proxy_enabled()); EXPECT_EQ(footage.proxy_path(), QStringLiteral("/cache/proxy/example.mp4")); - EXPECT_EQ(footage.proxy_state(), olive::ProxyManager::kProxyReady); + EXPECT_EQ(footage.proxy_state(), olive::ProxyManager::k_proxy_ready); EXPECT_EQ(footage.proxy_video_stream_index(), 0); EXPECT_EQ(footage.proxy_preset_version(), 1); } @@ -185,14 +185,14 @@ TEST(ProxyManager, FootageSavesProxyMetadata) { olive::Footage footage; footage.set_timestamp(42); - footage.SetProxy(QStringLiteral("/cache/proxy/example.mp4"), - olive::ProxyManager::kProxyReady, 2, 3, true); + footage.set_proxy(QStringLiteral("/cache/proxy/example.mp4"), + olive::ProxyManager::k_proxy_ready, 2, 3, true); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("custom")); - footage.SaveCustom(&writer); + footage.save_custom(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -207,14 +207,14 @@ TEST(ProxyManager, FootageSavesProxyMetadata) TEST(ProxyManager, FootageClearRemovesProxyMetadata) { olive::Footage footage; - footage.SetProxy(QStringLiteral("/cache/proxy/example.mp4"), - olive::ProxyManager::kProxyReady, 0, 1, true); + footage.set_proxy(QStringLiteral("/cache/proxy/example.mp4"), + olive::ProxyManager::k_proxy_ready, 0, 1, true); - footage.Clear(); + footage.clear(); EXPECT_FALSE(footage.proxy_enabled()); EXPECT_TRUE(footage.proxy_path().isEmpty()); - EXPECT_EQ(footage.proxy_state(), olive::ProxyManager::kProxyMissing); + EXPECT_EQ(footage.proxy_state(), olive::ProxyManager::k_proxy_missing); EXPECT_EQ(footage.proxy_video_stream_index(), -1); EXPECT_EQ(footage.proxy_preset_version(), 0); } @@ -223,8 +223,8 @@ TEST(ProxyManager, EmitsProxyFinishedState) { // Drives a real proxy job through ProxyManager so that ProxyFinished is // emitted by the manager's own task completion path - const QString ffmpeg = olive::ProxyManager::FindFFmpegExecutable( - ProxyConfigValue("FFmpegPath").toString()); + const QString ffmpeg = olive::ProxyManager::find_f_fmpeg_executable( + proxy_config_value("FFmpegPath").toString()); if (ffmpeg.isEmpty()) { GTEST_SKIP() << "ffmpeg executable not available"; } @@ -237,9 +237,9 @@ TEST(ProxyManager, EmitsProxyFinishedState) const bool created_task_manager = (olive::TaskManager::instance() == nullptr); if (created_task_manager) { - olive::TaskManager::CreateInstance(); + olive::TaskManager::create_instance(); } - olive::ProxyManager::CreateInstance(); + olive::ProxyManager::create_instance(); QTemporaryDir cache; ASSERT_TRUE(cache.isValid()); @@ -251,7 +251,7 @@ TEST(ProxyManager, EmitsProxyFinishedState) params.preset = QStringLiteral("ultrafast"); params.include_audio = true; - const QString expected_proxy = olive::ProxyManager::GetProxyFilename( + const QString expected_proxy = olive::ProxyManager::get_proxy_filename( cache.path(), source, 0, params); bool received = false; @@ -259,11 +259,11 @@ TEST(ProxyManager, EmitsProxyFinishedState) int received_stream = -1; QString received_proxy; olive::ProxyManager::ProxyState received_state = - olive::ProxyManager::kProxyMissing; + olive::ProxyManager::k_proxy_missing; bool ready_received = false; QEventLoop loop; QObject::connect( - olive::ProxyManager::instance(), &olive::ProxyManager::ProxyFinished, + olive::ProxyManager::instance(), &olive::ProxyManager::proxy_finished, &loop, [&received, &received_source, &received_stream, &received_proxy, &received_state, &loop](const QString &source_filename, @@ -277,7 +277,7 @@ TEST(ProxyManager, EmitsProxyFinishedState) loop.quit(); }); QObject::connect(olive::ProxyManager::instance(), - &olive::ProxyManager::ProxyReady, &loop, + &olive::ProxyManager::proxy_ready, &loop, [&ready_received](const QString &, int, const QString &) { ready_received = true; }); @@ -285,9 +285,9 @@ TEST(ProxyManager, EmitsProxyFinishedState) QTimer::singleShot(120000, &loop, &QEventLoop::quit); const olive::ProxyManager::Proxy proxy = - olive::ProxyManager::instance()->GetOrStartProxy(cache.path(), source, 0, + olive::ProxyManager::instance()->get_or_start_proxy(cache.path(), source, 0, params); - ASSERT_EQ(proxy.state, olive::ProxyManager::kProxyGenerating); + ASSERT_EQ(proxy.state, olive::ProxyManager::k_proxy_generating); ASSERT_NE(proxy.task, nullptr); loop.exec(); @@ -297,38 +297,38 @@ TEST(ProxyManager, EmitsProxyFinishedState) EXPECT_EQ(received_source, source); EXPECT_EQ(received_stream, 0); EXPECT_EQ(received_proxy, expected_proxy); - EXPECT_EQ(received_state, olive::ProxyManager::kProxyReady); + EXPECT_EQ(received_state, olive::ProxyManager::k_proxy_ready); // The manager moved the completed proxy into its final location EXPECT_TRUE(QFileInfo::exists(expected_proxy)); - EXPECT_EQ(olive::ProxyManager::GetProxyState(expected_proxy), - olive::ProxyManager::kProxyReady); + EXPECT_EQ(olive::ProxyManager::get_proxy_state(expected_proxy), + olive::ProxyManager::k_proxy_ready); - olive::ProxyManager::DestroyInstance(); + olive::ProxyManager::destroy_instance(); if (created_task_manager) { - olive::TaskManager::DestroyInstance(); + olive::TaskManager::destroy_instance(); } } TEST(ProxyManager, WorkingProxyFilenamePrependsExtension) { const QString proxy = QStringLiteral("/cache/proxy/example.mp4"); - const QString working = olive::ProxyManager::GetWorkingProxyFilename(proxy); + const QString working = olive::ProxyManager::get_working_proxy_filename(proxy); EXPECT_EQ(working, QStringLiteral("/cache/proxy/example.mp4.working.mp4")); } TEST(ProxyManager, ProxyStateFromStringDefaultsForEmpty) { - EXPECT_EQ(olive::ProxyManager::ProxyStateFromString(QString()), - olive::ProxyManager::kProxyMissing); + EXPECT_EQ(olive::ProxyManager::proxy_state_from_string(QString()), + olive::ProxyManager::k_proxy_missing); } TEST(ProxyManager, FootageProxyCanBeDisabled) { olive::Footage footage; - footage.SetProxy(QStringLiteral("/cache/proxy/example.mp4"), - olive::ProxyManager::kProxyReady, 0, 1, false); + footage.set_proxy(QStringLiteral("/cache/proxy/example.mp4"), + olive::ProxyManager::k_proxy_ready, 0, 1, false); EXPECT_FALSE(footage.proxy_enabled()); EXPECT_FALSE(footage.proxy_path().isEmpty()); @@ -338,8 +338,8 @@ TEST(ProxyManager, FootageJobWithoutProxyHasEmptyProxyFields) { olive::FootageJob job(olive::TimeRange(), QStringLiteral("source-decoder"), QStringLiteral("/media/source.mov"), - olive::Track::kVideo, olive::rational(10), - olive::LoopMode::kLoopModeOff); + olive::Track::k_video, olive::Rational(10), + olive::LoopMode::k_loop_mode_off); EXPECT_FALSE(job.has_proxy()); EXPECT_TRUE(job.proxy_filename().isEmpty()); @@ -352,21 +352,21 @@ TEST(ProxyManager, ProxyFilenameIncludesAudioFlag) olive::ProxyManager::ProxyParams params; params.include_audio = true; - const QString with_audio = olive::ProxyManager::GetProxyFilename( + const QString with_audio = olive::ProxyManager::get_proxy_filename( QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"), 0, params); EXPECT_TRUE(with_audio.contains(QStringLiteral(".a1."))); - EXPECT_TRUE(olive::ProxyManager::ProxyFilenameHasAudio(with_audio)); + EXPECT_TRUE(olive::ProxyManager::proxy_filename_has_audio(with_audio)); params.include_audio = false; - const QString without_audio = olive::ProxyManager::GetProxyFilename( + const QString without_audio = olive::ProxyManager::get_proxy_filename( QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"), 0, params); EXPECT_TRUE(without_audio.contains(QStringLiteral(".a0."))); - EXPECT_FALSE(olive::ProxyManager::ProxyFilenameHasAudio(without_audio)); + EXPECT_FALSE(olive::ProxyManager::proxy_filename_has_audio(without_audio)); // Legacy proxy filenames (no audio marker) must be treated as video-only - EXPECT_FALSE(olive::ProxyManager::ProxyFilenameHasAudio( + EXPECT_FALSE(olive::ProxyManager::proxy_filename_has_audio( QStringLiteral("/tmp/oak-cache/proxy/abc-0.1280x720.v1.mp4"))); // The audio flag distinguishes otherwise identical proxy filenames @@ -376,14 +376,14 @@ TEST(ProxyManager, ProxyFilenameIncludesAudioFlag) TEST(ProxyManager, ProxyParamsFromConfigReadsDefaults) { const olive::ProxyManager::ProxyParams params = - olive::ProxyManager::ProxyParamsFromConfig(); + olive::ProxyManager::proxy_params_from_config(); - EXPECT_EQ(params.width, ProxyConfigValue("ProxyWidth").value()); - EXPECT_EQ(params.height, ProxyConfigValue("ProxyHeight").value()); - EXPECT_EQ(params.crf, ProxyConfigValue("ProxyCRF").value()); - EXPECT_EQ(params.preset, ProxyConfigValue("ProxyPreset").toString()); + EXPECT_EQ(params.width, proxy_config_value("ProxyWidth").value()); + EXPECT_EQ(params.height, proxy_config_value("ProxyHeight").value()); + EXPECT_EQ(params.crf, proxy_config_value("ProxyCRF").value()); + EXPECT_EQ(params.preset, proxy_config_value("ProxyPreset").toString()); EXPECT_EQ(params.include_audio, - ProxyConfigValue("ProxyIncludeAudio").toBool()); + proxy_config_value("ProxyIncludeAudio").toBool()); } TEST(ProxyManager, FindFFmpegExecutablePrefersConfiguredPath) @@ -393,13 +393,13 @@ TEST(ProxyManager, FindFFmpegExecutablePrefersConfiguredPath) const QString self = QCoreApplication::applicationFilePath(); ASSERT_FALSE(self.isEmpty()); - EXPECT_EQ(olive::ProxyManager::FindFFmpegExecutable(self), self); + EXPECT_EQ(olive::ProxyManager::find_f_fmpeg_executable(self), self); } TEST(ProxyManager, FindFFmpegExecutableRejectsInvalidConfiguredPath) { const QString bogus = QStringLiteral("/nonexistent/ffmpeg-binary"); - const QString result = olive::ProxyManager::FindFFmpegExecutable(bogus); + const QString result = olive::ProxyManager::find_f_fmpeg_executable(bogus); // Must not return the invalid configured path; any fallback is acceptable EXPECT_NE(result, bogus); @@ -410,7 +410,7 @@ TEST(ProxyTask, BuildArgumentsIncludesAudioWhenEnabled) olive::ProxyManager::ProxyParams params; params.include_audio = true; - const QStringList args = olive::ProxyTask::BuildArguments( + const QStringList args = olive::ProxyTask::build_arguments( QStringLiteral("/media/source.mov"), 1, params, QStringLiteral("/cache/proxy/out.mp4")); @@ -429,7 +429,7 @@ TEST(ProxyTask, BuildArgumentsDisablesAudioWhenDisabled) olive::ProxyManager::ProxyParams params; params.include_audio = false; - const QStringList args = olive::ProxyTask::BuildArguments( + const QStringList args = olive::ProxyTask::build_arguments( QStringLiteral("/media/source.mov"), 1, params, QStringLiteral("/cache/proxy/out.mp4")); @@ -447,15 +447,15 @@ TEST(ProxyManager, FootagePersistsCustomProxyParams) params.preset = QStringLiteral("faster"); params.extension = QStringLiteral("mov"); params.include_audio = false; - footage.SetCustomProxyParams(params); - footage.SetProxy(QStringLiteral("/cache/proxy/example.mp4"), - olive::ProxyManager::kProxyReady, 0, 1, true); + footage.set_custom_proxy_params(params); + footage.set_proxy(QStringLiteral("/cache/proxy/example.mp4"), + olive::ProxyManager::k_proxy_ready, 0, 1, true); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("custom")); - footage.SaveCustom(&writer); + footage.save_custom(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -472,7 +472,7 @@ TEST(ProxyManager, FootagePersistsCustomProxyParams) ASSERT_EQ(reader.name(), QStringLiteral("custom")); olive::Footage loaded; - ASSERT_TRUE(loaded.LoadCustom(&reader, nullptr)); + ASSERT_TRUE(loaded.load_custom(&reader, nullptr)); ASSERT_TRUE(loaded.has_custom_proxy_params()); EXPECT_EQ(loaded.custom_proxy_params().width, 640); EXPECT_EQ(loaded.custom_proxy_params().height, 360); @@ -485,14 +485,14 @@ TEST(ProxyManager, FootagePersistsCustomProxyParams) TEST(ProxyManager, FootageWithoutCustomParamsOmitsThemFromXml) { olive::Footage footage; - footage.SetProxy(QStringLiteral("/cache/proxy/example.mp4"), - olive::ProxyManager::kProxyReady, 0, 1, true); + footage.set_proxy(QStringLiteral("/cache/proxy/example.mp4"), + olive::ProxyManager::k_proxy_ready, 0, 1, true); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("custom")); - footage.SaveCustom(&writer); + footage.save_custom(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -502,7 +502,7 @@ TEST(ProxyManager, FootageWithoutCustomParamsOmitsThemFromXml) QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); olive::Footage loaded; - ASSERT_TRUE(loaded.LoadCustom(&reader, nullptr)); + ASSERT_TRUE(loaded.load_custom(&reader, nullptr)); EXPECT_FALSE(loaded.has_custom_proxy_params()); } @@ -512,23 +512,23 @@ TEST(ProxyManager, FootageEffectiveProxyParams) // Without custom params, the global config values apply const olive::ProxyManager::ProxyParams global_params = - footage.GetEffectiveProxyParams(); - EXPECT_EQ(global_params.width, ProxyConfigValue("ProxyWidth").value()); + footage.get_effective_proxy_params(); + EXPECT_EQ(global_params.width, proxy_config_value("ProxyWidth").value()); EXPECT_EQ(global_params.include_audio, - ProxyConfigValue("ProxyIncludeAudio").toBool()); + proxy_config_value("ProxyIncludeAudio").toBool()); // Custom params take precedence olive::ProxyManager::ProxyParams custom; custom.width = 320; custom.height = 180; - footage.SetCustomProxyParams(custom); + footage.set_custom_proxy_params(custom); EXPECT_TRUE(footage.has_custom_proxy_params()); - EXPECT_EQ(footage.GetEffectiveProxyParams().width, 320); - EXPECT_EQ(footage.GetEffectiveProxyParams().height, 180); + EXPECT_EQ(footage.get_effective_proxy_params().width, 320); + EXPECT_EQ(footage.get_effective_proxy_params().height, 180); // Clearing reverts to the global config values - footage.ClearCustomProxyParams(); + footage.clear_custom_proxy_params(); EXPECT_FALSE(footage.has_custom_proxy_params()); - EXPECT_EQ(footage.GetEffectiveProxyParams().width, - ProxyConfigValue("ProxyWidth").value()); + EXPECT_EQ(footage.get_effective_proxy_params().width, + proxy_config_value("ProxyWidth").value()); } diff --git a/tests/gtest/render_alphaassoc_test.cpp b/tests/gtest/render_alphaassoc_test.cpp index 294961389..ccf4edcf6 100644 --- a/tests/gtest/render_alphaassoc_test.cpp +++ b/tests/gtest/render_alphaassoc_test.cpp @@ -4,7 +4,7 @@ TEST(AlphaAssociated, ValuesAreDistinct) { - EXPECT_NE(olive::kAlphaNone, olive::kAlphaUnassociated); - EXPECT_NE(olive::kAlphaNone, olive::kAlphaAssociated); - EXPECT_NE(olive::kAlphaUnassociated, olive::kAlphaAssociated); + EXPECT_NE(olive::k_alpha_none, olive::k_alpha_unassociated); + EXPECT_NE(olive::k_alpha_none, olive::k_alpha_associated); + EXPECT_NE(olive::k_alpha_unassociated, olive::k_alpha_associated); } diff --git a/tests/gtest/render_audioparams_branch_test.cpp b/tests/gtest/render_audioparams_branch_test.cpp index c5b6d4f7b..b12d4f790 100644 --- a/tests/gtest/render_audioparams_branch_test.cpp +++ b/tests/gtest/render_audioparams_branch_test.cpp @@ -7,12 +7,12 @@ TEST(RenderAudioParams, ValidityAndEquality) olive::core::AudioParams invalid; EXPECT_FALSE(invalid.is_valid()); - olive::core::AudioParams params(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::S16); + olive::core::AudioParams params(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::s16); EXPECT_TRUE(params.is_valid()); - olive::core::AudioParams other(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::S16); + olive::core::AudioParams other(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::s16); EXPECT_TRUE(params == other); other.set_sample_rate(44100); @@ -21,8 +21,8 @@ TEST(RenderAudioParams, ValidityAndEquality) TEST(RenderAudioParams, TimeAndSampleConversions) { - olive::core::AudioParams params(48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::S16); + olive::core::AudioParams params(48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::s16); EXPECT_EQ(params.channel_count(), 2); EXPECT_EQ(params.bytes_per_sample_per_channel(), 2); @@ -36,46 +36,46 @@ TEST(RenderAudioParams, TimeAndSampleConversions) EXPECT_EQ(params.samples_to_bytes_per_channel(48000), 96000); EXPECT_EQ(params.bytes_to_samples(192000), 48000); - EXPECT_EQ(params.bytes_to_time(192000), olive::core::rational(1, 1)); + EXPECT_EQ(params.bytes_to_time(192000), olive::core::Rational(1, 1)); EXPECT_EQ(params.bytes_per_channel_to_time(96000), - olive::core::rational(1, 1)); + olive::core::Rational(1, 1)); } TEST(RenderAudioParams, ChannelLayoutCount) { - olive::core::AudioParams mono(48000, olive::core::kChannelLayoutMono, - olive::core::SampleFormat::F32); + olive::core::AudioParams mono(48000, olive::core::k_channel_layout_mono, + olive::core::SampleFormat::f32); EXPECT_EQ(mono.channel_count(), 1); - olive::core::AudioParams surround(48000, olive::core::kChannelLayout5Point1, - olive::core::SampleFormat::F32); + olive::core::AudioParams surround(48000, olive::core::k_channel_layout5_point1, + olive::core::SampleFormat::f32); EXPECT_EQ(surround.channel_count(), 6); } TEST(RenderAudioParams, SampleFormatSizes) { - olive::core::AudioParams u8(48000, olive::core::kChannelLayoutMono, - olive::core::SampleFormat::U8); + olive::core::AudioParams u8(48000, olive::core::k_channel_layout_mono, + olive::core::SampleFormat::u8); EXPECT_EQ(u8.bytes_per_sample_per_channel(), 1); - olive::core::AudioParams f32(48000, olive::core::kChannelLayoutMono, - olive::core::SampleFormat::F32); + olive::core::AudioParams f32(48000, olive::core::k_channel_layout_mono, + olive::core::SampleFormat::f32); EXPECT_EQ(f32.bytes_per_sample_per_channel(), 4); - olive::core::AudioParams f64(48000, olive::core::kChannelLayoutMono, - olive::core::SampleFormat::F64); + olive::core::AudioParams f64(48000, olive::core::k_channel_layout_mono, + olive::core::SampleFormat::f64); EXPECT_EQ(f64.bytes_per_sample_per_channel(), 8); } TEST(RenderAudioParams, CopyAndAssignment) { - olive::core::AudioParams params(96000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32); + olive::core::AudioParams params(96000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32); olive::core::AudioParams copy(params); EXPECT_EQ(copy.sample_rate(), 96000); EXPECT_EQ(copy.channel_count(), 2); - EXPECT_EQ(copy.format(), olive::core::SampleFormat::F32); + EXPECT_EQ(copy.format(), olive::core::SampleFormat::f32); olive::core::AudioParams assigned; assigned = params; @@ -85,13 +85,13 @@ TEST(RenderAudioParams, CopyAndAssignment) TEST(RenderAudioParams, SettersModifyState) { - olive::core::AudioParams params(44100, olive::core::kChannelLayoutMono, - olive::core::SampleFormat::S16); + olive::core::AudioParams params(44100, olive::core::k_channel_layout_mono, + olive::core::SampleFormat::s16); EXPECT_TRUE(params.is_valid()); params.set_sample_rate(48000); - params.set_format(olive::core::SampleFormat::F32); + params.set_format(olive::core::SampleFormat::f32); EXPECT_EQ(params.sample_rate(), 48000); - EXPECT_EQ(params.format(), olive::core::SampleFormat::F32); + EXPECT_EQ(params.format(), olive::core::SampleFormat::f32); } diff --git a/tests/gtest/render_audioparams_test.cpp b/tests/gtest/render_audioparams_test.cpp index 48da336fc..a2367b829 100644 --- a/tests/gtest/render_audioparams_test.cpp +++ b/tests/gtest/render_audioparams_test.cpp @@ -12,7 +12,7 @@ TEST(RenderAudioParams, SaveLoadRoundTrip) olive::AudioParams params; params.set_sample_rate(48000); params.set_enabled(true); - params.set_time_base(olive::core::rational(1, 48000)); + params.set_time_base(olive::core::Rational(1, 48000)); QByteArray xml; QBuffer buffer(&xml); @@ -20,7 +20,7 @@ TEST(RenderAudioParams, SaveLoadRoundTrip) QXmlStreamWriter writer(&buffer); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("audioparams")); - olive::TypeSerializer::SaveAudioParams(&writer, params); + olive::TypeSerializer::save_audio_params(&writer, params); writer.writeEndElement(); writer.writeEndDocument(); buffer.close(); @@ -30,9 +30,9 @@ TEST(RenderAudioParams, SaveLoadRoundTrip) QXmlStreamReader reader(&read_buffer); EXPECT_TRUE(reader.readNextStartElement()); EXPECT_EQ(reader.name().toString(), QStringLiteral("audioparams")); - olive::AudioParams loaded = olive::TypeSerializer::LoadAudioParams(&reader); + olive::AudioParams loaded = olive::TypeSerializer::load_audio_params(&reader); EXPECT_EQ(loaded.sample_rate(), 48000); EXPECT_TRUE(loaded.enabled()); - EXPECT_EQ(loaded.time_base(), olive::core::rational(1, 48000)); + EXPECT_EQ(loaded.time_base(), olive::core::Rational(1, 48000)); } diff --git a/tests/gtest/render_clip_buffer_hint_test.cpp b/tests/gtest/render_clip_buffer_hint_test.cpp index 31db1132d..b90c6abb9 100644 --- a/tests/gtest/render_clip_buffer_hint_test.cpp +++ b/tests/gtest/render_clip_buffer_hint_test.cpp @@ -60,13 +60,13 @@ using namespace olive; namespace { -QString DemoVideoPath() +QString demo_video_path() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/demo.mp4")); } -QString WorkerBinaryPath() +QString worker_binary_path() { // The test binary lives in cmake-build-debug/tests/gtest; the worker is in // cmake-build-debug/app. @@ -81,30 +81,30 @@ QString WorkerBinaryPath() #endif } -bool IsRenderBackendAvailable(const QString &backend) +bool is_render_backend_available(const QString &backend) { #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND olive::DynamicRenderer renderer(backend); - if (!renderer.Load()) { + if (!renderer.load()) { return false; } OakRenderBackendInfo info = {}; - if (!renderer.GetBackendInfo(&info)) { + if (!renderer.get_backend_info(&info)) { return false; } if (backend == QStringLiteral("vulkan") && - info.kind != OAK_RENDER_BACKEND_VULKAN) { + info.kind != oak_render_backend_vulkan) { return false; } if (backend == QStringLiteral("opengl") && - info.kind != OAK_RENDER_BACKEND_OPENGL) { + info.kind != oak_render_backend_opengl) { return false; } - return renderer.Init(); + return renderer.init(); #else Q_UNUSED(backend) return false; @@ -113,7 +113,7 @@ bool IsRenderBackendAvailable(const QString &backend) // Returns the number of non-zero bytes sampled from the frame buffer, or -1 // when the frame is invalid. -int CountNonZeroBytes(const FramePtr &frame) +int count_non_zero_bytes(const FramePtr &frame) { if (!frame || !frame->is_allocated()) { return -1; @@ -141,17 +141,17 @@ protected: { // Mirror Core::Start()'s singleton initialization order (RenderManager // is created per-test instead, so that each backend gets a fresh one). - NodeFactory::Initialize(); - ColorManager::SetUpDefaultConfig(); - TaskManager::CreateInstance(); - ConformManager::CreateInstance(); - ProxyManager::CreateInstance(); - FrameManager::CreateInstance(); - ProjectSerializer::Initialize(); - DiskManager::CreateInstance(); + NodeFactory::initialize(); + ColorManager::set_up_default_config(); + TaskManager::create_instance(); + ConformManager::create_instance(); + ProxyManager::create_instance(); + FrameManager::create_instance(); + ProjectSerializer::initialize(); + DiskManager::create_instance(); // Point the worker pool at the built worker binary. - const QString worker = WorkerBinaryPath(); + const QString worker = worker_binary_path(); if (QFileInfo::exists(worker)) { qputenv("OAK_RENDER_WORKER", QFile::encodeName(worker)); } @@ -159,58 +159,58 @@ protected: static void TearDownTestSuite() { - DiskManager::DestroyInstance(); - ProjectSerializer::Destroy(); - FrameManager::DestroyInstance(); - ProxyManager::DestroyInstance(); - ConformManager::DestroyInstance(); - TaskManager::DestroyInstance(); - NodeFactory::Destroy(); + DiskManager::destroy_instance(); + ProjectSerializer::destroy(); + FrameManager::destroy_instance(); + ProxyManager::destroy_instance(); + ConformManager::destroy_instance(); + TaskManager::destroy_instance(); + NodeFactory::destroy(); } void SetUp() override { backend_ = GetParam(); - if (!IsRenderBackendAvailable(backend_)) { + if (!is_render_backend_available(backend_)) { GTEST_SKIP() << "Render backend is not available: " << backend_.toStdString(); } - const QString worker = WorkerBinaryPath(); + const QString worker = worker_binary_path(); if (!QFileInfo::exists(worker)) { GTEST_SKIP() << "worker binary not found at " << worker.toStdString(); } - demo_path_ = DemoVideoPath(); + demo_path_ = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(demo_path_)); - Config::Current()[QStringLiteral("GraphicsBackend")] = backend_; + Config::current()[QStringLiteral("GraphicsBackend")] = backend_; project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); footage_ = new Footage(demo_path_); footage_->setParent(project_.get()); - ASSERT_TRUE(footage_->IsValid()) + ASSERT_TRUE(footage_->is_valid()) << "Footage failed to probe " << demo_path_.toStdString(); // The bug requires the footage to provide both a video and an audio // stream, so that the video texture is not the last value in the // footage's table. - ASSERT_GE(footage_->GetVideoStreamCount(), 1); - ASSERT_GE(footage_->GetAudioStreamCount(), 1) + ASSERT_GE(footage_->get_video_stream_count(), 1); + ASSERT_GE(footage_->get_audio_stream_count(), 1) << "Test footage must contain an audio stream"; - RenderManager::CreateInstance(); - RenderManager::instance()->GetCacher()->SetProject(project_.get()); + RenderManager::create_instance(); + RenderManager::instance()->get_cacher()->set_project(project_.get()); } void TearDown() override { // May be null when SetUp() skipped before creating the instance. if (RenderManager::instance()) { - RenderManager::instance()->GetCacher()->SetProject(nullptr); - RenderManager::DestroyInstance(); + RenderManager::instance()->get_cacher()->set_project(nullptr); + RenderManager::destroy_instance(); } project_.reset(); } @@ -218,66 +218,66 @@ protected: // Builds sequence <- track <- clip <- (optional effect) <- footage and // returns the clip. When insert_effect is false the footage is connected // directly to the clip's buffer input, which is the black-screen case. - ClipBlock *BuildVideoClipChain(bool insert_effect) + ClipBlock *build_video_clip_chain(bool insert_effect) { sequence_ = new Sequence(); sequence_->setParent(project_.get()); - sequence_->SetVideoParams(VideoParams( - 1920, 1080, rational(25), + sequence_->set_video_params(VideoParams( + 1920, 1080, Rational(25), static_cast( - Config::Current()[QStringLiteral("OfflinePixelFormat")] + Config::current()[QStringLiteral("OfflinePixelFormat")] .toInt()), - VideoParams::kInternalChannelCount, rational(1), - VideoParams::kInterlaceNone, 1)); - sequence_->SetAudioParams(olive::core::AudioParams( - 48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P)); + VideoParams::k_internal_channel_count, Rational(1), + VideoParams::k_interlace_none, 1)); + sequence_->set_audio_params(olive::core::AudioParams( + 48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p)); Track *track = new Track(); track->setParent(project_.get()); video_track_ = track; ClipBlock *clip = new ClipBlock(); clip->setParent(project_.get()); - clip->set_length_and_media_out(footage_->GetLength()); + clip->set_length_and_media_out(footage_->get_length()); Node *buffer_source = footage_; if (insert_effect) { OpacityEffect *opacity = new OpacityEffect(); opacity->setParent(project_.get()); - Node::ConnectEdge(footage_, - NodeInput(opacity, OpacityEffect::kTextureInput)); + Node::connect_edge(footage_, + NodeInput(opacity, OpacityEffect::k_texture_input)); buffer_source = opacity; } - Node::ConnectEdge(buffer_source, - NodeInput(clip, ClipBlock::kBufferIn)); + Node::connect_edge(buffer_source, + NodeInput(clip, ClipBlock::k_buffer_in)); - track->AppendBlock(clip); + track->append_block(clip); // Wire the track into the sequence's video track list (this is what // assigns the track its type) and into the sequence's texture output. - TrackList *track_list = sequence_->track_list(Track::kVideo); - track_list->ArrayAppend(); - Node::ConnectEdge( - track, track_list->track_input(track_list->ArraySize() - 1)); - Node::ConnectEdge(track, - NodeInput(sequence_, ViewerOutput::kTextureInput)); + TrackList *track_list = sequence_->track_list(Track::k_video); + track_list->array_append(); + Node::connect_edge( + track, track_list->track_input(track_list->array_size() - 1)); + Node::connect_edge(track, + NodeInput(sequence_, ViewerOutput::k_texture_input)); return clip; } // Renders one frame through the application's preview path and returns the // resulting CPU frame (nullptr on failure/timeout). - FramePtr RenderOneFrame(ViewerOutput *viewer, const rational &time) + FramePtr render_one_frame(ViewerOutput *viewer, const Rational &time) { RenderTicketPtr ticket = - RenderManager::instance()->GetCacher()->GetSingleFrame(viewer, time, + RenderManager::instance()->get_cacher()->get_single_frame(viewer, time, false); if (!ticket) { return nullptr; } std::atomic finished{ false }; - QObject::connect(ticket.get(), &RenderTicket::Finished, + QObject::connect(ticket.get(), &RenderTicket::finished, [&finished]() { finished = true; }); QElapsedTimer timer; @@ -287,11 +287,11 @@ protected: QThread::msleep(5); } - if (!finished.load() || !ticket->HasResult()) { + if (!finished.load() || !ticket->has_result()) { return nullptr; } - return ticket->Get().value(); + return ticket->get().value(); } QString backend_; @@ -307,14 +307,14 @@ protected: // (the last value in the footage's table) instead of its video texture. TEST_P(RenderClipBufferHintTest, DirectFootageToVideoClipNotBlack) { - BuildVideoClipChain(false); + build_video_clip_chain(false); for (double t : { 0.0, 1.0 }) { - FramePtr frame = RenderOneFrame(sequence_, rational::fromDouble(t)); + FramePtr frame = render_one_frame(sequence_, Rational::from_double(t)); ASSERT_TRUE(frame != nullptr) << "Direct footage->clip render produced no frame at t=" << t; ASSERT_TRUE(frame->is_allocated()); - EXPECT_GT(CountNonZeroBytes(frame), 0) + EXPECT_GT(count_non_zero_bytes(frame), 0) << "Direct footage->clip render is BLACK at t=" << t << " (all sampled bytes are zero)"; } @@ -324,15 +324,15 @@ TEST_P(RenderClipBufferHintTest, DirectFootageToVideoClipNotBlack) // because the effect's table contains only the passed-through texture. TEST_P(RenderClipBufferHintTest, IndirectFootageToVideoClipNotBlack) { - BuildVideoClipChain(true); + build_video_clip_chain(true); for (double t : { 0.0, 1.0 }) { - FramePtr frame = RenderOneFrame(sequence_, rational::fromDouble(t)); + FramePtr frame = render_one_frame(sequence_, Rational::from_double(t)); ASSERT_TRUE(frame != nullptr) << "Indirect footage->opacity->clip render produced no frame at t=" << t; ASSERT_TRUE(frame->is_allocated()); - EXPECT_GT(CountNonZeroBytes(frame), 0) + EXPECT_GT(count_non_zero_bytes(frame), 0) << "Indirect footage->opacity->clip render is BLACK at t=" << t << " (all sampled bytes are zero)"; } @@ -343,25 +343,25 @@ TEST_P(RenderClipBufferHintTest, IndirectFootageToVideoClipNotBlack) // source. TEST_P(RenderClipBufferHintTest, BufferHintFollowsTrackType) { - ClipBlock *clip = BuildVideoClipChain(false); + ClipBlock *clip = build_video_clip_chain(false); Node::ValueHint video_hint = - clip->GetValueHintForInput(ClipBlock::kBufferIn); + clip->get_value_hint_for_input(ClipBlock::k_buffer_in); ASSERT_FALSE(video_hint.types().isEmpty()); - EXPECT_TRUE(video_hint.types().contains(NodeValue::kTexture)); + EXPECT_TRUE(video_hint.types().contains(NodeValue::k_texture)); // Move the clip onto an audio track: the hint must prefer samples. - video_track_->RippleRemoveBlock(clip); + video_track_->ripple_remove_block(clip); Track *audio_track = new Track(); audio_track->setParent(project_.get()); - audio_track->set_type(Track::kAudio); - audio_track->AppendBlock(clip); + audio_track->set_type(Track::k_audio); + audio_track->append_block(clip); Node::ValueHint audio_hint = - clip->GetValueHintForInput(ClipBlock::kBufferIn); + clip->get_value_hint_for_input(ClipBlock::k_buffer_in); ASSERT_FALSE(audio_hint.types().isEmpty()); - EXPECT_TRUE(audio_hint.types().contains(NodeValue::kSamples)); + EXPECT_TRUE(audio_hint.types().contains(NodeValue::k_samples)); } INSTANTIATE_TEST_SUITE_P(Backends, RenderClipBufferHintTest, diff --git a/tests/gtest/render_direct_connection_test.cpp b/tests/gtest/render_direct_connection_test.cpp index 15cd18a0f..7a80760cb 100644 --- a/tests/gtest/render_direct_connection_test.cpp +++ b/tests/gtest/render_direct_connection_test.cpp @@ -47,13 +47,13 @@ using namespace olive; namespace { -QString DemoVideoPath() +QString demo_video_path() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/demo.mp4")); } -QString WorkerBinaryPath() +QString worker_binary_path() { // The test binary lives in cmake-build-debug/tests/gtest; the worker is in // cmake-build-debug/app. @@ -68,30 +68,30 @@ QString WorkerBinaryPath() #endif } -bool IsRenderBackendAvailable(const QString &backend) +bool is_render_backend_available(const QString &backend) { #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND olive::DynamicRenderer renderer(backend); - if (!renderer.Load()) { + if (!renderer.load()) { return false; } OakRenderBackendInfo info = {}; - if (!renderer.GetBackendInfo(&info)) { + if (!renderer.get_backend_info(&info)) { return false; } if (backend == QStringLiteral("vulkan") && - info.kind != OAK_RENDER_BACKEND_VULKAN) { + info.kind != oak_render_backend_vulkan) { return false; } if (backend == QStringLiteral("opengl") && - info.kind != OAK_RENDER_BACKEND_OPENGL) { + info.kind != oak_render_backend_opengl) { return false; } - return renderer.Init(); + return renderer.init(); #else Q_UNUSED(backend) return false; @@ -100,7 +100,7 @@ bool IsRenderBackendAvailable(const QString &backend) // Returns the number of non-zero bytes sampled from the frame buffer, or -1 // when the frame is invalid. -int CountNonZeroBytes(const FramePtr &frame) +int count_non_zero_bytes(const FramePtr &frame) { if (!frame || !frame->is_allocated()) { return -1; @@ -128,17 +128,17 @@ protected: { // Mirror Core::Start()'s singleton initialization order (RenderManager // is created per-test instead, so that each backend gets a fresh one). - NodeFactory::Initialize(); - ColorManager::SetUpDefaultConfig(); - TaskManager::CreateInstance(); - ConformManager::CreateInstance(); - ProxyManager::CreateInstance(); - FrameManager::CreateInstance(); - ProjectSerializer::Initialize(); - DiskManager::CreateInstance(); + NodeFactory::initialize(); + ColorManager::set_up_default_config(); + TaskManager::create_instance(); + ConformManager::create_instance(); + ProxyManager::create_instance(); + FrameManager::create_instance(); + ProjectSerializer::initialize(); + DiskManager::create_instance(); // Point the worker pool at the built worker binary. - const QString worker = WorkerBinaryPath(); + const QString worker = worker_binary_path(); if (QFileInfo::exists(worker)) { qputenv("OAK_RENDER_WORKER", QFile::encodeName(worker)); } @@ -146,69 +146,69 @@ protected: static void TearDownTestSuite() { - DiskManager::DestroyInstance(); - ProjectSerializer::Destroy(); - FrameManager::DestroyInstance(); - ProxyManager::DestroyInstance(); - ConformManager::DestroyInstance(); - TaskManager::DestroyInstance(); - NodeFactory::Destroy(); + DiskManager::destroy_instance(); + ProjectSerializer::destroy(); + FrameManager::destroy_instance(); + ProxyManager::destroy_instance(); + ConformManager::destroy_instance(); + TaskManager::destroy_instance(); + NodeFactory::destroy(); } void SetUp() override { backend_ = GetParam(); - if (!IsRenderBackendAvailable(backend_)) { + if (!is_render_backend_available(backend_)) { GTEST_SKIP() << "Render backend is not available: " << backend_.toStdString(); } - const QString worker = WorkerBinaryPath(); + const QString worker = worker_binary_path(); if (!QFileInfo::exists(worker)) { GTEST_SKIP() << "worker binary not found at " << worker.toStdString(); } - demo_path_ = DemoVideoPath(); + demo_path_ = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(demo_path_)); - Config::Current()[QStringLiteral("GraphicsBackend")] = backend_; + Config::current()[QStringLiteral("GraphicsBackend")] = backend_; project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); footage_ = new Footage(demo_path_); footage_->setParent(project_.get()); - ASSERT_TRUE(footage_->IsValid()) + ASSERT_TRUE(footage_->is_valid()) << "Footage failed to probe " << demo_path_.toStdString(); - RenderManager::CreateInstance(); - RenderManager::instance()->GetCacher()->SetProject(project_.get()); + RenderManager::create_instance(); + RenderManager::instance()->get_cacher()->set_project(project_.get()); } void TearDown() override { // May be null when SetUp() skipped before creating the instance. if (RenderManager::instance()) { - RenderManager::instance()->GetCacher()->SetProject(nullptr); - RenderManager::DestroyInstance(); + RenderManager::instance()->get_cacher()->set_project(nullptr); + RenderManager::destroy_instance(); } project_.reset(); } // Renders one frame through the application's preview path and returns the // resulting CPU frame (nullptr on failure/timeout). - FramePtr RenderOneFrame(ViewerOutput *viewer) + FramePtr render_one_frame(ViewerOutput *viewer) { RenderTicketPtr ticket = - RenderManager::instance()->GetCacher()->GetSingleFrame( - viewer, rational(0), false); + RenderManager::instance()->get_cacher()->get_single_frame( + viewer, Rational(0), false); if (!ticket) { return nullptr; } std::atomic finished{ false }; - QObject::connect(ticket.get(), &RenderTicket::Finished, + QObject::connect(ticket.get(), &RenderTicket::finished, [&finished]() { finished = true; }); QElapsedTimer timer; @@ -218,11 +218,11 @@ protected: QThread::msleep(5); } - if (!finished.load() || !ticket->HasResult()) { + if (!finished.load() || !ticket->has_result()) { return nullptr; } - return ticket->Get().value(); + return ticket->get().value(); } QString backend_; @@ -239,20 +239,20 @@ TEST_P(RenderDirectConnectionTest, DirectConnectionIsNotBlack) viewer->setParent(project_.get()); // Direct connection: footage -> viewer - Node::ConnectEdge(footage_, NodeInput(viewer, ViewerOutput::kTextureInput)); + Node::connect_edge(footage_, NodeInput(viewer, ViewerOutput::k_texture_input)); - FramePtr frame = RenderOneFrame(viewer); + FramePtr frame = render_one_frame(viewer); ASSERT_TRUE(frame != nullptr) << "Direct connection render produced no frame (timeout or empty " "ticket)"; ASSERT_TRUE(frame->is_allocated()); - int nonzero = CountNonZeroBytes(frame); + int nonzero = count_non_zero_bytes(frame); EXPECT_GT(nonzero, 0) << "Direct connection render is BLACK (all sampled bytes are zero)"; - Node::DisconnectEdge(footage_, - NodeInput(viewer, ViewerOutput::kTextureInput)); + Node::disconnect_edge(footage_, + NodeInput(viewer, ViewerOutput::k_texture_input)); } // Same as above but with an effect node between footage and viewer. This is @@ -266,16 +266,16 @@ TEST_P(RenderDirectConnectionTest, IndirectConnectionIsNotBlack) opacity->setParent(project_.get()); // Indirect connection: footage -> opacity -> viewer - Node::ConnectEdge(footage_, - NodeInput(opacity, OpacityEffect::kTextureInput)); - Node::ConnectEdge(opacity, NodeInput(viewer, ViewerOutput::kTextureInput)); + Node::connect_edge(footage_, + NodeInput(opacity, OpacityEffect::k_texture_input)); + Node::connect_edge(opacity, NodeInput(viewer, ViewerOutput::k_texture_input)); - FramePtr frame = RenderOneFrame(viewer); + FramePtr frame = render_one_frame(viewer); ASSERT_TRUE(frame != nullptr) << "Indirect connection render produced no " "frame (timeout or empty ticket)"; ASSERT_TRUE(frame->is_allocated()); - int nonzero = CountNonZeroBytes(frame); + int nonzero = count_non_zero_bytes(frame); EXPECT_GT(nonzero, 0) << "Indirect connection render is BLACK (all sampled bytes are zero)"; } @@ -288,26 +288,26 @@ INSTANTIATE_TEST_SUITE_P(Backends, RenderDirectConnectionTest, // 1280x720, forcing a rescale when the frame is downloaded in the worker. class RenderResolutionMismatchTest : public RenderDirectConnectionTest { protected: - ViewerOutput *CreateSmallViewer() + ViewerOutput *create_small_viewer() { ViewerOutput *viewer = new ViewerOutput(); viewer->setParent(project_.get()); - viewer->SetVideoParams(VideoParams( - 1280, 720, rational(24), + viewer->set_video_params(VideoParams( + 1280, 720, Rational(24), static_cast( - Config::Current()[QStringLiteral("OfflinePixelFormat")] + Config::current()[QStringLiteral("OfflinePixelFormat")] .toInt()), - VideoParams::kInternalChannelCount, rational(1), - VideoParams::kInterlaceNone, 1)); + VideoParams::k_internal_channel_count, Rational(1), + VideoParams::k_interlace_none, 1)); return viewer; } - void ExpectFrameNotBlack(FramePtr frame, const char *what) + void expect_frame_not_black(FramePtr frame, const char *what) { ASSERT_TRUE(frame != nullptr) << what << " render produced no frame (timeout or empty ticket)"; ASSERT_TRUE(frame->is_allocated()); - EXPECT_GT(CountNonZeroBytes(frame), 0) + EXPECT_GT(count_non_zero_bytes(frame), 0) << what << " render is BLACK (all sampled bytes are zero)"; } }; @@ -316,30 +316,30 @@ protected: // footage-sized texture into the viewer-sized output frame. TEST_P(RenderResolutionMismatchTest, DirectConnectionNotBlack) { - ViewerOutput *viewer = CreateSmallViewer(); - Node::ConnectEdge(footage_, NodeInput(viewer, ViewerOutput::kTextureInput)); + ViewerOutput *viewer = create_small_viewer(); + Node::connect_edge(footage_, NodeInput(viewer, ViewerOutput::k_texture_input)); - ExpectFrameNotBlack(RenderOneFrame(viewer), + expect_frame_not_black(render_one_frame(viewer), "Direct connection (resolution mismatch)"); - Node::DisconnectEdge(footage_, - NodeInput(viewer, ViewerOutput::kTextureInput)); + Node::disconnect_edge(footage_, + NodeInput(viewer, ViewerOutput::k_texture_input)); } // Opacity passes the footage-sized texture through, so the worker still has // to rescale at download time. Control case for the direct test above. TEST_P(RenderResolutionMismatchTest, IndirectOpacityNotBlack) { - ViewerOutput *viewer = CreateSmallViewer(); + ViewerOutput *viewer = create_small_viewer(); OpacityEffect *opacity = new OpacityEffect(); opacity->setParent(project_.get()); - Node::ConnectEdge(footage_, - NodeInput(opacity, OpacityEffect::kTextureInput)); - Node::ConnectEdge(opacity, NodeInput(viewer, ViewerOutput::kTextureInput)); + Node::connect_edge(footage_, + NodeInput(opacity, OpacityEffect::k_texture_input)); + Node::connect_edge(opacity, NodeInput(viewer, ViewerOutput::k_texture_input)); - ExpectFrameNotBlack(RenderOneFrame(viewer), + expect_frame_not_black(render_one_frame(viewer), "Indirect opacity (resolution mismatch)"); } @@ -347,19 +347,19 @@ TEST_P(RenderResolutionMismatchTest, IndirectOpacityNotBlack) // rescale is needed at download time. This mirrors the timeline chain. TEST_P(RenderResolutionMismatchTest, IndirectTransformNotBlack) { - ViewerOutput *viewer = CreateSmallViewer(); + ViewerOutput *viewer = create_small_viewer(); TransformDistortNode *transform = new TransformDistortNode(); transform->setParent(project_.get()); // 1 = Fit - transform->SetStandardValue(TransformDistortNode::kAutoscaleInput, 1); + transform->set_standard_value(TransformDistortNode::k_autoscale_input, 1); - Node::ConnectEdge(footage_, - NodeInput(transform, TransformDistortNode::kTextureInput)); - Node::ConnectEdge(transform, - NodeInput(viewer, ViewerOutput::kTextureInput)); + Node::connect_edge(footage_, + NodeInput(transform, TransformDistortNode::k_texture_input)); + Node::connect_edge(transform, + NodeInput(viewer, ViewerOutput::k_texture_input)); - ExpectFrameNotBlack(RenderOneFrame(viewer), + expect_frame_not_black(render_one_frame(viewer), "Indirect transform (resolution mismatch)"); } diff --git a/tests/gtest/render_diskcache_test.cpp b/tests/gtest/render_diskcache_test.cpp index c59a9c698..1f27a8b6d 100644 --- a/tests/gtest/render_diskcache_test.cpp +++ b/tests/gtest/render_diskcache_test.cpp @@ -20,7 +20,7 @@ namespace { -bool WriteFile(const QString &path, qint64 size) +bool write_file(const QString &path, qint64 size) { QFile file(path); if (!file.open(QFile::WriteOnly)) { @@ -33,19 +33,19 @@ bool WriteFile(const QString &path, qint64 size) // Mirrors PlaybackCache::GetThisCacheDirectory + FrameHashCache::CachePathName: // cached frames are stored as // with no extension. -QString ExpectedFrameFile(const QString &cache_root, const QUuid &uuid, +QString expected_frame_file(const QString &cache_root, const QUuid &uuid, qint64 timestamp) { return QDir(QDir(cache_root).filePath(uuid.toString())) .filePath(QString::number(timestamp)); } -olive::FramePtr MakeSolidFrame(int width, int height, +olive::FramePtr make_solid_frame(int width, int height, olive::core::PixelFormat format, int channel_count, const olive::core::Color &color) { - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params( olive::VideoParams(width, height, format, channel_count)); frame->allocate(); @@ -74,31 +74,31 @@ protected: new olive::Core(olive::Core::CoreParams()); } - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); // Point the project cache at a folder alongside the (unsaved) project // file so every cache read/write stays inside the temporary directory. - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); project_->set_filename( QDir(temp_dir_.path()).filePath(QStringLiteral("test.ove"))); - project_->SetCacheLocationSetting( - olive::Project::kCacheStoreAlongsideProject); + project_->set_cache_location_setting( + olive::Project::k_cache_store_alongside_project); } void TearDown() override { project_.reset(); - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } - QString CacheRoot() const + QString cache_root() const { return QDir(temp_dir_.path()).filePath(QStringLiteral("cache")); } - QString MakeSubDir(const QString &name) const + QString make_sub_dir(const QString &name) const { QDir root(temp_dir_.path()); if (!root.mkpath(name)) { @@ -114,57 +114,57 @@ protected: TEST_F(RenderDiskCacheTest, ValidateTimestampCachesSingleFrame) { olive::FrameHashCache cache(project_.get()); - cache.SetTimebase(olive::core::rational(1, 30)); - EXPECT_EQ(cache.GetTimebase(), olive::core::rational(1, 30)); + cache.set_timebase(olive::core::Rational(1, 30)); + EXPECT_EQ(cache.get_timebase(), olive::core::Rational(1, 30)); - EXPECT_FALSE(cache.IsFrameCached(olive::core::rational(15, 30))); + EXPECT_FALSE(cache.is_frame_cached(olive::core::Rational(15, 30))); - cache.ValidateTimestamp(15); + cache.validate_timestamp(15); // Validated range is [15/30, 16/30): in inclusive, out exclusive - EXPECT_TRUE(cache.IsFrameCached(olive::core::rational(15, 30))); - EXPECT_TRUE(cache.IsFrameCached(olive::core::rational(31, 60))); - EXPECT_FALSE(cache.IsFrameCached(olive::core::rational(16, 30))); - EXPECT_FALSE(cache.IsFrameCached(olive::core::rational(14, 30))); + EXPECT_TRUE(cache.is_frame_cached(olive::core::Rational(15, 30))); + EXPECT_TRUE(cache.is_frame_cached(olive::core::Rational(31, 60))); + EXPECT_FALSE(cache.is_frame_cached(olive::core::Rational(16, 30))); + EXPECT_FALSE(cache.is_frame_cached(olive::core::Rational(14, 30))); } TEST_F(RenderDiskCacheTest, ValidateTimeCachesOneTimebaseRange) { olive::FrameHashCache cache(project_.get()); - cache.SetTimebase(olive::core::rational(1, 10)); + cache.set_timebase(olive::core::Rational(1, 10)); // Validates [0.5, 0.6) - cache.ValidateTime(olive::core::rational(1, 2)); + cache.validate_time(olive::core::Rational(1, 2)); - EXPECT_TRUE(cache.IsFrameCached(olive::core::rational(1, 2))); - EXPECT_TRUE(cache.IsFrameCached(olive::core::rational(59, 100))); - EXPECT_FALSE(cache.IsFrameCached(olive::core::rational(6, 10))); - EXPECT_FALSE(cache.IsFrameCached(olive::core::rational(4, 10))); + EXPECT_TRUE(cache.is_frame_cached(olive::core::Rational(1, 2))); + EXPECT_TRUE(cache.is_frame_cached(olive::core::Rational(59, 100))); + EXPECT_FALSE(cache.is_frame_cached(olive::core::Rational(6, 10))); + EXPECT_FALSE(cache.is_frame_cached(olive::core::Rational(4, 10))); } TEST_F(RenderDiskCacheTest, SaveAndLoadFloatFrameRoundTrips) { - const QString sub = MakeSubDir(QStringLiteral("exr_f32")); + const QString sub = make_sub_dir(QStringLiteral("exr_f32")); ASSERT_FALSE(sub.isEmpty()); const QUuid uuid = QUuid::createUuid(); olive::FramePtr frame = - MakeSolidFrame(8, 6, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount, + make_solid_frame(8, 6, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count, olive::core::Color(0.25f, 0.5f, 0.75f, 1.0f)); - ASSERT_TRUE(olive::FrameHashCache::SaveCacheFrame(sub, uuid, 12345, frame)); + ASSERT_TRUE(olive::FrameHashCache::save_cache_frame(sub, uuid, 12345, frame)); - const QString fn = ExpectedFrameFile(sub, uuid, 12345); + const QString fn = expected_frame_file(sub, uuid, 12345); ASSERT_TRUE(QFileInfo::exists(fn)); olive::FramePtr loaded = - olive::FrameHashCache::LoadCacheFrame(sub, uuid, 12345); + olive::FrameHashCache::load_cache_frame(sub, uuid, 12345); ASSERT_NE(loaded, nullptr); EXPECT_EQ(loaded->width(), 8); EXPECT_EQ(loaded->height(), 6); - EXPECT_EQ(loaded->format(), olive::core::PixelFormat::F32); - EXPECT_EQ(loaded->channel_count(), int(olive::VideoParams::kRGBAChannelCount)); + EXPECT_EQ(loaded->format(), olive::core::PixelFormat::f32); + EXPECT_EQ(loaded->channel_count(), int(olive::VideoParams::k_rgba_channel_count)); // EXR storage uses lossy DWAA compression; a solid color survives it well const olive::core::Color px = loaded->get_pixel(4, 3); @@ -175,25 +175,25 @@ TEST_F(RenderDiskCacheTest, SaveAndLoadFloatFrameRoundTrips) TEST_F(RenderDiskCacheTest, SaveAndLoadHalfFloatRgbFrameRoundTrips) { - const QString sub = MakeSubDir(QStringLiteral("exr_f16")); + const QString sub = make_sub_dir(QStringLiteral("exr_f16")); ASSERT_FALSE(sub.isEmpty()); const QUuid uuid = QUuid::createUuid(); olive::FramePtr frame = - MakeSolidFrame(8, 6, olive::core::PixelFormat::F16, - olive::VideoParams::kRGBChannelCount, + make_solid_frame(8, 6, olive::core::PixelFormat::f16, + olive::VideoParams::k_rgb_channel_count, olive::core::Color(0.5f, 0.5f, 0.5f, 1.0f)); - ASSERT_TRUE(olive::FrameHashCache::SaveCacheFrame(sub, uuid, 7, frame)); - ASSERT_TRUE(QFileInfo::exists(ExpectedFrameFile(sub, uuid, 7))); + ASSERT_TRUE(olive::FrameHashCache::save_cache_frame(sub, uuid, 7, frame)); + ASSERT_TRUE(QFileInfo::exists(expected_frame_file(sub, uuid, 7))); // RGB-only frames are stored without an alpha channel - olive::FramePtr loaded = olive::FrameHashCache::LoadCacheFrame(sub, uuid, 7); + olive::FramePtr loaded = olive::FrameHashCache::load_cache_frame(sub, uuid, 7); ASSERT_NE(loaded, nullptr); EXPECT_EQ(loaded->width(), 8); EXPECT_EQ(loaded->height(), 6); - EXPECT_EQ(loaded->format(), olive::core::PixelFormat::F16); - EXPECT_EQ(loaded->channel_count(), int(olive::VideoParams::kRGBChannelCount)); + EXPECT_EQ(loaded->format(), olive::core::PixelFormat::f16); + EXPECT_EQ(loaded->channel_count(), int(olive::VideoParams::k_rgb_channel_count)); const olive::core::Color px = loaded->get_pixel(2, 2); EXPECT_NEAR(px.red(), 0.5f, 0.05); @@ -201,24 +201,24 @@ TEST_F(RenderDiskCacheTest, SaveAndLoadHalfFloatRgbFrameRoundTrips) TEST_F(RenderDiskCacheTest, SaveAndLoadU8FrameRoundTripsThroughJpeg) { - const QString sub = MakeSubDir(QStringLiteral("jpg_u8")); + const QString sub = make_sub_dir(QStringLiteral("jpg_u8")); ASSERT_FALSE(sub.isEmpty()); const QUuid uuid = QUuid::createUuid(); olive::FramePtr frame = - MakeSolidFrame(16, 16, olive::core::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount, + make_solid_frame(16, 16, olive::core::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count, olive::core::Color(0.5f, 0.5f, 0.5f, 1.0f)); - ASSERT_TRUE(olive::FrameHashCache::SaveCacheFrame(sub, uuid, 3, frame)); - ASSERT_TRUE(QFileInfo::exists(ExpectedFrameFile(sub, uuid, 3))); + ASSERT_TRUE(olive::FrameHashCache::save_cache_frame(sub, uuid, 3, frame)); + ASSERT_TRUE(QFileInfo::exists(expected_frame_file(sub, uuid, 3))); // Integer formats fall back to JPEG; the loader hardcodes 4 channels - olive::FramePtr loaded = olive::FrameHashCache::LoadCacheFrame(sub, uuid, 3); + olive::FramePtr loaded = olive::FrameHashCache::load_cache_frame(sub, uuid, 3); ASSERT_NE(loaded, nullptr); EXPECT_EQ(loaded->width(), 16); EXPECT_EQ(loaded->height(), 16); - EXPECT_EQ(loaded->format(), olive::core::PixelFormat::U8); + EXPECT_EQ(loaded->format(), olive::core::PixelFormat::u8); EXPECT_EQ(loaded->channel_count(), 4); // Gray is unaffected by channel order and survives JPEG nearly intact @@ -229,166 +229,166 @@ TEST_F(RenderDiskCacheTest, SaveAndLoadU8FrameRoundTripsThroughJpeg) TEST_F(RenderDiskCacheTest, SaveAndLoadWithEmptyCachePathFail) { olive::FramePtr frame = - MakeSolidFrame(4, 4, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount, + make_solid_frame(4, 4, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count, olive::core::Color(1.0f, 1.0f, 1.0f, 1.0f)); - EXPECT_FALSE(olive::FrameHashCache::SaveCacheFrame( + EXPECT_FALSE(olive::FrameHashCache::save_cache_frame( QString(), QUuid::createUuid(), 1, frame)); - EXPECT_EQ(olive::FrameHashCache::LoadCacheFrame( + EXPECT_EQ(olive::FrameHashCache::load_cache_frame( QString(), QUuid::createUuid(), 1), nullptr); } TEST_F(RenderDiskCacheTest, LoadOfMissingFileReturnsNull) { - const QString sub = MakeSubDir(QStringLiteral("missing")); + const QString sub = make_sub_dir(QStringLiteral("missing")); ASSERT_FALSE(sub.isEmpty()); - EXPECT_EQ(olive::FrameHashCache::LoadCacheFrame(sub, QUuid::createUuid(), + EXPECT_EQ(olive::FrameHashCache::load_cache_frame(sub, QUuid::createUuid(), 555), nullptr); } TEST_F(RenderDiskCacheTest, LoadingCorruptFileReturnsNullAndDeletesIt) { - const QString sub = MakeSubDir(QStringLiteral("corrupt")); + const QString sub = make_sub_dir(QStringLiteral("corrupt")); ASSERT_FALSE(sub.isEmpty()); const QUuid uuid = QUuid::createUuid(); - const QString fn = ExpectedFrameFile(sub, uuid, 999); + const QString fn = expected_frame_file(sub, uuid, 999); ASSERT_TRUE(QDir().mkpath(QFileInfo(fn).absolutePath())); - ASSERT_TRUE(WriteFile(fn, 64)); // neither EXR nor JPEG + ASSERT_TRUE(write_file(fn, 64)); // neither EXR nor JPEG // The corrupt frame must be registered for the disk manager to delete it - olive::DiskManager::instance()->CreatedFile(sub, fn); + olive::DiskManager::instance()->created_file(sub, fn); - EXPECT_EQ(olive::FrameHashCache::LoadCacheFrame(sub, uuid, 999), nullptr); + EXPECT_EQ(olive::FrameHashCache::load_cache_frame(sub, uuid, 999), nullptr); EXPECT_FALSE(QFileInfo::exists(fn)); } TEST_F(RenderDiskCacheTest, SavingUnsupportedPixelFormatFails) { - const QString sub = MakeSubDir(QStringLiteral("unsupported")); + const QString sub = make_sub_dir(QStringLiteral("unsupported")); ASSERT_FALSE(sub.isEmpty()); // U10 is a packed format with no EXR/QImage writer in FrameHashCache - olive::FramePtr frame = olive::Frame::Create(); + olive::FramePtr frame = olive::Frame::create(); frame->set_video_params( - olive::VideoParams(8, 8, olive::core::PixelFormat::U10, - olive::VideoParams::kRGBAChannelCount)); + olive::VideoParams(8, 8, olive::core::PixelFormat::u10, + olive::VideoParams::k_rgba_channel_count)); frame->allocate(); const QString fn = QDir(sub).filePath(QStringLiteral("u10_frame")); - EXPECT_FALSE(olive::FrameHashCache::SaveCacheFrame(fn, frame)); + EXPECT_FALSE(olive::FrameHashCache::save_cache_frame(fn, frame)); EXPECT_FALSE(QFileInfo::exists(fn)); } TEST_F(RenderDiskCacheTest, SaveCacheFrameRegistersFolderWithDiskManager) { - const QString sub = MakeSubDir(QStringLiteral("registered")); + const QString sub = make_sub_dir(QStringLiteral("registered")); ASSERT_FALSE(sub.isEmpty()); const QUuid uuid = QUuid::createUuid(); olive::FramePtr frame = - MakeSolidFrame(4, 4, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount, + make_solid_frame(4, 4, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count, olive::core::Color(0.0f, 0.0f, 0.0f, 1.0f)); olive::DiskManager *dm = olive::DiskManager::instance(); - const int folder_count_before = dm->GetOpenFolders().size(); + const int folder_count_before = dm->get_open_folders().size(); - ASSERT_TRUE(olive::FrameHashCache::SaveCacheFrame(sub, uuid, 42, frame)); + ASSERT_TRUE(olive::FrameHashCache::save_cache_frame(sub, uuid, 42, frame)); - EXPECT_EQ(dm->GetOpenFolders().size(), folder_count_before + 1); + EXPECT_EQ(dm->get_open_folders().size(), folder_count_before + 1); // Registration means the folder now tracks the file for deletion - olive::DiskCacheFolder *folder = dm->GetOpenFolder(sub); + olive::DiskCacheFolder *folder = dm->get_open_folder(sub); ASSERT_NE(folder, nullptr); - EXPECT_TRUE(folder->DeleteSpecificFile(ExpectedFrameFile(sub, uuid, 42))); + EXPECT_TRUE(folder->delete_specific_file(expected_frame_file(sub, uuid, 42))); } TEST_F(RenderDiskCacheTest, GetValidCacheFilenameRequiresValidatedFrame) { olive::FrameHashCache cache(project_.get()); - cache.SetTimebase(olive::core::rational(1, 30)); + cache.set_timebase(olive::core::Rational(1, 30)); - const olive::core::rational t(15, 30); - EXPECT_TRUE(cache.GetValidCacheFilename(t).isEmpty()); + const olive::core::Rational t(15, 30); + EXPECT_TRUE(cache.get_valid_cache_filename(t).isEmpty()); - cache.ValidateTimestamp(15); + cache.validate_timestamp(15); - const QString fn = cache.GetValidCacheFilename(t); - EXPECT_EQ(fn, ExpectedFrameFile(CacheRoot(), cache.GetUuid(), 15)); + const QString fn = cache.get_valid_cache_filename(t); + EXPECT_EQ(fn, expected_frame_file(cache_root(), cache.get_uuid(), 15)); } TEST_F(RenderDiskCacheTest, DeletingFrameThroughDiskManagerInvalidatesRange) { olive::FrameHashCache cache(project_.get()); - cache.SetTimebase(olive::core::rational(1, 30)); + cache.set_timebase(olive::core::Rational(1, 30)); olive::FramePtr frame = - MakeSolidFrame(4, 4, olive::core::PixelFormat::F32, - olive::VideoParams::kRGBAChannelCount, + make_solid_frame(4, 4, olive::core::PixelFormat::f32, + olive::VideoParams::k_rgba_channel_count, olive::core::Color(1.0f, 0.0f, 0.0f, 1.0f)); // Instance overloads resolve the cache dir/uuid from the parent project - ASSERT_TRUE(cache.SaveCacheFrame(15, frame)); + ASSERT_TRUE(cache.save_cache_frame(15, frame)); - const QString fn = ExpectedFrameFile(CacheRoot(), cache.GetUuid(), 15); + const QString fn = expected_frame_file(cache_root(), cache.get_uuid(), 15); ASSERT_TRUE(QFileInfo::exists(fn)); - ASSERT_NE(cache.LoadCacheFrame(15), nullptr); + ASSERT_NE(cache.load_cache_frame(15), nullptr); - const olive::core::rational t(15, 30); - cache.ValidateTimestamp(15); - ASSERT_TRUE(cache.IsFrameCached(t)); + const olive::core::Rational t(15, 30); + cache.validate_timestamp(15); + ASSERT_TRUE(cache.is_frame_cached(t)); // Deletion must propagate through DiskManager::DeletedFrame into HashDeleted - olive::DiskManager::instance()->DeleteSpecificFile(fn); + olive::DiskManager::instance()->delete_specific_file(fn); EXPECT_FALSE(QFileInfo::exists(fn)); - EXPECT_FALSE(cache.IsFrameCached(t)); + EXPECT_FALSE(cache.is_frame_cached(t)); } TEST_F(RenderDiskCacheTest, DiskDeletedSignalFromForeignCacheDoesNotInvalidate) { olive::FrameHashCache cache(project_.get()); - cache.SetTimebase(olive::core::rational(1, 30)); - cache.ValidateTimestamp(15); + cache.set_timebase(olive::core::Rational(1, 30)); + cache.validate_timestamp(15); - const olive::core::rational t(15, 30); - ASSERT_TRUE(cache.IsFrameCached(t)); + const olive::core::Rational t(15, 30); + ASSERT_TRUE(cache.is_frame_cached(t)); // Different cache directory: must be ignored emit olive::DiskManager::instance() - ->DeletedFrame(QStringLiteral("/some/other/cache"), + ->deleted_frame(QStringLiteral("/some/other/cache"), QStringLiteral("/some/other/cache/15")); - EXPECT_TRUE(cache.IsFrameCached(t)); + EXPECT_TRUE(cache.is_frame_cached(t)); // Same directory but a different cache UUID: must be ignored emit olive::DiskManager::instance() - ->DeletedFrame(CacheRoot(), - ExpectedFrameFile(CacheRoot(), QUuid::createUuid(), 15)); - EXPECT_TRUE(cache.IsFrameCached(t)); + ->deleted_frame(cache_root(), + expected_frame_file(cache_root(), QUuid::createUuid(), 15)); + EXPECT_TRUE(cache.is_frame_cached(t)); } TEST_F(RenderDiskCacheTest, InvalidateProjectSignalClearsValidatedRanges) { olive::FrameHashCache cache(project_.get()); - cache.SetTimebase(olive::core::rational(1, 30)); + cache.set_timebase(olive::core::Rational(1, 30)); - const olive::core::rational t(15, 30); - cache.ValidateTimestamp(15); - ASSERT_TRUE(cache.IsFrameCached(t)); + const olive::core::Rational t(15, 30); + cache.validate_timestamp(15); + ASSERT_TRUE(cache.is_frame_cached(t)); // An unrelated project must not invalidate this cache - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project other; - emit olive::DiskManager::instance()->InvalidateProject(&other); - EXPECT_TRUE(cache.IsFrameCached(t)); + emit olive::DiskManager::instance()->invalidate_project(&other); + EXPECT_TRUE(cache.is_frame_cached(t)); - emit olive::DiskManager::instance()->InvalidateProject(project_.get()); - EXPECT_FALSE(cache.IsFrameCached(t)); + emit olive::DiskManager::instance()->invalidate_project(project_.get()); + EXPECT_FALSE(cache.is_frame_cached(t)); } TEST_F(RenderDiskCacheTest, ValidatedStatePersistsAcrossCaches) @@ -397,77 +397,77 @@ TEST_F(RenderDiskCacheTest, ValidatedStatePersistsAcrossCaches) { olive::FrameHashCache cache(project_.get()); - cache.SetUuid(uuid); - cache.SetTimebase(olive::core::rational(1, 30)); - cache.ValidateTimestamp(15); + cache.set_uuid(uuid); + cache.set_timebase(olive::core::Rational(1, 30)); + cache.validate_timestamp(15); } const QString state_file = - QDir(QDir(CacheRoot()).filePath(uuid.toString())) + QDir(QDir(cache_root()).filePath(uuid.toString())) .filePath(QStringLiteral("state")); ASSERT_TRUE(QFileInfo::exists(state_file)); // SetUuid triggers LoadState, restoring timebase and validated ranges olive::FrameHashCache restored(project_.get()); - restored.SetUuid(uuid); + restored.set_uuid(uuid); - EXPECT_EQ(restored.GetTimebase(), olive::core::rational(1, 30)); - EXPECT_TRUE(restored.IsFrameCached(olive::core::rational(15, 30))); - EXPECT_FALSE(restored.IsFrameCached(olive::core::rational(16, 30))); + EXPECT_EQ(restored.get_timebase(), olive::core::Rational(1, 30)); + EXPECT_TRUE(restored.is_frame_cached(olive::core::Rational(15, 30))); + EXPECT_FALSE(restored.is_frame_cached(olive::core::Rational(16, 30))); } TEST_F(RenderDiskCacheTest, PassthroughProvidesFilenameForUnvalidatedFrame) { - const olive::core::rational tb(1, 30); + const olive::core::Rational tb(1, 30); olive::FrameHashCache source(project_.get()); - source.SetTimebase(tb); - source.ValidateTimestamp(15); + source.set_timebase(tb); + source.validate_timestamp(15); olive::FrameHashCache dest(project_.get()); - dest.SetPassthrough(&source); + dest.set_passthrough(&source); // SetPassthrough adopts the source cache's timebase - EXPECT_EQ(dest.GetTimebase(), tb); + EXPECT_EQ(dest.get_timebase(), tb); // The frame is not validated locally but the passthrough covers it - const olive::core::rational t(15, 30); - EXPECT_FALSE(dest.IsFrameCached(t)); - EXPECT_EQ(dest.GetValidCacheFilename(t), - ExpectedFrameFile(CacheRoot(), source.GetUuid(), 15)); + const olive::core::Rational t(15, 30); + EXPECT_FALSE(dest.is_frame_cached(t)); + EXPECT_EQ(dest.get_valid_cache_filename(t), + expected_frame_file(cache_root(), source.get_uuid(), 15)); } TEST_F(RenderDiskCacheTest, ThumbnailCacheUsesFixedTimebase) { olive::ThumbnailCache cache(project_.get()); - EXPECT_EQ(cache.GetTimebase(), olive::core::rational(1, 10)); + EXPECT_EQ(cache.get_timebase(), olive::core::Rational(1, 10)); } TEST_F(RenderDiskCacheTest, FolderDefaultsToTwentyGbLimit) { - const QString sub = MakeSubDir(QStringLiteral("folder_defaults")); + const QString sub = make_sub_dir(QStringLiteral("folder_defaults")); ASSERT_FALSE(sub.isEmpty()); olive::DiskCacheFolder folder(sub); - EXPECT_EQ(folder.GetPath(), sub); - EXPECT_EQ(folder.GetLimit(), 21474836480LL); // 20 GB - EXPECT_FALSE(folder.GetClearOnClose()); + EXPECT_EQ(folder.get_path(), sub); + EXPECT_EQ(folder.get_limit(), 21474836480LL); // 20 GB + EXPECT_FALSE(folder.get_clear_on_close()); } TEST_F(RenderDiskCacheTest, CreatedFileCanBeDeletedSpecifically) { - const QString sub = MakeSubDir(QStringLiteral("delete_specific")); + const QString sub = make_sub_dir(QStringLiteral("delete_specific")); ASSERT_FALSE(sub.isEmpty()); olive::DiskCacheFolder folder(sub); const QString fn = QDir(sub).filePath(QStringLiteral("frame1")); - ASSERT_TRUE(WriteFile(fn, 128)); - folder.CreatedFile(fn); + ASSERT_TRUE(write_file(fn, 128)); + folder.created_file(fn); - QSignalSpy spy(&folder, &olive::DiskCacheFolder::DeletedFrame); + QSignalSpy spy(&folder, &olive::DiskCacheFolder::deleted_frame); - EXPECT_TRUE(folder.DeleteSpecificFile(fn)); + EXPECT_TRUE(folder.delete_specific_file(fn)); EXPECT_FALSE(QFileInfo::exists(fn)); ASSERT_EQ(spy.count(), 1); @@ -476,28 +476,28 @@ TEST_F(RenderDiskCacheTest, CreatedFileCanBeDeletedSpecifically) EXPECT_EQ(args.at(1).toString(), fn); // A second deletion attempt fails, as does deleting an unknown file - EXPECT_FALSE(folder.DeleteSpecificFile(fn)); - EXPECT_FALSE(folder.DeleteSpecificFile( + EXPECT_FALSE(folder.delete_specific_file(fn)); + EXPECT_FALSE(folder.delete_specific_file( QDir(sub).filePath(QStringLiteral("never_registered")))); } TEST_F(RenderDiskCacheTest, ClearCacheRemovesAllRegisteredFiles) { - const QString sub = MakeSubDir(QStringLiteral("clear_cache")); + const QString sub = make_sub_dir(QStringLiteral("clear_cache")); ASSERT_FALSE(sub.isEmpty()); olive::DiskCacheFolder folder(sub); const QString f1 = QDir(sub).filePath(QStringLiteral("a")); const QString f2 = QDir(sub).filePath(QStringLiteral("b")); - ASSERT_TRUE(WriteFile(f1, 32)); - ASSERT_TRUE(WriteFile(f2, 32)); - folder.CreatedFile(f1); - folder.CreatedFile(f2); + ASSERT_TRUE(write_file(f1, 32)); + ASSERT_TRUE(write_file(f2, 32)); + folder.created_file(f1); + folder.created_file(f2); - QSignalSpy spy(&folder, &olive::DiskCacheFolder::DeletedFrame); + QSignalSpy spy(&folder, &olive::DiskCacheFolder::deleted_frame); - EXPECT_TRUE(folder.ClearCache()); + EXPECT_TRUE(folder.clear_cache()); EXPECT_FALSE(QFileInfo::exists(f1)); EXPECT_FALSE(QFileInfo::exists(f2)); EXPECT_EQ(spy.count(), 2); @@ -505,85 +505,85 @@ TEST_F(RenderDiskCacheTest, ClearCacheRemovesAllRegisteredFiles) TEST_F(RenderDiskCacheTest, ClearCacheToleratesExternallyRemovedFiles) { - const QString sub = MakeSubDir(QStringLiteral("clear_missing")); + const QString sub = make_sub_dir(QStringLiteral("clear_missing")); ASSERT_FALSE(sub.isEmpty()); olive::DiskCacheFolder folder(sub); const QString fn = QDir(sub).filePath(QStringLiteral("gone")); - ASSERT_TRUE(WriteFile(fn, 32)); - folder.CreatedFile(fn); + ASSERT_TRUE(write_file(fn, 32)); + folder.created_file(fn); ASSERT_TRUE(QFile::remove(fn)); // Already-missing files count as successfully cleared - EXPECT_TRUE(folder.ClearCache()); + EXPECT_TRUE(folder.clear_cache()); } TEST_F(RenderDiskCacheTest, FolderStatePersistsAcrossInstances) { - const QString sub = MakeSubDir(QStringLiteral("persist")); + const QString sub = make_sub_dir(QStringLiteral("persist")); ASSERT_FALSE(sub.isEmpty()); const QString fn = QDir(sub).filePath(QStringLiteral("persisted_frame")); - ASSERT_TRUE(WriteFile(fn, 64)); + ASSERT_TRUE(write_file(fn, 64)); { olive::DiskCacheFolder folder(sub); - folder.SetLimit(12345); - folder.CreatedFile(fn); + folder.set_limit(12345); + folder.created_file(fn); // Destruction writes the index file into the cache folder } { olive::DiskCacheFolder reopened(sub); - EXPECT_EQ(reopened.GetLimit(), 12345); - EXPECT_FALSE(reopened.GetClearOnClose()); + EXPECT_EQ(reopened.get_limit(), 12345); + EXPECT_FALSE(reopened.get_clear_on_close()); // The persisted entry is only known if the index was reloaded - EXPECT_TRUE(reopened.DeleteSpecificFile(fn)); + EXPECT_TRUE(reopened.delete_specific_file(fn)); EXPECT_FALSE(QFileInfo::exists(fn)); } } TEST_F(RenderDiskCacheTest, ExceedingLimitEvictsLeastRecentlyUsedFile) { - const QString sub = MakeSubDir(QStringLiteral("eviction")); + const QString sub = make_sub_dir(QStringLiteral("eviction")); ASSERT_FALSE(sub.isEmpty()); olive::DiskCacheFolder folder(sub); - folder.SetLimit(250); - EXPECT_EQ(folder.GetLimit(), 250); + folder.set_limit(250); + EXPECT_EQ(folder.get_limit(), 250); // Names are ordered so that even identical timestamps evict "aaa_evict" const QString keep = QDir(sub).filePath(QStringLiteral("zzz_keep")); const QString evict = QDir(sub).filePath(QStringLiteral("aaa_evict")); const QString newest = QDir(sub).filePath(QStringLiteral("bbb_newest")); - ASSERT_TRUE(WriteFile(keep, 100)); - folder.CreatedFile(keep); + ASSERT_TRUE(write_file(keep, 100)); + folder.created_file(keep); QThread::msleep(20); - ASSERT_TRUE(WriteFile(evict, 100)); - folder.CreatedFile(evict); + ASSERT_TRUE(write_file(evict, 100)); + folder.created_file(evict); // Both files fit within the limit ASSERT_TRUE(QFileInfo::exists(keep)); ASSERT_TRUE(QFileInfo::exists(evict)); // Unknown filenames are ignored by Accessed - folder.Accessed(QDir(sub).filePath(QStringLiteral("unknown"))); + folder.accessed(QDir(sub).filePath(QStringLiteral("unknown"))); QThread::msleep(20); // "keep" becomes the most recently used file - folder.Accessed(keep); + folder.accessed(keep); - QSignalSpy spy(&folder, &olive::DiskCacheFolder::DeletedFrame); + QSignalSpy spy(&folder, &olive::DiskCacheFolder::deleted_frame); - ASSERT_TRUE(WriteFile(newest, 100)); - folder.CreatedFile(newest); // 300 > 250, one eviction required + ASSERT_TRUE(write_file(newest, 100)); + folder.created_file(newest); // 300 > 250, one eviction required EXPECT_TRUE(QFileInfo::exists(keep)); EXPECT_FALSE(QFileInfo::exists(evict)); @@ -595,17 +595,17 @@ TEST_F(RenderDiskCacheTest, ExceedingLimitEvictsLeastRecentlyUsedFile) TEST_F(RenderDiskCacheTest, ClearOnCloseDeletesFilesWhenFolderCloses) { - const QString sub = MakeSubDir(QStringLiteral("clear_on_close")); + const QString sub = make_sub_dir(QStringLiteral("clear_on_close")); ASSERT_FALSE(sub.isEmpty()); const QString fn = QDir(sub).filePath(QStringLiteral("closing_frame")); - ASSERT_TRUE(WriteFile(fn, 32)); + ASSERT_TRUE(write_file(fn, 32)); { olive::DiskCacheFolder folder(sub); - folder.SetClearOnClose(true); - EXPECT_TRUE(folder.GetClearOnClose()); - folder.CreatedFile(fn); + folder.set_clear_on_close(true); + EXPECT_TRUE(folder.get_clear_on_close()); + folder.created_file(fn); } EXPECT_FALSE(QFileInfo::exists(fn)); @@ -616,22 +616,22 @@ TEST_F(RenderDiskCacheTest, DiskManagerOpenFolderDeduplicates) olive::DiskManager *dm = olive::DiskManager::instance(); ASSERT_NE(dm, nullptr); - const QString sub = MakeSubDir(QStringLiteral("dedupe")); + const QString sub = make_sub_dir(QStringLiteral("dedupe")); ASSERT_FALSE(sub.isEmpty()); - const int folder_count_before = dm->GetOpenFolders().size(); + const int folder_count_before = dm->get_open_folders().size(); - olive::DiskCacheFolder *first = dm->GetOpenFolder(sub); - olive::DiskCacheFolder *second = dm->GetOpenFolder(sub); + olive::DiskCacheFolder *first = dm->get_open_folder(sub); + olive::DiskCacheFolder *second = dm->get_open_folder(sub); ASSERT_NE(first, nullptr); EXPECT_EQ(first, second); - EXPECT_EQ(first->GetPath(), sub); - EXPECT_EQ(dm->GetOpenFolders().size(), folder_count_before + 1); + EXPECT_EQ(first->get_path(), sub); + EXPECT_EQ(dm->get_open_folders().size(), folder_count_before + 1); // An empty path resolves to the default cache folder - EXPECT_EQ(dm->GetOpenFolder(QString()), dm->GetDefaultCacheFolder()); - EXPECT_FALSE(dm->GetDefaultCachePath().isEmpty()); + EXPECT_EQ(dm->get_open_folder(QString()), dm->get_default_cache_folder()); + EXPECT_FALSE(dm->get_default_cache_path().isEmpty()); } TEST_F(RenderDiskCacheTest, DiskManagerClearDiskCacheRemovesFiles) @@ -639,14 +639,14 @@ TEST_F(RenderDiskCacheTest, DiskManagerClearDiskCacheRemovesFiles) olive::DiskManager *dm = olive::DiskManager::instance(); ASSERT_NE(dm, nullptr); - const QString sub = MakeSubDir(QStringLiteral("managed_clear")); + const QString sub = make_sub_dir(QStringLiteral("managed_clear")); ASSERT_FALSE(sub.isEmpty()); const QString fn = QDir(sub).filePath(QStringLiteral("managed_frame")); - ASSERT_TRUE(WriteFile(fn, 32)); - dm->CreatedFile(sub, fn); + ASSERT_TRUE(write_file(fn, 32)); + dm->created_file(sub, fn); ASSERT_TRUE(QFileInfo::exists(fn)); - EXPECT_TRUE(dm->ClearDiskCache(sub)); + EXPECT_TRUE(dm->clear_disk_cache(sub)); EXPECT_FALSE(QFileInfo::exists(fn)); } diff --git a/tests/gtest/render_ipc_test.cpp b/tests/gtest/render_ipc_test.cpp index 42df49f27..90e69d778 100644 --- a/tests/gtest/render_ipc_test.cpp +++ b/tests/gtest/render_ipc_test.cpp @@ -34,58 +34,58 @@ using namespace olive::ipc; TEST(SpscRingBuffer, BasicPushPopAndCapacity) { - std::vector mem(SpscRingBuffer::BytesNeeded(4)); - SpscRingBuffer *ring = SpscRingBuffer::Create(mem.data(), 4); + std::vector mem(SpscRingBuffer::bytes_needed(4)); + SpscRingBuffer *ring = SpscRingBuffer::create(mem.data(), 4); - EXPECT_TRUE(ring->IsEmptyApprox()); + EXPECT_TRUE(ring->is_empty_approx()); uint32_t v = 0; - EXPECT_FALSE(ring->Pop(&v)); // empty + EXPECT_FALSE(ring->pop(&v)); // empty // Capacity 4 holds at most 3 entries (one slot reserved to disambiguate full/empty). - EXPECT_TRUE(ring->Push(10)); - EXPECT_TRUE(ring->Push(20)); - EXPECT_TRUE(ring->Push(30)); - EXPECT_FALSE(ring->Push(40)); // full + EXPECT_TRUE(ring->push(10)); + EXPECT_TRUE(ring->push(20)); + EXPECT_TRUE(ring->push(30)); + EXPECT_FALSE(ring->push(40)); // full - EXPECT_TRUE(ring->Pop(&v)); + EXPECT_TRUE(ring->pop(&v)); EXPECT_EQ(v, 10u); - EXPECT_TRUE(ring->Pop(&v)); + EXPECT_TRUE(ring->pop(&v)); EXPECT_EQ(v, 20u); - EXPECT_TRUE(ring->Pop(&v)); + EXPECT_TRUE(ring->pop(&v)); EXPECT_EQ(v, 30u); - EXPECT_FALSE(ring->Pop(&v)); // empty again + EXPECT_FALSE(ring->pop(&v)); // empty again } TEST(SpscRingBuffer, WrapAround) { - std::vector mem(SpscRingBuffer::BytesNeeded(4)); - SpscRingBuffer *ring = SpscRingBuffer::Create(mem.data(), 4); + std::vector mem(SpscRingBuffer::bytes_needed(4)); + SpscRingBuffer *ring = SpscRingBuffer::create(mem.data(), 4); // Repeatedly pushing then popping single values forces the cursors past the backing array end. for (uint32_t i = 0; i < 100; i++) { - ASSERT_TRUE(ring->Push(i)); + ASSERT_TRUE(ring->push(i)); uint32_t got = 0; - ASSERT_TRUE(ring->Pop(&got)); + ASSERT_TRUE(ring->pop(&got)); EXPECT_EQ(got, i); } - EXPECT_TRUE(ring->IsEmptyApprox()); + EXPECT_TRUE(ring->is_empty_approx()); } TEST(SpscRingBuffer, ConcurrentProducerConsumer) { - constexpr uint32_t kCapacity = 1024; - constexpr uint32_t kCount = + constexpr uint32_t k_capacity = 1024; + constexpr uint32_t k_count = 2'000'000; // values 0..kCount-1 streamed through the ring - std::vector mem(SpscRingBuffer::BytesNeeded(kCapacity)); - SpscRingBuffer *ring = SpscRingBuffer::Create(mem.data(), kCapacity); + std::vector mem(SpscRingBuffer::bytes_needed(k_capacity)); + SpscRingBuffer *ring = SpscRingBuffer::create(mem.data(), k_capacity); std::atomic order_ok{ true }; std::thread producer([&] { - for (uint32_t i = 0; i < kCount; i++) { - while (!ring->Push(i)) { + for (uint32_t i = 0; i < k_count; i++) { + while (!ring->push(i)) { std::this_thread::yield(); // buffer full, spin until consumer drains } } @@ -94,9 +94,9 @@ TEST(SpscRingBuffer, ConcurrentProducerConsumer) std::thread consumer([&] { // Every value must arrive exactly once and strictly in order (FIFO). uint32_t expected = 0; - while (expected < kCount) { + while (expected < k_count) { uint32_t got = 0; - if (ring->Pop(&got)) { + if (ring->pop(&got)) { if (got != expected) { order_ok.store(false); return; @@ -112,7 +112,7 @@ TEST(SpscRingBuffer, ConcurrentProducerConsumer) consumer.join(); EXPECT_TRUE(order_ok.load()); - EXPECT_TRUE(ring->IsEmptyApprox()); + EXPECT_TRUE(ring->is_empty_approx()); } // ============================================================================ @@ -121,109 +121,109 @@ TEST(SpscRingBuffer, ConcurrentProducerConsumer) TEST(FrameSlotPool, SingleThreadedHandoff) { - constexpr uint32_t kSlots = 3; - constexpr size_t kSlotBytes = 256; + constexpr uint32_t k_slots = 3; + constexpr size_t k_slot_bytes = 256; - std::vector mem(FrameSlotPool::BytesNeeded(kSlots, kSlotBytes)); + std::vector mem(FrameSlotPool::bytes_needed(k_slots, k_slot_bytes)); FrameSlotPool filler = - FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes); - FrameSlotPool drainer = FrameSlotPool::Attach(mem.data()); + FrameSlotPool::create(mem.data(), k_slots, k_slot_bytes); + FrameSlotPool drainer = FrameSlotPool::attach(mem.data()); - ASSERT_TRUE(filler.IsValid()); - ASSERT_TRUE(drainer.IsValid()); - EXPECT_EQ(drainer.slot_count(), kSlots); - EXPECT_EQ(drainer.slot_data_bytes(), kSlotBytes); + ASSERT_TRUE(filler.is_valid()); + ASSERT_TRUE(drainer.is_valid()); + EXPECT_EQ(drainer.slot_count(), k_slots); + EXPECT_EQ(drainer.slot_data_bytes(), k_slot_bytes); // Fill one slot with a recognizable pattern + metadata, publish, then drain and verify. uint32_t idx = 0; - ASSERT_TRUE(filler.Acquire(&idx)); + ASSERT_TRUE(filler.acquire(&idx)); - auto *data = static_cast(filler.SlotData(idx)); - for (size_t i = 0; i < kSlotBytes; i++) { + auto *data = static_cast(filler.slot_data(idx)); + for (size_t i = 0; i < k_slot_bytes; i++) { data[i] = uint8_t(i & 0xFF); } - FrameSlotMeta *meta = filler.Meta(idx); + FrameSlotMeta *meta = filler.meta(idx); meta->id = 4242; meta->width = 16; meta->height = 8; - meta->data_size = int32_t(kSlotBytes); + meta->data_size = int32_t(k_slot_bytes); - ASSERT_TRUE(filler.Publish(idx)); + ASSERT_TRUE(filler.publish(idx)); uint32_t got_idx = 0; - ASSERT_TRUE(drainer.Consume(&got_idx)); + ASSERT_TRUE(drainer.consume(&got_idx)); EXPECT_EQ(got_idx, idx); - const FrameSlotMeta *got_meta = drainer.Meta(got_idx); + const FrameSlotMeta *got_meta = drainer.meta(got_idx); EXPECT_EQ(got_meta->id, 4242); EXPECT_EQ(got_meta->width, 16); const auto *got_data = - static_cast(drainer.SlotData(got_idx)); - for (size_t i = 0; i < kSlotBytes; i++) { + static_cast(drainer.slot_data(got_idx)); + for (size_t i = 0; i < k_slot_bytes; i++) { ASSERT_EQ(got_data[i], uint8_t(i & 0xFF)); } - EXPECT_TRUE(drainer.Release(got_idx)); + EXPECT_TRUE(drainer.release(got_idx)); } TEST(FrameSlotPool, ExhaustionAndRefill) { - constexpr uint32_t kSlots = 3; - constexpr size_t kSlotBytes = 64; + constexpr uint32_t k_slots = 3; + constexpr size_t k_slot_bytes = 64; - std::vector mem(FrameSlotPool::BytesNeeded(kSlots, kSlotBytes)); - FrameSlotPool pool = FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes); + std::vector mem(FrameSlotPool::bytes_needed(k_slots, k_slot_bytes)); + FrameSlotPool pool = FrameSlotPool::create(mem.data(), k_slots, k_slot_bytes); // Acquire every slot, then confirm the pool reports empty. std::vector held; - for (uint32_t i = 0; i < kSlots; i++) { + for (uint32_t i = 0; i < k_slots; i++) { uint32_t a = 0; - ASSERT_TRUE(pool.Acquire(&a)); + ASSERT_TRUE(pool.acquire(&a)); held.push_back(a); } uint32_t overflow = 0; - EXPECT_FALSE(pool.Acquire(&overflow)); // pool exhausted + EXPECT_FALSE(pool.acquire(&overflow)); // pool exhausted // Publishing then consuming + releasing returns the slots to the free pool. for (uint32_t idx : held) { - ASSERT_TRUE(pool.Publish(idx)); + ASSERT_TRUE(pool.publish(idx)); } - for (uint32_t i = 0; i < kSlots; i++) { + for (uint32_t i = 0; i < k_slots; i++) { uint32_t c = 0; - ASSERT_TRUE(pool.Consume(&c)); - ASSERT_TRUE(pool.Release(c)); + ASSERT_TRUE(pool.consume(&c)); + ASSERT_TRUE(pool.release(c)); } uint32_t again = 0; - EXPECT_TRUE(pool.Acquire(&again)); // free again + EXPECT_TRUE(pool.acquire(&again)); // free again } TEST(FrameSlotPool, ConcurrentFillDrainIntegrity) { - constexpr uint32_t kSlots = 8; - constexpr size_t kSlotBytes = 4096; - constexpr int64_t kFrames = 200'000; + constexpr uint32_t k_slots = 8; + constexpr size_t k_slot_bytes = 4096; + constexpr int64_t k_frames = 200'000; - std::vector mem(FrameSlotPool::BytesNeeded(kSlots, kSlotBytes)); + std::vector mem(FrameSlotPool::bytes_needed(k_slots, k_slot_bytes)); FrameSlotPool filler = - FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes); - FrameSlotPool drainer = FrameSlotPool::Attach(mem.data()); + FrameSlotPool::create(mem.data(), k_slots, k_slot_bytes); + FrameSlotPool drainer = FrameSlotPool::attach(mem.data()); std::atomic integrity_ok{ true }; // Filler: for each frame id, acquire a slot, stamp the id into meta and a pattern into the data, // publish. Spins when no slot is free (this is the natural backpressure path). std::thread fill_thread([&] { - for (int64_t id = 0; id < kFrames; id++) { + for (int64_t id = 0; id < k_frames; id++) { uint32_t idx = 0; - while (!filler.Acquire(&idx)) { + while (!filler.acquire(&idx)) { std::this_thread::yield(); } - filler.Meta(idx)->id = id; - auto *d = static_cast(filler.SlotData(idx)); + filler.meta(idx)->id = id; + auto *d = static_cast(filler.slot_data(idx)); const uint8_t pat = uint8_t(id & 0xFF); - memset(d, pat, kSlotBytes); - while (!filler.Publish(idx)) { + memset(d, pat, k_slot_bytes); + while (!filler.publish(idx)) { std::this_thread::yield(); // ready ring transiently full } } @@ -233,24 +233,24 @@ TEST(FrameSlotPool, ConcurrentFillDrainIntegrity) // then release the slot back to the filler. std::thread drain_thread([&] { int64_t expected = 0; - while (expected < kFrames) { + while (expected < k_frames) { uint32_t idx = 0; - if (!drainer.Consume(&idx)) { + if (!drainer.consume(&idx)) { std::this_thread::yield(); continue; } - const FrameSlotMeta *m = drainer.Meta(idx); + const FrameSlotMeta *m = drainer.meta(idx); if (m->id != expected) { integrity_ok.store(false); return; } - const auto *d = static_cast(drainer.SlotData(idx)); + const auto *d = static_cast(drainer.slot_data(idx)); const uint8_t pat = uint8_t(expected & 0xFF); - if (d[0] != pat || d[kSlotBytes - 1] != pat) { + if (d[0] != pat || d[k_slot_bytes - 1] != pat) { integrity_ok.store(false); return; } - while (!drainer.Release(idx)) { + while (!drainer.release(idx)) { std::this_thread::yield(); } expected++; @@ -283,7 +283,7 @@ TEST(IpcMessage, TypedRoundTrip) hs.output_slots = 6; hs.slot_data_bytes = 256ll * 1024 * 1024; hs.input_slot_data_bytes = 128ll * 1024 * 1024; - ASSERT_TRUE(WriteMessage(&dev, hs.ToJson())); + ASSERT_TRUE(write_message(&dev, hs.to_json())); RenderFrameMsg rf; rf.ticket_id = 99; @@ -297,12 +297,12 @@ TEST(IpcMessage, TypedRoundTrip) rf.mode = 1; rf.input_slot = 2; rf.input_slots = { 2, 3 }; - ASSERT_TRUE(WriteMessage(&dev, rf.ToJson())); + ASSERT_TRUE(write_message(&dev, rf.to_json())); FrameReadyMsg fr; fr.ticket_id = 99; fr.output_slot = 2; - ASSERT_TRUE(WriteMessage(&dev, fr.ToJson())); + ASSERT_TRUE(write_message(&dev, fr.to_json())); dev.close(); @@ -310,10 +310,10 @@ TEST(IpcMessage, TypedRoundTrip) QJsonObject obj; bool ok = false; - ASSERT_TRUE(ReadMessage(&reader, &obj, &ok)); + ASSERT_TRUE(read_message(&reader, &obj, &ok)); ASSERT_TRUE(ok); HandshakeMsg hs2; - ASSERT_TRUE(HandshakeMsg::FromJson(obj, &hs2)); + ASSERT_TRUE(HandshakeMsg::from_json(obj, &hs2)); EXPECT_EQ(hs2.protocol_version, 1); EXPECT_EQ(hs2.shm_key, hs.shm_key); EXPECT_EQ(hs2.input_shm_key, hs.input_shm_key); @@ -322,10 +322,10 @@ TEST(IpcMessage, TypedRoundTrip) EXPECT_EQ(hs2.slot_data_bytes, hs.slot_data_bytes); EXPECT_EQ(hs2.input_slot_data_bytes, hs.input_slot_data_bytes); - ASSERT_TRUE(ReadMessage(&reader, &obj, &ok)); + ASSERT_TRUE(read_message(&reader, &obj, &ok)); ASSERT_TRUE(ok); RenderFrameMsg rf2; - ASSERT_TRUE(RenderFrameMsg::FromJson(obj, &rf2)); + ASSERT_TRUE(RenderFrameMsg::from_json(obj, &rf2)); EXPECT_EQ(rf2.ticket_id, 99); EXPECT_EQ(rf2.node_uuid, rf.node_uuid); EXPECT_EQ(rf2.time_num, 1001); @@ -337,15 +337,15 @@ TEST(IpcMessage, TypedRoundTrip) EXPECT_EQ(rf2.input_slots[0], 2); EXPECT_EQ(rf2.input_slots[1], 3); - ASSERT_TRUE(ReadMessage(&reader, &obj, &ok)); + ASSERT_TRUE(read_message(&reader, &obj, &ok)); ASSERT_TRUE(ok); FrameReadyMsg fr2; - ASSERT_TRUE(FrameReadyMsg::FromJson(obj, &fr2)); + ASSERT_TRUE(FrameReadyMsg::from_json(obj, &fr2)); EXPECT_EQ(fr2.ticket_id, 99); EXPECT_EQ(fr2.output_slot, 2); // No more complete lines remain. - EXPECT_FALSE(ReadMessage(&reader, &obj, &ok)); + EXPECT_FALSE(read_message(&reader, &obj, &ok)); } TEST(IpcMessage, PartialFrameByteByByte) @@ -353,7 +353,7 @@ TEST(IpcMessage, PartialFrameByteByByte) CancelMsg c; c.ticket_id = 7; const QByteArray full = - QByteArray(QJsonDocument(c.ToJson()).toJson(QJsonDocument::Compact)) + + QByteArray(QJsonDocument(c.to_json()).toJson(QJsonDocument::Compact)) + '\n'; // Feed the bytes one at a time; ReadMessage must return false until the terminating '\n'. @@ -362,14 +362,14 @@ TEST(IpcMessage, PartialFrameByteByByte) bool ok = false; for (int i = 0; i < full.size() - 1; i++) { reader.append(full.at(i)); - ASSERT_FALSE(ReadMessage(&reader, &obj, &ok)); // no complete line yet + ASSERT_FALSE(read_message(&reader, &obj, &ok)); // no complete line yet } reader.append(full.at(full.size() - 1)); // the trailing newline - ASSERT_TRUE(ReadMessage(&reader, &obj, &ok)); + ASSERT_TRUE(read_message(&reader, &obj, &ok)); ASSERT_TRUE(ok); CancelMsg c2; - ASSERT_TRUE(CancelMsg::FromJson(obj, &c2)); + ASSERT_TRUE(CancelMsg::from_json(obj, &c2)); EXPECT_EQ(c2.ticket_id, 7); } @@ -379,7 +379,7 @@ TEST(IpcMessage, MalformedLineIsSkipped) QJsonObject obj; bool ok = true; // A complete but malformed line is consumed and reported as not-ok, leaving the buffer drained. - EXPECT_FALSE(ReadMessage(&reader, &obj, &ok)); + EXPECT_FALSE(read_message(&reader, &obj, &ok)); EXPECT_FALSE(ok); EXPECT_TRUE(reader.isEmpty()); } @@ -389,7 +389,7 @@ TEST(IpcMessage, BlankLinesAreSkippedSilently) CancelMsg c; c.ticket_id = 7; const QByteArray line = - QByteArray(QJsonDocument(c.ToJson()).toJson(QJsonDocument::Compact)) + + QByteArray(QJsonDocument(c.to_json()).toJson(QJsonDocument::Compact)) + '\n'; // Blank lines (even repeated) are consumed without flagging an error, and @@ -397,16 +397,16 @@ TEST(IpcMessage, BlankLinesAreSkippedSilently) QByteArray reader = QByteArray("\n \n\n") + line; QJsonObject obj; bool ok = false; - ASSERT_TRUE(ReadMessage(&reader, &obj, &ok)); + ASSERT_TRUE(read_message(&reader, &obj, &ok)); EXPECT_TRUE(ok); CancelMsg c2; - ASSERT_TRUE(CancelMsg::FromJson(obj, &c2)); + ASSERT_TRUE(CancelMsg::from_json(obj, &c2)); EXPECT_EQ(c2.ticket_id, 7); // Only blank lines left: nothing more to read, but still not an error. ok = true; - EXPECT_FALSE(ReadMessage(&reader, &obj, &ok)); + EXPECT_FALSE(read_message(&reader, &obj, &ok)); EXPECT_TRUE(ok); EXPECT_TRUE(reader.isEmpty()); } @@ -416,8 +416,8 @@ TEST(IpcMessage, WrongTypeRejected) // FromJson must reject an object whose "type" does not match the target struct. HandshakeMsg hs; hs.protocol_version = 1; - const QJsonObject obj = hs.ToJson(); + const QJsonObject obj = hs.to_json(); RenderFrameMsg rf; - EXPECT_FALSE(RenderFrameMsg::FromJson(obj, &rf)); + EXPECT_FALSE(RenderFrameMsg::from_json(obj, &rf)); } diff --git a/tests/gtest/render_loopmode_test.cpp b/tests/gtest/render_loopmode_test.cpp index 04f949c24..28b51468e 100644 --- a/tests/gtest/render_loopmode_test.cpp +++ b/tests/gtest/render_loopmode_test.cpp @@ -4,7 +4,7 @@ TEST(LoopMode, ValuesAreDistinct) { - EXPECT_NE(olive::LoopMode::kLoopModeOff, olive::LoopMode::kLoopModeLoop); - EXPECT_NE(olive::LoopMode::kLoopModeOff, olive::LoopMode::kLoopModeClamp); - EXPECT_NE(olive::LoopMode::kLoopModeLoop, olive::LoopMode::kLoopModeClamp); + EXPECT_NE(olive::LoopMode::k_loop_mode_off, olive::LoopMode::k_loop_mode_loop); + EXPECT_NE(olive::LoopMode::k_loop_mode_off, olive::LoopMode::k_loop_mode_clamp); + EXPECT_NE(olive::LoopMode::k_loop_mode_loop, olive::LoopMode::k_loop_mode_clamp); } diff --git a/tests/gtest/render_misc_test.cpp b/tests/gtest/render_misc_test.cpp index 4e8706fee..587c6a657 100644 --- a/tests/gtest/render_misc_test.cpp +++ b/tests/gtest/render_misc_test.cpp @@ -55,25 +55,25 @@ public: { } - bool Init() override + bool init() override { return true; } - void PostDestroy() override + void post_destroy() override { } - void PostInit() override + void post_init() override { } - void ClearDestination(olive::Texture *texture, double r, double g, double b, + void clear_destination(olive::Texture *texture, double r, double g, double b, double a) override { } - QVariant CreateNativeShader(olive::ShaderCode code) override + QVariant create_native_shader(olive::ShaderCode code) override { create_shader_count++; if (fail_create_shader) { @@ -82,12 +82,12 @@ public: return QVariant(QStringLiteral("shader%1").arg(create_shader_count)); } - void DestroyNativeShader(QVariant shader) override + void destroy_native_shader(QVariant shader) override { destroy_shader_count++; } - void UploadToTexture(const QVariant &handle, const olive::VideoParams ¶ms, + void upload_to_texture(const QVariant &handle, const olive::VideoParams ¶ms, const void *data, int linesize) override { upload_count++; @@ -95,7 +95,7 @@ public: last_upload_linesize = linesize; } - void DownloadFromTexture(const QVariant &handle, + void download_from_texture(const QVariant &handle, const olive::VideoParams ¶ms, void *data, int linesize) override { @@ -104,12 +104,12 @@ public: last_download_linesize = linesize; } - void Flush() override + void flush() override { flush_count++; } - olive::Color GetPixelFromTexture(olive::Texture *texture, + olive::Color get_pixel_from_texture(olive::Texture *texture, const QPointF &pt) override { return olive::Color(); @@ -148,7 +148,7 @@ public: bool last_blit_clear; protected: - void Blit(QVariant shader, olive::AcceleratedJob &job, + void blit(QVariant shader, olive::AcceleratedJob &job, olive::Texture *destination, olive::VideoParams destination_params, bool clear_destination) override @@ -160,7 +160,7 @@ protected: last_blit_clear = clear_destination; } - QVariant CreateNativeTexture(int width, int height, int depth, + QVariant create_native_texture(int width, int height, int depth, olive::PixelFormat format, int channel_count, const void *data, int linesize) override { @@ -177,26 +177,26 @@ protected: return QVariant(++next_handle); } - void DestroyNativeTexture(QVariant texture) override + void destroy_native_texture(QVariant texture) override { destroy_texture_count++; } - void DestroyInternal() override + void destroy_internal() override { destroy_internal_count++; } }; -olive::ColorProcessorPtr CreateIdentityProcessor() +olive::ColorProcessorPtr create_identity_processor() { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); - OCIO::MatrixTransformRcPtr transform = OCIO::MatrixTransform::Create(); - transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD); + ocio::MatrixTransformRcPtr transform = ocio::MatrixTransform::Create(); + transform->setDirection(ocio::TRANSFORM_DIR_FORWARD); - return olive::ColorProcessor::Create( - olive::ColorManager::GetDefaultConfig()->getProcessor(transform)); + return olive::ColorProcessor::create( + olive::ColorManager::get_default_config()->getProcessor(transform)); } } // namespace @@ -207,13 +207,13 @@ TEST(DynamicRenderer, ConstructorNormalizesBackendName) { olive::DynamicRenderer gl(QStringLiteral("OpenGL")); EXPECT_EQ(gl.backend_name(), QStringLiteral("opengl")); - EXPECT_TRUE(gl.IsOpenGL()); - EXPECT_FALSE(gl.IsVulkan()); + EXPECT_TRUE(gl.is_open_gl()); + EXPECT_FALSE(gl.is_vulkan()); olive::DynamicRenderer vk(QStringLiteral("VULKAN")); EXPECT_EQ(vk.backend_name(), QStringLiteral("vulkan")); - EXPECT_TRUE(vk.IsVulkan()); - EXPECT_FALSE(vk.IsOpenGL()); + EXPECT_TRUE(vk.is_vulkan()); + EXPECT_FALSE(vk.is_open_gl()); } // Documents that an unrecognized backend name is kept verbatim (and @@ -224,8 +224,8 @@ TEST(DynamicRenderer, UnknownBackendNameIsReportedVerbatim) { olive::DynamicRenderer renderer(QStringLiteral("Metal")); EXPECT_EQ(renderer.backend_name(), QStringLiteral("metal")); - EXPECT_FALSE(renderer.IsOpenGL()); - EXPECT_FALSE(renderer.IsVulkan()); + EXPECT_FALSE(renderer.is_open_gl()); + EXPECT_FALSE(renderer.is_vulkan()); } // Before Load() succeeds there is no backend handle, so the metadata and @@ -235,11 +235,11 @@ TEST(DynamicRenderer, AccessorsBeforeLoadReturnDefaults) { olive::DynamicRenderer renderer(QStringLiteral("opengl")); - EXPECT_EQ(renderer.OpenGLContext(), nullptr); + EXPECT_EQ(renderer.open_gl_context(), nullptr); OakRenderBackendInfo info = {}; - EXPECT_FALSE(renderer.GetBackendInfo(&info)); - EXPECT_FALSE(renderer.GetBackendInfo(nullptr)); + EXPECT_FALSE(renderer.get_backend_info(&info)); + EXPECT_FALSE(renderer.get_backend_info(nullptr)); } // Lifecycle entry points must tolerate being called without a loaded backend: @@ -248,11 +248,11 @@ TEST(DynamicRenderer, PreLoadLifecycleCallsAreSafeNoOps) { olive::DynamicRenderer renderer(QStringLiteral("opengl")); - renderer.PostInit(); - renderer.PostDestroy(); - renderer.AttachOutputTexture(nullptr); - renderer.DetachOutputTexture(); - renderer.Destroy(); + renderer.post_init(); + renderer.post_destroy(); + renderer.attach_output_texture(nullptr); + renderer.detach_output_texture(); + renderer.destroy(); // Destruction after an explicit Destroy() must also be safe. } @@ -264,13 +264,13 @@ TEST(DynamicRenderer, SecondLoadReturnsImmediately) GTEST_SKIP() << "Dynamic render backend is not enabled in this build"; #else olive::DynamicRenderer renderer(QStringLiteral("opengl")); - if (!renderer.Load()) { + if (!renderer.load()) { GTEST_SKIP() << "opengl backend library could not be loaded in this environment"; } - EXPECT_TRUE(renderer.Load()); - EXPECT_TRUE(renderer.IsOpenGL()); + EXPECT_TRUE(renderer.load()); + EXPECT_TRUE(renderer.is_open_gl()); EXPECT_EQ(renderer.backend_name(), QStringLiteral("opengl")); #endif } @@ -280,21 +280,21 @@ TEST(DynamicRenderer, SecondLoadReturnsImmediately) TEST(RendererTextureCache, CreateTextureWrapsNativeHandle) { StubRenderer renderer; - const olive::VideoParams params(64, 32, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(64, 32, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - olive::TexturePtr texture = renderer.CreateTexture(params); + olive::TexturePtr texture = renderer.create_texture(params); ASSERT_NE(texture, nullptr); - EXPECT_FALSE(texture->IsDummy()); + EXPECT_FALSE(texture->is_dummy()); EXPECT_EQ(texture->id(), QVariant(1)); EXPECT_EQ(texture->width(), 64); EXPECT_EQ(texture->height(), 32); - EXPECT_EQ(texture->format(), olive::PixelFormat::U8); + EXPECT_EQ(texture->format(), olive::PixelFormat::u8); EXPECT_EQ(texture->channel_count(), - int(olive::VideoParams::kRGBAChannelCount)); + int(olive::VideoParams::k_rgba_channel_count)); EXPECT_EQ(renderer.create_texture_count, 1); - renderer.Destroy(); + renderer.destroy(); } // A null native handle (backend allocation failure) must propagate as a null @@ -304,9 +304,9 @@ TEST(RendererTextureCache, FailedNativeTextureCreateReturnsNull) StubRenderer renderer; renderer.fail_create_texture = true; - const olive::VideoParams params(64, 64, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - EXPECT_EQ(renderer.CreateTexture(params), nullptr); + const olive::VideoParams params(64, 64, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + EXPECT_EQ(renderer.create_texture(params), nullptr); EXPECT_EQ(renderer.create_texture_count, 1); } @@ -316,33 +316,33 @@ TEST(RendererTextureCache, FailedNativeTextureCreateReturnsNull) TEST(RendererTextureCache, DestroyedTextureIsReusedFromCache) { StubRenderer renderer; - const olive::VideoParams params(64, 64, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(64, 64, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); { - olive::TexturePtr texture = renderer.CreateTexture(params); + olive::TexturePtr texture = renderer.create_texture(params); ASSERT_NE(texture, nullptr); EXPECT_EQ(texture->id(), QVariant(1)); } EXPECT_EQ(renderer.create_texture_count, 1); - olive::TexturePtr reused = renderer.CreateTexture(params); + olive::TexturePtr reused = renderer.create_texture(params); ASSERT_NE(reused, nullptr); EXPECT_EQ(reused->id(), QVariant(1)); EXPECT_EQ(renderer.create_texture_count, 1); EXPECT_EQ(renderer.flush_count, 1); // A different size must miss the cache and allocate natively again. - const olive::VideoParams other(32, 32, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::TexturePtr fresh = renderer.CreateTexture(other); + const olive::VideoParams other(32, 32, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::TexturePtr fresh = renderer.create_texture(other); ASSERT_NE(fresh, nullptr); EXPECT_EQ(fresh->id(), QVariant(2)); EXPECT_EQ(renderer.create_texture_count, 2); reused.reset(); fresh.reset(); - renderer.Destroy(); + renderer.destroy(); EXPECT_EQ(renderer.destroy_texture_count, 2); } @@ -351,17 +351,17 @@ TEST(RendererTextureCache, DestroyedTextureIsReusedFromCache) TEST(RendererTextureCache, CachedTextureReusedWithDataTriggersUpload) { StubRenderer renderer; - const olive::VideoParams params(16, 16, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); { - olive::TexturePtr texture = renderer.CreateTexture(params); + olive::TexturePtr texture = renderer.create_texture(params); ASSERT_NE(texture, nullptr); } char data[16 * 16 * 4] = {}; olive::TexturePtr texture = - renderer.CreateTexture(params, data, 16 * 4); + renderer.create_texture(params, data, 16 * 4); ASSERT_NE(texture, nullptr); EXPECT_EQ(renderer.create_texture_count, 1); EXPECT_EQ(renderer.upload_count, 1); @@ -369,7 +369,7 @@ TEST(RendererTextureCache, CachedTextureReusedWithDataTriggersUpload) EXPECT_EQ(renderer.last_upload_linesize, 16 * 4); texture.reset(); - renderer.Destroy(); + renderer.destroy(); } // On a cache miss with initial data, the data pointer and linesize must be @@ -377,11 +377,11 @@ TEST(RendererTextureCache, CachedTextureReusedWithDataTriggersUpload) TEST(RendererTextureCache, CreateWithDataForwardsToNativeCreate) { StubRenderer renderer; - const olive::VideoParams params(8, 8, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(8, 8, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); char data[8 * 8 * 4] = {}; - olive::TexturePtr texture = renderer.CreateTexture(params, data, 8 * 4); + olive::TexturePtr texture = renderer.create_texture(params, data, 8 * 4); ASSERT_NE(texture, nullptr); EXPECT_EQ(renderer.create_texture_count, 1); EXPECT_EQ(renderer.last_create_data, static_cast(data)); @@ -389,11 +389,11 @@ TEST(RendererTextureCache, CreateWithDataForwardsToNativeCreate) EXPECT_EQ(renderer.last_create_width, 8); EXPECT_EQ(renderer.last_create_height, 8); EXPECT_EQ(renderer.last_create_channel_count, - int(olive::VideoParams::kRGBAChannelCount)); + int(olive::VideoParams::k_rgba_channel_count)); EXPECT_EQ(renderer.upload_count, 0); texture.reset(); - renderer.Destroy(); + renderer.destroy(); } // GetDefaultShader() must compile the built-in shader once and cache it; @@ -402,18 +402,18 @@ TEST(RendererShaderCache, DefaultShaderCreatedOnceAndReleasedOnDestroy) { StubRenderer renderer; - const QVariant first = renderer.GetDefaultShader(); - const QVariant second = renderer.GetDefaultShader(); + const QVariant first = renderer.get_default_shader(); + const QVariant second = renderer.get_default_shader(); EXPECT_FALSE(first.isNull()); EXPECT_EQ(first, second); EXPECT_EQ(renderer.create_shader_count, 1); - renderer.Destroy(); + renderer.destroy(); EXPECT_EQ(renderer.destroy_shader_count, 1); EXPECT_EQ(renderer.destroy_internal_count, 1); // A repeated Destroy() must not release the shader a second time. - renderer.Destroy(); + renderer.destroy(); EXPECT_EQ(renderer.destroy_shader_count, 1); EXPECT_EQ(renderer.destroy_internal_count, 2); } @@ -423,66 +423,66 @@ TEST(RendererShaderCache, DefaultShaderCreatedOnceAndReleasedOnDestroy) TEST(TextureIo, UploadDownloadForwardToRenderer) { StubRenderer renderer; - const olive::VideoParams params(16, 16, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(16, 16, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - olive::TexturePtr texture = renderer.CreateTexture(params); + olive::TexturePtr texture = renderer.create_texture(params); ASSERT_NE(texture, nullptr); char data[16 * 16 * 4] = {}; - texture->Upload(data, 16 * 4); + texture->upload(data, 16 * 4); EXPECT_EQ(renderer.upload_count, 1); EXPECT_EQ(renderer.last_upload_handle, texture->id()); EXPECT_EQ(renderer.last_upload_linesize, 16 * 4); - texture->Download(data, 16 * 4); + texture->download(data, 16 * 4); EXPECT_EQ(renderer.download_count, 1); EXPECT_EQ(renderer.last_download_handle, texture->id()); EXPECT_EQ(renderer.last_download_linesize, 16 * 4); texture.reset(); - renderer.Destroy(); + renderer.destroy(); } // A dummy texture (no backend renderer) must expose its params, report // IsDummy(), and make Upload/Download harmless no-ops. TEST(TextureDummy, AccessorsAndNoOpIo) { - const olive::VideoParams params(128, 64, olive::PixelFormat::F16, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(128, 64, olive::PixelFormat::f16, + olive::VideoParams::k_rgba_channel_count); olive::Texture texture(params); - EXPECT_TRUE(texture.IsDummy()); + EXPECT_TRUE(texture.is_dummy()); EXPECT_EQ(texture.renderer(), nullptr); EXPECT_TRUE(texture.id().isNull()); EXPECT_EQ(texture.width(), 128); EXPECT_EQ(texture.height(), 64); EXPECT_EQ(texture.virtual_resolution(), QVector2D(128, 64)); - EXPECT_EQ(texture.format(), olive::PixelFormat::F16); + EXPECT_EQ(texture.format(), olive::PixelFormat::f16); EXPECT_EQ(texture.channel_count(), - int(olive::VideoParams::kRGBAChannelCount)); + int(olive::VideoParams::k_rgba_channel_count)); EXPECT_EQ(texture.divider(), 1); - EXPECT_EQ(texture.pixel_aspect_ratio(), olive::rational(1)); - EXPECT_FALSE(texture.IsJob()); + EXPECT_EQ(texture.pixel_aspect_ratio(), olive::Rational(1)); + EXPECT_FALSE(texture.is_job()); EXPECT_EQ(texture.job(), nullptr); char data[4] = {}; - texture.Upload(data, 4); - texture.Download(data, 4); + texture.upload(data, 4); + texture.download(data, 4); } // Textures can carry a CPU-side AcceleratedJob instead of a native handle; // the job must be owned and retrievable through job(). TEST(TextureJob, JobTextureExposesJob) { - const olive::VideoParams params(32, 32, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(32, 32, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); olive::TexturePtr texture = - olive::Texture::Job(params, olive::ShaderJob()); + olive::Texture::job(params, olive::ShaderJob()); ASSERT_NE(texture, nullptr); - EXPECT_TRUE(texture->IsDummy()); - EXPECT_TRUE(texture->IsJob()); + EXPECT_TRUE(texture->is_dummy()); + EXPECT_TRUE(texture->is_job()); ASSERT_NE(texture->job(), nullptr); EXPECT_EQ(texture->params().width(), 32); } @@ -495,15 +495,15 @@ TEST(RendererColorManagement, FallsBackToDefaultShaderWhenCompilationFails) StubRenderer renderer; renderer.fail_create_shader = true; - olive::ColorProcessorPtr processor = CreateIdentityProcessor(); + olive::ColorProcessorPtr processor = create_identity_processor(); ASSERT_TRUE(processor); olive::ColorTransformJob job; - job.SetColorProcessor(processor); + job.set_color_processor(processor); - const olive::VideoParams params(64, 64, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - renderer.BlitColorManaged(job, params); + const olive::VideoParams params(64, 64, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + renderer.blit_color_managed(job, params); // One blit to the null destination overload, with the (failed) default // shader handle and the job's clear-destination flag preserved. @@ -513,7 +513,7 @@ TEST(RendererColorManagement, FallsBackToDefaultShaderWhenCompilationFails) EXPECT_TRUE(renderer.last_blit_clear); EXPECT_EQ(renderer.last_blit_params.width(), 64); - renderer.Destroy(); + renderer.destroy(); } // GetColorContext must cache the compiled color pipeline per processor id: @@ -523,34 +523,34 @@ TEST(RendererColorManagement, CachesColorContextPerProcessorId) { StubRenderer renderer; - olive::ColorProcessorPtr processor = CreateIdentityProcessor(); + olive::ColorProcessorPtr processor = create_identity_processor(); ASSERT_TRUE(processor); olive::ColorTransformJob job; - job.SetColorProcessor(processor); + job.set_color_processor(processor); - const olive::VideoParams params(64, 64, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); + const olive::VideoParams params(64, 64, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); - renderer.BlitColorManaged(job, params); + renderer.blit_color_managed(job, params); EXPECT_EQ(renderer.blit_count, 1); EXPECT_EQ(renderer.create_shader_count, 1); EXPECT_FALSE(renderer.last_blit_shader.isNull()); // Same processor id: color context cache hit, no new shader compilation. - renderer.BlitColorManaged(job, params); + renderer.blit_color_managed(job, params); EXPECT_EQ(renderer.blit_count, 2); EXPECT_EQ(renderer.create_shader_count, 1); // A distinct override id bypasses the cached context and compiles again. olive::ColorTransformJob other_job; - other_job.SetColorProcessor(processor); - other_job.SetOverrideID(QStringLiteral("other-context")); - renderer.BlitColorManaged(other_job, params); + other_job.set_color_processor(processor); + other_job.set_override_id(QStringLiteral("other-context")); + renderer.blit_color_managed(other_job, params); EXPECT_EQ(renderer.blit_count, 3); EXPECT_EQ(renderer.create_shader_count, 2); - renderer.Destroy(); + renderer.destroy(); } // The destination overload of BlitColorManaged must forward the destination @@ -559,52 +559,52 @@ TEST(RendererColorManagement, BlitToDestinationForwardsTexture) { StubRenderer renderer; - olive::ColorProcessorPtr processor = CreateIdentityProcessor(); + olive::ColorProcessorPtr processor = create_identity_processor(); ASSERT_TRUE(processor); olive::ColorTransformJob job; - job.SetColorProcessor(processor); + job.set_color_processor(processor); - const olive::VideoParams params(32, 16, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - olive::TexturePtr destination = renderer.CreateTexture(params); + const olive::VideoParams params(32, 16, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + olive::TexturePtr destination = renderer.create_texture(params); ASSERT_NE(destination, nullptr); - renderer.BlitColorManaged(job, destination.get()); + renderer.blit_color_managed(job, destination.get()); EXPECT_EQ(renderer.blit_count, 1); EXPECT_EQ(renderer.last_blit_destination, destination.get()); EXPECT_EQ(renderer.last_blit_params.width(), 32); EXPECT_EQ(renderer.last_blit_params.height(), 16); destination.reset(); - renderer.Destroy(); + renderer.destroy(); } class RenderMiscAutoCacherTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); // Use the dummy render backend so PreviewAutoCacher can be exercised // without initializing OpenGL/Vulkan in the unit-test process. - olive::Config::Current()[QStringLiteral("GraphicsBackend")] = + olive::Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("dummy"); - olive::DiskManager::CreateInstance(); - olive::ConformManager::CreateInstance(); - olive::RenderManager::CreateInstance(); + olive::DiskManager::create_instance(); + olive::ConformManager::create_instance(); + olive::RenderManager::create_instance(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override { project_.reset(); - olive::RenderManager::DestroyInstance(); - olive::ConformManager::DestroyInstance(); - olive::DiskManager::DestroyInstance(); + olive::RenderManager::destroy_instance(); + olive::ConformManager::destroy_instance(); + olive::DiskManager::destroy_instance(); } std::unique_ptr project_; @@ -621,19 +621,19 @@ TEST_F(RenderMiscAutoCacherTest, GetSingleFrameCancelsPreviouslyQueuedTicket) olive::PreviewAutoCacher cacher; olive::RenderTicketPtr first = - cacher.GetSingleFrame(viewer, olive::rational(0)); + cacher.get_single_frame(viewer, olive::Rational(0)); olive::RenderTicketPtr second = - cacher.GetSingleFrame(viewer, olive::rational(1)); + cacher.get_single_frame(viewer, olive::Rational(1)); ASSERT_NE(first, nullptr); ASSERT_NE(second, nullptr); EXPECT_NE(first, second); - EXPECT_EQ(first->GetFinishCount(), 1); - EXPECT_FALSE(first->IsRunning()); - EXPECT_FALSE(first->HasResult()); + EXPECT_EQ(first->get_finish_count(), 1); + EXPECT_FALSE(first->is_running()); + EXPECT_FALSE(first->has_result()); - EXPECT_TRUE(second->IsRunning()); + EXPECT_TRUE(second->is_running()); } // SetProject() early-outs when the same project (or null twice) is passed; @@ -641,11 +641,11 @@ TEST_F(RenderMiscAutoCacherTest, GetSingleFrameCancelsPreviouslyQueuedTicket) TEST_F(RenderMiscAutoCacherTest, SetSameProjectTwiceIsNoOp) { olive::PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); - cacher.SetProject(project_.get()); - cacher.SetProject(nullptr); - cacher.SetProject(nullptr); - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + cacher.set_project(project_.get()); + cacher.set_project(project_.get()); + cacher.set_project(nullptr); + cacher.set_project(nullptr); + EXPECT_FALSE(cacher.is_rendering_custom_range()); } // ForceCacheRange queues the requested frames through TryRender; with the @@ -656,27 +656,27 @@ TEST_F(RenderMiscAutoCacherTest, { auto *viewer = new olive::ViewerOutput(); viewer->setParent(project_.get()); - viewer->SetVideoParams( - olive::VideoParams(64, 64, olive::rational(1, 25), - olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + viewer->set_video_params( + olive::VideoParams(64, 64, olive::Rational(1, 25), + olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); olive::PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); - QSignalSpy stop_spy(&cacher, &olive::PreviewAutoCacher::StopCacheProxyTasks); + QSignalSpy stop_spy(&cacher, &olive::PreviewAutoCacher::stop_cache_proxy_tasks); - cacher.ForceCacheRange( - viewer, olive::TimeRange(olive::rational(0), olive::rational(1, 25))); + cacher.force_cache_range( + viewer, olive::TimeRange(olive::Rational(0), olive::Rational(1, 25))); EXPECT_GE(stop_spy.count(), 1); - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + EXPECT_FALSE(cacher.is_rendering_custom_range()); // Deliver the queued RenderTicketWatcher::Finished emissions so the // completed watchers are reaped before teardown. QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // A conform-ready notification with no conform-blocked audio ranges must be a @@ -684,19 +684,19 @@ TEST_F(RenderMiscAutoCacherTest, TEST_F(RenderMiscAutoCacherTest, ConformReadyWithoutPendingConformsIsNoOp) { olive::PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); - QSignalSpy stop_spy(&cacher, &olive::PreviewAutoCacher::StopCacheProxyTasks); + QSignalSpy stop_spy(&cacher, &olive::PreviewAutoCacher::stop_cache_proxy_tasks); QSignalSpy progress_spy(&cacher, - &olive::PreviewAutoCacher::SignalCacheProxyTaskProgress); + &olive::PreviewAutoCacher::signal_cache_proxy_task_progress); - emit olive::ConformManager::instance()->ConformReady(); + emit olive::ConformManager::instance()->conform_ready(); EXPECT_EQ(stop_spy.count(), 0); EXPECT_EQ(progress_spy.count(), 0); - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + EXPECT_FALSE(cacher.is_rendering_custom_range()); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // Cancelling cache-proxy tasks must drop pending video jobs without touching @@ -705,27 +705,27 @@ TEST_F(RenderMiscAutoCacherTest, CacheProxyTaskCancelledClearsPendingJobs) { auto *viewer = new olive::ViewerOutput(); viewer->setParent(project_.get()); - viewer->SetVideoParams( - olive::VideoParams(64, 64, olive::rational(1, 25), - olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + viewer->set_video_params( + olive::VideoParams(64, 64, olive::Rational(1, 25), + olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); olive::PreviewAutoCacher cacher; // No project is set, so the forced range cannot be dispatched and sits in // the pending queue - cacher.ForceCacheRange( - viewer, olive::TimeRange(olive::rational(0), olive::rational(1))); - EXPECT_TRUE(cacher.IsRenderingCustomRange()); + cacher.force_cache_range( + viewer, olive::TimeRange(olive::Rational(0), olive::Rational(1))); + EXPECT_TRUE(cacher.is_rendering_custom_range()); - EXPECT_TRUE(QMetaObject::invokeMethod(&cacher, "CacheProxyTaskCancelled", + EXPECT_TRUE(QMetaObject::invokeMethod(&cacher, "cache_proxy_task_cancelled", Qt::DirectConnection)); // With the pending jobs cleared, the custom range is no longer being // rendered - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + EXPECT_FALSE(cacher.is_rendering_custom_range()); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // With an unknown/dummy graphics backend the RenderManager never creates the @@ -735,18 +735,18 @@ TEST_F(RenderMiscAutoCacherTest, CacheProxyTaskCancelledClearsPendingJobs) TEST(RenderManagerDummyBackend, GpuCacherMemberIsNullRatherThanUninitialized) { const QVariant previous = - olive::Config::Current()[QStringLiteral("GraphicsBackend")]; - olive::Config::Current()[QStringLiteral("GraphicsBackend")] = + olive::Config::current()[QStringLiteral("GraphicsBackend")]; + olive::Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("dummy"); - olive::RenderManager::CreateInstance(); + olive::RenderManager::create_instance(); EXPECT_EQ(olive::RenderManager::instance()->backend(), - olive::RenderManager::kDummy); + olive::RenderManager::k_dummy); EXPECT_EQ(olive::RenderManager::instance()->requested_backend(), - olive::RenderManager::kDummy); - EXPECT_EQ(olive::RenderManager::instance()->GetCacher(), nullptr); + olive::RenderManager::k_dummy); + EXPECT_EQ(olive::RenderManager::instance()->get_cacher(), nullptr); - olive::RenderManager::DestroyInstance(); - olive::Config::Current()[QStringLiteral("GraphicsBackend")] = previous; + olive::RenderManager::destroy_instance(); + olive::Config::current()[QStringLiteral("GraphicsBackend")] = previous; } diff --git a/tests/gtest/render_pixelformat_test.cpp b/tests/gtest/render_pixelformat_test.cpp index d0cccbb02..6eabcf501 100644 --- a/tests/gtest/render_pixelformat_test.cpp +++ b/tests/gtest/render_pixelformat_test.cpp @@ -6,23 +6,23 @@ TEST(RenderPixelFormat, ByteCountAndString) { using olive::core::PixelFormat; - EXPECT_EQ(PixelFormat::byte_count(PixelFormat::INVALID), 0); - EXPECT_EQ(PixelFormat::byte_count(PixelFormat::U8), 1); - EXPECT_EQ(PixelFormat::byte_count(PixelFormat::U16), 2); - EXPECT_EQ(PixelFormat::byte_count(PixelFormat::F16), 2); - EXPECT_EQ(PixelFormat::byte_count(PixelFormat::F32), 4); + EXPECT_EQ(PixelFormat::byte_count(PixelFormat::invalid), 0); + EXPECT_EQ(PixelFormat::byte_count(PixelFormat::u8), 1); + EXPECT_EQ(PixelFormat::byte_count(PixelFormat::u16), 2); + EXPECT_EQ(PixelFormat::byte_count(PixelFormat::f16), 2); + EXPECT_EQ(PixelFormat::byte_count(PixelFormat::f32), 4); - EXPECT_EQ(PixelFormat(PixelFormat::U8).to_string(), std::string("u8")); - EXPECT_EQ(PixelFormat(PixelFormat::INVALID).to_string(), std::string("")); + EXPECT_EQ(PixelFormat(PixelFormat::u8).to_string(), std::string("u8")); + EXPECT_EQ(PixelFormat(PixelFormat::invalid).to_string(), std::string("")); } TEST(RenderPixelFormat, FloatChecks) { using olive::core::PixelFormat; - EXPECT_FALSE(PixelFormat::is_float(PixelFormat::U8)); - EXPECT_FALSE(PixelFormat::is_float(PixelFormat::U16)); - EXPECT_TRUE(PixelFormat::is_float(PixelFormat::F16)); - EXPECT_TRUE(PixelFormat::is_float(PixelFormat::F32)); - EXPECT_FALSE(PixelFormat::is_float(PixelFormat::INVALID)); + EXPECT_FALSE(PixelFormat::is_float(PixelFormat::u8)); + EXPECT_FALSE(PixelFormat::is_float(PixelFormat::u16)); + EXPECT_TRUE(PixelFormat::is_float(PixelFormat::f16)); + EXPECT_TRUE(PixelFormat::is_float(PixelFormat::f32)); + EXPECT_FALSE(PixelFormat::is_float(PixelFormat::invalid)); } diff --git a/tests/gtest/render_processor_test.cpp b/tests/gtest/render_processor_test.cpp index 5dd1921a5..c516158f5 100644 --- a/tests/gtest/render_processor_test.cpp +++ b/tests/gtest/render_processor_test.cpp @@ -59,7 +59,7 @@ public: NODE_DEFAULT_FUNCTIONS(ConstantSampleNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Constant Sample Node"); } @@ -69,12 +69,12 @@ public: return QStringLiteral("org.oak.test.constant_sample_node"); } - virtual QVector Category() const override + virtual QVector category() const override { return {}; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { @@ -92,53 +92,53 @@ public: } } - table->Push(olive::NodeValue::kSamples, QVariant::fromValue(buffer), + table->push(olive::NodeValue::k_samples, QVariant::fromValue(buffer), this); } }; -olive::RenderTicketPtr MakeVideoTicket(olive::Node *node) +olive::RenderTicketPtr make_video_ticket(olive::Node *node) { olive::RenderTicketPtr ticket = std::make_shared(); - ticket->setProperty("node", olive::QtUtils::PtrToValue(node)); - ticket->setProperty("time", QVariant::fromValue(olive::rational(0))); + ticket->setProperty("node", olive::QtUtils::ptr_to_value(node)); + ticket->setProperty("time", QVariant::fromValue(olive::Rational(0))); ticket->setProperty( - "type", QVariant::fromValue(olive::RenderManager::kTypeVideo)); + "type", QVariant::fromValue(olive::RenderManager::k_type_video)); ticket->setProperty( "vparam", - QVariant::fromValue(olive::VideoParams(64, 64, olive::rational(1, 30), - olive::core::PixelFormat::U8, + QVariant::fromValue(olive::VideoParams(64, 64, olive::Rational(1, 30), + olive::core::PixelFormat::u8, 4))); ticket->setProperty("aparam", QVariant::fromValue(olive::core::AudioParams())); - ticket->setProperty("mode", int(olive::RenderMode::kOnline)); + ticket->setProperty("mode", int(olive::RenderMode::k_online)); return ticket; } -olive::RenderTicketPtr MakeAudioTicket(olive::Node *node, bool waveforms, +olive::RenderTicketPtr make_audio_ticket(olive::Node *node, bool waveforms, bool clamp) { olive::RenderTicketPtr ticket = std::make_shared(); - ticket->setProperty("node", olive::QtUtils::PtrToValue(node)); + ticket->setProperty("node", olive::QtUtils::ptr_to_value(node)); ticket->setProperty( "time", - QVariant::fromValue(olive::TimeRange(olive::rational(0), - olive::rational(1)))); + QVariant::fromValue(olive::TimeRange(olive::Rational(0), + olive::Rational(1)))); ticket->setProperty( - "type", QVariant::fromValue(olive::RenderManager::kTypeAudio)); + "type", QVariant::fromValue(olive::RenderManager::k_type_audio)); ticket->setProperty("enablewaveforms", waveforms); ticket->setProperty("clamp", clamp); ticket->setProperty( "aparam", QVariant::fromValue(olive::core::AudioParams( - 48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P))); + 48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p))); ticket->setProperty( "vparam", - QVariant::fromValue(olive::VideoParams(64, 64, olive::rational(1, 30), - olive::core::PixelFormat::U8, + QVariant::fromValue(olive::VideoParams(64, 64, olive::Rational(1, 30), + olive::core::PixelFormat::u8, 4))); - ticket->setProperty("mode", int(olive::RenderMode::kOnline)); + ticket->setProperty("mode", int(olive::RenderMode::k_online)); return ticket; } @@ -150,21 +150,21 @@ olive::RenderTicketPtr MakeAudioTicket(olive::Node *node, bool waveforms, TEST(RenderProcessor, AudioTicketRendersAndClampsSamples) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new ConstantSampleNode(); node->setParent(&project); - olive::RenderTicketPtr ticket = MakeAudioTicket(node, false, true); - ticket->Start(); + olive::RenderTicketPtr ticket = make_audio_ticket(node, false, true); + ticket->start(); - olive::RenderProcessor::Process(ticket, nullptr, nullptr, nullptr); + olive::RenderProcessor::process(ticket, nullptr, nullptr, nullptr); - ASSERT_TRUE(ticket->HasResult()); + ASSERT_TRUE(ticket->has_result()); olive::core::SampleBuffer samples = - ticket->Get().value(); + ticket->get().value(); ASSERT_TRUE(samples.is_allocated()); EXPECT_EQ(samples.channel_count(), 2); EXPECT_EQ(samples.sample_count(), size_t(48000)); @@ -180,21 +180,21 @@ TEST(RenderProcessor, AudioTicketRendersAndClampsSamples) TEST(RenderProcessor, AudioTicketWithoutClampKeepsSamples) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new ConstantSampleNode(); node->setParent(&project); - olive::RenderTicketPtr ticket = MakeAudioTicket(node, false, false); - ticket->Start(); + olive::RenderTicketPtr ticket = make_audio_ticket(node, false, false); + ticket->start(); - olive::RenderProcessor::Process(ticket, nullptr, nullptr, nullptr); + olive::RenderProcessor::process(ticket, nullptr, nullptr, nullptr); - ASSERT_TRUE(ticket->HasResult()); + ASSERT_TRUE(ticket->has_result()); olive::core::SampleBuffer samples = - ticket->Get().value(); + ticket->get().value(); ASSERT_TRUE(samples.is_allocated()); ASSERT_GT(samples.sample_count(), size_t(0)); @@ -206,19 +206,19 @@ TEST(RenderProcessor, AudioTicketWithoutClampKeepsSamples) TEST(RenderProcessor, AudioTicketGeneratesWaveformWhenRequested) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new ConstantSampleNode(); node->setParent(&project); - olive::RenderTicketPtr ticket = MakeAudioTicket(node, true, true); - ticket->Start(); + olive::RenderTicketPtr ticket = make_audio_ticket(node, true, true); + ticket->start(); - olive::RenderProcessor::Process(ticket, nullptr, nullptr, nullptr); + olive::RenderProcessor::process(ticket, nullptr, nullptr, nullptr); - ASSERT_TRUE(ticket->HasResult()); + ASSERT_TRUE(ticket->has_result()); const QVariant waveform_var = ticket->property("waveform"); ASSERT_TRUE(waveform_var.isValid()); @@ -229,70 +229,70 @@ TEST(RenderProcessor, AudioTicketGeneratesWaveformWhenRequested) TEST(RenderProcessor, AudioTicketWithoutNodeReturnsEmptyBuffer) { - olive::RenderTicketPtr ticket = MakeAudioTicket(nullptr, true, true); - ticket->Start(); + olive::RenderTicketPtr ticket = make_audio_ticket(nullptr, true, true); + ticket->start(); - olive::RenderProcessor::Process(ticket, nullptr, nullptr, nullptr); + olive::RenderProcessor::process(ticket, nullptr, nullptr, nullptr); // With no node to traverse the processor still finishes with a (null) // SampleBuffer, and skips both clamping and waveform generation. - ASSERT_TRUE(ticket->HasResult()); + ASSERT_TRUE(ticket->has_result()); const olive::core::SampleBuffer samples = - ticket->Get().value(); + ticket->get().value(); EXPECT_FALSE(samples.is_allocated()); EXPECT_FALSE(ticket->property("waveform").isValid()); } TEST(RenderProcessor, VideoTicketWithoutRendererFinishesWithoutResult) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - olive::RenderTicketPtr ticket = MakeVideoTicket(solid); - ticket->Start(); + olive::RenderTicketPtr ticket = make_video_ticket(solid); + ticket->start(); // A null render context is the "dry run": the graph is traversed (Solid // emits a shader job which is skipped) and the ticket finishes empty. - olive::RenderProcessor::Process(ticket, nullptr, nullptr, nullptr); + olive::RenderProcessor::process(ticket, nullptr, nullptr, nullptr); - EXPECT_FALSE(ticket->IsRunning()); - EXPECT_EQ(ticket->GetFinishCount(), 1); - EXPECT_FALSE(ticket->HasResult()); + EXPECT_FALSE(ticket->is_running()); + EXPECT_EQ(ticket->get_finish_count(), 1); + EXPECT_FALSE(ticket->has_result()); } TEST(RenderProcessor, VideoTicketWithoutNodeFinishesWithoutResult) { - olive::RenderTicketPtr ticket = MakeVideoTicket(nullptr); - ticket->Start(); + olive::RenderTicketPtr ticket = make_video_ticket(nullptr); + ticket->start(); - olive::RenderProcessor::Process(ticket, nullptr, nullptr, nullptr); + olive::RenderProcessor::process(ticket, nullptr, nullptr, nullptr); - EXPECT_FALSE(ticket->IsRunning()); - EXPECT_EQ(ticket->GetFinishCount(), 1); - EXPECT_FALSE(ticket->HasResult()); + EXPECT_FALSE(ticket->is_running()); + EXPECT_EQ(ticket->get_finish_count(), 1); + EXPECT_FALSE(ticket->has_result()); } TEST(RenderProcessor, CancelledTicketFinishesImmediately) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *solid = new olive::SolidGenerator(); solid->setParent(&project); - olive::RenderTicketPtr ticket = MakeVideoTicket(solid); - ticket->Start(); - ticket->Cancel(); + olive::RenderTicketPtr ticket = make_video_ticket(solid); + ticket->start(); + ticket->cancel(); - olive::RenderProcessor::Process(ticket, nullptr, nullptr, nullptr); + olive::RenderProcessor::process(ticket, nullptr, nullptr, nullptr); - EXPECT_EQ(ticket->GetFinishCount(), 1); - EXPECT_FALSE(ticket->HasResult()); + EXPECT_EQ(ticket->get_finish_count(), 1); + EXPECT_FALSE(ticket->has_result()); } // ============================================================================ @@ -301,23 +301,23 @@ TEST(RenderProcessor, CancelledTicketFinishesImmediately) TEST(RenderManagerParams, RenderVideoParamsDefaults) { - const olive::VideoParams vparams(1920, 1080, olive::core::PixelFormat::U8, + const olive::VideoParams vparams(1920, 1080, olive::core::PixelFormat::u8, 4); const olive::core::AudioParams aparams; olive::RenderManager::RenderVideoParams params(nullptr, vparams, aparams, - olive::rational(5), nullptr, - olive::RenderMode::kOnline); + olive::Rational(5), nullptr, + olive::RenderMode::k_online); EXPECT_EQ(params.node, nullptr); EXPECT_EQ(params.video_params, vparams); EXPECT_EQ(params.audio_params, aparams); - EXPECT_EQ(params.time, olive::rational(5)); + EXPECT_EQ(params.time, olive::Rational(5)); EXPECT_EQ(params.color_manager, nullptr); - EXPECT_EQ(params.mode, olive::RenderMode::kOnline); + EXPECT_EQ(params.mode, olive::RenderMode::k_online); EXPECT_FALSE(params.use_cache); - EXPECT_EQ(params.return_type, olive::RenderManager::kFrame); + EXPECT_EQ(params.return_type, olive::RenderManager::k_frame); EXPECT_EQ(params.multicam, nullptr); EXPECT_TRUE(params.cache_dir.isEmpty()); @@ -327,7 +327,7 @@ TEST(RenderManagerParams, RenderVideoParamsDefaults) EXPECT_EQ(params.force_channel_count, 0); EXPECT_TRUE(params.force_matrix.isIdentity()); EXPECT_EQ(int(params.force_format), - int(olive::core::PixelFormat::INVALID)); + int(olive::core::PixelFormat::invalid)); EXPECT_TRUE(params.force_color_output == nullptr); EXPECT_FALSE(params.force_color_transform.is_display()); EXPECT_TRUE(params.force_color_transform.output().isEmpty()); @@ -336,25 +336,25 @@ TEST(RenderManagerParams, RenderVideoParamsDefaults) TEST(RenderManagerParams, RenderAudioParamsDefaults) { const olive::core::AudioParams aparams( - 48000, olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); - const olive::TimeRange range(olive::rational(2), olive::rational(7)); + 48000, olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); + const olive::TimeRange range(olive::Rational(2), olive::Rational(7)); olive::RenderManager::RenderAudioParams params(nullptr, range, aparams, - olive::RenderMode::kOffline); + olive::RenderMode::k_offline); EXPECT_EQ(params.node, nullptr); EXPECT_EQ(params.range, range); EXPECT_EQ(params.audio_params, aparams); EXPECT_FALSE(params.generate_waveforms); EXPECT_TRUE(params.clamp); - EXPECT_EQ(params.mode, olive::RenderMode::kOffline); + EXPECT_EQ(params.mode, olive::RenderMode::k_offline); } TEST(RenderManagerParams, DryRunIntervalIsTenSeconds) { - EXPECT_EQ(olive::rational(olive::RenderManager::kDryRunInterval), - olive::rational(10)); + EXPECT_EQ(olive::Rational(olive::RenderManager::k_dry_run_interval), + olive::Rational(10)); } // ============================================================================ @@ -366,7 +366,7 @@ TEST(RenderJobTracker, EmptyTrackerIsNeverCurrent) olive::RenderJobTracker tracker; const olive::JobTime job; - EXPECT_FALSE(tracker.isCurrent(olive::rational(0), job)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(0), job)); EXPECT_TRUE( tracker.getCurrentSubRanges(olive::TimeRange(0, 10), job).isEmpty()); } @@ -380,8 +380,8 @@ TEST(RenderJobTracker, InsertedRangeIsCurrentForSameAndNewerJobs) tracker.insert(olive::TimeRange(0, 10), older); // A range rendered at job time T satisfies queries at T and later. - EXPECT_TRUE(tracker.isCurrent(olive::rational(5), older)); - EXPECT_TRUE(tracker.isCurrent(olive::rational(5), newer)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(5), older)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(5), newer)); } TEST(RenderJobTracker, IsCurrentRespectsRangeBoundaries) @@ -391,11 +391,11 @@ TEST(RenderJobTracker, IsCurrentRespectsRangeBoundaries) tracker.insert(olive::TimeRange(0, 10), job); - EXPECT_TRUE(tracker.isCurrent(olive::rational(0), job)); - EXPECT_FALSE(tracker.isCurrent(olive::rational(-1), job)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(0), job)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(-1), job)); // The out point is exclusive. - EXPECT_FALSE(tracker.isCurrent(olive::rational(10), job)); - EXPECT_FALSE(tracker.isCurrent(olive::rational(11), job)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(10), job)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(11), job)); } TEST(RenderJobTracker, ReinsertingSameRangeBumpsJobTime) @@ -405,13 +405,13 @@ TEST(RenderJobTracker, ReinsertingSameRangeBumpsJobTime) const olive::JobTime newer; tracker.insert(olive::TimeRange(0, 10), older); - EXPECT_TRUE(tracker.isCurrent(olive::rational(5), older)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(5), older)); tracker.insert(olive::TimeRange(0, 10), newer); // The older job no longer describes the cached content. - EXPECT_FALSE(tracker.isCurrent(olive::rational(5), older)); - EXPECT_TRUE(tracker.isCurrent(olive::rational(5), newer)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(5), older)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(5), newer)); } TEST(RenderJobTracker, InsertSplitsExistingRange) @@ -424,10 +424,10 @@ TEST(RenderJobTracker, InsertSplitsExistingRange) tracker.insert(olive::TimeRange(4, 6), newer); // The original range is split around the new one, keeping its job time. - EXPECT_TRUE(tracker.isCurrent(olive::rational(2), older)); - EXPECT_TRUE(tracker.isCurrent(olive::rational(8), older)); - EXPECT_FALSE(tracker.isCurrent(olive::rational(5), older)); - EXPECT_TRUE(tracker.isCurrent(olive::rational(5), newer)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(2), older)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(8), older)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(5), older)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(5), newer)); } TEST(RenderJobTracker, InsertTrimsOverlappingRangeEnds) @@ -439,11 +439,11 @@ TEST(RenderJobTracker, InsertTrimsOverlappingRangeEnds) tracker.insert(olive::TimeRange(0, 10), older); tracker.insert(olive::TimeRange(5, 15), newer); - EXPECT_TRUE(tracker.isCurrent(olive::rational(2), older)); - EXPECT_FALSE(tracker.isCurrent(olive::rational(7), older)); - EXPECT_TRUE(tracker.isCurrent(olive::rational(7), newer)); - EXPECT_TRUE(tracker.isCurrent(olive::rational(12), newer)); - EXPECT_FALSE(tracker.isCurrent(olive::rational(16), newer)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(2), older)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(7), older)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(7), newer)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(12), newer)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(16), newer)); } TEST(RenderJobTracker, InsertRangeListTagsAllRanges) @@ -456,9 +456,9 @@ TEST(RenderJobTracker, InsertRangeListTagsAllRanges) ranges.insert(olive::TimeRange(10, 15)); tracker.insert(ranges, job); - EXPECT_TRUE(tracker.isCurrent(olive::rational(2), job)); - EXPECT_TRUE(tracker.isCurrent(olive::rational(12), job)); - EXPECT_FALSE(tracker.isCurrent(olive::rational(7), job)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(2), job)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(12), job)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(7), job)); } TEST(RenderJobTracker, GetCurrentSubRangesClipsToQueryRange) @@ -509,10 +509,10 @@ TEST(RenderJobTracker, ClearDropsAllJobs) const olive::JobTime job; tracker.insert(olive::TimeRange(0, 10), job); - EXPECT_TRUE(tracker.isCurrent(olive::rational(5), job)); + EXPECT_TRUE(tracker.isCurrent(olive::Rational(5), job)); tracker.clear(); - EXPECT_FALSE(tracker.isCurrent(olive::rational(5), job)); + EXPECT_FALSE(tracker.isCurrent(olive::Rational(5), job)); } // ============================================================================ @@ -524,7 +524,7 @@ TEST(SubtitleParams, DefaultsAreEmptyEnabledStreamZero) const olive::SubtitleParams params; EXPECT_FALSE(params.is_valid()); - EXPECT_EQ(params.duration(), olive::rational(0)); + EXPECT_EQ(params.duration(), olive::Rational(0)); EXPECT_EQ(params.stream_index(), 0); EXPECT_TRUE(params.enabled()); } @@ -538,7 +538,7 @@ TEST(SubtitleParams, DurationFollowsLastSubtitle) olive::Subtitle(olive::TimeRange(3, 5), QStringLiteral("two"))); EXPECT_TRUE(params.is_valid()); - EXPECT_EQ(params.duration(), olive::rational(5)); + EXPECT_EQ(params.duration(), olive::Rational(5)); params.set_stream_index(3); params.set_enabled(false); @@ -563,7 +563,7 @@ TEST(SubtitleParams, SubtitleAccessorsRoundTrip) TEST(SubtitleParams, GenerateAssHeaderContainsRequiredSections) { - const QString header = olive::SubtitleParams::GenerateASSHeader(); + const QString header = olive::SubtitleParams::generate_ass_header(); EXPECT_TRUE(header.contains(QStringLiteral("[Script Info]\r\n"))); EXPECT_TRUE(header.contains(QStringLiteral("ScriptType: v4.00+\r\n"))); @@ -588,17 +588,17 @@ TEST(SubtitleParams, SaveLoadRoundTrip) params.set_stream_index(2); params.set_enabled(false); params.push_back(olive::Subtitle( - olive::TimeRange(olive::rational(0), olive::rational(1, 2)), + olive::TimeRange(olive::Rational(0), olive::Rational(1, 2)), QStringLiteral("Hello, world!"))); params.push_back(olive::Subtitle( - olive::TimeRange(olive::rational(3, 4), olive::rational(2)), + olive::TimeRange(olive::Rational(3, 4), olive::Rational(2)), QStringLiteral("Second & more"))); QString xml; { QXmlStreamWriter writer(&xml); writer.writeStartElement(QStringLiteral("root")); - params.Save(&writer); + params.save(&writer); writer.writeEndElement(); } @@ -609,16 +609,16 @@ TEST(SubtitleParams, SaveLoadRoundTrip) QXmlStreamReader reader(xml); ASSERT_TRUE(reader.readNextStartElement()); // position on - loaded.Load(&reader); + loaded.load(&reader); EXPECT_EQ(loaded.stream_index(), 2); EXPECT_FALSE(loaded.enabled()); ASSERT_EQ(loaded.size(), size_t(2)); - EXPECT_EQ(loaded.at(0).time().in(), olive::rational(0)); - EXPECT_EQ(loaded.at(0).time().out(), olive::rational(1, 2)); + EXPECT_EQ(loaded.at(0).time().in(), olive::Rational(0)); + EXPECT_EQ(loaded.at(0).time().out(), olive::Rational(1, 2)); EXPECT_EQ(loaded.at(0).text(), QStringLiteral("Hello, world!")); - EXPECT_EQ(loaded.at(1).time().in(), olive::rational(3, 4)); - EXPECT_EQ(loaded.at(1).time().out(), olive::rational(2)); + EXPECT_EQ(loaded.at(1).time().in(), olive::Rational(3, 4)); + EXPECT_EQ(loaded.at(1).time().out(), olive::Rational(2)); EXPECT_EQ(loaded.at(1).text(), QStringLiteral("Second & more")); } @@ -663,7 +663,7 @@ TEST(ManagedColor, ColorCopyConstructorPreservesChannels) TEST(ManagedColor, RawDataConstructorDecodesU8) { const char data[4] = { char(255), char(128), char(0), char(64) }; - const olive::ManagedColor color(data, olive::core::PixelFormat::U8, 4); + const olive::ManagedColor color(data, olive::core::PixelFormat::u8, 4); EXPECT_FLOAT_EQ(color.red(), 1.0f); EXPECT_NEAR(color.green(), 128.0 / 255.0, 1e-6); @@ -697,30 +697,30 @@ TEST(ManagedColor, ColorInputAndOutputRoundTrip) TEST(RenderTexture, DummyTextureExposesParams) { - const olive::VideoParams params(320, 240, olive::core::PixelFormat::U8, 4); + const olive::VideoParams params(320, 240, olive::core::PixelFormat::u8, 4); olive::Texture texture(params); - EXPECT_TRUE(texture.IsDummy()); + EXPECT_TRUE(texture.is_dummy()); EXPECT_EQ(texture.renderer(), nullptr); EXPECT_EQ(texture.params(), params); EXPECT_EQ(texture.width(), 320); EXPECT_EQ(texture.height(), 240); EXPECT_EQ(texture.channel_count(), 4); EXPECT_EQ(texture.divider(), 1); - EXPECT_EQ(texture.pixel_aspect_ratio(), olive::rational(1)); + EXPECT_EQ(texture.pixel_aspect_ratio(), olive::Rational(1)); EXPECT_EQ(texture.virtual_resolution(), QVector2D(320, 240)); - EXPECT_EQ(int(texture.format()), int(olive::core::PixelFormat::U8)); + EXPECT_EQ(int(texture.format()), int(olive::core::PixelFormat::u8)); EXPECT_FALSE(texture.id().isValid()); - EXPECT_FALSE(texture.IsJob()); + EXPECT_FALSE(texture.is_job()); EXPECT_EQ(texture.job(), nullptr); EXPECT_TRUE(texture.frame() == nullptr); } TEST(RenderTexture, DummyTextureHonorsDivider) { - const olive::VideoParams params(320, 240, olive::core::PixelFormat::U8, 4, - olive::rational(1), - olive::VideoParams::kInterlaceNone, 2); + const olive::VideoParams params(320, 240, olive::core::PixelFormat::u8, 4, + olive::Rational(1), + olive::VideoParams::k_interlace_none, 2); const olive::Texture texture(params); EXPECT_EQ(texture.divider(), 2); @@ -730,52 +730,52 @@ TEST(RenderTexture, DummyTextureHonorsDivider) TEST(RenderTexture, JobTextureCarriesJobAndParams) { - const olive::VideoParams params(64, 64, olive::core::PixelFormat::F32, 4); + const olive::VideoParams params(64, 64, olive::core::PixelFormat::f32, 4); olive::AcceleratedJob job; - job.Insert(QStringLiteral("value_in"), - olive::NodeValue(olive::NodeValue::kFloat, 2.5)); + job.insert(QStringLiteral("value_in"), + olive::NodeValue(olive::NodeValue::k_float, 2.5)); - const olive::TexturePtr texture = olive::Texture::Job(params, job); + const olive::TexturePtr texture = olive::Texture::job(params, job); ASSERT_TRUE(texture != nullptr); - EXPECT_TRUE(texture->IsDummy()); - EXPECT_TRUE(texture->IsJob()); + EXPECT_TRUE(texture->is_dummy()); + EXPECT_TRUE(texture->is_job()); ASSERT_TRUE(texture->job() != nullptr); EXPECT_TRUE( - texture->job()->GetValues().contains(QStringLiteral("value_in"))); - EXPECT_EQ(texture->job()->Get(QStringLiteral("value_in")).toDouble(), 2.5); + texture->job()->get_values().contains(QStringLiteral("value_in"))); + EXPECT_EQ(texture->job()->get(QStringLiteral("value_in")).to_double(), 2.5); EXPECT_EQ(texture->params(), params); } TEST(RenderTexture, ToJobCreatesJobTextureWithSameParams) { - const olive::VideoParams params(128, 72, olive::core::PixelFormat::U8, 4); + const olive::VideoParams params(128, 72, olive::core::PixelFormat::u8, 4); olive::Texture dummy(params); const olive::AcceleratedJob job; - const olive::TexturePtr job_tex = dummy.toJob(job); + const olive::TexturePtr job_tex = dummy.to_job(job); ASSERT_TRUE(job_tex != nullptr); - EXPECT_FALSE(dummy.IsJob()); - EXPECT_TRUE(job_tex->IsJob()); + EXPECT_FALSE(dummy.is_job()); + EXPECT_TRUE(job_tex->is_job()); EXPECT_EQ(job_tex->params(), dummy.params()); } TEST(RenderTexture, UploadDownloadOnDummyAreNoOps) { - const olive::VideoParams params(16, 16, olive::core::PixelFormat::U8, 4); + const olive::VideoParams params(16, 16, olive::core::PixelFormat::u8, 4); olive::Texture texture(params); // With no renderer backend both calls must return without touching data. uint8_t buffer[16 * 16 * 4]; memset(buffer, 0xAB, sizeof(buffer)); - texture.Upload(buffer, 16 * 4); - texture.Download(buffer, 16 * 4); + texture.upload(buffer, 16 * 4); + texture.download(buffer, 16 * 4); EXPECT_EQ(buffer[0], uint8_t(0xAB)); } TEST(RenderTexture, DefaultInterpolationIsMipmappedLinear) { - EXPECT_EQ(int(olive::Texture::kDefaultInterpolation), - int(olive::Texture::kMipmappedLinear)); + EXPECT_EQ(int(olive::Texture::k_default_interpolation), + int(olive::Texture::k_mipmapped_linear)); } diff --git a/tests/gtest/render_projectcopier_test.cpp b/tests/gtest/render_projectcopier_test.cpp index d46ee5d52..184eef414 100644 --- a/tests/gtest/render_projectcopier_test.cpp +++ b/tests/gtest/render_projectcopier_test.cpp @@ -37,7 +37,7 @@ public: { } - using olive::PlaybackCache::Validate; + using olive::PlaybackCache::validate; int invalidate_event_count = 0; int load_state_event_count = 0; @@ -70,7 +70,7 @@ protected: GTEST_FAIL() << "Failed to create temporary directory"; } - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); if (!olive::Core::instance()) { // Leaked intentionally: Core is process-wide (matches @@ -78,33 +78,33 @@ protected: new olive::Core(olive::Core::CoreParams()); } - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); // Point the project cache at a folder alongside the (unsaved) project // file so every cache read/write stays inside the temporary directory. project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); project_->set_filename( QDir(temp_dir_.path()).filePath(QStringLiteral("test.ove"))); - project_->SetCacheLocationSetting( - olive::Project::kCacheStoreAlongsideProject); + project_->set_cache_location_setting( + olive::Project::k_cache_store_alongside_project); } void TearDown() override { copier_.reset(); project_.reset(); - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } - template T *AddNode() + template T *add_node() { T *node = new T(); node->setParent(project_.get()); return node; } - QString CacheRoot() const + QString cache_root() const { return QDir(temp_dir_.path()).filePath(QStringLiteral("cache")); } @@ -122,20 +122,20 @@ class RenderPlaybackCacheTest : public RenderCopierTestBase { TEST_F(RenderProjectCopierTest, CopyIsSeparateProjectWithSameStructure) { - auto *math_a = AddNode(); - auto *math_b = AddNode(); - AddNode(); + auto *math_a = add_node(); + auto *math_b = add_node(); + add_node(); - olive::Node::ConnectEdge( - math_a, olive::NodeInput(math_b, olive::MathNode::kParamAIn)); + olive::Node::connect_edge( + math_a, olive::NodeInput(math_b, olive::MathNode::k_param_a_in)); - project_->SetSetting(QStringLiteral("copier_test_key"), + project_->set_setting(QStringLiteral("copier_test_key"), QStringLiteral("copier_test_value")); copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - olive::Project *copy = copier_->GetCopiedProject(); + olive::Project *copy = copier_->get_copied_project(); ASSERT_NE(copy, nullptr); EXPECT_NE(copy, project_.get()); @@ -144,64 +144,64 @@ TEST_F(RenderProjectCopierTest, CopyIsSeparateProjectWithSameStructure) // Same number of nodes, same IDs, different objects ASSERT_EQ(copy->nodes().size(), project_->nodes().size()); - EXPECT_EQ(copier_->GetNodeMap().size(), project_->nodes().size()); + EXPECT_EQ(copier_->get_node_map().size(), project_->nodes().size()); for (olive::Node *original : project_->nodes()) { - olive::Node *cloned = copier_->GetCopy(original); + olive::Node *cloned = copier_->get_copy(original); ASSERT_NE(cloned, nullptr); EXPECT_NE(cloned, original); EXPECT_EQ(cloned->id(), original->id()); - EXPECT_EQ(copier_->GetOriginal(cloned), original); + EXPECT_EQ(copier_->get_original(cloned), original); EXPECT_TRUE(copy->nodes().contains(cloned)); } // Settings were copied - EXPECT_EQ(copy->GetSetting(QStringLiteral("copier_test_key")), + EXPECT_EQ(copy->get_setting(QStringLiteral("copier_test_key")), QStringLiteral("copier_test_value")); // The pre-existing edge was recreated between the copies - olive::Node *copy_a = copier_->GetCopy(math_a); - olive::Node *copy_b = copier_->GetCopy(math_b); + olive::Node *copy_a = copier_->get_copy(math_a); + olive::Node *copy_b = copier_->get_copy(math_b); ASSERT_EQ(copy_b->input_connections().size(), 1); EXPECT_EQ(copy_b->input_connections().at( - olive::NodeInput(copy_b, olive::MathNode::kParamAIn)), + olive::NodeInput(copy_b, olive::MathNode::k_param_a_in)), copy_a); // SetProject applies the initial sync synchronously - EXPECT_FALSE(copier_->HasUpdatesInQueue()); + EXPECT_FALSE(copier_->has_updates_in_queue()); } TEST_F(RenderProjectCopierTest, CopiedNodesHaveDisabledCachesAndSharedUuids) { - auto *math = AddNode(); + auto *math = add_node(); copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - olive::Node *copy = copier_->GetCopy(math); + olive::Node *copy = copier_->get_copy(math); ASSERT_NE(copy, nullptr); // Caches are disabled on the render-proxy copy but keep the same UUIDs so // the copy can read frames written by the original - EXPECT_TRUE(math->AreCachesEnabled()); - EXPECT_FALSE(copy->AreCachesEnabled()); - EXPECT_EQ(copy->video_frame_cache()->GetUuid(), - math->video_frame_cache()->GetUuid()); - EXPECT_EQ(copy->audio_playback_cache()->GetUuid(), - math->audio_playback_cache()->GetUuid()); + EXPECT_TRUE(math->are_caches_enabled()); + EXPECT_FALSE(copy->are_caches_enabled()); + EXPECT_EQ(copy->video_frame_cache()->get_uuid(), + math->video_frame_cache()->get_uuid()); + EXPECT_EQ(copy->audio_playback_cache()->get_uuid(), + math->audio_playback_cache()->get_uuid()); } TEST_F(RenderProjectCopierTest, AddedNodeSignalFiresForEachCopiedNode) { - AddNode(); - AddNode(); + add_node(); + add_node(); copier_ = std::make_unique(); QVector added; - QObject::connect(copier_.get(), &olive::ProjectCopier::AddedNode, + QObject::connect(copier_.get(), &olive::ProjectCopier::added_node, [&added](olive::Node *n) { added.append(n); }); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); // One signal per node in the original project (color manager, root folder, // and the two nodes added above), carrying the *original* pointers @@ -214,87 +214,87 @@ TEST_F(RenderProjectCopierTest, AddedNodeSignalFiresForEachCopiedNode) TEST_F(RenderProjectCopierTest, QueuedNodeAddIsAppliedByProcessUpdateQueue) { copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); QVector added; - QObject::connect(copier_.get(), &olive::ProjectCopier::AddedNode, + QObject::connect(copier_.get(), &olive::ProjectCopier::added_node, [&added](olive::Node *n) { added.append(n); }); - auto *math = AddNode(); + auto *math = add_node(); // The change is queued, not applied immediately - EXPECT_TRUE(copier_->HasUpdatesInQueue()); - EXPECT_EQ(copier_->GetCopy(math), nullptr); + EXPECT_TRUE(copier_->has_updates_in_queue()); + EXPECT_EQ(copier_->get_copy(math), nullptr); EXPECT_TRUE(added.isEmpty()); - copier_->ProcessUpdateQueue(); + copier_->process_update_queue(); - EXPECT_FALSE(copier_->HasUpdatesInQueue()); - olive::Node *copy = copier_->GetCopy(math); + EXPECT_FALSE(copier_->has_updates_in_queue()); + olive::Node *copy = copier_->get_copy(math); ASSERT_NE(copy, nullptr); EXPECT_EQ(copy->id(), math->id()); - EXPECT_TRUE(copier_->GetCopiedProject()->nodes().contains(copy)); + EXPECT_TRUE(copier_->get_copied_project()->nodes().contains(copy)); ASSERT_EQ(added.size(), 1); EXPECT_EQ(added.first(), math); // Processing the queue marked the copy as modified - EXPECT_TRUE(copier_->GetCopiedProject()->is_modified()); + EXPECT_TRUE(copier_->get_copied_project()->is_modified()); } TEST_F(RenderProjectCopierTest, QueuedNodeRemoveDeletesCopy) { - auto *math = AddNode(); + auto *math = add_node(); copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - olive::Node *copy = copier_->GetCopy(math); + olive::Node *copy = copier_->get_copy(math); ASSERT_NE(copy, nullptr); QVector removed; - QObject::connect(copier_.get(), &olive::ProjectCopier::RemovedNode, + QObject::connect(copier_.get(), &olive::ProjectCopier::removed_node, [&removed](olive::Node *n) { removed.append(n); }); delete math; - EXPECT_TRUE(copier_->HasUpdatesInQueue()); + EXPECT_TRUE(copier_->has_updates_in_queue()); - copier_->ProcessUpdateQueue(); + copier_->process_update_queue(); - EXPECT_FALSE(copier_->HasUpdatesInQueue()); + EXPECT_FALSE(copier_->has_updates_in_queue()); ASSERT_EQ(removed.size(), 1); EXPECT_EQ(removed.first(), math); - EXPECT_EQ(copier_->GetCopy(math), nullptr); - EXPECT_FALSE(copier_->GetCopiedProject()->nodes().contains(copy)); + EXPECT_EQ(copier_->get_copy(math), nullptr); + EXPECT_FALSE(copier_->get_copied_project()->nodes().contains(copy)); } TEST_F(RenderProjectCopierTest, QueuedEdgeAddAndRemoveAreMirrored) { - auto *src = AddNode(); - auto *dst = AddNode(); + auto *src = add_node(); + auto *dst = add_node(); copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - olive::Node *copy_src = copier_->GetCopy(src); - olive::Node *copy_dst = copier_->GetCopy(dst); + olive::Node *copy_src = copier_->get_copy(src); + olive::Node *copy_dst = copier_->get_copy(dst); ASSERT_NE(copy_src, nullptr); ASSERT_NE(copy_dst, nullptr); - olive::Node::ConnectEdge( - src, olive::NodeInput(dst, olive::MathNode::kParamAIn)); - EXPECT_TRUE(copier_->HasUpdatesInQueue()); + olive::Node::connect_edge( + src, olive::NodeInput(dst, olive::MathNode::k_param_a_in)); + EXPECT_TRUE(copier_->has_updates_in_queue()); EXPECT_TRUE(copy_dst->input_connections().empty()); - copier_->ProcessUpdateQueue(); + copier_->process_update_queue(); ASSERT_EQ(copy_dst->input_connections().size(), 1); EXPECT_EQ(copy_dst->input_connections().at( - olive::NodeInput(copy_dst, olive::MathNode::kParamAIn)), + olive::NodeInput(copy_dst, olive::MathNode::k_param_a_in)), copy_src); - olive::Node::DisconnectEdge( - src, olive::NodeInput(dst, olive::MathNode::kParamAIn)); - copier_->ProcessUpdateQueue(); + olive::Node::disconnect_edge( + src, olive::NodeInput(dst, olive::MathNode::k_param_a_in)); + copier_->process_update_queue(); EXPECT_TRUE(copy_dst->input_connections().empty()); EXPECT_TRUE(copy_src->output_connections().empty()); @@ -302,72 +302,72 @@ TEST_F(RenderProjectCopierTest, QueuedEdgeAddAndRemoveAreMirrored) TEST_F(RenderProjectCopierTest, QueuedValueChangeKeepsCopyIndependentUntilProcessed) { - auto *math = AddNode(); + auto *math = add_node(); copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - olive::Node *copy = copier_->GetCopy(math); + olive::Node *copy = copier_->get_copy(math); ASSERT_NE(copy, nullptr); const double before = - math->GetStandardValue(olive::MathNode::kParamAIn).toDouble(); + math->get_standard_value(olive::MathNode::k_param_a_in).toDouble(); const double changed = before + 2.5; - math->SetStandardValue(olive::MathNode::kParamAIn, changed); + math->set_standard_value(olive::MathNode::k_param_a_in, changed); - EXPECT_TRUE(copier_->HasUpdatesInQueue()); + EXPECT_TRUE(copier_->has_updates_in_queue()); // The copy must not change until the queue is processed EXPECT_DOUBLE_EQ( - copy->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), before); + copy->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), before); - copier_->ProcessUpdateQueue(); + copier_->process_update_queue(); EXPECT_DOUBLE_EQ( - copy->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), changed); + copy->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), changed); EXPECT_DOUBLE_EQ( - math->GetStandardValue(olive::MathNode::kParamAIn).toDouble(), changed); + math->get_standard_value(olive::MathNode::k_param_a_in).toDouble(), changed); } TEST_F(RenderProjectCopierTest, QueuedValueHintChangeIsMirrored) { - auto *math = AddNode(); + auto *math = add_node(); copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - olive::Node *copy = copier_->GetCopy(math); + olive::Node *copy = copier_->get_copy(math); ASSERT_NE(copy, nullptr); - const olive::Node::ValueHint hint({ olive::NodeValue::kFloat }, 7, + const olive::Node::ValueHint hint({ olive::NodeValue::k_float }, 7, QStringLiteral("copier_hint")); - math->SetValueHintForInput(olive::MathNode::kParamAIn, hint); - EXPECT_TRUE(copier_->HasUpdatesInQueue()); + math->set_value_hint_for_input(olive::MathNode::k_param_a_in, hint); + EXPECT_TRUE(copier_->has_updates_in_queue()); - copier_->ProcessUpdateQueue(); + copier_->process_update_queue(); const olive::Node::ValueHint copied_hint = - copy->GetValueHintForInput(olive::MathNode::kParamAIn); + copy->get_value_hint_for_input(olive::MathNode::k_param_a_in); EXPECT_EQ(copied_hint.tag(), QStringLiteral("copier_hint")); EXPECT_EQ(copied_hint.index(), 7); ASSERT_EQ(copied_hint.types().size(), 1); - EXPECT_EQ(copied_hint.types().first(), olive::NodeValue::kFloat); + EXPECT_EQ(copied_hint.types().first(), olive::NodeValue::k_float); } TEST_F(RenderProjectCopierTest, QueuedProjectSettingChangeIsMirrored) { copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - project_->SetSetting(QStringLiteral("copier_late_key"), + project_->set_setting(QStringLiteral("copier_late_key"), QStringLiteral("copier_late_value")); - EXPECT_TRUE(copier_->HasUpdatesInQueue()); - EXPECT_TRUE(copier_->GetCopiedProject() - ->GetSetting(QStringLiteral("copier_late_key")) + EXPECT_TRUE(copier_->has_updates_in_queue()); + EXPECT_TRUE(copier_->get_copied_project() + ->get_setting(QStringLiteral("copier_late_key")) .isEmpty()); - copier_->ProcessUpdateQueue(); + copier_->process_update_queue(); - EXPECT_EQ(copier_->GetCopiedProject()->GetSetting( + EXPECT_EQ(copier_->get_copied_project()->get_setting( QStringLiteral("copier_late_key")), QStringLiteral("copier_late_value")); } @@ -375,18 +375,18 @@ TEST_F(RenderProjectCopierTest, QueuedProjectSettingChangeIsMirrored) TEST_F(RenderProjectCopierTest, GroupNodesAreNotCopied) { copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); const int copy_count_before = - copier_->GetCopiedProject()->nodes().size(); + copier_->get_copied_project()->nodes().size(); - auto *group = AddNode(); - copier_->ProcessUpdateQueue(); + auto *group = add_node(); + copier_->process_update_queue(); // Group nodes are dummies for rendering and must not appear in the copy - EXPECT_EQ(copier_->GetCopy(group), nullptr); - EXPECT_EQ(copier_->GetCopiedProject()->nodes().size(), copy_count_before); - for (olive::Node *n : copier_->GetCopiedProject()->nodes()) { + EXPECT_EQ(copier_->get_copy(group), nullptr); + EXPECT_EQ(copier_->get_copied_project()->nodes().size(), copy_count_before); + for (olive::Node *n : copier_->get_copied_project()->nodes()) { EXPECT_NE(n->id(), group->id()); } } @@ -394,254 +394,254 @@ TEST_F(RenderProjectCopierTest, GroupNodesAreNotCopied) TEST_F(RenderProjectCopierTest, GraphChangeTimeAdvancesAndSyncCatchesUp) { copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); // SetProject leaves the sync point at or after the graph change point - EXPECT_GE(copier_->GetLastUpdateTime().value(), - copier_->GetGraphChangeTime().value()); + EXPECT_GE(copier_->get_last_update_time().value(), + copier_->get_graph_change_time().value()); - AddNode(); + add_node(); // A queued change moves the graph change point ahead of the sync point - EXPECT_GT(copier_->GetGraphChangeTime().value(), - copier_->GetLastUpdateTime().value()); + EXPECT_GT(copier_->get_graph_change_time().value(), + copier_->get_last_update_time().value()); - copier_->ProcessUpdateQueue(); + copier_->process_update_queue(); - EXPECT_GE(copier_->GetLastUpdateTime().value(), - copier_->GetGraphChangeTime().value()); + EXPECT_GE(copier_->get_last_update_time().value(), + copier_->get_graph_change_time().value()); } TEST_F(RenderProjectCopierTest, FootageProxySettingsSyncToCopyImmediately) { - auto *footage = AddNode(); + auto *footage = add_node(); copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - olive::Footage *copy = copier_->GetCopy(footage); + olive::Footage *copy = copier_->get_copy(footage); ASSERT_NE(copy, nullptr); EXPECT_FALSE(copy->proxy_enabled()); // Proxy settings are not Node inputs, so the copier mirrors them through a // direct connection without involving the update queue - footage->SetProxy(QStringLiteral("/cache/proxy/example.mp4"), - olive::ProxyManager::kProxyReady, 2, 3, true); + footage->set_proxy(QStringLiteral("/cache/proxy/example.mp4"), + olive::ProxyManager::k_proxy_ready, 2, 3, true); - EXPECT_FALSE(copier_->HasUpdatesInQueue()); + EXPECT_FALSE(copier_->has_updates_in_queue()); EXPECT_TRUE(copy->proxy_enabled()); EXPECT_EQ(copy->proxy_path(), QStringLiteral("/cache/proxy/example.mp4")); - EXPECT_EQ(copy->proxy_state(), olive::ProxyManager::kProxyReady); + EXPECT_EQ(copy->proxy_state(), olive::ProxyManager::k_proxy_ready); EXPECT_EQ(copy->proxy_video_stream_index(), 2); EXPECT_EQ(copy->proxy_preset_version(), 3); - footage->SetProxy(QString(), olive::ProxyManager::kProxyMissing, -1, 0, + footage->set_proxy(QString(), olive::ProxyManager::k_proxy_missing, -1, 0, false); EXPECT_FALSE(copy->proxy_enabled()); - EXPECT_EQ(copy->proxy_state(), olive::ProxyManager::kProxyMissing); + EXPECT_EQ(copy->proxy_state(), olive::ProxyManager::k_proxy_missing); } TEST_F(RenderProjectCopierTest, SetProjectTwiceReplacesCopyContents) { - auto *first = AddNode(); + auto *first = add_node(); copier_ = std::make_unique(); - copier_->SetProject(project_.get()); - ASSERT_NE(copier_->GetCopy(first), nullptr); + copier_->set_project(project_.get()); + ASSERT_NE(copier_->get_copy(first), nullptr); olive::Project second_project; - second_project.Initialize(); + second_project.initialize(); auto *second = new olive::SolidGenerator(); second->setParent(&second_project); - copier_->SetProject(&second_project); + copier_->set_project(&second_project); // Nodes from the first project are gone, nodes from the second are present - EXPECT_EQ(copier_->GetCopy(first), nullptr); - EXPECT_NE(copier_->GetCopy(second), nullptr); - EXPECT_EQ(copier_->GetCopiedProject()->nodes().size(), + EXPECT_EQ(copier_->get_copy(first), nullptr); + EXPECT_NE(copier_->get_copy(second), nullptr); + EXPECT_EQ(copier_->get_copied_project()->nodes().size(), second_project.nodes().size()); - EXPECT_FALSE(copier_->HasUpdatesInQueue()); + EXPECT_FALSE(copier_->has_updates_in_queue()); } TEST_F(RenderProjectCopierTest, SetProjectNullStopsTracking) { copier_ = std::make_unique(); - copier_->SetProject(project_.get()); + copier_->set_project(project_.get()); - AddNode(); - EXPECT_TRUE(copier_->HasUpdatesInQueue()); + add_node(); + EXPECT_TRUE(copier_->has_updates_in_queue()); - copier_->SetProject(nullptr); + copier_->set_project(nullptr); // Pending changes are discarded and the original is no longer tracked - EXPECT_FALSE(copier_->HasUpdatesInQueue()); - EXPECT_NE(copier_->GetCopiedProject(), nullptr); + EXPECT_FALSE(copier_->has_updates_in_queue()); + EXPECT_NE(copier_->get_copied_project(), nullptr); - AddNode(); - EXPECT_FALSE(copier_->HasUpdatesInQueue()); + add_node(); + EXPECT_FALSE(copier_->has_updates_in_queue()); } TEST_F(RenderPlaybackCacheTest, UuidAndSavingFlagAccessors) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache cache(node); - EXPECT_FALSE(cache.GetUuid().isNull()); + EXPECT_FALSE(cache.get_uuid().isNull()); EXPECT_EQ(cache.parent(), node); - EXPECT_TRUE(cache.IsSavingEnabled()); + EXPECT_TRUE(cache.is_saving_enabled()); EXPECT_NE(cache.mutex(), nullptr); TestPlaybackCache other(node); - EXPECT_NE(other.GetUuid(), cache.GetUuid()); + EXPECT_NE(other.get_uuid(), cache.get_uuid()); const QUuid uuid = QUuid::createUuid(); - cache.SetUuid(uuid); - EXPECT_EQ(cache.GetUuid(), uuid); + cache.set_uuid(uuid); + EXPECT_EQ(cache.get_uuid(), uuid); - cache.SetSavingEnabled(false); - EXPECT_FALSE(cache.IsSavingEnabled()); + cache.set_saving_enabled(false); + EXPECT_FALSE(cache.is_saving_enabled()); } TEST_F(RenderPlaybackCacheTest, ValidateAndInvalidateBookkeeping) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache cache(node); QVector validated_signals; QVector invalidated_signals; - QObject::connect(&cache, &olive::PlaybackCache::Validated, + QObject::connect(&cache, &olive::PlaybackCache::validated, [&validated_signals](const olive::TimeRange &r) { validated_signals.append(r); }); - QObject::connect(&cache, &olive::PlaybackCache::Invalidated, + QObject::connect(&cache, &olive::PlaybackCache::invalidated, [&invalidated_signals](const olive::TimeRange &r) { invalidated_signals.append(r); }); - const olive::TimeRange whole(olive::rational(0), olive::rational(10)); - EXPECT_TRUE(cache.HasInvalidatedRanges(whole)); - EXPECT_FALSE(cache.HasValidatedRanges()); + const olive::TimeRange whole(olive::Rational(0), olive::Rational(10)); + EXPECT_TRUE(cache.has_invalidated_ranges(whole)); + EXPECT_FALSE(cache.has_validated_ranges()); - cache.Validate(whole); + cache.validate(whole); - EXPECT_TRUE(cache.HasValidatedRanges()); - EXPECT_TRUE(cache.GetValidatedRanges().contains(whole)); - EXPECT_FALSE(cache.HasInvalidatedRanges(whole)); - EXPECT_TRUE(cache.GetInvalidatedRanges(olive::rational(10)).isEmpty()); + EXPECT_TRUE(cache.has_validated_ranges()); + EXPECT_TRUE(cache.get_validated_ranges().contains(whole)); + EXPECT_FALSE(cache.has_invalidated_ranges(whole)); + EXPECT_TRUE(cache.get_invalidated_ranges(olive::Rational(10)).isEmpty()); EXPECT_EQ(cache.invalidate_event_count, 0); ASSERT_EQ(validated_signals.size(), 1); EXPECT_EQ(validated_signals.first(), whole); // A larger query range still reports the remainder as invalidated - EXPECT_TRUE(cache.HasInvalidatedRanges( - olive::TimeRange(olive::rational(0), olive::rational(11)))); + EXPECT_TRUE(cache.has_invalidated_ranges( + olive::TimeRange(olive::Rational(0), olive::Rational(11)))); - const olive::TimeRange hole(olive::rational(2), olive::rational(5)); - cache.Invalidate(hole); + const olive::TimeRange hole(olive::Rational(2), olive::Rational(5)); + cache.invalidate(hole); EXPECT_EQ(cache.invalidate_event_count, 1); ASSERT_EQ(invalidated_signals.size(), 1); EXPECT_EQ(invalidated_signals.first(), hole); - EXPECT_TRUE(cache.HasInvalidatedRanges(whole)); + EXPECT_TRUE(cache.has_invalidated_ranges(whole)); const olive::TimeRangeList invalidated = - cache.GetInvalidatedRanges(olive::rational(10)); + cache.get_invalidated_ranges(olive::Rational(10)); ASSERT_EQ(invalidated.size(), 1); EXPECT_EQ(invalidated.first(), hole); } TEST_F(RenderPlaybackCacheTest, InvalidateZeroLengthRangeIsIgnored) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache cache(node); - const olive::TimeRange whole(olive::rational(0), olive::rational(10)); - cache.Validate(whole); + const olive::TimeRange whole(olive::Rational(0), olive::Rational(10)); + cache.validate(whole); int invalidated_count = 0; - QObject::connect(&cache, &olive::PlaybackCache::Invalidated, + QObject::connect(&cache, &olive::PlaybackCache::invalidated, [&invalidated_count](const olive::TimeRange &) { invalidated_count++; }); // Zero-length invalidations are rejected with a warning - cache.Invalidate(olive::TimeRange(olive::rational(5), olive::rational(5))); + cache.invalidate(olive::TimeRange(olive::Rational(5), olive::Rational(5))); EXPECT_EQ(invalidated_count, 0); EXPECT_EQ(cache.invalidate_event_count, 0); - EXPECT_TRUE(cache.GetValidatedRanges().contains(whole)); + EXPECT_TRUE(cache.get_validated_ranges().contains(whole)); } TEST_F(RenderPlaybackCacheTest, GetInvalidatedRangesClampsNegativeTimes) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache cache(node); // Nothing is validated, so the whole (clamped) range is invalidated - const olive::TimeRangeList invalidated = cache.GetInvalidatedRanges( - olive::TimeRange(olive::rational(-5), olive::rational(10))); + const olive::TimeRangeList invalidated = cache.get_invalidated_ranges( + olive::TimeRange(olive::Rational(-5), olive::Rational(10))); ASSERT_EQ(invalidated.size(), 1); - EXPECT_EQ(invalidated.first().in(), olive::rational(0)); - EXPECT_EQ(invalidated.first().out(), olive::rational(10)); + EXPECT_EQ(invalidated.first().in(), olive::Rational(0)); + EXPECT_EQ(invalidated.first().out(), olive::Rational(10)); } TEST_F(RenderPlaybackCacheTest, PassthroughCoversInvalidatedRanges) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache source(node); TestPlaybackCache dest(node); - const olive::TimeRange whole(olive::rational(0), olive::rational(10)); - source.Validate(whole); + const olive::TimeRange whole(olive::Rational(0), olive::Rational(10)); + source.validate(whole); - dest.SetPassthrough(&source); + dest.set_passthrough(&source); - ASSERT_EQ(dest.GetPassthroughs().size(), 1); - EXPECT_EQ(dest.GetPassthroughs().front().cache, source.GetUuid()); - EXPECT_EQ(dest.GetPassthroughs().front().in(), whole.in()); - EXPECT_EQ(dest.GetPassthroughs().front().out(), whole.out()); + ASSERT_EQ(dest.get_passthroughs().size(), 1); + EXPECT_EQ(dest.get_passthroughs().front().cache, source.get_uuid()); + EXPECT_EQ(dest.get_passthroughs().front().in(), whole.in()); + EXPECT_EQ(dest.get_passthroughs().front().out(), whole.out()); // GetInvalidatedRanges honors passthroughs ... - EXPECT_TRUE(dest.GetInvalidatedRanges(olive::rational(10)).isEmpty()); + EXPECT_TRUE(dest.get_invalidated_ranges(olive::Rational(10)).isEmpty()); // ... but HasInvalidatedRanges only looks at locally validated ranges - EXPECT_TRUE(dest.HasInvalidatedRanges(whole)); + EXPECT_TRUE(dest.has_invalidated_ranges(whole)); // Invalidating trims the passthrough too - const olive::TimeRange hole(olive::rational(2), olive::rational(3)); - dest.Invalidate(hole); + const olive::TimeRange hole(olive::Rational(2), olive::Rational(3)); + dest.invalidate(hole); const olive::TimeRangeList invalidated = - dest.GetInvalidatedRanges(olive::rational(10)); + dest.get_invalidated_ranges(olive::Rational(10)); ASSERT_EQ(invalidated.size(), 1); EXPECT_EQ(invalidated.first(), hole); } TEST_F(RenderPlaybackCacheTest, PassthroughChainsAcrossCaches) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache a(node); TestPlaybackCache b(node); TestPlaybackCache c(node); - a.Validate(olive::TimeRange(olive::rational(0), olive::rational(10))); - b.SetPassthrough(&a); - c.SetPassthrough(&b); + a.validate(olive::TimeRange(olive::Rational(0), olive::Rational(10))); + b.set_passthrough(&a); + c.set_passthrough(&b); // c inherits b's passthrough of a - ASSERT_EQ(c.GetPassthroughs().size(), 1); - EXPECT_EQ(c.GetPassthroughs().front().cache, a.GetUuid()); - EXPECT_TRUE(c.GetInvalidatedRanges(olive::rational(10)).isEmpty()); + ASSERT_EQ(c.get_passthroughs().size(), 1); + EXPECT_EQ(c.get_passthroughs().front().cache, a.get_uuid()); + EXPECT_TRUE(c.get_invalidated_ranges(olive::Rational(10)).isEmpty()); } TEST_F(RenderPlaybackCacheTest, RequestResignalAndClear) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache cache(node); int requested_count = 0; olive::TimeRange last_requested; - QObject::connect(&cache, &olive::PlaybackCache::Requested, + QObject::connect(&cache, &olive::PlaybackCache::requested, [&requested_count, &last_requested]( olive::ViewerOutput *context, const olive::TimeRange &r) { @@ -650,120 +650,120 @@ TEST_F(RenderPlaybackCacheTest, RequestResignalAndClear) last_requested = r; }); - const olive::TimeRange first(olive::rational(0), olive::rational(5)); - const olive::TimeRange second(olive::rational(10), olive::rational(20)); + const olive::TimeRange first(olive::Rational(0), olive::Rational(5)); + const olive::TimeRange second(olive::Rational(10), olive::Rational(20)); - cache.Request(nullptr, first); + cache.request(nullptr, first); EXPECT_EQ(requested_count, 1); EXPECT_EQ(last_requested, first); - cache.Request(nullptr, second); + cache.request(nullptr, second); EXPECT_EQ(requested_count, 2); // Both pending ranges are re-signaled - cache.ResignalRequests(); + cache.resignal_requests(); EXPECT_EQ(requested_count, 4); // Clearing one range leaves the other pending - cache.ClearRequestRange(first); - cache.ResignalRequests(); + cache.clear_request_range(first); + cache.resignal_requests(); EXPECT_EQ(requested_count, 5); EXPECT_EQ(last_requested, second); } TEST_F(RenderPlaybackCacheTest, InvalidateAllClearsEverything) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache cache(node); TestPlaybackCache source(node); - source.Validate(olive::TimeRange(olive::rational(0), olive::rational(10))); - cache.Validate(olive::TimeRange(olive::rational(0), olive::rational(10))); - cache.SetPassthrough(&source); + source.validate(olive::TimeRange(olive::Rational(0), olive::Rational(10))); + cache.validate(olive::TimeRange(olive::Rational(0), olive::Rational(10))); + cache.set_passthrough(&source); QVector invalidated_signals; - QObject::connect(&cache, &olive::PlaybackCache::Invalidated, + QObject::connect(&cache, &olive::PlaybackCache::invalidated, [&invalidated_signals](const olive::TimeRange &r) { invalidated_signals.append(r); }); - cache.InvalidateAll(); + cache.invalidate_all(); - EXPECT_FALSE(cache.HasValidatedRanges()); - EXPECT_TRUE(cache.GetPassthroughs().empty()); + EXPECT_FALSE(cache.has_validated_ranges()); + EXPECT_TRUE(cache.get_passthroughs().empty()); ASSERT_EQ(invalidated_signals.size(), 1); EXPECT_EQ(invalidated_signals.first(), - olive::TimeRange(olive::rational(0), RATIONAL_MAX)); + olive::TimeRange(olive::Rational(0), RATIONAL_MAX)); } TEST_F(RenderPlaybackCacheTest, StatePersistsAcrossCaches) { - auto *node = AddNode(); + auto *node = add_node(); const QUuid uuid = QUuid::createUuid(); const QUuid source_uuid = QUuid::createUuid(); - const olive::TimeRange valid(olive::rational(5), olive::rational(15)); - const olive::TimeRange pass(olive::rational(20), olive::rational(30)); + const olive::TimeRange valid(olive::Rational(5), olive::Rational(15)); + const olive::TimeRange pass(olive::Rational(20), olive::Rational(30)); { TestPlaybackCache cache(node); - cache.SetUuid(uuid); - cache.Validate(valid); + cache.set_uuid(uuid); + cache.validate(valid); TestPlaybackCache source(node); - source.SetUuid(source_uuid); - source.Validate(pass); - cache.SetPassthrough(&source); + source.set_uuid(source_uuid); + source.validate(pass); + cache.set_passthrough(&source); EXPECT_GE(cache.save_state_event_count, 1); } const QString state_file = - QDir(QDir(CacheRoot()).filePath(uuid.toString())) + QDir(QDir(cache_root()).filePath(uuid.toString())) .filePath(QStringLiteral("state")); ASSERT_TRUE(QFileInfo::exists(state_file)); TestPlaybackCache restored(node); - restored.SetUuid(uuid); + restored.set_uuid(uuid); EXPECT_EQ(restored.load_state_event_count, 1); - EXPECT_TRUE(restored.GetValidatedRanges().contains(valid)); - ASSERT_EQ(restored.GetPassthroughs().size(), 1); - EXPECT_EQ(restored.GetPassthroughs().front().cache, source_uuid); - EXPECT_EQ(restored.GetPassthroughs().front().in(), pass.in()); - EXPECT_EQ(restored.GetPassthroughs().front().out(), pass.out()); + EXPECT_TRUE(restored.get_validated_ranges().contains(valid)); + ASSERT_EQ(restored.get_passthroughs().size(), 1); + EXPECT_EQ(restored.get_passthroughs().front().cache, source_uuid); + EXPECT_EQ(restored.get_passthroughs().front().in(), pass.in()); + EXPECT_EQ(restored.get_passthroughs().front().out(), pass.out()); } TEST_F(RenderPlaybackCacheTest, CacheDirectoryHelpers) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache cache(node); const QUuid uuid = QUuid::createUuid(); - cache.SetUuid(uuid); + cache.set_uuid(uuid); - EXPECT_EQ(olive::PlaybackCache::GetThisCacheDirectory( + EXPECT_EQ(olive::PlaybackCache::get_this_cache_directory( QStringLiteral("/base/path"), uuid), QDir(QDir(QStringLiteral("/base/path")).filePath( uuid.toString()))); - EXPECT_EQ(cache.GetThisCacheDirectory(), - QDir(QDir(CacheRoot()).filePath(uuid.toString()))); + EXPECT_EQ(cache.get_this_cache_directory(), + QDir(QDir(cache_root()).filePath(uuid.toString()))); - EXPECT_GT(olive::PlaybackCache::GetCacheIndicatorHeight(), 0); + EXPECT_GT(olive::PlaybackCache::get_cache_indicator_height(), 0); } TEST_F(RenderPlaybackCacheTest, DrawPaintsValidatedRangesGreen) { - auto *node = AddNode(); + auto *node = add_node(); TestPlaybackCache cache(node); - cache.Validate(olive::TimeRange(olive::rational(2), olive::rational(5))); + cache.validate(olive::TimeRange(olive::Rational(2), olive::Rational(5))); QImage image(100, 10, QImage::Format_RGB32); image.fill(Qt::black); { QPainter painter(&image); - cache.Draw(&painter, olive::rational(0), 10.0, QRect(0, 0, 100, 10)); + cache.draw(&painter, olive::Rational(0), 10.0, QRect(0, 0, 100, 10)); } // 10 px/s: validated seconds [2,5) cover pixels [20,50) @@ -774,25 +774,25 @@ TEST_F(RenderPlaybackCacheTest, DrawPaintsValidatedRangesGreen) TEST_F(RenderPlaybackCacheTest, AudioParametersRoundTrip) { - auto *node = AddNode(); + auto *node = add_node(); olive::AudioPlaybackCache cache(node); - const olive::AudioParams params(48000, olive::kChannelLayoutStereo, - olive::SampleFormat::F32P); - cache.SetParameters(params); - EXPECT_TRUE(cache.GetParameters() == params); - EXPECT_EQ(cache.GetParameters().sample_rate(), 48000); - EXPECT_EQ(cache.GetParameters().channel_count(), 2); + const olive::AudioParams params(48000, olive::k_channel_layout_stereo, + olive::SampleFormat::f32_p); + cache.set_parameters(params); + EXPECT_TRUE(cache.get_parameters() == params); + EXPECT_EQ(cache.get_parameters().sample_rate(), 48000); + EXPECT_EQ(cache.get_parameters().channel_count(), 2); // Setting identical parameters again takes the no-op path - cache.SetParameters(params); - EXPECT_TRUE(cache.GetParameters() == params); + cache.set_parameters(params); + EXPECT_TRUE(cache.get_parameters() == params); - const olive::AudioParams other(44100, olive::kChannelLayoutMono, - olive::SampleFormat::F32P); - cache.SetParameters(other); - EXPECT_EQ(cache.GetParameters().sample_rate(), 44100); - EXPECT_EQ(cache.GetParameters().channel_count(), 1); + const olive::AudioParams other(44100, olive::k_channel_layout_mono, + olive::SampleFormat::f32_p); + cache.set_parameters(other); + EXPECT_EQ(cache.get_parameters().sample_rate(), 44100); + EXPECT_EQ(cache.get_parameters().channel_count(), 1); } // NOTE: AudioPlaybackCache::WriteSilence() is intentionally not exercised: it @@ -801,17 +801,17 @@ TEST_F(RenderPlaybackCacheTest, AudioParametersRoundTrip) // the buffer provides no bytes). See the bug notes in the test report. TEST_F(RenderPlaybackCacheTest, WritePcmValidatesRangesAndWritesSegments) { - auto *node = AddNode(); + auto *node = add_node(); olive::AudioPlaybackCache cache(node); - const olive::AudioParams params(48000, olive::kChannelLayoutStereo, - olive::SampleFormat::F32P); - cache.SetParameters(params); + const olive::AudioParams params(48000, olive::k_channel_layout_stereo, + olive::SampleFormat::f32_p); + cache.set_parameters(params); // Two adjacent 0.1s ranges at 48kHz stereo float - const olive::TimeRange r1(olive::rational(0), olive::rational(1, 10)); - const olive::TimeRange r2(olive::rational(1, 10), olive::rational(1, 5)); - const olive::TimeRange whole(olive::rational(0), olive::rational(1, 5)); + const olive::TimeRange r1(olive::Rational(0), olive::Rational(1, 10)); + const olive::TimeRange r2(olive::Rational(1, 10), olive::Rational(1, 5)); + const olive::TimeRange whole(olive::Rational(0), olive::Rational(1, 5)); const qint64 total_bytes = params.time_to_bytes_per_channel(whole.length()); const qint64 range_bytes = params.time_to_bytes_per_channel(r1.length()); @@ -828,21 +828,21 @@ TEST_F(RenderPlaybackCacheTest, WritePcmValidatesRangesAndWritesSegments) } int validated_count = 0; - QObject::connect(&cache, &olive::PlaybackCache::Validated, + QObject::connect(&cache, &olive::PlaybackCache::validated, [&validated_count](const olive::TimeRange &) { validated_count++; }); - cache.WritePCM(whole, { r1, r2 }, samples); + cache.write_pcm(whole, { r1, r2 }, samples); // Adjacent ranges merge into one validated block EXPECT_EQ(validated_count, 2); - EXPECT_TRUE(cache.GetValidatedRanges().contains(r1)); - EXPECT_TRUE(cache.GetValidatedRanges().contains(r2)); - EXPECT_FALSE(cache.HasInvalidatedRanges(whole)); + EXPECT_TRUE(cache.get_validated_ranges().contains(r1)); + EXPECT_TRUE(cache.get_validated_ranges().contains(r2)); + EXPECT_FALSE(cache.has_invalidated_ranges(whole)); // One segment file per channel in this cache's directory - const QDir cache_dir = cache.GetThisCacheDirectory(); + const QDir cache_dir = cache.get_this_cache_directory(); const QString seg_ch0 = cache_dir.filePath(QStringLiteral("0.0")); const QString seg_ch1 = cache_dir.filePath(QStringLiteral("0.1")); ASSERT_TRUE(QFileInfo::exists(seg_ch0)); diff --git a/tests/gtest/render_sampleformat_test.cpp b/tests/gtest/render_sampleformat_test.cpp index 811332061..30e7ec98a 100644 --- a/tests/gtest/render_sampleformat_test.cpp +++ b/tests/gtest/render_sampleformat_test.cpp @@ -6,24 +6,24 @@ TEST(RenderSampleFormat, ByteCountAndStringRoundTrip) { using olive::core::SampleFormat; - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::INVALID), 0); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::U8), 1); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::S16), 2); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::F32), 4); - EXPECT_EQ(SampleFormat::byte_count(SampleFormat::F64), 8); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::invalid), 0); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::u8), 1); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::s16), 2); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::f32), 4); + EXPECT_EQ(SampleFormat::byte_count(SampleFormat::f64), 8); - EXPECT_EQ(SampleFormat::to_string(SampleFormat::S16), "s16"); - EXPECT_EQ(SampleFormat::from_string("s16"), SampleFormat::S16); - EXPECT_EQ(SampleFormat::from_string(""), SampleFormat::INVALID); - EXPECT_EQ(SampleFormat::from_string("unknown"), SampleFormat::INVALID); + EXPECT_EQ(SampleFormat::to_string(SampleFormat::s16), "s16"); + EXPECT_EQ(SampleFormat::from_string("s16"), SampleFormat::s16); + EXPECT_EQ(SampleFormat::from_string(""), SampleFormat::invalid); + EXPECT_EQ(SampleFormat::from_string("unknown"), SampleFormat::invalid); } TEST(RenderSampleFormat, PackedAndPlanarChecks) { using olive::core::SampleFormat; - EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::S16)); - EXPECT_FALSE(SampleFormat::is_packed(SampleFormat::S16P)); - EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::S16P)); - EXPECT_FALSE(SampleFormat::is_planar(SampleFormat::S16)); + EXPECT_TRUE(SampleFormat::is_packed(SampleFormat::s16)); + EXPECT_FALSE(SampleFormat::is_packed(SampleFormat::s16_p)); + EXPECT_TRUE(SampleFormat::is_planar(SampleFormat::s16_p)); + EXPECT_FALSE(SampleFormat::is_planar(SampleFormat::s16)); } diff --git a/tests/gtest/render_tail_test.cpp b/tests/gtest/render_tail_test.cpp index 454e74961..15eb280bf 100644 --- a/tests/gtest/render_tail_test.cpp +++ b/tests/gtest/render_tail_test.cpp @@ -47,25 +47,25 @@ public: { } - bool Init() override + bool init() override { return true; } - void PostDestroy() override + void post_destroy() override { } - void PostInit() override + void post_init() override { } - void ClearDestination(olive::Texture *texture, double r, double g, double b, + void clear_destination(olive::Texture *texture, double r, double g, double b, double a) override { } - QVariant CreateNativeShader(olive::ShaderCode code) override + QVariant create_native_shader(olive::ShaderCode code) override { create_shader_count++; last_frag_code = code.frag_code(); @@ -73,26 +73,26 @@ public: return QVariant(create_shader_count); } - void DestroyNativeShader(QVariant shader) override + void destroy_native_shader(QVariant shader) override { } - void UploadToTexture(const QVariant &handle, const olive::VideoParams ¶ms, + void upload_to_texture(const QVariant &handle, const olive::VideoParams ¶ms, const void *data, int linesize) override { } - void DownloadFromTexture(const QVariant &handle, + void download_from_texture(const QVariant &handle, const olive::VideoParams ¶ms, void *data, int linesize) override { } - void Flush() override + void flush() override { } - olive::Color GetPixelFromTexture(olive::Texture *texture, + olive::Color get_pixel_from_texture(olive::Texture *texture, const QPointF &pt) override { return olive::Color(); @@ -105,14 +105,14 @@ public: QString last_vert_code; protected: - void Blit(QVariant shader, olive::AcceleratedJob &job, + void blit(QVariant shader, olive::AcceleratedJob &job, olive::Texture *destination, olive::VideoParams destination_params, bool clear_destination) override { blit_count++; } - QVariant CreateNativeTexture(int width, int height, int depth, + QVariant create_native_texture(int width, int height, int depth, olive::PixelFormat format, int channel_count, const void *data, int linesize) override { @@ -120,27 +120,27 @@ protected: return QVariant(create_texture_count); } - void DestroyNativeTexture(QVariant texture) override + void destroy_native_texture(QVariant texture) override { } - void DestroyInternal() override + void destroy_internal() override { } }; -olive::ColorProcessorPtr MakeIdentityProcessor() +olive::ColorProcessorPtr make_identity_processor() { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); - OCIO::MatrixTransformRcPtr transform = OCIO::MatrixTransform::Create(); - transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD); + ocio::MatrixTransformRcPtr transform = ocio::MatrixTransform::Create(); + transform->setDirection(ocio::TRANSFORM_DIR_FORWARD); - return olive::ColorProcessor::Create( - olive::ColorManager::GetDefaultConfig()->getProcessor(transform)); + return olive::ColorProcessor::create( + olive::ColorManager::get_default_config()->getProcessor(transform)); } -bool WriteFile(const QString &path, qint64 size) +bool write_file(const QString &path, qint64 size) { QFile file(path); if (!file.open(QFile::WriteOnly)) { @@ -151,7 +151,7 @@ bool WriteFile(const QString &path, qint64 size) return true; } -bool ReadBytesAt(const QString &path, qint64 offset, qint64 len, QByteArray *out) +bool read_bytes_at(const QString &path, qint64 offset, qint64 len, QByteArray *out) { QFile f(path); if (!f.open(QFile::ReadOnly)) { @@ -164,7 +164,7 @@ bool ReadBytesAt(const QString &path, qint64 offset, qint64 len, QByteArray *out return out->size() == len; } -float BytesToFloat(const QByteArray &bytes) +float bytes_to_float(const QByteArray &bytes) { float v; memcpy(&v, bytes.constData(), sizeof(v)); @@ -173,7 +173,7 @@ float BytesToFloat(const QByteArray &bytes) // AudioPlaybackCache always stores audio in fixed-size segments of 10 MB per // channel (AudioPlaybackCache::kDefaultSegmentSizePerChannel). -const qint64 kSegmentSize = 10 * 1024 * 1024; +const qint64 k_segment_size = 10 * 1024 * 1024; } // namespace @@ -183,38 +183,38 @@ TEST(DynamicRenderer, EmptyBackendNameHasNoBackendType) { olive::DynamicRenderer renderer{ QString() }; EXPECT_TRUE(renderer.backend_name().isEmpty()); - EXPECT_FALSE(renderer.IsOpenGL()); - EXPECT_FALSE(renderer.IsVulkan()); + EXPECT_FALSE(renderer.is_open_gl()); + EXPECT_FALSE(renderer.is_vulkan()); // Without a loaded backend, context and info accessors stay at defaults - EXPECT_EQ(renderer.OpenGLContext(), nullptr); + EXPECT_EQ(renderer.open_gl_context(), nullptr); OakRenderBackendInfo info = {}; - EXPECT_FALSE(renderer.GetBackendInfo(&info)); + EXPECT_FALSE(renderer.get_backend_info(&info)); } // BackendFromString lowercases its input before comparing, so mixed-case // spellings of every backend must resolve correctly. TEST(RenderManagerBackendStrings, FromStringIsCaseInsensitive) { - EXPECT_EQ(olive::RenderManager::BackendFromString(QStringLiteral("VULKAN")), - olive::RenderManager::kVulkan); + EXPECT_EQ(olive::RenderManager::backend_from_string(QStringLiteral("VULKAN")), + olive::RenderManager::k_vulkan); EXPECT_EQ( - olive::RenderManager::BackendFromString(QStringLiteral("MultiProcess")), - olive::RenderManager::kMultiProcess); - EXPECT_EQ(olive::RenderManager::BackendFromString(QStringLiteral("DUMMY")), - olive::RenderManager::kDummy); + olive::RenderManager::backend_from_string(QStringLiteral("MultiProcess")), + olive::RenderManager::k_multi_process); + EXPECT_EQ(olive::RenderManager::backend_from_string(QStringLiteral("DUMMY")), + olive::RenderManager::k_dummy); // Unknown and empty strings fall through to OpenGL - EXPECT_EQ(olive::RenderManager::BackendFromString(QString()), - olive::RenderManager::kOpenGL); + EXPECT_EQ(olive::RenderManager::backend_from_string(QString()), + olive::RenderManager::k_open_gl); } // BackendToString has a default return after the switch for out-of-range enum // values, which must be the OpenGL string. TEST(RenderManagerBackendStrings, ToStringFallsBackToOpenGLForUnknownEnum) { - EXPECT_EQ(olive::RenderManager::BackendToString( + EXPECT_EQ(olive::RenderManager::backend_to_string( static_cast(42)), QStringLiteral("opengl")); } @@ -226,23 +226,23 @@ TEST(RendererColorContext, CustomFunctionNameIsCompiledIntoShader) { ShaderCaptureRenderer renderer; - olive::ColorProcessorPtr processor = MakeIdentityProcessor(); + olive::ColorProcessorPtr processor = make_identity_processor(); ASSERT_TRUE(processor); olive::ColorTransformJob job; - job.SetColorProcessor(processor); - job.SetFunctionName(QStringLiteral("MyCustomOcioFunc")); + job.set_color_processor(processor); + job.set_function_name(QStringLiteral("MyCustomOcioFunc")); - const olive::VideoParams params(32, 32, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - renderer.BlitColorManaged(job, params); + const olive::VideoParams params(32, 32, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + renderer.blit_color_managed(job, params); ASSERT_EQ(renderer.create_shader_count, 1); EXPECT_TRUE( renderer.last_frag_code.contains(QStringLiteral("MyCustomOcioFunc"))); EXPECT_EQ(renderer.blit_count, 1); - renderer.Destroy(); + renderer.destroy(); } // When the job names a custom shader source node, GetColorContext must ask the @@ -252,62 +252,62 @@ TEST(RendererColorContext, CustomShaderSourceSuppliesFragmentCode) { ShaderCaptureRenderer renderer; - olive::ColorProcessorPtr processor = MakeIdentityProcessor(); + olive::ColorProcessorPtr processor = make_identity_processor(); ASSERT_TRUE(processor); olive::ChromaKeyNode key_node; olive::ColorTransformJob job; - job.SetColorProcessor(processor); - job.SetNeedsCustomShader(&key_node); + job.set_color_processor(processor); + job.set_needs_custom_shader(&key_node); - const olive::VideoParams params(32, 32, olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount); - renderer.BlitColorManaged(job, params); + const olive::VideoParams params(32, 32, olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count); + renderer.blit_color_managed(job, params); ASSERT_EQ(renderer.create_shader_count, 1); // A uniform name unique to chromakey.frag proves the node's code was used EXPECT_TRUE(renderer.last_frag_code.contains(QStringLiteral("color_key"))); EXPECT_EQ(renderer.blit_count, 1); - renderer.Destroy(); + renderer.destroy(); } class RenderTailAutoCacherTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); // Use the dummy render backend so PreviewAutoCacher can be exercised // without initializing OpenGL/Vulkan in the unit-test process. - olive::Config::Current()[QStringLiteral("GraphicsBackend")] = + olive::Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("dummy"); - olive::DiskManager::CreateInstance(); - olive::ConformManager::CreateInstance(); - olive::RenderManager::CreateInstance(); + olive::DiskManager::create_instance(); + olive::ConformManager::create_instance(); + olive::RenderManager::create_instance(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override { project_.reset(); - olive::RenderManager::DestroyInstance(); - olive::ConformManager::DestroyInstance(); - olive::DiskManager::DestroyInstance(); + olive::RenderManager::destroy_instance(); + olive::ConformManager::destroy_instance(); + olive::DiskManager::destroy_instance(); } - olive::ViewerOutput *CreateViewerWithParams() + olive::ViewerOutput *create_viewer_with_params() { auto *viewer = new olive::ViewerOutput(); viewer->setParent(project_.get()); - viewer->SetVideoParams( - olive::VideoParams(64, 64, olive::rational(1, 25), - olive::PixelFormat::U8, - olive::VideoParams::kRGBAChannelCount)); + viewer->set_video_params( + olive::VideoParams(64, 64, olive::Rational(1, 25), + olive::PixelFormat::u8, + olive::VideoParams::k_rgba_channel_count)); return viewer; } @@ -319,50 +319,50 @@ protected: // range iterator is exhausted. TEST_F(RenderTailAutoCacherTest, PausedRendersDelayForcedCacheRange) { - olive::ViewerOutput *viewer = CreateViewerWithParams(); + olive::ViewerOutput *viewer = create_viewer_with_params(); olive::PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); - QSignalSpy stop_spy(&cacher, &olive::PreviewAutoCacher::StopCacheProxyTasks); + QSignalSpy stop_spy(&cacher, &olive::PreviewAutoCacher::stop_cache_proxy_tasks); - cacher.SetRendersPaused(true); - cacher.ForceCacheRange( - viewer, olive::TimeRange(olive::rational(0), olive::rational(1, 25))); + cacher.set_renders_paused(true); + cacher.force_cache_range( + viewer, olive::TimeRange(olive::Rational(0), olive::Rational(1, 25))); EXPECT_EQ(stop_spy.count(), 0); - cacher.SetRendersPaused(false); + cacher.set_renders_paused(false); EXPECT_GE(stop_spy.count(), 1); // Deliver the queued RenderTicketWatcher::Finished emissions so the // completed watchers are reaped before teardown. QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // The thumbnail pause gates only the video-job half of TryRender, so a forced // cache range queued while thumbnails are paused must wait for the unpause. TEST_F(RenderTailAutoCacherTest, PausedThumbnailsDelayForcedCacheRange) { - olive::ViewerOutput *viewer = CreateViewerWithParams(); + olive::ViewerOutput *viewer = create_viewer_with_params(); olive::PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); - QSignalSpy stop_spy(&cacher, &olive::PreviewAutoCacher::StopCacheProxyTasks); + QSignalSpy stop_spy(&cacher, &olive::PreviewAutoCacher::stop_cache_proxy_tasks); - cacher.SetThumbnailsPaused(true); - cacher.ForceCacheRange( - viewer, olive::TimeRange(olive::rational(0), olive::rational(1, 25))); + cacher.set_thumbnails_paused(true); + cacher.force_cache_range( + viewer, olive::TimeRange(olive::Rational(0), olive::Rational(1, 25))); EXPECT_EQ(stop_spy.count(), 0); - cacher.SetThumbnailsPaused(false); + cacher.set_thumbnails_paused(false); EXPECT_GE(stop_spy.count(), 1); QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // With a project set, GetSingleFrame resolves the node through the ProjectCopier @@ -371,29 +371,29 @@ TEST_F(RenderTailAutoCacherTest, PausedThumbnailsDelayForcedCacheRange) // once the watcher signals completion. TEST_F(RenderTailAutoCacherTest, GetSingleFrameDispatchesThroughProjectCopy) { - olive::ViewerOutput *viewer = CreateViewerWithParams(); + olive::ViewerOutput *viewer = create_viewer_with_params(); auto *solid = new olive::SolidGenerator(); solid->setParent(project_.get()); olive::PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); olive::RenderTicketPtr ticket = - cacher.GetSingleFrame(solid, viewer, olive::rational(0)); + cacher.get_single_frame(solid, viewer, olive::Rational(0)); ASSERT_NE(ticket, nullptr); - EXPECT_TRUE(ticket->IsRunning()); + EXPECT_TRUE(ticket->is_running()); // The dummy backend has no render threads, so the dispatched ticket can // only be finished through the clear path (covered in detail by the // ClearSingleFrameRenders tests below). - cacher.ClearSingleFrameRenders(); + cacher.clear_single_frame_renders(); - EXPECT_EQ(ticket->GetFinishCount(), 1); - EXPECT_FALSE(ticket->IsRunning()); - EXPECT_FALSE(ticket->HasResult()); + EXPECT_EQ(ticket->get_finish_count(), 1); + EXPECT_FALSE(ticket->is_running()); + EXPECT_FALSE(ticket->has_result()); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // ClearSingleFrameRenders must cancel every dispatched (but no longer running) @@ -401,29 +401,29 @@ TEST_F(RenderTailAutoCacherTest, GetSingleFrameDispatchesThroughProjectCopy) // watcher is reaped synchronously through VideoRendered. TEST_F(RenderTailAutoCacherTest, ClearSingleFrameRendersFinishesDispatchedTicket) { - olive::ViewerOutput *viewer = CreateViewerWithParams(); + olive::ViewerOutput *viewer = create_viewer_with_params(); auto *solid = new olive::SolidGenerator(); solid->setParent(project_.get()); olive::PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); olive::RenderTicketPtr ticket = - cacher.GetSingleFrame(solid, viewer, olive::rational(0)); + cacher.get_single_frame(solid, viewer, olive::Rational(0)); ASSERT_NE(ticket, nullptr); - ASSERT_TRUE(ticket->IsRunning()); + ASSERT_TRUE(ticket->is_running()); - cacher.ClearSingleFrameRenders(); + cacher.clear_single_frame_renders(); - EXPECT_EQ(ticket->GetFinishCount(), 1); - EXPECT_FALSE(ticket->IsRunning()); - EXPECT_FALSE(ticket->HasResult()); + EXPECT_EQ(ticket->get_finish_count(), 1); + EXPECT_FALSE(ticket->is_running()); + EXPECT_FALSE(ticket->has_result()); // Flush the stale queued watcher notification (its receiver is gone now). QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // ClearSingleFrameRendersThatArentRunning follows the same path for the dummy @@ -431,28 +431,28 @@ TEST_F(RenderTailAutoCacherTest, ClearSingleFrameRendersFinishesDispatchedTicket TEST_F(RenderTailAutoCacherTest, ClearSingleFrameRendersThatArentRunningFinishesDispatchedTicket) { - olive::ViewerOutput *viewer = CreateViewerWithParams(); + olive::ViewerOutput *viewer = create_viewer_with_params(); auto *solid = new olive::SolidGenerator(); solid->setParent(project_.get()); olive::PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); olive::RenderTicketPtr ticket = - cacher.GetSingleFrame(solid, viewer, olive::rational(0)); + cacher.get_single_frame(solid, viewer, olive::Rational(0)); ASSERT_NE(ticket, nullptr); - ASSERT_TRUE(ticket->IsRunning()); + ASSERT_TRUE(ticket->is_running()); - cacher.ClearSingleFrameRendersThatArentRunning(); + cacher.clear_single_frame_renders_that_arent_running(); - EXPECT_EQ(ticket->GetFinishCount(), 1); - EXPECT_FALSE(ticket->IsRunning()); - EXPECT_FALSE(ticket->HasResult()); + EXPECT_EQ(ticket->get_finish_count(), 1); + EXPECT_FALSE(ticket->is_running()); + EXPECT_FALSE(ticket->has_result()); QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } class RenderTailDiskCacheTest : public ::testing::Test { @@ -469,15 +469,15 @@ protected: new olive::Core(olive::Core::CoreParams()); } - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } void TearDown() override { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } - QString MakeSubDir(const QString &name) const + QString make_sub_dir(const QString &name) const { QDir root(temp_dir_.path()); if (!root.mkpath(name)) { @@ -494,25 +494,25 @@ protected: // defaults before loading the new path's index. TEST_F(RenderTailDiskCacheTest, SetPathEmitsDeletedFramesAndResetsState) { - const QString sub1 = MakeSubDir(QStringLiteral("move_from")); - const QString sub2 = MakeSubDir(QStringLiteral("move_to")); + const QString sub1 = make_sub_dir(QStringLiteral("move_from")); + const QString sub2 = make_sub_dir(QStringLiteral("move_to")); ASSERT_FALSE(sub1.isEmpty()); ASSERT_FALSE(sub2.isEmpty()); olive::DiskCacheFolder folder(sub1); - folder.SetLimit(12345); + folder.set_limit(12345); const QString fn = QDir(sub1).filePath(QStringLiteral("frame")); - ASSERT_TRUE(WriteFile(fn, 64)); - folder.CreatedFile(fn); + ASSERT_TRUE(write_file(fn, 64)); + folder.created_file(fn); - QSignalSpy spy(&folder, &olive::DiskCacheFolder::DeletedFrame); + QSignalSpy spy(&folder, &olive::DiskCacheFolder::deleted_frame); - folder.SetPath(sub2); + folder.set_path(sub2); - EXPECT_EQ(folder.GetPath(), sub2); - EXPECT_EQ(folder.GetLimit(), 21474836480LL); // back to the 20 GB default - EXPECT_FALSE(folder.GetClearOnClose()); + EXPECT_EQ(folder.get_path(), sub2); + EXPECT_EQ(folder.get_limit(), 21474836480LL); // back to the 20 GB default + EXPECT_FALSE(folder.get_clear_on_close()); ASSERT_EQ(spy.count(), 1); const QList args = spy.takeFirst(); @@ -521,7 +521,7 @@ TEST_F(RenderTailDiskCacheTest, SetPathEmitsDeletedFramesAndResetsState) // The file itself is untouched, but it is no longer tracked EXPECT_TRUE(QFileInfo::exists(fn)); - EXPECT_FALSE(folder.DeleteSpecificFile(fn)); + EXPECT_FALSE(folder.delete_specific_file(fn)); } // When the persisted index references files that have since been deleted @@ -529,18 +529,18 @@ TEST_F(RenderTailDiskCacheTest, SetPathEmitsDeletedFramesAndResetsState) // still picked up. TEST_F(RenderTailDiskCacheTest, PersistedIndexSkipsFilesThatNoLongerExist) { - const QString sub = MakeSubDir(QStringLiteral("index_skip")); + const QString sub = make_sub_dir(QStringLiteral("index_skip")); ASSERT_FALSE(sub.isEmpty()); const QString keep = QDir(sub).filePath(QStringLiteral("keep")); const QString gone = QDir(sub).filePath(QStringLiteral("gone")); - ASSERT_TRUE(WriteFile(keep, 32)); - ASSERT_TRUE(WriteFile(gone, 32)); + ASSERT_TRUE(write_file(keep, 32)); + ASSERT_TRUE(write_file(gone, 32)); { olive::DiskCacheFolder folder(sub); - folder.CreatedFile(keep); - folder.CreatedFile(gone); + folder.created_file(keep); + folder.created_file(gone); // Destruction writes the index file into the cache folder } @@ -550,8 +550,8 @@ TEST_F(RenderTailDiskCacheTest, PersistedIndexSkipsFilesThatNoLongerExist) olive::DiskCacheFolder reopened(sub); // The missing file was not re-registered, the surviving one was - EXPECT_TRUE(reopened.DeleteSpecificFile(keep)); - EXPECT_FALSE(reopened.DeleteSpecificFile(gone)); + EXPECT_TRUE(reopened.delete_specific_file(keep)); + EXPECT_FALSE(reopened.delete_specific_file(gone)); EXPECT_FALSE(QFileInfo::exists(keep)); } } @@ -560,16 +560,16 @@ TEST_F(RenderTailDiskCacheTest, PersistedIndexSkipsFilesThatNoLongerExist) // so a folder reopened after closing with the flag set must restore it. TEST_F(RenderTailDiskCacheTest, ClearOnCloseFlagPersistsAcrossInstances) { - const QString sub = MakeSubDir(QStringLiteral("persist_clear_flag")); + const QString sub = make_sub_dir(QStringLiteral("persist_clear_flag")); ASSERT_FALSE(sub.isEmpty()); const QString fn = QDir(sub).filePath(QStringLiteral("frame")); - ASSERT_TRUE(WriteFile(fn, 32)); + ASSERT_TRUE(write_file(fn, 32)); { olive::DiskCacheFolder folder(sub); - folder.SetClearOnClose(true); - folder.CreatedFile(fn); + folder.set_clear_on_close(true); + folder.created_file(fn); // Destruction clears the cache and saves the flag into the index } @@ -577,10 +577,10 @@ TEST_F(RenderTailDiskCacheTest, ClearOnCloseFlagPersistsAcrossInstances) { olive::DiskCacheFolder reopened(sub); - EXPECT_TRUE(reopened.GetClearOnClose()); + EXPECT_TRUE(reopened.get_clear_on_close()); // The cleared entry must not come back through the index either - EXPECT_FALSE(reopened.DeleteSpecificFile(fn)); + EXPECT_FALSE(reopened.delete_specific_file(fn)); } } @@ -588,18 +588,18 @@ TEST_F(RenderTailDiskCacheTest, ClearOnCloseFlagPersistsAcrossInstances) // deleting it again succeeds because a missing file counts as deleted. TEST_F(RenderTailDiskCacheTest, CreatedFileForMissingFileIsTrackedAsZeroSize) { - const QString sub = MakeSubDir(QStringLiteral("zero_size")); + const QString sub = make_sub_dir(QStringLiteral("zero_size")); ASSERT_FALSE(sub.isEmpty()); olive::DiskCacheFolder folder(sub); const QString ghost = QDir(sub).filePath(QStringLiteral("ghost")); ASSERT_FALSE(QFileInfo::exists(ghost)); - folder.CreatedFile(ghost); + folder.created_file(ghost); - QSignalSpy spy(&folder, &olive::DiskCacheFolder::DeletedFrame); + QSignalSpy spy(&folder, &olive::DiskCacheFolder::deleted_frame); - EXPECT_TRUE(folder.DeleteSpecificFile(ghost)); + EXPECT_TRUE(folder.delete_specific_file(ghost)); ASSERT_EQ(spy.count(), 1); EXPECT_EQ(spy.first().at(0).toString(), sub); @@ -615,19 +615,19 @@ TEST_F(RenderTailDiskCacheTest, olive::DiskManager *dm = olive::DiskManager::instance(); ASSERT_NE(dm, nullptr); - const QString sub = MakeSubDir(QStringLiteral("forwarding")); + const QString sub = make_sub_dir(QStringLiteral("forwarding")); ASSERT_FALSE(sub.isEmpty()); const QString fn = QDir(sub).filePath(QStringLiteral("frame")); - ASSERT_TRUE(WriteFile(fn, 32)); + ASSERT_TRUE(write_file(fn, 32)); - dm->CreatedFile(sub, fn); - dm->Accessed(sub, fn); + dm->created_file(sub, fn); + dm->accessed(sub, fn); ASSERT_TRUE(QFileInfo::exists(fn)); - QSignalSpy spy(dm, &olive::DiskManager::DeletedFrame); + QSignalSpy spy(dm, &olive::DiskManager::deleted_frame); - dm->DeleteSpecificFile(fn); + dm->delete_specific_file(fn); EXPECT_FALSE(QFileInfo::exists(fn)); ASSERT_EQ(spy.count(), 1); @@ -640,8 +640,8 @@ TEST_F(RenderTailDiskCacheTest, TEST_F(RenderTailDiskCacheTest, DefaultDiskCachePathsAreNonEmptyAndDistinct) { const QString config_file = - olive::DiskManager::GetDefaultDiskCacheConfigFile(); - const QString cache_path = olive::DiskManager::GetDefaultDiskCachePath(); + olive::DiskManager::get_default_disk_cache_config_file(); + const QString cache_path = olive::DiskManager::get_default_disk_cache_path(); EXPECT_FALSE(config_file.isEmpty()); EXPECT_FALSE(cache_path.isEmpty()); @@ -661,33 +661,33 @@ protected: new olive::Core(olive::Core::CoreParams()); // intentionally leaked } - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); // Point the project cache at a folder alongside the (unsaved) project // file so every cache write stays inside the temporary directory. - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); project_->set_filename( QDir(temp_dir_.path()).filePath(QStringLiteral("test.ove"))); - project_->SetCacheLocationSetting( - olive::Project::kCacheStoreAlongsideProject); + project_->set_cache_location_setting( + olive::Project::k_cache_store_alongside_project); } void TearDown() override { project_.reset(); - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } - static olive::core::AudioParams MakeParams() + static olive::core::AudioParams make_params() { return olive::core::AudioParams(48000, - olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); } - static void FillBuffer(olive::core::SampleBuffer *buf, float ch0, float ch1) + static void fill_buffer(olive::core::SampleBuffer *buf, float ch0, float ch1) { for (size_t i = 0; i < buf->sample_count(); i++) { buf->data(0)[i] = ch0; @@ -704,21 +704,21 @@ protected: TEST_F(RenderTailAudioCacheTest, SetParametersRoundTrip) { olive::AudioPlaybackCache cache(project_.get()); - EXPECT_EQ(cache.GetParameters().channel_count(), 0); + EXPECT_EQ(cache.get_parameters().channel_count(), 0); - const olive::core::AudioParams params = MakeParams(); - cache.SetParameters(params); - EXPECT_EQ(cache.GetParameters(), params); + const olive::core::AudioParams params = make_params(); + cache.set_parameters(params); + EXPECT_EQ(cache.get_parameters(), params); - cache.SetParameters(params); - EXPECT_EQ(cache.GetParameters(), params); + cache.set_parameters(params); + EXPECT_EQ(cache.get_parameters(), params); const olive::core::AudioParams other(44100, - olive::core::kChannelLayoutMono, - olive::core::SampleFormat::F32P); - cache.SetParameters(other); - EXPECT_EQ(cache.GetParameters().sample_rate(), 44100); - EXPECT_EQ(cache.GetParameters().channel_count(), 1); + olive::core::k_channel_layout_mono, + olive::core::SampleFormat::f32_p); + cache.set_parameters(other); + EXPECT_EQ(cache.get_parameters().sample_rate(), 44100); + EXPECT_EQ(cache.get_parameters().channel_count(), 1); } // WritePCM writes one segment file per channel, zero-padded to the full segment @@ -726,23 +726,23 @@ TEST_F(RenderTailAudioCacheTest, SetParametersRoundTrip) TEST_F(RenderTailAudioCacheTest, WritePcmWritesSegmentFilesAndValidatesRange) { olive::AudioPlaybackCache cache(project_.get()); - cache.SetParameters(MakeParams()); + cache.set_parameters(make_params()); - const olive::TimeRange range(olive::rational(0), olive::rational(1, 10)); + const olive::TimeRange range(olive::Rational(0), olive::Rational(1, 10)); - olive::core::SampleBuffer buf(MakeParams(), olive::rational(1, 10)); + olive::core::SampleBuffer buf(make_params(), olive::Rational(1, 10)); ASSERT_TRUE(buf.is_allocated()); - FillBuffer(&buf, 0.5f, 0.25f); + fill_buffer(&buf, 0.5f, 0.25f); - cache.WritePCM(range, { range }, buf); + cache.write_pcm(range, { range }, buf); - EXPECT_TRUE(cache.HasValidatedRanges()); - EXPECT_FALSE(cache.HasInvalidatedRanges(range)); + EXPECT_TRUE(cache.has_validated_ranges()); + EXPECT_FALSE(cache.has_invalidated_ranges(range)); // 4800 samples of 4-byte floats per channel const qint64 data_bytes = 19200; - const QDir seg_dir = cache.GetThisCacheDirectory(); + const QDir seg_dir = cache.get_this_cache_directory(); const QString ch0 = seg_dir.filePath(QStringLiteral("0.0")); const QString ch1 = seg_dir.filePath(QStringLiteral("0.1")); ASSERT_TRUE(QFileInfo::exists(ch0)); @@ -754,11 +754,11 @@ TEST_F(RenderTailAudioCacheTest, WritePcmWritesSegmentFilesAndValidatesRange) EXPECT_EQ(QFileInfo(ch1).size(), data_bytes); QByteArray bytes; - ASSERT_TRUE(ReadBytesAt(ch0, 0, 4, &bytes)); - EXPECT_FLOAT_EQ(BytesToFloat(bytes), 0.5f); + ASSERT_TRUE(read_bytes_at(ch0, 0, 4, &bytes)); + EXPECT_FLOAT_EQ(bytes_to_float(bytes), 0.5f); - ASSERT_TRUE(ReadBytesAt(ch1, 0, 4, &bytes)); - EXPECT_FLOAT_EQ(BytesToFloat(bytes), 0.25f); + ASSERT_TRUE(read_bytes_at(ch1, 0, 4, &bytes)); + EXPECT_FLOAT_EQ(bytes_to_float(bytes), 0.25f); } // A write that does not start at zero must seek into the segment, leaving the @@ -766,33 +766,33 @@ TEST_F(RenderTailAudioCacheTest, WritePcmWritesSegmentFilesAndValidatesRange) TEST_F(RenderTailAudioCacheTest, WritePcmAtNonZeroStartWritesAtByteOffset) { olive::AudioPlaybackCache cache(project_.get()); - cache.SetParameters(MakeParams()); + cache.set_parameters(make_params()); - const olive::TimeRange range(olive::rational(1, 10), olive::rational(1, 5)); + const olive::TimeRange range(olive::Rational(1, 10), olive::Rational(1, 5)); - olive::core::SampleBuffer buf(MakeParams(), olive::rational(1, 10)); + olive::core::SampleBuffer buf(make_params(), olive::Rational(1, 10)); ASSERT_TRUE(buf.is_allocated()); - FillBuffer(&buf, 0.75f, 0.75f); + fill_buffer(&buf, 0.75f, 0.75f); - cache.WritePCM(range, { range }, buf); + cache.write_pcm(range, { range }, buf); - EXPECT_FALSE(cache.HasInvalidatedRanges(range)); + EXPECT_FALSE(cache.has_invalidated_ranges(range)); const qint64 data_bytes = 19200; const QString ch0 = - cache.GetThisCacheDirectory().filePath(QStringLiteral("0.0")); + cache.get_this_cache_directory().filePath(QStringLiteral("0.0")); ASSERT_TRUE(QFileInfo::exists(ch0)); // The file extends exactly to the end of the written range EXPECT_EQ(QFileInfo(ch0).size(), 2 * data_bytes); // The first range was never written, so it reads back as silence QByteArray bytes; - ASSERT_TRUE(ReadBytesAt(ch0, 0, 4, &bytes)); + ASSERT_TRUE(read_bytes_at(ch0, 0, 4, &bytes)); EXPECT_EQ(bytes, QByteArray(4, '\0')); // The new data starts exactly at its byte offset - ASSERT_TRUE(ReadBytesAt(ch0, data_bytes, 4, &bytes)); - EXPECT_FLOAT_EQ(BytesToFloat(bytes), 0.75f); + ASSERT_TRUE(read_bytes_at(ch0, data_bytes, 4, &bytes)); + EXPECT_FLOAT_EQ(bytes_to_float(bytes), 0.75f); } // Only the listed valid ranges are validated, even when the sample buffer @@ -800,37 +800,37 @@ TEST_F(RenderTailAudioCacheTest, WritePcmAtNonZeroStartWritesAtByteOffset) TEST_F(RenderTailAudioCacheTest, WritePcmWithPartialValidRangesValidatesOnlyThose) { olive::AudioPlaybackCache cache(project_.get()); - cache.SetParameters(MakeParams()); + cache.set_parameters(make_params()); - const olive::TimeRange range(olive::rational(0), olive::rational(1, 5)); - const olive::TimeRange first_half(olive::rational(0), olive::rational(1, 10)); + const olive::TimeRange range(olive::Rational(0), olive::Rational(1, 5)); + const olive::TimeRange first_half(olive::Rational(0), olive::Rational(1, 10)); - olive::core::SampleBuffer buf(MakeParams(), olive::rational(1, 5)); + olive::core::SampleBuffer buf(make_params(), olive::Rational(1, 5)); ASSERT_TRUE(buf.is_allocated()); - FillBuffer(&buf, 0.5f, 0.5f); + fill_buffer(&buf, 0.5f, 0.5f); - cache.WritePCM(range, { first_half }, buf); + cache.write_pcm(range, { first_half }, buf); - EXPECT_FALSE(cache.HasInvalidatedRanges(first_half)); - EXPECT_TRUE(cache.HasInvalidatedRanges(range)); + EXPECT_FALSE(cache.has_invalidated_ranges(first_half)); + EXPECT_TRUE(cache.has_invalidated_ranges(range)); } // An empty valid-range list writes no segments and validates nothing. TEST_F(RenderTailAudioCacheTest, WritePcmWithNoValidRangesWritesNothing) { olive::AudioPlaybackCache cache(project_.get()); - cache.SetParameters(MakeParams()); + cache.set_parameters(make_params()); - const olive::TimeRange range(olive::rational(0), olive::rational(1, 10)); + const olive::TimeRange range(olive::Rational(0), olive::Rational(1, 10)); - olive::core::SampleBuffer buf(MakeParams(), olive::rational(1, 10)); + olive::core::SampleBuffer buf(make_params(), olive::Rational(1, 10)); ASSERT_TRUE(buf.is_allocated()); - cache.WritePCM(range, olive::TimeRangeList(), buf); + cache.write_pcm(range, olive::TimeRangeList(), buf); - EXPECT_FALSE(cache.HasValidatedRanges()); + EXPECT_FALSE(cache.has_validated_ranges()); EXPECT_FALSE(QFileInfo::exists( - cache.GetThisCacheDirectory().filePath(QStringLiteral("0.0")))); + cache.get_this_cache_directory().filePath(QStringLiteral("0.0")))); } // A write larger than one segment must spill into the next segment file, with @@ -839,34 +839,34 @@ TEST_F(RenderTailAudioCacheTest, WritePcmSpanningSegmentBoundaryCreatesBothSegments) { olive::AudioPlaybackCache cache(project_.get()); - cache.SetParameters(MakeParams()); + cache.set_parameters(make_params()); // 56 seconds at 48000 Hz is 10752000 bytes per channel, just over one // 10 MB segment. - const olive::TimeRange range(olive::rational(0), olive::rational(56)); + const olive::TimeRange range(olive::Rational(0), olive::Rational(56)); - olive::core::SampleBuffer buf(MakeParams(), olive::rational(56)); + olive::core::SampleBuffer buf(make_params(), olive::Rational(56)); ASSERT_TRUE(buf.is_allocated()); ASSERT_EQ(buf.sample_count(), size_t(56 * 48000)); - FillBuffer(&buf, 1.0f, 1.0f); + fill_buffer(&buf, 1.0f, 1.0f); - cache.WritePCM(range, { range }, buf); + cache.write_pcm(range, { range }, buf); - EXPECT_FALSE(cache.HasInvalidatedRanges(range)); + EXPECT_FALSE(cache.has_invalidated_ranges(range)); - const QDir seg_dir = cache.GetThisCacheDirectory(); + const QDir seg_dir = cache.get_this_cache_directory(); const QString seg0 = seg_dir.filePath(QStringLiteral("0.0")); const QString seg1 = seg_dir.filePath(QStringLiteral("1.0")); ASSERT_TRUE(QFileInfo::exists(seg0)); ASSERT_TRUE(QFileInfo::exists(seg1)); - EXPECT_EQ(QFileInfo(seg0).size(), kSegmentSize); + EXPECT_EQ(QFileInfo(seg0).size(), k_segment_size); // The second segment holds exactly the spillover bytes EXPECT_EQ(QFileInfo(seg1).size(), - 56 * 48000 * 4 - kSegmentSize); + 56 * 48000 * 4 - k_segment_size); // The spillover data starts at the beginning of the second segment file QByteArray bytes; - ASSERT_TRUE(ReadBytesAt(seg1, 0, 4, &bytes)); - EXPECT_FLOAT_EQ(BytesToFloat(bytes), 1.0f); + ASSERT_TRUE(read_bytes_at(seg1, 0, 4, &bytes)); + EXPECT_FLOAT_EQ(bytes_to_float(bytes), 1.0f); } diff --git a/tests/gtest/render_ticket_test.cpp b/tests/gtest/render_ticket_test.cpp index 2c94b7faa..68b41f4d2 100644 --- a/tests/gtest/render_ticket_test.cpp +++ b/tests/gtest/render_ticket_test.cpp @@ -10,18 +10,18 @@ using namespace olive; TEST(RenderTicketWatcher, DoesNotEmitFinishedForRunningTicketSynchronously) { RenderTicketPtr ticket = std::make_shared(); - ticket->Start(); + ticket->start(); RenderTicketWatcher watcher; - QSignalSpy spy(&watcher, &RenderTicketWatcher::Finished); + QSignalSpy spy(&watcher, &RenderTicketWatcher::finished); - watcher.SetTicket(ticket); + watcher.set_ticket(ticket); // The ticket is still running, so the watcher must not emit Finished // synchronously when SetTicket is called. EXPECT_EQ(spy.count(), 0); - ticket->Finish(); + ticket->finish(); // Once the ticket finishes, the watcher should emit Finished. spy.wait(100); @@ -31,19 +31,19 @@ TEST(RenderTicketWatcher, DoesNotEmitFinishedForRunningTicketSynchronously) TEST(RenderTicketWatcher, EmitsFinishedForAlreadyFinishedTicketAsynchronously) { RenderTicketPtr ticket = std::make_shared(); - ticket->Start(); - ticket->Finish(); + ticket->start(); + ticket->finish(); RenderTicketWatcher watcher; - QSignalSpy spy(&watcher, &RenderTicketWatcher::Finished); + QSignalSpy spy(&watcher, &RenderTicketWatcher::finished); - watcher.SetTicket(ticket); + watcher.set_ticket(ticket); // The ticket has already finished. The watcher must not delete itself or // emit Finished synchronously inside SetTicket, because the caller may still // need the returned pointer. Instead it should defer the signal. EXPECT_EQ(spy.count(), 0); - EXPECT_FALSE(watcher.GetTicket() == nullptr); + EXPECT_FALSE(watcher.get_ticket() == nullptr); // Process the queued Finished emission. QCoreApplication::processEvents(); @@ -54,81 +54,81 @@ TEST(RenderTicketWatcher, EmitsFinishedForAlreadyFinishedTicketAsynchronously) TEST(RenderTicketWatcher, CancelMarksTicketAsCancelled) { RenderTicketPtr ticket = std::make_shared(); - ticket->Start(); + ticket->start(); RenderTicketWatcher watcher; - watcher.SetTicket(ticket); + watcher.set_ticket(ticket); - EXPECT_TRUE(watcher.IsRunning()); - EXPECT_FALSE(ticket->IsCancelled()); + EXPECT_TRUE(watcher.is_running()); + EXPECT_FALSE(ticket->is_cancelled()); - watcher.Cancel(); + watcher.cancel(); - EXPECT_TRUE(ticket->IsCancelled()); + EXPECT_TRUE(ticket->is_cancelled()); } TEST(RenderTicket, HasResultIsFalseWhileRunning) { RenderTicketPtr ticket = std::make_shared(); - ticket->Start(); + ticket->start(); - EXPECT_TRUE(ticket->IsRunning()); - EXPECT_FALSE(ticket->HasResult()); + EXPECT_TRUE(ticket->is_running()); + EXPECT_FALSE(ticket->has_result()); } TEST(RenderTicket, FinishWithValueProvidesResult) { RenderTicketPtr ticket = std::make_shared(); - ticket->Start(); - ticket->Finish(QVariant(42)); + ticket->start(); + ticket->finish(QVariant(42)); - EXPECT_FALSE(ticket->IsRunning()); - EXPECT_TRUE(ticket->HasResult()); - EXPECT_EQ(ticket->Get().toInt(), 42); + EXPECT_FALSE(ticket->is_running()); + EXPECT_TRUE(ticket->has_result()); + EXPECT_EQ(ticket->get().toInt(), 42); } TEST(RenderTicket, FinishCountIncrementsOnEachFinish) { RenderTicketPtr ticket = std::make_shared(); - EXPECT_EQ(ticket->GetFinishCount(), 0); + EXPECT_EQ(ticket->get_finish_count(), 0); - ticket->Start(); - ticket->Finish(); - EXPECT_EQ(ticket->GetFinishCount(), 1); + ticket->start(); + ticket->finish(); + EXPECT_EQ(ticket->get_finish_count(), 1); - ticket->Start(); - ticket->Finish(); - EXPECT_EQ(ticket->GetFinishCount(), 2); + ticket->start(); + ticket->finish(); + EXPECT_EQ(ticket->get_finish_count(), 2); } TEST(RenderTicket, FinishWithoutStartIsIgnored) { RenderTicketPtr ticket = std::make_shared(); - ticket->Finish(); - EXPECT_EQ(ticket->GetFinishCount(), 0); + ticket->finish(); + EXPECT_EQ(ticket->get_finish_count(), 0); } TEST(RenderTicketWatcher, DelegatesGetAndHasResultToTicket) { RenderTicketPtr ticket = std::make_shared(); - ticket->Start(); - ticket->Finish(QVariant(QStringLiteral("result"))); + ticket->start(); + ticket->finish(QVariant(QStringLiteral("result"))); RenderTicketWatcher watcher; - watcher.SetTicket(ticket); + watcher.set_ticket(ticket); - EXPECT_FALSE(watcher.IsRunning()); - EXPECT_TRUE(watcher.HasResult()); - EXPECT_EQ(watcher.Get().toString(), QStringLiteral("result")); + EXPECT_FALSE(watcher.is_running()); + EXPECT_TRUE(watcher.has_result()); + EXPECT_EQ(watcher.get().toString(), QStringLiteral("result")); } TEST(RenderTicketWatcher, EmptyWatcherReturnsDefaults) { RenderTicketWatcher watcher; - EXPECT_FALSE(watcher.IsRunning()); - EXPECT_FALSE(watcher.HasResult()); - EXPECT_TRUE(watcher.Get().isNull()); - EXPECT_EQ(watcher.GetTicket(), nullptr); + EXPECT_FALSE(watcher.is_running()); + EXPECT_FALSE(watcher.has_result()); + EXPECT_TRUE(watcher.get().isNull()); + EXPECT_EQ(watcher.get_ticket(), nullptr); } TEST(RenderTicketWatcher, SettingTicketTwiceIsRejected) @@ -137,8 +137,8 @@ TEST(RenderTicketWatcher, SettingTicketTwiceIsRejected) RenderTicketPtr second = std::make_shared(); RenderTicketWatcher watcher; - watcher.SetTicket(first); - watcher.SetTicket(second); + watcher.set_ticket(first); + watcher.set_ticket(second); - EXPECT_EQ(watcher.GetTicket(), first); + EXPECT_EQ(watcher.get_ticket(), first); } diff --git a/tests/gtest/render_videoparams_branch_test.cpp b/tests/gtest/render_videoparams_branch_test.cpp index 1b2780ef5..12316a0ee 100644 --- a/tests/gtest/render_videoparams_branch_test.cpp +++ b/tests/gtest/render_videoparams_branch_test.cpp @@ -10,43 +10,43 @@ TEST(RenderVideoParams, BytesPerChannelAndPixel) { - EXPECT_EQ(olive::VideoParams::GetBytesPerChannel( - olive::core::PixelFormat::INVALID), + EXPECT_EQ(olive::VideoParams::get_bytes_per_channel( + olive::core::PixelFormat::invalid), 0); EXPECT_EQ( - olive::VideoParams::GetBytesPerChannel(olive::core::PixelFormat::U8), + olive::VideoParams::get_bytes_per_channel(olive::core::PixelFormat::u8), 1); EXPECT_EQ( - olive::VideoParams::GetBytesPerChannel(olive::core::PixelFormat::U16), + olive::VideoParams::get_bytes_per_channel(olive::core::PixelFormat::u16), 2); EXPECT_EQ( - olive::VideoParams::GetBytesPerChannel(olive::core::PixelFormat::F16), + olive::VideoParams::get_bytes_per_channel(olive::core::PixelFormat::f16), 2); EXPECT_EQ( - olive::VideoParams::GetBytesPerChannel(olive::core::PixelFormat::F32), + olive::VideoParams::get_bytes_per_channel(olive::core::PixelFormat::f32), 4); - EXPECT_EQ(olive::VideoParams::GetBytesPerPixel(olive::core::PixelFormat::U8, + EXPECT_EQ(olive::VideoParams::get_bytes_per_pixel(olive::core::PixelFormat::u8, 4), 4); } TEST(RenderVideoParams, DividerAndFormatNames) { - EXPECT_EQ(olive::VideoParams::GetNameForDivider(1), QStringLiteral("Full")); - EXPECT_EQ(olive::VideoParams::GetNameForDivider(3), QStringLiteral("1/3")); + EXPECT_EQ(olive::VideoParams::get_name_for_divider(1), QStringLiteral("Full")); + EXPECT_EQ(olive::VideoParams::get_name_for_divider(3), QStringLiteral("1/3")); const QString unknown = - olive::VideoParams::GetFormatName(olive::core::PixelFormat::INVALID); + olive::VideoParams::get_format_name(olive::core::PixelFormat::invalid); EXPECT_TRUE(unknown.contains(QStringLiteral("Unknown"))); } TEST(RenderVideoParams, ScalingAndDividerForTarget) { - EXPECT_EQ(olive::VideoParams::GetScaledDimension(100, 3), 33); - EXPECT_EQ(olive::VideoParams::GetDividerForTargetResolution(1920, 1080, 960, + EXPECT_EQ(olive::VideoParams::get_scaled_dimension(100, 3), 33); + EXPECT_EQ(olive::VideoParams::get_divider_for_target_resolution(1920, 1080, 960, 540), 2); - EXPECT_EQ(olive::VideoParams::GetDividerForTargetResolution(1920, 1080, 480, + EXPECT_EQ(olive::VideoParams::get_divider_for_target_resolution(1920, 1080, 480, 270), 4); } @@ -54,12 +54,12 @@ TEST(RenderVideoParams, ScalingAndDividerForTarget) TEST(RenderVideoParams, FrameRateStringsAndPixelAspect) { const QString fps = - olive::VideoParams::FrameRateToString(olive::core::rational(24, 1)); + olive::VideoParams::frame_rate_to_string(olive::core::Rational(24, 1)); EXPECT_TRUE(fps.contains(QStringLiteral("24"))); EXPECT_TRUE(fps.contains(QStringLiteral("FPS"))); const QStringList names = - olive::VideoParams::GetStandardPixelAspectRatioNames(); + olive::VideoParams::get_standard_pixel_aspect_ratio_names(); ASSERT_EQ(names.size(), 6); EXPECT_TRUE(names.at(0).contains(QStringLiteral("1.0000"))); } @@ -70,12 +70,12 @@ TEST(RenderVideoParams, AutoDividerAndPixelAspect) EXPECT_EQ(olive::VideoParams::generate_auto_divider(7680, 4320), 6); EXPECT_EQ(olive::VideoParams::generate_auto_divider(50000, 50000), 16); - olive::VideoParams params(100, 50, olive::core::PixelFormat::U8, 4); - params.set_pixel_aspect_ratio(olive::core::rational(0, 1)); - EXPECT_EQ(params.pixel_aspect_ratio(), olive::core::rational(1, 1)); + olive::VideoParams params(100, 50, olive::core::PixelFormat::u8, 4); + params.set_pixel_aspect_ratio(olive::core::Rational(0, 1)); + EXPECT_EQ(params.pixel_aspect_ratio(), olive::core::Rational(1, 1)); EXPECT_EQ(params.square_pixel_width(), 100); - params.set_pixel_aspect_ratio(olive::core::rational(2, 1)); + params.set_pixel_aspect_ratio(olive::core::Rational(2, 1)); EXPECT_EQ(params.square_pixel_width(), 200); } @@ -83,52 +83,52 @@ TEST(RenderVideoParams, ValidityAndTimebase) { olive::VideoParams params; EXPECT_FALSE(params.is_valid()); - EXPECT_EQ(params.get_time_in_timebase_units(olive::core::rational(1, 1)), + EXPECT_EQ(params.get_time_in_timebase_units(olive::core::Rational(1, 1)), INT64_MIN /* AV_NOPTS_VALUE */); params.set_width(1920); params.set_height(1080); - params.set_format(olive::core::PixelFormat::U8); + params.set_format(olive::core::PixelFormat::u8); params.set_channel_count(4); - params.set_pixel_aspect_ratio(olive::core::rational(1, 1)); - params.set_time_base(olive::core::rational(1, 1)); + params.set_pixel_aspect_ratio(olive::core::Rational(1, 1)); + params.set_time_base(olive::core::Rational(1, 1)); params.set_start_time(10); EXPECT_TRUE(params.is_valid()); - EXPECT_EQ(params.get_time_in_timebase_units(olive::core::rational(2, 1)), + EXPECT_EQ(params.get_time_in_timebase_units(olive::core::Rational(2, 1)), 12); } TEST(RenderVideoParams, CopyConstructorPreservesValues) { - olive::VideoParams params(1920, 1080, olive::core::rational(24, 1), - olive::core::PixelFormat::F32, 4); + olive::VideoParams params(1920, 1080, olive::core::Rational(24, 1), + olive::core::PixelFormat::f32, 4); params.set_colorspace(QStringLiteral("ACEScg")); olive::VideoParams copy(params); EXPECT_EQ(copy.width(), 1920); EXPECT_EQ(copy.height(), 1080); - EXPECT_EQ(copy.format(), olive::core::PixelFormat::F32); + EXPECT_EQ(copy.format(), olive::core::PixelFormat::f32); EXPECT_EQ(copy.channel_count(), 4); EXPECT_EQ(copy.colorspace(), QStringLiteral("ACEScg")); } TEST(RenderVideoParams, AssignmentPreservesValues) { - olive::VideoParams params(1280, 720, olive::core::rational(30, 1), - olive::core::PixelFormat::U16, 4); + olive::VideoParams params(1280, 720, olive::core::Rational(30, 1), + olive::core::PixelFormat::u16, 4); olive::VideoParams copy; copy = params; EXPECT_EQ(copy.width(), 1280); EXPECT_EQ(copy.height(), 720); - EXPECT_EQ(copy.format(), olive::core::PixelFormat::U16); + EXPECT_EQ(copy.format(), olive::core::PixelFormat::u16); } TEST(RenderVideoParams, EqualityComparesDimensionsAndFormat) { - olive::VideoParams a(1920, 1080, olive::core::PixelFormat::U8, 4); - olive::VideoParams b(1920, 1080, olive::core::PixelFormat::U8, 4); - olive::VideoParams c(1280, 720, olive::core::PixelFormat::U8, 4); - olive::VideoParams d(1920, 1080, olive::core::PixelFormat::F32, 4); + olive::VideoParams a(1920, 1080, olive::core::PixelFormat::u8, 4); + olive::VideoParams b(1920, 1080, olive::core::PixelFormat::u8, 4); + olive::VideoParams c(1280, 720, olive::core::PixelFormat::u8, 4); + olive::VideoParams d(1920, 1080, olive::core::PixelFormat::f32, 4); EXPECT_EQ(a, b); EXPECT_NE(a, c); @@ -137,23 +137,23 @@ TEST(RenderVideoParams, EqualityComparesDimensionsAndFormat) TEST(RenderVideoParams, SaveLoadRoundTripExtended) { - olive::VideoParams params(1920, 1080, olive::core::rational(1, 24), - olive::core::PixelFormat::U16, 4); + olive::VideoParams params(1920, 1080, olive::core::Rational(1, 24), + olive::core::PixelFormat::u16, 4); params.set_depth(2); - params.set_pixel_aspect_ratio(olive::core::rational(4, 3)); - params.set_interlacing(olive::VideoParams::kInterlacedTopFirst); + params.set_pixel_aspect_ratio(olive::core::Rational(4, 3)); + params.set_interlacing(olive::VideoParams::k_interlaced_top_first); params.set_divider(2); params.set_enabled(false); params.set_x(1.5f); params.set_y(-2.25f); params.set_stream_index(7); - params.set_video_type(olive::VideoParams::kVideoTypeImageSequence); - params.set_frame_rate(olive::core::rational(30000, 1001)); + params.set_video_type(olive::VideoParams::k_video_type_image_sequence); + params.set_frame_rate(olive::core::Rational(30000, 1001)); params.set_start_time(123); params.set_duration(456); params.set_premultiplied_alpha(true); params.set_colorspace(QStringLiteral("Rec.709")); - params.set_color_range(olive::VideoParams::kColorRangeFull); + params.set_color_range(olive::VideoParams::k_color_range_full); QByteArray xml; QBuffer buffer(&xml); @@ -161,7 +161,7 @@ TEST(RenderVideoParams, SaveLoadRoundTripExtended) QXmlStreamWriter writer(&buffer); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("videoparams")); - params.Save(&writer); + params.save(&writer); writer.writeEndElement(); writer.writeEndDocument(); buffer.close(); @@ -172,26 +172,26 @@ TEST(RenderVideoParams, SaveLoadRoundTripExtended) QXmlStreamReader reader(&read_buffer); ASSERT_TRUE(reader.readNextStartElement()); EXPECT_EQ(reader.name().toString(), QStringLiteral("videoparams")); - loaded.Load(&reader); + loaded.load(&reader); EXPECT_EQ(loaded.width(), 1920); EXPECT_EQ(loaded.height(), 1080); EXPECT_EQ(loaded.depth(), 2); - EXPECT_EQ(loaded.time_base(), olive::core::rational(1, 24)); - EXPECT_EQ(loaded.format(), olive::core::PixelFormat::U16); + EXPECT_EQ(loaded.time_base(), olive::core::Rational(1, 24)); + EXPECT_EQ(loaded.format(), olive::core::PixelFormat::u16); EXPECT_EQ(loaded.channel_count(), 4); - EXPECT_EQ(loaded.pixel_aspect_ratio(), olive::core::rational(4, 3)); - EXPECT_EQ(loaded.interlacing(), olive::VideoParams::kInterlacedTopFirst); + EXPECT_EQ(loaded.pixel_aspect_ratio(), olive::core::Rational(4, 3)); + EXPECT_EQ(loaded.interlacing(), olive::VideoParams::k_interlaced_top_first); EXPECT_EQ(loaded.divider(), 2); EXPECT_EQ(loaded.enabled(), false); EXPECT_FLOAT_EQ(loaded.x(), 1.5f); EXPECT_FLOAT_EQ(loaded.y(), -2.25f); EXPECT_EQ(loaded.stream_index(), 7); - EXPECT_EQ(loaded.video_type(), olive::VideoParams::kVideoTypeImageSequence); - EXPECT_EQ(loaded.frame_rate(), olive::core::rational(30000, 1001)); + EXPECT_EQ(loaded.video_type(), olive::VideoParams::k_video_type_image_sequence); + EXPECT_EQ(loaded.frame_rate(), olive::core::Rational(30000, 1001)); EXPECT_EQ(loaded.start_time(), 123); EXPECT_EQ(loaded.duration(), 456); EXPECT_TRUE(loaded.premultiplied_alpha()); EXPECT_EQ(loaded.colorspace(), QStringLiteral("Rec.709")); - EXPECT_EQ(loaded.color_range(), olive::VideoParams::kColorRangeFull); + EXPECT_EQ(loaded.color_range(), olive::VideoParams::k_color_range_full); } diff --git a/tests/gtest/render_videoparams_test.cpp b/tests/gtest/render_videoparams_test.cpp index de4ab6503..c80cdd12b 100644 --- a/tests/gtest/render_videoparams_test.cpp +++ b/tests/gtest/render_videoparams_test.cpp @@ -11,8 +11,8 @@ TEST(RenderVideoParams, SaveLoadRoundTrip) olive::VideoParams params; params.set_width(1280); params.set_height(720); - params.set_frame_rate(olive::core::rational(24, 1)); - params.set_pixel_aspect_ratio(olive::core::rational(1, 1)); + params.set_frame_rate(olive::core::Rational(24, 1)); + params.set_pixel_aspect_ratio(olive::core::Rational(1, 1)); params.set_colorspace(QStringLiteral("test")); QByteArray xml; @@ -21,7 +21,7 @@ TEST(RenderVideoParams, SaveLoadRoundTrip) QXmlStreamWriter writer(&buffer); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("videoparams")); - params.Save(&writer); + params.save(&writer); writer.writeEndElement(); writer.writeEndDocument(); buffer.close(); @@ -32,11 +32,11 @@ TEST(RenderVideoParams, SaveLoadRoundTrip) QXmlStreamReader reader(&read_buffer); EXPECT_TRUE(reader.readNextStartElement()); EXPECT_EQ(reader.name().toString(), QStringLiteral("videoparams")); - loaded.Load(&reader); + loaded.load(&reader); EXPECT_EQ(loaded.width(), 1280); EXPECT_EQ(loaded.height(), 720); - EXPECT_EQ(loaded.frame_rate(), olive::core::rational(24, 1)); - EXPECT_EQ(loaded.pixel_aspect_ratio(), olive::core::rational(1, 1)); + EXPECT_EQ(loaded.frame_rate(), olive::core::Rational(24, 1)); + EXPECT_EQ(loaded.pixel_aspect_ratio(), olive::core::Rational(1, 1)); EXPECT_EQ(loaded.colorspace(), QStringLiteral("test")); } diff --git a/tests/gtest/render_worker_footage_test.cpp b/tests/gtest/render_worker_footage_test.cpp index 9682d4230..b42f0e311 100644 --- a/tests/gtest/render_worker_footage_test.cpp +++ b/tests/gtest/render_worker_footage_test.cpp @@ -51,29 +51,29 @@ namespace { #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND -bool IsRenderBackendAvailable(const QString &backend) +bool is_render_backend_available(const QString &backend) { olive::DynamicRenderer renderer(backend); - if (!renderer.Load()) { + if (!renderer.load()) { return false; } OakRenderBackendInfo info = {}; - if (!renderer.GetBackendInfo(&info)) { + if (!renderer.get_backend_info(&info)) { return false; } if (backend == QStringLiteral("vulkan") && - info.kind != OAK_RENDER_BACKEND_VULKAN) { + info.kind != oak_render_backend_vulkan) { return false; } if (backend == QStringLiteral("opengl") && - info.kind != OAK_RENDER_BACKEND_OPENGL) { + info.kind != oak_render_backend_opengl) { return false; } - return renderer.Init(); + return renderer.init(); } #else bool IsRenderBackendAvailable(const QString &) @@ -86,11 +86,11 @@ bool IsRenderBackendAvailable(const QString &) } #endif -constexpr int kInputSlots = 1; -constexpr int kOutputSlots = 1; -constexpr int kTimeoutMs = 30000; +constexpr int k_input_slots = 1; +constexpr int k_output_slots = 1; +constexpr int k_timeout_ms = 30000; -QString WorkerBinaryPath() +QString worker_binary_path() { // The test binary lives in cmake-build-debug/tests/gtest; the worker is in // cmake-build-debug/app. @@ -105,13 +105,13 @@ QString WorkerBinaryPath() #endif } -QString DemoVideoPath() +QString demo_video_path() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/demo.mp4")); } -double SampleBrightnessF32(const void *data, int width, int height, int stride) +double sample_brightness_f32(const void *data, int width, int height, int stride) { const auto *base = reinterpret_cast(data); double avg = 0.0; @@ -135,28 +135,28 @@ class RenderWorkerFootageTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); - ProjectSerializer::Initialize(); - DiskManager::CreateInstance(); + ColorManager::set_up_default_config(); + ProjectSerializer::initialize(); + DiskManager::create_instance(); - demo_path_ = DemoVideoPath(); + demo_path_ = demo_video_path(); ASSERT_TRUE(QFileInfo::exists(demo_path_)) << "demo.mp4 not found at " << demo_path_.toStdString(); - worker_path_ = WorkerBinaryPath(); + worker_path_ = worker_binary_path(); ASSERT_TRUE(QFileInfo::exists(worker_path_)) << "worker binary not found at " << worker_path_.toStdString(); ASSERT_TRUE(temp_dir_.isValid()); // Create a minimal project containing the demo footage. - CreateProjectFile(); + create_project_file(); } void TearDown() override { - input_region_.Close(); - output_region_.Close(); + input_region_.close(); + output_region_.close(); if (worker_.state() != QProcess::NotRunning) { worker_.terminate(); worker_.waitForFinished(5000); @@ -165,47 +165,47 @@ protected: worker_.waitForFinished(5000); } } - DiskManager::DestroyInstance(); - ProjectSerializer::Destroy(); + DiskManager::destroy_instance(); + ProjectSerializer::destroy(); } - void CreateProjectFile() + void create_project_file() { project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); footage_ = new Footage(demo_path_); footage_->setParent(project_.get()); - footage_->SetLabel(QStringLiteral("demo")); - ASSERT_TRUE(footage_->IsValid()) + footage_->set_label(QStringLiteral("demo")); + ASSERT_TRUE(footage_->is_valid()) << "Footage failed to probe " << demo_path_.toStdString(); footage_id_ = QString::number(reinterpret_cast(footage_)); - project_file_ = FileFunctions::GetSafeTemporaryFilename( + project_file_ = FileFunctions::get_safe_temporary_filename( temp_dir_.filePath(QStringLiteral("worker_graph.ove"))); - ProjectSerializer::Result r = ProjectSerializer::Save( - ProjectSerializer::SaveData(ProjectSerializer::kProject, + ProjectSerializer::Result r = ProjectSerializer::save( + ProjectSerializer::SaveData(ProjectSerializer::k_project, project_.get(), project_file_), false); - ASSERT_EQ(r.code(), ProjectSerializer::kSuccess) - << "Failed to save project file: " << r.GetDetails().toStdString(); + ASSERT_EQ(r.code(), ProjectSerializer::k_success) + << "Failed to save project file: " << r.get_details().toStdString(); ASSERT_TRUE(QFileInfo::exists(project_file_)); } - bool StartWorker(const QString &backend) + bool start_worker(const QString &backend) { // ---- decode a frame so we know the dimensions and slot sizes ---- - DecoderPtr decoder = Decoder::CreateFromID(QStringLiteral("ffmpeg")); + DecoderPtr decoder = Decoder::create_from_id(QStringLiteral("ffmpeg")); if (!decoder || - !decoder->Open(Decoder::CodecStream(demo_path_, 0, nullptr))) { + !decoder->open(Decoder::CodecStream(demo_path_, 0, nullptr))) { return false; } Decoder::RetrieveVideoParams retrieve; - retrieve.time = rational(0); - retrieve.maximum_format = PixelFormat::U16; - FramePtr frame = decoder->RetrieveVideoFrame(retrieve); + retrieve.time = Rational(0); + retrieve.maximum_format = PixelFormat::u16; + FramePtr frame = decoder->retrieve_video_frame(retrieve); if (!frame || !frame->is_allocated()) { return false; } @@ -213,7 +213,7 @@ protected: input_width_ = frame->width(); input_height_ = frame->height(); input_stride_ = frame->linesize_bytes(); - input_bpc_ = VideoParams::GetBytesPerChannel(frame->format()); + input_bpc_ = VideoParams::get_bytes_per_channel(frame->format()); input_data_bytes_ = frame->allocated_size(); decoded_frame_ = frame; @@ -221,35 +221,35 @@ protected: output_width_ = 1920; output_height_ = 1080; output_data_bytes_ = size_t(output_width_) * output_height_ * 4 * - VideoParams::GetBytesPerChannel(PixelFormat::F32); + VideoParams::get_bytes_per_channel(PixelFormat::f32); // ---- create shared memory pools ---- const qint64 owner_pid = QCoreApplication::applicationPid(); - output_shm_key_ = ipc::SharedMemoryRegion::MakeKey(owner_pid, 0); - input_shm_key_ = ipc::SharedMemoryRegion::MakeKey(owner_pid, 1); + output_shm_key_ = ipc::SharedMemoryRegion::make_key(owner_pid, 0); + input_shm_key_ = ipc::SharedMemoryRegion::make_key(owner_pid, 1); const size_t output_bytes = - ipc::FrameSlotPool::BytesNeeded(kOutputSlots, output_data_bytes_); + ipc::FrameSlotPool::bytes_needed(k_output_slots, output_data_bytes_); const size_t input_bytes = - ipc::FrameSlotPool::BytesNeeded(kInputSlots, input_data_bytes_); + ipc::FrameSlotPool::bytes_needed(k_input_slots, input_data_bytes_); - if (!output_region_.Open(output_shm_key_, output_bytes, - ipc::SharedMemoryRegion::kCreate)) { + if (!output_region_.open(output_shm_key_, output_bytes, + ipc::SharedMemoryRegion::k_create)) { return false; } - if (!input_region_.Open(input_shm_key_, input_bytes, - ipc::SharedMemoryRegion::kCreate)) { + if (!input_region_.open(input_shm_key_, input_bytes, + ipc::SharedMemoryRegion::k_create)) { return false; } output_pool_ = std::make_unique( - ipc::FrameSlotPool::Create(output_region_.data(), kOutputSlots, + ipc::FrameSlotPool::create(output_region_.data(), k_output_slots, output_data_bytes_)); input_pool_ = std::make_unique( - ipc::FrameSlotPool::Create(input_region_.data(), kInputSlots, + ipc::FrameSlotPool::create(input_region_.data(), k_input_slots, input_data_bytes_)); - if (!output_pool_->IsValid() || !input_pool_->IsValid()) { + if (!output_pool_->is_valid() || !input_pool_->is_valid()) { return false; } @@ -257,16 +257,16 @@ protected: worker_.setProcessChannelMode(QProcess::SeparateChannels); worker_.start(worker_path_, QStringList{ QStringLiteral("--backend"), backend }); - if (!worker_.waitForStarted(kTimeoutMs)) { + if (!worker_.waitForStarted(k_timeout_ms)) { return false; } // ---- wait for worker handshake ---- - if (!WaitForMessage(&worker_handshake_)) { + if (!wait_for_message(&worker_handshake_)) { return false; } if (worker_handshake_[QStringLiteral("type")].toString() != - QLatin1String(ipc::msgtype::kHandshake)) { + QLatin1String(ipc::msgtype::k_handshake)) { return false; } @@ -275,24 +275,24 @@ protected: response.protocol_version = 1; response.shm_key = output_shm_key_; response.input_shm_key = input_shm_key_; - response.input_slots = kInputSlots; - response.output_slots = kOutputSlots; + response.input_slots = k_input_slots; + response.output_slots = k_output_slots; response.slot_data_bytes = qint64(output_data_bytes_); response.input_slot_data_bytes = qint64(input_data_bytes_); - if (!ipc::WriteMessage(&worker_, response.ToJson())) { + if (!ipc::write_message(&worker_, response.to_json())) { return false; } // ---- load graph ---- ipc::LoadGraphMsg load; load.path = project_file_; - if (!ipc::WriteMessage(&worker_, load.ToJson())) { + if (!ipc::write_message(&worker_, load.to_json())) { return false; } // ---- wait for graph_loaded ---- QJsonObject loaded; - if (!WaitForMessage(&loaded)) { + if (!wait_for_message(&loaded)) { return false; } if (loaded[QStringLiteral("type")].toString() != @@ -303,17 +303,17 @@ protected: return true; } - bool RenderFrameAndWait(int *output_slot) + bool render_frame_and_wait(int *output_slot) { // Publish the decoded frame to the input pool. The worker consumes it and // releases it back, so we re-publish before every render. uint32_t input_slot = 0; - if (!input_pool_->Acquire(&input_slot)) { + if (!input_pool_->acquire(&input_slot)) { return false; } - std::memcpy(input_pool_->SlotData(input_slot), + std::memcpy(input_pool_->slot_data(input_slot), decoded_frame_->const_data(), input_data_bytes_); - ipc::FrameSlotMeta *meta = input_pool_->Meta(input_slot); + ipc::FrameSlotMeta *meta = input_pool_->meta(input_slot); meta->id = 0; meta->time_num = 0; meta->time_den = 1; @@ -328,7 +328,7 @@ protected: decoded_frame_->video_params().colorspace().toUtf8().constData(), sizeof(meta->colorspace) - 1); meta->colorspace[sizeof(meta->colorspace) - 1] = '\0'; - input_pool_->Publish(input_slot); + input_pool_->publish(input_slot); ipc::RenderFrameMsg req; req.ticket_id = 1; @@ -337,24 +337,24 @@ protected: req.time_den = 1; req.width = output_width_; req.height = output_height_; - req.format = int(PixelFormat::F32); - req.channel_count = VideoParams::kRGBAChannelCount; - req.mode = int(RenderMode::kOnline); + req.format = int(PixelFormat::f32); + req.channel_count = VideoParams::k_rgba_channel_count; + req.mode = int(RenderMode::k_online); req.input_slot = 0; - if (!ipc::WriteMessage(&worker_, req.ToJson())) { + if (!ipc::write_message(&worker_, req.to_json())) { std::cerr << "RenderFrameAndWait: failed to write request" << std::endl; return false; } QJsonObject ready; - if (!WaitForMessage(&ready)) { + if (!wait_for_message(&ready)) { std::cerr << "RenderFrameAndWait: failed to receive ready message" << std::endl; return false; } if (ready[QStringLiteral("type")].toString() != - QLatin1String(ipc::msgtype::kFrameReady)) { + QLatin1String(ipc::msgtype::k_frame_ready)) { std::cerr << "RenderFrameAndWait: unexpected message type " << ready[QStringLiteral("type")].toString().toStdString() << " body=" @@ -368,16 +368,16 @@ protected: return true; } - bool WaitForMessage(QJsonObject *out) + bool wait_for_message(QJsonObject *out) { QElapsedTimer timer; timer.start(); - while (!timer.hasExpired(kTimeoutMs)) { + while (!timer.hasExpired(k_timeout_ms)) { if (worker_.waitForReadyRead(100)) { read_buffer_.append(worker_.readAllStandardOutput()); } bool ok = true; - if (ipc::ReadMessage(&read_buffer_, out, &ok)) { + if (ipc::read_message(&read_buffer_, out, &ok)) { return true; } if (!ok) { @@ -440,56 +440,56 @@ protected: TEST_F(RenderWorkerFootageTest, VulkanFootageIsNotBlack) { - if (!IsRenderBackendAvailable(QStringLiteral("vulkan"))) { + if (!is_render_backend_available(QStringLiteral("vulkan"))) { GTEST_SKIP() << "Vulkan backend is not available in this environment"; } - ASSERT_TRUE(StartWorker(QStringLiteral("vulkan"))); + ASSERT_TRUE(start_worker(QStringLiteral("vulkan"))); int output_slot = -1; - ASSERT_TRUE(RenderFrameAndWait(&output_slot)); + ASSERT_TRUE(render_frame_and_wait(&output_slot)); ASSERT_GE(output_slot, 0); - ASSERT_LT(output_slot, kOutputSlots); + ASSERT_LT(output_slot, k_output_slots); uint32_t consumed_slot = 0; - ASSERT_TRUE(output_pool_->Consume(&consumed_slot)); + ASSERT_TRUE(output_pool_->consume(&consumed_slot)); ASSERT_EQ(int(consumed_slot), output_slot); - const void *output_data = output_pool_->SlotData(consumed_slot); + const void *output_data = output_pool_->slot_data(consumed_slot); const double brightness = - SampleBrightnessF32(output_data, output_width_, output_height_, + sample_brightness_f32(output_data, output_width_, output_height_, output_width_ * 4 * int(sizeof(float))); EXPECT_GT(brightness, 0.01) << "Worker output frame is black (brightness=" << brightness << ")"; - output_pool_->Release(consumed_slot); + output_pool_->release(consumed_slot); } TEST_F(RenderWorkerFootageTest, OpenGLFootageIsNotBlack) { - if (!IsRenderBackendAvailable(QStringLiteral("opengl"))) { + if (!is_render_backend_available(QStringLiteral("opengl"))) { GTEST_SKIP() << "OpenGL backend is not available in this environment"; } - ASSERT_TRUE(StartWorker(QStringLiteral("opengl"))); + ASSERT_TRUE(start_worker(QStringLiteral("opengl"))); int output_slot = -1; - ASSERT_TRUE(RenderFrameAndWait(&output_slot)); + ASSERT_TRUE(render_frame_and_wait(&output_slot)); ASSERT_GE(output_slot, 0); - ASSERT_LT(output_slot, kOutputSlots); + ASSERT_LT(output_slot, k_output_slots); uint32_t consumed_slot = 0; - ASSERT_TRUE(output_pool_->Consume(&consumed_slot)); + ASSERT_TRUE(output_pool_->consume(&consumed_slot)); ASSERT_EQ(int(consumed_slot), output_slot); - const void *output_data = output_pool_->SlotData(consumed_slot); + const void *output_data = output_pool_->slot_data(consumed_slot); const double brightness = - SampleBrightnessF32(output_data, output_width_, output_height_, + sample_brightness_f32(output_data, output_width_, output_height_, output_width_ * 4 * int(sizeof(float))); EXPECT_GT(brightness, 0.01) << "Worker output frame is black (brightness=" << brightness << ")"; - output_pool_->Release(consumed_slot); + output_pool_->release(consumed_slot); } diff --git a/tests/gtest/render_workerpool_ipc_test.cpp b/tests/gtest/render_workerpool_ipc_test.cpp index e4236ee95..fafbddd7c 100644 --- a/tests/gtest/render_workerpool_ipc_test.cpp +++ b/tests/gtest/render_workerpool_ipc_test.cpp @@ -45,19 +45,19 @@ namespace // Unique-per-run segment key so stale POSIX segments left by earlier runs can // never collide with a test (MakeKey() bakes the pid into the key). -QString TestShmKey(const char *tag) +QString test_shm_key(const char *tag) { - return olive::ipc::SharedMemoryRegion::MakeKey( + return olive::ipc::SharedMemoryRegion::make_key( QCoreApplication::applicationPid(), 99) + QStringLiteral("-") + QLatin1String(tag); } olive::RenderManager::RenderVideoParams -MakeVideoParams(olive::Node *node, const olive::VideoParams &video_params) +make_video_params(olive::Node *node, const olive::VideoParams &video_params) { return olive::RenderManager::RenderVideoParams( node, video_params, olive::core::AudioParams(), - olive::core::rational(0), nullptr, olive::RenderMode::kOnline); + olive::core::Rational(0), nullptr, olive::RenderMode::k_online); } } // namespace @@ -68,23 +68,23 @@ MakeVideoParams(olive::Node *node, const olive::VideoParams &video_params) TEST(SharedMemoryRegion, MakeKeyFormat) { - EXPECT_EQ(olive::ipc::SharedMemoryRegion::MakeKey(12345, 3), + EXPECT_EQ(olive::ipc::SharedMemoryRegion::make_key(12345, 3), QStringLiteral("olive-rw-12345-3")); - EXPECT_NE(olive::ipc::SharedMemoryRegion::MakeKey(12345, 3), - olive::ipc::SharedMemoryRegion::MakeKey(12345, 4)); - EXPECT_NE(olive::ipc::SharedMemoryRegion::MakeKey(12345, 3), - olive::ipc::SharedMemoryRegion::MakeKey(12346, 3)); + EXPECT_NE(olive::ipc::SharedMemoryRegion::make_key(12345, 3), + olive::ipc::SharedMemoryRegion::make_key(12345, 4)); + EXPECT_NE(olive::ipc::SharedMemoryRegion::make_key(12345, 3), + olive::ipc::SharedMemoryRegion::make_key(12346, 3)); } TEST(SharedMemoryRegion, CreateProvidesZeroedWritableMemory) { - const QString key = TestShmKey("zeroed"); + const QString key = test_shm_key("zeroed"); olive::ipc::SharedMemoryRegion region; - ASSERT_TRUE(region.Open(key, 4096, olive::ipc::SharedMemoryRegion::kCreate)) + ASSERT_TRUE(region.open(key, 4096, olive::ipc::SharedMemoryRegion::k_create)) << region.error().toStdString(); - EXPECT_TRUE(region.IsValid()); + EXPECT_TRUE(region.is_valid()); EXPECT_EQ(region.size(), size_t(4096)); EXPECT_EQ(region.key(), key); ASSERT_NE(region.data(), nullptr); @@ -107,25 +107,25 @@ TEST(SharedMemoryRegion, CreateProvidesZeroedWritableMemory) TEST(SharedMemoryRegion, AttachToMissingKeyFails) { olive::ipc::SharedMemoryRegion region; - EXPECT_FALSE(region.Open(TestShmKey("missing"), 4096, - olive::ipc::SharedMemoryRegion::kAttach)); - EXPECT_FALSE(region.IsValid()); + EXPECT_FALSE(region.open(test_shm_key("missing"), 4096, + olive::ipc::SharedMemoryRegion::k_attach)); + EXPECT_FALSE(region.is_valid()); EXPECT_EQ(region.data(), nullptr); EXPECT_FALSE(region.error().isEmpty()); } TEST(SharedMemoryRegion, CreateAttachRoundTrip) { - const QString key = TestShmKey("roundtrip"); + const QString key = test_shm_key("roundtrip"); olive::ipc::SharedMemoryRegion owner; - ASSERT_TRUE(owner.Open(key, 8192, olive::ipc::SharedMemoryRegion::kCreate)) + ASSERT_TRUE(owner.open(key, 8192, olive::ipc::SharedMemoryRegion::k_create)) << owner.error().toStdString(); olive::ipc::SharedMemoryRegion peer; - ASSERT_TRUE(peer.Open(key, 8192, olive::ipc::SharedMemoryRegion::kAttach)) + ASSERT_TRUE(peer.open(key, 8192, olive::ipc::SharedMemoryRegion::k_attach)) << peer.error().toStdString(); - EXPECT_TRUE(peer.IsValid()); + EXPECT_TRUE(peer.is_valid()); EXPECT_EQ(peer.size(), size_t(8192)); EXPECT_EQ(peer.key(), key); @@ -150,52 +150,52 @@ TEST(SharedMemoryRegion, ZeroSizeCreateFails) olive::ipc::SharedMemoryRegion region; // A zero-length mapping is rejected (EINVAL from mmap on POSIX, invalid // size for CreateFileMapping on Windows). - EXPECT_FALSE(region.Open(TestShmKey("zerosize"), 0, - olive::ipc::SharedMemoryRegion::kCreate)); - EXPECT_FALSE(region.IsValid()); + EXPECT_FALSE(region.open(test_shm_key("zerosize"), 0, + olive::ipc::SharedMemoryRegion::k_create)); + EXPECT_FALSE(region.is_valid()); EXPECT_FALSE(region.error().isEmpty()); } TEST(SharedMemoryRegion, CloseInvalidatesThenReopenWorks) { olive::ipc::SharedMemoryRegion region; - ASSERT_TRUE(region.Open(TestShmKey("close1"), 4096, - olive::ipc::SharedMemoryRegion::kCreate)); + ASSERT_TRUE(region.open(test_shm_key("close1"), 4096, + olive::ipc::SharedMemoryRegion::k_create)); - region.Close(); - EXPECT_FALSE(region.IsValid()); + region.close(); + EXPECT_FALSE(region.is_valid()); EXPECT_EQ(region.data(), nullptr); EXPECT_EQ(region.size(), size_t(0)); // Close is idempotent. - region.Close(); - EXPECT_FALSE(region.IsValid()); + region.close(); + EXPECT_FALSE(region.is_valid()); // The same object can be reused for a new segment (Open() closes first). - ASSERT_TRUE(region.Open(TestShmKey("close2"), 2048, - olive::ipc::SharedMemoryRegion::kCreate)); - EXPECT_TRUE(region.IsValid()); + ASSERT_TRUE(region.open(test_shm_key("close2"), 2048, + olive::ipc::SharedMemoryRegion::k_create)); + EXPECT_TRUE(region.is_valid()); EXPECT_EQ(region.size(), size_t(2048)); } TEST(SharedMemoryRegion, OwnerDestructionUnlinksSegment) { - const QString key = TestShmKey("unlink"); + const QString key = test_shm_key("unlink"); { olive::ipc::SharedMemoryRegion owner; - ASSERT_TRUE(owner.Open(key, 4096, - olive::ipc::SharedMemoryRegion::kCreate)); + ASSERT_TRUE(owner.open(key, 4096, + olive::ipc::SharedMemoryRegion::k_create)); // While the owner lives, attaching works. olive::ipc::SharedMemoryRegion peer; ASSERT_TRUE( - peer.Open(key, 4096, olive::ipc::SharedMemoryRegion::kAttach)); + peer.open(key, 4096, olive::ipc::SharedMemoryRegion::k_attach)); } // Once the owner is destroyed the name is unlinked; new attaches fail. olive::ipc::SharedMemoryRegion late; - EXPECT_FALSE(late.Open(key, 4096, olive::ipc::SharedMemoryRegion::kAttach)); - EXPECT_FALSE(late.IsValid()); + EXPECT_FALSE(late.open(key, 4096, olive::ipc::SharedMemoryRegion::k_attach)); + EXPECT_FALSE(late.is_valid()); } // ============================================================================ @@ -205,10 +205,10 @@ TEST(SharedMemoryRegion, OwnerDestructionUnlinksSegment) TEST(FrameSlotPool, AttachRejectsBadMagic) { // A region that was never initialized by Create() has no valid magic number. - std::vector mem(olive::ipc::FrameSlotPool::BytesNeeded(2, 64), 0xAB); - olive::ipc::FrameSlotPool pool = olive::ipc::FrameSlotPool::Attach(mem.data()); + std::vector mem(olive::ipc::FrameSlotPool::bytes_needed(2, 64), 0xAB); + olive::ipc::FrameSlotPool pool = olive::ipc::FrameSlotPool::attach(mem.data()); - EXPECT_FALSE(pool.IsValid()); + EXPECT_FALSE(pool.is_valid()); EXPECT_EQ(pool.slot_count(), 0u); EXPECT_EQ(pool.slot_data_bytes(), size_t(0)); } @@ -216,7 +216,7 @@ TEST(FrameSlotPool, AttachRejectsBadMagic) TEST(FrameSlotPool, DefaultConstructedIsInvalid) { olive::ipc::FrameSlotPool pool; - EXPECT_FALSE(pool.IsValid()); + EXPECT_FALSE(pool.is_valid()); EXPECT_EQ(pool.slot_count(), 0u); EXPECT_EQ(pool.slot_data_bytes(), size_t(0)); } @@ -224,69 +224,69 @@ TEST(FrameSlotPool, DefaultConstructedIsInvalid) TEST(FrameSlotPool, BytesNeededReflectsGeometry) { // The total is a sum of 64-byte-aligned sub-regions, so it stays 64-aligned. - EXPECT_EQ(olive::ipc::FrameSlotPool::BytesNeeded(1, 64) % 64, 0u); - EXPECT_EQ(olive::ipc::FrameSlotPool::BytesNeeded(3, 1000) % 64, 0u); + EXPECT_EQ(olive::ipc::FrameSlotPool::bytes_needed(1, 64) % 64, 0u); + EXPECT_EQ(olive::ipc::FrameSlotPool::bytes_needed(3, 1000) % 64, 0u); // More slots and bigger slots both need strictly more memory... - EXPECT_LT(olive::ipc::FrameSlotPool::BytesNeeded(1, 64), - olive::ipc::FrameSlotPool::BytesNeeded(2, 64)); - EXPECT_LT(olive::ipc::FrameSlotPool::BytesNeeded(2, 64), - olive::ipc::FrameSlotPool::BytesNeeded(3, 64)); - EXPECT_LT(olive::ipc::FrameSlotPool::BytesNeeded(2, 64), - olive::ipc::FrameSlotPool::BytesNeeded(2, 128)); + EXPECT_LT(olive::ipc::FrameSlotPool::bytes_needed(1, 64), + olive::ipc::FrameSlotPool::bytes_needed(2, 64)); + EXPECT_LT(olive::ipc::FrameSlotPool::bytes_needed(2, 64), + olive::ipc::FrameSlotPool::bytes_needed(3, 64)); + EXPECT_LT(olive::ipc::FrameSlotPool::bytes_needed(2, 64), + olive::ipc::FrameSlotPool::bytes_needed(2, 128)); // ...but sizes inside the same 64-byte alignment bucket collapse together. - EXPECT_EQ(olive::ipc::FrameSlotPool::BytesNeeded(2, 65), - olive::ipc::FrameSlotPool::BytesNeeded(2, 128)); + EXPECT_EQ(olive::ipc::FrameSlotPool::bytes_needed(2, 65), + olive::ipc::FrameSlotPool::bytes_needed(2, 128)); } TEST(FrameSlotPool, SlotDataBlocksAreAlignedAndDistinct) { - constexpr uint32_t kSlots = 2; - constexpr size_t kSlotBytes = 100; // deliberately not 64-aligned + constexpr uint32_t k_slots = 2; + constexpr size_t k_slot_bytes = 100; // deliberately not 64-aligned std::vector mem( - olive::ipc::FrameSlotPool::BytesNeeded(kSlots, kSlotBytes)); + olive::ipc::FrameSlotPool::bytes_needed(k_slots, k_slot_bytes)); olive::ipc::FrameSlotPool pool = - olive::ipc::FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes); - ASSERT_TRUE(pool.IsValid()); + olive::ipc::FrameSlotPool::create(mem.data(), k_slots, k_slot_bytes); + ASSERT_TRUE(pool.is_valid()); - auto *first = static_cast(pool.SlotData(0)); - auto *second = static_cast(pool.SlotData(1)); + auto *first = static_cast(pool.slot_data(0)); + auto *second = static_cast(pool.slot_data(1)); // Slot data blocks are padded out to 64-byte boundaries within the region. EXPECT_EQ(second - first, ptrdiff_t(128)); // A full-size write to one slot never spills into the next. - std::memset(first, 0x11, kSlotBytes); - std::memset(second, 0x22, kSlotBytes); - EXPECT_EQ(first[kSlotBytes - 1], 0x11); + std::memset(first, 0x11, k_slot_bytes); + std::memset(second, 0x22, k_slot_bytes); + EXPECT_EQ(first[k_slot_bytes - 1], 0x11); EXPECT_EQ(second[0], 0x22); // The const overload maps the same addresses. const olive::ipc::FrameSlotPool &const_pool = pool; - EXPECT_EQ(static_cast(const_pool.SlotData(0)), first); - EXPECT_EQ(static_cast(const_pool.SlotData(1)), second); + EXPECT_EQ(static_cast(const_pool.slot_data(0)), first); + EXPECT_EQ(static_cast(const_pool.slot_data(1)), second); } TEST(FrameSlotPool, MetadataFieldsRoundTrip) { - constexpr uint32_t kSlots = 2; - constexpr size_t kSlotBytes = 64; + constexpr uint32_t k_slots = 2; + constexpr size_t k_slot_bytes = 64; std::vector mem( - olive::ipc::FrameSlotPool::BytesNeeded(kSlots, kSlotBytes)); + olive::ipc::FrameSlotPool::bytes_needed(k_slots, k_slot_bytes)); olive::ipc::FrameSlotPool filler = - olive::ipc::FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes); + olive::ipc::FrameSlotPool::create(mem.data(), k_slots, k_slot_bytes); olive::ipc::FrameSlotPool drainer = - olive::ipc::FrameSlotPool::Attach(mem.data()); + olive::ipc::FrameSlotPool::attach(mem.data()); uint32_t idx = 0; - ASSERT_TRUE(filler.Acquire(&idx)); + ASSERT_TRUE(filler.acquire(&idx)); // Freshly created pools zero the metadata array. const olive::ipc::FrameSlotPool &const_drainer = drainer; - const olive::ipc::FrameSlotMeta *blank = const_drainer.Meta(idx); + const olive::ipc::FrameSlotMeta *blank = const_drainer.meta(idx); EXPECT_EQ(blank->id, 0); EXPECT_EQ(blank->time_num, 0); EXPECT_EQ(blank->time_den, 0); @@ -294,155 +294,155 @@ TEST(FrameSlotPool, MetadataFieldsRoundTrip) EXPECT_EQ(blank->colorspace[0], '\0'); // Every field the producer writes survives the hand-off. - olive::ipc::FrameSlotMeta *meta = filler.Meta(idx); + olive::ipc::FrameSlotMeta *meta = filler.meta(idx); meta->id = -99; meta->time_num = 1001; meta->time_den = 30000; meta->width = 3840; meta->height = 2160; - meta->format = int(olive::core::PixelFormat::F32); + meta->format = int(olive::core::PixelFormat::f32); meta->channel_count = 4; meta->linesize = 3840 * 4 * 4; - meta->data_size = int32_t(kSlotBytes); - const char kColorspace[] = "acescg"; - std::strncpy(meta->colorspace, kColorspace, sizeof(meta->colorspace) - 1); + meta->data_size = int32_t(k_slot_bytes); + const char k_colorspace[] = "acescg"; + std::strncpy(meta->colorspace, k_colorspace, sizeof(meta->colorspace) - 1); meta->colorspace[sizeof(meta->colorspace) - 1] = '\0'; - ASSERT_TRUE(filler.Publish(idx)); + ASSERT_TRUE(filler.publish(idx)); uint32_t got = 0; - ASSERT_TRUE(drainer.Consume(&got)); + ASSERT_TRUE(drainer.consume(&got)); EXPECT_EQ(got, idx); - const olive::ipc::FrameSlotMeta *out = const_drainer.Meta(got); + const olive::ipc::FrameSlotMeta *out = const_drainer.meta(got); EXPECT_EQ(out->id, -99); EXPECT_EQ(out->time_num, 1001); EXPECT_EQ(out->time_den, 30000); EXPECT_EQ(out->width, 3840); EXPECT_EQ(out->height, 2160); - EXPECT_EQ(out->format, int(olive::core::PixelFormat::F32)); + EXPECT_EQ(out->format, int(olive::core::PixelFormat::f32)); EXPECT_EQ(out->channel_count, 4); EXPECT_EQ(out->linesize, 3840 * 4 * 4); - EXPECT_EQ(out->data_size, int32_t(kSlotBytes)); - EXPECT_STREQ(out->colorspace, kColorspace); + EXPECT_EQ(out->data_size, int32_t(k_slot_bytes)); + EXPECT_STREQ(out->colorspace, k_colorspace); - EXPECT_TRUE(drainer.Release(got)); + EXPECT_TRUE(drainer.release(got)); } TEST(FrameSlotPool, FreeSlotsAreIssuedInOrder) { - constexpr uint32_t kSlots = 4; + constexpr uint32_t k_slots = 4; std::vector mem( - olive::ipc::FrameSlotPool::BytesNeeded(kSlots, 64)); + olive::ipc::FrameSlotPool::bytes_needed(k_slots, 64)); olive::ipc::FrameSlotPool pool = - olive::ipc::FrameSlotPool::Create(mem.data(), kSlots, 64); + olive::ipc::FrameSlotPool::create(mem.data(), k_slots, 64); // Create() seeds the free ring FIFO with every slot index. - for (uint32_t expected = 0; expected < kSlots; expected++) { + for (uint32_t expected = 0; expected < k_slots; expected++) { uint32_t idx = 0; - ASSERT_TRUE(pool.Acquire(&idx)); + ASSERT_TRUE(pool.acquire(&idx)); EXPECT_EQ(idx, expected); } uint32_t overflow = 0; - EXPECT_FALSE(pool.Acquire(&overflow)); + EXPECT_FALSE(pool.acquire(&overflow)); // Released slots are re-issued in the order they were released. - ASSERT_TRUE(pool.Release(2)); - ASSERT_TRUE(pool.Release(0)); + ASSERT_TRUE(pool.release(2)); + ASSERT_TRUE(pool.release(0)); uint32_t idx = 0; - ASSERT_TRUE(pool.Acquire(&idx)); + ASSERT_TRUE(pool.acquire(&idx)); EXPECT_EQ(idx, 2u); - ASSERT_TRUE(pool.Acquire(&idx)); + ASSERT_TRUE(pool.acquire(&idx)); EXPECT_EQ(idx, 0u); } TEST(FrameSlotPool, ReadyRingDeliversInPublishOrder) { - constexpr uint32_t kSlots = 3; + constexpr uint32_t k_slots = 3; std::vector mem( - olive::ipc::FrameSlotPool::BytesNeeded(kSlots, 64)); + olive::ipc::FrameSlotPool::bytes_needed(k_slots, 64)); olive::ipc::FrameSlotPool pool = - olive::ipc::FrameSlotPool::Create(mem.data(), kSlots, 64); + olive::ipc::FrameSlotPool::create(mem.data(), k_slots, 64); uint32_t a = 0, b = 0, c = 0; - ASSERT_TRUE(pool.Acquire(&a)); - ASSERT_TRUE(pool.Acquire(&b)); - ASSERT_TRUE(pool.Acquire(&c)); + ASSERT_TRUE(pool.acquire(&a)); + ASSERT_TRUE(pool.acquire(&b)); + ASSERT_TRUE(pool.acquire(&c)); // Publish order, not slot order, determines consume order. - ASSERT_TRUE(pool.Publish(c)); - ASSERT_TRUE(pool.Publish(a)); - ASSERT_TRUE(pool.Publish(b)); + ASSERT_TRUE(pool.publish(c)); + ASSERT_TRUE(pool.publish(a)); + ASSERT_TRUE(pool.publish(b)); const uint32_t expected[] = { c, a, b }; for (uint32_t want : expected) { uint32_t got = 0; - ASSERT_TRUE(pool.Consume(&got)); + ASSERT_TRUE(pool.consume(&got)); EXPECT_EQ(got, want); - ASSERT_TRUE(pool.Release(got)); + ASSERT_TRUE(pool.release(got)); } uint32_t empty = 0; - EXPECT_FALSE(pool.Consume(&empty)); + EXPECT_FALSE(pool.consume(&empty)); } TEST(FrameSlotPool, CrossMappingHandoff) { - constexpr uint32_t kSlots = 2; - constexpr size_t kSlotBytes = 128; - const QString key = TestShmKey("pool-handoff"); + constexpr uint32_t k_slots = 2; + constexpr size_t k_slot_bytes = 128; + const QString key = test_shm_key("pool-handoff"); const size_t bytes = - olive::ipc::FrameSlotPool::BytesNeeded(kSlots, kSlotBytes); + olive::ipc::FrameSlotPool::bytes_needed(k_slots, k_slot_bytes); olive::ipc::SharedMemoryRegion owner_region; - ASSERT_TRUE(owner_region.Open(key, bytes, - olive::ipc::SharedMemoryRegion::kCreate)) + ASSERT_TRUE(owner_region.open(key, bytes, + olive::ipc::SharedMemoryRegion::k_create)) << owner_region.error().toStdString(); - olive::ipc::FrameSlotPool filler = olive::ipc::FrameSlotPool::Create( - owner_region.data(), kSlots, kSlotBytes); - ASSERT_TRUE(filler.IsValid()); + olive::ipc::FrameSlotPool filler = olive::ipc::FrameSlotPool::create( + owner_region.data(), k_slots, k_slot_bytes); + ASSERT_TRUE(filler.is_valid()); // The peer maps the same segment separately and attaches to the pool header. olive::ipc::SharedMemoryRegion peer_region; - ASSERT_TRUE(peer_region.Open(key, bytes, - olive::ipc::SharedMemoryRegion::kAttach)) + ASSERT_TRUE(peer_region.open(key, bytes, + olive::ipc::SharedMemoryRegion::k_attach)) << peer_region.error().toStdString(); olive::ipc::FrameSlotPool drainer = - olive::ipc::FrameSlotPool::Attach(peer_region.data()); - ASSERT_TRUE(drainer.IsValid()); - EXPECT_EQ(drainer.slot_count(), kSlots); - EXPECT_EQ(drainer.slot_data_bytes(), kSlotBytes); + olive::ipc::FrameSlotPool::attach(peer_region.data()); + ASSERT_TRUE(drainer.is_valid()); + EXPECT_EQ(drainer.slot_count(), k_slots); + EXPECT_EQ(drainer.slot_data_bytes(), k_slot_bytes); // Filler side: acquire a slot, stamp it, publish it. uint32_t idx = 0; - ASSERT_TRUE(filler.Acquire(&idx)); - auto *data = static_cast(filler.SlotData(idx)); - for (size_t i = 0; i < kSlotBytes; i++) { + ASSERT_TRUE(filler.acquire(&idx)); + auto *data = static_cast(filler.slot_data(idx)); + for (size_t i = 0; i < k_slot_bytes; i++) { data[i] = uint8_t(0xC3 ^ i); } - filler.Meta(idx)->id = 777; - ASSERT_TRUE(filler.Publish(idx)); + filler.meta(idx)->id = 777; + ASSERT_TRUE(filler.publish(idx)); // Drainer side (through the second mapping): same slot, meta and pixels. uint32_t got = 0; - ASSERT_TRUE(drainer.Consume(&got)); + ASSERT_TRUE(drainer.consume(&got)); EXPECT_EQ(got, idx); - EXPECT_EQ(drainer.Meta(got)->id, 777); + EXPECT_EQ(drainer.meta(got)->id, 777); const auto *peer_data = - static_cast(drainer.SlotData(got)); - for (size_t i = 0; i < kSlotBytes; i++) { + static_cast(drainer.slot_data(got)); + for (size_t i = 0; i < k_slot_bytes; i++) { ASSERT_EQ(peer_data[i], uint8_t(0xC3 ^ i)) << "byte " << i; } - ASSERT_TRUE(drainer.Release(got)); + ASSERT_TRUE(drainer.release(got)); // The release crosses back to the owner's mapping. The free ring is FIFO: // the next fresh slot comes first, then the released slot cycles back. uint32_t reacquired = 0; - ASSERT_TRUE(filler.Acquire(&reacquired)); + ASSERT_TRUE(filler.acquire(&reacquired)); EXPECT_EQ(reacquired, 1u); - ASSERT_TRUE(filler.Acquire(&reacquired)); + ASSERT_TRUE(filler.acquire(&reacquired)); EXPECT_EQ(reacquired, got); } @@ -455,12 +455,12 @@ TEST(IpcMessage, LoadGraphRoundTrip) olive::ipc::LoadGraphMsg msg; msg.path = QStringLiteral("/tmp/oak-render-graph-abc123.ove"); - const QJsonObject obj = msg.ToJson(); + const QJsonObject obj = msg.to_json(); EXPECT_EQ(obj.value(QStringLiteral("type")).toString(), - QLatin1String(olive::ipc::msgtype::kLoadGraph)); + QLatin1String(olive::ipc::msgtype::k_load_graph)); olive::ipc::LoadGraphMsg back; - ASSERT_TRUE(olive::ipc::LoadGraphMsg::FromJson(obj, &back)); + ASSERT_TRUE(olive::ipc::LoadGraphMsg::from_json(obj, &back)); EXPECT_EQ(back.path, msg.path); } @@ -473,7 +473,7 @@ TEST(IpcMessage, RenderFrameColorTransformRoundTrip) msg.time_den = 24000; msg.width = 1920; msg.height = 1080; - msg.format = int(olive::core::PixelFormat::F32); + msg.format = int(olive::core::PixelFormat::f32); msg.channel_count = 4; msg.mode = 1; msg.input_slots = { 0, 2, 5 }; @@ -483,13 +483,13 @@ TEST(IpcMessage, RenderFrameColorTransformRoundTrip) msg.color_view = QStringLiteral("ACES 1.0 SDR-video"); msg.color_look = QStringLiteral("None"); - const QJsonObject obj = msg.ToJson(); + const QJsonObject obj = msg.to_json(); EXPECT_EQ(obj.value(QStringLiteral("type")).toString(), - QLatin1String(olive::ipc::msgtype::kRenderFrame)); + QLatin1String(olive::ipc::msgtype::k_render_frame)); EXPECT_TRUE(obj.value(QStringLiteral("has_color_transform")).toBool()); olive::ipc::RenderFrameMsg back; - ASSERT_TRUE(olive::ipc::RenderFrameMsg::FromJson(obj, &back)); + ASSERT_TRUE(olive::ipc::RenderFrameMsg::from_json(obj, &back)); EXPECT_EQ(back.ticket_id, msg.ticket_id); EXPECT_EQ(back.node_uuid, msg.node_uuid); EXPECT_EQ(back.time_num, msg.time_num); @@ -510,7 +510,7 @@ TEST(IpcMessage, RenderFrameColorTransformRoundTrip) TEST(IpcMessage, RenderFrameOmitsColorTransformWhenUnset) { olive::ipc::RenderFrameMsg msg; // has_color_transform defaults to false - const QJsonObject obj = msg.ToJson(); + const QJsonObject obj = msg.to_json(); EXPECT_FALSE(obj.contains(QStringLiteral("has_color_transform"))); EXPECT_FALSE(obj.contains(QStringLiteral("color_output"))); @@ -518,7 +518,7 @@ TEST(IpcMessage, RenderFrameOmitsColorTransformWhenUnset) EXPECT_FALSE(obj.contains(QStringLiteral("color_look"))); olive::ipc::RenderFrameMsg back; - ASSERT_TRUE(olive::ipc::RenderFrameMsg::FromJson(obj, &back)); + ASSERT_TRUE(olive::ipc::RenderFrameMsg::from_json(obj, &back)); EXPECT_FALSE(back.has_color_transform); EXPECT_FALSE(back.color_is_display); EXPECT_TRUE(back.color_output.isEmpty()); @@ -530,12 +530,12 @@ TEST(IpcMessage, RenderFrameLegacyInputSlotFallback) // input_slots array when the array is absent. QJsonObject obj; obj[QStringLiteral("type")] = - QLatin1String(olive::ipc::msgtype::kRenderFrame); + QLatin1String(olive::ipc::msgtype::k_render_frame); obj[QStringLiteral("ticket")] = 5.0; obj[QStringLiteral("input_slot")] = 3; olive::ipc::RenderFrameMsg back; - ASSERT_TRUE(olive::ipc::RenderFrameMsg::FromJson(obj, &back)); + ASSERT_TRUE(olive::ipc::RenderFrameMsg::from_json(obj, &back)); EXPECT_EQ(back.input_slot, 3); ASSERT_EQ(back.input_slots.size(), 1); EXPECT_EQ(back.input_slots.first(), 3); @@ -543,7 +543,7 @@ TEST(IpcMessage, RenderFrameLegacyInputSlotFallback) // When the array is present it wins and the scalar is not duplicated. obj[QStringLiteral("input_slots")] = QJsonArray{ 7, 8 }; olive::ipc::RenderFrameMsg back2; - ASSERT_TRUE(olive::ipc::RenderFrameMsg::FromJson(obj, &back2)); + ASSERT_TRUE(olive::ipc::RenderFrameMsg::from_json(obj, &back2)); ASSERT_EQ(back2.input_slots.size(), 2); EXPECT_EQ(back2.input_slots.at(0), 7); EXPECT_EQ(back2.input_slots.at(1), 8); @@ -555,10 +555,10 @@ TEST(IpcMessage, RenderFrameDefaultsFromSparseJson) // falling back to its documented default. QJsonObject obj; obj[QStringLiteral("type")] = - QLatin1String(olive::ipc::msgtype::kRenderFrame); + QLatin1String(olive::ipc::msgtype::k_render_frame); olive::ipc::RenderFrameMsg back; - ASSERT_TRUE(olive::ipc::RenderFrameMsg::FromJson(obj, &back)); + ASSERT_TRUE(olive::ipc::RenderFrameMsg::from_json(obj, &back)); EXPECT_EQ(back.ticket_id, 0); EXPECT_TRUE(back.node_uuid.isEmpty()); EXPECT_EQ(back.time_num, 0); @@ -585,7 +585,7 @@ TEST(IpcMessage, LargeIdentifiersSurviveRoundTrip) rf.time_num = qint64(48000) * 123456789; rf.time_den = qint64(1) << 40; olive::ipc::RenderFrameMsg rf_back; - ASSERT_TRUE(olive::ipc::RenderFrameMsg::FromJson(rf.ToJson(), &rf_back)); + ASSERT_TRUE(olive::ipc::RenderFrameMsg::from_json(rf.to_json(), &rf_back)); EXPECT_EQ(rf_back.ticket_id, ticket); EXPECT_EQ(rf_back.time_num, rf.time_num); EXPECT_EQ(rf_back.time_den, rf.time_den); @@ -593,50 +593,50 @@ TEST(IpcMessage, LargeIdentifiersSurviveRoundTrip) olive::ipc::FrameReadyMsg fr; fr.ticket_id = ticket; olive::ipc::FrameReadyMsg fr_back; - ASSERT_TRUE(olive::ipc::FrameReadyMsg::FromJson(fr.ToJson(), &fr_back)); + ASSERT_TRUE(olive::ipc::FrameReadyMsg::from_json(fr.to_json(), &fr_back)); EXPECT_EQ(fr_back.ticket_id, ticket); olive::ipc::CancelMsg cancel; cancel.ticket_id = ticket; olive::ipc::CancelMsg cancel_back; - ASSERT_TRUE(olive::ipc::CancelMsg::FromJson(cancel.ToJson(), &cancel_back)); + ASSERT_TRUE(olive::ipc::CancelMsg::from_json(cancel.to_json(), &cancel_back)); EXPECT_EQ(cancel_back.ticket_id, ticket); olive::ipc::HandshakeMsg hs; hs.slot_data_bytes = slot_bytes; hs.input_slot_data_bytes = slot_bytes / 2; olive::ipc::HandshakeMsg hs_back; - ASSERT_TRUE(olive::ipc::HandshakeMsg::FromJson(hs.ToJson(), &hs_back)); + ASSERT_TRUE(olive::ipc::HandshakeMsg::from_json(hs.to_json(), &hs_back)); EXPECT_EQ(hs_back.slot_data_bytes, slot_bytes); EXPECT_EQ(hs_back.input_slot_data_bytes, slot_bytes / 2); } TEST(IpcMessage, TypedBuildersRejectMismatchedType) { - const QJsonObject hs_obj = olive::ipc::HandshakeMsg().ToJson(); - const QJsonObject rf_obj = olive::ipc::RenderFrameMsg().ToJson(); - const QJsonObject fr_obj = olive::ipc::FrameReadyMsg().ToJson(); - const QJsonObject cancel_obj = olive::ipc::CancelMsg().ToJson(); - const QJsonObject load_obj = olive::ipc::LoadGraphMsg().ToJson(); + const QJsonObject hs_obj = olive::ipc::HandshakeMsg().to_json(); + const QJsonObject rf_obj = olive::ipc::RenderFrameMsg().to_json(); + const QJsonObject fr_obj = olive::ipc::FrameReadyMsg().to_json(); + const QJsonObject cancel_obj = olive::ipc::CancelMsg().to_json(); + const QJsonObject load_obj = olive::ipc::LoadGraphMsg().to_json(); olive::ipc::HandshakeMsg hs_out; - EXPECT_FALSE(olive::ipc::HandshakeMsg::FromJson(rf_obj, &hs_out)); + EXPECT_FALSE(olive::ipc::HandshakeMsg::from_json(rf_obj, &hs_out)); olive::ipc::RenderFrameMsg rf_out; - EXPECT_FALSE(olive::ipc::RenderFrameMsg::FromJson(cancel_obj, &rf_out)); + EXPECT_FALSE(olive::ipc::RenderFrameMsg::from_json(cancel_obj, &rf_out)); olive::ipc::FrameReadyMsg fr_out; - EXPECT_FALSE(olive::ipc::FrameReadyMsg::FromJson(load_obj, &fr_out)); + EXPECT_FALSE(olive::ipc::FrameReadyMsg::from_json(load_obj, &fr_out)); olive::ipc::CancelMsg cancel_out; - EXPECT_FALSE(olive::ipc::CancelMsg::FromJson(fr_obj, &cancel_out)); + EXPECT_FALSE(olive::ipc::CancelMsg::from_json(fr_obj, &cancel_out)); olive::ipc::LoadGraphMsg load_out; - EXPECT_FALSE(olive::ipc::LoadGraphMsg::FromJson(hs_obj, &load_out)); + EXPECT_FALSE(olive::ipc::LoadGraphMsg::from_json(hs_obj, &load_out)); // An object with no "type" at all is rejected by every parser. const QJsonObject empty; - EXPECT_FALSE(olive::ipc::HandshakeMsg::FromJson(empty, &hs_out)); - EXPECT_FALSE(olive::ipc::RenderFrameMsg::FromJson(empty, &rf_out)); - EXPECT_FALSE(olive::ipc::FrameReadyMsg::FromJson(empty, &fr_out)); - EXPECT_FALSE(olive::ipc::CancelMsg::FromJson(empty, &cancel_out)); - EXPECT_FALSE(olive::ipc::LoadGraphMsg::FromJson(empty, &load_out)); + EXPECT_FALSE(olive::ipc::HandshakeMsg::from_json(empty, &hs_out)); + EXPECT_FALSE(olive::ipc::RenderFrameMsg::from_json(empty, &rf_out)); + EXPECT_FALSE(olive::ipc::FrameReadyMsg::from_json(empty, &fr_out)); + EXPECT_FALSE(olive::ipc::CancelMsg::from_json(empty, &cancel_out)); + EXPECT_FALSE(olive::ipc::LoadGraphMsg::from_json(empty, &load_out)); } TEST(IpcMessage, ReadMessageSkipsBlankLines) @@ -644,7 +644,7 @@ TEST(IpcMessage, ReadMessageSkipsBlankLines) olive::ipc::CancelMsg cancel; cancel.ticket_id = 9; const QByteArray line = - QJsonDocument(cancel.ToJson()).toJson(QJsonDocument::Compact); + QJsonDocument(cancel.to_json()).toJson(QJsonDocument::Compact); // A reader loop sees: blank line, whitespace-only line, then a real // message. Blank lines are skipped silently. @@ -652,10 +652,10 @@ TEST(IpcMessage, ReadMessageSkipsBlankLines) QJsonObject obj; bool ok = true; - ASSERT_TRUE(olive::ipc::ReadMessage(&reader, &obj, &ok)); + ASSERT_TRUE(olive::ipc::read_message(&reader, &obj, &ok)); EXPECT_TRUE(ok); olive::ipc::CancelMsg back; - ASSERT_TRUE(olive::ipc::CancelMsg::FromJson(obj, &back)); + ASSERT_TRUE(olive::ipc::CancelMsg::from_json(obj, &back)); EXPECT_EQ(back.ticket_id, 9); EXPECT_TRUE(reader.isEmpty()); } @@ -666,7 +666,7 @@ TEST(IpcMessage, ReadMessageRejectsNonObjectJson) QByteArray reader = QByteArray("[1,2,3]\n"); QJsonObject obj; bool ok = true; - EXPECT_FALSE(olive::ipc::ReadMessage(&reader, &obj, &ok)); + EXPECT_FALSE(olive::ipc::read_message(&reader, &obj, &ok)); EXPECT_FALSE(ok); EXPECT_TRUE(reader.isEmpty()); } @@ -676,14 +676,14 @@ TEST(IpcMessage, ReadMessageWorksWithoutOkPointer) olive::ipc::CancelMsg cancel; cancel.ticket_id = 4; QByteArray reader = - QJsonDocument(cancel.ToJson()).toJson(QJsonDocument::Compact); + QJsonDocument(cancel.to_json()).toJson(QJsonDocument::Compact); reader.append('\n'); QJsonObject obj; - EXPECT_TRUE(olive::ipc::ReadMessage(&reader, &obj)); // ok defaults to nullptr + EXPECT_TRUE(olive::ipc::read_message(&reader, &obj)); // ok defaults to nullptr QByteArray bad = QByteArray("garbage\n"); - EXPECT_FALSE(olive::ipc::ReadMessage(&bad, &obj)); + EXPECT_FALSE(olive::ipc::read_message(&bad, &obj)); } TEST(IpcMessage, WriteMessageProducesSingleTerminatedLine) @@ -695,7 +695,7 @@ TEST(IpcMessage, WriteMessageProducesSingleTerminatedLine) olive::ipc::HandshakeMsg hs; hs.protocol_version = 1; hs.shm_key = QStringLiteral("olive-rw-1-0"); - ASSERT_TRUE(olive::ipc::WriteMessage(&device, hs.ToJson())); + ASSERT_TRUE(olive::ipc::write_message(&device, hs.to_json())); device.close(); // NDJSON: exactly one compact line, newline-terminated. @@ -706,9 +706,9 @@ TEST(IpcMessage, WriteMessageProducesSingleTerminatedLine) // And it parses back to an identical object. QJsonObject obj; bool ok = false; - ASSERT_TRUE(olive::ipc::ReadMessage(&storage, &obj, &ok)); + ASSERT_TRUE(olive::ipc::read_message(&storage, &obj, &ok)); EXPECT_TRUE(ok); - EXPECT_EQ(obj, hs.ToJson()); + EXPECT_EQ(obj, hs.to_json()); } TEST(IpcMessage, WriteMessageFailsOnClosedDevice) @@ -717,50 +717,50 @@ TEST(IpcMessage, WriteMessageFailsOnClosedDevice) QBuffer device(&storage); // never opened: writes fail olive::ipc::CancelMsg cancel; - EXPECT_FALSE(olive::ipc::WriteMessage(&device, cancel.ToJson())); + EXPECT_FALSE(olive::ipc::write_message(&device, cancel.to_json())); EXPECT_TRUE(storage.isEmpty()); } TEST(IpcMessage, MessageTypeConstantsAreDistinct) { const QSet types = { - QString::fromUtf8(olive::ipc::msgtype::kHandshake), - QString::fromUtf8(olive::ipc::msgtype::kLoadGraph), - QString::fromUtf8(olive::ipc::msgtype::kRenderFrame), - QString::fromUtf8(olive::ipc::msgtype::kFrameReady), - QString::fromUtf8(olive::ipc::msgtype::kCancel), - QString::fromUtf8(olive::ipc::msgtype::kGraphUpdate), - QString::fromUtf8(olive::ipc::msgtype::kShutdown), - QString::fromUtf8(olive::ipc::msgtype::kError), + QString::fromUtf8(olive::ipc::msgtype::k_handshake), + QString::fromUtf8(olive::ipc::msgtype::k_load_graph), + QString::fromUtf8(olive::ipc::msgtype::k_render_frame), + QString::fromUtf8(olive::ipc::msgtype::k_frame_ready), + QString::fromUtf8(olive::ipc::msgtype::k_cancel), + QString::fromUtf8(olive::ipc::msgtype::k_graph_update), + QString::fromUtf8(olive::ipc::msgtype::k_shutdown), + QString::fromUtf8(olive::ipc::msgtype::k_error), }; EXPECT_EQ(types.size(), 8); // Each builder stamps its own constant into the "type" field. EXPECT_EQ(olive::ipc::HandshakeMsg() - .ToJson() + .to_json() .value(QStringLiteral("type")) .toString(), - QLatin1String(olive::ipc::msgtype::kHandshake)); + QLatin1String(olive::ipc::msgtype::k_handshake)); EXPECT_EQ(olive::ipc::RenderFrameMsg() - .ToJson() + .to_json() .value(QStringLiteral("type")) .toString(), - QLatin1String(olive::ipc::msgtype::kRenderFrame)); + QLatin1String(olive::ipc::msgtype::k_render_frame)); EXPECT_EQ(olive::ipc::FrameReadyMsg() - .ToJson() + .to_json() .value(QStringLiteral("type")) .toString(), - QLatin1String(olive::ipc::msgtype::kFrameReady)); + QLatin1String(olive::ipc::msgtype::k_frame_ready)); EXPECT_EQ(olive::ipc::CancelMsg() - .ToJson() + .to_json() .value(QStringLiteral("type")) .toString(), - QLatin1String(olive::ipc::msgtype::kCancel)); + QLatin1String(olive::ipc::msgtype::k_cancel)); EXPECT_EQ(olive::ipc::LoadGraphMsg() - .ToJson() + .to_json() .value(QStringLiteral("type")) .toString(), - QLatin1String(olive::ipc::msgtype::kLoadGraph)); + QLatin1String(olive::ipc::msgtype::k_load_graph)); } // ============================================================================ @@ -772,7 +772,7 @@ TEST(RenderWorkerPool, RemoveTicketRejectsNull) olive::DecoderCache cache; olive::RenderWorkerPool pool(&cache, QStringLiteral("cpu")); - EXPECT_FALSE(pool.RemoveTicket(nullptr)); + EXPECT_FALSE(pool.remove_ticket(nullptr)); } TEST(RenderWorkerPool, RemoveTicketUnknownTicketReturnsFalse) @@ -783,7 +783,7 @@ TEST(RenderWorkerPool, RemoveTicketUnknownTicketReturnsFalse) // The pool thread was never started, so the ticket can be neither queued // nor active. const olive::RenderTicketPtr ticket = std::make_shared(); - EXPECT_FALSE(pool.RemoveTicket(ticket)); + EXPECT_FALSE(pool.remove_ticket(ticket)); } TEST(RenderWorkerPool, ShutdownWithoutStartIsSafeAndIdempotent) @@ -793,8 +793,8 @@ TEST(RenderWorkerPool, ShutdownWithoutStartIsSafeAndIdempotent) // Shutdown on a pool whose thread never ran must not block or crash; the // destructor runs it once more when the pool goes out of scope. - pool.Shutdown(); - pool.Shutdown(); + pool.shutdown(); + pool.shutdown(); EXPECT_FALSE(pool.isRunning()); } @@ -804,14 +804,14 @@ TEST(RenderWorkerPool, SubmitFrameRejectsNullNode) olive::RenderWorkerPool pool(&cache, QStringLiteral("cpu")); const olive::RenderTicketPtr ticket = std::make_shared(); - EXPECT_FALSE(pool.SubmitFrame( + EXPECT_FALSE(pool.submit_frame( ticket, - MakeVideoParams(nullptr, olive::VideoParams( - 64, 64, olive::core::PixelFormat::U8, 4)))); + make_video_params(nullptr, olive::VideoParams( + 64, 64, olive::core::PixelFormat::u8, 4)))); // A rejected submission must leave the ticket untouched. - EXPECT_FALSE(ticket->IsRunning()); - EXPECT_EQ(ticket->GetFinishCount(), 0); + EXPECT_FALSE(ticket->is_running()); + EXPECT_EQ(ticket->get_finish_count(), 0); } TEST(RenderWorkerPool, SubmitFrameRejectsInvalidVideoParams) @@ -826,8 +826,8 @@ TEST(RenderWorkerPool, SubmitFrameRejectsInvalidVideoParams) const olive::RenderTicketPtr ticket = std::make_shared(); EXPECT_FALSE( - pool.SubmitFrame(ticket, MakeVideoParams(&track, olive::VideoParams()))); - EXPECT_FALSE(ticket->IsRunning()); + pool.submit_frame(ticket, make_video_params(&track, olive::VideoParams()))); + EXPECT_FALSE(ticket->is_running()); } TEST(RenderWorkerPool, SubmitFrameRejectsNonFrameReturnType) @@ -836,13 +836,13 @@ TEST(RenderWorkerPool, SubmitFrameRejectsNonFrameReturnType) olive::RenderWorkerPool pool(&cache, QStringLiteral("cpu")); olive::Track track; - olive::RenderManager::RenderVideoParams params = MakeVideoParams( - &track, olive::VideoParams(64, 64, olive::core::PixelFormat::U8, 4)); - params.return_type = olive::RenderManager::kTexture; + olive::RenderManager::RenderVideoParams params = make_video_params( + &track, olive::VideoParams(64, 64, olive::core::PixelFormat::u8, 4)); + params.return_type = olive::RenderManager::k_texture; const olive::RenderTicketPtr ticket = std::make_shared(); - EXPECT_FALSE(pool.SubmitFrame(ticket, params)); - EXPECT_FALSE(ticket->IsRunning()); + EXPECT_FALSE(pool.submit_frame(ticket, params)); + EXPECT_FALSE(ticket->is_running()); } // ============================================================================ diff --git a/tests/gtest/sequence_test.cpp b/tests/gtest/sequence_test.cpp index 1ebb2b216..2e1c65a95 100644 --- a/tests/gtest/sequence_test.cpp +++ b/tests/gtest/sequence_test.cpp @@ -14,22 +14,22 @@ namespace { -olive::Sequence *CreateSequence(olive::Project *project) +olive::Sequence *create_sequence(olive::Project *project) { auto *sequence = new olive::Sequence(); sequence->setParent(project); return sequence; } -olive::Track *CreateTrack(olive::Project *project) +olive::Track *create_track(olive::Project *project) { auto *track = new olive::Track(); track->setParent(project); return track; } -olive::ClipBlock *CreateClip(olive::Project *project, - const olive::core::rational &length) +olive::ClipBlock *create_clip(olive::Project *project, + const olive::core::Rational &length) { auto *clip = new olive::ClipBlock(); clip->setParent(project); @@ -39,11 +39,11 @@ olive::ClipBlock *CreateClip(olive::Project *project, // Mirrors what TimelineAddTrackCommand::redo() does to wire a track into a // sequence: grow the track input array, then connect the edge -void AppendTrackToList(olive::TrackList *list, olive::Track *track) +void append_track_to_list(olive::TrackList *list, olive::Track *track) { - list->ArrayAppend(); - olive::Node::ConnectEdge(track, - list->track_input(list->ArraySize() - 1)); + list->array_append(); + olive::Node::connect_edge(track, + list->track_input(list->array_size() - 1)); } } // namespace @@ -52,30 +52,30 @@ TEST(Sequence, DefaultState) { olive::Sequence sequence; - EXPECT_EQ(sequence.Name(), QStringLiteral("Sequence")); + EXPECT_EQ(sequence.name(), QStringLiteral("Sequence")); EXPECT_EQ(sequence.id(), QStringLiteral("org.olivevideoeditor.Olive.sequence")); - EXPECT_TRUE(sequence.Category().contains(olive::Node::kCategoryProject)); + EXPECT_TRUE(sequence.category().contains(olive::Node::k_category_project)); // Track input ids are generated from kTrackInputFormat - EXPECT_EQ(olive::Sequence::kTrackInputFormat.arg(0), + EXPECT_EQ(olive::Sequence::k_track_input_format.arg(0), QStringLiteral("track_in_0")); - EXPECT_EQ(olive::Sequence::kTrackInputFormat.arg(1), + EXPECT_EQ(olive::Sequence::k_track_input_format.arg(1), QStringLiteral("track_in_1")); - EXPECT_EQ(olive::Sequence::kTrackInputFormat.arg(2), + EXPECT_EQ(olive::Sequence::k_track_input_format.arg(2), QStringLiteral("track_in_2")); // One track list per track type, all empty - olive::TrackList *video = sequence.track_list(olive::Track::kVideo); - olive::TrackList *audio = sequence.track_list(olive::Track::kAudio); - olive::TrackList *subtitle = sequence.track_list(olive::Track::kSubtitle); + olive::TrackList *video = sequence.track_list(olive::Track::k_video); + olive::TrackList *audio = sequence.track_list(olive::Track::k_audio); + olive::TrackList *subtitle = sequence.track_list(olive::Track::k_subtitle); ASSERT_NE(video, nullptr); ASSERT_NE(audio, nullptr); ASSERT_NE(subtitle, nullptr); - EXPECT_EQ(video->type(), olive::Track::kVideo); - EXPECT_EQ(audio->type(), olive::Track::kAudio); - EXPECT_EQ(subtitle->type(), olive::Track::kSubtitle); + EXPECT_EQ(video->type(), olive::Track::k_video); + EXPECT_EQ(audio->type(), olive::Track::k_audio); + EXPECT_EQ(subtitle->type(), olive::Track::k_subtitle); EXPECT_EQ(video->track_input(), QStringLiteral("track_in_0")); EXPECT_EQ(audio->track_input(), QStringLiteral("track_in_1")); @@ -85,90 +85,90 @@ TEST(Sequence, DefaultState) EXPECT_EQ(audio->parent(), &sequence); EXPECT_EQ(subtitle->parent(), &sequence); - EXPECT_EQ(video->GetTrackCount(), 0); - EXPECT_EQ(video->GetTotalLength(), olive::core::rational(0)); - EXPECT_EQ(video->ArraySize(), 0); - EXPECT_EQ(video->GetTrackAt(0), nullptr); - EXPECT_EQ(video->GetTrackAt(-1), nullptr); + EXPECT_EQ(video->get_track_count(), 0); + EXPECT_EQ(video->get_total_length(), olive::core::Rational(0)); + EXPECT_EQ(video->array_size(), 0); + EXPECT_EQ(video->get_track_at(0), nullptr); + EXPECT_EQ(video->get_track_at(-1), nullptr); - EXPECT_TRUE(sequence.GetTracks().isEmpty()); - EXPECT_TRUE(sequence.GetUnlockedTracks().isEmpty()); - EXPECT_EQ(sequence.GetTrackFromReference( - olive::Track::Reference(olive::Track::kVideo, 0)), + EXPECT_TRUE(sequence.get_tracks().isEmpty()); + EXPECT_TRUE(sequence.get_unlocked_tracks().isEmpty()); + EXPECT_EQ(sequence.get_track_from_reference( + olive::Track::Reference(olive::Track::k_video, 0)), nullptr); // Invalid and out-of-range reference types return null instead of crashing - EXPECT_EQ(sequence.GetTrackFromReference( - olive::Track::Reference(olive::Track::kNone, 0)), + EXPECT_EQ(sequence.get_track_from_reference( + olive::Track::Reference(olive::Track::k_none, 0)), nullptr); - EXPECT_EQ(sequence.GetTrackFromReference( - olive::Track::Reference(olive::Track::kCount, 0)), + EXPECT_EQ(sequence.get_track_from_reference( + olive::Track::Reference(olive::Track::k_count, 0)), nullptr); // Length verification over empty track lists keeps everything at zero - sequence.VerifyLength(); - EXPECT_EQ(sequence.GetLength(), olive::core::rational(0)); - EXPECT_EQ(sequence.GetVideoLength(), olive::core::rational(0)); - EXPECT_EQ(sequence.GetAudioLength(), olive::core::rational(0)); - EXPECT_EQ(sequence.GetPlayhead(), olive::core::rational(0)); + sequence.verify_length(); + EXPECT_EQ(sequence.get_length(), olive::core::Rational(0)); + EXPECT_EQ(sequence.get_video_length(), olive::core::Rational(0)); + EXPECT_EQ(sequence.get_audio_length(), olive::core::Rational(0)); + EXPECT_EQ(sequence.get_playhead(), olive::core::Rational(0)); } TEST(Sequence, RetranslateSetsTrackInputNames) { olive::Sequence sequence; - sequence.Retranslate(); + sequence.retranslate(); - EXPECT_EQ(sequence.GetInputName(olive::Sequence::kTrackInputFormat.arg( - olive::Track::kVideo)), + EXPECT_EQ(sequence.get_input_name(olive::Sequence::k_track_input_format.arg( + olive::Track::k_video)), QStringLiteral("Video Tracks")); - EXPECT_EQ(sequence.GetInputName(olive::Sequence::kTrackInputFormat.arg( - olive::Track::kAudio)), + EXPECT_EQ(sequence.get_input_name(olive::Sequence::k_track_input_format.arg( + olive::Track::k_audio)), QStringLiteral("Audio Tracks")); - EXPECT_EQ(sequence.GetInputName(olive::Sequence::kTrackInputFormat.arg( - olive::Track::kSubtitle)), + EXPECT_EQ(sequence.get_input_name(olive::Sequence::k_track_input_format.arg( + olive::Track::k_subtitle)), QStringLiteral("Subtitle Tracks")); } TEST(Sequence, AddDefaultNodesCreatesVideoAndAudioTracks) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); QVector added; olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); - QObject::connect(sequence, &olive::Sequence::TrackAdded, + QObject::connect(sequence, &olive::Sequence::track_added, [&added](olive::Track *t) { added.append(t); }); sequence->add_default_nodes(); - olive::TrackList *video_list = sequence->track_list(olive::Track::kVideo); - olive::TrackList *audio_list = sequence->track_list(olive::Track::kAudio); + olive::TrackList *video_list = sequence->track_list(olive::Track::k_video); + olive::TrackList *audio_list = sequence->track_list(olive::Track::k_audio); olive::TrackList *subtitle_list = - sequence->track_list(olive::Track::kSubtitle); + sequence->track_list(olive::Track::k_subtitle); // One video and one audio track, no subtitle tracks - ASSERT_EQ(video_list->GetTrackCount(), 1); - ASSERT_EQ(audio_list->GetTrackCount(), 1); - EXPECT_EQ(subtitle_list->GetTrackCount(), 0); + ASSERT_EQ(video_list->get_track_count(), 1); + ASSERT_EQ(audio_list->get_track_count(), 1); + EXPECT_EQ(subtitle_list->get_track_count(), 0); - olive::Track *video_track = video_list->GetTrackAt(0); - olive::Track *audio_track = audio_list->GetTrackAt(0); + olive::Track *video_track = video_list->get_track_at(0); + olive::Track *audio_track = audio_list->get_track_at(0); ASSERT_NE(video_track, nullptr); ASSERT_NE(audio_track, nullptr); - EXPECT_EQ(video_track->type(), olive::Track::kVideo); - EXPECT_EQ(audio_track->type(), olive::Track::kAudio); + EXPECT_EQ(video_track->type(), olive::Track::k_video); + EXPECT_EQ(audio_track->type(), olive::Track::k_audio); EXPECT_EQ(video_track->sequence(), sequence); EXPECT_EQ(audio_track->sequence(), sequence); - EXPECT_EQ(video_track->Index(), 0); - EXPECT_EQ(audio_track->Index(), 0); + EXPECT_EQ(video_track->index(), 0); + EXPECT_EQ(audio_track->index(), 0); // Both tracks were reparented into the sequence's project EXPECT_EQ(video_track->parent(), &project); EXPECT_EQ(audio_track->parent(), &project); - EXPECT_EQ(video_list->GetParentGraph(), &project); + EXPECT_EQ(video_list->get_parent_graph(), &project); // The sequence forwards TrackAdded from its track lists ASSERT_EQ(added.size(), 2); @@ -176,61 +176,61 @@ TEST(Sequence, AddDefaultNodesCreatesVideoAndAudioTracks) EXPECT_TRUE(added.contains(audio_track)); // The flattened track cache contains both tracks - EXPECT_EQ(sequence->GetTracks().size(), 2); - EXPECT_TRUE(sequence->GetTracks().contains(video_track)); - EXPECT_TRUE(sequence->GetTracks().contains(audio_track)); - EXPECT_EQ(sequence->GetUnlockedTracks(), sequence->GetTracks()); + EXPECT_EQ(sequence->get_tracks().size(), 2); + EXPECT_TRUE(sequence->get_tracks().contains(video_track)); + EXPECT_TRUE(sequence->get_tracks().contains(audio_track)); + EXPECT_EQ(sequence->get_unlocked_tracks(), sequence->get_tracks()); // Track lookup by reference - EXPECT_EQ(sequence->GetTrackFromReference( - olive::Track::Reference(olive::Track::kVideo, 0)), + EXPECT_EQ(sequence->get_track_from_reference( + olive::Track::Reference(olive::Track::k_video, 0)), video_track); - EXPECT_EQ(sequence->GetTrackFromReference( - olive::Track::Reference(olive::Track::kAudio, 0)), + EXPECT_EQ(sequence->get_track_from_reference( + olive::Track::Reference(olive::Track::k_audio, 0)), audio_track); - EXPECT_EQ(sequence->GetTrackFromReference( - olive::Track::Reference(olive::Track::kSubtitle, 0)), + EXPECT_EQ(sequence->get_track_from_reference( + olive::Track::Reference(olive::Track::k_subtitle, 0)), nullptr); // The default tracks are wired straight into the viewer outputs - EXPECT_TRUE(sequence->IsInputConnected(olive::ViewerOutput::kTextureInput)); - EXPECT_TRUE(sequence->IsInputConnected(olive::ViewerOutput::kSamplesInput)); - EXPECT_EQ(sequence->GetConnectedTextureOutput(), video_track); - EXPECT_EQ(sequence->GetConnectedSampleOutput(), audio_track); + EXPECT_TRUE(sequence->is_input_connected(olive::ViewerOutput::k_texture_input)); + EXPECT_TRUE(sequence->is_input_connected(olive::ViewerOutput::k_samples_input)); + EXPECT_EQ(sequence->get_connected_texture_output(), video_track); + EXPECT_EQ(sequence->get_connected_sample_output(), audio_track); } TEST(Sequence, TrackConnectEmitsSignalsAndSetsTrackState) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); int list_added = 0; int list_changed = 0; int sequence_added = 0; olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(&project); olive::Track *list_last_added = nullptr; - QObject::connect(list, &olive::TrackList::TrackAdded, + QObject::connect(list, &olive::TrackList::track_added, [&list_added, &list_last_added](olive::Track *t) { ++list_added; list_last_added = t; }); - QObject::connect(list, &olive::TrackList::TrackListChanged, + QObject::connect(list, &olive::TrackList::track_list_changed, [&list_changed]() { ++list_changed; }); olive::Track *sequence_last_added = nullptr; - QObject::connect(sequence, &olive::Sequence::TrackAdded, + QObject::connect(sequence, &olive::Sequence::track_added, [&sequence_added, &sequence_last_added](olive::Track *t) { ++sequence_added; sequence_last_added = t; }); - list->ArrayAppend(); - EXPECT_EQ(list->ArraySize(), 1); - EXPECT_EQ(list->GetTrackCount(), 0); + list->array_append(); + EXPECT_EQ(list->array_size(), 1); + EXPECT_EQ(list->get_track_count(), 0); - olive::Node::ConnectEdge(track, list->track_input(0)); + olive::Node::connect_edge(track, list->track_input(0)); EXPECT_EQ(list_added, 1); EXPECT_EQ(list_last_added, track); @@ -239,67 +239,67 @@ TEST(Sequence, TrackConnectEmitsSignalsAndSetsTrackState) EXPECT_EQ(sequence_last_added, track); // The track adopts the list's type, sequence and cache index - EXPECT_EQ(track->type(), olive::Track::kVideo); + EXPECT_EQ(track->type(), olive::Track::k_video); EXPECT_EQ(track->sequence(), sequence); - EXPECT_EQ(track->Index(), 0); + EXPECT_EQ(track->index(), 0); - EXPECT_EQ(list->GetTrackCount(), 1); - EXPECT_EQ(list->GetTrackAt(0), track); - EXPECT_EQ(list->GetArrayIndexFromCacheIndex(0), 0); - EXPECT_EQ(list->GetCacheIndexFromArrayIndex(0), 0); - EXPECT_EQ(list->GetParentGraph(), &project); + EXPECT_EQ(list->get_track_count(), 1); + EXPECT_EQ(list->get_track_at(0), track); + EXPECT_EQ(list->get_array_index_from_cache_index(0), 0); + EXPECT_EQ(list->get_cache_index_from_array_index(0), 0); + EXPECT_EQ(list->get_parent_graph(), &project); // TrackList::track_input() builds a NodeInput pointing at the sequence const olive::NodeInput input = list->track_input(0); EXPECT_EQ(input, olive::NodeInput( - sequence, olive::Sequence::kTrackInputFormat.arg( - olive::Track::kVideo), + sequence, olive::Sequence::k_track_input_format.arg( + olive::Track::k_video), 0)); // The sequence-level cache tracks the new track - EXPECT_EQ(sequence->GetTracks(), QVector({ track })); - EXPECT_EQ(sequence->GetTrackFromReference( - olive::Track::Reference(olive::Track::kVideo, 0)), + EXPECT_EQ(sequence->get_tracks(), QVector({ track })); + EXPECT_EQ(sequence->get_track_from_reference( + olive::Track::Reference(olive::Track::k_video, 0)), track); } TEST(Sequence, TrackDisconnectResetsTrackState) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); int list_removed = 0; int sequence_removed = 0; olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); - olive::Track *first = CreateTrack(&project); - olive::Track *second = CreateTrack(&project); - AppendTrackToList(list, first); - AppendTrackToList(list, second); - ASSERT_EQ(list->GetTrackCount(), 2); + olive::Track *first = create_track(&project); + olive::Track *second = create_track(&project); + append_track_to_list(list, first); + append_track_to_list(list, second); + ASSERT_EQ(list->get_track_count(), 2); olive::Track *list_last_removed = nullptr; - QObject::connect(list, &olive::TrackList::TrackRemoved, + QObject::connect(list, &olive::TrackList::track_removed, [&list_removed, &list_last_removed](olive::Track *t) { ++list_removed; list_last_removed = t; }); - QObject::connect(sequence, &olive::Sequence::TrackRemoved, + QObject::connect(sequence, &olive::Sequence::track_removed, [&sequence_removed](olive::Track *) { ++sequence_removed; }); // While connected, track height changes are forwarded by the list int height_changed = 0; - QObject::connect(list, &olive::TrackList::TrackHeightChanged, + QObject::connect(list, &olive::TrackList::track_height_changed, [&height_changed](olive::Track *, int) { ++height_changed; }); - first->SetTrackHeight(first->GetTrackHeight() + 1.0); + first->set_track_height(first->get_track_height() + 1.0); EXPECT_EQ(height_changed, 1); - olive::Node::DisconnectEdge(first, list->track_input(0)); + olive::Node::disconnect_edge(first, list->track_input(0)); EXPECT_EQ(list_removed, 1); EXPECT_EQ(list_last_removed, first); @@ -307,225 +307,225 @@ TEST(Sequence, TrackDisconnectResetsTrackState) // The removed track is fully detached from the sequence EXPECT_EQ(first->sequence(), nullptr); - EXPECT_EQ(first->type(), olive::Track::kNone); - EXPECT_EQ(first->Index(), -1); + EXPECT_EQ(first->type(), olive::Track::k_none); + EXPECT_EQ(first->index(), -1); // Subsequent tracks shift down in the cache and get re-indexed - EXPECT_EQ(list->GetTrackCount(), 1); - EXPECT_EQ(list->GetTrackAt(0), second); - EXPECT_EQ(second->Index(), 0); + EXPECT_EQ(list->get_track_count(), 1); + EXPECT_EQ(list->get_track_at(0), second); + EXPECT_EQ(second->index(), 0); // The array element itself stays; only the cache mapping moves - EXPECT_EQ(list->ArraySize(), 2); - EXPECT_EQ(list->GetCacheIndexFromArrayIndex(0), -1); - EXPECT_EQ(list->GetCacheIndexFromArrayIndex(1), 0); - EXPECT_EQ(list->GetArrayIndexFromCacheIndex(0), 1); + EXPECT_EQ(list->array_size(), 2); + EXPECT_EQ(list->get_cache_index_from_array_index(0), -1); + EXPECT_EQ(list->get_cache_index_from_array_index(1), 0); + EXPECT_EQ(list->get_array_index_from_cache_index(0), 1); - EXPECT_EQ(sequence->GetTracks(), QVector({ second })); - EXPECT_EQ(sequence->GetTrackFromReference( - olive::Track::Reference(olive::Track::kVideo, 0)), + EXPECT_EQ(sequence->get_tracks(), QVector({ second })); + EXPECT_EQ(sequence->get_track_from_reference( + olive::Track::Reference(olive::Track::k_video, 0)), second); - EXPECT_EQ(sequence->GetTrackFromReference( - olive::Track::Reference(olive::Track::kVideo, 1)), + EXPECT_EQ(sequence->get_track_from_reference( + olive::Track::Reference(olive::Track::k_video, 1)), nullptr); // Height changes on the removed track must no longer be forwarded - first->SetTrackHeight(first->GetTrackHeight() + 1.0); + first->set_track_height(first->get_track_height() + 1.0); EXPECT_EQ(height_changed, 1); } TEST(TrackList, CacheOrderFollowsArrayIndex) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); - olive::Track *first = CreateTrack(&project); - olive::Track *second = CreateTrack(&project); + olive::Track *first = create_track(&project); + olive::Track *second = create_track(&project); - list->ArrayAppend(); - list->ArrayAppend(); + list->array_append(); + list->array_append(); // Connect the higher array element first; it takes cache index 0 for now - olive::Node::ConnectEdge(second, list->track_input(1)); - EXPECT_EQ(list->GetTrackCount(), 1); - EXPECT_EQ(list->GetTrackAt(0), second); - EXPECT_EQ(second->Index(), 0); - EXPECT_EQ(list->GetCacheIndexFromArrayIndex(0), -1); - EXPECT_EQ(list->GetCacheIndexFromArrayIndex(1), 0); + olive::Node::connect_edge(second, list->track_input(1)); + EXPECT_EQ(list->get_track_count(), 1); + EXPECT_EQ(list->get_track_at(0), second); + EXPECT_EQ(second->index(), 0); + EXPECT_EQ(list->get_cache_index_from_array_index(0), -1); + EXPECT_EQ(list->get_cache_index_from_array_index(1), 0); // Connecting element 0 inserts ahead of it in the cache - olive::Node::ConnectEdge(first, list->track_input(0)); - EXPECT_EQ(list->GetTrackCount(), 2); - EXPECT_EQ(list->GetTrackAt(0), first); - EXPECT_EQ(list->GetTrackAt(1), second); - EXPECT_EQ(first->Index(), 0); - EXPECT_EQ(second->Index(), 1); - EXPECT_EQ(list->GetCacheIndexFromArrayIndex(0), 0); - EXPECT_EQ(list->GetCacheIndexFromArrayIndex(1), 1); + olive::Node::connect_edge(first, list->track_input(0)); + EXPECT_EQ(list->get_track_count(), 2); + EXPECT_EQ(list->get_track_at(0), first); + EXPECT_EQ(list->get_track_at(1), second); + EXPECT_EQ(first->index(), 0); + EXPECT_EQ(second->index(), 1); + EXPECT_EQ(list->get_cache_index_from_array_index(0), 0); + EXPECT_EQ(list->get_cache_index_from_array_index(1), 1); // Disconnecting element 0 re-indexes the remainder of the cache - olive::Node::DisconnectEdge(first, list->track_input(0)); - EXPECT_EQ(list->GetTrackCount(), 1); - EXPECT_EQ(list->GetTrackAt(0), second); - EXPECT_EQ(second->Index(), 0); + olive::Node::disconnect_edge(first, list->track_input(0)); + EXPECT_EQ(list->get_track_count(), 1); + EXPECT_EQ(list->get_track_at(0), second); + EXPECT_EQ(second->index(), 0); } TEST(TrackList, ArrayAppendAndRemoveLast) { olive::Sequence sequence; - olive::TrackList *list = sequence.track_list(olive::Track::kAudio); + olive::TrackList *list = sequence.track_list(olive::Track::k_audio); - EXPECT_EQ(list->ArraySize(), 0); + EXPECT_EQ(list->array_size(), 0); - list->ArrayAppend(); - EXPECT_EQ(list->ArraySize(), 1); - EXPECT_EQ(list->GetTrackCount(), 0); + list->array_append(); + EXPECT_EQ(list->array_size(), 1); + EXPECT_EQ(list->get_track_count(), 0); - list->ArrayAppend(); - EXPECT_EQ(list->ArraySize(), 2); - EXPECT_EQ(list->GetTrackCount(), 0); + list->array_append(); + EXPECT_EQ(list->array_size(), 2); + EXPECT_EQ(list->get_track_count(), 0); - list->ArrayRemoveLast(); - EXPECT_EQ(list->ArraySize(), 1); + list->array_remove_last(); + EXPECT_EQ(list->array_size(), 1); - list->ArrayRemoveLast(); - EXPECT_EQ(list->ArraySize(), 0); + list->array_remove_last(); + EXPECT_EQ(list->array_size(), 0); } TEST(TrackList, NonTrackAndArrayWideConnectionsAreIgnored) { olive::Sequence sequence; - olive::TrackList *list = sequence.track_list(olive::Track::kVideo); + olive::TrackList *list = sequence.track_list(olive::Track::k_video); olive::MathNode math; olive::Track track; int changed = 0; - QObject::connect(list, &olive::TrackList::TrackListChanged, + QObject::connect(list, &olive::TrackList::track_list_changed, [&changed]() { ++changed; }); // Nodes that are not Tracks never enter the cache - list->TrackConnected(&math, 0); - EXPECT_EQ(list->GetTrackCount(), 0); + list->track_connected(&math, 0); + EXPECT_EQ(list->get_track_count(), 0); EXPECT_EQ(changed, 0); - list->TrackDisconnected(&math, 0); - EXPECT_EQ(list->GetTrackCount(), 0); + list->track_disconnected(&math, 0); + EXPECT_EQ(list->get_track_count(), 0); EXPECT_EQ(changed, 0); // Element -1 means the whole array was replaced; the cache is left alone - list->TrackConnected(&track, -1); - EXPECT_EQ(list->GetTrackCount(), 0); + list->track_connected(&track, -1); + EXPECT_EQ(list->get_track_count(), 0); EXPECT_EQ(changed, 0); EXPECT_EQ(track.sequence(), nullptr); - list->TrackDisconnected(&track, -1); - EXPECT_EQ(list->GetTrackCount(), 0); + list->track_disconnected(&track, -1); + EXPECT_EQ(list->get_track_count(), 0); EXPECT_EQ(changed, 0); } TEST(Sequence, LengthFlowsFromTracksToLengthCache) { - olive::ColorManager::SetUpDefaultConfig(); - QVector lengths; + olive::ColorManager::set_up_default_config(); + QVector lengths; olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); - QObject::connect(sequence, &olive::ViewerOutput::LengthChanged, - [&lengths](const olive::core::rational &r) { + QObject::connect(sequence, &olive::ViewerOutput::length_changed, + [&lengths](const olive::core::Rational &r) { lengths.append(r); }); // A video track with content drives the video length and total length - olive::Track *video_track = CreateTrack(&project); - video_track->AppendBlock(CreateClip(&project, olive::core::rational(5))); - AppendTrackToList(sequence->track_list(olive::Track::kVideo), video_track); + olive::Track *video_track = create_track(&project); + video_track->append_block(create_clip(&project, olive::core::Rational(5))); + append_track_to_list(sequence->track_list(olive::Track::k_video), video_track); - EXPECT_EQ(sequence->GetVideoLength(), olive::core::rational(5)); - EXPECT_EQ(sequence->GetAudioLength(), olive::core::rational(0)); - EXPECT_EQ(sequence->GetLength(), olive::core::rational(5)); + EXPECT_EQ(sequence->get_video_length(), olive::core::Rational(5)); + EXPECT_EQ(sequence->get_audio_length(), olive::core::Rational(0)); + EXPECT_EQ(sequence->get_length(), olive::core::Rational(5)); // A longer audio track takes over the total length - olive::Track *audio_track = CreateTrack(&project); - audio_track->AppendBlock(CreateClip(&project, olive::core::rational(7))); - AppendTrackToList(sequence->track_list(olive::Track::kAudio), audio_track); + olive::Track *audio_track = create_track(&project); + audio_track->append_block(create_clip(&project, olive::core::Rational(7))); + append_track_to_list(sequence->track_list(olive::Track::k_audio), audio_track); - EXPECT_EQ(sequence->GetVideoLength(), olive::core::rational(5)); - EXPECT_EQ(sequence->GetAudioLength(), olive::core::rational(7)); - EXPECT_EQ(sequence->GetLength(), olive::core::rational(7)); + EXPECT_EQ(sequence->get_video_length(), olive::core::Rational(5)); + EXPECT_EQ(sequence->get_audio_length(), olive::core::Rational(7)); + EXPECT_EQ(sequence->get_length(), olive::core::Rational(7)); // Extending a connected track ripples through to the sequence length - video_track->AppendBlock(CreateClip(&project, olive::core::rational(5))); + video_track->append_block(create_clip(&project, olive::core::Rational(5))); - EXPECT_EQ(sequence->GetVideoLength(), olive::core::rational(10)); - EXPECT_EQ(sequence->GetAudioLength(), olive::core::rational(7)); - EXPECT_EQ(sequence->GetLength(), olive::core::rational(10)); + EXPECT_EQ(sequence->get_video_length(), olive::core::Rational(10)); + EXPECT_EQ(sequence->get_audio_length(), olive::core::Rational(7)); + EXPECT_EQ(sequence->get_length(), olive::core::Rational(10)); // LengthChanged only fires when the total length actually changes EXPECT_EQ(lengths, - QVector({ olive::core::rational(5), - olive::core::rational(7), - olive::core::rational(10) })); + QVector({ olive::core::Rational(5), + olive::core::Rational(7), + olive::core::Rational(10) })); } TEST(Sequence, SubtitleTrackLengthContributesToTotalLength) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); - olive::Track *subtitle_track = CreateTrack(&project); - subtitle_track->AppendBlock(CreateClip(&project, olive::core::rational(3))); - AppendTrackToList(sequence->track_list(olive::Track::kSubtitle), + olive::Track *subtitle_track = create_track(&project); + subtitle_track->append_block(create_clip(&project, olive::core::Rational(3))); + append_track_to_list(sequence->track_list(olive::Track::k_subtitle), subtitle_track); - EXPECT_EQ(subtitle_track->type(), olive::Track::kSubtitle); - EXPECT_EQ(sequence->GetVideoLength(), olive::core::rational(0)); - EXPECT_EQ(sequence->GetAudioLength(), olive::core::rational(0)); - EXPECT_EQ(sequence->GetLength(), olive::core::rational(3)); + EXPECT_EQ(subtitle_track->type(), olive::Track::k_subtitle); + EXPECT_EQ(sequence->get_video_length(), olive::core::Rational(0)); + EXPECT_EQ(sequence->get_audio_length(), olive::core::Rational(0)); + EXPECT_EQ(sequence->get_length(), olive::core::Rational(3)); } TEST(Sequence, GetUnlockedTracksOmitsLocked) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); - olive::Track *video_a = CreateTrack(&project); - olive::Track *video_b = CreateTrack(&project); - olive::Track *audio = CreateTrack(&project); - AppendTrackToList(sequence->track_list(olive::Track::kVideo), video_a); - AppendTrackToList(sequence->track_list(olive::Track::kVideo), video_b); - AppendTrackToList(sequence->track_list(olive::Track::kAudio), audio); + olive::Track *video_a = create_track(&project); + olive::Track *video_b = create_track(&project); + olive::Track *audio = create_track(&project); + append_track_to_list(sequence->track_list(olive::Track::k_video), video_a); + append_track_to_list(sequence->track_list(olive::Track::k_video), video_b); + append_track_to_list(sequence->track_list(olive::Track::k_audio), audio); // The flattened cache is ordered by track type (video, then audio) - EXPECT_EQ(sequence->GetTracks(), + EXPECT_EQ(sequence->get_tracks(), QVector({ video_a, video_b, audio })); - EXPECT_EQ(sequence->GetUnlockedTracks(), sequence->GetTracks()); + EXPECT_EQ(sequence->get_unlocked_tracks(), sequence->get_tracks()); - video_b->SetLocked(true); - EXPECT_EQ(sequence->GetUnlockedTracks(), + video_b->set_locked(true); + EXPECT_EQ(sequence->get_unlocked_tracks(), QVector({ video_a, audio })); - video_b->SetLocked(false); - EXPECT_EQ(sequence->GetUnlockedTracks(), sequence->GetTracks()); + video_b->set_locked(false); + EXPECT_EQ(sequence->get_unlocked_tracks(), sequence->get_tracks()); } TEST(Sequence, SubtitleInvalidateEmitsSubtitlesChanged) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); QVector received; olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); - QObject::connect(sequence, &olive::Sequence::SubtitlesChanged, + QObject::connect(sequence, &olive::Sequence::subtitles_changed, [&received](const olive::core::TimeRange &r) { received.append(r); }); @@ -533,25 +533,25 @@ TEST(Sequence, SubtitleInvalidateEmitsSubtitlesChanged) // Invalidations from the subtitle track input are forwarded as a signal // (Sequence's override hides the base-class default arguments, so the // element and options must be passed explicitly) - const olive::core::TimeRange subtitle_range(olive::core::rational(1), - olive::core::rational(2)); - sequence->InvalidateCache(subtitle_range, - olive::Sequence::kTrackInputFormat.arg( - olive::Track::kSubtitle), + const olive::core::TimeRange subtitle_range(olive::core::Rational(1), + olive::core::Rational(2)); + sequence->invalidate_cache(subtitle_range, + olive::Sequence::k_track_input_format.arg( + olive::Track::k_subtitle), -1, olive::Node::InvalidateCacheOptions()); EXPECT_EQ(received, QVector({ subtitle_range })); // Invalidations from other inputs do not emit the signal - sequence->InvalidateCache( - olive::core::TimeRange(olive::core::rational(3), - olive::core::rational(4)), - olive::Sequence::kTrackInputFormat.arg(olive::Track::kVideo), -1, + sequence->invalidate_cache( + olive::core::TimeRange(olive::core::Rational(3), + olive::core::Rational(4)), + olive::Sequence::k_track_input_format.arg(olive::Track::k_video), -1, olive::Node::InvalidateCacheOptions()); - sequence->InvalidateCache( - olive::core::TimeRange(olive::core::rational(3), - olive::core::rational(4)), - olive::ViewerOutput::kTextureInput, -1, + sequence->invalidate_cache( + olive::core::TimeRange(olive::core::Rational(3), + olive::core::Rational(4)), + olive::ViewerOutput::k_texture_input, -1, olive::Node::InvalidateCacheOptions()); EXPECT_EQ(received.size(), 1); @@ -559,19 +559,19 @@ TEST(Sequence, SubtitleInvalidateEmitsSubtitlesChanged) TEST(Sequence, TrackHeightChangePropagatesThroughTrackList) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); int emissions = 0; int signal_height = 0; olive::Project project; - project.Initialize(); - olive::Sequence *sequence = CreateSequence(&project); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + project.initialize(); + olive::Sequence *sequence = create_sequence(&project); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); - olive::Track *track = CreateTrack(&project); - AppendTrackToList(list, track); + olive::Track *track = create_track(&project); + append_track_to_list(list, track); olive::Track *signal_track = nullptr; - QObject::connect(list, &olive::TrackList::TrackHeightChanged, + QObject::connect(list, &olive::TrackList::track_height_changed, [&emissions, &signal_track, &signal_height]( olive::Track *t, int h) { ++emissions; @@ -579,7 +579,7 @@ TEST(Sequence, TrackHeightChangePropagatesThroughTrackList) signal_height = h; }); - track->SetTrackHeightInPixels(96); + track->set_track_height_in_pixels(96); EXPECT_EQ(emissions, 1); EXPECT_EQ(signal_track, track); diff --git a/tests/gtest/task_cache_test.cpp b/tests/gtest/task_cache_test.cpp index a3c7f2a46..aba698c57 100644 --- a/tests/gtest/task_cache_test.cpp +++ b/tests/gtest/task_cache_test.cpp @@ -23,14 +23,14 @@ TEST(TaskCustomCache, CancelBeforeRunReturnsImmediately) olive::CustomCacheTask task(QStringLiteral("Sequence")); bool cancelled_emitted = false; - QObject::connect(&task, &olive::CustomCacheTask::Cancelled, &task, + QObject::connect(&task, &olive::CustomCacheTask::cancelled, &task, [&cancelled_emitted] { cancelled_emitted = true; }); task.Cancel(); EXPECT_TRUE(cancelled_emitted); // Run() sees the cancel flag on entry and returns without ever blocking - EXPECT_TRUE(task.Start()); + EXPECT_TRUE(task.start()); } TEST(TaskCustomCache, RunBlocksUntilCancelled) @@ -40,7 +40,7 @@ TEST(TaskCustomCache, RunBlocksUntilCancelled) bool run_returned = false; bool run_result = false; QThread *thread = QThread::create([&] { - run_result = task.Start(); + run_result = task.start(); run_returned = true; }); thread->start(); @@ -50,7 +50,7 @@ TEST(TaskCustomCache, RunBlocksUntilCancelled) EXPECT_FALSE(run_returned); bool cancelled_emitted = false; - QObject::connect(&task, &olive::CustomCacheTask::Cancelled, &task, + QObject::connect(&task, &olive::CustomCacheTask::cancelled, &task, [&cancelled_emitted] { cancelled_emitted = true; }); task.Cancel(); @@ -67,16 +67,16 @@ TEST(TaskCustomCache, FinishWakesRunWithoutEmittingCancelled) { olive::CustomCacheTask task(QStringLiteral("Sequence")); - QThread *thread = QThread::create([&] { task.Start(); }); + QThread *thread = QThread::create([&] { task.start(); }); thread->start(); EXPECT_FALSE(thread->wait(200)); bool cancelled_emitted = false; - QObject::connect(&task, &olive::CustomCacheTask::Cancelled, &task, + QObject::connect(&task, &olive::CustomCacheTask::cancelled, &task, [&cancelled_emitted] { cancelled_emitted = true; }); - task.Finish(); + task.finish(); ASSERT_TRUE(thread->wait(5000)); EXPECT_FALSE(cancelled_emitted); @@ -93,24 +93,24 @@ protected: new olive::Core(olive::Core::CoreParams()); } - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); // Use the dummy render backend so no GPU is touched (matches // preview_autocacher_test) - olive::Config::Current()[QStringLiteral("GraphicsBackend")] = + olive::Config::current()[QStringLiteral("GraphicsBackend")] = QStringLiteral("dummy"); created_disk_manager_ = (olive::DiskManager::instance() == nullptr); if (created_disk_manager_) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } created_conform_manager_ = (olive::ConformManager::instance() == nullptr); if (created_conform_manager_) { - olive::ConformManager::CreateInstance(); + olive::ConformManager::create_instance(); } created_render_manager_ = (olive::RenderManager::instance() == nullptr); if (created_render_manager_) { - olive::RenderManager::CreateInstance(); + olive::RenderManager::create_instance(); } // Sandbox the footage metadata cache so real probes write into the @@ -123,20 +123,20 @@ protected: QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override { project_.reset(); if (created_render_manager_) { - olive::RenderManager::DestroyInstance(); + olive::RenderManager::destroy_instance(); } if (created_conform_manager_) { - olive::ConformManager::DestroyInstance(); + olive::ConformManager::destroy_instance(); } if (created_disk_manager_) { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } if (had_cache_home_) { qputenv("XDG_CACHE_HOME", old_cache_home_); @@ -181,7 +181,7 @@ TEST_F(TaskPreCacheTest, ConstructorCopiesFootageIntoPrivateProject) auto *footage = new olive::Footage(path); footage->setParent(project_.get()); - ASSERT_TRUE(footage->IsValid()); + ASSERT_TRUE(footage->is_valid()); auto *sequence = new olive::Sequence(); sequence->setParent(project_.get()); @@ -192,19 +192,19 @@ TEST_F(TaskPreCacheTest, ConstructorCopiesFootageIntoPrivateProject) // not exercised here since it requires live render workers. InspectablePreCacheTask task(footage, 0, sequence); - EXPECT_TRUE(task.GetTitle().contains(path)); - EXPECT_TRUE(task.GetTitle().contains(QStringLiteral(":0"))); + EXPECT_TRUE(task.get_title().contains(path)); + EXPECT_TRUE(task.get_title().contains(QStringLiteral(":0"))); // The private viewer must mirror the sequence's parameters olive::ViewerOutput *viewer = task.viewer(); ASSERT_NE(viewer, nullptr); - EXPECT_EQ(task.video_params(), sequence->GetVideoParams()); - EXPECT_EQ(viewer->GetVideoParams(), sequence->GetVideoParams()); + EXPECT_EQ(task.video_params(), sequence->get_video_params()); + EXPECT_EQ(viewer->get_video_params(), sequence->get_video_params()); // The viewer's texture input must be fed by a private copy of the footage: // same file, different node, living in the task's private project rather // than the caller's - olive::Node *connected = viewer->GetConnectedTextureOutput(); + olive::Node *connected = viewer->get_connected_texture_output(); ASSERT_NE(connected, nullptr); EXPECT_NE(connected, footage); diff --git a/tests/gtest/task_project_test.cpp b/tests/gtest/task_project_test.cpp index 8d4197e8b..ac8cadb5c 100644 --- a/tests/gtest/task_project_test.cpp +++ b/tests/gtest/task_project_test.cpp @@ -26,7 +26,7 @@ namespace { -QString TestImagePath() +QString test_image_path() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/img.png")); @@ -45,7 +45,7 @@ protected: created_disk_manager_ = (olive::DiskManager::instance() == nullptr); if (created_disk_manager_) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } // Sandbox the footage metadata cache so real probes write into the @@ -57,17 +57,17 @@ protected: QDir().mkpath( QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override { project_.reset(); if (created_disk_manager_) { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } if (had_cache_home_) { qputenv("XDG_CACHE_HOME", old_cache_home_); @@ -94,64 +94,64 @@ TEST_F(TaskProjectImportTest, ImportOfUnprobeableFileCollectsInvalidList) } olive::ProjectImportTask task(project_->root(), { path }); - EXPECT_EQ(task.GetFileCount(), 1); + EXPECT_EQ(task.get_file_count(), 1); double last_progress = -1.0; - QObject::connect(&task, &olive::Task::ProgressChanged, &task, + QObject::connect(&task, &olive::Task::progress_changed, &task, [&last_progress](double p) { last_progress = p; }); - ASSERT_TRUE(task.Start()); + ASSERT_TRUE(task.start()); - EXPECT_TRUE(task.HasInvalidFiles()); - ASSERT_EQ(task.GetInvalidFiles().size(), 1); - EXPECT_EQ(task.GetInvalidFiles().first(), path); - EXPECT_TRUE(task.GetImportedFootage().isEmpty()); + EXPECT_TRUE(task.has_invalid_files()); + ASSERT_EQ(task.get_invalid_files().size(), 1); + EXPECT_EQ(task.get_invalid_files().first(), path); + EXPECT_TRUE(task.get_imported_footage().isEmpty()); EXPECT_DOUBLE_EQ(last_progress, 1.0); // The undo command exists but contains no children since nothing was added - ASSERT_NE(task.GetCommand(), nullptr); - EXPECT_EQ(task.GetCommand()->child_count(), 0); - delete task.GetCommand(); + ASSERT_NE(task.get_command(), nullptr); + EXPECT_EQ(task.get_command()->child_count(), 0); + delete task.get_command(); } TEST_F(TaskProjectImportTest, ImportOfImageFileAddsFootageThroughUndoCommand) { - const QString path = TestImagePath(); + const QString path = test_image_path(); ASSERT_TRUE(QFileInfo::exists(path)); olive::ProjectImportTask task(project_->root(), { path }); - EXPECT_EQ(task.GetFileCount(), 1); + EXPECT_EQ(task.get_file_count(), 1); - ASSERT_TRUE(task.Start()); + ASSERT_TRUE(task.start()); - EXPECT_FALSE(task.HasInvalidFiles()); - ASSERT_EQ(task.GetImportedFootage().size(), 1); + EXPECT_FALSE(task.has_invalid_files()); + ASSERT_EQ(task.get_imported_footage().size(), 1); - olive::Footage *footage = task.GetImportedFootage().first(); + olive::Footage *footage = task.get_imported_footage().first(); EXPECT_EQ(footage->filename(), path); - EXPECT_EQ(footage->GetLabel(), QStringLiteral("img.png")); - EXPECT_TRUE(footage->IsValid()); + EXPECT_EQ(footage->get_label(), QStringLiteral("img.png")); + EXPECT_TRUE(footage->is_valid()); // Nothing is in the folder until the command is redone EXPECT_TRUE(project_->root()->children().isEmpty()); - ASSERT_NE(task.GetCommand(), nullptr); - task.GetCommand()->redo_now(); + ASSERT_NE(task.get_command(), nullptr); + task.get_command()->redo_now(); ASSERT_EQ(project_->root()->children().size(), 1); EXPECT_EQ(project_->root()->children().first(), static_cast(footage)); EXPECT_TRUE(project_->nodes().contains(footage)); - task.GetCommand()->undo_now(); + task.get_command()->undo_now(); EXPECT_TRUE(project_->root()->children().isEmpty()); - delete task.GetCommand(); + delete task.get_command(); } TEST_F(TaskProjectImportTest, ImportOfDirectoryCreatesFolderHierarchy) { - const QString src = TestImagePath(); + const QString src = test_image_path(); ASSERT_TRUE(QFileInfo::exists(src)); const QString dir_path = @@ -165,50 +165,50 @@ TEST_F(TaskProjectImportTest, ImportOfDirectoryCreatesFolderHierarchy) ASSERT_TRUE(QFile::copy(src, second)); olive::ProjectImportTask task(project_->root(), { dir_path }); - EXPECT_EQ(task.GetFileCount(), 2); + EXPECT_EQ(task.get_file_count(), 2); - ASSERT_TRUE(task.Start()); - EXPECT_FALSE(task.HasInvalidFiles()); - EXPECT_EQ(task.GetImportedFootage().size(), 2); + ASSERT_TRUE(task.start()); + EXPECT_FALSE(task.has_invalid_files()); + EXPECT_EQ(task.get_imported_footage().size(), 2); - ASSERT_NE(task.GetCommand(), nullptr); - task.GetCommand()->redo_now(); + ASSERT_NE(task.get_command(), nullptr); + task.get_command()->redo_now(); // Importing a directory creates a folder named after it under the target const QVector &root_children = project_->root()->children(); ASSERT_EQ(root_children.size(), 1); auto *top_folder = dynamic_cast(root_children.first()); ASSERT_NE(top_folder, nullptr); - EXPECT_EQ(top_folder->GetLabel(), QStringLiteral("media")); + EXPECT_EQ(top_folder->get_label(), QStringLiteral("media")); // ...which holds the first image plus a subfolder with the second image QVector all_footage = - top_folder->ListChildrenOfType(); + top_folder->list_children_of_type(); EXPECT_EQ(all_footage.size(), 2); QVector sub_folders = - top_folder->ListChildrenOfType(); + top_folder->list_children_of_type(); ASSERT_EQ(sub_folders.size(), 1); - EXPECT_EQ(sub_folders.first()->GetLabel(), QStringLiteral("sub")); + EXPECT_EQ(sub_folders.first()->get_label(), QStringLiteral("sub")); - task.GetCommand()->undo_now(); + task.get_command()->undo_now(); EXPECT_TRUE(project_->root()->children().isEmpty()); - delete task.GetCommand(); + delete task.get_command(); } TEST_F(TaskProjectImportTest, CancelledBeforeRunReturnsFalseAndDropsCommand) { - const QString path = TestImagePath(); + const QString path = test_image_path(); ASSERT_TRUE(QFileInfo::exists(path)); olive::ProjectImportTask task(project_->root(), { path }); task.Cancel(); - EXPECT_FALSE(task.Start()); - EXPECT_EQ(task.GetCommand(), nullptr); - EXPECT_TRUE(task.GetImportedFootage().isEmpty()); - EXPECT_FALSE(task.HasInvalidFiles()); + EXPECT_FALSE(task.start()); + EXPECT_EQ(task.get_command(), nullptr); + EXPECT_TRUE(task.get_imported_footage().isEmpty()); + EXPECT_FALSE(task.has_invalid_files()); EXPECT_TRUE(project_->root()->children().isEmpty()); } @@ -256,31 +256,31 @@ protected: { created_disk_manager_ = (olive::DiskManager::instance() == nullptr); if (created_disk_manager_) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } - olive::ColorManager::SetUpDefaultConfig(); - olive::NodeFactory::Initialize(); - olive::ProjectSerializer::Initialize(); + olive::ColorManager::set_up_default_config(); + olive::NodeFactory::initialize(); + olive::ProjectSerializer::initialize(); } void TearDown() override { - olive::ProjectSerializer::Destroy(); + olive::ProjectSerializer::destroy(); if (created_disk_manager_) { - olive::DiskManager::DestroyInstance(); + olive::DiskManager::destroy_instance(); } } - QString SaveProjectToTempFile(olive::Project *project, + QString save_project_to_temp_file(olive::Project *project, const QString &filename) { const QString path = QDir(temp_dir_.path()).filePath(filename); olive::ProjectSerializer::SaveData data( - olive::ProjectSerializer::kProject, project, path); + olive::ProjectSerializer::k_project, project, path); olive::ProjectSerializer::Result result = - olive::ProjectSerializer::Save(data, false); - if (result.code() != olive::ProjectSerializer::kSuccess) { + olive::ProjectSerializer::save(data, false); + if (result.code() != olive::ProjectSerializer::k_success) { return QString(); } return path; @@ -293,24 +293,24 @@ protected: TEST_F(TaskProjectLoadTest, LoadingValidProjectSucceeds) { olive::Project project; - project.Initialize(); + project.initialize(); auto *node = new olive::TimeInput(); - node->SetLabel(QStringLiteral("TimeInput")); + node->set_label(QStringLiteral("TimeInput")); node->setParent(&project); const QString path = - SaveProjectToTempFile(&project, QStringLiteral("project.ove")); + save_project_to_temp_file(&project, QStringLiteral("project.ove")); ASSERT_FALSE(path.isEmpty()); ASSERT_TRUE(QFileInfo::exists(path)); olive::ProjectLoadTask task(path); - EXPECT_EQ(task.GetFilename(), path); - EXPECT_EQ(task.GetLoadedProject(), nullptr); + EXPECT_EQ(task.get_filename(), path); + EXPECT_EQ(task.get_loaded_project(), nullptr); - ASSERT_TRUE(task.Start()) << task.GetError().toStdString(); + ASSERT_TRUE(task.start()) << task.get_error().toStdString(); - olive::Project *loaded = task.GetLoadedProject(); + olive::Project *loaded = task.get_loaded_project(); ASSERT_NE(loaded, nullptr); // Project::set_filename() stores native separators on Windows EXPECT_EQ(QDir::fromNativeSeparators(loaded->filename()), @@ -327,9 +327,9 @@ TEST_F(TaskProjectLoadTest, LoadingMissingFileFails) olive::ProjectLoadTask task(path); - EXPECT_FALSE(task.Start()); - EXPECT_FALSE(task.GetError().isEmpty()); - EXPECT_EQ(task.GetLoadedProject(), nullptr); + EXPECT_FALSE(task.start()); + EXPECT_FALSE(task.get_error().isEmpty()); + EXPECT_EQ(task.get_loaded_project(), nullptr); } TEST_F(TaskProjectLoadTest, LoadingCorruptFileFails) @@ -344,7 +344,7 @@ TEST_F(TaskProjectLoadTest, LoadingCorruptFileFails) olive::ProjectLoadTask task(path); - EXPECT_FALSE(task.Start()); - EXPECT_FALSE(task.GetError().isEmpty()); - EXPECT_EQ(task.GetLoadedProject(), nullptr); + EXPECT_FALSE(task.start()); + EXPECT_FALSE(task.get_error().isEmpty()); + EXPECT_EQ(task.get_loaded_project(), nullptr); } diff --git a/tests/gtest/task_taskmanager_test.cpp b/tests/gtest/task_taskmanager_test.cpp index 14b4be9fa..ce8a245ab 100644 --- a/tests/gtest/task_taskmanager_test.cpp +++ b/tests/gtest/task_taskmanager_test.cpp @@ -12,11 +12,11 @@ public: explicit DummyTask(bool *ran) : ran_(ran) { - SetTitle(QStringLiteral("DummyTask")); + set_title(QStringLiteral("DummyTask")); } protected: - bool Run() override + bool run() override { if (ran_) { *ran_ = true; @@ -32,13 +32,13 @@ class FailingTask final : public olive::Task { public: FailingTask() { - SetTitle(QStringLiteral("FailingTask")); + set_title(QStringLiteral("FailingTask")); } protected: - bool Run() override + bool run() override { - SetError(QStringLiteral("expected failure")); + set_error(QStringLiteral("expected failure")); return false; } }; @@ -48,14 +48,14 @@ public: explicit ProgressTask(int steps) : steps_(steps) { - SetTitle(QStringLiteral("ProgressTask")); + set_title(QStringLiteral("ProgressTask")); } protected: - bool Run() override + bool run() override { for (int i = 0; i <= steps_; ++i) { - emit ProgressChanged(static_cast(i) / steps_); + emit progress_changed(static_cast(i) / steps_); } return true; } @@ -67,7 +67,7 @@ private: TEST(TaskManager, AddAndRunTask) { - olive::TaskManager::CreateInstance(); + olive::TaskManager::create_instance(); olive::TaskManager *mgr = olive::TaskManager::instance(); ASSERT_NE(mgr, nullptr); @@ -75,21 +75,21 @@ TEST(TaskManager, AddAndRunTask) DummyTask *task = new DummyTask(&ran); QEventLoop loop; - QObject::connect(task, &olive::Task::Finished, &loop, + QObject::connect(task, &olive::Task::finished, &loop, [&loop](olive::Task *, bool) { loop.quit(); }); - mgr->AddTask(task); + mgr->add_task(task); QTimer::singleShot(5000, &loop, &QEventLoop::quit); loop.exec(); EXPECT_TRUE(ran); - olive::TaskManager::DestroyInstance(); + olive::TaskManager::destroy_instance(); } TEST(TaskManager, FailedTaskEmitsTaskFailed) { - olive::TaskManager::CreateInstance(); + olive::TaskManager::create_instance(); olive::TaskManager *mgr = olive::TaskManager::instance(); ASSERT_NE(mgr, nullptr); @@ -97,24 +97,24 @@ TEST(TaskManager, FailedTaskEmitsTaskFailed) QEventLoop loop; bool saw_failed = false; - QObject::connect(mgr, &olive::TaskManager::TaskFailed, &loop, + QObject::connect(mgr, &olive::TaskManager::task_failed, &loop, [&loop, &saw_failed](olive::Task *) { saw_failed = true; loop.quit(); }); QTimer::singleShot(5000, &loop, &QEventLoop::quit); - mgr->AddTask(task); + mgr->add_task(task); loop.exec(); EXPECT_TRUE(saw_failed); - EXPECT_FALSE(task->GetError().isEmpty()); - olive::TaskManager::DestroyInstance(); + EXPECT_FALSE(task->get_error().isEmpty()); + olive::TaskManager::destroy_instance(); } TEST(TaskManager, ProgressSignalIsEmitted) { - olive::TaskManager::CreateInstance(); + olive::TaskManager::create_instance(); olive::TaskManager *mgr = olive::TaskManager::instance(); ASSERT_NE(mgr, nullptr); @@ -122,23 +122,23 @@ TEST(TaskManager, ProgressSignalIsEmitted) QEventLoop loop; QVector progress; - QObject::connect(task, &olive::Task::ProgressChanged, &loop, + QObject::connect(task, &olive::Task::progress_changed, &loop, [&progress](double p) { progress.append(p); }); - QObject::connect(task, &olive::Task::Finished, &loop, + QObject::connect(task, &olive::Task::finished, &loop, [&loop](olive::Task *, bool) { loop.quit(); }); QTimer::singleShot(5000, &loop, &QEventLoop::quit); - mgr->AddTask(task); + mgr->add_task(task); loop.exec(); EXPECT_FALSE(progress.isEmpty()); EXPECT_GE(progress.last(), 0.99); - olive::TaskManager::DestroyInstance(); + olive::TaskManager::destroy_instance(); } TEST(TaskManager, MultipleTasksComplete) { - olive::TaskManager::CreateInstance(); + olive::TaskManager::create_instance(); olive::TaskManager *mgr = olive::TaskManager::instance(); ASSERT_NE(mgr, nullptr); @@ -154,15 +154,15 @@ TEST(TaskManager, MultipleTasksComplete) loop.quit(); } }; - QObject::connect(task1, &olive::Task::Finished, &loop, on_finished); - QObject::connect(task2, &olive::Task::Finished, &loop, on_finished); + QObject::connect(task1, &olive::Task::finished, &loop, on_finished); + QObject::connect(task2, &olive::Task::finished, &loop, on_finished); QTimer::singleShot(5000, &loop, &QEventLoop::quit); - mgr->AddTask(task1); - mgr->AddTask(task2); + mgr->add_task(task1); + mgr->add_task(task2); loop.exec(); EXPECT_TRUE(ran1); EXPECT_TRUE(ran2); - olive::TaskManager::DestroyInstance(); + olive::TaskManager::destroy_instance(); } diff --git a/tests/gtest/timebased_widget_test.cpp b/tests/gtest/timebased_widget_test.cpp index 215e48997..1319a3848 100644 --- a/tests/gtest/timebased_widget_test.cpp +++ b/tests/gtest/timebased_widget_test.cpp @@ -7,27 +7,27 @@ TEST(TimeBasedWidget, ConnectViewerNodeNullSafe) { olive::TimeBasedWidget widget(false, false); - widget.ConnectViewerNode(nullptr); - EXPECT_EQ(widget.GetConnectedNode(), nullptr); + widget.connect_viewer_node(nullptr); + EXPECT_EQ(widget.get_connected_node(), nullptr); } TEST(TimeBasedWidget, ConnectedNodeClearsOnDelete) { olive::TimeBasedWidget widget(false, false); auto *viewer = new olive::ViewerOutput(); - widget.ConnectViewerNode(viewer); - EXPECT_EQ(widget.GetConnectedNode(), viewer); + widget.connect_viewer_node(viewer); + EXPECT_EQ(widget.get_connected_node(), viewer); delete viewer; - EXPECT_EQ(widget.GetConnectedNode(), nullptr); + EXPECT_EQ(widget.get_connected_node(), nullptr); } TEST(SeekableWidget, ConstructionInitializesDefaults) { olive::SeekableWidget widget; - EXPECT_FALSE(widget.IsDraggingPlayhead()); - EXPECT_FALSE(widget.HasItemsSelected()); - EXPECT_EQ(widget.GetMarkers(), nullptr); - EXPECT_EQ(widget.GetWorkArea(), nullptr); + EXPECT_FALSE(widget.is_dragging_playhead()); + EXPECT_FALSE(widget.has_items_selected()); + EXPECT_EQ(widget.get_markers(), nullptr); + EXPECT_EQ(widget.get_work_area(), nullptr); } TEST(SeekableWidget, SetScrollAdjustsScrollBar) @@ -35,25 +35,25 @@ TEST(SeekableWidget, SetScrollAdjustsScrollBar) olive::SeekableWidget widget; widget.resize(400, 100); - widget.SetScroll(0); - EXPECT_EQ(widget.GetScroll(), 0); + widget.set_scroll(0); + EXPECT_EQ(widget.get_scroll(), 0); // Give the scene a deterministic length much wider than the viewport so // the horizontal scrollbar gains a non-zero range (60 seconds at // 100 px/second) - widget.SetTimebase(olive::rational(1, 30)); - widget.SetScale(100.0); - widget.SetEndTime(olive::rational(60)); + widget.set_timebase(olive::Rational(1, 30)); + widget.set_scale(100.0); + widget.set_end_time(olive::Rational(60)); const int max_scroll = widget.horizontalScrollBar()->maximum(); ASSERT_GT(max_scroll, 0); - widget.SetScroll(max_scroll); - EXPECT_EQ(widget.GetScroll(), max_scroll); + widget.set_scroll(max_scroll); + EXPECT_EQ(widget.get_scroll(), max_scroll); // Values beyond the range clamp to the scrollbar's maximum - widget.SetScroll(max_scroll + 1000); - EXPECT_EQ(widget.GetScroll(), max_scroll); + widget.set_scroll(max_scroll + 1000); + EXPECT_EQ(widget.get_scroll(), max_scroll); } TEST(SeekableWidget, SetMarkersAndWorkAreaAreReflected) @@ -63,21 +63,21 @@ TEST(SeekableWidget, SetMarkersAndWorkAreaAreReflected) olive::TimelineMarkerList markers; olive::TimelineWorkArea workarea; - widget.SetMarkers(&markers); - widget.SetWorkArea(&workarea); + widget.set_markers(&markers); + widget.set_work_area(&workarea); - EXPECT_EQ(widget.GetMarkers(), &markers); - EXPECT_EQ(widget.GetWorkArea(), &workarea); + EXPECT_EQ(widget.get_markers(), &markers); + EXPECT_EQ(widget.get_work_area(), &workarea); } TEST(SeekableWidget, MarkerEditingEnabledToggles) { olive::SeekableWidget widget; - EXPECT_TRUE(widget.IsMarkerEditingEnabled()); + EXPECT_TRUE(widget.is_marker_editing_enabled()); - widget.SetMarkerEditingEnabled(false); - EXPECT_FALSE(widget.IsMarkerEditingEnabled()); + widget.set_marker_editing_enabled(false); + EXPECT_FALSE(widget.is_marker_editing_enabled()); - widget.SetMarkerEditingEnabled(true); - EXPECT_TRUE(widget.IsMarkerEditingEnabled()); + widget.set_marker_editing_enabled(true); + EXPECT_TRUE(widget.is_marker_editing_enabled()); } diff --git a/tests/gtest/timecode_metadata_test.cpp b/tests/gtest/timecode_metadata_test.cpp index 1090eda47..2203e32b6 100644 --- a/tests/gtest/timecode_metadata_test.cpp +++ b/tests/gtest/timecode_metadata_test.cpp @@ -12,77 +12,77 @@ TEST(TimecodeMetadata, ParsesNonDropFrameTimecode) { const olive::TimecodeMetadata::SourceTime parsed = - olive::TimecodeMetadata::FromTimecodeString( - QStringLiteral("01:02:03:12"), olive::core::rational(1, 24)); + olive::TimecodeMetadata::from_timecode_string( + QStringLiteral("01:02:03:12"), olive::core::Rational(1, 24)); ASSERT_TRUE(parsed.valid); EXPECT_EQ(parsed.source, QStringLiteral("timecode")); - EXPECT_EQ(parsed.time, olive::core::rational(1 * 3600 + 2 * 60 + 3, 1) + - olive::core::rational(12, 24)); + EXPECT_EQ(parsed.time, olive::core::Rational(1 * 3600 + 2 * 60 + 3, 1) + + olive::core::Rational(12, 24)); } TEST(TimecodeMetadata, ParsesDropFrameTimecode) { const olive::TimecodeMetadata::SourceTime parsed = - olive::TimecodeMetadata::FromTimecodeString( - QStringLiteral("00:01:00;02"), olive::core::rational(1001, 30000)); + olive::TimecodeMetadata::from_timecode_string( + QStringLiteral("00:01:00;02"), olive::core::Rational(1001, 30000)); ASSERT_TRUE(parsed.valid); EXPECT_EQ(parsed.source, QStringLiteral("timecode")); - EXPECT_GT(parsed.time, olive::core::rational(59)); - EXPECT_LT(parsed.time, olive::core::rational(61)); + EXPECT_GT(parsed.time, olive::core::Rational(59)); + EXPECT_LT(parsed.time, olive::core::Rational(61)); } TEST(TimecodeMetadata, ParsesBwfTimeReference) { const olive::TimecodeMetadata::SourceTime parsed = - olive::TimecodeMetadata::FromBwfTimeReference(QStringLiteral("96000"), + olive::TimecodeMetadata::from_bwf_time_reference(QStringLiteral("96000"), 48000); ASSERT_TRUE(parsed.valid); EXPECT_EQ(parsed.source, QStringLiteral("bwf_time_reference")); - EXPECT_EQ(parsed.time, olive::core::rational(2)); + EXPECT_EQ(parsed.time, olive::core::Rational(2)); } TEST(TimecodeMetadata, ParsesLargeBwfTimeReferenceWithoutTruncation) { const olive::TimecodeMetadata::SourceTime parsed = - olive::TimecodeMetadata::FromBwfTimeReference( + olive::TimecodeMetadata::from_bwf_time_reference( QStringLiteral("4294967296"), 48000); ASSERT_TRUE(parsed.valid); - EXPECT_GT(parsed.time, olive::core::rational(89478)); - EXPECT_LT(parsed.time, olive::core::rational(89479)); + EXPECT_GT(parsed.time, olive::core::Rational(89478)); + EXPECT_LT(parsed.time, olive::core::Rational(89479)); } TEST(TimecodeMetadata, RejectsInvalidMetadata) { - EXPECT_FALSE(olive::TimecodeMetadata::FromTimecodeString( - QString(), olive::core::rational(1, 24)) + EXPECT_FALSE(olive::TimecodeMetadata::from_timecode_string( + QString(), olive::core::Rational(1, 24)) .valid); - EXPECT_FALSE(olive::TimecodeMetadata::FromBwfTimeReference( + EXPECT_FALSE(olive::TimecodeMetadata::from_bwf_time_reference( QStringLiteral("not-a-number"), 48000) .valid); EXPECT_FALSE( - olive::TimecodeMetadata::FromBwfTimeReference(QStringLiteral("123"), 0) + olive::TimecodeMetadata::from_bwf_time_reference(QStringLiteral("123"), 0) .valid); EXPECT_FALSE( - olive::TimecodeMetadata::FromTimecodeString( - QStringLiteral("not-a-timecode"), olive::core::rational(1, 24)) + olive::TimecodeMetadata::from_timecode_string( + QStringLiteral("not-a-timecode"), olive::core::Rational(1, 24)) .valid); } TEST(TimecodeMetadata, FromBwfTimeReferenceZeroSampleRateIsInvalid) { EXPECT_FALSE( - olive::TimecodeMetadata::FromBwfTimeReference(QStringLiteral("0"), 0) + olive::TimecodeMetadata::from_bwf_time_reference(QStringLiteral("0"), 0) .valid); } TEST(TimecodeMetadata, FootageDescriptionWithoutSourceStartTime) { olive::FootageDescription desc(QStringLiteral("ffmpeg")); - EXPECT_FALSE(desc.HasSourceStartTime()); + EXPECT_FALSE(desc.has_source_start_time()); } TEST(TimecodeMetadata, FootageDescriptionCachesSourceStartTime) @@ -93,14 +93,14 @@ TEST(TimecodeMetadata, FootageDescriptionCachesSourceStartTime) QDir(dir.path()).filePath(QStringLiteral("footage-cache.xml")); olive::FootageDescription desc(QStringLiteral("ffmpeg")); - desc.SetSourceStartTime(olive::core::rational(96000, 48000), + desc.set_source_start_time(olive::core::Rational(96000, 48000), QStringLiteral("bwf_time_reference")); - ASSERT_TRUE(desc.Save(path)); + ASSERT_TRUE(desc.save(path)); olive::FootageDescription loaded; - ASSERT_TRUE(loaded.Load(path)); - ASSERT_TRUE(loaded.HasSourceStartTime()); - EXPECT_EQ(loaded.source_start_time(), olive::core::rational(2)); + ASSERT_TRUE(loaded.load(path)); + ASSERT_TRUE(loaded.has_source_start_time()); + EXPECT_EQ(loaded.source_start_time(), olive::core::Rational(2)); EXPECT_EQ(loaded.source_start_time_source(), QStringLiteral("bwf_time_reference")); } @@ -124,37 +124,37 @@ TEST(TimecodeMetadata, FootagePersistsSourceStartTime) ASSERT_EQ(reader.name(), QStringLiteral("custom")); olive::Footage footage; - ASSERT_TRUE(footage.LoadCustom(&reader, nullptr)); - ASSERT_TRUE(footage.HasSourceStartTime()); - EXPECT_EQ(footage.source_start_time(), olive::core::rational(3600)); + ASSERT_TRUE(footage.load_custom(&reader, nullptr)); + ASSERT_TRUE(footage.has_source_start_time()); + EXPECT_EQ(footage.source_start_time(), olive::core::Rational(3600)); EXPECT_EQ(footage.source_start_time_source(), QStringLiteral("timecode")); } TEST(TimecodeMetadata, FootageClearSourceStartTime) { olive::Footage footage; - footage.SetSourceStartTime(olive::core::rational(3600), + footage.set_source_start_time(olive::core::Rational(3600), QStringLiteral("manual")); - ASSERT_TRUE(footage.HasSourceStartTime()); + ASSERT_TRUE(footage.has_source_start_time()); - footage.ClearSourceStartTime(); + footage.clear_source_start_time(); - EXPECT_FALSE(footage.HasSourceStartTime()); - EXPECT_EQ(footage.source_start_time(), olive::core::rational()); + EXPECT_FALSE(footage.has_source_start_time()); + EXPECT_EQ(footage.source_start_time(), olive::core::Rational()); EXPECT_TRUE(footage.source_start_time_source().isEmpty()); } TEST(TimecodeMetadata, FootageSetSourceStartTimeOverridesPreviousValue) { olive::Footage footage; - footage.SetSourceStartTime(olive::core::rational(3600), + footage.set_source_start_time(olive::core::Rational(3600), QStringLiteral("timecode")); // A manual edit replaces both the value and the recorded source - footage.SetSourceStartTime(olive::core::rational(1800), + footage.set_source_start_time(olive::core::Rational(1800), QStringLiteral("manual")); - EXPECT_TRUE(footage.HasSourceStartTime()); - EXPECT_EQ(footage.source_start_time(), olive::core::rational(1800)); + EXPECT_TRUE(footage.has_source_start_time()); + EXPECT_EQ(footage.source_start_time(), olive::core::Rational(1800)); EXPECT_EQ(footage.source_start_time_source(), QStringLiteral("manual")); } diff --git a/tests/gtest/timeline_coordinate_test.cpp b/tests/gtest/timeline_coordinate_test.cpp index fb67e2865..99f543e40 100644 --- a/tests/gtest/timeline_coordinate_test.cpp +++ b/tests/gtest/timeline_coordinate_test.cpp @@ -5,96 +5,96 @@ TEST(TimelineCoordinate, DefaultAndSetters) { olive::TimelineCoordinate coord; - EXPECT_EQ(coord.GetTrack().type(), olive::Track::kNone); - EXPECT_EQ(coord.GetTrack().index(), 0); + EXPECT_EQ(coord.get_track().type(), olive::Track::k_none); + EXPECT_EQ(coord.get_track().index(), 0); - const olive::core::rational frame(10, 1); - olive::Track::Reference ref(olive::Track::kVideo, 2); + const olive::core::Rational frame(10, 1); + olive::Track::Reference ref(olive::Track::k_video, 2); - coord.SetFrame(frame); - coord.SetTrack(ref); + coord.set_frame(frame); + coord.set_track(ref); - EXPECT_EQ(coord.GetFrame(), frame); - EXPECT_EQ(coord.GetTrack(), ref); + EXPECT_EQ(coord.get_frame(), frame); + EXPECT_EQ(coord.get_track(), ref); } TEST(TimelineCoordinate, Constructors) { - const olive::core::rational frame(5, 1); - olive::Track::Reference ref(olive::Track::kAudio, 1); + const olive::core::Rational frame(5, 1); + olive::Track::Reference ref(olive::Track::k_audio, 1); olive::TimelineCoordinate with_ref(frame, ref); - EXPECT_EQ(with_ref.GetFrame(), frame); - EXPECT_EQ(with_ref.GetTrack(), ref); + EXPECT_EQ(with_ref.get_frame(), frame); + EXPECT_EQ(with_ref.get_track(), ref); - olive::TimelineCoordinate with_type(frame, olive::Track::kSubtitle, 3); - EXPECT_EQ(with_type.GetFrame(), frame); - EXPECT_EQ(with_type.GetTrack().type(), olive::Track::kSubtitle); - EXPECT_EQ(with_type.GetTrack().index(), 3); + olive::TimelineCoordinate with_type(frame, olive::Track::k_subtitle, 3); + EXPECT_EQ(with_type.get_frame(), frame); + EXPECT_EQ(with_type.get_track().type(), olive::Track::k_subtitle); + EXPECT_EQ(with_type.get_track().index(), 3); } TEST(TimelineCoordinate, CopyAndAssignment) { - const olive::core::rational frame(7, 1); - olive::Track::Reference ref(olive::Track::kVideo, 4); + const olive::core::Rational frame(7, 1); + olive::Track::Reference ref(olive::Track::k_video, 4); olive::TimelineCoordinate original(frame, ref); olive::TimelineCoordinate copy(original); - EXPECT_EQ(copy.GetFrame(), frame); - EXPECT_EQ(copy.GetTrack(), ref); + EXPECT_EQ(copy.get_frame(), frame); + EXPECT_EQ(copy.get_track(), ref); olive::TimelineCoordinate assigned; assigned = original; - EXPECT_EQ(assigned.GetFrame(), frame); - EXPECT_EQ(assigned.GetTrack(), ref); + EXPECT_EQ(assigned.get_frame(), frame); + EXPECT_EQ(assigned.get_track(), ref); } TEST(TimelineCoordinate, Equality) { // TimelineCoordinate provides no operator== of its own; equality is - // observable through the real operators of its components (rational and + // observable through the real operators of its components (Rational and // Track::Reference) const olive::TimelineCoordinate a( - olive::core::rational(5, 1), - olive::Track::Reference(olive::Track::kVideo, 1)); + olive::core::Rational(5, 1), + olive::Track::Reference(olive::Track::k_video, 1)); // Distinct objects with identical frame and track compare equal in both // components const olive::TimelineCoordinate b( - olive::core::rational(5, 1), - olive::Track::Reference(olive::Track::kVideo, 1)); - EXPECT_TRUE(a.GetFrame() == b.GetFrame()); - EXPECT_TRUE(a.GetTrack() == b.GetTrack()); - EXPECT_FALSE(a.GetFrame() != b.GetFrame()); - EXPECT_FALSE(a.GetTrack() != b.GetTrack()); + olive::core::Rational(5, 1), + olive::Track::Reference(olive::Track::k_video, 1)); + EXPECT_TRUE(a.get_frame() == b.get_frame()); + EXPECT_TRUE(a.get_track() == b.get_track()); + EXPECT_FALSE(a.get_frame() != b.get_frame()); + EXPECT_FALSE(a.get_track() != b.get_track()); // A different frame breaks frame equality while the track stays equal const olive::TimelineCoordinate c( - olive::core::rational(6, 1), - olive::Track::Reference(olive::Track::kVideo, 1)); - EXPECT_FALSE(a.GetFrame() == c.GetFrame()); - EXPECT_TRUE(a.GetFrame() != c.GetFrame()); - EXPECT_TRUE(a.GetTrack() == c.GetTrack()); + olive::core::Rational(6, 1), + olive::Track::Reference(olive::Track::k_video, 1)); + EXPECT_FALSE(a.get_frame() == c.get_frame()); + EXPECT_TRUE(a.get_frame() != c.get_frame()); + EXPECT_TRUE(a.get_track() == c.get_track()); // A different track type or index breaks track equality while the frame // stays equal const olive::TimelineCoordinate d( - olive::core::rational(5, 1), - olive::Track::Reference(olive::Track::kAudio, 1)); + olive::core::Rational(5, 1), + olive::Track::Reference(olive::Track::k_audio, 1)); const olive::TimelineCoordinate e( - olive::core::rational(5, 1), - olive::Track::Reference(olive::Track::kVideo, 2)); - EXPECT_TRUE(a.GetTrack() != d.GetTrack()); - EXPECT_FALSE(a.GetTrack() == d.GetTrack()); - EXPECT_TRUE(a.GetTrack() != e.GetTrack()); - EXPECT_TRUE(a.GetFrame() == d.GetFrame()); - EXPECT_TRUE(a.GetFrame() == e.GetFrame()); + olive::core::Rational(5, 1), + olive::Track::Reference(olive::Track::k_video, 2)); + EXPECT_TRUE(a.get_track() != d.get_track()); + EXPECT_FALSE(a.get_track() == d.get_track()); + EXPECT_TRUE(a.get_track() != e.get_track()); + EXPECT_TRUE(a.get_frame() == d.get_frame()); + EXPECT_TRUE(a.get_frame() == e.get_frame()); // Mutating a copy breaks equality with the original olive::TimelineCoordinate mutated = a; - mutated.SetFrame(olive::core::rational(7, 1)); - EXPECT_TRUE(mutated.GetFrame() != a.GetFrame()); - mutated.SetFrame(olive::core::rational(5, 1)); - mutated.SetTrack(olive::Track::Reference(olive::Track::kSubtitle, 0)); - EXPECT_TRUE(mutated.GetTrack() != a.GetTrack()); + mutated.set_frame(olive::core::Rational(7, 1)); + EXPECT_TRUE(mutated.get_frame() != a.get_frame()); + mutated.set_frame(olive::core::Rational(5, 1)); + mutated.set_track(olive::Track::Reference(olive::Track::k_subtitle, 0)); + EXPECT_TRUE(mutated.get_track() != a.get_track()); } diff --git a/tests/gtest/timeline_marker_test.cpp b/tests/gtest/timeline_marker_test.cpp index c5d5b7752..706a5052f 100644 --- a/tests/gtest/timeline_marker_test.cpp +++ b/tests/gtest/timeline_marker_test.cpp @@ -9,7 +9,7 @@ TEST(TimelineMarker, SaveLoadRoundTrip) { olive::TimelineMarker marker; - marker.set_time(olive::core::rational(10, 1)); + marker.set_time(olive::core::Rational(10, 1)); marker.set_name(QStringLiteral("Marker")); marker.set_color(5); @@ -32,7 +32,7 @@ TEST(TimelineMarker, SaveLoadRoundTrip) EXPECT_EQ(reader.name().toString(), QStringLiteral("marker")); loaded.load(&reader); - EXPECT_EQ(loaded.time().in(), olive::core::rational(10, 1)); + EXPECT_EQ(loaded.time().in(), olive::core::Rational(10, 1)); EXPECT_EQ(loaded.name(), QStringLiteral("Marker")); EXPECT_EQ(loaded.color(), 5); } @@ -41,7 +41,7 @@ TEST(TimelineMarker, DefaultConstruction) { olive::TimelineMarker marker; EXPECT_TRUE(marker.name().isEmpty()); - EXPECT_EQ(marker.time().in(), olive::core::rational(0, 1)); + EXPECT_EQ(marker.time().in(), olive::core::Rational(0, 1)); } TEST(TimelineMarkerList, OrderAndLookup) @@ -49,40 +49,40 @@ TEST(TimelineMarkerList, OrderAndLookup) olive::TimelineMarkerList list; olive::TimelineMarker marker_a( 1, - olive::core::TimeRange(olive::core::rational(10, 1), - olive::core::rational(10, 1)), + olive::core::TimeRange(olive::core::Rational(10, 1), + olive::core::Rational(10, 1)), QStringLiteral("A"), &list); olive::TimelineMarker marker_b( 2, - olive::core::TimeRange(olive::core::rational(5, 1), - olive::core::rational(5, 1)), + olive::core::TimeRange(olive::core::Rational(5, 1), + olive::core::Rational(5, 1)), QStringLiteral("B"), &list); olive::TimelineMarker marker_c( 3, - olive::core::TimeRange(olive::core::rational(20, 1), - olive::core::rational(20, 1)), + olive::core::TimeRange(olive::core::Rational(20, 1), + olive::core::Rational(20, 1)), QStringLiteral("C"), &list); ASSERT_EQ(list.size(), 3); auto it = list.cbegin(); - EXPECT_EQ((*it)->time().in(), olive::core::rational(5, 1)); + EXPECT_EQ((*it)->time().in(), olive::core::Rational(5, 1)); ++it; - EXPECT_EQ((*it)->time().in(), olive::core::rational(10, 1)); + EXPECT_EQ((*it)->time().in(), olive::core::Rational(10, 1)); ++it; - EXPECT_EQ((*it)->time().in(), olive::core::rational(20, 1)); + EXPECT_EQ((*it)->time().in(), olive::core::Rational(20, 1)); - EXPECT_EQ(list.GetMarkerAtTime(olive::core::rational(10, 1)), &marker_a); - EXPECT_EQ(list.GetClosestMarkerToTime(olive::core::rational(7, 1)), + EXPECT_EQ(list.get_marker_at_time(olive::core::Rational(10, 1)), &marker_a); + EXPECT_EQ(list.get_closest_marker_to_time(olive::core::Rational(7, 1)), &marker_b); - EXPECT_EQ(list.GetClosestMarkerToTime(olive::core::rational(9, 1)), + EXPECT_EQ(list.get_closest_marker_to_time(olive::core::Rational(9, 1)), &marker_a); } TEST(TimelineMarkerList, GetMarkerAtTimeReturnsNullWhenEmpty) { olive::TimelineMarkerList list; - EXPECT_EQ(list.GetMarkerAtTime(olive::core::rational(10, 1)), nullptr); - EXPECT_EQ(list.GetClosestMarkerToTime(olive::core::rational(10, 1)), + EXPECT_EQ(list.get_marker_at_time(olive::core::Rational(10, 1)), nullptr); + EXPECT_EQ(list.get_closest_marker_to_time(olive::core::Rational(10, 1)), nullptr); } @@ -91,8 +91,8 @@ TEST(TimelineMarkerList, SaveLoadWithUnknownElements) olive::TimelineMarkerList list; olive::TimelineMarker marker( 4, - olive::core::TimeRange(olive::core::rational(12, 1), - olive::core::rational(15, 1)), + olive::core::TimeRange(olive::core::Rational(12, 1), + olive::core::Rational(15, 1)), QStringLiteral("Span"), &list); QByteArray xml; @@ -117,7 +117,7 @@ TEST(TimelineMarkerList, SaveLoadWithUnknownElements) EXPECT_TRUE(loaded.load(&reader)); EXPECT_EQ(loaded.size(), 1); EXPECT_EQ(loaded.front()->name(), QStringLiteral("Span")); - EXPECT_EQ(loaded.front()->time().in(), olive::core::rational(12, 1)); + EXPECT_EQ(loaded.front()->time().in(), olive::core::Rational(12, 1)); } TEST(TimelineMarkerCommands, AddRemoveAndChange) @@ -125,8 +125,8 @@ TEST(TimelineMarkerCommands, AddRemoveAndChange) olive::TimelineMarkerList list; olive::MarkerAddCommand add( &list, - olive::core::TimeRange(olive::core::rational(1, 1), - olive::core::rational(2, 1)), + olive::core::TimeRange(olive::core::Rational(1, 1), + olive::core::Rational(2, 1)), QStringLiteral("One"), 1); add.redo_now(); ASSERT_EQ(list.size(), 1); @@ -153,18 +153,18 @@ TEST(TimelineMarkerCommands, AddRemoveAndChange) olive::TimelineMarker other( 2, - olive::core::TimeRange(olive::core::rational(5, 1), - olive::core::rational(5, 1)), + olive::core::TimeRange(olive::core::Rational(5, 1), + olive::core::Rational(5, 1)), QStringLiteral("Two"), &list); - EXPECT_EQ(list.front()->time().in(), olive::core::rational(1, 1)); + EXPECT_EQ(list.front()->time().in(), olive::core::Rational(1, 1)); olive::MarkerChangeTimeCommand move( - marker, olive::core::TimeRange(olive::core::rational(0, 1), - olive::core::rational(0, 1))); + marker, olive::core::TimeRange(olive::core::Rational(0, 1), + olive::core::Rational(0, 1))); move.redo_now(); EXPECT_EQ(list.front(), marker); move.undo_now(); - EXPECT_EQ(list.front()->time().in(), olive::core::rational(1, 1)); + EXPECT_EQ(list.front()->time().in(), olive::core::Rational(1, 1)); } TEST(TimelineMarkerCommands, AddCommandUndo) @@ -172,8 +172,8 @@ TEST(TimelineMarkerCommands, AddCommandUndo) olive::TimelineMarkerList list; olive::MarkerAddCommand add( &list, - olive::core::TimeRange(olive::core::rational(5, 1), - olive::core::rational(5, 1)), + olive::core::TimeRange(olive::core::Rational(5, 1), + olive::core::Rational(5, 1)), QStringLiteral("UndoMe"), 2); add.redo_now(); EXPECT_EQ(list.size(), 1); diff --git a/tests/gtest/timeline_undo_general_test.cpp b/tests/gtest/timeline_undo_general_test.cpp index f4bc84e6f..9abc7b131 100644 --- a/tests/gtest/timeline_undo_general_test.cpp +++ b/tests/gtest/timeline_undo_general_test.cpp @@ -19,22 +19,22 @@ namespace { -olive::Sequence *CreateSequence(olive::Project *project) +olive::Sequence *create_sequence(olive::Project *project) { auto *sequence = new olive::Sequence(); sequence->setParent(project); return sequence; } -olive::Track *CreateTrack(olive::Project *project) +olive::Track *create_track(olive::Project *project) { auto *track = new olive::Track(); track->setParent(project); return track; } -olive::ClipBlock *CreateClip(olive::Project *project, - const olive::core::rational &length) +olive::ClipBlock *create_clip(olive::Project *project, + const olive::core::Rational &length) { auto *clip = new olive::ClipBlock(); clip->setParent(project); @@ -42,8 +42,8 @@ olive::ClipBlock *CreateClip(olive::Project *project, return clip; } -olive::GapBlock *CreateGap(olive::Project *project, - const olive::core::rational &length) +olive::GapBlock *create_gap(olive::Project *project, + const olive::core::Rational &length) { auto *gap = new olive::GapBlock(); gap->setParent(project); @@ -51,8 +51,8 @@ olive::GapBlock *CreateGap(olive::Project *project, return gap; } -olive::CrossDissolveTransition *CreateTransition(olive::Project *project, - const olive::core::rational &length) +olive::CrossDissolveTransition *create_transition(olive::Project *project, + const olive::core::Rational &length) { auto *transition = new olive::CrossDissolveTransition(); transition->setParent(project); @@ -60,11 +60,11 @@ olive::CrossDissolveTransition *CreateTransition(olive::Project *project, return transition; } -void AppendTrackToList(olive::TrackList *list, olive::Track *track) +void append_track_to_list(olive::TrackList *list, olive::Track *track) { - list->ArrayAppend(); - olive::Node::ConnectEdge(track, - list->track_input(list->ArraySize() - 1)); + list->array_append(); + olive::Node::connect_edge(track, + list->track_input(list->array_size() - 1)); } } // namespace @@ -73,10 +73,10 @@ class TimelineUndoGeneralTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } std::unique_ptr project_; @@ -84,67 +84,67 @@ protected: TEST_F(TimelineUndoGeneralTest, BlockResizeCommandChangesLength) { - olive::ClipBlock *clip = CreateClip(project_.get(), olive::core::rational(4)); + olive::ClipBlock *clip = create_clip(project_.get(), olive::core::Rational(4)); - olive::BlockResizeCommand cmd(clip, olive::core::rational(2)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::BlockResizeCommand cmd(clip, olive::core::Rational(2)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(clip->length(), olive::core::rational(2)); + EXPECT_EQ(clip->length(), olive::core::Rational(2)); // Resizing from the out point leaves the media in point alone - EXPECT_EQ(clip->media_in(), olive::core::rational(0)); + EXPECT_EQ(clip->media_in(), olive::core::Rational(0)); cmd.undo_now(); - EXPECT_EQ(clip->length(), olive::core::rational(4)); + EXPECT_EQ(clip->length(), olive::core::Rational(4)); // Resizing to zero length is allowed on a detached block - olive::BlockResizeCommand to_zero(clip, olive::core::rational(0)); + olive::BlockResizeCommand to_zero(clip, olive::core::Rational(0)); to_zero.redo_now(); - EXPECT_EQ(clip->length(), olive::core::rational(0)); + EXPECT_EQ(clip->length(), olive::core::Rational(0)); to_zero.undo_now(); - EXPECT_EQ(clip->length(), olive::core::rational(4)); + EXPECT_EQ(clip->length(), olive::core::Rational(4)); } TEST_F(TimelineUndoGeneralTest, BlockResizeWithMediaInCommandShiftsMediaIn) { - olive::ClipBlock *clip = CreateClip(project_.get(), olive::core::rational(4)); - ASSERT_EQ(clip->media_in(), olive::core::rational(0)); + olive::ClipBlock *clip = create_clip(project_.get(), olive::core::Rational(4)); + ASSERT_EQ(clip->media_in(), olive::core::Rational(0)); - olive::BlockResizeWithMediaInCommand cmd(clip, olive::core::rational(2)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::BlockResizeWithMediaInCommand cmd(clip, olive::core::Rational(2)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(clip->length(), olive::core::rational(2)); + EXPECT_EQ(clip->length(), olive::core::Rational(2)); // Resizing from the in point pushes the media in point forward - EXPECT_EQ(clip->media_in(), olive::core::rational(2)); + EXPECT_EQ(clip->media_in(), olive::core::Rational(2)); cmd.undo_now(); - EXPECT_EQ(clip->length(), olive::core::rational(4)); - EXPECT_EQ(clip->media_in(), olive::core::rational(0)); + EXPECT_EQ(clip->length(), olive::core::Rational(4)); + EXPECT_EQ(clip->media_in(), olive::core::Rational(0)); } TEST_F(TimelineUndoGeneralTest, BlockSetMediaInCommandSetsAndRestores) { - olive::ClipBlock *clip = CreateClip(project_.get(), olive::core::rational(4)); - ASSERT_EQ(clip->media_in(), olive::core::rational(0)); + olive::ClipBlock *clip = create_clip(project_.get(), olive::core::Rational(4)); + ASSERT_EQ(clip->media_in(), olive::core::Rational(0)); - olive::BlockSetMediaInCommand cmd(clip, olive::core::rational(3)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::BlockSetMediaInCommand cmd(clip, olive::core::Rational(3)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(clip->media_in(), olive::core::rational(3)); + EXPECT_EQ(clip->media_in(), olive::core::Rational(3)); cmd.undo_now(); - EXPECT_EQ(clip->media_in(), olive::core::rational(0)); + EXPECT_EQ(clip->media_in(), olive::core::Rational(0)); } TEST_F(TimelineUndoGeneralTest, BlockEnableDisableCommandToggles) { - olive::ClipBlock *clip = CreateClip(project_.get(), olive::core::rational(4)); + olive::ClipBlock *clip = create_clip(project_.get(), olive::core::Rational(4)); ASSERT_TRUE(clip->is_enabled()); olive::BlockEnableDisableCommand cmd(clip, false); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); EXPECT_FALSE(clip->is_enabled()); @@ -155,595 +155,595 @@ TEST_F(TimelineUndoGeneralTest, BlockEnableDisableCommandToggles) TEST_F(TimelineUndoGeneralTest, AddTrackCommandConnectsDirectly) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); olive::TimelineAddTrackCommand cmd(list, false); olive::Track *track = cmd.track(); ASSERT_NE(track, nullptr); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(list->GetTrackCount(), 1); - EXPECT_EQ(list->GetTrackAt(0), track); + EXPECT_EQ(list->get_track_count(), 1); + EXPECT_EQ(list->get_track_at(0), track); EXPECT_EQ(track->sequence(), sequence); - EXPECT_EQ(track->type(), olive::Track::kVideo); - EXPECT_EQ(track->Index(), 0); + EXPECT_EQ(track->type(), olive::Track::k_video); + EXPECT_EQ(track->index(), 0); EXPECT_EQ(track->project(), project_.get()); // The first track connects straight to the sequence's texture input - EXPECT_TRUE(sequence->IsInputConnected(olive::ViewerOutput::kTextureInput)); - EXPECT_EQ(sequence->GetConnectedTextureOutput(), track); + EXPECT_TRUE(sequence->is_input_connected(olive::ViewerOutput::k_texture_input)); + EXPECT_EQ(sequence->get_connected_texture_output(), track); cmd.undo_now(); - EXPECT_EQ(list->GetTrackCount(), 0); - EXPECT_EQ(list->ArraySize(), 0); + EXPECT_EQ(list->get_track_count(), 0); + EXPECT_EQ(list->array_size(), 0); EXPECT_EQ(track->sequence(), nullptr); EXPECT_EQ(track->project(), nullptr); - EXPECT_FALSE(sequence->IsInputConnected(olive::ViewerOutput::kTextureInput)); + EXPECT_FALSE(sequence->is_input_connected(olive::ViewerOutput::k_texture_input)); } TEST_F(TimelineUndoGeneralTest, AddTrackCommandInsertsVideoMergeNode) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); // The first track takes the direct connection olive::TimelineAddTrackCommand first(list, false); first.redo_now(); olive::Track *track1 = first.track(); - ASSERT_EQ(sequence->GetConnectedTextureOutput(), track1); + ASSERT_EQ(sequence->get_connected_texture_output(), track1); // Adding another video track with automerge inserts a merge node olive::TimelineAddTrackCommand second(list, true); olive::Track *track2 = second.track(); second.redo_now(); - EXPECT_EQ(list->GetTrackCount(), 2); + EXPECT_EQ(list->get_track_count(), 2); - olive::Node *merge = sequence->GetConnectedTextureOutput(); + olive::Node *merge = sequence->get_connected_texture_output(); ASSERT_NE(merge, nullptr); EXPECT_NE(merge, track1); EXPECT_NE(merge, track2); EXPECT_EQ(merge->project(), project_.get()); - EXPECT_EQ(olive::NodeInput(merge, olive::MergeNode::kBaseIn) - .GetConnectedOutput(), + EXPECT_EQ(olive::NodeInput(merge, olive::MergeNode::k_base_in) + .get_connected_output(), track1); - EXPECT_EQ(olive::NodeInput(merge, olive::MergeNode::kBlendIn) - .GetConnectedOutput(), + EXPECT_EQ(olive::NodeInput(merge, olive::MergeNode::k_blend_in) + .get_connected_output(), track2); second.undo_now(); // The direct connection from the first track is restored - EXPECT_EQ(sequence->GetConnectedTextureOutput(), track1); + EXPECT_EQ(sequence->get_connected_texture_output(), track1); EXPECT_EQ(merge->project(), nullptr); EXPECT_EQ(track2->project(), nullptr); - EXPECT_EQ(list->GetTrackCount(), 1); + EXPECT_EQ(list->get_track_count(), 1); } TEST_F(TimelineUndoGeneralTest, AddTrackCommandMergesAudioWithMathNode) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kAudio); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_audio); olive::TimelineAddTrackCommand first(list, false); first.redo_now(); olive::Track *track1 = first.track(); - ASSERT_EQ(sequence->GetConnectedSampleOutput(), track1); + ASSERT_EQ(sequence->get_connected_sample_output(), track1); olive::TimelineAddTrackCommand second(list, true); olive::Track *track2 = second.track(); second.redo_now(); - EXPECT_EQ(list->GetTrackCount(), 2); + EXPECT_EQ(list->get_track_count(), 2); // Audio tracks are summed with a math (add) node - olive::Node *math = sequence->GetConnectedSampleOutput(); + olive::Node *math = sequence->get_connected_sample_output(); ASSERT_NE(math, nullptr); EXPECT_NE(math, track1); EXPECT_NE(math, track2); EXPECT_EQ(math->id(), QStringLiteral("org.olivevideoeditor.Olive.math")); - EXPECT_EQ(olive::NodeInput(math, olive::MathNode::kParamAIn) - .GetConnectedOutput(), + EXPECT_EQ(olive::NodeInput(math, olive::MathNode::k_param_a_in) + .get_connected_output(), track1); - EXPECT_EQ(olive::NodeInput(math, olive::MathNode::kParamBIn) - .GetConnectedOutput(), + EXPECT_EQ(olive::NodeInput(math, olive::MathNode::k_param_b_in) + .get_connected_output(), track2); second.undo_now(); - EXPECT_EQ(sequence->GetConnectedSampleOutput(), track1); + EXPECT_EQ(sequence->get_connected_sample_output(), track1); EXPECT_EQ(math->project(), nullptr); - EXPECT_EQ(list->GetTrackCount(), 1); + EXPECT_EQ(list->get_track_count(), 1); } TEST_F(TimelineUndoGeneralTest, RemoveTrackCommandRemovesAndRestores) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *clip = CreateClip(project_.get(), olive::core::rational(4)); - track->AppendBlock(clip); - AppendTrackToList(list, track); - ASSERT_EQ(track->Index(), 0); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *clip = create_clip(project_.get(), olive::core::Rational(4)); + track->append_block(clip); + append_track_to_list(list, track); + ASSERT_EQ(track->index(), 0); olive::TimelineRemoveTrackCommand cmd(track); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); EXPECT_EQ(track->project(), nullptr); EXPECT_EQ(track->sequence(), nullptr); - EXPECT_EQ(list->GetTrackCount(), 0); - EXPECT_EQ(list->ArraySize(), 0); + EXPECT_EQ(list->get_track_count(), 0); + EXPECT_EQ(list->array_size(), 0); // The clip was an exclusive dependency of the track and left the graph too EXPECT_EQ(clip->project(), nullptr); cmd.undo_now(); EXPECT_EQ(track->project(), project_.get()); EXPECT_EQ(clip->project(), project_.get()); - EXPECT_EQ(list->GetTrackCount(), 1); - EXPECT_EQ(list->ArraySize(), 1); - EXPECT_EQ(list->GetTrackAt(0), track); - EXPECT_EQ(track->Index(), 0); + EXPECT_EQ(list->get_track_count(), 1); + EXPECT_EQ(list->array_size(), 1); + EXPECT_EQ(list->get_track_at(0), track); + EXPECT_EQ(track->index(), 0); EXPECT_EQ(track->sequence(), sequence); } TEST_F(TimelineUndoGeneralTest, TransitionRemoveCommandRestoresClipLengths) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(1)); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(1)); olive::CrossDissolveTransition *transition = - CreateTransition(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - b->set_media_in(olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(transition); - track->AppendBlock(b); - olive::Node::ConnectEdge( + create_transition(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + b->set_media_in(olive::core::Rational(1)); + track->append_block(a); + track->append_block(transition); + track->append_block(b); + olive::Node::connect_edge( a, olive::NodeInput(transition, - olive::TransitionBlock::kOutBlockInput)); - olive::Node::ConnectEdge( - b, olive::NodeInput(transition, olive::TransitionBlock::kInBlockInput)); + olive::TransitionBlock::k_out_block_input)); + olive::Node::connect_edge( + b, olive::NodeInput(transition, olive::TransitionBlock::k_in_block_input)); // Layout: a [0,1], transition [1,3], b [3,6] with media_in 1 ASSERT_EQ(transition->connected_out_block(), a); ASSERT_EQ(transition->connected_in_block(), b); ASSERT_TRUE(transition->is_dual_transition()); olive::TransitionRemoveCommand cmd(transition, true); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); + ASSERT_EQ(track->blocks().size(), 2); // Both clips reclaim the half of the transition that overlapped them - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(2)); - EXPECT_EQ(b->length(), olive::core::rational(4)); - EXPECT_EQ(b->media_in(), olive::core::rational(0)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(6)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); + EXPECT_EQ(b->length(), olive::core::Rational(4)); + EXPECT_EQ(b->media_in(), olive::core::Rational(0)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); EXPECT_EQ(transition->track(), nullptr); EXPECT_EQ(transition->project(), nullptr); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), transition); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), transition); EXPECT_EQ(transition->project(), project_.get()); - EXPECT_EQ(transition->in(), olive::core::rational(1)); - EXPECT_EQ(transition->out(), olive::core::rational(3)); + EXPECT_EQ(transition->in(), olive::core::Rational(1)); + EXPECT_EQ(transition->out(), olive::core::Rational(3)); EXPECT_EQ(transition->connected_out_block(), a); EXPECT_EQ(transition->connected_in_block(), b); - EXPECT_EQ(a->length(), olive::core::rational(1)); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(b->media_in(), olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(3)); - EXPECT_EQ(b->out(), olive::core::rational(6)); + EXPECT_EQ(a->length(), olive::core::Rational(1)); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(b->media_in(), olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(3)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); } TEST_F(TimelineUndoGeneralTest, ReplaceBlockWithGapCreatesGap) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); // Layout: a [0,2], b [2,5], c [5,6] olive::TrackReplaceBlockWithGapCommand cmd(track, b); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - olive::Block *gap = track->Blocks().at(1); + ASSERT_EQ(track->blocks().size(), 3); + olive::Block *gap = track->blocks().at(1); EXPECT_NE(dynamic_cast(gap), nullptr); - EXPECT_EQ(gap->in(), olive::core::rational(2)); - EXPECT_EQ(gap->out(), olive::core::rational(5)); + EXPECT_EQ(gap->in(), olive::core::Rational(2)); + EXPECT_EQ(gap->out(), olive::core::Rational(5)); EXPECT_EQ(b->track(), nullptr); - EXPECT_EQ(c->in(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(6)); + EXPECT_EQ(c->in(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(6)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(c->in(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(c->in(), olive::core::Rational(5)); } TEST_F(TimelineUndoGeneralTest, ReplaceBlockWithGapExtendsPreviousGap) { - olive::Track *track = CreateTrack(project_.get()); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(1)); - track->AppendBlock(g); - track->AppendBlock(b); - track->AppendBlock(c); + olive::Track *track = create_track(project_.get()); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(1)); + track->append_block(g); + track->append_block(b); + track->append_block(c); // Layout: gap [0,2], b [2,5], c [5,6] olive::TrackReplaceBlockWithGapCommand cmd(track, b); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), g); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), g); // The preceding gap grows to absorb the removed block's time - EXPECT_EQ(g->length(), olive::core::rational(5)); - EXPECT_EQ(g->in(), olive::core::rational(0)); - EXPECT_EQ(g->out(), olive::core::rational(5)); - EXPECT_EQ(c->in(), olive::core::rational(5)); - EXPECT_EQ(c->out(), olive::core::rational(6)); + EXPECT_EQ(g->length(), olive::core::Rational(5)); + EXPECT_EQ(g->in(), olive::core::Rational(0)); + EXPECT_EQ(g->out(), olive::core::Rational(5)); + EXPECT_EQ(c->in(), olive::core::Rational(5)); + EXPECT_EQ(c->out(), olive::core::Rational(6)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(g->length(), olive::core::rational(2)); - EXPECT_EQ(g->out(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(c->in(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(g->length(), olive::core::Rational(2)); + EXPECT_EQ(g->out(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(c->in(), olive::core::Rational(5)); } TEST_F(TimelineUndoGeneralTest, ReplaceBlockWithGapExtendsNextGap) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(g); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(2)); + track->append_block(a); + track->append_block(b); + track->append_block(g); // Layout: a [0,2], b [2,4], gap [4,6] olive::TrackReplaceBlockWithGapCommand cmd(track, b); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), g); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), g); // The following gap grows backwards to absorb the removed block's time - EXPECT_EQ(g->length(), olive::core::rational(4)); - EXPECT_EQ(g->in(), olive::core::rational(2)); - EXPECT_EQ(g->out(), olive::core::rational(6)); - EXPECT_EQ(a->out(), olive::core::rational(2)); + EXPECT_EQ(g->length(), olive::core::Rational(4)); + EXPECT_EQ(g->in(), olive::core::Rational(2)); + EXPECT_EQ(g->out(), olive::core::Rational(6)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(4)); - EXPECT_EQ(g->length(), olive::core::rational(2)); - EXPECT_EQ(g->in(), olive::core::rational(4)); - EXPECT_EQ(g->out(), olive::core::rational(6)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(4)); + EXPECT_EQ(g->length(), olive::core::Rational(2)); + EXPECT_EQ(g->in(), olive::core::Rational(4)); + EXPECT_EQ(g->out(), olive::core::Rational(6)); } TEST_F(TimelineUndoGeneralTest, ReplaceBlockWithGapMergesSurroundingGaps) { - olive::Track *track = CreateTrack(project_.get()); - olive::GapBlock *g1 = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); - olive::GapBlock *g2 = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(g1); - track->AppendBlock(b); - track->AppendBlock(g2); - track->AppendBlock(c); + olive::Track *track = create_track(project_.get()); + olive::GapBlock *g1 = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); + olive::GapBlock *g2 = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(g1); + track->append_block(b); + track->append_block(g2); + track->append_block(c); // Layout: gap [0,2], b [2,4], gap [4,6], c [6,8] olive::TrackReplaceBlockWithGapCommand cmd(track, b); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), g1); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), g1); // Both surrounding gaps merge into one covering the removed block - EXPECT_EQ(g1->length(), olive::core::rational(6)); - EXPECT_EQ(g1->in(), olive::core::rational(0)); - EXPECT_EQ(g1->out(), olive::core::rational(6)); - EXPECT_EQ(c->in(), olive::core::rational(6)); - EXPECT_EQ(c->out(), olive::core::rational(8)); + EXPECT_EQ(g1->length(), olive::core::Rational(6)); + EXPECT_EQ(g1->in(), olive::core::Rational(0)); + EXPECT_EQ(g1->out(), olive::core::Rational(6)); + EXPECT_EQ(c->in(), olive::core::Rational(6)); + EXPECT_EQ(c->out(), olive::core::Rational(8)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 4); - EXPECT_EQ(track->Blocks().at(0), g1); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(track->Blocks().at(2), g2); - EXPECT_EQ(track->Blocks().at(3), c); - EXPECT_EQ(g1->length(), olive::core::rational(2)); - EXPECT_EQ(g2->length(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(4)); - EXPECT_EQ(g2->in(), olive::core::rational(4)); - EXPECT_EQ(g2->out(), olive::core::rational(6)); - EXPECT_EQ(c->in(), olive::core::rational(6)); + ASSERT_EQ(track->blocks().size(), 4); + EXPECT_EQ(track->blocks().at(0), g1); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(track->blocks().at(2), g2); + EXPECT_EQ(track->blocks().at(3), c); + EXPECT_EQ(g1->length(), olive::core::Rational(2)); + EXPECT_EQ(g2->length(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(4)); + EXPECT_EQ(g2->in(), olive::core::Rational(4)); + EXPECT_EQ(g2->out(), olive::core::Rational(6)); + EXPECT_EQ(c->in(), olive::core::Rational(6)); } TEST_F(TimelineUndoGeneralTest, ReplaceBlockWithGapRemovesLastBlock) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Layout: a [0,2], b [2,5] olive::TrackReplaceBlockWithGapCommand cmd(track, b); cmd.redo_now(); // The last block needs no gap, it is simply removed - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(track->Blocks().at(0), a); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(track->blocks().at(0), a); EXPECT_EQ(b->track(), nullptr); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); } TEST_F(TimelineUndoGeneralTest, ReplaceBlockWithGapRemovesPrecedingGapAtEnd) { - olive::Track *track = CreateTrack(project_.get()); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(g); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(g); + track->append_block(b); // Layout: gap [0,2], b [2,5] olive::TrackReplaceBlockWithGapCommand cmd(track, b); cmd.redo_now(); // Removing the last block also removes the now-pointless gap before it - EXPECT_TRUE(track->Blocks().isEmpty()); - EXPECT_EQ(track->track_length(), olive::core::rational(0)); + EXPECT_TRUE(track->blocks().isEmpty()); + EXPECT_EQ(track->track_length(), olive::core::Rational(0)); EXPECT_EQ(g->track(), nullptr); EXPECT_EQ(b->track(), nullptr); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), g); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(g->in(), olive::core::rational(0)); - EXPECT_EQ(g->out(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), g); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(g->in(), olive::core::Rational(0)); + EXPECT_EQ(g->out(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); } TEST_F(TimelineUndoGeneralTest, InsertGapsSplitsClipAndInsertsGap) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(4)); - track->AppendBlock(a); - track->AppendBlock(b); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(4)); + track->append_block(a); + track->append_block(b); + append_track_to_list(list, track); // Layout: a [0,2], b [2,6] - olive::TrackListInsertGaps cmd(list, olive::core::rational(3), - olive::core::rational(2)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::TrackListInsertGaps cmd(list, olive::core::Rational(3), + olive::core::Rational(2)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); // b is split at the insert point and a gap goes between the halves - ASSERT_EQ(track->Blocks().size(), 4); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->length(), olive::core::rational(1)); - EXPECT_EQ(b->out(), olive::core::rational(3)); - olive::Block *gap = track->Blocks().at(2); + ASSERT_EQ(track->blocks().size(), 4); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->length(), olive::core::Rational(1)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); + olive::Block *gap = track->blocks().at(2); EXPECT_NE(dynamic_cast(gap), nullptr); - EXPECT_EQ(gap->in(), olive::core::rational(3)); - EXPECT_EQ(gap->out(), olive::core::rational(5)); - olive::Block *second_half = track->Blocks().at(3); - EXPECT_EQ(second_half->in(), olive::core::rational(5)); - EXPECT_EQ(second_half->out(), olive::core::rational(8)); - EXPECT_EQ(track->track_length(), olive::core::rational(8)); + EXPECT_EQ(gap->in(), olive::core::Rational(3)); + EXPECT_EQ(gap->out(), olive::core::Rational(5)); + olive::Block *second_half = track->blocks().at(3); + EXPECT_EQ(second_half->in(), olive::core::Rational(5)); + EXPECT_EQ(second_half->out(), olive::core::Rational(8)); + EXPECT_EQ(track->track_length(), olive::core::Rational(8)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->length(), olive::core::rational(4)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(6)); - EXPECT_EQ(track->track_length(), olive::core::rational(6)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->length(), olive::core::Rational(4)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); + EXPECT_EQ(track->track_length(), olive::core::Rational(6)); } TEST_F(TimelineUndoGeneralTest, InsertGapsExtendsExistingGap) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(4)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(g); - track->AppendBlock(c); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(4)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(g); + track->append_block(c); + append_track_to_list(list, track); // Layout: gap [0,4], c [4,6] - olive::TrackListInsertGaps cmd(list, olive::core::rational(3), - olive::core::rational(2)); + olive::TrackListInsertGaps cmd(list, olive::core::Rational(3), + olive::core::Rational(2)); cmd.redo_now(); // A gap already at the insert point simply grows - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(g->length(), olive::core::rational(6)); - EXPECT_EQ(g->out(), olive::core::rational(6)); - EXPECT_EQ(c->in(), olive::core::rational(6)); - EXPECT_EQ(c->out(), olive::core::rational(8)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(g->length(), olive::core::Rational(6)); + EXPECT_EQ(g->out(), olive::core::Rational(6)); + EXPECT_EQ(c->in(), olive::core::Rational(6)); + EXPECT_EQ(c->out(), olive::core::Rational(8)); cmd.undo_now(); - EXPECT_EQ(g->length(), olive::core::rational(4)); - EXPECT_EQ(g->out(), olive::core::rational(4)); - EXPECT_EQ(c->in(), olive::core::rational(4)); - EXPECT_EQ(c->out(), olive::core::rational(6)); + EXPECT_EQ(g->length(), olive::core::Rational(4)); + EXPECT_EQ(g->out(), olive::core::Rational(4)); + EXPECT_EQ(c->in(), olive::core::Rational(4)); + EXPECT_EQ(c->out(), olive::core::Rational(6)); } TEST_F(TimelineUndoGeneralTest, InsertGapsSkipsLockedTracks) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); - olive::Track *t1 = CreateTrack(project_.get()); - t1->AppendBlock(CreateClip(project_.get(), olive::core::rational(4))); - AppendTrackToList(list, t1); + olive::Track *t1 = create_track(project_.get()); + t1->append_block(create_clip(project_.get(), olive::core::Rational(4))); + append_track_to_list(list, t1); - olive::Track *t2 = CreateTrack(project_.get()); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(4)); - t2->AppendBlock(c); - AppendTrackToList(list, t2); - t2->SetLocked(true); + olive::Track *t2 = create_track(project_.get()); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(4)); + t2->append_block(c); + append_track_to_list(list, t2); + t2->set_locked(true); // Layout: t1 [0,4] / t2 [0,4] - olive::TrackListInsertGaps cmd(list, olive::core::rational(2), - olive::core::rational(2)); + olive::TrackListInsertGaps cmd(list, olive::core::Rational(2), + olive::core::Rational(2)); cmd.redo_now(); - EXPECT_EQ(t1->track_length(), olive::core::rational(6)); + EXPECT_EQ(t1->track_length(), olive::core::Rational(6)); // The locked track is untouched - EXPECT_EQ(t2->Blocks().size(), 1); - EXPECT_EQ(t2->track_length(), olive::core::rational(4)); + EXPECT_EQ(t2->blocks().size(), 1); + EXPECT_EQ(t2->track_length(), olive::core::Rational(4)); cmd.undo_now(); - EXPECT_EQ(t1->track_length(), olive::core::rational(4)); - EXPECT_EQ(t2->track_length(), olive::core::rational(4)); + EXPECT_EQ(t1->track_length(), olive::core::Rational(4)); + EXPECT_EQ(t2->track_length(), olive::core::Rational(4)); } TEST_F(TimelineUndoGeneralTest, InsertGapsAtOrBeyondEndDoesNothing) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(a); + append_track_to_list(list, track); // Layout: a [0,2] // Exactly at the end of the last block no gap is needed - olive::TrackListInsertGaps at_end(list, olive::core::rational(2), - olive::core::rational(2)); + olive::TrackListInsertGaps at_end(list, olive::core::Rational(2), + olive::core::Rational(2)); at_end.redo_now(); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); at_end.undo_now(); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); // Beyond all content there is nothing to split or extend - olive::TrackListInsertGaps beyond(list, olive::core::rational(5), - olive::core::rational(2)); + olive::TrackListInsertGaps beyond(list, olive::core::Rational(5), + olive::core::Rational(2)); beyond.redo_now(); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); beyond.undo_now(); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); } TEST_F(TimelineUndoGeneralTest, AddDefaultTransitionAddsInAndOutTransitions) { - olive::NodeFactory::Initialize(); + olive::NodeFactory::initialize(); - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(4)); - track->AppendBlock(c); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(4)); + track->append_block(c); + append_track_to_list(list, track); // Layout: c [0,4] olive::TimelineAddDefaultTransitionCommand cmd( - { c }, olive::core::rational(1, 30)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + { c }, olive::core::Rational(1, 30)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); // A lone clip gets an in transition and an out transition, each one second - ASSERT_EQ(track->Blocks().size(), 3); + ASSERT_EQ(track->blocks().size(), 3); auto *in_transition = - dynamic_cast(track->Blocks().at(0)); + dynamic_cast(track->blocks().at(0)); auto *out_transition = - dynamic_cast(track->Blocks().at(2)); + dynamic_cast(track->blocks().at(2)); ASSERT_NE(in_transition, nullptr); ASSERT_NE(out_transition, nullptr); - EXPECT_EQ(in_transition->in(), olive::core::rational(0)); - EXPECT_EQ(in_transition->out(), olive::core::rational(1)); + EXPECT_EQ(in_transition->in(), olive::core::Rational(0)); + EXPECT_EQ(in_transition->out(), olive::core::Rational(1)); EXPECT_EQ(in_transition->connected_in_block(), c); EXPECT_EQ(in_transition->connected_out_block(), nullptr); EXPECT_FALSE(in_transition->is_dual_transition()); - EXPECT_EQ(c->length(), olive::core::rational(2)); - EXPECT_EQ(c->media_in(), olive::core::rational(1)); - EXPECT_EQ(c->in(), olive::core::rational(1)); - EXPECT_EQ(c->out(), olive::core::rational(3)); + EXPECT_EQ(c->length(), olive::core::Rational(2)); + EXPECT_EQ(c->media_in(), olive::core::Rational(1)); + EXPECT_EQ(c->in(), olive::core::Rational(1)); + EXPECT_EQ(c->out(), olive::core::Rational(3)); - EXPECT_EQ(out_transition->in(), olive::core::rational(3)); - EXPECT_EQ(out_transition->out(), olive::core::rational(4)); + EXPECT_EQ(out_transition->in(), olive::core::Rational(3)); + EXPECT_EQ(out_transition->out(), olive::core::Rational(4)); EXPECT_EQ(out_transition->connected_out_block(), c); EXPECT_EQ(out_transition->connected_in_block(), nullptr); // The total length of the track is unchanged - EXPECT_EQ(track->track_length(), olive::core::rational(4)); + EXPECT_EQ(track->track_length(), olive::core::Rational(4)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(track->Blocks().at(0), c); - EXPECT_EQ(c->length(), olive::core::rational(4)); - EXPECT_EQ(c->media_in(), olive::core::rational(0)); - EXPECT_EQ(c->in(), olive::core::rational(0)); - EXPECT_EQ(c->out(), olive::core::rational(4)); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(track->blocks().at(0), c); + EXPECT_EQ(c->length(), olive::core::Rational(4)); + EXPECT_EQ(c->media_in(), olive::core::Rational(0)); + EXPECT_EQ(c->in(), olive::core::Rational(0)); + EXPECT_EQ(c->out(), olive::core::Rational(4)); EXPECT_EQ(in_transition->project(), nullptr); EXPECT_EQ(out_transition->project(), nullptr); } TEST_F(TimelineUndoGeneralTest, AddDefaultTransitionAddsDualTransition) { - olive::NodeFactory::Initialize(); + olive::NodeFactory::initialize(); - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(4)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(4)); - track->AppendBlock(a); - track->AppendBlock(b); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(4)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(4)); + track->append_block(a); + track->append_block(b); + append_track_to_list(list, track); // Layout: a [0,4], b [4,8] olive::TimelineAddDefaultTransitionCommand cmd( - { a, b }, olive::core::rational(1, 30)); + { a, b }, olive::core::Rational(1, 30)); cmd.redo_now(); // Adjacent clips get an in transition on a, a dual transition between // them, and an out transition on b - ASSERT_EQ(track->Blocks().size(), 5); + ASSERT_EQ(track->blocks().size(), 5); auto *in_transition = - dynamic_cast(track->Blocks().at(0)); + dynamic_cast(track->blocks().at(0)); auto *dual_transition = - dynamic_cast(track->Blocks().at(2)); + dynamic_cast(track->blocks().at(2)); auto *out_transition = - dynamic_cast(track->Blocks().at(4)); + dynamic_cast(track->blocks().at(4)); ASSERT_NE(in_transition, nullptr); ASSERT_NE(dual_transition, nullptr); ASSERT_NE(out_transition, nullptr); @@ -752,80 +752,80 @@ TEST_F(TimelineUndoGeneralTest, AddDefaultTransitionAddsDualTransition) EXPECT_EQ(dual_transition->connected_out_block(), a); EXPECT_EQ(dual_transition->connected_in_block(), b); // A centered dual transition overlaps each clip by half its length - EXPECT_EQ(dual_transition->in_offset(), olive::core::rational(1, 2)); - EXPECT_EQ(dual_transition->out_offset(), olive::core::rational(1, 2)); + EXPECT_EQ(dual_transition->in_offset(), olive::core::Rational(1, 2)); + EXPECT_EQ(dual_transition->out_offset(), olive::core::Rational(1, 2)); - EXPECT_EQ(a->length(), olive::core::rational(5, 2)); - EXPECT_EQ(a->in(), olive::core::rational(1)); - EXPECT_EQ(a->out(), olive::core::rational(7, 2)); - EXPECT_EQ(b->length(), olive::core::rational(5, 2)); - EXPECT_EQ(b->media_in(), olive::core::rational(1, 2)); - EXPECT_EQ(b->in(), olive::core::rational(9, 2)); - EXPECT_EQ(b->out(), olive::core::rational(7)); + EXPECT_EQ(a->length(), olive::core::Rational(5, 2)); + EXPECT_EQ(a->in(), olive::core::Rational(1)); + EXPECT_EQ(a->out(), olive::core::Rational(7, 2)); + EXPECT_EQ(b->length(), olive::core::Rational(5, 2)); + EXPECT_EQ(b->media_in(), olive::core::Rational(1, 2)); + EXPECT_EQ(b->in(), olive::core::Rational(9, 2)); + EXPECT_EQ(b->out(), olive::core::Rational(7)); - EXPECT_EQ(dual_transition->in(), olive::core::rational(7, 2)); - EXPECT_EQ(dual_transition->out(), olive::core::rational(9, 2)); - EXPECT_EQ(track->track_length(), olive::core::rational(8)); + EXPECT_EQ(dual_transition->in(), olive::core::Rational(7, 2)); + EXPECT_EQ(dual_transition->out(), olive::core::Rational(9, 2)); + EXPECT_EQ(track->track_length(), olive::core::Rational(8)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(a->length(), olive::core::rational(4)); - EXPECT_EQ(a->media_in(), olive::core::rational(0)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(4)); - EXPECT_EQ(b->length(), olive::core::rational(4)); - EXPECT_EQ(b->media_in(), olive::core::rational(0)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(8)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(a->length(), olive::core::Rational(4)); + EXPECT_EQ(a->media_in(), olive::core::Rational(0)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(4)); + EXPECT_EQ(b->length(), olive::core::Rational(4)); + EXPECT_EQ(b->media_in(), olive::core::Rational(0)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(8)); } TEST_F(TimelineUndoGeneralTest, AddDefaultTransitionEmptyClipListIsHarmless) { // A real timeline with two adjacent clips; the empty command must leave // every observable detail of it untouched - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(4)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(4)); - track->AppendBlock(a); - track->AppendBlock(b); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(4)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(4)); + track->append_block(a); + track->append_block(b); + append_track_to_list(list, track); // Layout: a [0,4], b [4,8] olive::TimelineAddDefaultTransitionCommand cmd( - {}, olive::core::rational(1, 30)); - EXPECT_EQ(cmd.GetRelevantProject(), nullptr); + {}, olive::core::Rational(1, 30)); + EXPECT_EQ(cmd.get_relevant_project(), nullptr); // redo on an empty command adds no transitions and changes nothing cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(a->length(), olive::core::rational(4)); - EXPECT_EQ(a->media_in(), olive::core::rational(0)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(4)); - EXPECT_EQ(b->length(), olive::core::rational(4)); - EXPECT_EQ(b->media_in(), olive::core::rational(0)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(8)); - EXPECT_EQ(track->track_length(), olive::core::rational(8)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(a->length(), olive::core::Rational(4)); + EXPECT_EQ(a->media_in(), olive::core::Rational(0)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(4)); + EXPECT_EQ(b->length(), olive::core::Rational(4)); + EXPECT_EQ(b->media_in(), olive::core::Rational(0)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(8)); + EXPECT_EQ(track->track_length(), olive::core::Rational(8)); // undo is equally a no-op cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(a->length(), olive::core::rational(4)); - EXPECT_EQ(a->media_in(), olive::core::rational(0)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(4)); - EXPECT_EQ(b->length(), olive::core::rational(4)); - EXPECT_EQ(b->media_in(), olive::core::rational(0)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(8)); - EXPECT_EQ(track->track_length(), olive::core::rational(8)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(a->length(), olive::core::Rational(4)); + EXPECT_EQ(a->media_in(), olive::core::Rational(0)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(4)); + EXPECT_EQ(b->length(), olive::core::Rational(4)); + EXPECT_EQ(b->media_in(), olive::core::Rational(0)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(8)); + EXPECT_EQ(track->track_length(), olive::core::Rational(8)); } diff --git a/tests/gtest/timeline_undo_test.cpp b/tests/gtest/timeline_undo_test.cpp index 4c8ee0b62..a22372601 100644 --- a/tests/gtest/timeline_undo_test.cpp +++ b/tests/gtest/timeline_undo_test.cpp @@ -21,22 +21,22 @@ namespace { -olive::Sequence *CreateSequence(olive::Project *project) +olive::Sequence *create_sequence(olive::Project *project) { auto *sequence = new olive::Sequence(); sequence->setParent(project); return sequence; } -olive::Track *CreateTrack(olive::Project *project) +olive::Track *create_track(olive::Project *project) { auto *track = new olive::Track(); track->setParent(project); return track; } -olive::ClipBlock *CreateClip(olive::Project *project, - const olive::core::rational &length) +olive::ClipBlock *create_clip(olive::Project *project, + const olive::core::Rational &length) { auto *clip = new olive::ClipBlock(); clip->setParent(project); @@ -44,8 +44,8 @@ olive::ClipBlock *CreateClip(olive::Project *project, return clip; } -olive::GapBlock *CreateGap(olive::Project *project, - const olive::core::rational &length) +olive::GapBlock *create_gap(olive::Project *project, + const olive::core::Rational &length) { auto *gap = new olive::GapBlock(); gap->setParent(project); @@ -53,11 +53,11 @@ olive::GapBlock *CreateGap(olive::Project *project, return gap; } -void AppendTrackToList(olive::TrackList *list, olive::Track *track) +void append_track_to_list(olive::TrackList *list, olive::Track *track) { - list->ArrayAppend(); - olive::Node::ConnectEdge(track, - list->track_input(list->ArraySize() - 1)); + list->array_append(); + olive::Node::connect_edge(track, + list->track_input(list->array_size() - 1)); } } // namespace @@ -66,10 +66,10 @@ class TimelineUndoTest : public ::testing::Test { protected: void SetUp() override { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } std::unique_ptr project_; @@ -80,116 +80,116 @@ protected: // TEST_F(TimelineUndoTest, RippleRemoveBlockCommandRemovesAndRestores) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); // Layout: a [0,2], b [2,5], c [5,6] olive::TrackRippleRemoveBlockCommand cmd(track, b); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), c); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), c); EXPECT_EQ(b->track(), nullptr); - EXPECT_EQ(c->in(), olive::core::rational(2)); - EXPECT_EQ(c->out(), olive::core::rational(3)); - EXPECT_EQ(track->track_length(), olive::core::rational(3)); + EXPECT_EQ(c->in(), olive::core::Rational(2)); + EXPECT_EQ(c->out(), olive::core::Rational(3)); + EXPECT_EQ(track->track_length(), olive::core::Rational(3)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), b); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), b); EXPECT_EQ(b->track(), track); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(c->in(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(6)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(c->in(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(6)); } TEST_F(TimelineUndoTest, PrependBlockCommandInsertsAndRemoves) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(b); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(1)); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(1)); olive::TrackPrependBlockCommand cmd(track, a); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(1)); - EXPECT_EQ(b->out(), olive::core::rational(3)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(1)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(track->Blocks().at(0), b); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(track->blocks().at(0), b); EXPECT_EQ(a->track(), nullptr); - EXPECT_EQ(b->in(), olive::core::rational(0)); - EXPECT_EQ(b->out(), olive::core::rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(0)); + EXPECT_EQ(b->out(), olive::core::Rational(2)); } TEST_F(TimelineUndoTest, InsertBlockAfterCommandInsertsAndRemoves) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(1)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(c); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(1)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(1)); + track->append_block(a); + track->append_block(c); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); olive::TrackInsertBlockAfterCommand cmd(track, b, a); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->in(), olive::core::rational(1)); - EXPECT_EQ(b->out(), olive::core::rational(3)); - EXPECT_EQ(c->in(), olive::core::rational(3)); - EXPECT_EQ(track->track_length(), olive::core::rational(4)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->in(), olive::core::Rational(1)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); + EXPECT_EQ(c->in(), olive::core::Rational(3)); + EXPECT_EQ(track->track_length(), olive::core::Rational(4)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); + ASSERT_EQ(track->blocks().size(), 2); EXPECT_EQ(b->track(), nullptr); - EXPECT_EQ(c->in(), olive::core::rational(1)); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + EXPECT_EQ(c->in(), olive::core::Rational(1)); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); } TEST_F(TimelineUndoTest, ReplaceBlockCommandSwapsAndRestores) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); - olive::ClipBlock *r = CreateClip(project_.get(), olive::core::rational(3)); + olive::ClipBlock *r = create_clip(project_.get(), olive::core::Rational(3)); olive::TrackReplaceBlockCommand cmd(track, b, r); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), r); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), r); EXPECT_EQ(b->track(), nullptr); - EXPECT_EQ(r->in(), olive::core::rational(2)); - EXPECT_EQ(r->out(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(5)); + EXPECT_EQ(r->in(), olive::core::Rational(2)); + EXPECT_EQ(r->out(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(5)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), b); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), b); EXPECT_EQ(r->track(), nullptr); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); } // @@ -201,7 +201,7 @@ TEST_F(TimelineUndoTest, WorkareaSetEnabledCommandToggles) ASSERT_FALSE(workarea.enabled()); olive::WorkareaSetEnabledCommand cmd(project_.get(), &workarea, true); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); EXPECT_TRUE(workarea.enabled()); @@ -213,10 +213,10 @@ TEST_F(TimelineUndoTest, WorkareaSetEnabledCommandToggles) TEST_F(TimelineUndoTest, WorkareaSetRangeCommandSetsAndRestores) { olive::TimelineWorkArea workarea; - const olive::core::TimeRange old_range(olive::core::rational(2), - olive::core::rational(6)); - const olive::core::TimeRange new_range(olive::core::rational(3), - olive::core::rational(9)); + const olive::core::TimeRange old_range(olive::core::Rational(2), + olive::core::Rational(6)); + const olive::core::TimeRange new_range(olive::core::Rational(3), + olive::core::Rational(9)); workarea.set_range(old_range); // The two-argument form captures the workarea's current range as the old one @@ -232,18 +232,18 @@ TEST_F(TimelineUndoTest, WorkareaSetRangeCommandSetsAndRestores) TEST_F(TimelineUndoTest, WorkareaSetRangeCommandExplicitOldRange) { olive::TimelineWorkArea workarea; - const olive::core::TimeRange old_range(olive::core::rational(0), - olive::core::rational(10)); - const olive::core::TimeRange new_range(olive::core::rational(4), - olive::core::rational(5)); + const olive::core::TimeRange old_range(olive::core::Rational(0), + olive::core::Rational(10)); + const olive::core::TimeRange new_range(olive::core::Rational(4), + olive::core::Rational(5)); workarea.set_range(old_range); olive::WorkareaSetRangeCommand cmd(&workarea, new_range, old_range); cmd.redo_now(); EXPECT_EQ(workarea.range(), new_range); - EXPECT_EQ(workarea.in(), olive::core::rational(4)); - EXPECT_EQ(workarea.out(), olive::core::rational(5)); + EXPECT_EQ(workarea.in(), olive::core::Rational(4)); + EXPECT_EQ(workarea.out(), olive::core::Rational(5)); cmd.undo_now(); EXPECT_EQ(workarea.range(), old_range); @@ -254,17 +254,17 @@ TEST_F(TimelineUndoTest, WorkareaSetRangeCommandExplicitOldRange) // TEST_F(TimelineUndoTest, NodeCanBeRemovedReflectsConnections) { - olive::ClipBlock *clip = CreateClip(project_.get(), olive::core::rational(2)); + olive::ClipBlock *clip = create_clip(project_.get(), olive::core::Rational(2)); // An unconnected node has no output connections and can be removed - EXPECT_TRUE(olive::NodeCanBeRemoved(clip)); + EXPECT_TRUE(olive::node_can_be_removed(clip)); - olive::Track *track = CreateTrack(project_.get()); - track->AppendBlock(clip); - EXPECT_FALSE(olive::NodeCanBeRemoved(clip)); + olive::Track *track = create_track(project_.get()); + track->append_block(clip); + EXPECT_FALSE(olive::node_can_be_removed(clip)); - track->RippleRemoveBlock(clip); - EXPECT_TRUE(olive::NodeCanBeRemoved(clip)); + track->ripple_remove_block(clip); + EXPECT_TRUE(olive::node_can_be_removed(clip)); } TEST_F(TimelineUndoTest, CreateAndRunRemoveCommandRemovesFromGraph) @@ -273,7 +273,7 @@ TEST_F(TimelineUndoTest, CreateAndRunRemoveCommandRemovesFromGraph) node->setParent(project_.get()); ASSERT_EQ(node->project(), project_.get()); - olive::UndoCommand *cmd = olive::CreateAndRunRemoveCommand(node); + olive::UndoCommand *cmd = olive::create_and_run_remove_command(node); EXPECT_EQ(node->project(), nullptr); EXPECT_FALSE(project_->nodes().contains(node)); @@ -289,180 +289,180 @@ TEST_F(TimelineUndoTest, CreateAndRunRemoveCommandRemovesFromGraph) // TEST_F(TimelineUndoTest, BlockSplitCommandSplitsAndMerges) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(4)); - track->AppendBlock(a); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(4)); + track->append_block(a); // Layout: a [0,4] - olive::BlockSplitCommand cmd(a, olive::core::rational(1)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::BlockSplitCommand cmd(a, olive::core::Rational(1)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); olive::Block *split = cmd.new_block(); ASSERT_NE(split, nullptr); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), split); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), split); - EXPECT_EQ(a->length(), olive::core::rational(1)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(1)); + EXPECT_EQ(a->length(), olive::core::Rational(1)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(1)); - EXPECT_EQ(split->length(), olive::core::rational(3)); - EXPECT_EQ(split->in(), olive::core::rational(1)); - EXPECT_EQ(split->out(), olive::core::rational(4)); + EXPECT_EQ(split->length(), olive::core::Rational(3)); + EXPECT_EQ(split->in(), olive::core::Rational(1)); + EXPECT_EQ(split->out(), olive::core::Rational(4)); // The second half's media in point is offset by the split time EXPECT_EQ(static_cast(split)->media_in(), - olive::core::rational(1)); + olive::core::Rational(1)); - EXPECT_EQ(track->track_length(), olive::core::rational(4)); + EXPECT_EQ(track->track_length(), olive::core::Rational(4)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(a->length(), olive::core::rational(4)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(4)); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(a->length(), olive::core::Rational(4)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(4)); EXPECT_EQ(split->track(), nullptr); } TEST_F(TimelineUndoTest, BlockSplitCommandMovesOutTransitionToNewBlock) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(4)); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(4)); auto *transition = new olive::CrossDissolveTransition(); transition->setParent(project_.get()); - transition->set_length_and_media_out(olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(transition); - olive::Node::ConnectEdge( - a, olive::NodeInput(transition, olive::TransitionBlock::kOutBlockInput)); + transition->set_length_and_media_out(olive::core::Rational(2)); + track->append_block(a); + track->append_block(transition); + olive::Node::connect_edge( + a, olive::NodeInput(transition, olive::TransitionBlock::k_out_block_input)); ASSERT_EQ(transition->connected_out_block(), a); // Layout: a [0,4], transition [4,6] - olive::BlockSplitCommand cmd(a, olive::core::rational(2)); + olive::BlockSplitCommand cmd(a, olive::core::Rational(2)); cmd.redo_now(); olive::Block *split = cmd.new_block(); ASSERT_NE(split, nullptr); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(split->in(), olive::core::rational(2)); - EXPECT_EQ(split->out(), olive::core::rational(4)); - EXPECT_EQ(transition->in(), olive::core::rational(4)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(split->in(), olive::core::Rational(2)); + EXPECT_EQ(split->out(), olive::core::Rational(4)); + EXPECT_EQ(transition->in(), olive::core::Rational(4)); // The out transition moved from the original block to the split block EXPECT_EQ(transition->connected_out_block(), split); EXPECT_EQ(olive::NodeInput(transition, - olive::TransitionBlock::kOutBlockInput) - .GetConnectedOutput(), + olive::TransitionBlock::k_out_block_input) + .get_connected_output(), split); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(a->length(), olive::core::rational(4)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(a->length(), olive::core::Rational(4)); EXPECT_EQ(transition->connected_out_block(), a); - EXPECT_EQ(transition->in(), olive::core::rational(4)); + EXPECT_EQ(transition->in(), olive::core::Rational(4)); } TEST_F(TimelineUndoTest, BlockSplitPreservingLinksCommandSplitsLinkedBlocks) { - olive::Track *video_track = CreateTrack(project_.get()); - olive::Track *audio_track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(4)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(4)); - video_track->AppendBlock(a); - audio_track->AppendBlock(b); - olive::Node::Link(a, b); + olive::Track *video_track = create_track(project_.get()); + olive::Track *audio_track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(4)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(4)); + video_track->append_block(a); + audio_track->append_block(b); + olive::Node::link(a, b); olive::BlockSplitPreservingLinksCommand cmd( - { a, b }, { olive::core::rational(2) }); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + { a, b }, { olive::core::Rational(2) }); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(video_track->Blocks().size(), 2); - ASSERT_EQ(audio_track->Blocks().size(), 2); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(b->length(), olive::core::rational(2)); + ASSERT_EQ(video_track->blocks().size(), 2); + ASSERT_EQ(audio_track->blocks().size(), 2); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(b->length(), olive::core::Rational(2)); - olive::Block *a_split = cmd.GetSplit(a, 0); - olive::Block *b_split = cmd.GetSplit(b, 0); + olive::Block *a_split = cmd.get_split(a, 0); + olive::Block *b_split = cmd.get_split(b, 0); ASSERT_NE(a_split, nullptr); ASSERT_NE(b_split, nullptr); - EXPECT_EQ(a_split->in(), olive::core::rational(2)); - EXPECT_EQ(b_split->in(), olive::core::rational(2)); + EXPECT_EQ(a_split->in(), olive::core::Rational(2)); + EXPECT_EQ(b_split->in(), olive::core::Rational(2)); // The original link survives and the new halves are linked together too - EXPECT_TRUE(olive::Node::AreLinked(a, b)); - EXPECT_TRUE(olive::Node::AreLinked(a_split, b_split)); + EXPECT_TRUE(olive::Node::are_linked(a, b)); + EXPECT_TRUE(olive::Node::are_linked(a_split, b_split)); // Invalid lookups return null instead of crashing - EXPECT_EQ(cmd.GetSplit(a, 1), nullptr); - EXPECT_EQ(cmd.GetSplit(a, -1), nullptr); + EXPECT_EQ(cmd.get_split(a, 1), nullptr); + EXPECT_EQ(cmd.get_split(a, -1), nullptr); olive::ClipBlock *stray = - CreateClip(project_.get(), olive::core::rational(1)); - EXPECT_EQ(cmd.GetSplit(stray, 0), nullptr); + create_clip(project_.get(), olive::core::Rational(1)); + EXPECT_EQ(cmd.get_split(stray, 0), nullptr); cmd.undo_now(); - ASSERT_EQ(video_track->Blocks().size(), 1); - ASSERT_EQ(audio_track->Blocks().size(), 1); - EXPECT_EQ(a->length(), olive::core::rational(4)); - EXPECT_EQ(b->length(), olive::core::rational(4)); - EXPECT_TRUE(olive::Node::AreLinked(a, b)); + ASSERT_EQ(video_track->blocks().size(), 1); + ASSERT_EQ(audio_track->blocks().size(), 1); + EXPECT_EQ(a->length(), olive::core::Rational(4)); + EXPECT_EQ(b->length(), olive::core::Rational(4)); + EXPECT_TRUE(olive::Node::are_linked(a, b)); } TEST_F(TimelineUndoTest, TrackSplitAtTimeCommandSplitsContainingBlock) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Layout: a [0,2], b [2,5] - olive::TrackSplitAtTimeCommand cmd(track, olive::core::rational(3)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::TrackSplitAtTimeCommand cmd(track, olive::core::Rational(3)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(b->length(), olive::core::rational(1)); - EXPECT_EQ(b->out(), olive::core::rational(3)); - EXPECT_EQ(track->Blocks().at(2)->in(), olive::core::rational(3)); - EXPECT_EQ(track->Blocks().at(2)->out(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(b->length(), olive::core::Rational(1)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); + EXPECT_EQ(track->blocks().at(2)->in(), olive::core::Rational(3)); + EXPECT_EQ(track->blocks().at(2)->out(), olive::core::Rational(5)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); } TEST_F(TimelineUndoTest, TrackSplitAtTimeCommandNoOpOutsideBlocks) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Layout: a [0,2], b [2,5] // A time exactly on a block boundary is not contained by any block - olive::TrackSplitAtTimeCommand on_edge(track, olive::core::rational(2)); + olive::TrackSplitAtTimeCommand on_edge(track, olive::core::Rational(2)); on_edge.redo_now(); - EXPECT_EQ(track->Blocks().size(), 2); + EXPECT_EQ(track->blocks().size(), 2); on_edge.undo_now(); - EXPECT_EQ(track->Blocks().size(), 2); + EXPECT_EQ(track->blocks().size(), 2); // A time past the end of the track contains nothing either - olive::TrackSplitAtTimeCommand past_end(track, olive::core::rational(10)); + olive::TrackSplitAtTimeCommand past_end(track, olive::core::Rational(10)); past_end.redo_now(); - EXPECT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(b->length(), olive::core::rational(3)); + EXPECT_EQ(track->blocks().size(), 2); + EXPECT_EQ(b->length(), olive::core::Rational(3)); past_end.undo_now(); - EXPECT_EQ(track->Blocks().size(), 2); + EXPECT_EQ(track->blocks().size(), 2); } // @@ -470,486 +470,486 @@ TEST_F(TimelineUndoTest, TrackSplitAtTimeCommandNoOpOutsideBlocks) // TEST_F(TimelineUndoTest, RippleRemoveAreaRemovesMiddleBlock) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); // Layout: a [0,2], b [2,5], c [5,6] olive::TrackRippleRemoveAreaCommand cmd( - track, olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(5))); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + track, olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(5))); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), c); - EXPECT_EQ(c->in(), olive::core::rational(2)); - EXPECT_EQ(c->out(), olive::core::rational(3)); - EXPECT_EQ(track->track_length(), olive::core::rational(3)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), c); + EXPECT_EQ(c->in(), olive::core::Rational(2)); + EXPECT_EQ(c->out(), olive::core::Rational(3)); + EXPECT_EQ(track->track_length(), olive::core::Rational(3)); // The removed block was taken out of the graph entirely EXPECT_EQ(b->track(), nullptr); EXPECT_EQ(b->project(), nullptr); // An insertion would go after the block preceding the removed area - EXPECT_EQ(cmd.GetInsertionIndex(), a); + EXPECT_EQ(cmd.get_insertion_index(), a); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), b); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), b); EXPECT_EQ(b->project(), project_.get()); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(c->in(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(6)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(c->in(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(6)); } TEST_F(TimelineUndoTest, RippleRemoveAreaRemovesMultipleBlocks) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(1)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(1)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(1)); - olive::ClipBlock *d = CreateClip(project_.get(), olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); - track->AppendBlock(d); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(1)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(1)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(1)); + olive::ClipBlock *d = create_clip(project_.get(), olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); + track->append_block(d); // Layout: a [0,1], b [1,2], c [2,3], d [3,4] olive::TrackRippleRemoveAreaCommand cmd( - track, olive::core::TimeRange(olive::core::rational(1), - olive::core::rational(3))); + track, olive::core::TimeRange(olive::core::Rational(1), + olive::core::Rational(3))); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), d); - EXPECT_EQ(d->in(), olive::core::rational(1)); - EXPECT_EQ(d->out(), olive::core::rational(2)); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), d); + EXPECT_EQ(d->in(), olive::core::Rational(1)); + EXPECT_EQ(d->out(), olive::core::Rational(2)); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 4); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(track->Blocks().at(2), c); - EXPECT_EQ(track->Blocks().at(3), d); - EXPECT_EQ(b->in(), olive::core::rational(1)); - EXPECT_EQ(c->in(), olive::core::rational(2)); - EXPECT_EQ(d->in(), olive::core::rational(3)); - EXPECT_EQ(track->track_length(), olive::core::rational(4)); + ASSERT_EQ(track->blocks().size(), 4); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(track->blocks().at(2), c); + EXPECT_EQ(track->blocks().at(3), d); + EXPECT_EQ(b->in(), olive::core::Rational(1)); + EXPECT_EQ(c->in(), olive::core::Rational(2)); + EXPECT_EQ(d->in(), olive::core::Rational(3)); + EXPECT_EQ(track->track_length(), olive::core::Rational(4)); } TEST_F(TimelineUndoTest, RippleRemoveAreaTrimsBothEnds) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(4)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(4)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(4)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(4)); + track->append_block(a); + track->append_block(b); // Layout: a [0,4], b [4,8] olive::TrackRippleRemoveAreaCommand cmd( - track, olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(6))); + track, olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(6))); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); + ASSERT_EQ(track->blocks().size(), 2); // a is out-trimmed to the range start, b is in-trimmed to the range end - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(2)); - EXPECT_EQ(b->length(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(4)); - EXPECT_EQ(track->track_length(), olive::core::rational(4)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); + EXPECT_EQ(b->length(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(4)); + EXPECT_EQ(track->track_length(), olive::core::Rational(4)); cmd.undo_now(); - EXPECT_EQ(a->length(), olive::core::rational(4)); - EXPECT_EQ(b->length(), olive::core::rational(4)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(4)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(8)); + EXPECT_EQ(a->length(), olive::core::Rational(4)); + EXPECT_EQ(b->length(), olive::core::Rational(4)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(4)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(8)); } TEST_F(TimelineUndoTest, RippleRemoveAreaSplicesBlock) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(10)); - track->AppendBlock(a); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(10)); + track->append_block(a); // Layout: a [0,10] olive::TrackRippleRemoveAreaCommand cmd( - track, olive::core::TimeRange(olive::core::rational(3), - olive::core::rational(6))); + track, olive::core::TimeRange(olive::core::Rational(3), + olive::core::Rational(6))); cmd.redo_now(); // The block is split around the removed range and the second half is // in-trimmed by the range length - olive::Block *spliced = cmd.GetSplicedBlock(); + olive::Block *spliced = cmd.get_spliced_block(); ASSERT_NE(spliced, nullptr); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(a->length(), olive::core::rational(3)); - EXPECT_EQ(a->out(), olive::core::rational(3)); - EXPECT_EQ(spliced->in(), olive::core::rational(3)); - EXPECT_EQ(spliced->out(), olive::core::rational(7)); - EXPECT_EQ(spliced->length(), olive::core::rational(4)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(a->length(), olive::core::Rational(3)); + EXPECT_EQ(a->out(), olive::core::Rational(3)); + EXPECT_EQ(spliced->in(), olive::core::Rational(3)); + EXPECT_EQ(spliced->out(), olive::core::Rational(7)); + EXPECT_EQ(spliced->length(), olive::core::Rational(4)); EXPECT_EQ(static_cast(spliced)->media_in(), - olive::core::rational(6)); - EXPECT_EQ(track->track_length(), olive::core::rational(7)); + olive::core::Rational(6)); + EXPECT_EQ(track->track_length(), olive::core::Rational(7)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(a->length(), olive::core::rational(10)); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(10)); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(a->length(), olive::core::Rational(10)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(10)); } TEST_F(TimelineUndoTest, RippleRemoveAreaTrimsGapWhenSplittingGapsDisabled) { - olive::Track *track = CreateTrack(project_.get()); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(5)); - track->AppendBlock(g); + olive::Track *track = create_track(project_.get()); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(5)); + track->append_block(g); // Layout: gap [0,5] olive::TrackRippleRemoveAreaCommand cmd( - track, olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(4))); - ASSERT_EQ(cmd.GetSplicedBlock(), nullptr); + track, olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(4))); + ASSERT_EQ(cmd.get_spliced_block(), nullptr); cmd.redo_now(); // Gaps are not spliced by default, the gap is just trimmed by the range - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(g->length(), olive::core::rational(3)); - EXPECT_EQ(g->in(), olive::core::rational(0)); - EXPECT_EQ(g->out(), olive::core::rational(3)); - EXPECT_EQ(cmd.GetSplicedBlock(), nullptr); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(g->length(), olive::core::Rational(3)); + EXPECT_EQ(g->in(), olive::core::Rational(0)); + EXPECT_EQ(g->out(), olive::core::Rational(3)); + EXPECT_EQ(cmd.get_spliced_block(), nullptr); cmd.undo_now(); - EXPECT_EQ(g->length(), olive::core::rational(5)); - EXPECT_EQ(g->out(), olive::core::rational(5)); + EXPECT_EQ(g->length(), olive::core::Rational(5)); + EXPECT_EQ(g->out(), olive::core::Rational(5)); } TEST_F(TimelineUndoTest, RippleRemoveAreaNoOpOnEmptyRange) { - olive::Track *track = CreateTrack(project_.get()); + olive::Track *track = create_track(project_.get()); // Empty track: nothing to remove olive::TrackRippleRemoveAreaCommand empty_track( - track, olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(5))); + track, olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(5))); empty_track.redo_now(); - EXPECT_TRUE(track->Blocks().isEmpty()); + EXPECT_TRUE(track->blocks().isEmpty()); empty_track.undo_now(); - EXPECT_TRUE(track->Blocks().isEmpty()); + EXPECT_TRUE(track->blocks().isEmpty()); // Range fully beyond the track's content: also nothing to remove - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(a); olive::TrackRippleRemoveAreaCommand past_end( - track, olive::core::TimeRange(olive::core::rational(5), - olive::core::rational(7))); + track, olive::core::TimeRange(olive::core::Rational(5), + olive::core::Rational(7))); past_end.redo_now(); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); past_end.undo_now(); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); } TEST_F(TimelineUndoTest, TrackListRippleRemoveAreaAffectsAllTracks) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); - olive::Track *t1 = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - t1->AppendBlock(a); - t1->AppendBlock(b); - AppendTrackToList(list, t1); + olive::Track *t1 = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + t1->append_block(a); + t1->append_block(b); + append_track_to_list(list, t1); - olive::Track *t2 = CreateTrack(project_.get()); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(3)); - olive::ClipBlock *d = CreateClip(project_.get(), olive::core::rational(3)); - t2->AppendBlock(c); - t2->AppendBlock(d); - AppendTrackToList(list, t2); + olive::Track *t2 = create_track(project_.get()); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(3)); + olive::ClipBlock *d = create_clip(project_.get(), olive::core::Rational(3)); + t2->append_block(c); + t2->append_block(d); + append_track_to_list(list, t2); // t1: a [0,2], b [2,5] / t2: c [0,3], d [3,6] - olive::TrackListRippleRemoveAreaCommand cmd(list, olive::core::rational(2), - olive::core::rational(4)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::TrackListRippleRemoveAreaCommand cmd(list, olive::core::Rational(2), + olive::core::Rational(4)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); // t1: b is in-trimmed by the range - EXPECT_EQ(b->length(), olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(3)); + EXPECT_EQ(b->length(), olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); // t2: c is out-trimmed and d is in-trimmed - EXPECT_EQ(c->length(), olive::core::rational(2)); - EXPECT_EQ(d->length(), olive::core::rational(2)); - EXPECT_EQ(d->in(), olive::core::rational(2)); - EXPECT_EQ(d->out(), olive::core::rational(4)); + EXPECT_EQ(c->length(), olive::core::Rational(2)); + EXPECT_EQ(d->length(), olive::core::Rational(2)); + EXPECT_EQ(d->in(), olive::core::Rational(2)); + EXPECT_EQ(d->out(), olive::core::Rational(4)); cmd.undo_now(); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(c->length(), olive::core::rational(3)); - EXPECT_EQ(d->length(), olive::core::rational(3)); - EXPECT_EQ(d->in(), olive::core::rational(3)); - EXPECT_EQ(d->out(), olive::core::rational(6)); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(c->length(), olive::core::Rational(3)); + EXPECT_EQ(d->length(), olive::core::Rational(3)); + EXPECT_EQ(d->in(), olive::core::Rational(3)); + EXPECT_EQ(d->out(), olive::core::Rational(6)); } TEST_F(TimelineUndoTest, TrackListRippleRemoveAreaSkipsLockedTracks) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); - olive::Track *t1 = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - t1->AppendBlock(a); - t1->AppendBlock(b); - AppendTrackToList(list, t1); + olive::Track *t1 = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + t1->append_block(a); + t1->append_block(b); + append_track_to_list(list, t1); - olive::Track *t2 = CreateTrack(project_.get()); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(3)); - t2->AppendBlock(c); - AppendTrackToList(list, t2); - t2->SetLocked(true); + olive::Track *t2 = create_track(project_.get()); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(3)); + t2->append_block(c); + append_track_to_list(list, t2); + t2->set_locked(true); - olive::TrackListRippleRemoveAreaCommand cmd(list, olive::core::rational(2), - olive::core::rational(4)); + olive::TrackListRippleRemoveAreaCommand cmd(list, olive::core::Rational(2), + olive::core::Rational(4)); cmd.redo_now(); - EXPECT_EQ(b->length(), olive::core::rational(1)); + EXPECT_EQ(b->length(), olive::core::Rational(1)); // The locked track is untouched - EXPECT_EQ(c->length(), olive::core::rational(3)); - EXPECT_EQ(c->in(), olive::core::rational(0)); - EXPECT_EQ(c->out(), olive::core::rational(3)); + EXPECT_EQ(c->length(), olive::core::Rational(3)); + EXPECT_EQ(c->in(), olive::core::Rational(0)); + EXPECT_EQ(c->out(), olive::core::Rational(3)); cmd.undo_now(); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(c->length(), olive::core::rational(3)); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(c->length(), olive::core::Rational(3)); } TEST_F(TimelineUndoTest, TimelineRippleRemoveAreaAffectsAllTrackTypes) { - olive::Sequence *sequence = CreateSequence(project_.get()); + olive::Sequence *sequence = create_sequence(project_.get()); - olive::Track *video = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - video->AppendBlock(a); - video->AppendBlock(b); - AppendTrackToList(sequence->track_list(olive::Track::kVideo), video); + olive::Track *video = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + video->append_block(a); + video->append_block(b); + append_track_to_list(sequence->track_list(olive::Track::k_video), video); - olive::Track *audio = CreateTrack(project_.get()); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(3)); - audio->AppendBlock(c); - AppendTrackToList(sequence->track_list(olive::Track::kAudio), audio); + olive::Track *audio = create_track(project_.get()); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(3)); + audio->append_block(c); + append_track_to_list(sequence->track_list(olive::Track::k_audio), audio); // video: a [0,2], b [2,5] / audio: c [0,3] olive::TimelineRippleRemoveAreaCommand cmd(sequence, - olive::core::rational(1), - olive::core::rational(3)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::core::Rational(1), + olive::core::Rational(3)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(a->length(), olive::core::rational(1)); - EXPECT_EQ(b->length(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(1)); - EXPECT_EQ(b->out(), olive::core::rational(3)); - EXPECT_EQ(c->length(), olive::core::rational(1)); - EXPECT_EQ(c->out(), olive::core::rational(1)); + EXPECT_EQ(a->length(), olive::core::Rational(1)); + EXPECT_EQ(b->length(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(1)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); + EXPECT_EQ(c->length(), olive::core::Rational(1)); + EXPECT_EQ(c->out(), olive::core::Rational(1)); cmd.undo_now(); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(c->length(), olive::core::rational(3)); - EXPECT_EQ(c->out(), olive::core::rational(3)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(c->length(), olive::core::Rational(3)); + EXPECT_EQ(c->out(), olive::core::Rational(3)); } TEST_F(TimelineUndoTest, RippleToolCommandTrimsBlockAndRipples) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); + append_track_to_list(list, track); // Layout: a [0,2], b [2,5] QHash info; info.insert(track, { a, false }); - olive::TrackListRippleToolCommand cmd(list, info, olive::core::rational(1), - olive::Timeline::kTrimOut); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::TrackListRippleToolCommand cmd(list, info, olive::core::Rational(1), + olive::Timeline::k_trim_out); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); // a extends by one, pushing b later - EXPECT_EQ(a->length(), olive::core::rational(3)); - EXPECT_EQ(a->out(), olive::core::rational(3)); - EXPECT_EQ(b->in(), olive::core::rational(3)); - EXPECT_EQ(b->out(), olive::core::rational(6)); - EXPECT_EQ(track->track_length(), olive::core::rational(6)); + EXPECT_EQ(a->length(), olive::core::Rational(3)); + EXPECT_EQ(a->out(), olive::core::Rational(3)); + EXPECT_EQ(b->in(), olive::core::Rational(3)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); + EXPECT_EQ(track->track_length(), olive::core::Rational(6)); cmd.undo_now(); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(a->out(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); } TEST_F(TimelineUndoTest, RippleToolCommandAppendsGap) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); + append_track_to_list(list, track); // Layout: a [0,2], b [2,5] // Rather than resizing a block, a gap of the movement length is inserted QHash info; info.insert(track, { b, true }); - olive::TrackListRippleToolCommand cmd(list, info, olive::core::rational(1), - olive::Timeline::kTrimOut); + olive::TrackListRippleToolCommand cmd(list, info, olive::core::Rational(1), + olive::Timeline::k_trim_out); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - olive::Block *gap = track->Blocks().at(1); + ASSERT_EQ(track->blocks().size(), 3); + olive::Block *gap = track->blocks().at(1); EXPECT_NE(dynamic_cast(gap), nullptr); - EXPECT_EQ(gap->length(), olive::core::rational(1)); - EXPECT_EQ(gap->in(), olive::core::rational(2)); - EXPECT_EQ(gap->out(), olive::core::rational(3)); - EXPECT_EQ(b->in(), olive::core::rational(3)); - EXPECT_EQ(b->out(), olive::core::rational(6)); + EXPECT_EQ(gap->length(), olive::core::Rational(1)); + EXPECT_EQ(gap->in(), olive::core::Rational(2)); + EXPECT_EQ(gap->out(), olive::core::Rational(3)); + EXPECT_EQ(b->in(), olive::core::Rational(3)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(5)); } TEST_F(TimelineUndoTest, RippleToolCommandRemovesZeroLengthGap) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(g); - track->AppendBlock(b); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(a); + track->append_block(g); + track->append_block(b); + append_track_to_list(list, track); // Layout: a [0,2], gap [2,4], b [4,6] // Trimming the gap by its entire length removes it from the track and graph QHash info; info.insert(track, { g, false }); olive::TrackListRippleToolCommand cmd(list, info, - olive::core::rational(-2), - olive::Timeline::kTrimOut); + olive::core::Rational(-2), + olive::Timeline::k_trim_out); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(4)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(4)); EXPECT_EQ(g->track(), nullptr); EXPECT_EQ(g->project(), nullptr); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), g); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), g); EXPECT_EQ(g->project(), project_.get()); - EXPECT_EQ(g->in(), olive::core::rational(2)); - EXPECT_EQ(g->out(), olive::core::rational(4)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(6)); + EXPECT_EQ(g->in(), olive::core::Rational(2)); + EXPECT_EQ(g->out(), olive::core::Rational(4)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); } TEST_F(TimelineUndoTest, RippleDeleteGapsAtRegionsRemovesGap) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(g); - track->AppendBlock(b); - AppendTrackToList(sequence->track_list(olive::Track::kVideo), track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(a); + track->append_block(g); + track->append_block(b); + append_track_to_list(sequence->track_list(olive::Track::k_video), track); // Layout: a [0,2], gap [2,4], b [4,6] olive::TimelineRippleDeleteGapsAtRegionsCommand::RangeList regions; - regions.append({ track, olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(4)) }); + regions.append({ track, olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(4)) }); olive::TimelineRippleDeleteGapsAtRegionsCommand cmd(sequence, regions); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); // commands_ is populated by prepare(), which runs on the first redo cmd.redo_now(); - EXPECT_TRUE(cmd.HasCommands()); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(4)); + EXPECT_TRUE(cmd.has_commands()); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(4)); EXPECT_EQ(g->track(), nullptr); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), g); - EXPECT_EQ(g->in(), olive::core::rational(2)); - EXPECT_EQ(g->out(), olive::core::rational(4)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(6)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), g); + EXPECT_EQ(g->in(), olive::core::Rational(2)); + EXPECT_EQ(g->out(), olive::core::Rational(4)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); } TEST_F(TimelineUndoTest, RippleDeleteGapsAtRegionsIgnoresNonGapRegion) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); - AppendTrackToList(sequence->track_list(olive::Track::kVideo), track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(a); + append_track_to_list(sequence->track_list(olive::Track::k_video), track); // Layout: a [0,2] // The region covers a clip rather than a gap, so there is nothing to do olive::TimelineRippleDeleteGapsAtRegionsCommand::RangeList regions; - regions.append({ track, olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(2)) }); + regions.append({ track, olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(2)) }); olive::TimelineRippleDeleteGapsAtRegionsCommand cmd(sequence, regions); // prepare() finds no gap for the region, so no sub-commands are created cmd.redo_now(); - EXPECT_FALSE(cmd.HasCommands()); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(a->length(), olive::core::rational(2)); + EXPECT_FALSE(cmd.has_commands()); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(a->length(), olive::core::Rational(2)); cmd.undo_now(); - EXPECT_EQ(track->track_length(), olive::core::rational(2)); + EXPECT_EQ(track->track_length(), olive::core::Rational(2)); } // @@ -957,487 +957,487 @@ TEST_F(TimelineUndoTest, RippleDeleteGapsAtRegionsIgnoresNonGapRegion) // TEST_F(TimelineUndoTest, BlockTrimCommandTrimOutCreatesGap) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Layout: a [0,2], b [2,5] // Trimming a shorter with a clip adjacent creates a gap to fill the space - olive::BlockTrimCommand cmd(track, a, olive::core::rational(1), - olive::Timeline::kTrimOut); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::BlockTrimCommand cmd(track, a, olive::core::Rational(1), + olive::Timeline::k_trim_out); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(a->length(), olive::core::rational(1)); - EXPECT_EQ(a->out(), olive::core::rational(1)); - olive::Block *gap = track->Blocks().at(1); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(a->length(), olive::core::Rational(1)); + EXPECT_EQ(a->out(), olive::core::Rational(1)); + olive::Block *gap = track->blocks().at(1); EXPECT_NE(dynamic_cast(gap), nullptr); - EXPECT_EQ(gap->in(), olive::core::rational(1)); - EXPECT_EQ(gap->out(), olive::core::rational(2)); + EXPECT_EQ(gap->in(), olive::core::Rational(1)); + EXPECT_EQ(gap->out(), olive::core::Rational(2)); // b is unaffected - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(5)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(5)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(a->out(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); } TEST_F(TimelineUndoTest, BlockTrimCommandTrimOutIntoGap) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(g); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(a); + track->append_block(g); + track->append_block(b); // Layout: a [0,2], gap [2,4], b [4,6] // Trimming a longer consumes time from the adjacent gap - olive::BlockTrimCommand cmd(track, a, olive::core::rational(3), - olive::Timeline::kTrimOut); + olive::BlockTrimCommand cmd(track, a, olive::core::Rational(3), + olive::Timeline::k_trim_out); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(a->length(), olive::core::rational(3)); - EXPECT_EQ(a->out(), olive::core::rational(3)); - EXPECT_EQ(g->length(), olive::core::rational(1)); - EXPECT_EQ(g->in(), olive::core::rational(3)); - EXPECT_EQ(g->out(), olive::core::rational(4)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(6)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(a->length(), olive::core::Rational(3)); + EXPECT_EQ(a->out(), olive::core::Rational(3)); + EXPECT_EQ(g->length(), olive::core::Rational(1)); + EXPECT_EQ(g->in(), olive::core::Rational(3)); + EXPECT_EQ(g->out(), olive::core::Rational(4)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); cmd.undo_now(); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(a->out(), olive::core::rational(2)); - EXPECT_EQ(g->length(), olive::core::rational(2)); - EXPECT_EQ(g->in(), olive::core::rational(2)); - EXPECT_EQ(g->out(), olive::core::rational(4)); - EXPECT_EQ(b->in(), olive::core::rational(4)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); + EXPECT_EQ(g->length(), olive::core::Rational(2)); + EXPECT_EQ(g->in(), olive::core::Rational(2)); + EXPECT_EQ(g->out(), olive::core::Rational(4)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); } TEST_F(TimelineUndoTest, BlockTrimCommandTrimOutConsumesWholeGap) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(g); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(a); + track->append_block(g); + track->append_block(b); // Layout: a [0,2], gap [2,4], b [4,6] // Trimming a longer by the exact gap length removes the gap entirely - olive::BlockTrimCommand cmd(track, a, olive::core::rational(4), - olive::Timeline::kTrimOut); + olive::BlockTrimCommand cmd(track, a, olive::core::Rational(4), + olive::Timeline::k_trim_out); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(a->length(), olive::core::rational(4)); - EXPECT_EQ(a->out(), olive::core::rational(4)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(6)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(a->length(), olive::core::Rational(4)); + EXPECT_EQ(a->out(), olive::core::Rational(4)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); // By default the consumed gap is removed from the graph too EXPECT_EQ(g->track(), nullptr); EXPECT_EQ(g->project(), nullptr); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), g); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), g); EXPECT_EQ(g->project(), project_.get()); - EXPECT_EQ(g->length(), olive::core::rational(2)); - EXPECT_EQ(g->in(), olive::core::rational(2)); - EXPECT_EQ(g->out(), olive::core::rational(4)); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(4)); + EXPECT_EQ(g->length(), olive::core::Rational(2)); + EXPECT_EQ(g->in(), olive::core::Rational(2)); + EXPECT_EQ(g->out(), olive::core::Rational(4)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); } TEST_F(TimelineUndoTest, BlockTrimCommandConsumedGapCanStayInGraph) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::GapBlock *g = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(g); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::GapBlock *g = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(2)); + track->append_block(a); + track->append_block(g); + track->append_block(b); // Layout: a [0,2], gap [2,4], b [4,6] - olive::BlockTrimCommand cmd(track, a, olive::core::rational(4), - olive::Timeline::kTrimOut); - cmd.SetRemoveZeroLengthFromGraph(false); + olive::BlockTrimCommand cmd(track, a, olive::core::Rational(4), + olive::Timeline::k_trim_out); + cmd.set_remove_zero_length_from_graph(false); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); + ASSERT_EQ(track->blocks().size(), 2); // The gap is off the track but remains in the graph when asked to stay EXPECT_EQ(g->track(), nullptr); EXPECT_EQ(g->project(), project_.get()); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(1), g); - EXPECT_EQ(g->in(), olive::core::rational(2)); - EXPECT_EQ(g->out(), olive::core::rational(4)); - EXPECT_EQ(a->length(), olive::core::rational(2)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(1), g); + EXPECT_EQ(g->in(), olive::core::Rational(2)); + EXPECT_EQ(g->out(), olive::core::Rational(4)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); } TEST_F(TimelineUndoTest, BlockTrimCommandTrimInCreatesGap) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Layout: a [0,2], b [2,5] // Trimming b's in point shorter with a clip before it creates a gap - olive::BlockTrimCommand cmd(track, b, olive::core::rational(2), - olive::Timeline::kTrimIn); + olive::BlockTrimCommand cmd(track, b, olive::core::Rational(2), + olive::Timeline::k_trim_in); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(0), a); - olive::Block *gap = track->Blocks().at(1); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(0), a); + olive::Block *gap = track->blocks().at(1); EXPECT_NE(dynamic_cast(gap), nullptr); - EXPECT_EQ(gap->in(), olive::core::rational(2)); - EXPECT_EQ(gap->out(), olive::core::rational(3)); - EXPECT_EQ(b->length(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(3)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(b->media_in(), olive::core::rational(1)); + EXPECT_EQ(gap->in(), olive::core::Rational(2)); + EXPECT_EQ(gap->out(), olive::core::Rational(3)); + EXPECT_EQ(b->length(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(3)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(b->media_in(), olive::core::Rational(1)); // a is unaffected - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(2)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(b->media_in(), olive::core::rational(0)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(b->media_in(), olive::core::Rational(0)); } TEST_F(TimelineUndoTest, BlockTrimCommandTrimInRollEdit) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Layout: a [0,2], b [2,5] // A roll edit extends the adjacent clip instead of creating a gap - olive::BlockTrimCommand cmd(track, b, olive::core::rational(2), - olive::Timeline::kTrimIn); - cmd.SetTrimIsARollEdit(true); + olive::BlockTrimCommand cmd(track, b, olive::core::Rational(2), + olive::Timeline::k_trim_in); + cmd.set_trim_is_a_roll_edit(true); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(a->length(), olive::core::rational(3)); - EXPECT_EQ(a->out(), olive::core::rational(3)); - EXPECT_EQ(b->length(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(3)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(b->media_in(), olive::core::rational(1)); - EXPECT_EQ(track->track_length(), olive::core::rational(5)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(a->length(), olive::core::Rational(3)); + EXPECT_EQ(a->out(), olive::core::Rational(3)); + EXPECT_EQ(b->length(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(3)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(b->media_in(), olive::core::Rational(1)); + EXPECT_EQ(track->track_length(), olive::core::Rational(5)); cmd.undo_now(); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(a->out(), olive::core::rational(2)); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(b->media_in(), olive::core::rational(0)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(b->media_in(), olive::core::Rational(0)); } TEST_F(TimelineUndoTest, BlockTrimCommandTrimOutLastBlockHasNoAdjacent) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Layout: a [0,2], b [2,5] // Trimming the last block's out point shorter shortens the whole track - olive::BlockTrimCommand cmd(track, b, olive::core::rational(1), - olive::Timeline::kTrimOut); + olive::BlockTrimCommand cmd(track, b, olive::core::Rational(1), + olive::Timeline::k_trim_out); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(b->length(), olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(3)); - EXPECT_EQ(track->track_length(), olive::core::rational(3)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(b->length(), olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); + EXPECT_EQ(track->track_length(), olive::core::Rational(3)); cmd.undo_now(); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(5)); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(5)); } TEST_F(TimelineUndoTest, BlockTrimCommandSameLengthDoesNothing) { - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Trimming to the current length is a no-op - olive::BlockTrimCommand cmd(track, a, olive::core::rational(2), - olive::Timeline::kTrimOut); + olive::BlockTrimCommand cmd(track, a, olive::core::Rational(2), + olive::Timeline::k_trim_out); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); cmd.undo_now(); - EXPECT_EQ(a->length(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); + EXPECT_EQ(a->length(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); } TEST_F(TimelineUndoTest, TrackSlideCommandShiftsGaps) { - olive::Track *track = CreateTrack(project_.get()); - olive::GapBlock *g1 = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(3)); - olive::GapBlock *g2 = CreateGap(project_.get(), olive::core::rational(2)); - track->AppendBlock(g1); - track->AppendBlock(a); - track->AppendBlock(g2); + olive::Track *track = create_track(project_.get()); + olive::GapBlock *g1 = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(3)); + olive::GapBlock *g2 = create_gap(project_.get(), olive::core::Rational(2)); + track->append_block(g1); + track->append_block(a); + track->append_block(g2); // Layout: gap [0,2], a [2,5], gap [5,7] // Sliding a one frame later grows the leading gap and shrinks the trailing one olive::TrackSlideCommand cmd(track, { a }, g1, g2, - olive::core::rational(1)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::core::Rational(1)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - EXPECT_EQ(g1->length(), olive::core::rational(3)); - EXPECT_EQ(g1->out(), olive::core::rational(3)); - EXPECT_EQ(a->in(), olive::core::rational(3)); - EXPECT_EQ(a->out(), olive::core::rational(6)); - EXPECT_EQ(g2->length(), olive::core::rational(1)); - EXPECT_EQ(g2->in(), olive::core::rational(6)); - EXPECT_EQ(g2->out(), olive::core::rational(7)); - EXPECT_EQ(track->track_length(), olive::core::rational(7)); + EXPECT_EQ(g1->length(), olive::core::Rational(3)); + EXPECT_EQ(g1->out(), olive::core::Rational(3)); + EXPECT_EQ(a->in(), olive::core::Rational(3)); + EXPECT_EQ(a->out(), olive::core::Rational(6)); + EXPECT_EQ(g2->length(), olive::core::Rational(1)); + EXPECT_EQ(g2->in(), olive::core::Rational(6)); + EXPECT_EQ(g2->out(), olive::core::Rational(7)); + EXPECT_EQ(track->track_length(), olive::core::Rational(7)); cmd.undo_now(); - EXPECT_EQ(g1->length(), olive::core::rational(2)); - EXPECT_EQ(a->in(), olive::core::rational(2)); - EXPECT_EQ(a->out(), olive::core::rational(5)); - EXPECT_EQ(g2->length(), olive::core::rational(2)); - EXPECT_EQ(g2->in(), olive::core::rational(5)); - EXPECT_EQ(g2->out(), olive::core::rational(7)); + EXPECT_EQ(g1->length(), olive::core::Rational(2)); + EXPECT_EQ(a->in(), olive::core::Rational(2)); + EXPECT_EQ(a->out(), olive::core::Rational(5)); + EXPECT_EQ(g2->length(), olive::core::Rational(2)); + EXPECT_EQ(g2->in(), olive::core::Rational(5)); + EXPECT_EQ(g2->out(), olive::core::Rational(7)); } TEST_F(TimelineUndoTest, TrackSlideCommandRemovesOutAdjacent) { - olive::Track *track = CreateTrack(project_.get()); - olive::GapBlock *g1 = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(3)); - olive::GapBlock *g2 = CreateGap(project_.get(), olive::core::rational(2)); - track->AppendBlock(g1); - track->AppendBlock(a); - track->AppendBlock(g2); + olive::Track *track = create_track(project_.get()); + olive::GapBlock *g1 = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(3)); + olive::GapBlock *g2 = create_gap(project_.get(), olive::core::Rational(2)); + track->append_block(g1); + track->append_block(a); + track->append_block(g2); // Layout: gap [0,2], a [2,5], gap [5,7] // Sliding right by the trailing gap's length consumes it olive::TrackSlideCommand cmd(track, { a }, g1, g2, - olive::core::rational(2)); + olive::core::Rational(2)); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), g1); - EXPECT_EQ(track->Blocks().at(1), a); - EXPECT_EQ(g1->length(), olive::core::rational(4)); - EXPECT_EQ(g1->out(), olive::core::rational(4)); - EXPECT_EQ(a->in(), olive::core::rational(4)); - EXPECT_EQ(a->out(), olive::core::rational(7)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), g1); + EXPECT_EQ(track->blocks().at(1), a); + EXPECT_EQ(g1->length(), olive::core::Rational(4)); + EXPECT_EQ(g1->out(), olive::core::Rational(4)); + EXPECT_EQ(a->in(), olive::core::Rational(4)); + EXPECT_EQ(a->out(), olive::core::Rational(7)); EXPECT_EQ(g2->track(), nullptr); EXPECT_EQ(g2->project(), nullptr); - EXPECT_EQ(track->track_length(), olive::core::rational(7)); + EXPECT_EQ(track->track_length(), olive::core::Rational(7)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(0), g1); - EXPECT_EQ(track->Blocks().at(1), a); - EXPECT_EQ(track->Blocks().at(2), g2); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(0), g1); + EXPECT_EQ(track->blocks().at(1), a); + EXPECT_EQ(track->blocks().at(2), g2); EXPECT_EQ(g2->project(), project_.get()); - EXPECT_EQ(g1->length(), olive::core::rational(2)); - EXPECT_EQ(g1->out(), olive::core::rational(2)); - EXPECT_EQ(a->in(), olive::core::rational(2)); - EXPECT_EQ(a->out(), olive::core::rational(5)); - EXPECT_EQ(g2->in(), olive::core::rational(5)); - EXPECT_EQ(g2->out(), olive::core::rational(7)); + EXPECT_EQ(g1->length(), olive::core::Rational(2)); + EXPECT_EQ(g1->out(), olive::core::Rational(2)); + EXPECT_EQ(a->in(), olive::core::Rational(2)); + EXPECT_EQ(a->out(), olive::core::Rational(5)); + EXPECT_EQ(g2->in(), olive::core::Rational(5)); + EXPECT_EQ(g2->out(), olive::core::Rational(7)); } TEST_F(TimelineUndoTest, TrackSlideCommandRemovesInAdjacent) { - olive::Track *track = CreateTrack(project_.get()); - olive::GapBlock *g1 = CreateGap(project_.get(), olive::core::rational(2)); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(3)); - olive::GapBlock *g2 = CreateGap(project_.get(), olive::core::rational(2)); - track->AppendBlock(g1); - track->AppendBlock(a); - track->AppendBlock(g2); + olive::Track *track = create_track(project_.get()); + olive::GapBlock *g1 = create_gap(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(3)); + olive::GapBlock *g2 = create_gap(project_.get(), olive::core::Rational(2)); + track->append_block(g1); + track->append_block(a); + track->append_block(g2); // Layout: gap [0,2], a [2,5], gap [5,7] // Sliding left by the leading gap's length consumes it olive::TrackSlideCommand cmd(track, { a }, g1, g2, - olive::core::rational(-2)); + olive::core::Rational(-2)); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), g2); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(3)); - EXPECT_EQ(g2->length(), olive::core::rational(4)); - EXPECT_EQ(g2->in(), olive::core::rational(3)); - EXPECT_EQ(g2->out(), olive::core::rational(7)); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), g2); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(3)); + EXPECT_EQ(g2->length(), olive::core::Rational(4)); + EXPECT_EQ(g2->in(), olive::core::Rational(3)); + EXPECT_EQ(g2->out(), olive::core::Rational(7)); EXPECT_EQ(g1->track(), nullptr); EXPECT_EQ(g1->project(), nullptr); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(0), g1); - EXPECT_EQ(track->Blocks().at(1), a); - EXPECT_EQ(track->Blocks().at(2), g2); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(0), g1); + EXPECT_EQ(track->blocks().at(1), a); + EXPECT_EQ(track->blocks().at(2), g2); EXPECT_EQ(g1->project(), project_.get()); - EXPECT_EQ(g1->in(), olive::core::rational(0)); - EXPECT_EQ(g1->out(), olive::core::rational(2)); - EXPECT_EQ(a->in(), olive::core::rational(2)); - EXPECT_EQ(a->out(), olive::core::rational(5)); - EXPECT_EQ(g2->length(), olive::core::rational(2)); - EXPECT_EQ(g2->in(), olive::core::rational(5)); - EXPECT_EQ(g2->out(), olive::core::rational(7)); + EXPECT_EQ(g1->in(), olive::core::Rational(0)); + EXPECT_EQ(g1->out(), olive::core::Rational(2)); + EXPECT_EQ(a->in(), olive::core::Rational(2)); + EXPECT_EQ(a->out(), olive::core::Rational(5)); + EXPECT_EQ(g2->length(), olive::core::Rational(2)); + EXPECT_EQ(g2->in(), olive::core::Rational(5)); + EXPECT_EQ(g2->out(), olive::core::Rational(7)); } TEST_F(TimelineUndoTest, TrackPlaceBlockCommandAppendsToEmptyTrack) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + append_track_to_list(list, track); - olive::ClipBlock *p = CreateClip(project_.get(), olive::core::rational(2)); - olive::TrackPlaceBlockCommand cmd(list, 0, p, olive::core::rational(0)); - EXPECT_EQ(cmd.GetRelevantProject(), project_.get()); + olive::ClipBlock *p = create_clip(project_.get(), olive::core::Rational(2)); + olive::TrackPlaceBlockCommand cmd(list, 0, p, olive::core::Rational(0)); + EXPECT_EQ(cmd.get_relevant_project(), project_.get()); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(track->Blocks().at(0), p); - EXPECT_EQ(p->in(), olive::core::rational(0)); - EXPECT_EQ(p->out(), olive::core::rational(2)); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(track->blocks().at(0), p); + EXPECT_EQ(p->in(), olive::core::Rational(0)); + EXPECT_EQ(p->out(), olive::core::Rational(2)); cmd.undo_now(); - EXPECT_TRUE(track->Blocks().isEmpty()); + EXPECT_TRUE(track->blocks().isEmpty()); EXPECT_EQ(p->track(), nullptr); } TEST_F(TimelineUndoTest, TrackPlaceBlockCommandInsertsGapToReachPoint) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + append_track_to_list(list, track); // Placing past the end of the track pads with a gap - olive::ClipBlock *p = CreateClip(project_.get(), olive::core::rational(2)); - olive::TrackPlaceBlockCommand cmd(list, 0, p, olive::core::rational(3)); + olive::ClipBlock *p = create_clip(project_.get(), olive::core::Rational(2)); + olive::TrackPlaceBlockCommand cmd(list, 0, p, olive::core::Rational(3)); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 2); - olive::Block *gap = track->Blocks().at(0); + ASSERT_EQ(track->blocks().size(), 2); + olive::Block *gap = track->blocks().at(0); EXPECT_NE(dynamic_cast(gap), nullptr); - EXPECT_EQ(gap->in(), olive::core::rational(0)); - EXPECT_EQ(gap->out(), olive::core::rational(3)); - EXPECT_EQ(track->Blocks().at(1), p); - EXPECT_EQ(p->in(), olive::core::rational(3)); - EXPECT_EQ(p->out(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(5)); + EXPECT_EQ(gap->in(), olive::core::Rational(0)); + EXPECT_EQ(gap->out(), olive::core::Rational(3)); + EXPECT_EQ(track->blocks().at(1), p); + EXPECT_EQ(p->in(), olive::core::Rational(3)); + EXPECT_EQ(p->out(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(5)); cmd.undo_now(); - EXPECT_TRUE(track->Blocks().isEmpty()); - EXPECT_EQ(track->track_length(), olive::core::rational(0)); + EXPECT_TRUE(track->blocks().isEmpty()); + EXPECT_EQ(track->track_length(), olive::core::Rational(0)); } TEST_F(TimelineUndoTest, TrackPlaceBlockCommandOverwritesMiddle) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - olive::Track *track = CreateTrack(project_.get()); - olive::ClipBlock *a = CreateClip(project_.get(), olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(project_.get(), olive::core::rational(3)); - olive::ClipBlock *c = CreateClip(project_.get(), olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); - AppendTrackToList(list, track); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + olive::Track *track = create_track(project_.get()); + olive::ClipBlock *a = create_clip(project_.get(), olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(project_.get(), olive::core::Rational(3)); + olive::ClipBlock *c = create_clip(project_.get(), olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); + append_track_to_list(list, track); // Layout: a [0,2], b [2,5], c [5,6] // Placing a two-second block at 2 trims b's head to make room - olive::ClipBlock *p = CreateClip(project_.get(), olive::core::rational(2)); - olive::TrackPlaceBlockCommand cmd(list, 0, p, olive::core::rational(2)); + olive::ClipBlock *p = create_clip(project_.get(), olive::core::Rational(2)); + olive::TrackPlaceBlockCommand cmd(list, 0, p, olive::core::Rational(2)); cmd.redo_now(); - ASSERT_EQ(track->Blocks().size(), 4); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), p); - EXPECT_EQ(p->in(), olive::core::rational(2)); - EXPECT_EQ(p->out(), olive::core::rational(4)); - EXPECT_EQ(track->Blocks().at(2), b); - EXPECT_EQ(b->length(), olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(4)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(track->Blocks().at(3), c); - EXPECT_EQ(c->in(), olive::core::rational(5)); - EXPECT_EQ(c->out(), olive::core::rational(6)); + ASSERT_EQ(track->blocks().size(), 4); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), p); + EXPECT_EQ(p->in(), olive::core::Rational(2)); + EXPECT_EQ(p->out(), olive::core::Rational(4)); + EXPECT_EQ(track->blocks().at(2), b); + EXPECT_EQ(b->length(), olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(4)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(track->blocks().at(3), c); + EXPECT_EQ(c->in(), olive::core::Rational(5)); + EXPECT_EQ(c->out(), olive::core::Rational(6)); cmd.undo_now(); - ASSERT_EQ(track->Blocks().size(), 3); + ASSERT_EQ(track->blocks().size(), 3); EXPECT_EQ(p->track(), nullptr); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(b->length(), olive::core::rational(3)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(c->in(), olive::core::rational(5)); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(b->length(), olive::core::Rational(3)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(c->in(), olive::core::Rational(5)); } TEST_F(TimelineUndoTest, TrackPlaceBlockCommandAddsMissingTracks) { - olive::Sequence *sequence = CreateSequence(project_.get()); - olive::TrackList *list = sequence->track_list(olive::Track::kVideo); - ASSERT_EQ(list->GetTrackCount(), 0); + olive::Sequence *sequence = create_sequence(project_.get()); + olive::TrackList *list = sequence->track_list(olive::Track::k_video); + ASSERT_EQ(list->get_track_count(), 0); // Placing on track index 1 of an empty list creates both tracks - olive::ClipBlock *p = CreateClip(project_.get(), olive::core::rational(2)); - olive::TrackPlaceBlockCommand cmd(list, 1, p, olive::core::rational(0)); + olive::ClipBlock *p = create_clip(project_.get(), olive::core::Rational(2)); + olive::TrackPlaceBlockCommand cmd(list, 1, p, olive::core::Rational(0)); cmd.redo_now(); - ASSERT_EQ(list->GetTrackCount(), 2); - olive::Track *placed_track = list->GetTrackAt(1); + ASSERT_EQ(list->get_track_count(), 2); + olive::Track *placed_track = list->get_track_at(1); ASSERT_NE(placed_track, nullptr); - ASSERT_EQ(placed_track->Blocks().size(), 1); - EXPECT_EQ(placed_track->Blocks().at(0), p); - EXPECT_EQ(p->in(), olive::core::rational(0)); - EXPECT_EQ(p->out(), olive::core::rational(2)); + ASSERT_EQ(placed_track->blocks().size(), 1); + EXPECT_EQ(placed_track->blocks().at(0), p); + EXPECT_EQ(p->in(), olive::core::Rational(0)); + EXPECT_EQ(p->out(), olive::core::Rational(2)); cmd.undo_now(); EXPECT_EQ(p->track(), nullptr); - EXPECT_EQ(list->GetTrackCount(), 0); + EXPECT_EQ(list->get_track_count(), 0); } diff --git a/tests/gtest/timeline_waveform_sync_test.cpp b/tests/gtest/timeline_waveform_sync_test.cpp index b282b2e54..5b88cab3b 100644 --- a/tests/gtest/timeline_waveform_sync_test.cpp +++ b/tests/gtest/timeline_waveform_sync_test.cpp @@ -23,15 +23,15 @@ using namespace olive::core; namespace { -AudioParams MakeMonoParams(int sample_rate) +AudioParams make_mono_params(int sample_rate) { - return AudioParams(sample_rate, static_cast(kChannelLayoutMono), - SampleFormat::F32P); + return AudioParams(sample_rate, static_cast(k_channel_layout_mono), + SampleFormat::f32_p); } -SampleBuffer MakeMonoBuffer(int sample_rate, float value, int seconds) +SampleBuffer make_mono_buffer(int sample_rate, float value, int seconds) { - SampleBuffer buf(MakeMonoParams(sample_rate), + SampleBuffer buf(make_mono_params(sample_rate), static_cast(sample_rate * seconds)); float *data = buf.data(0); for (size_t i = 0; i < buf.sample_count(); i++) { @@ -40,19 +40,19 @@ SampleBuffer MakeMonoBuffer(int sample_rate, float value, int seconds) return buf; } -void WritePartialWaveform(AudioWaveformCache *cache, int sample_rate) +void write_partial_waveform(AudioWaveformCache *cache, int sample_rate) { - const AudioParams params = MakeMonoParams(sample_rate); - cache->SetParameters(params); + const AudioParams params = make_mono_params(sample_rate); + cache->set_parameters(params); // Fill seconds [1,2) with a loud constant signal. AudioVisualWaveform waveform; waveform.set_channel_count(1); - SampleBuffer buf = MakeMonoBuffer(sample_rate, 1.0f, 1); - waveform.OverwriteSamples(buf, sample_rate, rational(1)); + SampleBuffer buf = make_mono_buffer(sample_rate, 1.0f, 1); + waveform.overwrite_samples(buf, sample_rate, Rational(1)); // Tell the cache that only the middle second is valid in a 3-second clip. - cache->WriteWaveform(TimeRange(1, 2), TimeRangeList({ TimeRange(1, 2) }), + cache->write_waveform(TimeRange(1, 2), TimeRangeList({ TimeRange(1, 2) }), &waveform); } @@ -60,20 +60,20 @@ void WritePartialWaveform(AudioWaveformCache *cache, int sample_rate) TEST(TimelineWaveformSync, ExtractEnvelopeUsesOnlyValidatedRanges) { - constexpr int kSampleRate = 48000; - constexpr size_t kWindowSamples = kSampleRate / 20; // 50 ms windows + constexpr int k_sample_rate = 48000; + constexpr size_t k_window_samples = k_sample_rate / 20; // 50 ms windows AudioWaveformCache cache; - WritePartialWaveform(&cache, kSampleRate); + write_partial_waveform(&cache, k_sample_rate); WaveformSyncClip clip; clip.waveform = &cache; clip.media_range = TimeRange(0, 3); - clip.sample_rate = kSampleRate; + clip.sample_rate = k_sample_rate; const QVector envelope = - TimelineWaveformSync::ExtractWaveformCacheEnvelope(clip, kSampleRate, - kWindowSamples); + timeline_waveform_sync::extract_waveform_cache_envelope(clip, k_sample_rate, + k_window_samples); // 3 seconds at 20 windows per second == 60 windows. EXPECT_EQ(envelope.size(), 60); @@ -97,21 +97,21 @@ TEST(TimelineWaveformSync, ExtractEnvelopeUsesOnlyValidatedRanges) TEST(TimelineWaveformSync, ExtractEnvelopeReportsValidityMask) { - constexpr int kSampleRate = 48000; - constexpr size_t kWindowSamples = kSampleRate / 20; // 50 ms windows + constexpr int k_sample_rate = 48000; + constexpr size_t k_window_samples = k_sample_rate / 20; // 50 ms windows AudioWaveformCache cache; - WritePartialWaveform(&cache, kSampleRate); + write_partial_waveform(&cache, k_sample_rate); WaveformSyncClip clip; clip.waveform = &cache; clip.media_range = TimeRange(0, 3); - clip.sample_rate = kSampleRate; + clip.sample_rate = k_sample_rate; QVector valid_mask; const QVector envelope = - TimelineWaveformSync::ExtractWaveformCacheEnvelope( - clip, kSampleRate, kWindowSamples, &valid_mask); + timeline_waveform_sync::extract_waveform_cache_envelope( + clip, k_sample_rate, k_window_samples, &valid_mask); // One flag per envelope window ASSERT_EQ(valid_mask.size(), envelope.size()); @@ -127,41 +127,41 @@ TEST(TimelineWaveformSync, ExtractEnvelopeReportsValidityMask) TEST(TimelineWaveformSync, PartialCacheIsConsideredReady) { - constexpr int kSampleRate = 48000; + constexpr int k_sample_rate = 48000; Footage footage; - footage.SetValid(); + footage.set_valid(); AudioWaveformCache *cache = footage.waveform_cache(); - WritePartialWaveform(cache, kSampleRate); + write_partial_waveform(cache, k_sample_rate); ClipBlock clip; - clip.set_length_and_media_out(rational(3)); - clip.set_media_in(rational(0)); + clip.set_length_and_media_out(Rational(3)); + clip.set_media_in(Rational(0)); - Node::ConnectEdge(&footage, NodeInput(&clip, ClipBlock::kBufferIn)); + Node::connect_edge(&footage, NodeInput(&clip, ClipBlock::k_buffer_in)); WaveformSyncClip out; - EXPECT_TRUE(TimelineWaveformSync::GetWaveformSyncClip(&clip, &out)); + EXPECT_TRUE(timeline_waveform_sync::get_waveform_sync_clip(&clip, &out)); EXPECT_EQ(out.waveform, cache); - EXPECT_EQ(out.sample_rate, kSampleRate); + EXPECT_EQ(out.sample_rate, k_sample_rate); EXPECT_EQ(out.media_range, TimeRange(0, 3)); } TEST(TimelineWaveformSync, EmptyCacheIsNotReady) { Footage footage; - footage.SetValid(); + footage.set_valid(); - AudioParams params = MakeMonoParams(48000); - footage.waveform_cache()->SetParameters(params); + AudioParams params = make_mono_params(48000); + footage.waveform_cache()->set_parameters(params); ClipBlock clip; - clip.set_length_and_media_out(rational(3)); - clip.set_media_in(rational(0)); + clip.set_length_and_media_out(Rational(3)); + clip.set_media_in(Rational(0)); - Node::ConnectEdge(&footage, NodeInput(&clip, ClipBlock::kBufferIn)); + Node::connect_edge(&footage, NodeInput(&clip, ClipBlock::k_buffer_in)); WaveformSyncClip out; - EXPECT_FALSE(TimelineWaveformSync::GetWaveformSyncClip(&clip, &out)); + EXPECT_FALSE(timeline_waveform_sync::get_waveform_sync_clip(&clip, &out)); } diff --git a/tests/gtest/timeline_workarea_test.cpp b/tests/gtest/timeline_workarea_test.cpp index 8c1a8df99..ca286fd9a 100644 --- a/tests/gtest/timeline_workarea_test.cpp +++ b/tests/gtest/timeline_workarea_test.cpp @@ -11,8 +11,8 @@ TEST(TimelineWorkArea, DefaultsAndSetters) olive::TimelineWorkArea workarea; EXPECT_FALSE(workarea.enabled()); - olive::core::TimeRange range(olive::core::rational(5, 1), - olive::core::rational(10, 1)); + olive::core::TimeRange range(olive::core::Rational(5, 1), + olive::core::Rational(10, 1)); workarea.set_enabled(true); workarea.set_range(range); @@ -27,8 +27,8 @@ TEST(TimelineWorkArea, SaveLoadRoundTrip) { olive::TimelineWorkArea workarea; workarea.set_enabled(true); - workarea.set_range(olive::core::TimeRange(olive::core::rational(2, 1), - olive::core::rational(6, 1))); + workarea.set_range(olive::core::TimeRange(olive::core::Rational(2, 1), + olive::core::Rational(6, 1))); QByteArray xml; QBuffer buffer(&xml); @@ -50,16 +50,16 @@ TEST(TimelineWorkArea, SaveLoadRoundTrip) EXPECT_TRUE(loaded.enabled()); EXPECT_EQ(loaded.range(), - olive::core::TimeRange(olive::core::rational(2, 1), - olive::core::rational(6, 1))); + olive::core::TimeRange(olive::core::Rational(2, 1), + olive::core::Rational(6, 1))); } TEST(TimelineWorkArea, DisabledWorkAreaRoundTrip) { olive::TimelineWorkArea workarea; workarea.set_enabled(false); - workarea.set_range(olive::core::TimeRange(olive::core::rational(0, 1), - olive::core::rational(10, 1))); + workarea.set_range(olive::core::TimeRange(olive::core::Rational(0, 1), + olive::core::Rational(10, 1))); QByteArray xml; QBuffer buffer(&xml); @@ -81,17 +81,17 @@ TEST(TimelineWorkArea, DisabledWorkAreaRoundTrip) EXPECT_FALSE(loaded.enabled()); EXPECT_EQ(loaded.range(), - olive::core::TimeRange(olive::core::rational(0, 1), - olive::core::rational(10, 1))); + olive::core::TimeRange(olive::core::Rational(0, 1), + olive::core::Rational(10, 1))); } TEST(TimelineWorkArea, SetRangeUpdatesInOut) { olive::TimelineWorkArea workarea; - workarea.set_range(olive::core::TimeRange(olive::core::rational(3, 1), - olive::core::rational(8, 1))); + workarea.set_range(olive::core::TimeRange(olive::core::Rational(3, 1), + olive::core::Rational(8, 1))); - EXPECT_EQ(workarea.in(), olive::core::rational(3, 1)); - EXPECT_EQ(workarea.out(), olive::core::rational(8, 1)); - EXPECT_EQ(workarea.length(), olive::core::rational(5, 1)); + EXPECT_EQ(workarea.in(), olive::core::Rational(3, 1)); + EXPECT_EQ(workarea.out(), olive::core::Rational(8, 1)); + EXPECT_EQ(workarea.length(), olive::core::Rational(5, 1)); } diff --git a/tests/gtest/track_test.cpp b/tests/gtest/track_test.cpp index 6a957065c..4b176edc4 100644 --- a/tests/gtest/track_test.cpp +++ b/tests/gtest/track_test.cpp @@ -22,8 +22,8 @@ namespace { -olive::Track *CreateTrack(olive::Project *project, - olive::Track::Type type = olive::Track::kVideo) +olive::Track *create_track(olive::Project *project, + olive::Track::Type type = olive::Track::k_video) { auto *track = new olive::Track(); track->setParent(project); @@ -31,8 +31,8 @@ olive::Track *CreateTrack(olive::Project *project, return track; } -olive::ClipBlock *CreateClip(olive::Project *project, - const olive::core::rational &length) +olive::ClipBlock *create_clip(olive::Project *project, + const olive::core::Rational &length) { auto *clip = new olive::ClipBlock(); clip->setParent(project); @@ -40,8 +40,8 @@ olive::ClipBlock *CreateClip(olive::Project *project, return clip; } -olive::GapBlock *CreateGap(olive::Project *project, - const olive::core::rational &length) +olive::GapBlock *create_gap(olive::Project *project, + const olive::core::Rational &length) { auto *gap = new olive::GapBlock(); gap->setParent(project); @@ -49,7 +49,7 @@ olive::GapBlock *CreateGap(olive::Project *project, return gap; } -float SumOfAbsoluteSamples(const olive::core::SampleBuffer &buffer) +float sum_of_absolute_samples(const olive::core::SampleBuffer &buffer) { float sum = 0.0f; for (int ch = 0; ch < buffer.channel_count(); ++ch) { @@ -67,37 +67,37 @@ TEST(Track, DefaultState) { olive::Track track; - EXPECT_EQ(track.type(), olive::Track::kNone); - EXPECT_EQ(track.Index(), -1); - EXPECT_TRUE(track.Blocks().isEmpty()); - EXPECT_EQ(track.track_length(), olive::core::rational(0)); - EXPECT_FALSE(track.IsMuted()); - EXPECT_FALSE(track.IsLocked()); - EXPECT_DOUBLE_EQ(track.GetTrackHeight(), olive::Track::kTrackHeightDefault); + EXPECT_EQ(track.type(), olive::Track::k_none); + EXPECT_EQ(track.index(), -1); + EXPECT_TRUE(track.blocks().isEmpty()); + EXPECT_EQ(track.track_length(), olive::core::Rational(0)); + EXPECT_FALSE(track.is_muted()); + EXPECT_FALSE(track.is_locked()); + EXPECT_DOUBLE_EQ(track.get_track_height(), olive::Track::k_track_height_default); EXPECT_EQ(track.sequence(), nullptr); - EXPECT_EQ(track.Name(), QStringLiteral("Track")); + EXPECT_EQ(track.name(), QStringLiteral("Track")); EXPECT_EQ(track.id(), QStringLiteral("org.olivevideoeditor.Olive.track")); - EXPECT_TRUE(track.Category().contains(olive::Node::kCategoryTimeline)); + EXPECT_TRUE(track.category().contains(olive::Node::k_category_timeline)); } TEST(Track, NameReflectsTypeAndIndex) { olive::Track track; - track.set_type(olive::Track::kVideo); - track.SetIndex(2); - EXPECT_EQ(track.Name(), QStringLiteral("Video Track 2")); + track.set_type(olive::Track::k_video); + track.set_index(2); + EXPECT_EQ(track.name(), QStringLiteral("Video Track 2")); - track.set_type(olive::Track::kAudio); - track.SetIndex(0); - EXPECT_EQ(track.Name(), QStringLiteral("Audio Track 0")); + track.set_type(olive::Track::k_audio); + track.set_index(0); + EXPECT_EQ(track.name(), QStringLiteral("Audio Track 0")); - track.set_type(olive::Track::kSubtitle); - track.SetIndex(1); - EXPECT_EQ(track.Name(), QStringLiteral("Subtitle Track 1")); + track.set_type(olive::Track::k_subtitle); + track.set_index(1); + EXPECT_EQ(track.name(), QStringLiteral("Subtitle Track 1")); - track.set_type(olive::Track::kNone); - EXPECT_EQ(track.Name(), QStringLiteral("Track")); + track.set_type(olive::Track::k_none); + EXPECT_EQ(track.name(), QStringLiteral("Track")); } TEST(Track, SetIndexEmitsIndexChanged) @@ -107,16 +107,16 @@ TEST(Track, SetIndexEmitsIndexChanged) int emissions = 0; int old_index = 0; int new_index = 0; - QObject::connect(&track, &olive::Track::IndexChanged, + QObject::connect(&track, &olive::Track::index_changed, [&emissions, &old_index, &new_index](int old_i, int now_i) { ++emissions; old_index = old_i; new_index = now_i; }); - track.SetIndex(3); + track.set_index(3); - EXPECT_EQ(track.Index(), 3); + EXPECT_EQ(track.index(), 3); EXPECT_EQ(emissions, 1); EXPECT_EQ(old_index, -1); EXPECT_EQ(new_index, 3); @@ -128,27 +128,27 @@ TEST(Track, MuteAndLockToggle) int emissions = 0; bool last_muted = false; - QObject::connect(&track, &olive::Track::MutedChanged, + QObject::connect(&track, &olive::Track::muted_changed, [&emissions, &last_muted](bool e) { ++emissions; last_muted = e; }); - track.SetMuted(true); - EXPECT_TRUE(track.IsMuted()); + track.set_muted(true); + EXPECT_TRUE(track.is_muted()); EXPECT_EQ(emissions, 1); EXPECT_TRUE(last_muted); - track.SetMuted(false); - EXPECT_FALSE(track.IsMuted()); + track.set_muted(false); + EXPECT_FALSE(track.is_muted()); EXPECT_EQ(emissions, 2); EXPECT_FALSE(last_muted); - EXPECT_FALSE(track.IsLocked()); - track.SetLocked(true); - EXPECT_TRUE(track.IsLocked()); - track.SetLocked(false); - EXPECT_FALSE(track.IsLocked()); + EXPECT_FALSE(track.is_locked()); + track.set_locked(true); + EXPECT_TRUE(track.is_locked()); + track.set_locked(false); + EXPECT_FALSE(track.is_locked()); } TEST(Track, TrackHeightAccessors) @@ -157,46 +157,46 @@ TEST(Track, TrackHeightAccessors) int emissions = 0; qreal last_height = 0.0; - QObject::connect(&track, &olive::Track::TrackHeightChanged, + QObject::connect(&track, &olive::Track::track_height_changed, [&emissions, &last_height](qreal h) { ++emissions; last_height = h; }); - track.SetTrackHeight(2.5); - EXPECT_DOUBLE_EQ(track.GetTrackHeight(), 2.5); + track.set_track_height(2.5); + EXPECT_DOUBLE_EQ(track.get_track_height(), 2.5); EXPECT_EQ(emissions, 1); EXPECT_DOUBLE_EQ(last_height, 2.5); - EXPECT_DOUBLE_EQ(olive::Track::kTrackHeightDefault, 3.0); - EXPECT_DOUBLE_EQ(olive::Track::kTrackHeightMinimum, 1.5); - EXPECT_DOUBLE_EQ(olive::Track::kTrackHeightInterval, 0.5); - EXPECT_LT(olive::Track::GetMinimumTrackHeightInPixels(), - olive::Track::GetDefaultTrackHeightInPixels()); + EXPECT_DOUBLE_EQ(olive::Track::k_track_height_default, 3.0); + EXPECT_DOUBLE_EQ(olive::Track::k_track_height_minimum, 1.5); + EXPECT_DOUBLE_EQ(olive::Track::k_track_height_interval, 0.5); + EXPECT_LT(olive::Track::get_minimum_track_height_in_pixels(), + olive::Track::get_default_track_height_in_pixels()); } TEST(Track, TrackHeightPixelRoundTrip) { olive::Track track; - track.SetTrackHeightInPixels(77); - EXPECT_EQ(track.GetTrackHeightInPixels(), 77); + track.set_track_height_in_pixels(77); + EXPECT_EQ(track.get_track_height_in_pixels(), 77); olive::Track default_track; - EXPECT_EQ(default_track.GetTrackHeightInPixels(), - olive::Track::GetDefaultTrackHeightInPixels()); + EXPECT_EQ(default_track.get_track_height_in_pixels(), + olive::Track::get_default_track_height_in_pixels()); } TEST(Track, HeightSaveLoadRoundTrip) { olive::Track track; - track.SetTrackHeight(1.75); + track.set_track_height(1.75); QString xml; QXmlStreamWriter writer(&xml); writer.writeStartDocument(); writer.writeStartElement(QStringLiteral("custom")); - track.SaveCustom(&writer); + track.save_custom(&writer); writer.writeEndElement(); writer.writeEndDocument(); @@ -207,68 +207,68 @@ TEST(Track, HeightSaveLoadRoundTrip) ASSERT_EQ(reader.name(), QStringLiteral("custom")); olive::Track loaded; - ASSERT_TRUE(loaded.LoadCustom(&reader, nullptr)); - EXPECT_DOUBLE_EQ(loaded.GetTrackHeight(), 1.75); + ASSERT_TRUE(loaded.load_custom(&reader, nullptr)); + EXPECT_DOUBLE_EQ(loaded.get_track_height(), 1.75); } TEST(Track, ReferenceStringsRoundTrip) { - const olive::Track::Reference video(olive::Track::kVideo, 2); - EXPECT_EQ(video.ToString(), QStringLiteral("v:2")); - EXPECT_TRUE(video.IsValid()); - EXPECT_EQ(olive::Track::Reference::FromString(QStringLiteral("v:2")), video); + const olive::Track::Reference video(olive::Track::k_video, 2); + EXPECT_EQ(video.to_string(), QStringLiteral("v:2")); + EXPECT_TRUE(video.is_valid()); + EXPECT_EQ(olive::Track::Reference::from_string(QStringLiteral("v:2")), video); - const olive::Track::Reference audio(olive::Track::kAudio, 10); - EXPECT_EQ(audio.ToString(), QStringLiteral("a:10")); - EXPECT_EQ(olive::Track::Reference::FromString(QStringLiteral("a:10")), + const olive::Track::Reference audio(olive::Track::k_audio, 10); + EXPECT_EQ(audio.to_string(), QStringLiteral("a:10")); + EXPECT_EQ(olive::Track::Reference::from_string(QStringLiteral("a:10")), audio); - const olive::Track::Reference subtitle(olive::Track::kSubtitle, 0); - EXPECT_EQ(subtitle.ToString(), QStringLiteral("s:0")); - EXPECT_EQ(olive::Track::Reference::FromString(QStringLiteral("s:0")), + const olive::Track::Reference subtitle(olive::Track::k_subtitle, 0); + EXPECT_EQ(subtitle.to_string(), QStringLiteral("s:0")); + EXPECT_EQ(olive::Track::Reference::from_string(QStringLiteral("s:0")), subtitle); - EXPECT_EQ(olive::Track::Reference::TypeFromString(QStringLiteral("v:2")), - olive::Track::kVideo); - EXPECT_EQ(olive::Track::Reference::TypeFromString(QStringLiteral("a:3")), - olive::Track::kAudio); - EXPECT_EQ(olive::Track::Reference::TypeFromString(QStringLiteral("s:0")), - olive::Track::kSubtitle); + EXPECT_EQ(olive::Track::Reference::type_from_string(QStringLiteral("v:2")), + olive::Track::k_video); + EXPECT_EQ(olive::Track::Reference::type_from_string(QStringLiteral("a:3")), + olive::Track::k_audio); + EXPECT_EQ(olive::Track::Reference::type_from_string(QStringLiteral("s:0")), + olive::Track::k_subtitle); EXPECT_TRUE( - olive::Track::Reference::TypeToString(olive::Track::kNone).isEmpty()); - EXPECT_TRUE(olive::Track::Reference().ToString().isEmpty()); + olive::Track::Reference::type_to_string(olive::Track::k_none).isEmpty()); + EXPECT_TRUE(olive::Track::Reference().to_string().isEmpty()); } TEST(Track, ReferenceInvalidStrings) { EXPECT_FALSE( - olive::Track::Reference::FromString(QString()).IsValid()); + olive::Track::Reference::from_string(QString()).is_valid()); EXPECT_FALSE( - olive::Track::Reference::FromString(QStringLiteral("x:1")).IsValid()); + olive::Track::Reference::from_string(QStringLiteral("x:1")).is_valid()); // Too short to contain a type prefix and separator EXPECT_FALSE( - olive::Track::Reference::FromString(QStringLiteral("v")).IsValid()); + olive::Track::Reference::from_string(QStringLiteral("v")).is_valid()); // Non-numeric index fails to parse EXPECT_FALSE( - olive::Track::Reference::FromString(QStringLiteral("v:x")).IsValid()); + olive::Track::Reference::from_string(QStringLiteral("v:x")).is_valid()); EXPECT_EQ( - olive::Track::Reference::TypeFromString(QStringLiteral("q:0")), - olive::Track::kNone); + olive::Track::Reference::type_from_string(QStringLiteral("q:0")), + olive::Track::k_none); - EXPECT_FALSE(olive::Track::Reference().IsValid()); + EXPECT_FALSE(olive::Track::Reference().is_valid()); EXPECT_FALSE( - olive::Track::Reference(olive::Track::kCount, 0).IsValid()); + olive::Track::Reference(olive::Track::k_count, 0).is_valid()); EXPECT_FALSE( - olive::Track::Reference(olive::Track::kVideo, -1).IsValid()); + olive::Track::Reference(olive::Track::k_video, -1).is_valid()); } TEST(Track, ReferenceComparisonAndHash) { - const olive::Track::Reference v1(olive::Track::kVideo, 1); - const olive::Track::Reference v1_copy(olive::Track::kVideo, 1); - const olive::Track::Reference v2(olive::Track::kVideo, 2); - const olive::Track::Reference a1(olive::Track::kAudio, 1); + const olive::Track::Reference v1(olive::Track::k_video, 1); + const olive::Track::Reference v1_copy(olive::Track::k_video, 1); + const olive::Track::Reference v2(olive::Track::k_video, 2); + const olive::Track::Reference a1(olive::Track::k_audio, 1); EXPECT_EQ(v1, v1_copy); EXPECT_NE(v1, v2); @@ -284,7 +284,7 @@ TEST(Track, ReferenceComparisonAndHash) TEST(Track, ReferenceDataStreamRoundTrip) { - const olive::Track::Reference ref(olive::Track::kAudio, 5); + const olive::Track::Reference ref(olive::Track::k_audio, 5); QByteArray bytes; QDataStream out(&bytes, QIODevice::WriteOnly); @@ -300,46 +300,46 @@ TEST(Track, ReferenceDataStreamRoundTrip) TEST(Track, ToReferenceMatchesTypeAndIndex) { olive::Track track; - track.set_type(olive::Track::kAudio); - track.SetIndex(7); + track.set_type(olive::Track::k_audio); + track.set_index(7); - const olive::Track::Reference ref = track.ToReference(); - EXPECT_EQ(ref, olive::Track::Reference(olive::Track::kAudio, 7)); - EXPECT_EQ(ref.ToString(), QStringLiteral("a:7")); + const olive::Track::Reference ref = track.to_reference(); + EXPECT_EQ(ref, olive::Track::Reference(olive::Track::k_audio, 7)); + EXPECT_EQ(ref.to_string(), QStringLiteral("a:7")); } TEST(Track, AppendBlocksSetsInOutLengthAndLinks) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); int added_count = 0; olive::Block *last_added = nullptr; - QObject::connect(track, &olive::Track::BlockAdded, + QObject::connect(track, &olive::Track::block_added, [&added_count, &last_added](olive::Block *b) { ++added_count; last_added = b; }); int length_changed_count = 0; - QObject::connect(track, &olive::Track::TrackLengthChanged, + QObject::connect(track, &olive::Track::track_length_changed, [&length_changed_count]() { ++length_changed_count; }); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(2)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(b->out(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(5)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(b->out(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(5)); EXPECT_EQ(a->track(), track); EXPECT_EQ(b->track(), track); @@ -355,26 +355,26 @@ TEST(Track, AppendBlocksSetsInOutLengthAndLinks) TEST(Track, PrependBlockShiftsExistingBlocks) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(2)); - track->AppendBlock(b); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(2)); + track->append_block(b); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(1)); - track->PrependBlock(a); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(1)); + track->prepend_block(a); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(1)); - EXPECT_EQ(b->out(), olive::core::rational(3)); - EXPECT_EQ(track->track_length(), olive::core::rational(3)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(1)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); + EXPECT_EQ(track->track_length(), olive::core::Rational(3)); EXPECT_EQ(a->next(), b); EXPECT_EQ(b->previous(), a); @@ -382,30 +382,30 @@ TEST(Track, PrependBlockShiftsExistingBlocks) TEST(Track, InsertBlockAtIndexMiddle) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(1)); - olive::ClipBlock *c = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(c); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(1)); + olive::ClipBlock *c = create_clip(&project, olive::core::Rational(1)); + track->append_block(a); + track->append_block(c); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(2)); - track->InsertBlockAtIndex(b, 1); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(2)); + track->insert_block_at_index(b, 1); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), b); - EXPECT_EQ(track->Blocks().at(2), c); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), b); + EXPECT_EQ(track->blocks().at(2), c); - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(1)); - EXPECT_EQ(b->out(), olive::core::rational(3)); - EXPECT_EQ(c->in(), olive::core::rational(3)); - EXPECT_EQ(c->out(), olive::core::rational(4)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(1)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); + EXPECT_EQ(c->in(), olive::core::Rational(3)); + EXPECT_EQ(c->out(), olive::core::Rational(4)); EXPECT_EQ(a->next(), b); EXPECT_EQ(b->previous(), a); @@ -415,86 +415,86 @@ TEST(Track, InsertBlockAtIndexMiddle) TEST(Track, InsertBlockAfterAndBefore) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(1)); - olive::ClipBlock *c = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(c); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(1)); + olive::ClipBlock *c = create_clip(&project, olive::core::Rational(1)); + track->append_block(a); + track->append_block(c); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(2)); - track->InsertBlockAfter(b, a); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(2)); + track->insert_block_after(b, a); - olive::ClipBlock *d = CreateClip(&project, olive::core::rational(1)); - track->InsertBlockBefore(d, c); + olive::ClipBlock *d = create_clip(&project, olive::core::Rational(1)); + track->insert_block_before(d, c); // A null "before" block prepends, a null "after" block appends - olive::ClipBlock *e = CreateClip(&project, olive::core::rational(1)); - track->InsertBlockAfter(e, nullptr); + olive::ClipBlock *e = create_clip(&project, olive::core::Rational(1)); + track->insert_block_after(e, nullptr); - olive::ClipBlock *f = CreateClip(&project, olive::core::rational(1)); - track->InsertBlockBefore(f, nullptr); + olive::ClipBlock *f = create_clip(&project, olive::core::Rational(1)); + track->insert_block_before(f, nullptr); const QVector expected = { e, a, b, d, c, f }; - ASSERT_EQ(track->Blocks().size(), expected.size()); + ASSERT_EQ(track->blocks().size(), expected.size()); for (int i = 0; i < expected.size(); ++i) { - EXPECT_EQ(track->Blocks().at(i), expected.at(i)); + EXPECT_EQ(track->blocks().at(i), expected.at(i)); } - EXPECT_EQ(e->in(), olive::core::rational(0)); - EXPECT_EQ(a->in(), olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(2)); - EXPECT_EQ(d->in(), olive::core::rational(4)); - EXPECT_EQ(c->in(), olive::core::rational(5)); - EXPECT_EQ(f->in(), olive::core::rational(6)); - EXPECT_EQ(f->out(), olive::core::rational(7)); - EXPECT_EQ(track->track_length(), olive::core::rational(7)); + EXPECT_EQ(e->in(), olive::core::Rational(0)); + EXPECT_EQ(a->in(), olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(2)); + EXPECT_EQ(d->in(), olive::core::Rational(4)); + EXPECT_EQ(c->in(), olive::core::Rational(5)); + EXPECT_EQ(f->in(), olive::core::Rational(6)); + EXPECT_EQ(f->out(), olive::core::Rational(7)); + EXPECT_EQ(track->track_length(), olive::core::Rational(7)); } TEST(Track, RippleRemoveBlockShiftsAndDetaches) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(3)); - olive::ClipBlock *c = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); - ASSERT_EQ(track->track_length(), olive::core::rational(6)); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(3)); + olive::ClipBlock *c = create_clip(&project, olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); + ASSERT_EQ(track->track_length(), olive::core::Rational(6)); int removed_count = 0; olive::Block *last_removed = nullptr; - QObject::connect(track, &olive::Track::BlockRemoved, + QObject::connect(track, &olive::Track::block_removed, [&removed_count, &last_removed](olive::Block *blk) { ++removed_count; last_removed = blk; }); - track->RippleRemoveBlock(b); + track->ripple_remove_block(b); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), c); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), c); // Subsequent blocks move earlier to fill the space - EXPECT_EQ(a->in(), olive::core::rational(0)); - EXPECT_EQ(a->out(), olive::core::rational(2)); - EXPECT_EQ(c->in(), olive::core::rational(2)); - EXPECT_EQ(c->out(), olive::core::rational(3)); - EXPECT_EQ(track->track_length(), olive::core::rational(3)); + EXPECT_EQ(a->in(), olive::core::Rational(0)); + EXPECT_EQ(a->out(), olive::core::Rational(2)); + EXPECT_EQ(c->in(), olive::core::Rational(2)); + EXPECT_EQ(c->out(), olive::core::Rational(3)); + EXPECT_EQ(track->track_length(), olive::core::Rational(3)); // The removed block is detached and reset to zero-based in/out EXPECT_EQ(b->track(), nullptr); EXPECT_EQ(b->previous(), nullptr); EXPECT_EQ(b->next(), nullptr); - EXPECT_EQ(b->in(), olive::core::rational(0)); + EXPECT_EQ(b->in(), olive::core::Rational(0)); EXPECT_EQ(b->out(), b->length()); EXPECT_EQ(a->next(), c); @@ -506,66 +506,66 @@ TEST(Track, RippleRemoveBlockShiftsAndDetaches) TEST(Track, RippleRemoveFirstAndLastBlock) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(3)); - olive::ClipBlock *c = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(3)); + olive::ClipBlock *c = create_clip(&project, olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); - track->RippleRemoveBlock(a); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(b->in(), olive::core::rational(0)); - EXPECT_EQ(b->out(), olive::core::rational(3)); - EXPECT_EQ(c->in(), olive::core::rational(3)); - EXPECT_EQ(track->track_length(), olive::core::rational(4)); + track->ripple_remove_block(a); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(b->in(), olive::core::Rational(0)); + EXPECT_EQ(b->out(), olive::core::Rational(3)); + EXPECT_EQ(c->in(), olive::core::Rational(3)); + EXPECT_EQ(track->track_length(), olive::core::Rational(4)); EXPECT_EQ(b->previous(), nullptr); - track->RippleRemoveBlock(c); - ASSERT_EQ(track->Blocks().size(), 1); - EXPECT_EQ(track->track_length(), olive::core::rational(3)); + track->ripple_remove_block(c); + ASSERT_EQ(track->blocks().size(), 1); + EXPECT_EQ(track->track_length(), olive::core::Rational(3)); EXPECT_EQ(b->next(), nullptr); - track->RippleRemoveBlock(b); - EXPECT_TRUE(track->Blocks().isEmpty()); - EXPECT_EQ(track->track_length(), olive::core::rational(0)); + track->ripple_remove_block(b); + EXPECT_TRUE(track->blocks().isEmpty()); + EXPECT_EQ(track->track_length(), olive::core::Rational(0)); } TEST(Track, ReplaceBlockSameLength) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); int removed_count = 0; int added_count = 0; - QObject::connect(track, &olive::Track::BlockRemoved, + QObject::connect(track, &olive::Track::block_removed, [&removed_count](olive::Block *) { ++removed_count; }); - QObject::connect(track, &olive::Track::BlockAdded, + QObject::connect(track, &olive::Track::block_added, [&added_count](olive::Block *) { ++added_count; }); - olive::ClipBlock *r = CreateClip(&project, olive::core::rational(3)); - track->ReplaceBlock(b, r); + olive::ClipBlock *r = create_clip(&project, olive::core::Rational(3)); + track->replace_block(b, r); - ASSERT_EQ(track->Blocks().size(), 2); - EXPECT_EQ(track->Blocks().at(0), a); - EXPECT_EQ(track->Blocks().at(1), r); + ASSERT_EQ(track->blocks().size(), 2); + EXPECT_EQ(track->blocks().at(0), a); + EXPECT_EQ(track->blocks().at(1), r); // Same-length replacement keeps in/out points identical - EXPECT_EQ(r->in(), olive::core::rational(2)); - EXPECT_EQ(r->out(), olive::core::rational(5)); - EXPECT_EQ(track->track_length(), olive::core::rational(5)); + EXPECT_EQ(r->in(), olive::core::Rational(2)); + EXPECT_EQ(r->out(), olive::core::Rational(5)); + EXPECT_EQ(track->track_length(), olive::core::Rational(5)); EXPECT_EQ(b->track(), nullptr); EXPECT_EQ(b->previous(), nullptr); @@ -581,174 +581,174 @@ TEST(Track, ReplaceBlockSameLength) TEST(Track, ReplaceBlockDifferentLengthRipples) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *c = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); - ASSERT_EQ(track->track_length(), olive::core::rational(5)); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *c = create_clip(&project, olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); + ASSERT_EQ(track->track_length(), olive::core::Rational(5)); - olive::ClipBlock *r = CreateClip(&project, olive::core::rational(4)); - track->ReplaceBlock(b, r); + olive::ClipBlock *r = create_clip(&project, olive::core::Rational(4)); + track->replace_block(b, r); - ASSERT_EQ(track->Blocks().size(), 3); - EXPECT_EQ(r->in(), olive::core::rational(2)); - EXPECT_EQ(r->out(), olive::core::rational(6)); + ASSERT_EQ(track->blocks().size(), 3); + EXPECT_EQ(r->in(), olive::core::Rational(2)); + EXPECT_EQ(r->out(), olive::core::Rational(6)); // The longer replacement pushes subsequent blocks later - EXPECT_EQ(c->in(), olive::core::rational(6)); - EXPECT_EQ(c->out(), olive::core::rational(7)); - EXPECT_EQ(track->track_length(), olive::core::rational(7)); + EXPECT_EQ(c->in(), olive::core::Rational(6)); + EXPECT_EQ(c->out(), olive::core::Rational(7)); + EXPECT_EQ(track->track_length(), olive::core::Rational(7)); } TEST(Track, BlockLookupFunctions) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::GapBlock *g = CreateGap(&project, olive::core::rational(3)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(4)); - track->AppendBlock(a); - track->AppendBlock(g); - track->AppendBlock(b); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::GapBlock *g = create_gap(&project, olive::core::Rational(3)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(4)); + track->append_block(a); + track->append_block(g); + track->append_block(b); // Layout: a [0,2], g [2,5], b [5,9] // BlockContainingTime: strictly inside only, never at edges - EXPECT_EQ(track->BlockContainingTime(olive::core::rational(1)), a); - EXPECT_EQ(track->BlockContainingTime(olive::core::rational(0)), nullptr); - EXPECT_EQ(track->BlockContainingTime(olive::core::rational(2)), nullptr); - EXPECT_EQ(track->BlockContainingTime(olive::core::rational(3)), g); - EXPECT_EQ(track->BlockContainingTime(olive::core::rational(5)), nullptr); - EXPECT_EQ(track->BlockContainingTime(olive::core::rational(8)), b); - EXPECT_EQ(track->BlockContainingTime(olive::core::rational(9)), nullptr); - EXPECT_EQ(track->BlockContainingTime(olive::core::rational(100)), nullptr); + EXPECT_EQ(track->block_containing_time(olive::core::Rational(1)), a); + EXPECT_EQ(track->block_containing_time(olive::core::Rational(0)), nullptr); + EXPECT_EQ(track->block_containing_time(olive::core::Rational(2)), nullptr); + EXPECT_EQ(track->block_containing_time(olive::core::Rational(3)), g); + EXPECT_EQ(track->block_containing_time(olive::core::Rational(5)), nullptr); + EXPECT_EQ(track->block_containing_time(olive::core::Rational(8)), b); + EXPECT_EQ(track->block_containing_time(olive::core::Rational(9)), nullptr); + EXPECT_EQ(track->block_containing_time(olive::core::Rational(100)), nullptr); // NearestBlockBefore: block starting before and ending at/after the time - EXPECT_EQ(track->NearestBlockBefore(olive::core::rational(2)), a); - EXPECT_EQ(track->NearestBlockBefore(olive::core::rational(5)), g); - EXPECT_EQ(track->NearestBlockBefore(olive::core::rational(9)), b); - EXPECT_EQ(track->NearestBlockBefore(olive::core::rational(10)), nullptr); + EXPECT_EQ(track->nearest_block_before(olive::core::Rational(2)), a); + EXPECT_EQ(track->nearest_block_before(olive::core::Rational(5)), g); + EXPECT_EQ(track->nearest_block_before(olive::core::Rational(9)), b); + EXPECT_EQ(track->nearest_block_before(olive::core::Rational(10)), nullptr); // NearestBlockBeforeOrAt: first block ending after the time - EXPECT_EQ(track->NearestBlockBeforeOrAt(olive::core::rational(0)), a); - EXPECT_EQ(track->NearestBlockBeforeOrAt(olive::core::rational(2)), g); - EXPECT_EQ(track->NearestBlockBeforeOrAt(olive::core::rational(5)), b); - EXPECT_EQ(track->NearestBlockBeforeOrAt(olive::core::rational(9)), nullptr); + EXPECT_EQ(track->nearest_block_before_or_at(olive::core::Rational(0)), a); + EXPECT_EQ(track->nearest_block_before_or_at(olive::core::Rational(2)), g); + EXPECT_EQ(track->nearest_block_before_or_at(olive::core::Rational(5)), b); + EXPECT_EQ(track->nearest_block_before_or_at(olive::core::Rational(9)), nullptr); // NearestBlockAfterOrAt: first block starting at or after the time - EXPECT_EQ(track->NearestBlockAfterOrAt(olive::core::rational(0)), a); - EXPECT_EQ(track->NearestBlockAfterOrAt(olive::core::rational(2)), g); - EXPECT_EQ(track->NearestBlockAfterOrAt(olive::core::rational(5)), b); - EXPECT_EQ(track->NearestBlockAfterOrAt(olive::core::rational(9)), nullptr); + EXPECT_EQ(track->nearest_block_after_or_at(olive::core::Rational(0)), a); + EXPECT_EQ(track->nearest_block_after_or_at(olive::core::Rational(2)), g); + EXPECT_EQ(track->nearest_block_after_or_at(olive::core::Rational(5)), b); + EXPECT_EQ(track->nearest_block_after_or_at(olive::core::Rational(9)), nullptr); // NearestBlockAfter: first block starting strictly after the time - EXPECT_EQ(track->NearestBlockAfter(olive::core::rational(0)), g); - EXPECT_EQ(track->NearestBlockAfter(olive::core::rational(2)), b); - EXPECT_EQ(track->NearestBlockAfter(olive::core::rational(4)), b); - EXPECT_EQ(track->NearestBlockAfter(olive::core::rational(5)), nullptr); + EXPECT_EQ(track->nearest_block_after(olive::core::Rational(0)), g); + EXPECT_EQ(track->nearest_block_after(olive::core::Rational(2)), b); + EXPECT_EQ(track->nearest_block_after(olive::core::Rational(4)), b); + EXPECT_EQ(track->nearest_block_after(olive::core::Rational(5)), nullptr); // VisibleBlockAtTime: half-open [in, out) containment via binary search - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(0)), a); - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(1)), a); - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(2)), g); - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(4)), g); - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(5)), b); - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(8)), b); - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(9)), nullptr); - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(-1)), nullptr); - EXPECT_EQ(track->VisibleBlockAtTime(olive::core::rational(100)), nullptr); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(0)), a); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(1)), a); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(2)), g); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(4)), g); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(5)), b); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(8)), b); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(9)), nullptr); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(-1)), nullptr); + EXPECT_EQ(track->visible_block_at_time(olive::core::Rational(100)), nullptr); } TEST(Track, BlockLookupOnEmptyTrack) { olive::Track track; - EXPECT_EQ(track.BlockContainingTime(olive::core::rational(0)), nullptr); - EXPECT_EQ(track.NearestBlockBefore(olive::core::rational(0)), nullptr); - EXPECT_EQ(track.NearestBlockBeforeOrAt(olive::core::rational(0)), nullptr); - EXPECT_EQ(track.NearestBlockAfterOrAt(olive::core::rational(0)), nullptr); - EXPECT_EQ(track.NearestBlockAfter(olive::core::rational(0)), nullptr); - EXPECT_EQ(track.VisibleBlockAtTime(olive::core::rational(0)), nullptr); - EXPECT_EQ(track.track_length(), olive::core::rational(0)); + EXPECT_EQ(track.block_containing_time(olive::core::Rational(0)), nullptr); + EXPECT_EQ(track.nearest_block_before(olive::core::Rational(0)), nullptr); + EXPECT_EQ(track.nearest_block_before_or_at(olive::core::Rational(0)), nullptr); + EXPECT_EQ(track.nearest_block_after_or_at(olive::core::Rational(0)), nullptr); + EXPECT_EQ(track.nearest_block_after(olive::core::Rational(0)), nullptr); + EXPECT_EQ(track.visible_block_at_time(olive::core::Rational(0)), nullptr); + EXPECT_EQ(track.track_length(), olive::core::Rational(0)); } TEST(Track, IsRangeFree) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::GapBlock *g = CreateGap(&project, olive::core::rational(3)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(4)); - track->AppendBlock(a); - track->AppendBlock(g); - track->AppendBlock(b); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::GapBlock *g = create_gap(&project, olive::core::Rational(3)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(4)); + track->append_block(a); + track->append_block(g); + track->append_block(b); // Layout: clip a [0,2], gap g [2,5], clip b [5,9] // A range covering only the gap (or part of it) is free - EXPECT_TRUE(track->IsRangeFree(olive::core::TimeRange( - olive::core::rational(2), olive::core::rational(5)))); - EXPECT_TRUE(track->IsRangeFree(olive::core::TimeRange( - olive::core::rational(3), olive::core::rational(4)))); + EXPECT_TRUE(track->is_range_free(olive::core::TimeRange( + olive::core::Rational(2), olive::core::Rational(5)))); + EXPECT_TRUE(track->is_range_free(olive::core::TimeRange( + olive::core::Rational(3), olive::core::Rational(4)))); // Ranges touching clips are not free - EXPECT_FALSE(track->IsRangeFree(olive::core::TimeRange( - olive::core::rational(0), olive::core::rational(2)))); - EXPECT_FALSE(track->IsRangeFree(olive::core::TimeRange( - olive::core::rational(1), olive::core::rational(3)))); - EXPECT_FALSE(track->IsRangeFree(olive::core::TimeRange( - olive::core::rational(4), olive::core::rational(9)))); + EXPECT_FALSE(track->is_range_free(olive::core::TimeRange( + olive::core::Rational(0), olive::core::Rational(2)))); + EXPECT_FALSE(track->is_range_free(olive::core::TimeRange( + olive::core::Rational(1), olive::core::Rational(3)))); + EXPECT_FALSE(track->is_range_free(olive::core::TimeRange( + olive::core::Rational(4), olive::core::Rational(9)))); // Past the end of the track there is nothing in the way - EXPECT_TRUE(track->IsRangeFree(olive::core::TimeRange( - olive::core::rational(9), olive::core::rational(12)))); + EXPECT_TRUE(track->is_range_free(olive::core::TimeRange( + olive::core::Rational(9), olive::core::Rational(12)))); olive::Track empty_track; - EXPECT_TRUE(empty_track.IsRangeFree(olive::core::TimeRange( - olive::core::rational(0), olive::core::rational(10)))); + EXPECT_TRUE(empty_track.is_range_free(olive::core::TimeRange( + olive::core::Rational(0), olive::core::Rational(10)))); } TEST(Track, ArrayIndexesAreReusedAfterRemoval) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(1)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(1)); - olive::ClipBlock *c = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); - track->AppendBlock(c); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(1)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(1)); + olive::ClipBlock *c = create_clip(&project, olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); + track->append_block(c); - EXPECT_EQ(track->GetArrayIndexFromBlock(a), 0); - EXPECT_EQ(track->GetArrayIndexFromBlock(b), 1); - EXPECT_EQ(track->GetArrayIndexFromBlock(c), 2); + EXPECT_EQ(track->get_array_index_from_block(a), 0); + EXPECT_EQ(track->get_array_index_from_block(b), 1); + EXPECT_EQ(track->get_array_index_from_block(c), 2); // Removing B frees its input array index; the next block reuses it - track->RippleRemoveBlock(b); + track->ripple_remove_block(b); - olive::ClipBlock *d = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(d); + olive::ClipBlock *d = create_clip(&project, olive::core::Rational(1)); + track->append_block(d); - EXPECT_EQ(track->GetArrayIndexFromBlock(a), 0); - EXPECT_EQ(track->GetArrayIndexFromBlock(c), 2); - EXPECT_EQ(track->GetArrayIndexFromBlock(d), 1); + EXPECT_EQ(track->get_array_index_from_block(a), 0); + EXPECT_EQ(track->get_array_index_from_block(c), 2); + EXPECT_EQ(track->get_array_index_from_block(d), 1); // The array map standard value mirrors the cache order [a, c, d] const QByteArray bytes = - track->GetStandardValue(olive::Track::kArrayMapInput).toByteArray(); + track->get_standard_value(olive::Track::k_array_map_input).toByteArray(); ASSERT_EQ(bytes.size(), 3 * int(sizeof(uint32_t))); uint32_t values[3]; std::memcpy(values, bytes.constData(), sizeof(values)); @@ -759,304 +759,304 @@ TEST(Track, ArrayIndexesAreReusedAfterRemoval) TEST(Track, BlockLengthChangeRipplesSubsequentBlocks) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(b); - ASSERT_EQ(track->track_length(), olive::core::rational(4)); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(2)); + track->append_block(a); + track->append_block(b); + ASSERT_EQ(track->track_length(), olive::core::Rational(4)); int refreshed_count = 0; - QObject::connect(track, &olive::Track::BlocksRefreshed, + QObject::connect(track, &olive::Track::blocks_refreshed, [&refreshed_count]() { ++refreshed_count; }); - a->set_length_and_media_out(olive::core::rational(5)); - EXPECT_EQ(a->out(), olive::core::rational(5)); - EXPECT_EQ(b->in(), olive::core::rational(5)); - EXPECT_EQ(b->out(), olive::core::rational(7)); - EXPECT_EQ(track->track_length(), olive::core::rational(7)); + a->set_length_and_media_out(olive::core::Rational(5)); + EXPECT_EQ(a->out(), olive::core::Rational(5)); + EXPECT_EQ(b->in(), olive::core::Rational(5)); + EXPECT_EQ(b->out(), olive::core::Rational(7)); + EXPECT_EQ(track->track_length(), olive::core::Rational(7)); - b->set_length_and_media_out(olive::core::rational(1)); - EXPECT_EQ(b->in(), olive::core::rational(5)); - EXPECT_EQ(b->out(), olive::core::rational(6)); - EXPECT_EQ(track->track_length(), olive::core::rational(6)); + b->set_length_and_media_out(olive::core::Rational(1)); + EXPECT_EQ(b->in(), olive::core::Rational(5)); + EXPECT_EQ(b->out(), olive::core::Rational(6)); + EXPECT_EQ(track->track_length(), olive::core::Rational(6)); EXPECT_EQ(refreshed_count, 2); } TEST(Track, GetActiveElementsAtTime) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); // An empty track has no active elements - EXPECT_EQ(track->GetActiveElementsAtTime( - olive::Track::kBlockInput, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(1))) + EXPECT_EQ(track->get_active_elements_at_time( + olive::Track::k_block_input, + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(1))) .mode(), - olive::Node::ActiveElements::kNoElements); + olive::Node::ActiveElements::k_no_elements); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::GapBlock *g = CreateGap(&project, olive::core::rational(2)); - track->AppendBlock(a); - track->AppendBlock(g); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::GapBlock *g = create_gap(&project, olive::core::Rational(2)); + track->append_block(a); + track->append_block(g); // Layout: clip a [0,2], gap g [2,4] // The clip is the only active element in [0,1] const olive::Node::ActiveElements active = - track->GetActiveElementsAtTime( - olive::Track::kBlockInput, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(1))); - EXPECT_EQ(active.mode(), olive::Node::ActiveElements::kSpecified); + track->get_active_elements_at_time( + olive::Track::k_block_input, + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(1))); + EXPECT_EQ(active.mode(), olive::Node::ActiveElements::k_specified); ASSERT_EQ(active.elements().size(), 1); - EXPECT_EQ(active.elements().front(), track->GetArrayIndexFromBlock(a)); + EXPECT_EQ(active.elements().front(), track->get_array_index_from_block(a)); // Gaps never count as active elements - EXPECT_EQ(track->GetActiveElementsAtTime( - olive::Track::kBlockInput, - olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(4))) + EXPECT_EQ(track->get_active_elements_at_time( + olive::Track::k_block_input, + olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(4))) .mode(), - olive::Node::ActiveElements::kNoElements); + olive::Node::ActiveElements::k_no_elements); // A muted track reports no active elements - track->SetMuted(true); - EXPECT_EQ(track->GetActiveElementsAtTime( - olive::Track::kBlockInput, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(1))) + track->set_muted(true); + EXPECT_EQ(track->get_active_elements_at_time( + olive::Track::k_block_input, + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(1))) .mode(), - olive::Node::ActiveElements::kNoElements); - track->SetMuted(false); + olive::Node::ActiveElements::k_no_elements); + track->set_muted(false); // A disabled clip is not an active element a->set_enabled(false); - EXPECT_EQ(track->GetActiveElementsAtTime( - olive::Track::kBlockInput, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(1))) + EXPECT_EQ(track->get_active_elements_at_time( + olive::Track::k_block_input, + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(1))) .mode(), - olive::Node::ActiveElements::kNoElements); + olive::Node::ActiveElements::k_no_elements); // Ranges outside the track length have no active elements - EXPECT_EQ(track->GetActiveElementsAtTime( - olive::Track::kBlockInput, - olive::core::TimeRange(olive::core::rational(4), - olive::core::rational(8))) + EXPECT_EQ(track->get_active_elements_at_time( + olive::Track::k_block_input, + olive::core::TimeRange(olive::core::Rational(4), + olive::core::Rational(8))) .mode(), - olive::Node::ActiveElements::kNoElements); - EXPECT_EQ(track->GetActiveElementsAtTime( - olive::Track::kBlockInput, - olive::core::TimeRange(olive::core::rational(-1), - olive::core::rational(0))) + olive::Node::ActiveElements::k_no_elements); + EXPECT_EQ(track->get_active_elements_at_time( + olive::Track::k_block_input, + olive::core::TimeRange(olive::core::Rational(-1), + olive::core::Rational(0))) .mode(), - olive::Node::ActiveElements::kNoElements); + olive::Node::ActiveElements::k_no_elements); // Non-block inputs fall back to the default (all elements) - EXPECT_EQ(track->GetActiveElementsAtTime( - olive::Track::kMutedInput, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(1))) + EXPECT_EQ(track->get_active_elements_at_time( + olive::Track::k_muted_input, + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(1))) .mode(), - olive::Node::ActiveElements::kAllElements); + olive::Node::ActiveElements::k_all_elements); } TEST(Track, TimeAdjustmentTransformsAroundBlock) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // Layout: a [0,2], b [2,5] - const int b_index = track->GetArrayIndexFromBlock(b); + const int b_index = track->get_array_index_from_block(b); // Without clamping, the range is simply shifted by the block's in point - EXPECT_EQ(track->InputTimeAdjustment( - olive::Track::kBlockInput, b_index, - olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(5)), + EXPECT_EQ(track->input_time_adjustment( + olive::Track::k_block_input, b_index, + olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(5)), false), - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(3))); + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(3))); // Clamping limits the range to the block before shifting - EXPECT_EQ(track->InputTimeAdjustment( - olive::Track::kBlockInput, b_index, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(10)), + EXPECT_EQ(track->input_time_adjustment( + olive::Track::k_block_input, b_index, + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(10)), true), - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(3))); - EXPECT_EQ(track->InputTimeAdjustment( - olive::Track::kBlockInput, b_index, - olive::core::TimeRange(olive::core::rational(1), - olive::core::rational(4)), + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(3))); + EXPECT_EQ(track->input_time_adjustment( + olive::Track::k_block_input, b_index, + olive::core::TimeRange(olive::core::Rational(1), + olive::core::Rational(4)), true), - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(2))); + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(2))); // Output adjustment shifts block-local time back into track time - EXPECT_EQ(track->OutputTimeAdjustment( - olive::Track::kBlockInput, b_index, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(3))), - olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(5))); + EXPECT_EQ(track->output_time_adjustment( + olive::Track::k_block_input, b_index, + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(3))), + olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(5))); // Unknown elements and inputs pass the range through unchanged - const olive::core::TimeRange unchanged(olive::core::rational(1), - olive::core::rational(2)); - EXPECT_EQ(track->InputTimeAdjustment(olive::Track::kBlockInput, 99, + const olive::core::TimeRange unchanged(olive::core::Rational(1), + olive::core::Rational(2)); + EXPECT_EQ(track->input_time_adjustment(olive::Track::k_block_input, 99, unchanged, true), unchanged); - EXPECT_EQ(track->OutputTimeAdjustment(olive::Track::kBlockInput, 99, + EXPECT_EQ(track->output_time_adjustment(olive::Track::k_block_input, 99, unchanged), unchanged); - EXPECT_EQ(track->InputTimeAdjustment(olive::Track::kMutedInput, -1, + EXPECT_EQ(track->input_time_adjustment(olive::Track::k_muted_input, -1, unchanged, true), unchanged); } TEST(Track, TransformTimeHelpersRespectInfinities) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project); + project.initialize(); + olive::Track *track = create_track(&project); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(2)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(3)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(2)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(3)); + track->append_block(a); + track->append_block(b); // b occupies [2,5] - const olive::core::rational kMax(INT_MAX); - const olive::core::rational kMin(INT_MIN); + const olive::core::Rational k_max(INT_MAX); + const olive::core::Rational k_min(INT_MIN); - EXPECT_EQ(olive::Track::TransformTimeForBlock(b, kMax), kMax); - EXPECT_EQ(olive::Track::TransformTimeForBlock(b, kMin), kMin); - EXPECT_EQ(olive::Track::TransformTimeFromBlock(b, kMax), kMax); - EXPECT_EQ(olive::Track::TransformTimeFromBlock(b, kMin), kMin); + EXPECT_EQ(olive::Track::transform_time_for_block(b, k_max), k_max); + EXPECT_EQ(olive::Track::transform_time_for_block(b, k_min), k_min); + EXPECT_EQ(olive::Track::transform_time_from_block(b, k_max), k_max); + EXPECT_EQ(olive::Track::transform_time_from_block(b, k_min), k_min); - EXPECT_EQ(olive::Track::TransformTimeForBlock(b, olive::core::rational(3)), - olive::core::rational(1)); + EXPECT_EQ(olive::Track::transform_time_for_block(b, olive::core::Rational(3)), + olive::core::Rational(1)); EXPECT_EQ( - olive::Track::TransformTimeFromBlock(b, olive::core::rational(1)), - olive::core::rational(3)); + olive::Track::transform_time_from_block(b, olive::core::Rational(1)), + olive::core::Rational(3)); - EXPECT_EQ(olive::Track::TransformRangeForBlock( - b, olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(5))), - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(3))); - EXPECT_EQ(olive::Track::TransformRangeFromBlock( - b, olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(3))), - olive::core::TimeRange(olive::core::rational(2), - olive::core::rational(5))); + EXPECT_EQ(olive::Track::transform_range_for_block( + b, olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(5))), + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(3))); + EXPECT_EQ(olive::Track::transform_range_from_block( + b, olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(3))), + olive::core::TimeRange(olive::core::Rational(2), + olive::core::Rational(5))); } TEST(Track, VideoValuePassesThroughFirstArrayElement) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project, olive::Track::kVideo); + project.initialize(); + olive::Track *track = create_track(&project, olive::Track::k_video); olive::NodeValueArray arr; - arr.emplace(0, olive::NodeValue(olive::NodeValue::kFloat, 42.0)); + arr.emplace(0, olive::NodeValue(olive::NodeValue::k_float, 42.0)); olive::NodeValueRow row; - row.insert(olive::Track::kBlockInput, - olive::NodeValue(olive::NodeValue::kNone, arr, nullptr, true)); + row.insert(olive::Track::k_block_input, + olive::NodeValue(olive::NodeValue::k_none, arr, nullptr, true)); olive::NodeValueTable table; - track->Value(row, olive::NodeGlobals(), &table); + track->value(row, olive::NodeGlobals(), &table); - const olive::NodeValue out = table.Get(olive::NodeValue::kFloat); - ASSERT_EQ(out.type(), olive::NodeValue::kFloat); - EXPECT_DOUBLE_EQ(out.toDouble(), 42.0); + const olive::NodeValue out = table.get(olive::NodeValue::k_float); + ASSERT_EQ(out.type(), olive::NodeValue::k_float); + EXPECT_DOUBLE_EQ(out.to_double(), 42.0); // An empty block array pushes nothing olive::NodeValueRow empty_row; - empty_row.insert(olive::Track::kBlockInput, - olive::NodeValue(olive::NodeValue::kNone, + empty_row.insert(olive::Track::k_block_input, + olive::NodeValue(olive::NodeValue::k_none, olive::NodeValueArray(), nullptr, true)); olive::NodeValueTable empty_table; - track->Value(empty_row, olive::NodeGlobals(), &empty_table); - EXPECT_EQ(empty_table.Get(olive::NodeValue::kFloat).type(), - olive::NodeValue::kNone); + track->value(empty_row, olive::NodeGlobals(), &empty_table); + EXPECT_EQ(empty_table.get(olive::NodeValue::k_float).type(), + olive::NodeValue::k_none); } TEST(Track, AudioValueProducesSilentBufferWithoutBlocks) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project, olive::Track::kAudio); + project.initialize(); + olive::Track *track = create_track(&project, olive::Track::k_audio); const olive::core::AudioParams aparams(48000, - olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); olive::NodeValueRow row; - row.insert(olive::Track::kBlockInput, - olive::NodeValue(olive::NodeValue::kNone, + row.insert(olive::Track::k_block_input, + olive::NodeValue(olive::NodeValue::k_none, olive::NodeValueArray(), nullptr, true)); const olive::NodeGlobals globals( olive::VideoParams(), aparams, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(1, 2)), - olive::LoopMode::kLoopModeOff); + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(1, 2)), + olive::LoopMode::k_loop_mode_off); olive::NodeValueTable table; - track->Value(row, globals, &table); + track->value(row, globals, &table); - const olive::NodeValue out = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(out.type(), olive::NodeValue::kSamples); + const olive::NodeValue out = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(out.type(), olive::NodeValue::k_samples); - const olive::core::SampleBuffer samples = out.toSamples(); + const olive::core::SampleBuffer samples = out.to_samples(); ASSERT_TRUE(samples.is_allocated()); EXPECT_EQ(samples.channel_count(), 2); EXPECT_EQ(samples.sample_count(), 24000); - EXPECT_FLOAT_EQ(SumOfAbsoluteSamples(samples), 0.0f); + EXPECT_FLOAT_EQ(sum_of_absolute_samples(samples), 0.0f); } TEST(Track, AudioValueMixesBlockSamples) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project, olive::Track::kAudio); + project.initialize(); + olive::Track *track = create_track(&project, olive::Track::k_audio); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(1)); - olive::ClipBlock *b = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(a); - track->AppendBlock(b); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(1)); + olive::ClipBlock *b = create_clip(&project, olive::core::Rational(1)); + track->append_block(a); + track->append_block(b); // Layout: a [0,1], b [1,2] const olive::core::AudioParams aparams(48000, - olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); - olive::core::SampleBuffer a_samples(aparams, olive::core::rational(1)); - olive::core::SampleBuffer b_samples(aparams, olive::core::rational(1)); + olive::core::SampleBuffer a_samples(aparams, olive::core::Rational(1)); + olive::core::SampleBuffer b_samples(aparams, olive::core::Rational(1)); ASSERT_TRUE(a_samples.is_allocated()); ASSERT_TRUE(b_samples.is_allocated()); for (int ch = 0; ch < a_samples.channel_count(); ++ch) { @@ -1065,28 +1065,28 @@ TEST(Track, AudioValueMixesBlockSamples) } olive::NodeValueArray arr; - arr.emplace(track->GetArrayIndexFromBlock(a), - olive::NodeValue(olive::NodeValue::kSamples, a_samples)); - arr.emplace(track->GetArrayIndexFromBlock(b), - olive::NodeValue(olive::NodeValue::kSamples, b_samples)); + arr.emplace(track->get_array_index_from_block(a), + olive::NodeValue(olive::NodeValue::k_samples, a_samples)); + arr.emplace(track->get_array_index_from_block(b), + olive::NodeValue(olive::NodeValue::k_samples, b_samples)); olive::NodeValueRow row; - row.insert(olive::Track::kBlockInput, - olive::NodeValue(olive::NodeValue::kNone, arr, nullptr, true)); + row.insert(olive::Track::k_block_input, + olive::NodeValue(olive::NodeValue::k_none, arr, nullptr, true)); const olive::NodeGlobals globals( olive::VideoParams(), aparams, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(2)), - olive::LoopMode::kLoopModeOff); + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(2)), + olive::LoopMode::k_loop_mode_off); olive::NodeValueTable table; - track->Value(row, globals, &table); + track->value(row, globals, &table); - const olive::NodeValue out = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(out.type(), olive::NodeValue::kSamples); + const olive::NodeValue out = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(out.type(), olive::NodeValue::k_samples); - const olive::core::SampleBuffer mixed = out.toSamples(); + const olive::core::SampleBuffer mixed = out.to_samples(); ASSERT_TRUE(mixed.is_allocated()); ASSERT_EQ(mixed.sample_count(), 96000); @@ -1101,67 +1101,67 @@ TEST(Track, AudioValueMixesBlockSamples) TEST(Track, AudioValueSilencesZeroSpeedClip) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project, olive::Track::kAudio); + project.initialize(); + olive::Track *track = create_track(&project, olive::Track::k_audio); - olive::ClipBlock *a = CreateClip(&project, olive::core::rational(1)); - track->AppendBlock(a); - a->SetStandardValue(olive::ClipBlock::kSpeedInput, 0.0); + olive::ClipBlock *a = create_clip(&project, olive::core::Rational(1)); + track->append_block(a); + a->set_standard_value(olive::ClipBlock::k_speed_input, 0.0); ASSERT_DOUBLE_EQ(a->speed(), 0.0); const olive::core::AudioParams aparams(48000, - olive::core::kChannelLayoutStereo, - olive::core::SampleFormat::F32P); + olive::core::k_channel_layout_stereo, + olive::core::SampleFormat::f32_p); - olive::core::SampleBuffer a_samples(aparams, olive::core::rational(1)); + olive::core::SampleBuffer a_samples(aparams, olive::core::Rational(1)); ASSERT_TRUE(a_samples.is_allocated()); for (int ch = 0; ch < a_samples.channel_count(); ++ch) { std::fill(a_samples.data(ch), a_samples.data(ch) + 48000, 1.0f); } olive::NodeValueArray arr; - arr.emplace(track->GetArrayIndexFromBlock(a), - olive::NodeValue(olive::NodeValue::kSamples, a_samples)); + arr.emplace(track->get_array_index_from_block(a), + olive::NodeValue(olive::NodeValue::k_samples, a_samples)); olive::NodeValueRow row; - row.insert(olive::Track::kBlockInput, - olive::NodeValue(olive::NodeValue::kNone, arr, nullptr, true)); + row.insert(olive::Track::k_block_input, + olive::NodeValue(olive::NodeValue::k_none, arr, nullptr, true)); const olive::NodeGlobals globals( olive::VideoParams(), aparams, - olive::core::TimeRange(olive::core::rational(0), - olive::core::rational(1)), - olive::LoopMode::kLoopModeOff); + olive::core::TimeRange(olive::core::Rational(0), + olive::core::Rational(1)), + olive::LoopMode::k_loop_mode_off); olive::NodeValueTable table; - track->Value(row, globals, &table); + track->value(row, globals, &table); - const olive::NodeValue out = table.Get(olive::NodeValue::kSamples); - ASSERT_EQ(out.type(), olive::NodeValue::kSamples); + const olive::NodeValue out = table.get(olive::NodeValue::k_samples); + ASSERT_EQ(out.type(), olive::NodeValue::k_samples); // Zero-speed audio is defined to come out as silence - const olive::core::SampleBuffer samples = out.toSamples(); + const olive::core::SampleBuffer samples = out.to_samples(); ASSERT_TRUE(samples.is_allocated()); - EXPECT_FLOAT_EQ(SumOfAbsoluteSamples(samples), 0.0f); + EXPECT_FLOAT_EQ(sum_of_absolute_samples(samples), 0.0f); } TEST(Track, SubtitleValuePushesNothing) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); - olive::Track *track = CreateTrack(&project, olive::Track::kSubtitle); + project.initialize(); + olive::Track *track = create_track(&project, olive::Track::k_subtitle); olive::NodeValueArray arr; - arr.emplace(0, olive::NodeValue(olive::NodeValue::kFloat, 42.0)); + arr.emplace(0, olive::NodeValue(olive::NodeValue::k_float, 42.0)); olive::NodeValueRow row; - row.insert(olive::Track::kBlockInput, - olive::NodeValue(olive::NodeValue::kNone, arr, nullptr, true)); + row.insert(olive::Track::k_block_input, + olive::NodeValue(olive::NodeValue::k_none, arr, nullptr, true)); olive::NodeValueTable table; - track->Value(row, olive::NodeGlobals(), &table); - EXPECT_EQ(table.Count(), 0); + track->value(row, olive::NodeGlobals(), &table); + EXPECT_EQ(table.count(), 0); } diff --git a/tests/gtest/ui_humanstrings_test.cpp b/tests/gtest/ui_humanstrings_test.cpp index ac59fd97a..9d5208b49 100644 --- a/tests/gtest/ui_humanstrings_test.cpp +++ b/tests/gtest/ui_humanstrings_test.cpp @@ -4,35 +4,35 @@ TEST(UIHumanStrings, SampleRateToStringAppendsHz) { - EXPECT_EQ(olive::HumanStrings::SampleRateToString(44100), + EXPECT_EQ(olive::HumanStrings::sample_rate_to_string(44100), QStringLiteral("44100 Hz")); - EXPECT_EQ(olive::HumanStrings::SampleRateToString(48000), + EXPECT_EQ(olive::HumanStrings::sample_rate_to_string(48000), QStringLiteral("48000 Hz")); - EXPECT_EQ(olive::HumanStrings::SampleRateToString(0), QStringLiteral("0 Hz")); + EXPECT_EQ(olive::HumanStrings::sample_rate_to_string(0), QStringLiteral("0 Hz")); } TEST(UIHumanStrings, KnownChannelLayoutsHaveNames) { - EXPECT_EQ(olive::HumanStrings::ChannelLayoutToString( - olive::kChannelLayoutMono), + EXPECT_EQ(olive::HumanStrings::channel_layout_to_string( + olive::k_channel_layout_mono), QStringLiteral("Mono")); - EXPECT_EQ(olive::HumanStrings::ChannelLayoutToString( - olive::kChannelLayoutStereo), + EXPECT_EQ(olive::HumanStrings::channel_layout_to_string( + olive::k_channel_layout_stereo), QStringLiteral("Stereo")); - EXPECT_EQ(olive::HumanStrings::ChannelLayoutToString( - olive::kChannelLayout2_1), + EXPECT_EQ(olive::HumanStrings::channel_layout_to_string( + olive::k_channel_layout2_1), QStringLiteral("2.1")); - EXPECT_EQ(olive::HumanStrings::ChannelLayoutToString( - olive::kChannelLayout5Point1), + EXPECT_EQ(olive::HumanStrings::channel_layout_to_string( + olive::k_channel_layout5_point1), QStringLiteral("5.1")); - EXPECT_EQ(olive::HumanStrings::ChannelLayoutToString( - olive::kChannelLayout7Point1), + EXPECT_EQ(olive::HumanStrings::channel_layout_to_string( + olive::k_channel_layout7_point1), QStringLiteral("7.1")); } TEST(UIHumanStrings, UnknownChannelLayoutFallsBackToHex) { - const QString s = olive::HumanStrings::ChannelLayoutToString(0x1234); + const QString s = olive::HumanStrings::channel_layout_to_string(0x1234); EXPECT_TRUE(s.startsWith(QStringLiteral("Unknown (0x"))); EXPECT_TRUE(s.contains(QStringLiteral("1234"))); @@ -43,11 +43,11 @@ TEST(UIHumanStrings, AllSampleFormatsHaveNonEmptyNames) using olive::core::SampleFormat; for (SampleFormat fmt : - { SampleFormat::U8, SampleFormat::S16, SampleFormat::S32, - SampleFormat::S64, SampleFormat::F32, SampleFormat::F64, - SampleFormat::U8P, SampleFormat::S16P, SampleFormat::S32P, - SampleFormat::S64P, SampleFormat::F32P, SampleFormat::F64P }) { - const QString s = olive::HumanStrings::FormatToString(fmt); + { SampleFormat::u8, SampleFormat::s16, SampleFormat::s32, + SampleFormat::s64, SampleFormat::f32, SampleFormat::f64, + SampleFormat::u8_p, SampleFormat::s16_p, SampleFormat::s32_p, + SampleFormat::s64_p, SampleFormat::f32_p, SampleFormat::f64_p }) { + const QString s = olive::HumanStrings::format_to_string(fmt); EXPECT_FALSE(s.isEmpty()); EXPECT_FALSE(s.startsWith(QStringLiteral("Unknown"))); } @@ -57,16 +57,16 @@ TEST(UIHumanStrings, PackedAndPlanarFormatsAreDistinguished) { using olive::core::SampleFormat; - EXPECT_TRUE(olive::HumanStrings::FormatToString(SampleFormat::F32) + EXPECT_TRUE(olive::HumanStrings::format_to_string(SampleFormat::f32) .contains(QStringLiteral("Packed"))); - EXPECT_TRUE(olive::HumanStrings::FormatToString(SampleFormat::F32P) + EXPECT_TRUE(olive::HumanStrings::format_to_string(SampleFormat::f32_p) .contains(QStringLiteral("Planar"))); } TEST(UIHumanStrings, InvalidSampleFormatFallsBackToHex) { - const QString s = olive::HumanStrings::FormatToString( - olive::core::SampleFormat::INVALID); + const QString s = olive::HumanStrings::format_to_string( + olive::core::SampleFormat::invalid); EXPECT_TRUE(s.startsWith(QStringLiteral("Unknown (0x"))); } diff --git a/tests/gtest/ui_icons_test.cpp b/tests/gtest/ui_icons_test.cpp index c3f511c70..fec2d6f92 100644 --- a/tests/gtest/ui_icons_test.cpp +++ b/tests/gtest/ui_icons_test.cpp @@ -19,7 +19,7 @@ TEST(UIIcons, ThemeResourcesAreRegistered) TEST(UIIcons, CreateLoadsAllSizes) { - QIcon icon = olive::icon::Create(QStringLiteral(":/style/olive-dark"), + QIcon icon = olive::icon::create(QStringLiteral(":/style/olive-dark"), QStringLiteral("play")); ASSERT_FALSE(icon.isNull()); @@ -34,7 +34,7 @@ TEST(UIIcons, CreateLoadsAllSizes) TEST(UIIcons, CreateWithUnknownNameYieldsNoUsableIcon) { - QIcon icon = olive::icon::Create(QStringLiteral(":/style/olive-dark"), + QIcon icon = olive::icon::create(QStringLiteral(":/style/olive-dark"), QStringLiteral("no-such-icon")); // QIcon::addFile() differs across Qt builds in whether entries for @@ -47,73 +47,73 @@ TEST(UIIcons, CreateWithUnknownNameYieldsNoUsableIcon) TEST(UIIcons, LoadAllPopulatesGlobalIcons) { - olive::icon::LoadAll(QStringLiteral(":/style/olive-dark")); + olive::icon::load_all(QStringLiteral(":/style/olive-dark")); - const QVector all = { &olive::icon::GoToStart, - &olive::icon::PrevFrame, - &olive::icon::Play, - &olive::icon::Pause, - &olive::icon::NextFrame, - &olive::icon::GoToEnd, + const QVector all = { &olive::icon::go_to_start, + &olive::icon::prev_frame, + &olive::icon::play, + &olive::icon::pause, + &olive::icon::next_frame, + &olive::icon::go_to_end, &olive::icon::New, - &olive::icon::Open, - &olive::icon::Save, - &olive::icon::Undo, - &olive::icon::Redo, - &olive::icon::TreeView, - &olive::icon::ListView, - &olive::icon::IconView, - &olive::icon::ToolPointer, - &olive::icon::ToolEdit, - &olive::icon::ToolRipple, - &olive::icon::ToolRolling, - &olive::icon::ToolRazor, - &olive::icon::ToolSlip, - &olive::icon::ToolSlide, - &olive::icon::ToolHand, - &olive::icon::ToolTransition, - &olive::icon::ToolTrackSelect, - &olive::icon::Folder, - &olive::icon::Sequence, - &olive::icon::Video, - &olive::icon::Audio, - &olive::icon::Image, - &olive::icon::MiniMap, - &olive::icon::TriUp, - &olive::icon::TriLeft, - &olive::icon::TriDown, - &olive::icon::TriRight, - &olive::icon::TextBold, - &olive::icon::TextItalic, - &olive::icon::TextUnderline, - &olive::icon::TextStrikethrough, - &olive::icon::TextSmallCaps, - &olive::icon::TextAlignLeft, - &olive::icon::TextAlignRight, - &olive::icon::TextAlignCenter, - &olive::icon::TextAlignJustify, - &olive::icon::TextAlignTop, - &olive::icon::TextAlignBottom, - &olive::icon::TextAlignMiddle, - &olive::icon::Snapping, - &olive::icon::ZoomIn, - &olive::icon::ZoomOut, - &olive::icon::Record, - &olive::icon::Add, - &olive::icon::Error, - &olive::icon::DirUp, - &olive::icon::Clock, - &olive::icon::Diamond, - &olive::icon::Plus, - &olive::icon::Minus, - &olive::icon::AddEffect, - &olive::icon::EyeOpened, - &olive::icon::EyeClosed, - &olive::icon::LockOpened, - &olive::icon::LockClosed, - &olive::icon::Pencil, - &olive::icon::Subtitles, - &olive::icon::ColorPicker }; + &olive::icon::open, + &olive::icon::save, + &olive::icon::undo, + &olive::icon::redo, + &olive::icon::tree_view, + &olive::icon::list_view, + &olive::icon::icon_view, + &olive::icon::tool_pointer, + &olive::icon::tool_edit, + &olive::icon::tool_ripple, + &olive::icon::tool_rolling, + &olive::icon::tool_razor, + &olive::icon::tool_slip, + &olive::icon::tool_slide, + &olive::icon::tool_hand, + &olive::icon::tool_transition, + &olive::icon::tool_track_select, + &olive::icon::folder, + &olive::icon::sequence, + &olive::icon::video, + &olive::icon::audio, + &olive::icon::image, + &olive::icon::mini_map, + &olive::icon::tri_up, + &olive::icon::tri_left, + &olive::icon::tri_down, + &olive::icon::tri_right, + &olive::icon::text_bold, + &olive::icon::text_italic, + &olive::icon::text_underline, + &olive::icon::text_strikethrough, + &olive::icon::text_small_caps, + &olive::icon::text_align_left, + &olive::icon::text_align_right, + &olive::icon::text_align_center, + &olive::icon::text_align_justify, + &olive::icon::text_align_top, + &olive::icon::text_align_bottom, + &olive::icon::text_align_middle, + &olive::icon::snapping, + &olive::icon::zoom_in, + &olive::icon::zoom_out, + &olive::icon::record, + &olive::icon::add, + &olive::icon::error, + &olive::icon::dir_up, + &olive::icon::clock, + &olive::icon::diamond, + &olive::icon::plus, + &olive::icon::minus, + &olive::icon::add_effect, + &olive::icon::eye_opened, + &olive::icon::eye_closed, + &olive::icon::lock_opened, + &olive::icon::lock_closed, + &olive::icon::pencil, + &olive::icon::subtitles, + &olive::icon::color_picker }; for (const QIcon *icon : all) { EXPECT_FALSE(icon->isNull()); diff --git a/tests/gtest/ui_style_test.cpp b/tests/gtest/ui_style_test.cpp index e69b262a6..810ac0902 100644 --- a/tests/gtest/ui_style_test.cpp +++ b/tests/gtest/ui_style_test.cpp @@ -9,7 +9,7 @@ TEST(UIStyle, InitPopulatesThemesAndAppliesStyle) { - olive::StyleManager::Init(); + olive::StyleManager::init(); const QMap &themes = olive::StyleManager::available_themes(); EXPECT_EQ(themes.size(), 2); @@ -19,14 +19,14 @@ TEST(UIStyle, InitPopulatesThemesAndAppliesStyle) QStringLiteral("Oak Light")); // Whatever the config says, the current style must be a known theme - EXPECT_TRUE(themes.contains(olive::StyleManager::GetStyle())); + EXPECT_TRUE(themes.contains(olive::StyleManager::get_style())); EXPECT_FALSE(qApp->styleSheet().isEmpty()); } TEST(UIStyle, SetStyleAppliesPaletteFromIni) { - olive::StyleManager::SetStyle(QStringLiteral("olive-dark")); - EXPECT_EQ(olive::StyleManager::GetStyle(), QStringLiteral("olive-dark")); + olive::StyleManager::set_style(QStringLiteral("olive-dark")); + EXPECT_EQ(olive::StyleManager::get_style(), QStringLiteral("olive-dark")); // Values from app/ui/style/olive-dark/palette.ini const QPalette p = qApp->palette(); @@ -44,11 +44,11 @@ TEST(UIStyle, SetStyleAppliesPaletteFromIni) TEST(UIStyle, SetStyleSwitchesThemes) { - olive::StyleManager::SetStyle(QStringLiteral("olive-dark")); + olive::StyleManager::set_style(QStringLiteral("olive-dark")); const QColor dark_window = qApp->palette().color(QPalette::Window); - olive::StyleManager::SetStyle(QStringLiteral("olive-light")); - EXPECT_EQ(olive::StyleManager::GetStyle(), QStringLiteral("olive-light")); + olive::StyleManager::set_style(QStringLiteral("olive-light")); + EXPECT_EQ(olive::StyleManager::get_style(), QStringLiteral("olive-light")); // Values from app/ui/style/olive-light/palette.ini EXPECT_EQ(qApp->palette().color(QPalette::Window), @@ -56,15 +56,15 @@ TEST(UIStyle, SetStyleSwitchesThemes) EXPECT_NE(qApp->palette().color(QPalette::Window), dark_window); // Restore the default theme for subsequent tests - olive::StyleManager::SetStyle(olive::StyleManager::kDefaultStyle); - EXPECT_EQ(olive::StyleManager::GetStyle(), + olive::StyleManager::set_style(olive::StyleManager::k_default_style); + EXPECT_EQ(olive::StyleManager::get_style(), QStringLiteral("olive-dark")); } TEST(UIStyle, SetStyleWithMissingThemeClearsOverrides) { - olive::StyleManager::SetStyle(QStringLiteral("does-not-exist")); - EXPECT_EQ(olive::StyleManager::GetStyle(), + olive::StyleManager::set_style(QStringLiteral("does-not-exist")); + EXPECT_EQ(olive::StyleManager::get_style(), QStringLiteral("does-not-exist")); // No palette.ini/style.css in this theme: fall back to standard palette @@ -74,5 +74,5 @@ TEST(UIStyle, SetStyleWithMissingThemeClearsOverrides) qApp->style()->standardPalette().color(QPalette::Window)); // Restore the default theme for subsequent tests - olive::StyleManager::SetStyle(olive::StyleManager::kDefaultStyle); + olive::StyleManager::set_style(olive::StyleManager::k_default_style); } diff --git a/tests/gtest/undo_stack_test.cpp b/tests/gtest/undo_stack_test.cpp index 416dd8786..e4a4f095d 100644 --- a/tests/gtest/undo_stack_test.cpp +++ b/tests/gtest/undo_stack_test.cpp @@ -14,7 +14,7 @@ public: { } - olive::Project *GetRelevantProject() const override + olive::Project *get_relevant_project() const override { return nullptr; } @@ -54,8 +54,8 @@ TEST(UndoStack, PushUndoRedo) TEST(UndoStack, EmptyStateAndModelData) { olive::UndoStack stack; - EXPECT_FALSE(stack.CanUndo()); - EXPECT_FALSE(stack.CanRedo()); + EXPECT_FALSE(stack.can_undo()); + EXPECT_FALSE(stack.can_redo()); EXPECT_EQ(stack.columnCount(), 2); EXPECT_EQ(stack.rowCount(), 1); EXPECT_TRUE(stack.hasChildren(QModelIndex())); @@ -80,7 +80,7 @@ TEST(UndoStack, UndoRedoListsAndColors) stack.undo(); EXPECT_EQ(counter, 1); - EXPECT_TRUE(stack.CanRedo()); + EXPECT_TRUE(stack.can_redo()); QModelIndex undone_name = stack.index(2, 1); EXPECT_EQ(stack.data(undone_name, Qt::DisplayRole).toString(), @@ -91,7 +91,7 @@ TEST(UndoStack, UndoRedoListsAndColors) stack.redo(); EXPECT_EQ(counter, 2); - EXPECT_FALSE(stack.CanRedo()); + EXPECT_FALSE(stack.can_redo()); } TEST(UndoStack, JumpRestoresState) @@ -106,11 +106,11 @@ TEST(UndoStack, JumpRestoresState) stack.jump(1); EXPECT_EQ(counter, 0); - EXPECT_TRUE(stack.CanRedo()); + EXPECT_TRUE(stack.can_redo()); stack.jump(4); EXPECT_EQ(counter, 3); - EXPECT_FALSE(stack.CanRedo()); + EXPECT_FALSE(stack.can_redo()); } TEST(UndoStack, EmptyMultiUndoCommandIsIgnored) @@ -119,7 +119,7 @@ TEST(UndoStack, EmptyMultiUndoCommandIsIgnored) auto *empty_multi = new olive::MultiUndoCommand(); stack.push(empty_multi, QStringLiteral("Empty")); EXPECT_EQ(stack.rowCount(), 1); - EXPECT_FALSE(stack.CanUndo()); + EXPECT_FALSE(stack.can_undo()); } TEST(UndoStack, MultipleUndosAndRedos) @@ -134,8 +134,8 @@ TEST(UndoStack, MultipleUndosAndRedos) stack.undo(); stack.undo(); EXPECT_EQ(counter, 1); - EXPECT_TRUE(stack.CanUndo()); - EXPECT_TRUE(stack.CanRedo()); + EXPECT_TRUE(stack.can_undo()); + EXPECT_TRUE(stack.can_redo()); stack.redo(); EXPECT_EQ(counter, 2); @@ -154,7 +154,7 @@ TEST(UndoStack, PushAfterUndoClearsRedoBranch) stack.push(new TestCommand(&counter), QStringLiteral("Third")); EXPECT_EQ(counter, 2); - EXPECT_FALSE(stack.CanRedo()); + EXPECT_FALSE(stack.can_redo()); } TEST(UndoStack, ResetClearsHistory) @@ -165,8 +165,8 @@ TEST(UndoStack, ResetClearsHistory) EXPECT_EQ(counter, 1); stack.clear(); - EXPECT_FALSE(stack.CanUndo()); - EXPECT_FALSE(stack.CanRedo()); + EXPECT_FALSE(stack.can_undo()); + EXPECT_FALSE(stack.can_redo()); EXPECT_EQ(stack.rowCount(), 1); } diff --git a/tests/gtest/viewer_display_repro_test.cpp b/tests/gtest/viewer_display_repro_test.cpp index 8143e487f..9dcab12e5 100644 --- a/tests/gtest/viewer_display_repro_test.cpp +++ b/tests/gtest/viewer_display_repro_test.cpp @@ -48,13 +48,13 @@ using namespace olive; namespace { -QString DemoVideoPathT() +QString demo_video_path_t() { return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR)) .filePath(QStringLiteral("tests/demo.mp4")); } -QString WorkerBinaryPathT() +QString worker_binary_path_t() { QDir dir(QCoreApplication::applicationDirPath()); dir.cdUp(); @@ -70,37 +70,37 @@ QString WorkerBinaryPathT() // Loads and initializes the requested render backend the same way the // application does, verifying that the loaded backend is actually of the // requested kind (a Vulkan request that fell back to OpenGL does not count). -bool IsRenderBackendAvailable(const QString &backend) +bool is_render_backend_available(const QString &backend) { #ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND olive::DynamicRenderer renderer(backend); - if (!renderer.Load()) { + if (!renderer.load()) { return false; } OakRenderBackendInfo info = {}; - if (!renderer.GetBackendInfo(&info)) { + if (!renderer.get_backend_info(&info)) { return false; } if (backend == QStringLiteral("vulkan") && - info.kind != OAK_RENDER_BACKEND_VULKAN) { + info.kind != oak_render_backend_vulkan) { return false; } if (backend == QStringLiteral("opengl") && - info.kind != OAK_RENDER_BACKEND_OPENGL) { + info.kind != oak_render_backend_opengl) { return false; } - return renderer.Init(); + return renderer.init(); #else Q_UNUSED(backend) return false; #endif } -double BrightnessOfWidget(QWidget *w) +double brightness_of_widget(QWidget *w) { QPixmap pm = w->grab(); QImage img = pm.toImage().convertToFormat(QImage::Format_RGB32); @@ -137,16 +137,16 @@ class ViewerDisplayReproTest : public ::testing::TestWithParam { protected: static void SetUpTestSuite() { - NodeFactory::Initialize(); - ColorManager::SetUpDefaultConfig(); - TaskManager::CreateInstance(); - ConformManager::CreateInstance(); - ProxyManager::CreateInstance(); - FrameManager::CreateInstance(); - ProjectSerializer::Initialize(); - DiskManager::CreateInstance(); + NodeFactory::initialize(); + ColorManager::set_up_default_config(); + TaskManager::create_instance(); + ConformManager::create_instance(); + ProxyManager::create_instance(); + FrameManager::create_instance(); + ProjectSerializer::initialize(); + DiskManager::create_instance(); - const QString worker = WorkerBinaryPathT(); + const QString worker = worker_binary_path_t(); if (QFileInfo::exists(worker)) { qputenv("OAK_RENDER_WORKER", QFile::encodeName(worker)); } @@ -154,19 +154,19 @@ protected: if (!Core::instance()) { new Core(Core::CoreParams()); } - AudioManager::CreateInstance(); + AudioManager::create_instance(); } static void TearDownTestSuite() { - AudioManager::DestroyInstance(); - DiskManager::DestroyInstance(); - ProjectSerializer::Destroy(); - FrameManager::DestroyInstance(); - ProxyManager::DestroyInstance(); - ConformManager::DestroyInstance(); - TaskManager::DestroyInstance(); - NodeFactory::Destroy(); + AudioManager::destroy_instance(); + DiskManager::destroy_instance(); + ProjectSerializer::destroy(); + FrameManager::destroy_instance(); + ProxyManager::destroy_instance(); + ConformManager::destroy_instance(); + TaskManager::destroy_instance(); + NodeFactory::destroy(); } void SetUp() override @@ -175,44 +175,44 @@ protected: if (backend_ != QStringLiteral("vulkan")) { GTEST_SKIP() << "offscreen QOpenGLWidget cannot paint; Vulkan only"; } - if (!IsRenderBackendAvailable(backend_)) { + if (!is_render_backend_available(backend_)) { GTEST_SKIP() << "Render backend is not available: " << backend_.toStdString(); } - Config::Current()[QStringLiteral("GraphicsBackend")] = backend_; + Config::current()[QStringLiteral("GraphicsBackend")] = backend_; - demo_path_ = DemoVideoPathT(); + demo_path_ = demo_video_path_t(); ASSERT_TRUE(QFileInfo::exists(demo_path_)); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); footage_ = new Footage(demo_path_); footage_->setParent(project_.get()); - ASSERT_TRUE(footage_->IsValid()); + ASSERT_TRUE(footage_->is_valid()); - RenderManager::CreateInstance(); - RenderManager::instance()->GetCacher()->SetProject(project_.get()); + RenderManager::create_instance(); + RenderManager::instance()->get_cacher()->set_project(project_.get()); } void TearDown() override { // May be null when SetUp() skipped before creating the instance. if (RenderManager::instance()) { - RenderManager::instance()->GetCacher()->SetProject(nullptr); - RenderManager::DestroyInstance(); + RenderManager::instance()->get_cacher()->set_project(nullptr); + RenderManager::destroy_instance(); } project_.reset(); } // Pumps the event loop until the display widget has a texture or timeout. - bool WaitForTexture(ViewerDisplayWidget *display, int timeout_ms = 30000) + bool wait_for_texture(ViewerDisplayWidget *display, int timeout_ms = 30000) { QElapsedTimer timer; timer.start(); while (!timer.hasExpired(timeout_ms)) { QCoreApplication::processEvents(QEventLoop::AllEvents, 50); - if (display->GetCurrentTexture()) { + if (display->get_current_texture()) { // Let a few more paints happen for (int i = 0; i < 5; i++) { QCoreApplication::processEvents(QEventLoop::AllEvents, 50); @@ -239,13 +239,13 @@ TEST_P(ViewerDisplayReproTest, FootageViewerNotBlack) viewer->resize(800, 600); viewer->show(); - viewer->ConnectViewerNode(footage_); + viewer->connect_viewer_node(footage_); - ASSERT_TRUE(WaitForTexture(viewer->display_widget())) + ASSERT_TRUE(wait_for_texture(viewer->display_widget())) << "Display widget never received a texture (backend=" << backend_.toStdString() << ")"; - double brightness = BrightnessOfWidget(viewer->display_widget()); + double brightness = brightness_of_widget(viewer->display_widget()); EXPECT_GT(brightness, 0.01) << "Footage viewer paints BLACK (brightness=" << brightness << ", backend=" << backend_.toStdString() << ")"; @@ -262,20 +262,20 @@ TEST_P(ViewerDisplayReproTest, SequenceViewerIndirectNotBlack) OpacityEffect *opacity = new OpacityEffect(); opacity->setParent(project_.get()); - Node::ConnectEdge(footage_, NodeInput(opacity, OpacityEffect::kTextureInput)); - Node::ConnectEdge(opacity, NodeInput(sequence, ViewerOutput::kTextureInput)); + Node::connect_edge(footage_, NodeInput(opacity, OpacityEffect::k_texture_input)); + Node::connect_edge(opacity, NodeInput(sequence, ViewerOutput::k_texture_input)); TestViewerWidget *viewer = new TestViewerWidget(); viewer->resize(800, 600); viewer->show(); - viewer->ConnectViewerNode(sequence); + viewer->connect_viewer_node(sequence); - ASSERT_TRUE(WaitForTexture(viewer->display_widget())) + ASSERT_TRUE(wait_for_texture(viewer->display_widget())) << "Display widget never received a texture (backend=" << backend_.toStdString() << ")"; - double brightness = BrightnessOfWidget(viewer->display_widget()); + double brightness = brightness_of_widget(viewer->display_widget()); EXPECT_GT(brightness, 0.01) << "Sequence viewer (indirect) paints BLACK (brightness=" << brightness << ", backend=" << backend_.toStdString() << ")"; @@ -290,20 +290,20 @@ TEST_P(ViewerDisplayReproTest, SequenceViewerDirectNotBlack) Sequence *sequence = new Sequence(); sequence->setParent(project_.get()); - Node::ConnectEdge(footage_, - NodeInput(sequence, ViewerOutput::kTextureInput)); + Node::connect_edge(footage_, + NodeInput(sequence, ViewerOutput::k_texture_input)); TestViewerWidget *viewer = new TestViewerWidget(); viewer->resize(800, 600); viewer->show(); - viewer->ConnectViewerNode(sequence); + viewer->connect_viewer_node(sequence); - ASSERT_TRUE(WaitForTexture(viewer->display_widget())) + ASSERT_TRUE(wait_for_texture(viewer->display_widget())) << "Display widget never received a texture (backend=" << backend_.toStdString() << ")"; - double brightness = BrightnessOfWidget(viewer->display_widget()); + double brightness = brightness_of_widget(viewer->display_widget()); EXPECT_GT(brightness, 0.01) << "Sequence viewer (direct) paints BLACK (brightness=" << brightness << ", backend=" << backend_.toStdString() << ")"; @@ -320,12 +320,12 @@ INSTANTIATE_TEST_SUITE_P(Backends, ViewerDisplayReproTest, // directly to the output. Vulkan only (offscreen QOpenGLWidget cannot paint). class ViewerRuntimeRewireTest : public ViewerDisplayReproTest { protected: - double PumpAndMeasure(TestViewerWidget *viewer, int timeout_ms = 30000) + double pump_and_measure(TestViewerWidget *viewer, int timeout_ms = 30000) { - if (!WaitForTexture(viewer->display_widget(), timeout_ms)) { + if (!wait_for_texture(viewer->display_widget(), timeout_ms)) { return -1.0; } - return BrightnessOfWidget(viewer->display_widget()); + return brightness_of_widget(viewer->display_widget()); } }; @@ -337,26 +337,26 @@ TEST_P(ViewerRuntimeRewireTest, RewireToDirectConnectionNotBlack) // Normal chain with a node in between: footage -> opacity -> sequence OpacityEffect *opacity = new OpacityEffect(); opacity->setParent(project_.get()); - Node::ConnectEdge(footage_, - NodeInput(opacity, OpacityEffect::kTextureInput)); - Node::ConnectEdge(opacity, NodeInput(sequence, ViewerOutput::kTextureInput)); + Node::connect_edge(footage_, + NodeInput(opacity, OpacityEffect::k_texture_input)); + Node::connect_edge(opacity, NodeInput(sequence, ViewerOutput::k_texture_input)); TestViewerWidget *viewer = new TestViewerWidget(); viewer->resize(800, 600); viewer->show(); - viewer->ConnectViewerNode(sequence); + viewer->connect_viewer_node(sequence); - double brightness = PumpAndMeasure(viewer); + double brightness = pump_and_measure(viewer); ASSERT_GT(brightness, 0.01) << "Precondition failed: indirect chain is already black"; // Now rewire at runtime: footage directly to the sequence output. - Node::DisconnectEdge(opacity, - NodeInput(sequence, ViewerOutput::kTextureInput)); - Node::ConnectEdge(footage_, - NodeInput(sequence, ViewerOutput::kTextureInput)); + Node::disconnect_edge(opacity, + NodeInput(sequence, ViewerOutput::k_texture_input)); + Node::connect_edge(footage_, + NodeInput(sequence, ViewerOutput::k_texture_input)); - brightness = PumpAndMeasure(viewer); + brightness = pump_and_measure(viewer); EXPECT_GT(brightness, 0.01) << "Viewer paints BLACK after rewiring to a direct connection " << "(brightness=" << brightness << ")"; @@ -370,28 +370,28 @@ TEST_P(ViewerRuntimeRewireTest, RewireToIndirectConnectionNotBlack) sequence->setParent(project_.get()); // Start direct: footage -> sequence - Node::ConnectEdge(footage_, - NodeInput(sequence, ViewerOutput::kTextureInput)); + Node::connect_edge(footage_, + NodeInput(sequence, ViewerOutput::k_texture_input)); TestViewerWidget *viewer = new TestViewerWidget(); viewer->resize(800, 600); viewer->show(); - viewer->ConnectViewerNode(sequence); + viewer->connect_viewer_node(sequence); - double brightness = PumpAndMeasure(viewer); + double brightness = pump_and_measure(viewer); ASSERT_GT(brightness, 0.01) << "Precondition failed: direct chain is already black"; // Insert a node at runtime: footage -> opacity -> sequence OpacityEffect *opacity = new OpacityEffect(); opacity->setParent(project_.get()); - Node::DisconnectEdge(footage_, - NodeInput(sequence, ViewerOutput::kTextureInput)); - Node::ConnectEdge(footage_, - NodeInput(opacity, OpacityEffect::kTextureInput)); - Node::ConnectEdge(opacity, NodeInput(sequence, ViewerOutput::kTextureInput)); + Node::disconnect_edge(footage_, + NodeInput(sequence, ViewerOutput::k_texture_input)); + Node::connect_edge(footage_, + NodeInput(opacity, OpacityEffect::k_texture_input)); + Node::connect_edge(opacity, NodeInput(sequence, ViewerOutput::k_texture_input)); - brightness = PumpAndMeasure(viewer); + brightness = pump_and_measure(viewer); EXPECT_GT(brightness, 0.01) << "Viewer paints BLACK after rewiring to an indirect connection " << "(brightness=" << brightness << ")"; diff --git a/tests/gtest/viewer_smoke_test.cpp b/tests/gtest/viewer_smoke_test.cpp index f2ed4553c..15a709bd0 100644 --- a/tests/gtest/viewer_smoke_test.cpp +++ b/tests/gtest/viewer_smoke_test.cpp @@ -48,8 +48,8 @@ TEST(ViewerSmokeTimer, DefaultConstruction) ViewerPlaybackTimer timer; // After Start() is called, the timer must return valid timestamps - timer.Start(0, 1, 1.0 / 24.0); - EXPECT_GE(timer.GetTimestampNow(), 0); + timer.start(0, 1, 1.0 / 24.0); + EXPECT_GE(timer.get_timestamp_now(), 0); } TEST(ViewerSmokeTimer, BasicTiming) @@ -57,15 +57,15 @@ TEST(ViewerSmokeTimer, BasicTiming) ViewerPlaybackTimer timer; // Start at timestamp 0, 1x speed, 24fps (timebase = 1/24) - timer.Start(0, 1, 1.0 / 24.0); + timer.start(0, 1, 1.0 / 24.0); // Immediately get timestamp (should be close to 0) - int64_t ts = timer.GetTimestampNow(); + int64_t ts = timer.get_timestamp_now(); EXPECT_GE(ts, 0); // Wait a bit and check timestamp has increased QThread::msleep(50); // 50ms - int64_t ts2 = timer.GetTimestampNow(); + int64_t ts2 = timer.get_timestamp_now(); // At 24fps, 50ms is more than one frame period (~41.7ms), so the // timestamp must have advanced by at least one frame @@ -77,11 +77,11 @@ TEST(ViewerSmokeTimer, PlaybackSpeedForward) ViewerPlaybackTimer timer; // Start at timestamp 100, 2x speed, 30fps - timer.Start(100, 2, 1.0 / 30.0); + timer.start(100, 2, 1.0 / 30.0); - int64_t ts1 = timer.GetTimestampNow(); + int64_t ts1 = timer.get_timestamp_now(); QThread::msleep(50); - int64_t ts2 = timer.GetTimestampNow(); + int64_t ts2 = timer.get_timestamp_now(); // At 2x speed, time should advance twice as fast EXPECT_GT(ts2, ts1); @@ -92,11 +92,11 @@ TEST(ViewerSmokeTimer, PlaybackSpeedReverse) ViewerPlaybackTimer timer; // Start at timestamp 1000, -1x speed (reverse), 24fps - timer.Start(1000, -1, 1.0 / 24.0); + timer.start(1000, -1, 1.0 / 24.0); - int64_t ts1 = timer.GetTimestampNow(); + int64_t ts1 = timer.get_timestamp_now(); QThread::msleep(50); - int64_t ts2 = timer.GetTimestampNow(); + int64_t ts2 = timer.get_timestamp_now(); // In reverse, timestamp should decrease EXPECT_LT(ts2, ts1); @@ -110,11 +110,11 @@ TEST(ViewerSmokeTimer, DifferentTimebases) for (double fps : { 24.0, 60.0 }) { ViewerPlaybackTimer timer; QElapsedTimer wall; - timer.Start(0, 1, 1.0 / fps); + timer.start(0, 1, 1.0 / fps); wall.start(); QThread::msleep(100); - const int64_t ts = timer.GetTimestampNow(); + const int64_t ts = timer.get_timestamp_now(); const int64_t expected = qFloor(static_cast(wall.elapsed()) / (1000.0 / fps)); EXPECT_NEAR(ts, expected, 1) << "fps=" << fps; @@ -123,11 +123,11 @@ TEST(ViewerSmokeTimer, DifferentTimebases) // With highly distinct timebases the faster one always produces more // frames in the same interval, even on heavily loaded machines ViewerPlaybackTimer slow, fast; - slow.Start(0, 1, 1.0); - fast.Start(0, 1, 1.0 / 240.0); + slow.start(0, 1, 1.0); + fast.start(0, 1, 1.0 / 240.0); QThread::msleep(100); - EXPECT_LT(slow.GetTimestampNow(), fast.GetTimestampNow()); + EXPECT_LT(slow.get_timestamp_now(), fast.get_timestamp_now()); } TEST(ViewerSmokeTimer, ZeroSpeed) @@ -135,11 +135,11 @@ TEST(ViewerSmokeTimer, ZeroSpeed) ViewerPlaybackTimer timer; // Start with 0 speed (paused) - timer.Start(500, 0, 1.0 / 24.0); + timer.start(500, 0, 1.0 / 24.0); - int64_t ts1 = timer.GetTimestampNow(); + int64_t ts1 = timer.get_timestamp_now(); QThread::msleep(50); - int64_t ts2 = timer.GetTimestampNow(); + int64_t ts2 = timer.get_timestamp_now(); // With 0 speed, timestamp should not change EXPECT_EQ(ts1, ts2); @@ -160,23 +160,23 @@ TEST(ViewerSmokeQueue, AppendForwardPlayback) ViewerQueue queue; // Append frames for forward playback - ViewerPlaybackFrame frame1{ rational(0), QVariant() }; - ViewerPlaybackFrame frame2{ rational(1, 24), QVariant() }; - ViewerPlaybackFrame frame3{ rational(2, 24), QVariant() }; + ViewerPlaybackFrame frame1{ Rational(0), QVariant() }; + ViewerPlaybackFrame frame2{ Rational(1, 24), QVariant() }; + ViewerPlaybackFrame frame3{ Rational(2, 24), QVariant() }; - queue.AppendTimewise(frame1, 1); // speed = 1 (forward) - queue.AppendTimewise(frame2, 1); - queue.AppendTimewise(frame3, 1); + queue.append_timewise(frame1, 1); // speed = 1 (forward) + queue.append_timewise(frame2, 1); + queue.append_timewise(frame3, 1); EXPECT_EQ(queue.size(), 3); // Verify order (should be chronological for forward playback) auto it = queue.begin(); - EXPECT_EQ(it->timestamp, rational(0)); + EXPECT_EQ(it->timestamp, Rational(0)); ++it; - EXPECT_EQ(it->timestamp, rational(1, 24)); + EXPECT_EQ(it->timestamp, Rational(1, 24)); ++it; - EXPECT_EQ(it->timestamp, rational(2, 24)); + EXPECT_EQ(it->timestamp, Rational(2, 24)); } TEST(ViewerSmokeQueue, AppendReversePlayback) @@ -184,23 +184,23 @@ TEST(ViewerSmokeQueue, AppendReversePlayback) ViewerQueue queue; // Append frames for reverse playback - ViewerPlaybackFrame frame1{ rational(2, 24), QVariant() }; - ViewerPlaybackFrame frame2{ rational(1, 24), QVariant() }; - ViewerPlaybackFrame frame3{ rational(0), QVariant() }; + ViewerPlaybackFrame frame1{ Rational(2, 24), QVariant() }; + ViewerPlaybackFrame frame2{ Rational(1, 24), QVariant() }; + ViewerPlaybackFrame frame3{ Rational(0), QVariant() }; - queue.AppendTimewise(frame1, -1); // speed = -1 (reverse) - queue.AppendTimewise(frame2, -1); - queue.AppendTimewise(frame3, -1); + queue.append_timewise(frame1, -1); // speed = -1 (reverse) + queue.append_timewise(frame2, -1); + queue.append_timewise(frame3, -1); EXPECT_EQ(queue.size(), 3); // Verify order (should be reverse chronological for reverse playback) auto it = queue.begin(); - EXPECT_EQ(it->timestamp, rational(2, 24)); + EXPECT_EQ(it->timestamp, Rational(2, 24)); ++it; - EXPECT_EQ(it->timestamp, rational(1, 24)); + EXPECT_EQ(it->timestamp, Rational(1, 24)); ++it; - EXPECT_EQ(it->timestamp, rational(0)); + EXPECT_EQ(it->timestamp, Rational(0)); } TEST(ViewerSmokeQueue, InsertOutOfOrder) @@ -208,23 +208,23 @@ TEST(ViewerSmokeQueue, InsertOutOfOrder) ViewerQueue queue; // Insert frames out of order for forward playback - ViewerPlaybackFrame frame1{ rational(0), QVariant() }; - ViewerPlaybackFrame frame2{ rational(2, 24), QVariant() }; - ViewerPlaybackFrame frame3{ rational(1, 24), QVariant() }; // Middle frame + ViewerPlaybackFrame frame1{ Rational(0), QVariant() }; + ViewerPlaybackFrame frame2{ Rational(2, 24), QVariant() }; + ViewerPlaybackFrame frame3{ Rational(1, 24), QVariant() }; // Middle frame - queue.AppendTimewise(frame1, 1); - queue.AppendTimewise(frame2, 1); - queue.AppendTimewise(frame3, 1); // Should insert in middle + queue.append_timewise(frame1, 1); + queue.append_timewise(frame2, 1); + queue.append_timewise(frame3, 1); // Should insert in middle EXPECT_EQ(queue.size(), 3); // Verify correct order auto it = queue.begin(); - EXPECT_EQ(it->timestamp, rational(0)); + EXPECT_EQ(it->timestamp, Rational(0)); ++it; - EXPECT_EQ(it->timestamp, rational(1, 24)); + EXPECT_EQ(it->timestamp, Rational(1, 24)); ++it; - EXPECT_EQ(it->timestamp, rational(2, 24)); + EXPECT_EQ(it->timestamp, Rational(2, 24)); } TEST(ViewerSmokeQueue, PurgeBefore) @@ -233,18 +233,18 @@ TEST(ViewerSmokeQueue, PurgeBefore) // Add some frames for (int i = 0; i < 10; i++) { - ViewerPlaybackFrame frame{ rational(i, 24), QVariant() }; - queue.AppendTimewise(frame, 1); + ViewerPlaybackFrame frame{ Rational(i, 24), QVariant() }; + queue.append_timewise(frame, 1); } EXPECT_EQ(queue.size(), 10); // Purge frames before 5/24 - queue.PurgeBefore(rational(5, 24), 1); + queue.purge_before(Rational(5, 24), 1); // Should have 5 frames remaining (5, 6, 7, 8, 9) EXPECT_EQ(queue.size(), 5); - EXPECT_EQ(queue.front().timestamp, rational(5, 24)); + EXPECT_EQ(queue.front().timestamp, Rational(5, 24)); } TEST(ViewerSmokeQueue, PurgeBeforeReverse) @@ -253,19 +253,19 @@ TEST(ViewerSmokeQueue, PurgeBeforeReverse) // Add frames for reverse playback (newest first) for (int i = 9; i >= 0; i--) { - ViewerPlaybackFrame frame{ rational(i, 24), QVariant() }; - queue.AppendTimewise(frame, -1); + ViewerPlaybackFrame frame{ Rational(i, 24), QVariant() }; + queue.append_timewise(frame, -1); } EXPECT_EQ(queue.size(), 10); // In reverse playback, front() is the largest timestamp (9/24) // PurgeBefore with negative speed removes frames where front > time - queue.PurgeBefore(rational(5, 24), -1); + queue.purge_before(Rational(5, 24), -1); // Should have frames 0-5 remaining (those <= 5/24) EXPECT_EQ(queue.size(), 6); - EXPECT_EQ(queue.front().timestamp, rational(5, 24)); + EXPECT_EQ(queue.front().timestamp, Rational(5, 24)); } // ============================================================================ @@ -336,19 +336,19 @@ TEST(ViewerSmokeAudioCache, DefaultConstruction) AudioPlaybackCache cache; // A fresh cache has invalid (unset) audio parameters and no validated ranges - EXPECT_FALSE(cache.GetParameters().is_valid()); - EXPECT_TRUE(cache.GetValidatedRanges().isEmpty()); + EXPECT_FALSE(cache.get_parameters().is_valid()); + EXPECT_TRUE(cache.get_validated_ranges().isEmpty()); } TEST(ViewerSmokeAudioCache, ParameterSetters) { AudioPlaybackCache cache; - AudioParams params(48000, kChannelLayoutStereo, SampleFormat::F32P); - cache.SetParameters(params); + AudioParams params(48000, k_channel_layout_stereo, SampleFormat::f32_p); + cache.set_parameters(params); // Parameters should be retrievable - AudioParams retrieved = cache.GetParameters(); + AudioParams retrieved = cache.get_parameters(); EXPECT_EQ(retrieved.sample_rate(), params.sample_rate()); } @@ -357,7 +357,7 @@ TEST(ViewerSmokeAudioCache, ValidateWithRange) AudioPlaybackCache cache; // Initially no validated ranges - TimeRangeList validated = cache.GetValidatedRanges(); + TimeRangeList validated = cache.get_validated_ranges(); EXPECT_TRUE(validated.isEmpty()); } @@ -371,35 +371,35 @@ class ViewerSmokeAutoCacherTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); // Use the dummy render backend so PreviewAutoCacher can be exercised // without initializing OpenGL/Vulkan in the unit-test process. - OLIVE_CONFIG("GraphicsBackend") = QStringLiteral("dummy"); + OAK_CONFIG("GraphicsBackend") = QStringLiteral("dummy"); - DiskManager::CreateInstance(); - ConformManager::CreateInstance(); - RenderManager::CreateInstance(); + DiskManager::create_instance(); + ConformManager::create_instance(); + RenderManager::create_instance(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override { project_.reset(); - RenderManager::DestroyInstance(); - ConformManager::DestroyInstance(); - DiskManager::DestroyInstance(); + RenderManager::destroy_instance(); + ConformManager::destroy_instance(); + DiskManager::destroy_instance(); } - ViewerOutput *CreateViewerWithValidParams() + ViewerOutput *create_viewer_with_valid_params() { auto *viewer = new ViewerOutput(); viewer->setParent(project_.get()); - viewer->SetVideoParams( - VideoParams(64, 64, rational(1, 25), PixelFormat::U8, - VideoParams::kRGBAChannelCount)); + viewer->set_video_params( + VideoParams(64, 64, Rational(1, 25), PixelFormat::u8, + VideoParams::k_rgba_channel_count)); return viewer; } @@ -411,74 +411,74 @@ TEST_F(ViewerSmokeAutoCacherTest, Construction) PreviewAutoCacher cacher; // A freshly constructed cacher has no project and no custom range running - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + EXPECT_FALSE(cacher.is_rendering_custom_range()); } TEST_F(ViewerSmokeAutoCacherTest, PauseControls) { - ViewerOutput *viewer = CreateViewerWithValidParams(); + ViewerOutput *viewer = create_viewer_with_valid_params(); PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); // While renders are paused, a forced cache range must stay queued - cacher.SetRendersPaused(true); - cacher.ForceCacheRange(viewer, TimeRange(rational(0), rational(1, 25))); - EXPECT_TRUE(cacher.IsRenderingCustomRange()); + cacher.set_renders_paused(true); + cacher.force_cache_range(viewer, TimeRange(Rational(0), Rational(1, 25))); + EXPECT_TRUE(cacher.is_rendering_custom_range()); // Unpausing must dispatch it; the dummy backend finishes each ticket // without a result, which exhausts the range immediately - cacher.SetRendersPaused(false); - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + cacher.set_renders_paused(false); + EXPECT_FALSE(cacher.is_rendering_custom_range()); // Deliver the queued RenderTicketWatcher::Finished emissions so the // completed watchers are reaped before teardown. QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } TEST_F(ViewerSmokeAutoCacherTest, CacheRequestSchedulesRenderWhenNotIgnored) { - ViewerOutput *viewer = CreateViewerWithValidParams(); + ViewerOutput *viewer = create_viewer_with_valid_params(); PreviewAutoCacher cacher; - cacher.SetProject(project_.get()); + cacher.set_project(project_.get()); - QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::StopCacheProxyTasks); + QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::stop_cache_proxy_tasks); // A cache request on a connected node's cache must be picked up and // rendered, emitting StopCacheProxyTasks when the range is exhausted - viewer->video_frame_cache()->Request( - viewer, TimeRange(rational(0), rational(1, 25))); + viewer->video_frame_cache()->request( + viewer, TimeRange(Rational(0), Rational(1, 25))); EXPECT_GE(stop_spy.count(), 1); // Deliver the queued RenderTicketWatcher::Finished emissions so the // completed watchers are reaped before teardown. QCoreApplication::processEvents(); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } TEST_F(ViewerSmokeAutoCacherTest, SetIgnoreCacheRequests) { - ViewerOutput *viewer = CreateViewerWithValidParams(); + ViewerOutput *viewer = create_viewer_with_valid_params(); PreviewAutoCacher cacher; // Must be set before SetProject(), which is when the cache connections // would be made - cacher.SetIgnoreCacheRequests(true); - cacher.SetProject(project_.get()); + cacher.set_ignore_cache_requests(true); + cacher.set_project(project_.get()); - QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::StopCacheProxyTasks); + QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::stop_cache_proxy_tasks); // With cache requests ignored, requesting a range must not queue any job - viewer->video_frame_cache()->Request( - viewer, TimeRange(rational(0), rational(1, 25))); + viewer->video_frame_cache()->request( + viewer, TimeRange(Rational(0), Rational(1, 25))); EXPECT_EQ(stop_spy.count(), 0); - EXPECT_FALSE(cacher.IsRenderingCustomRange()); + EXPECT_FALSE(cacher.is_rendering_custom_range()); - cacher.SetProject(nullptr); + cacher.set_project(nullptr); } // ============================================================================ @@ -487,50 +487,50 @@ TEST_F(ViewerSmokeAutoCacherTest, SetIgnoreCacheRequests) TEST(ViewerSmokeRational, DefaultConstruction) { - rational r; + Rational r; EXPECT_EQ(r.numerator(), 0); EXPECT_EQ(r.denominator(), 1); } TEST(ViewerSmokeRational, ValueConstruction) { - rational r(24, 1); + Rational r(24, 1); EXPECT_EQ(r.numerator(), 24); EXPECT_EQ(r.denominator(), 1); - rational r2(1, 24); + Rational r2(1, 24); EXPECT_EQ(r2.numerator(), 1); EXPECT_EQ(r2.denominator(), 24); } TEST(ViewerSmokeRational, ToDouble) { - rational r(1, 2); - EXPECT_DOUBLE_EQ(r.toDouble(), 0.5); + Rational r(1, 2); + EXPECT_DOUBLE_EQ(r.to_double(), 0.5); - rational r2(3, 4); - EXPECT_DOUBLE_EQ(r2.toDouble(), 0.75); + Rational r2(3, 4); + EXPECT_DOUBLE_EQ(r2.to_double(), 0.75); } TEST(ViewerSmokeRational, Arithmetic) { - rational r1(1, 2); - rational r2(1, 4); + Rational r1(1, 2); + Rational r2(1, 4); - rational sum = r1 + r2; + Rational sum = r1 + r2; EXPECT_EQ(sum.numerator(), 3); EXPECT_EQ(sum.denominator(), 4); - rational diff = r1 - r2; + Rational diff = r1 - r2; EXPECT_EQ(diff.numerator(), 1); EXPECT_EQ(diff.denominator(), 4); } TEST(ViewerSmokeRational, Comparison) { - rational r1(1, 2); - rational r2(2, 4); - rational r3(3, 4); + Rational r1(1, 2); + Rational r2(2, 4); + Rational r3(3, 4); EXPECT_TRUE(r1 == r2); // Equivalent fractions EXPECT_FALSE(r1 == r3); @@ -540,17 +540,17 @@ TEST(ViewerSmokeRational, Comparison) TEST(ViewerSmokeRational, NullCheck) { - rational r; + Rational r; EXPECT_TRUE(r.isNull()); // 0/1 is considered null - rational r2(1, 2); + Rational r2(1, 2); EXPECT_FALSE(r2.isNull()); } TEST(ViewerSmokeRational, Flipped) { - rational r(24, 1); - rational flipped = r.flipped(); + Rational r(24, 1); + Rational flipped = r.flipped(); EXPECT_EQ(flipped.numerator(), 1); EXPECT_EQ(flipped.denominator(), 24); @@ -566,7 +566,7 @@ TEST(ViewerSmokeThread, ConcurrentTimerAccess) const int num_iterations = 100; ViewerPlaybackTimer timer; - timer.Start(0, 1, 1.0 / 30.0); + timer.start(0, 1, 1.0 / 30.0); std::vector threads; std::atomic monotonic_violations{ 0 }; @@ -577,7 +577,7 @@ TEST(ViewerSmokeThread, ConcurrentTimerAccess) threads.emplace_back([&timer, &monotonic_violations, num_iterations]() { int64_t previous = 0; for (int i = 0; i < num_iterations; ++i) { - const int64_t ts = timer.GetTimestampNow(); + const int64_t ts = timer.get_timestamp_now(); if (ts < previous) { monotonic_violations++; } @@ -592,7 +592,7 @@ TEST(ViewerSmokeThread, ConcurrentTimerAccess) EXPECT_EQ(monotonic_violations.load(), 0); // The threads ran long enough that the timer must have advanced at all - EXPECT_GE(timer.GetTimestampNow(), 0); + EXPECT_GE(timer.get_timestamp_now(), 0); } TEST(ViewerSmokeThread, ConcurrentQueueAccess) @@ -609,9 +609,9 @@ TEST(ViewerSmokeThread, ConcurrentQueueAccess) [&queue, &append_count, t, num_frames_per_thread]() { for (int i = 0; i < num_frames_per_thread; ++i) { ViewerPlaybackFrame frame{ - rational(t * num_frames_per_thread + i, 24), QVariant() + Rational(t * num_frames_per_thread + i, 24), QVariant() }; - queue.AppendTimewise(frame, 1); + queue.append_timewise(frame, 1); append_count++; } }); @@ -636,17 +636,17 @@ TEST(ViewerSmokeIntegration, PlaybackSequenceSimulation) ViewerQueue queue; // Start playback at frame 0, 24fps; timestamps are expressed in frames - timer.Start(0, 1, 1.0 / 24.0); + timer.start(0, 1, 1.0 / 24.0); // Queue some frames for (int i = 0; i < 10; i++) { - ViewerPlaybackFrame frame{ rational(i, 24), QVariant(i) }; - queue.AppendTimewise(frame, 1); + ViewerPlaybackFrame frame{ Rational(i, 24), QVariant(i) }; + queue.append_timewise(frame, 1); } // Get current timestamp (in frames) and convert it to a time in seconds - const int64_t current_ts = timer.GetTimestampNow(); - const rational current_time(current_ts, 24); + const int64_t current_ts = timer.get_timestamp_now(); + const Rational current_time(current_ts, 24); // Find the first queued frame at or after the current playback time bool found = false; @@ -681,21 +681,21 @@ TEST(ViewerSmokeIntegration, ReversePlaybackScenario) ViewerQueue queue; // Start reverse playback from frame 100 - timer.Start(100, -1, 1.0 / 24.0); + timer.start(100, -1, 1.0 / 24.0); // Queue frames in reverse order for (int i = 100; i >= 90; i--) { - ViewerPlaybackFrame frame{ rational(i, 24), QVariant(i) }; - queue.AppendTimewise(frame, -1); + ViewerPlaybackFrame frame{ Rational(i, 24), QVariant(i) }; + queue.append_timewise(frame, -1); } // Get timestamps - should decrease - int64_t ts1 = timer.GetTimestampNow(); + int64_t ts1 = timer.get_timestamp_now(); QThread::msleep(50); - int64_t ts2 = timer.GetTimestampNow(); + int64_t ts2 = timer.get_timestamp_now(); EXPECT_LT(ts2, ts1); - EXPECT_EQ(queue.front().timestamp, rational(100, 24)); + EXPECT_EQ(queue.front().timestamp, Rational(100, 24)); } } // namespace test diff --git a/tests/gtest/widget_combos_test.cpp b/tests/gtest/widget_combos_test.cpp index d9db63d2d..5bf69035d 100644 --- a/tests/gtest/widget_combos_test.cpp +++ b/tests/gtest/widget_combos_test.cpp @@ -14,11 +14,11 @@ TEST(WidgetCombos, SampleRateContainsSupportedRates) olive::SampleRateComboBox combo; EXPECT_EQ(combo.count(), - int(olive::AudioParams::kSupportedSampleRates.size())); + int(olive::AudioParams::k_supported_sample_rates.size())); - for (int rate : olive::AudioParams::kSupportedSampleRates) { - combo.SetSampleRate(rate); - EXPECT_EQ(combo.GetSampleRate(), rate); + for (int rate : olive::AudioParams::k_supported_sample_rates) { + combo.set_sample_rate(rate); + EXPECT_EQ(combo.get_sample_rate(), rate); } } @@ -27,11 +27,11 @@ TEST(WidgetCombos, ChannelLayoutRoundTrips) olive::ChannelLayoutComboBox combo; EXPECT_EQ(combo.count(), - int(olive::AudioParams::kSupportedChannelLayouts.size())); + int(olive::AudioParams::k_supported_channel_layouts.size())); - for (uint64_t layout : olive::AudioParams::kSupportedChannelLayouts) { - combo.SetChannelLayout(layout); - EXPECT_EQ(combo.GetChannelLayout(), layout); + for (uint64_t layout : olive::AudioParams::k_supported_channel_layouts) { + combo.set_channel_layout(layout); + EXPECT_EQ(combo.get_channel_layout(), layout); } } @@ -41,34 +41,34 @@ TEST(WidgetCombos, InterlacedIndexesMatchEnum) ASSERT_EQ(combo.count(), 3); - combo.SetInterlaceMode(olive::VideoParams::kInterlaceNone); - EXPECT_EQ(combo.GetInterlaceMode(), olive::VideoParams::kInterlaceNone); - EXPECT_EQ(combo.currentIndex(), int(olive::VideoParams::kInterlaceNone)); + combo.set_interlace_mode(olive::VideoParams::k_interlace_none); + EXPECT_EQ(combo.get_interlace_mode(), olive::VideoParams::k_interlace_none); + EXPECT_EQ(combo.currentIndex(), int(olive::VideoParams::k_interlace_none)); - combo.SetInterlaceMode(olive::VideoParams::kInterlacedTopFirst); - EXPECT_EQ(combo.GetInterlaceMode(), olive::VideoParams::kInterlacedTopFirst); - EXPECT_EQ(combo.currentIndex(), int(olive::VideoParams::kInterlacedTopFirst)); + combo.set_interlace_mode(olive::VideoParams::k_interlaced_top_first); + EXPECT_EQ(combo.get_interlace_mode(), olive::VideoParams::k_interlaced_top_first); + EXPECT_EQ(combo.currentIndex(), int(olive::VideoParams::k_interlaced_top_first)); - combo.SetInterlaceMode(olive::VideoParams::kInterlacedBottomFirst); - EXPECT_EQ(combo.GetInterlaceMode(), - olive::VideoParams::kInterlacedBottomFirst); + combo.set_interlace_mode(olive::VideoParams::k_interlaced_bottom_first); + EXPECT_EQ(combo.get_interlace_mode(), + olive::VideoParams::k_interlaced_bottom_first); EXPECT_EQ(combo.currentIndex(), - int(olive::VideoParams::kInterlacedBottomFirst)); + int(olive::VideoParams::k_interlaced_bottom_first)); } TEST(WidgetCombos, PixelFormatAllFormatsPresent) { olive::PixelFormatComboBox combo(false); - EXPECT_EQ(combo.count(), int(olive::core::PixelFormat::COUNT)); + EXPECT_EQ(combo.count(), int(olive::core::PixelFormat::count)); - combo.SetPixelFormat(olive::core::PixelFormat::F32); - EXPECT_EQ(static_cast(combo.GetPixelFormat()), - olive::core::PixelFormat::F32); + combo.set_pixel_format(olive::core::PixelFormat::f32); + EXPECT_EQ(static_cast(combo.get_pixel_format()), + olive::core::PixelFormat::f32); - combo.SetPixelFormat(olive::core::PixelFormat::U8); - EXPECT_EQ(static_cast(combo.GetPixelFormat()), - olive::core::PixelFormat::U8); + combo.set_pixel_format(olive::core::PixelFormat::u8); + EXPECT_EQ(static_cast(combo.get_pixel_format()), + olive::core::PixelFormat::u8); } TEST(WidgetCombos, PixelFormatFloatOnlyFilters) @@ -76,7 +76,7 @@ TEST(WidgetCombos, PixelFormatFloatOnlyFilters) olive::PixelFormatComboBox combo(true); EXPECT_GT(combo.count(), 0); - EXPECT_LT(combo.count(), int(olive::core::PixelFormat::COUNT)); + EXPECT_LT(combo.count(), int(olive::core::PixelFormat::count)); for (int i = 0; i < combo.count(); i++) { olive::core::PixelFormat fmt = @@ -90,11 +90,11 @@ TEST(WidgetCombos, VideoDividerRoundTrips) { olive::VideoDividerComboBox combo; - EXPECT_EQ(combo.count(), olive::VideoParams::kSupportedDividers.size()); + EXPECT_EQ(combo.count(), olive::VideoParams::k_supported_dividers.size()); - for (int d : olive::VideoParams::kSupportedDividers) { - combo.SetDivider(d); - EXPECT_EQ(combo.GetDivider(), d); + for (int d : olive::VideoParams::k_supported_dividers) { + combo.set_divider(d); + EXPECT_EQ(combo.get_divider(), d); } } @@ -103,40 +103,40 @@ TEST(WidgetCombos, FrameRateStandardAndCustom) olive::FrameRateComboBox combo; // Defaults to the first standard rate - EXPECT_EQ(combo.GetFrameRate(), - olive::VideoParams::kSupportedFrameRates.first()); + EXPECT_EQ(combo.get_frame_rate(), + olive::VideoParams::k_supported_frame_rates.first()); // Selecting a standard rate just looks it up in the list - const olive::rational standard = - olive::VideoParams::kSupportedFrameRates.at(2); - combo.SetFrameRate(standard); - EXPECT_EQ(combo.GetFrameRate(), standard); + const olive::Rational standard = + olive::VideoParams::k_supported_frame_rates.at(2); + combo.set_frame_rate(standard); + EXPECT_EQ(combo.get_frame_rate(), standard); // A non-standard rate becomes the custom entry - const olive::rational custom(27, 2); - combo.SetFrameRate(custom); - EXPECT_EQ(combo.GetFrameRate(), custom); + const olive::Rational custom(27, 2); + combo.set_frame_rate(custom); + EXPECT_EQ(combo.get_frame_rate(), custom); // Switching back to a standard rate works again - combo.SetFrameRate(standard); - EXPECT_EQ(combo.GetFrameRate(), standard); + combo.set_frame_rate(standard); + EXPECT_EQ(combo.get_frame_rate(), standard); } TEST(WidgetCombos, PixelAspectRatioStandardAndCustom) { olive::PixelAspectRatioComboBox combo; - const QVector &standards = - olive::VideoParams::kStandardPixelAspects; + const QVector &standards = + olive::VideoParams::k_standard_pixel_aspects; ASSERT_GE(standards.size(), 2); - combo.SetPixelAspectRatio(standards.at(1)); - EXPECT_EQ(combo.GetPixelAspectRatio(), standards.at(1)); + combo.set_pixel_aspect_ratio(standards.at(1)); + EXPECT_EQ(combo.get_pixel_aspect_ratio(), standards.at(1)); // An unknown ratio lands on the last "Custom" item - const olive::rational custom(17, 13); - combo.SetPixelAspectRatio(custom); - EXPECT_EQ(combo.GetPixelAspectRatio(), custom); + const olive::Rational custom(17, 13); + combo.set_pixel_aspect_ratio(custom); + EXPECT_EQ(combo.get_pixel_aspect_ratio(), custom); EXPECT_EQ(combo.currentIndex(), combo.count() - 1); } @@ -145,73 +145,73 @@ TEST(WidgetCombos, SampleFormatPackedFormatsRoundTrip) using Format = olive::core::SampleFormat::Format; olive::SampleFormatComboBox combo; - combo.SetPackedFormats(); + combo.set_packed_formats(); EXPECT_EQ(combo.count(), - int(olive::core::SampleFormat::PACKED_END) - - int(olive::core::SampleFormat::PACKED_START)); + int(olive::core::SampleFormat::packed_end) - + int(olive::core::SampleFormat::packed_start)); - for (int i = olive::core::SampleFormat::PACKED_START; - i < olive::core::SampleFormat::PACKED_END; i++) { + for (int i = olive::core::SampleFormat::packed_start; + i < olive::core::SampleFormat::packed_end; i++) { const Format fmt = static_cast(i); - combo.SetSampleFormat(fmt); - EXPECT_EQ(static_cast(combo.GetSampleFormat()), fmt); + combo.set_sample_format(fmt); + EXPECT_EQ(static_cast(combo.get_sample_format()), fmt); } // Re-populating with restore enabled (the default) keeps the selection - combo.SetSampleFormat(olive::core::SampleFormat::F32); - combo.SetPackedFormats(); - EXPECT_EQ(static_cast(combo.GetSampleFormat()), - olive::core::SampleFormat::F32); + combo.set_sample_format(olive::core::SampleFormat::f32); + combo.set_packed_formats(); + EXPECT_EQ(static_cast(combo.get_sample_format()), + olive::core::SampleFormat::f32); // Requesting a format that isn't in the list leaves the selection alone - combo.SetSampleFormat(olive::core::SampleFormat::F32P); - EXPECT_EQ(static_cast(combo.GetSampleFormat()), - olive::core::SampleFormat::F32); + combo.set_sample_format(olive::core::SampleFormat::f32_p); + EXPECT_EQ(static_cast(combo.get_sample_format()), + olive::core::SampleFormat::f32); } TEST(WidgetCombos, NodeComboBoxTracksSelectionWithoutSignal) { - olive::NodeFactory::Initialize(); + olive::NodeFactory::initialize(); { olive::NodeComboBox combo; - QSignalSpy spy(&combo, &olive::NodeComboBox::NodeChanged); + QSignalSpy spy(&combo, &olive::NodeComboBox::node_changed); const QString id = QStringLiteral("org.olivevideoeditor.Olive.math"); - combo.SetNode(id); - EXPECT_EQ(combo.GetSelectedNode(), id); + combo.set_node(id); + EXPECT_EQ(combo.get_selected_node(), id); EXPECT_EQ(combo.count(), 1); - EXPECT_EQ(combo.itemText(0), olive::NodeFactory::GetNameFromID(id)); + EXPECT_EQ(combo.itemText(0), olive::NodeFactory::get_name_from_id(id)); EXPECT_FALSE(combo.itemText(0).isEmpty()); // Programmatic SetNode never emits NodeChanged EXPECT_EQ(spy.count(), 0); // Setting the same ID again is a no-op - combo.SetNode(id); + combo.set_node(id); EXPECT_EQ(combo.count(), 1); EXPECT_EQ(spy.count(), 0); // Clearing the selection empties the list - combo.SetNode(QString()); - EXPECT_TRUE(combo.GetSelectedNode().isEmpty()); + combo.set_node(QString()); + EXPECT_TRUE(combo.get_selected_node().isEmpty()); EXPECT_EQ(combo.count(), 0); } - olive::NodeFactory::Destroy(); + olive::NodeFactory::destroy(); } TEST(WidgetCombos, ColorCodingComboSetColor) { olive::ColorCodingComboBox combo; - EXPECT_EQ(combo.GetSelectedColor(), 0); + EXPECT_EQ(combo.get_selected_color(), 0); EXPECT_EQ(combo.count(), 1); - EXPECT_EQ(combo.itemText(0), olive::ColorCoding::GetColorName(0)); + EXPECT_EQ(combo.itemText(0), olive::ColorCoding::get_color_name(0)); - combo.SetColor(3); - EXPECT_EQ(combo.GetSelectedColor(), 3); + combo.set_color(3); + EXPECT_EQ(combo.get_selected_color(), 3); EXPECT_EQ(combo.count(), 1); - EXPECT_EQ(combo.itemText(0), olive::ColorCoding::GetColorName(3)); + EXPECT_EQ(combo.itemText(0), olive::ColorCoding::get_color_name(3)); } diff --git a/tests/gtest/widget_curve_keyframe_test.cpp b/tests/gtest/widget_curve_keyframe_test.cpp index 031511e55..a8241dc4e 100644 --- a/tests/gtest/widget_curve_keyframe_test.cpp +++ b/tests/gtest/widget_curve_keyframe_test.cpp @@ -23,22 +23,22 @@ namespace { // Keyframe deletion goes through the global undo stack hosted by Core -void EnsureAppSingletons() +void ensure_app_singletons() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } -NodeKeyframe *InsertKeyframe(Node *node, const QString &input, - const rational &time, const QVariant &value, +NodeKeyframe *insert_keyframe(Node *node, const QString &input, + const Rational &time, const QVariant &value, int track = 0) { auto *key = - new NodeKeyframe(time, value, NodeKeyframe::kLinear, track, -1, input); + new NodeKeyframe(time, value, NodeKeyframe::k_linear, track, -1, input); NodeParamInsertKeyframeCommand(node, key).redo_now(); return key; } @@ -49,14 +49,14 @@ class KeyframeViewTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + ColorManager::set_up_default_config(); + ensure_app_singletons(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - MathNode *AddMathNode() + MathNode *add_math_node() { auto *node = new MathNode(); node->setParent(project_.get()); @@ -68,52 +68,52 @@ protected: TEST_F(KeyframeViewTest, AddKeyframesOfNodeCreatesConnectionPerKeyframableInput) { - MathNode *node = AddMathNode(); + MathNode *node = add_math_node(); KeyframeView view; - KeyframeView::NodeConnections map = view.AddKeyframesOfNode(node); + KeyframeView::NodeConnections map = view.add_keyframes_of_node(node); // A float input has one element (the array-less -1) with one track - ASSERT_TRUE(map.contains(MathNode::kParamAIn)); - const KeyframeView::InputConnections ¶m_a = map[MathNode::kParamAIn]; + ASSERT_TRUE(map.contains(MathNode::k_param_a_in)); + const KeyframeView::InputConnections ¶m_a = map[MathNode::k_param_a_in]; ASSERT_EQ(param_a.size(), 1); ASSERT_EQ(param_a.first().size(), 1); EXPECT_NE(param_a.first().first(), nullptr); - ASSERT_TRUE(map.contains(MathNode::kParamBIn)); - EXPECT_EQ(map[MathNode::kParamBIn].size(), 1); + ASSERT_TRUE(map.contains(MathNode::k_param_b_in)); + EXPECT_EQ(map[MathNode::k_param_b_in].size(), 1); // The base-class enabled checkbox is keyframable too - ASSERT_TRUE(map.contains(Node::kEnabledInput)); - EXPECT_EQ(map[Node::kEnabledInput].size(), 1); + ASSERT_TRUE(map.contains(Node::k_enabled_input)); + EXPECT_EQ(map[Node::k_enabled_input].size(), 1); // The combo input is flagged not-keyframable, so it gets no connections - ASSERT_TRUE(map.contains(MathNode::kMethodIn)); - EXPECT_TRUE(map[MathNode::kMethodIn].isEmpty()); + ASSERT_TRUE(map.contains(MathNode::k_method_in)); + EXPECT_TRUE(map[MathNode::k_method_in].isEmpty()); // One track connection each for enabled, param A and param B - EXPECT_EQ(view.GetKeyframeTracks().size(), 3); + EXPECT_EQ(view.get_keyframe_tracks().size(), 3); } TEST_F(KeyframeViewTest, SelectAllAndDeselectAllUpdateSelection) { - MathNode *node = AddMathNode(); - NodeKeyframe *key_a = InsertKeyframe(node, MathNode::kParamAIn, rational(0), 0.0); - NodeKeyframe *key_b = InsertKeyframe(node, MathNode::kParamAIn, rational(1), 1.0); + MathNode *node = add_math_node(); + NodeKeyframe *key_a = insert_keyframe(node, MathNode::k_param_a_in, Rational(0), 0.0); + NodeKeyframe *key_b = insert_keyframe(node, MathNode::k_param_a_in, Rational(1), 1.0); KeyframeView view; - view.AddKeyframesOfNode(node); + view.add_keyframes_of_node(node); - QSignalSpy selection_spy(&view, &KeyframeView::SelectionChanged); + QSignalSpy selection_spy(&view, &KeyframeView::selection_changed); - EXPECT_TRUE(view.GetSelectedKeyframes().empty()); + EXPECT_TRUE(view.get_selected_keyframes().empty()); - view.SelectAll(); - EXPECT_EQ(view.GetSelectedKeyframes().size(), 2); + view.select_all(); + EXPECT_EQ(view.get_selected_keyframes().size(), 2); EXPECT_GE(selection_spy.count(), 1); - view.DeselectAll(); - EXPECT_TRUE(view.GetSelectedKeyframes().empty()); + view.deselect_all(); + EXPECT_TRUE(view.get_selected_keyframes().empty()); EXPECT_GE(selection_spy.count(), 2); Q_UNUSED(key_a) @@ -122,69 +122,69 @@ TEST_F(KeyframeViewTest, SelectAllAndDeselectAllUpdateSelection) TEST_F(KeyframeViewTest, RemoveKeyframesOfTrackDeselectsAndDetaches) { - MathNode *node = AddMathNode(); - InsertKeyframe(node, MathNode::kParamAIn, rational(0), 0.0); + MathNode *node = add_math_node(); + insert_keyframe(node, MathNode::k_param_a_in, Rational(0), 0.0); KeyframeView view; - KeyframeViewInputConnection *connection = view.AddKeyframesOfTrack( - NodeKeyframeTrackReference(NodeInput(node, MathNode::kParamAIn), 0)); + KeyframeViewInputConnection *connection = view.add_keyframes_of_track( + NodeKeyframeTrackReference(NodeInput(node, MathNode::k_param_a_in), 0)); ASSERT_NE(connection, nullptr); - ASSERT_EQ(view.GetKeyframeTracks().size(), 1); + ASSERT_EQ(view.get_keyframe_tracks().size(), 1); - view.SelectAll(); - ASSERT_EQ(view.GetSelectedKeyframes().size(), 1); + view.select_all(); + ASSERT_EQ(view.get_selected_keyframes().size(), 1); - QSignalSpy selection_spy(&view, &KeyframeView::SelectionChanged); - view.RemoveKeyframesOfTrack(connection); + QSignalSpy selection_spy(&view, &KeyframeView::selection_changed); + view.remove_keyframes_of_track(connection); - EXPECT_TRUE(view.GetKeyframeTracks().isEmpty()); - EXPECT_TRUE(view.GetSelectedKeyframes().empty()); + EXPECT_TRUE(view.get_keyframe_tracks().isEmpty()); + EXPECT_TRUE(view.get_selected_keyframes().empty()); EXPECT_GE(selection_spy.count(), 1); // Removing again is a harmless no-op - view.RemoveKeyframesOfTrack(connection); - EXPECT_TRUE(view.GetKeyframeTracks().isEmpty()); + view.remove_keyframes_of_track(connection); + EXPECT_TRUE(view.get_keyframe_tracks().isEmpty()); } TEST_F(KeyframeViewTest, ClearRemovesAllTracksAndSelection) { - MathNode *node = AddMathNode(); - InsertKeyframe(node, MathNode::kParamAIn, rational(0), 0.0); + MathNode *node = add_math_node(); + insert_keyframe(node, MathNode::k_param_a_in, Rational(0), 0.0); KeyframeView view; - view.AddKeyframesOfNode(node); - view.SelectAll(); - ASSERT_FALSE(view.GetKeyframeTracks().isEmpty()); - ASSERT_FALSE(view.GetSelectedKeyframes().empty()); + view.add_keyframes_of_node(node); + view.select_all(); + ASSERT_FALSE(view.get_keyframe_tracks().isEmpty()); + ASSERT_FALSE(view.get_selected_keyframes().empty()); - view.Clear(); - EXPECT_TRUE(view.GetKeyframeTracks().isEmpty()); - EXPECT_TRUE(view.GetSelectedKeyframes().empty()); + view.clear(); + EXPECT_TRUE(view.get_keyframe_tracks().isEmpty()); + EXPECT_TRUE(view.get_selected_keyframes().empty()); } TEST_F(KeyframeViewTest, DeleteSelectedPushesUndoableRemoval) { - MathNode *node = AddMathNode(); - NodeKeyframe *key = InsertKeyframe(node, MathNode::kParamAIn, rational(0), 0.0); + MathNode *node = add_math_node(); + NodeKeyframe *key = insert_keyframe(node, MathNode::k_param_a_in, Rational(0), 0.0); KeyframeView view; - view.AddKeyframesOfTrack( - NodeKeyframeTrackReference(NodeInput(node, MathNode::kParamAIn), 0)); - view.SelectAll(); - view.DeleteSelected(); + view.add_keyframes_of_track( + NodeKeyframeTrackReference(NodeInput(node, MathNode::k_param_a_in), 0)); + view.select_all(); + view.delete_selected(); // The command was executed on push: the keyframe is gone from the node - EXPECT_TRUE(node->GetKeyframeTracks(MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(MathNode::k_param_a_in, -1) .at(0) .isEmpty()); Core::instance()->undo_stack()->undo(); - EXPECT_TRUE(node->GetKeyframeTracks(MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(MathNode::k_param_a_in, -1) .at(0) .contains(key)); Core::instance()->undo_stack()->redo(); - EXPECT_TRUE(node->GetKeyframeTracks(MathNode::kParamAIn, -1) + EXPECT_TRUE(node->get_keyframe_tracks(MathNode::k_param_a_in, -1) .at(0) .isEmpty()); @@ -196,10 +196,10 @@ class KeyframeViewUndoTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); node_ = new MathNode(); node_->setParent(project_.get()); @@ -212,29 +212,29 @@ protected: TEST_F(KeyframeViewUndoTest, SetTypeCommandSwitchesAndRestoresType) { NodeKeyframe *key = - InsertKeyframe(node_, MathNode::kParamAIn, rational(0), 0.0); - ASSERT_EQ(key->type(), NodeKeyframe::kLinear); + insert_keyframe(node_, MathNode::k_param_a_in, Rational(0), 0.0); + ASSERT_EQ(key->type(), NodeKeyframe::k_linear); - KeyframeSetTypeCommand command(key, NodeKeyframe::kBezier); - EXPECT_EQ(command.GetRelevantProject(), project_.get()); + KeyframeSetTypeCommand command(key, NodeKeyframe::k_bezier); + EXPECT_EQ(command.get_relevant_project(), project_.get()); command.redo_now(); - EXPECT_EQ(key->type(), NodeKeyframe::kBezier); + EXPECT_EQ(key->type(), NodeKeyframe::k_bezier); command.undo_now(); - EXPECT_EQ(key->type(), NodeKeyframe::kLinear); + EXPECT_EQ(key->type(), NodeKeyframe::k_linear); } TEST_F(KeyframeViewUndoTest, SetBezierControlPointCapturesOldPointFromKeyframe) { NodeKeyframe *key = - InsertKeyframe(node_, MathNode::kParamAIn, rational(0), 0.0); - key->set_type(NodeKeyframe::kBezier); + insert_keyframe(node_, MathNode::k_param_a_in, Rational(0), 0.0); + key->set_type(NodeKeyframe::k_bezier); key->set_bezier_control_in(QPointF(0.1, 0.2)); - KeyframeSetBezierControlPoint command(key, NodeKeyframe::kInHandle, + KeyframeSetBezierControlPoint command(key, NodeKeyframe::k_in_handle, QPointF(0.5, 0.6)); - EXPECT_EQ(command.GetRelevantProject(), project_.get()); + EXPECT_EQ(command.get_relevant_project(), project_.get()); command.redo_now(); EXPECT_EQ(key->bezier_control_in(), QPointF(0.5, 0.6)); @@ -246,11 +246,11 @@ TEST_F(KeyframeViewUndoTest, SetBezierControlPointCapturesOldPointFromKeyframe) TEST_F(KeyframeViewUndoTest, SetBezierControlPointWithExplicitOldPoint) { NodeKeyframe *key = - InsertKeyframe(node_, MathNode::kParamAIn, rational(0), 0.0); - key->set_type(NodeKeyframe::kBezier); + insert_keyframe(node_, MathNode::k_param_a_in, Rational(0), 0.0); + key->set_type(NodeKeyframe::k_bezier); // The four-argument overload does not read the current control point - KeyframeSetBezierControlPoint command(key, NodeKeyframe::kOutHandle, + KeyframeSetBezierControlPoint command(key, NodeKeyframe::k_out_handle, QPointF(0.7, 0.8), QPointF(0.3, 0.4)); command.redo_now(); @@ -264,19 +264,19 @@ class CurveViewTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); solid_ = new SolidGenerator(); solid_->setParent(project_.get()); } - NodeKeyframeTrackReference ColorTrackRef(int track) const + NodeKeyframeTrackReference color_track_ref(int track) const { return NodeKeyframeTrackReference( - NodeInput(solid_, SolidGenerator::kColorInput), track); + NodeInput(solid_, SolidGenerator::k_color_input), track); } std::unique_ptr project_; @@ -286,45 +286,45 @@ protected: TEST_F(CurveViewTest, ConnectAndDisconnectInputManageTrackConnections) { CurveView view; - EXPECT_TRUE(view.GetConnections().isEmpty()); + EXPECT_TRUE(view.get_connections().isEmpty()); - view.ConnectInput(ColorTrackRef(0)); - EXPECT_EQ(view.GetConnections().size(), 1); - EXPECT_TRUE(view.GetConnections().contains(ColorTrackRef(0))); - EXPECT_EQ(view.GetConnections().value(ColorTrackRef(0))->GetReference(), - ColorTrackRef(0)); + view.connect_input(color_track_ref(0)); + EXPECT_EQ(view.get_connections().size(), 1); + EXPECT_TRUE(view.get_connections().contains(color_track_ref(0))); + EXPECT_EQ(view.get_connections().value(color_track_ref(0))->get_reference(), + color_track_ref(0)); // Connecting the same reference twice is a no-op - view.ConnectInput(ColorTrackRef(0)); - EXPECT_EQ(view.GetConnections().size(), 1); + view.connect_input(color_track_ref(0)); + EXPECT_EQ(view.get_connections().size(), 1); // A color input has four tracks; connecting another track adds one more - view.ConnectInput(ColorTrackRef(1)); - EXPECT_EQ(view.GetConnections().size(), 2); + view.connect_input(color_track_ref(1)); + EXPECT_EQ(view.get_connections().size(), 2); - view.DisconnectInput(ColorTrackRef(0)); - EXPECT_EQ(view.GetConnections().size(), 1); - EXPECT_FALSE(view.GetConnections().contains(ColorTrackRef(0))); + view.disconnect_input(color_track_ref(0)); + EXPECT_EQ(view.get_connections().size(), 1); + EXPECT_FALSE(view.get_connections().contains(color_track_ref(0))); // Disconnecting an unconnected reference is a no-op - view.DisconnectInput(ColorTrackRef(0)); - EXPECT_EQ(view.GetConnections().size(), 1); + view.disconnect_input(color_track_ref(0)); + EXPECT_EQ(view.get_connections().size(), 1); } TEST_F(CurveViewTest, ConnectionReflectsLiveKeyframeList) { CurveView view; - view.ConnectInput(ColorTrackRef(0)); + view.connect_input(color_track_ref(0)); KeyframeViewInputConnection *connection = - view.GetConnections().value(ColorTrackRef(0)); + view.get_connections().value(color_track_ref(0)); ASSERT_NE(connection, nullptr); - EXPECT_TRUE(connection->GetKeyframes().isEmpty()); + EXPECT_TRUE(connection->get_keyframes().isEmpty()); NodeKeyframe *key = - InsertKeyframe(solid_, SolidGenerator::kColorInput, rational(0), 0.5, 0); - EXPECT_EQ(connection->GetKeyframes().size(), 1); - EXPECT_EQ(connection->GetKeyframes().first(), key); + insert_keyframe(solid_, SolidGenerator::k_color_input, Rational(0), 0.5, 0); + EXPECT_EQ(connection->get_keyframes().size(), 1); + EXPECT_EQ(connection->get_keyframes().first(), key); } TEST_F(CurveViewTest, SetKeyframeTrackColorAppliesToBrush) @@ -332,78 +332,78 @@ TEST_F(CurveViewTest, SetKeyframeTrackColorAppliesToBrush) CurveView view; // Setting the color before connecting is picked up on connect - view.SetKeyframeTrackColor(ColorTrackRef(0), QColor(Qt::red)); - view.ConnectInput(ColorTrackRef(0)); + view.set_keyframe_track_color(color_track_ref(0), QColor(Qt::red)); + view.connect_input(color_track_ref(0)); KeyframeViewInputConnection *connection = - view.GetConnections().value(ColorTrackRef(0)); + view.get_connections().value(color_track_ref(0)); ASSERT_NE(connection, nullptr); - EXPECT_EQ(connection->GetBrush().color(), QColor(Qt::red)); + EXPECT_EQ(connection->get_brush().color(), QColor(Qt::red)); // Setting it afterwards updates the live connection - view.SetKeyframeTrackColor(ColorTrackRef(0), QColor(Qt::blue)); - EXPECT_EQ(connection->GetBrush().color(), QColor(Qt::blue)); + view.set_keyframe_track_color(color_track_ref(0), QColor(Qt::blue)); + EXPECT_EQ(connection->get_brush().color(), QColor(Qt::blue)); } TEST_F(CurveViewTest, SelectKeyframesOfInputSelectsOnlyRequestedTrack) { class SelectionProbeCurveView : public CurveView { public: - using KeyframeView::IsKeyframeSelected; + using KeyframeView::is_keyframe_selected; }; SelectionProbeCurveView view; - view.ConnectInput(ColorTrackRef(0)); - view.ConnectInput(ColorTrackRef(1)); + view.connect_input(color_track_ref(0)); + view.connect_input(color_track_ref(1)); NodeKeyframe *key0 = - InsertKeyframe(solid_, SolidGenerator::kColorInput, rational(0), 0.5, 0); + insert_keyframe(solid_, SolidGenerator::k_color_input, Rational(0), 0.5, 0); NodeKeyframe *key1 = - InsertKeyframe(solid_, SolidGenerator::kColorInput, rational(1), 0.6, 1); + insert_keyframe(solid_, SolidGenerator::k_color_input, Rational(1), 0.6, 1); // Previously the reference was ignored and keyframes of every connected // track got selected. - view.SelectKeyframesOfInput(ColorTrackRef(0)); - EXPECT_TRUE(view.IsKeyframeSelected(key0)); - EXPECT_FALSE(view.IsKeyframeSelected(key1)); + view.select_keyframes_of_input(color_track_ref(0)); + EXPECT_TRUE(view.is_keyframe_selected(key0)); + EXPECT_FALSE(view.is_keyframe_selected(key1)); // Selecting the other track replaces the selection (DeselectAll first) - view.SelectKeyframesOfInput(ColorTrackRef(1)); - EXPECT_FALSE(view.IsKeyframeSelected(key0)); - EXPECT_TRUE(view.IsKeyframeSelected(key1)); + view.select_keyframes_of_input(color_track_ref(1)); + EXPECT_FALSE(view.is_keyframe_selected(key0)); + EXPECT_TRUE(view.is_keyframe_selected(key1)); } TEST(CurveWidget, VerticalScaleRoundTripsThroughView) { - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); CurveWidget widget; - const double original = widget.GetVerticalScale(); + const double original = widget.get_vertical_scale(); EXPECT_GT(original, 0.0); - widget.SetVerticalScale(original * 2.0); - EXPECT_DOUBLE_EQ(widget.GetVerticalScale(), original * 2.0); + widget.set_vertical_scale(original * 2.0); + EXPECT_DOUBLE_EQ(widget.get_vertical_scale(), original * 2.0); } TEST(CurveWidget, TreeSelectionConnectsTracksAndResolvesNodeId) { - ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + ColorManager::set_up_default_config(); + ensure_app_singletons(); Project project; - project.Initialize(); + project.initialize(); auto *solid = new SolidGenerator(); solid->setParent(&project); - solid->Retranslate(); + solid->retranslate(); CurveWidget widget; - widget.SetNodes({ solid }); + widget.set_nodes({ solid }); auto *tree = widget.findChild(); ASSERT_NE(tree, nullptr); ASSERT_EQ(tree->topLevelItemCount(), 1); // Nothing is connected until an input is selected in the tree - EXPECT_EQ(widget.GetSelectedNodeWithID(solid->id()), nullptr); + EXPECT_EQ(widget.get_selected_node_with_id(solid->id()), nullptr); // The solid has two inputs ("enabled" from the base class, then "Color") QTreeWidgetItem *node_item = tree->topLevelItem(0); @@ -411,11 +411,11 @@ TEST(CurveWidget, TreeSelectionConnectsTracksAndResolvesNodeId) QTreeWidgetItem *color_item = node_item->child(1); color_item->setSelected(true); - EXPECT_EQ(widget.GetSelectedNodeWithID(solid->id()), solid); - EXPECT_EQ(widget.GetSelectedNodeWithID(QStringLiteral("org.example.bogus")), + EXPECT_EQ(widget.get_selected_node_with_id(solid->id()), solid); + EXPECT_EQ(widget.get_selected_node_with_id(QStringLiteral("org.example.bogus")), nullptr); // Clearing the selection disconnects the tracks again tree->clearSelection(); - EXPECT_EQ(widget.GetSelectedNodeWithID(solid->id()), nullptr); + EXPECT_EQ(widget.get_selected_node_with_id(solid->id()), nullptr); } diff --git a/tests/gtest/widget_layout_test.cpp b/tests/gtest/widget_layout_test.cpp index 8ca662479..d99b472a2 100644 --- a/tests/gtest/widget_layout_test.cpp +++ b/tests/gtest/widget_layout_test.cpp @@ -35,8 +35,8 @@ TEST(WidgetLayout, FlowLayoutSpacingGetters) QWidget container; FlowLayout *layout = new FlowLayout(&container, 0, 7, 9); - EXPECT_EQ(layout->horizontalSpacing(), 7); - EXPECT_EQ(layout->verticalSpacing(), 9); + EXPECT_EQ(layout->horizontal_spacing(), 7); + EXPECT_EQ(layout->vertical_spacing(), 9); } TEST(WidgetLayout, FlowLayoutWrapsAndComputesHeightForWidth) @@ -44,8 +44,8 @@ TEST(WidgetLayout, FlowLayoutWrapsAndComputesHeightForWidth) QWidget container; FlowLayout *layout = new FlowLayout(&container, 0, 0, 0); - const int kButtonCount = 5; - for (int i = 0; i < kButtonCount; i++) { + const int k_button_count = 5; + for (int i = 0; i < k_button_count; i++) { auto *b = new QPushButton(QStringLiteral("Btn")); b->setFixedSize(100, 30); layout->addWidget(b); @@ -61,7 +61,7 @@ TEST(WidgetLayout, FlowLayoutWrapsAndComputesHeightForWidth) // Lay out for real and inspect positions layout->setGeometry(QRect(0, 0, 250, 90)); - ASSERT_EQ(layout->count(), kButtonCount); + ASSERT_EQ(layout->count(), k_button_count); EXPECT_EQ(layout->itemAt(0)->geometry().topLeft(), QPoint(0, 0)); EXPECT_EQ(layout->itemAt(1)->geometry().topLeft(), QPoint(100, 0)); @@ -83,10 +83,10 @@ TEST(WidgetLayout, ColumnedGridLayoutArrangesByMaximumColumns) for (int i = 0; i < 7; i++) { auto *b = new QPushButton(QString::number(i)); buttons.append(b); - layout->Add(b); + layout->add(b); } - EXPECT_EQ(layout->MaximumColumns(), 3); + EXPECT_EQ(layout->maximum_columns(), 3); EXPECT_EQ(layout->count(), 7); // Widgets are placed row-major with at most three columns @@ -99,8 +99,8 @@ TEST(WidgetLayout, ColumnedGridLayoutArrangesByMaximumColumns) // Nothing beyond the last populated cell EXPECT_EQ(layout->itemAtPosition(2, 1), nullptr); - layout->SetMaximumColumns(4); - EXPECT_EQ(layout->MaximumColumns(), 4); + layout->set_maximum_columns(4); + EXPECT_EQ(layout->maximum_columns(), 4); } TEST(WidgetLayout, ColumnedGridLayoutWithoutColumnLimitStillAdds) @@ -108,12 +108,12 @@ TEST(WidgetLayout, ColumnedGridLayoutWithoutColumnLimitStillAdds) QWidget container; olive::ColumnedGridLayout *layout = new olive::ColumnedGridLayout(&container); - EXPECT_EQ(layout->MaximumColumns(), 0); + EXPECT_EQ(layout->maximum_columns(), 0); auto *a = new QPushButton(QStringLiteral("A")); auto *b = new QPushButton(QStringLiteral("B")); - layout->Add(a); - layout->Add(b); + layout->add(a); + layout->add(b); EXPECT_EQ(layout->count(), 2); } diff --git a/tests/gtest/widget_misc_test.cpp b/tests/gtest/widget_misc_test.cpp index 58e026aa1..c580dc847 100644 --- a/tests/gtest/widget_misc_test.cpp +++ b/tests/gtest/widget_misc_test.cpp @@ -49,7 +49,7 @@ namespace // Widgets that connect to Core::instance() at construction require the // application singleton, but not a MainWindow -void EnsureCore() +void ensure_core() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked @@ -65,7 +65,7 @@ public: { } - QRect SliderRect() + QRect slider_rect() { QStyleOptionSlider opt; initStyleOption(&opt); @@ -77,32 +77,32 @@ public: // Exposes the protected hand-drag state machine entry points class ProbeHandView : public olive::HandMovableView { public: - bool PubHandPress(QMouseEvent *e) + bool pub_hand_press(QMouseEvent *e) { - return HandPress(e); + return hand_press(e); } - bool PubHandMove(QMouseEvent *e) + bool pub_hand_move(QMouseEvent *e) { - return HandMove(e); + return hand_move(e); } - bool PubHandRelease(QMouseEvent *e) + bool pub_hand_release(QMouseEvent *e) { - return HandRelease(e); + return hand_release(e); } - void PubSetDefaultDragMode(DragMode mode) + void pub_set_default_drag_mode(DragMode mode) { - SetDefaultDragMode(mode); + set_default_drag_mode(mode); } - const DragMode &PubGetDefaultDragMode() const + const DragMode &pub_get_default_drag_mode() const { - return GetDefaultDragMode(); + return get_default_drag_mode(); } }; // ToolbarButton has no Q_OBJECT, so findChildren doesn't // compile; every button in a Toolbar is a ToolbarButton, so fetch QPushButtons // and static_cast -QList ToolbarButtons(olive::Toolbar *bar) +QList toolbar_buttons(olive::Toolbar *bar) { QList out; for (QPushButton *b : bar->findChildren()) { @@ -119,7 +119,7 @@ public: NODE_DEFAULT_FUNCTIONS(TwoValueNode) - virtual QString Name() const override + virtual QString name() const override { return QStringLiteral("Test Two Value"); } @@ -129,20 +129,20 @@ public: return QStringLiteral("org.oak.test.twovalue"); } - virtual QVector Category() const override + virtual QVector category() const override { - return { kCategoryMath }; + return { k_category_math }; } - virtual void Value(const olive::NodeValueRow &value, + virtual void value(const olive::NodeValueRow &value, const olive::NodeGlobals &globals, olive::NodeValueTable *table) const override { Q_UNUSED(value) Q_UNUSED(globals) - table->Push(olive::NodeValue::kFloat, QVariant(1.5), this); - table->Push(olive::NodeValue::kInt, QVariant(2), this); + table->push(olive::NodeValue::k_float, QVariant(1.5), this); + table->push(olive::NodeValue::k_int, QVariant(2), this); } }; @@ -151,9 +151,9 @@ public: TEST(WidgetMenu, InsertAlphabeticallySortsActions) { olive::Menu menu; - menu.InsertAlphabetically(QStringLiteral("Charlie")); - menu.InsertAlphabetically(QStringLiteral("Alpha")); - menu.InsertAlphabetically(QStringLiteral("Bravo")); + menu.insert_alphabetically(QStringLiteral("Charlie")); + menu.insert_alphabetically(QStringLiteral("Alpha")); + menu.insert_alphabetically(QStringLiteral("Bravo")); ASSERT_EQ(menu.actions().size(), 3); EXPECT_EQ(menu.actions().at(0)->text(), QStringLiteral("Alpha")); @@ -163,7 +163,7 @@ TEST(WidgetMenu, InsertAlphabeticallySortsActions) // Submenus slot in by their title too auto *sub = new olive::Menu(&menu); sub->setTitle(QStringLiteral("Aardvark")); - menu.InsertAlphabetically(sub); + menu.insert_alphabetically(sub); ASSERT_EQ(menu.actions().size(), 4); EXPECT_EQ(menu.actions().at(0)->text(), QStringLiteral("Aardvark")); @@ -173,8 +173,8 @@ TEST(WidgetMenu, InsertAlphabeticallySortsActions) TEST(WidgetMenu, AddActionWithDataChecksMatchingValue) { olive::Menu menu; - QAction *match = menu.AddActionWithData(QStringLiteral("Five"), 5, 5); - QAction *other = menu.AddActionWithData(QStringLiteral("Six"), 6, 5); + QAction *match = menu.add_action_with_data(QStringLiteral("Five"), 5, 5); + QAction *other = menu.add_action_with_data(QStringLiteral("Six"), 6, 5); EXPECT_TRUE(match->isCheckable()); EXPECT_TRUE(match->isChecked()); @@ -188,7 +188,7 @@ TEST(WidgetMenu, AddActionWithDataChecksMatchingValue) TEST(WidgetMenu, ConformItemStoresIdAndKeyDefault) { QAction a; - olive::Menu::ConformItem(&a, QStringLiteral("myaction"), + olive::Menu::conform_item(&a, QStringLiteral("myaction"), QKeySequence(QStringLiteral("Ctrl+K"))); EXPECT_EQ(a.property("id").toString(), QStringLiteral("myaction")); @@ -199,7 +199,7 @@ TEST(WidgetMenu, ConformItemStoresIdAndKeyDefault) // Without a key, no keydefault is stored QAction b; - olive::Menu::ConformItem(&b, QStringLiteral("plain")); + olive::Menu::conform_item(&b, QStringLiteral("plain")); EXPECT_EQ(b.property("id").toString(), QStringLiteral("plain")); EXPECT_FALSE(b.property("keydefault").isValid()); } @@ -214,12 +214,12 @@ TEST(WidgetColorLabelMenu, ItemsCarryIndexAndEmitSelection) for (int i = 0; i < color_count; i++) { QAction *a = menu.actions().at(i); EXPECT_EQ(a->data().toInt(), i); - EXPECT_EQ(a->text(), olive::ColorCoding::GetColorName(i)); + EXPECT_EQ(a->text(), olive::ColorCoding::get_color_name(i)); EXPECT_EQ(a->property("id").toString(), QStringLiteral("colorlabel%1").arg(i)); } - QSignalSpy spy(&menu, &olive::ColorLabelMenu::ColorSelected); + QSignalSpy spy(&menu, &olive::ColorLabelMenu::color_selected); menu.actions().at(2)->trigger(); ASSERT_EQ(spy.count(), 1); EXPECT_EQ(spy.first().first().toInt(), 2); @@ -228,10 +228,10 @@ TEST(WidgetColorLabelMenu, ItemsCarryIndexAndEmitSelection) TEST(WidgetFileField, SetFilenameReadbackDoesNotSignal) { olive::FileField field; - QSignalSpy spy(&field, &olive::FileField::FilenameChanged); + QSignalSpy spy(&field, &olive::FileField::filename_changed); - field.SetFilename(QStringLiteral("/some/file.txt")); - EXPECT_EQ(field.GetFilename(), QStringLiteral("/some/file.txt")); + field.set_filename(QStringLiteral("/some/file.txt")); + EXPECT_EQ(field.get_filename(), QStringLiteral("/some/file.txt")); // Programmatic changes don't count as user edits EXPECT_EQ(spy.count(), 0); @@ -243,12 +243,12 @@ TEST(WidgetFileField, TypingEmitsFilenameChanged) QLineEdit *edit = field.findChild(); ASSERT_NE(edit, nullptr); - QSignalSpy spy(&field, &olive::FileField::FilenameChanged); + QSignalSpy spy(&field, &olive::FileField::filename_changed); QTest::keyClicks(edit, QStringLiteral("a")); ASSERT_EQ(spy.count(), 1); EXPECT_EQ(spy.first().first().toString(), QStringLiteral("a")); - EXPECT_EQ(field.GetFilename(), QStringLiteral("a")); + EXPECT_EQ(field.get_filename(), QStringLiteral("a")); } TEST(WidgetFileField, InvalidPathMarkedRed) @@ -296,7 +296,7 @@ TEST(WidgetPathWidget, ReadbackAndDirectoryValidation) TEST(WidgetCollapseButton, ToggleSwitchesIcon) { // Icons are normally loaded by the app style; pull them in explicitly - olive::icon::LoadAll(QStringLiteral(":/style/olive-dark")); + olive::icon::load_all(QStringLiteral(":/style/olive-dark")); olive::CollapseButton btn; EXPECT_TRUE(btn.isCheckable()); @@ -323,8 +323,8 @@ TEST(WidgetClickableLabel, ClickAndDoubleClickSignals) GTEST_SKIP() << "Platform does not track cursor position"; } - QSignalSpy clicked_spy(&label, &olive::ClickableLabel::MouseClicked); - QSignalSpy dbl_spy(&label, &olive::ClickableLabel::MouseDoubleClicked); + QSignalSpy clicked_spy(&label, &olive::ClickableLabel::mouse_clicked); + QSignalSpy dbl_spy(&label, &olive::ClickableLabel::mouse_double_clicked); QTest::mouseClick(&label, Qt::LeftButton); EXPECT_EQ(clicked_spy.count(), 1); @@ -337,8 +337,8 @@ TEST(WidgetClickableLabel, ClickAndDoubleClickSignals) TEST(WidgetFocusableLineEdit, EnterConfirmsEscapeCancels) { olive::FocusableLineEdit edit; - QSignalSpy confirmed(&edit, &olive::FocusableLineEdit::Confirmed); - QSignalSpy cancelled(&edit, &olive::FocusableLineEdit::Cancelled); + QSignalSpy confirmed(&edit, &olive::FocusableLineEdit::confirmed); + QSignalSpy cancelled(&edit, &olive::FocusableLineEdit::cancelled); QTest::keyClick(&edit, Qt::Key_Return); EXPECT_EQ(confirmed.count(), 1); @@ -363,7 +363,7 @@ TEST(WidgetPixelSampler, LabelShowsColorComponents) QLabel *label = w.findChild(); ASSERT_NE(label, nullptr); - w.SetValues(olive::Color(1.0, 0.5, 0.0, 1.0)); + w.set_values(olive::Color(1.0, 0.5, 0.0, 1.0)); const QString text = label->text(); EXPECT_TRUE(text.contains(QStringLiteral("R: 1 (255)"))); EXPECT_TRUE(text.contains(QStringLiteral("G: 0.5 (127)"))); @@ -378,7 +378,7 @@ TEST(WidgetPixelSampler, ManagedSamplerForwardsValues) ASSERT_EQ(samplers.size(), 2); // First child is the display view, second the reference view - w.SetValues(olive::Color(1.0, 0.0, 0.0, 1.0), olive::Color(0.0, 1.0, 0.0, 1.0)); + w.set_values(olive::Color(1.0, 0.0, 0.0, 1.0), olive::Color(0.0, 1.0, 0.0, 1.0)); EXPECT_TRUE(samplers.at(0)->findChild()->text().contains( QStringLiteral("G: 1 (255)"))); @@ -391,9 +391,9 @@ TEST(WidgetBezierWidget, ValueRoundTripsThroughSliders) olive::BezierWidget w; olive::Bezier b(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); - w.SetValue(b); + w.set_value(b); - olive::Bezier out = w.GetValue(); + olive::Bezier out = w.get_value(); EXPECT_DOUBLE_EQ(out.x(), 1.0); EXPECT_DOUBLE_EQ(out.y(), 2.0); EXPECT_DOUBLE_EQ(out.cp1_x(), 3.0); @@ -401,10 +401,10 @@ TEST(WidgetBezierWidget, ValueRoundTripsThroughSliders) EXPECT_DOUBLE_EQ(out.cp2_x(), 5.0); EXPECT_DOUBLE_EQ(out.cp2_y(), 6.0); - EXPECT_DOUBLE_EQ(w.x_slider()->GetValue(), 1.0); - EXPECT_DOUBLE_EQ(w.y_slider()->GetValue(), 2.0); - EXPECT_DOUBLE_EQ(w.cp1_x_slider()->GetValue(), 3.0); - EXPECT_DOUBLE_EQ(w.cp2_y_slider()->GetValue(), 6.0); + EXPECT_DOUBLE_EQ(w.x_slider()->get_value(), 1.0); + EXPECT_DOUBLE_EQ(w.y_slider()->get_value(), 2.0); + EXPECT_DOUBLE_EQ(w.cp1_x_slider()->get_value(), 3.0); + EXPECT_DOUBLE_EQ(w.cp2_y_slider()->get_value(), 6.0); } TEST(WidgetResizableScrollBar, DefaultsMatchInit) @@ -428,13 +428,13 @@ TEST(WidgetResizableScrollBar, HandleDragEmitsResizeSignals) bar.show(); EXPECT_TRUE(QTest::qWaitForWindowExposed(&bar)); - const QRect slider = bar.SliderRect(); + const QRect slider = bar.slider_rect(); ASSERT_GT(slider.width(), 30) << "slider too small to hold two handles and a middle"; - QSignalSpy began(&bar, &olive::ResizableScrollBar::ResizeBegan); - QSignalSpy moved(&bar, &olive::ResizableScrollBar::ResizeMoved); - QSignalSpy ended(&bar, &olive::ResizableScrollBar::ResizeEnded); + QSignalSpy began(&bar, &olive::ResizableScrollBar::resize_began); + QSignalSpy moved(&bar, &olive::ResizableScrollBar::resize_moved); + QSignalSpy ended(&bar, &olive::ResizableScrollBar::resize_ended); // Hover the top (left) handle, then drag it 25px to the right const QPoint handle_pos(slider.left() + 1, slider.center().y()); @@ -472,68 +472,68 @@ TEST(WidgetResizableScrollBar, HandleDragEmitsResizeSignals) TEST(WidgetHandMovableView, ToolSwitchChangesDragMode) { - EnsureCore(); + ensure_core(); ProbeHandView view; - view.PubSetDefaultDragMode(QGraphicsView::RubberBandDrag); + view.pub_set_default_drag_mode(QGraphicsView::RubberBandDrag); EXPECT_EQ(view.dragMode(), QGraphicsView::RubberBandDrag); - EXPECT_EQ(view.PubGetDefaultDragMode(), QGraphicsView::RubberBandDrag); + EXPECT_EQ(view.pub_get_default_drag_mode(), QGraphicsView::RubberBandDrag); - olive::Core::instance()->SetTool(olive::Tool::kHand); + olive::Core::instance()->set_tool(olive::Tool::k_hand); EXPECT_EQ(view.dragMode(), QGraphicsView::ScrollHandDrag); EXPECT_FALSE(view.isInteractive()); // Restore the previous tool state for other tests - olive::Core::instance()->SetTool(olive::Tool::kPointer); + olive::Core::instance()->set_tool(olive::Tool::k_pointer); EXPECT_EQ(view.dragMode(), QGraphicsView::RubberBandDrag); EXPECT_TRUE(view.isInteractive()); } TEST(WidgetHandMovableView, MiddleButtonHandDragStateMachine) { - EnsureCore(); + ensure_core(); ProbeHandView view; view.resize(200, 100); - view.PubSetDefaultDragMode(QGraphicsView::NoDrag); + view.pub_set_default_drag_mode(QGraphicsView::NoDrag); // Left button is not a hand drag QMouseEvent left_press(QEvent::MouseButtonPress, QPointF(10, 10), QPointF(10, 10), QPointF(10, 10), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); - EXPECT_FALSE(view.PubHandPress(&left_press)); + EXPECT_FALSE(view.pub_hand_press(&left_press)); EXPECT_TRUE(view.isInteractive()); // Middle button starts a hand drag QMouseEvent mid_press(QEvent::MouseButtonPress, QPointF(10, 10), QPointF(10, 10), QPointF(10, 10), Qt::MiddleButton, Qt::MiddleButton, Qt::NoModifier); - EXPECT_TRUE(view.PubHandPress(&mid_press)); + EXPECT_TRUE(view.pub_hand_press(&mid_press)); EXPECT_EQ(view.dragMode(), QGraphicsView::ScrollHandDrag); EXPECT_FALSE(view.isInteractive()); QMouseEvent move(QEvent::MouseMove, QPointF(30, 20), QPointF(30, 20), QPointF(30, 20), Qt::NoButton, Qt::MiddleButton, Qt::NoModifier); - EXPECT_TRUE(view.PubHandMove(&move)); + EXPECT_TRUE(view.pub_hand_move(&move)); // Release restores the pre-drag state QMouseEvent release(QEvent::MouseButtonRelease, QPointF(30, 20), QPointF(30, 20), QPointF(30, 20), Qt::MiddleButton, Qt::NoButton, Qt::NoModifier); - EXPECT_TRUE(view.PubHandRelease(&release)); + EXPECT_TRUE(view.pub_hand_release(&release)); EXPECT_TRUE(view.isInteractive()); EXPECT_EQ(view.dragMode(), QGraphicsView::NoDrag); // Without an active hand drag, move/release are ignored - EXPECT_FALSE(view.PubHandMove(&move)); - EXPECT_FALSE(view.PubHandRelease(&release)); + EXPECT_FALSE(view.pub_hand_move(&move)); + EXPECT_FALSE(view.pub_hand_release(&release)); } TEST(WidgetHandMovableView, WheelZoomHelpers) { const QVariant old_scroll_zooms = - olive::Config::Current()[QStringLiteral("ScrollZooms")]; + olive::Config::current()[QStringLiteral("ScrollZooms")]; QWheelEvent plain(QPointF(5, 5), QPointF(5, 5), QPoint(), QPoint(0, 120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); @@ -541,49 +541,49 @@ TEST(WidgetHandMovableView, WheelZoomHelpers) Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, false); // With ScrollZooms off, only Ctrl+wheel zooms - olive::Config::Current()[QStringLiteral("ScrollZooms")] = false; + olive::Config::current()[QStringLiteral("ScrollZooms")] = false; EXPECT_TRUE(olive::HandMovableView::WheelEventIsAZoomEvent(&ctrl)); EXPECT_FALSE(olive::HandMovableView::WheelEventIsAZoomEvent(&plain)); // With ScrollZooms on, plain wheel zooms and Ctrl+wheel does not - olive::Config::Current()[QStringLiteral("ScrollZooms")] = true; + olive::Config::current()[QStringLiteral("ScrollZooms")] = true; EXPECT_TRUE(olive::HandMovableView::WheelEventIsAZoomEvent(&plain)); EXPECT_FALSE(olive::HandMovableView::WheelEventIsAZoomEvent(&ctrl)); // 120 wheel units -> 1.12x; inverted devices flip the sign - EXPECT_NEAR(olive::HandMovableView::GetScrollZoomMultiplier(&plain), 1.12, + EXPECT_NEAR(olive::HandMovableView::get_scroll_zoom_multiplier(&plain), 1.12, 1e-9); QWheelEvent inverted(QPointF(5, 5), QPointF(5, 5), QPoint(), QPoint(0, 120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, true); - EXPECT_NEAR(olive::HandMovableView::GetScrollZoomMultiplier(&inverted), + EXPECT_NEAR(olive::HandMovableView::get_scroll_zoom_multiplier(&inverted), 0.88, 1e-9); - olive::Config::Current()[QStringLiteral("ScrollZooms")] = + olive::Config::current()[QStringLiteral("ScrollZooms")] = old_scroll_zooms; } TEST(WidgetToolbarButton, StoresToolAndIsCheckable) { - olive::ToolbarButton btn(nullptr, olive::Tool::kSlip); - EXPECT_EQ(btn.tool(), olive::Tool::kSlip); + olive::ToolbarButton btn(nullptr, olive::Tool::k_slip); + EXPECT_EQ(btn.tool(), olive::Tool::k_slip); EXPECT_TRUE(btn.isCheckable()); } TEST(WidgetToolbar, SetToolChecksMatchingButtonOnly) { olive::Toolbar bar(nullptr); - const auto buttons = ToolbarButtons(&bar); + const auto buttons = toolbar_buttons(&bar); // 13 tool buttons + 1 snapping toggle EXPECT_EQ(buttons.size(), 14); - bar.SetTool(olive::Tool::kRazor); + bar.set_tool(olive::Tool::k_razor); for (olive::ToolbarButton *b : buttons) { - if (b->tool() == olive::Tool::kNone) { + if (b->tool() == olive::Tool::k_none) { continue; } - EXPECT_EQ(b->isChecked(), b->tool() == olive::Tool::kRazor) + EXPECT_EQ(b->isChecked(), b->tool() == olive::Tool::k_razor) << int(b->tool()); } } @@ -593,14 +593,14 @@ TEST(WidgetToolbar, ClickingButtonEmitsToolChanged) olive::Toolbar bar(nullptr); QVector received; - QObject::connect(&bar, &olive::Toolbar::ToolChanged, + QObject::connect(&bar, &olive::Toolbar::tool_changed, [&received](const olive::Tool::Item &t) { received.append(t); }); olive::ToolbarButton *pointer = nullptr; - for (olive::ToolbarButton *b : ToolbarButtons(&bar)) { - if (b->tool() == olive::Tool::kPointer) { + for (olive::ToolbarButton *b : toolbar_buttons(&bar)) { + if (b->tool() == olive::Tool::k_pointer) { pointer = b; break; } @@ -609,26 +609,26 @@ TEST(WidgetToolbar, ClickingButtonEmitsToolChanged) pointer->click(); ASSERT_EQ(received.size(), 1); - EXPECT_EQ(received.first(), olive::Tool::kPointer); + EXPECT_EQ(received.first(), olive::Tool::k_pointer); } TEST(WidgetToolbar, SnappingToggleReflectsAndEmits) { olive::Toolbar bar(nullptr); - QSignalSpy spy(&bar, &olive::Toolbar::SnappingChanged); + QSignalSpy spy(&bar, &olive::Toolbar::snapping_changed); olive::ToolbarButton *snap = nullptr; - for (olive::ToolbarButton *b : ToolbarButtons(&bar)) { - if (b->tool() == olive::Tool::kNone) { + for (olive::ToolbarButton *b : toolbar_buttons(&bar)) { + if (b->tool() == olive::Tool::k_none) { snap = b; break; } } ASSERT_NE(snap, nullptr); - bar.SetSnapping(false); + bar.set_snapping(false); EXPECT_FALSE(snap->isChecked()); - bar.SetSnapping(true); + bar.set_snapping(true); EXPECT_TRUE(snap->isChecked()); snap->click(); @@ -638,17 +638,17 @@ TEST(WidgetToolbar, SnappingToggleReflectsAndEmits) TEST(WidgetColorButton, SetColorRoundTrips) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; olive::ColorButton btn(project.color_manager()); - EXPECT_FLOAT_EQ(btn.GetColor().red(), 1.0f); - EXPECT_FLOAT_EQ(btn.GetColor().green(), 1.0f); - EXPECT_FLOAT_EQ(btn.GetColor().blue(), 1.0f); + EXPECT_FLOAT_EQ(btn.get_color().red(), 1.0f); + EXPECT_FLOAT_EQ(btn.get_color().green(), 1.0f); + EXPECT_FLOAT_EQ(btn.get_color().blue(), 1.0f); - btn.SetColor(olive::ManagedColor(0.25, 0.5, 0.75, 1.0)); + btn.set_color(olive::ManagedColor(0.25, 0.5, 0.75, 1.0)); - const olive::ManagedColor &out = btn.GetColor(); + const olive::ManagedColor &out = btn.get_color(); EXPECT_FLOAT_EQ(out.red(), 0.25f); EXPECT_FLOAT_EQ(out.green(), 0.5f); EXPECT_FLOAT_EQ(out.blue(), 0.75f); @@ -661,13 +661,13 @@ TEST(WidgetColorButton, SetColorRoundTrips) TEST(WidgetColorValuesTab, FloatModeRoundTripsColor) { olive::ColorValuesTab tab(false); - tab.SetColor(olive::Color(0.25, 0.5, 0.75)); + tab.set_color(olive::Color(0.25, 0.5, 0.75)); - EXPECT_NEAR(tab.GetRed(), 0.25, 1e-6); - EXPECT_NEAR(tab.GetGreen(), 0.5, 1e-6); - EXPECT_NEAR(tab.GetBlue(), 0.75, 1e-6); + EXPECT_NEAR(tab.get_red(), 0.25, 1e-6); + EXPECT_NEAR(tab.get_green(), 0.5, 1e-6); + EXPECT_NEAR(tab.get_blue(), 0.75, 1e-6); - olive::Color out = tab.GetColor(); + olive::Color out = tab.get_color(); EXPECT_NEAR(out.red(), 0.25, 1e-6); EXPECT_NEAR(out.green(), 0.5, 1e-6); EXPECT_NEAR(out.blue(), 0.75, 1e-6); @@ -675,19 +675,19 @@ TEST(WidgetColorValuesTab, FloatModeRoundTripsColor) // The web field shows the rgb() form in float mode auto *hex = tab.findChild(); ASSERT_NE(hex, nullptr); - EXPECT_EQ(hex->GetValue(), QStringLiteral("rgb(0.25, 0.5, 0.75)")); + EXPECT_EQ(hex->get_value(), QStringLiteral("rgb(0.25, 0.5, 0.75)")); } TEST(WidgetColorValuesTab, LegacyToggleRescalesSliders) { const QVariant old_legacy = - olive::Config::Current()[QStringLiteral("UseLegacyColorInInputTab")]; - olive::Config::Current()[QStringLiteral("UseLegacyColorInInputTab")] = false; + olive::Config::current()[QStringLiteral("UseLegacyColorInInputTab")]; + olive::Config::current()[QStringLiteral("UseLegacyColorInInputTab")] = false; { olive::ColorValuesTab tab(true); - tab.SetRed(1.0); - EXPECT_NEAR(tab.GetRed(), 1.0, 1e-6); + tab.set_red(1.0); + EXPECT_NEAR(tab.get_red(), 1.0, 1e-6); QCheckBox *legacy = tab.findChild(); ASSERT_NE(legacy, nullptr); @@ -695,25 +695,25 @@ TEST(WidgetColorValuesTab, LegacyToggleRescalesSliders) // Switching to legacy keeps the effective color but shows 0-255 legacy->click(); - EXPECT_NEAR(tab.GetRed(), 1.0, 1e-6); + EXPECT_NEAR(tab.get_red(), 1.0, 1e-6); auto *hex = tab.findChild(); ASSERT_NE(hex, nullptr); - EXPECT_EQ(hex->GetValue(), QStringLiteral("FF0000")); + EXPECT_EQ(hex->get_value(), QStringLiteral("FF0000")); // And back legacy->click(); - EXPECT_NEAR(tab.GetRed(), 1.0, 1e-6); - EXPECT_EQ(hex->GetValue(), QStringLiteral("rgb(1.0, 0.0, 0.0)")); + EXPECT_NEAR(tab.get_red(), 1.0, 1e-6); + EXPECT_EQ(hex->get_value(), QStringLiteral("rgb(1.0, 0.0, 0.0)")); } - olive::Config::Current()[QStringLiteral("UseLegacyColorInInputTab")] = + olive::Config::current()[QStringLiteral("UseLegacyColorInInputTab")] = old_legacy; } TEST(WidgetColorSwatchChooser, ClickingSwatchEmitsItsColor) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; olive::ColorSwatchChooser chooser(project.color_manager()); @@ -721,7 +721,7 @@ TEST(WidgetColorSwatchChooser, ClickingSwatchEmitsItsColor) EXPECT_EQ(buttons.size(), 32); QVector received; - QObject::connect(&chooser, &olive::ColorSwatchChooser::ColorClicked, + QObject::connect(&chooser, &olive::ColorSwatchChooser::color_clicked, [&received](const olive::ManagedColor &c) { received.append(c); }); @@ -730,7 +730,7 @@ TEST(WidgetColorSwatchChooser, ClickingSwatchEmitsItsColor) ASSERT_EQ(received.size(), 1); // The emitted color is exactly the clicked button's color - const olive::ManagedColor &expected = buttons.first()->GetColor(); + const olive::ManagedColor &expected = buttons.first()->get_color(); EXPECT_FLOAT_EQ(received.first().red(), expected.red()); EXPECT_FLOAT_EQ(received.first().green(), expected.green()); EXPECT_FLOAT_EQ(received.first().blue(), expected.blue()); @@ -738,11 +738,11 @@ TEST(WidgetColorSwatchChooser, ClickingSwatchEmitsItsColor) TEST(WidgetColorSpaceChooser, InputRoundTripsAndEmits) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; const QStringList spaces = - project.color_manager()->ListAvailableColorspaces(); + project.color_manager()->list_available_colorspaces(); ASSERT_GE(spaces.size(), 2); // Input-only mode, as used by the export dialog @@ -750,7 +750,7 @@ TEST(WidgetColorSpaceChooser, InputRoundTripsAndEmits) EXPECT_FALSE(chooser.input().isEmpty()); QSignalSpy spy(&chooser, - &olive::ColorSpaceChooser::InputColorSpaceChanged); + &olive::ColorSpaceChooser::input_color_space_changed); // Pick whichever colorspace isn't currently selected QString target; @@ -770,7 +770,7 @@ TEST(WidgetColorSpaceChooser, InputRoundTripsAndEmits) TEST(WidgetColorSpaceChooser, FullModePopulatesDisplayFields) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; olive::ColorSpaceChooser chooser(project.color_manager()); @@ -783,7 +783,7 @@ TEST(WidgetColorPreviewBox, RendersManagedColor) { olive::ColorPreviewBox box; box.resize(20, 20); - box.SetColor(olive::Color(1.0, 0.0, 0.0, 1.0)); + box.set_color(olive::Color(1.0, 0.0, 0.0, 1.0)); QImage img(box.size(), QImage::Format_ARGB32); img.fill(Qt::transparent); @@ -799,24 +799,24 @@ TEST(WidgetColorGradient, ClickPositionsMapToValueRange) { olive::ColorGradientWidget grad(Qt::Horizontal); grad.resize(100, 20); - grad.SetSelectedColor(olive::Color(1.0, 0.0, 0.0)); + grad.set_selected_color(olive::Color(1.0, 0.0, 0.0)); QVector received; - QObject::connect(&grad, &olive::ColorGradientWidget::SelectedColorChanged, + QObject::connect(&grad, &olive::ColorGradientWidget::selected_color_changed, [&received](const olive::Color &c) { received.append(c); }); // Left edge is the full-value end of the gradient float hue, sat, val; QTest::mouseClick(&grad, Qt::LeftButton, Qt::NoModifier, QPoint(0, 10)); ASSERT_EQ(received.size(), 1); - EXPECT_FLOAT_EQ(grad.GetSelectedColor().red(), received.first().red()); - received.first().toHsv(&hue, &sat, &val); + EXPECT_FLOAT_EQ(grad.get_selected_color().red(), received.first().red()); + received.first().to_hsv(&hue, &sat, &val); EXPECT_NEAR(val, 1.0, 1e-4); // Right edge approaches the zero-value end QTest::mouseClick(&grad, Qt::LeftButton, Qt::NoModifier, QPoint(99, 10)); ASSERT_EQ(received.size(), 2); - received.at(1).toHsv(&hue, &sat, &val); + received.at(1).to_hsv(&hue, &sat, &val); EXPECT_NEAR(val, 0.01, 0.02); } @@ -826,7 +826,7 @@ TEST(WidgetColorWheel, ResizeEmitsDiameter) wheel.show(); EXPECT_TRUE(QTest::qWaitForWindowExposed(&wheel)); - QSignalSpy spy(&wheel, &olive::ColorWheelWidget::DiameterChanged); + QSignalSpy spy(&wheel, &olive::ColorWheelWidget::diameter_changed); wheel.resize(200, 100); ASSERT_GE(spy.count(), 1); @@ -841,17 +841,17 @@ TEST(WidgetColorWheel, SelectedColorRoundTrips) olive::ColorWheelWidget wheel; wheel.resize(100, 100); - wheel.SetSelectedColor(olive::Color(0.2, 0.4, 0.6)); - EXPECT_FLOAT_EQ(wheel.GetSelectedColor().red(), 0.2f); - EXPECT_FLOAT_EQ(wheel.GetSelectedColor().green(), 0.4f); - EXPECT_FLOAT_EQ(wheel.GetSelectedColor().blue(), 0.6f); + wheel.set_selected_color(olive::Color(0.2, 0.4, 0.6)); + EXPECT_FLOAT_EQ(wheel.get_selected_color().red(), 0.2f); + EXPECT_FLOAT_EQ(wheel.get_selected_color().green(), 0.4f); + EXPECT_FLOAT_EQ(wheel.get_selected_color().blue(), 0.6f); } TEST(WidgetNodeValueTree, PopulatesRowsAndSetsValueHint) { - olive::ColorManager::SetUpDefaultConfig(); + olive::ColorManager::set_up_default_config(); olive::Project project; - project.Initialize(); + project.initialize(); auto *source = new TwoValueNode(); source->setParent(&project); @@ -859,12 +859,12 @@ TEST(WidgetNodeValueTree, PopulatesRowsAndSetsValueHint) auto *consumer = new olive::MathNode(); consumer->setParent(&project); - olive::Node::ConnectEdge(source, - olive::NodeInput(consumer, olive::MathNode::kParamAIn)); + olive::Node::connect_edge(source, + olive::NodeInput(consumer, olive::MathNode::k_param_a_in)); olive::NodeValueTree tree; - tree.SetNode(olive::NodeInput(consumer, olive::MathNode::kParamAIn), - olive::rational(0)); + tree.set_node(olive::NodeInput(consumer, olive::MathNode::k_param_a_in), + olive::Rational(0)); // One row per pushed value ASSERT_EQ(tree.topLevelItemCount(), 2); @@ -884,7 +884,7 @@ TEST(WidgetNodeValueTree, PopulatesRowsAndSetsValueHint) } } EXPECT_EQ(checked_row, float_row); - EXPECT_EQ(consumer->GetValueHintForInput(olive::MathNode::kParamAIn).index(), + EXPECT_EQ(consumer->get_value_hint_for_input(olive::MathNode::k_param_a_in).index(), -1); // Clicking the other row writes its value hint back to the node @@ -895,7 +895,7 @@ TEST(WidgetNodeValueTree, PopulatesRowsAndSetsValueHint) other_radio->click(); const olive::Node::ValueHint hint = - consumer->GetValueHintForInput(olive::MathNode::kParamAIn); + consumer->get_value_hint_for_input(olive::MathNode::k_param_a_in); EXPECT_EQ(hint.index(), 1 - other_row); // table.Count() - 1 - row - EXPECT_TRUE(hint.types().contains(olive::NodeValue::kInt)); + EXPECT_TRUE(hint.types().contains(olive::NodeValue::k_int)); } diff --git a/tests/gtest/widget_panels_model_test.cpp b/tests/gtest/widget_panels_model_test.cpp index c91aafb18..a6210e0f8 100644 --- a/tests/gtest/widget_panels_model_test.cpp +++ b/tests/gtest/widget_panels_model_test.cpp @@ -42,13 +42,13 @@ namespace { // Bridges, history and multicam widgets all talk to the Core singleton -void EnsureAppSingletons() +void ensure_app_singletons() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } @@ -56,12 +56,12 @@ class DummyTask : public Task { public: DummyTask() { - SetTitle(QStringLiteral("Test Task")); - SetError(QStringLiteral("boom")); + set_title(QStringLiteral("Test Task")); + set_error(QStringLiteral("boom")); } protected: - virtual bool Run() override + virtual bool run() override { return true; } @@ -74,7 +74,7 @@ public: { } - virtual Project *GetRelevantProject() const override + virtual Project *get_relevant_project() const override { return nullptr; } @@ -95,8 +95,8 @@ private: }; // NodeTreeView stores these on its items (mirrors the private constants) -const int kItemTypeRole = Qt::UserRole; -const int kItemInputReferenceRole = Qt::UserRole + 1; +const int k_item_type_role = Qt::UserRole; +const int k_item_input_reference_role = Qt::UserRole + 1; } // namespace @@ -104,14 +104,14 @@ class WidgetPanelsTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + ColorManager::set_up_default_config(); + ensure_app_singletons(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - template T *AddNode() + template T *add_node() { auto *node = new T(); node->setParent(project_.get()); @@ -123,33 +123,33 @@ protected: TEST_F(WidgetPanelsTest, NodeTableSelectNodesCreatesTopLevelItems) { - auto *solid = AddNode(); + auto *solid = add_node(); NodeTableView view; EXPECT_EQ(view.topLevelItemCount(), 0); - view.SelectNodes({ solid }); + view.select_nodes({ solid }); ASSERT_EQ(view.topLevelItemCount(), 1); - EXPECT_EQ(view.topLevelItem(0)->text(0), solid->GetLabelAndName()); + EXPECT_EQ(view.topLevelItem(0)->text(0), solid->get_label_and_name()); - auto *math = AddNode(); - view.SelectNodes({ math }); + auto *math = add_node(); + view.select_nodes({ math }); EXPECT_EQ(view.topLevelItemCount(), 2); - view.DeselectNodes({ solid }); + view.deselect_nodes({ solid }); EXPECT_EQ(view.topLevelItemCount(), 1); - view.DeselectNodes({ math }); + view.deselect_nodes({ math }); EXPECT_EQ(view.topLevelItemCount(), 0); } TEST_F(WidgetPanelsTest, NodeTableSetTimePopulatesInputRows) { - auto *solid = AddNode(); - solid->Retranslate(); + auto *solid = add_node(); + solid->retranslate(); NodeTableView view; - view.SelectNodes({ solid }); + view.select_nodes({ solid }); QTreeWidgetItem *top = view.topLevelItem(0); ASSERT_NE(top, nullptr); @@ -161,52 +161,52 @@ TEST_F(WidgetPanelsTest, NodeTableSetTimePopulatesInputRows) QTreeWidgetItem *color_row = nullptr; for (int i = 0; i < top->childCount(); i++) { if (top->child(i)->data(0, Qt::UserRole).toString() == - SolidGenerator::kColorInput) { + SolidGenerator::k_color_input) { color_row = top->child(i); break; } } ASSERT_NE(color_row, nullptr); - EXPECT_EQ(color_row->text(0), solid->GetInputName(SolidGenerator::kColorInput)); + EXPECT_EQ(color_row->text(0), solid->get_input_name(SolidGenerator::k_color_input)); // The value row shows the data type name and the split RGBA columns ASSERT_EQ(color_row->childCount(), 1); QTreeWidgetItem *value_row = color_row->child(0); EXPECT_EQ(value_row->text(0), - NodeValue::GetPrettyDataTypeName(NodeValue::kColor)); + NodeValue::get_pretty_data_type_name(NodeValue::k_color)); EXPECT_FALSE(value_row->text(1).isEmpty()); for (int col = 2; col <= 5; col++) { EXPECT_FALSE(value_row->text(col).isEmpty()) << "column" << col; } // Re-evaluating at another time keeps the same structure - view.SetTime(rational(1)); + view.set_time(Rational(1)); EXPECT_EQ(top->childCount(), 2); EXPECT_EQ(color_row->childCount(), 1); } TEST_F(WidgetPanelsTest, NodeTreeSetNodesBuildsInputHierarchy) { - auto *math = AddNode(); - math->Retranslate(); + auto *math = add_node(); + math->retranslate(); NodeTreeView view; - view.SetNodes({ math }); + view.set_nodes({ math }); ASSERT_EQ(view.topLevelItemCount(), 1); QTreeWidgetItem *node_item = view.topLevelItem(0); - EXPECT_EQ(node_item->data(0, kItemTypeRole).toInt(), 0); // kItemTypeNode + EXPECT_EQ(node_item->data(0, k_item_type_role).toInt(), 0); // kItemTypeNode // All four inputs are visible: the base-class enabled checkbox, the // method combo, and the two float params ASSERT_EQ(node_item->childCount(), 4); - const QStringList expected_inputs = { Node::kEnabledInput, MathNode::kMethodIn, - MathNode::kParamAIn, MathNode::kParamBIn }; + const QStringList expected_inputs = { Node::k_enabled_input, MathNode::k_method_in, + MathNode::k_param_a_in, MathNode::k_param_b_in }; for (int i = 0; i < expected_inputs.size(); i++) { QTreeWidgetItem *input_item = node_item->child(i); - EXPECT_EQ(input_item->data(0, kItemTypeRole).toInt(), 1); // kItemTypeInput + EXPECT_EQ(input_item->data(0, k_item_type_role).toInt(), 1); // kItemTypeInput const NodeKeyframeTrackReference ref = - input_item->data(0, kItemInputReferenceRole) + input_item->data(0, k_item_input_reference_role) .value(); EXPECT_EQ(ref.input().node(), math); EXPECT_EQ(ref.input().input(), expected_inputs.at(i)); @@ -215,11 +215,11 @@ TEST_F(WidgetPanelsTest, NodeTreeSetNodesBuildsInputHierarchy) TEST_F(WidgetPanelsTest, NodeTreeOnlyShowKeyframableFiltersInputs) { - auto *math = AddNode(); + auto *math = add_node(); NodeTreeView view; - view.SetOnlyShowKeyframable(true); - view.SetNodes({ math }); + view.set_only_show_keyframable(true); + view.set_nodes({ math }); // The method combo is flagged not-keyframable; enabled and the two // float params remain @@ -228,30 +228,30 @@ TEST_F(WidgetPanelsTest, NodeTreeOnlyShowKeyframableFiltersInputs) // Of a bare viewer's inputs only "enabled" is keyframable, so it is the // sole row left standing - auto *viewer = AddNode(); - view.SetNodes({ viewer }); + auto *viewer = add_node(); + view.set_nodes({ viewer }); ASSERT_EQ(view.topLevelItemCount(), 1); EXPECT_EQ(view.topLevelItem(0)->childCount(), 1); // Without the filter its buffer inputs show up as well - view.SetOnlyShowKeyframable(false); - view.SetNodes({ viewer }); + view.set_only_show_keyframable(false); + view.set_nodes({ viewer }); ASSERT_EQ(view.topLevelItemCount(), 1); EXPECT_EQ(view.topLevelItem(0)->childCount(), 3); } TEST_F(WidgetPanelsTest, NodeTreeCheckboxesToggleEnableStateAndEmit) { - auto *math = AddNode(); + auto *math = add_node(); NodeTreeView view; - view.SetCheckBoxesEnabled(true); - view.SetNodes({ math }); + view.set_check_boxes_enabled(true); + view.set_nodes({ math }); Node *node_signal_node = nullptr; bool node_signal_enabled = true; int node_emissions = 0; - QObject::connect(&view, &NodeTreeView::NodeEnableChanged, + QObject::connect(&view, &NodeTreeView::node_enable_changed, [&node_signal_node, &node_signal_enabled, &node_emissions](Node *n, bool e) { node_signal_node = n; @@ -262,7 +262,7 @@ TEST_F(WidgetPanelsTest, NodeTreeCheckboxesToggleEnableStateAndEmit) NodeKeyframeTrackReference input_signal_ref; bool input_signal_enabled = true; int input_emissions = 0; - QObject::connect(&view, &NodeTreeView::InputEnableChanged, + QObject::connect(&view, &NodeTreeView::input_enable_changed, [&input_signal_ref, &input_signal_enabled, &input_emissions](const NodeKeyframeTrackReference &ref, bool e) { @@ -280,32 +280,32 @@ TEST_F(WidgetPanelsTest, NodeTreeCheckboxesToggleEnableStateAndEmit) EXPECT_EQ(node_emissions, 1); EXPECT_EQ(node_signal_node, math); EXPECT_FALSE(node_signal_enabled); - EXPECT_FALSE(view.IsNodeEnabled(math)); + EXPECT_FALSE(view.is_node_enabled(math)); // Re-checking restores it node_item->setCheckState(0, Qt::Checked); EXPECT_EQ(node_emissions, 2); EXPECT_TRUE(node_signal_enabled); - EXPECT_TRUE(view.IsNodeEnabled(math)); + EXPECT_TRUE(view.is_node_enabled(math)); // Same behavior on input rows QTreeWidgetItem *input_item = node_item->child(0); ASSERT_NE(input_item, nullptr); input_item->setCheckState(0, Qt::Unchecked); EXPECT_EQ(input_emissions, 1); - EXPECT_EQ(input_signal_ref.input().input(), Node::kEnabledInput); + EXPECT_EQ(input_signal_ref.input().input(), Node::k_enabled_input); EXPECT_FALSE(input_signal_enabled); - EXPECT_FALSE(view.IsInputEnabled(input_signal_ref)); + EXPECT_FALSE(view.is_input_enabled(input_signal_ref)); } TEST_F(WidgetPanelsTest, NodeTreeKeyframeTracksBecomeRows) { - auto *solid = AddNode(); - solid->Retranslate(); + auto *solid = add_node(); + solid->retranslate(); NodeTreeView view; - view.SetShowKeyframeTracksAsRows(true); - view.SetNodes({ solid }); + view.set_show_keyframe_tracks_as_rows(true); + view.set_nodes({ solid }); QTreeWidgetItem *node_item = view.topLevelItem(0); ASSERT_NE(node_item, nullptr); @@ -321,15 +321,15 @@ TEST_F(WidgetPanelsTest, NodeTreeKeyframeTracksBecomeRows) EXPECT_EQ(color_item->child(i)->text(0), track_names.at(i)); const NodeKeyframeTrackReference ref = color_item->child(i) - ->data(0, kItemInputReferenceRole) + ->data(0, k_item_input_reference_role) .value(); EXPECT_EQ(ref.track(), i); } // A single-track float input stays a single row - auto *math = AddNode(); - math->Retranslate(); - view.SetNodes({ math }); + auto *math = add_node(); + math->retranslate(); + view.set_nodes({ math }); QTreeWidgetItem *param_item = view.topLevelItem(0)->child(2); // after enabled and the method combo ASSERT_NE(param_item, nullptr); @@ -339,10 +339,10 @@ TEST_F(WidgetPanelsTest, NodeTreeKeyframeTracksBecomeRows) TEST_F(WidgetPanelsTest, BridgeCreatesSliderForFloatInput) { - auto *math = AddNode(); + auto *math = add_node(); QWidget parent; - NodeParamViewWidgetBridge bridge(NodeInput(math, MathNode::kParamAIn), &parent); + NodeParamViewWidgetBridge bridge(NodeInput(math, MathNode::k_param_a_in), &parent); ASSERT_EQ(bridge.widgets().size(), 1); EXPECT_NE(qobject_cast(bridge.widgets().first()), nullptr); @@ -350,10 +350,10 @@ TEST_F(WidgetPanelsTest, BridgeCreatesSliderForFloatInput) TEST_F(WidgetPanelsTest, BridgeCreatesColorButtonForColorInput) { - auto *solid = AddNode(); + auto *solid = add_node(); QWidget parent; - NodeParamViewWidgetBridge bridge(NodeInput(solid, SolidGenerator::kColorInput), + NodeParamViewWidgetBridge bridge(NodeInput(solid, SolidGenerator::k_color_input), &parent); ASSERT_EQ(bridge.widgets().size(), 1); @@ -362,25 +362,25 @@ TEST_F(WidgetPanelsTest, BridgeCreatesColorButtonForColorInput) TEST_F(WidgetPanelsTest, BridgeCreatesComboBoxForComboInput) { - auto *math = AddNode(); - math->Retranslate(); + auto *math = add_node(); + math->retranslate(); QWidget parent; - NodeParamViewWidgetBridge bridge(NodeInput(math, MathNode::kMethodIn), &parent); + NodeParamViewWidgetBridge bridge(NodeInput(math, MathNode::k_method_in), &parent); ASSERT_EQ(bridge.widgets().size(), 1); auto *combo = qobject_cast(bridge.widgets().first()); ASSERT_NE(combo, nullptr); - EXPECT_EQ(combo->count(), math->GetComboBoxStrings(MathNode::kMethodIn).size()); + EXPECT_EQ(combo->count(), math->get_combo_box_strings(MathNode::k_method_in).size()); EXPECT_GT(combo->count(), 0); } TEST_F(WidgetPanelsTest, BridgeCreatesCheckBoxForBooleanInput) { - auto *clip = AddNode(); + auto *clip = add_node(); QWidget parent; - NodeParamViewWidgetBridge bridge(NodeInput(clip, ClipBlock::kReverseInput), + NodeParamViewWidgetBridge bridge(NodeInput(clip, ClipBlock::k_reverse_input), &parent); ASSERT_EQ(bridge.widgets().size(), 1); @@ -389,40 +389,40 @@ TEST_F(WidgetPanelsTest, BridgeCreatesCheckBoxForBooleanInput) TEST_F(WidgetPanelsTest, BridgeUpdatesWidgetWhenNodeValueChanges) { - auto *math = AddNode(); - auto *viewer = AddNode(); + auto *math = add_node(); + auto *viewer = add_node(); QWidget parent; - NodeParamViewWidgetBridge bridge(NodeInput(math, MathNode::kParamAIn), &parent); + NodeParamViewWidgetBridge bridge(NodeInput(math, MathNode::k_param_a_in), &parent); auto *slider = qobject_cast(bridge.widgets().first()); ASSERT_NE(slider, nullptr); - EXPECT_DOUBLE_EQ(slider->GetValue(), 0.0); + EXPECT_DOUBLE_EQ(slider->get_value(), 0.0); // The bridge only refreshes widgets for value changes at the playhead // of a connected time target - bridge.SetTimeTarget(viewer); + bridge.set_time_target(viewer); - math->SetStandardValue(MathNode::kParamAIn, 2.5); - EXPECT_DOUBLE_EQ(slider->GetValue(), 2.5); + math->set_standard_value(MathNode::k_param_a_in, 2.5); + EXPECT_DOUBLE_EQ(slider->get_value(), 2.5); } TEST_F(WidgetPanelsTest, BridgePushesUndoCommandWhenWidgetChanges) { - auto *math = AddNode(); - math->Retranslate(); - ASSERT_EQ(math->GetStandardValue(MathNode::kMethodIn).toInt(), 0); + auto *math = add_node(); + math->retranslate(); + ASSERT_EQ(math->get_standard_value(MathNode::k_method_in).toInt(), 0); QWidget parent; - NodeParamViewWidgetBridge bridge(NodeInput(math, MathNode::kMethodIn), &parent); + NodeParamViewWidgetBridge bridge(NodeInput(math, MathNode::k_method_in), &parent); auto *combo = qobject_cast(bridge.widgets().first()); ASSERT_NE(combo, nullptr); ASSERT_GT(combo->count(), 1); combo->setCurrentIndex(1); - EXPECT_EQ(math->GetStandardValue(MathNode::kMethodIn).toInt(), 1); + EXPECT_EQ(math->get_standard_value(MathNode::k_method_in).toInt(), 1); Core::instance()->undo_stack()->undo(); - EXPECT_EQ(math->GetStandardValue(MathNode::kMethodIn).toInt(), 0); + EXPECT_EQ(math->get_standard_value(MathNode::k_method_in).toInt(), 0); Core::instance()->undo_stack()->clear(); } @@ -431,7 +431,7 @@ TEST(TaskView, TaskLifecycleUpdatesItems) TaskView view(nullptr); DummyTask task; - view.AddTask(&task); + view.add_task(&task); auto *item = view.findChild(); ASSERT_NE(item, nullptr); @@ -449,12 +449,12 @@ TEST(TaskView, TaskLifecycleUpdatesItems) // Progress signals drive the progress bar auto *bar = item->findChild(); ASSERT_NE(bar, nullptr); - emit task.ProgressChanged(0.5); + emit task.progress_changed(0.5); EXPECT_EQ(bar->value(), 50); // The cancel button relays the task through TaskCancelled Task *cancelled = nullptr; - QObject::connect(&view, &TaskView::TaskCancelled, + QObject::connect(&view, &TaskView::task_cancelled, [&cancelled](Task *t) { cancelled = t; }); auto *cancel_button = item->findChild(); ASSERT_NE(cancel_button, nullptr); @@ -462,7 +462,7 @@ TEST(TaskView, TaskLifecycleUpdatesItems) EXPECT_EQ(cancelled, &task); // Failure swaps in the error label - view.TaskFailed(&task); + view.task_failed(&task); bool found_error = false; foreach (QLabel *label, item->findChildren()) { if (label->text().contains(QStringLiteral("boom"))) { @@ -473,14 +473,14 @@ TEST(TaskView, TaskLifecycleUpdatesItems) EXPECT_TRUE(found_error); // Removal deletes the item once deferred deletions are processed - view.RemoveTask(&task); + view.remove_task(&task); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); EXPECT_EQ(view.findChild(), nullptr); } TEST(HistoryWidget, ReflectsAndDrivesUndoStack) { - EnsureAppSingletons(); + ensure_app_singletons(); UndoStack *stack = Core::instance()->undo_stack(); stack->clear(); @@ -501,21 +501,21 @@ TEST(HistoryWidget, ReflectsAndDrivesUndoStack) QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); EXPECT_EQ(counter, 1); - EXPECT_TRUE(stack->CanRedo()); + EXPECT_TRUE(stack->can_redo()); // Moving to the second entry redoes everything again widget.selectionModel()->setCurrentIndex(stack->index(2, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); EXPECT_EQ(counter, 2); - EXPECT_FALSE(stack->CanRedo()); + EXPECT_FALSE(stack->can_redo()); // Moving back to the sentinel row undoes both commands widget.selectionModel()->setCurrentIndex(stack->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); EXPECT_EQ(counter, 0); - EXPECT_TRUE(stack->CanRedo()); + EXPECT_TRUE(stack->can_redo()); stack->clear(); } @@ -523,135 +523,135 @@ TEST(HistoryWidget, ReflectsAndDrivesUndoStack) TEST(TimelineSelections, ShiftTimeMovesAllRanges) { TimelineWidgetSelections sel; - const Track::Reference video0(Track::kVideo, 0); + const Track::Reference video0(Track::k_video, 0); sel.insert(video0, - TimeRangeList({ TimeRange(rational(0), rational(10)) })); + TimeRangeList({ TimeRange(Rational(0), Rational(10)) })); - sel.ShiftTime(rational(5)); + sel.shift_time(Rational(5)); const TimeRangeList list = sel.value(video0); ASSERT_EQ(list.size(), 1); - EXPECT_EQ(list.first().in(), rational(5)); - EXPECT_EQ(list.first().out(), rational(15)); + EXPECT_EQ(list.first().in(), Rational(5)); + EXPECT_EQ(list.first().out(), Rational(15)); } TEST(TimelineSelections, ShiftTracksReindexesMatchingTypeOnly) { TimelineWidgetSelections sel; - sel.insert(Track::Reference(Track::kVideo, 0), - TimeRangeList({ TimeRange(rational(0), rational(10)) })); - sel.insert(Track::Reference(Track::kVideo, 1), - TimeRangeList({ TimeRange(rational(0), rational(10)) })); - sel.insert(Track::Reference(Track::kAudio, 0), - TimeRangeList({ TimeRange(rational(0), rational(10)) })); + sel.insert(Track::Reference(Track::k_video, 0), + TimeRangeList({ TimeRange(Rational(0), Rational(10)) })); + sel.insert(Track::Reference(Track::k_video, 1), + TimeRangeList({ TimeRange(Rational(0), Rational(10)) })); + sel.insert(Track::Reference(Track::k_audio, 0), + TimeRangeList({ TimeRange(Rational(0), Rational(10)) })); - sel.ShiftTracks(Track::kVideo, 2); + sel.shift_tracks(Track::k_video, 2); - EXPECT_FALSE(sel.contains(Track::Reference(Track::kVideo, 0))); - EXPECT_FALSE(sel.contains(Track::Reference(Track::kVideo, 1))); - EXPECT_TRUE(sel.contains(Track::Reference(Track::kVideo, 2))); - EXPECT_TRUE(sel.contains(Track::Reference(Track::kVideo, 3))); - EXPECT_TRUE(sel.contains(Track::Reference(Track::kAudio, 0))); + EXPECT_FALSE(sel.contains(Track::Reference(Track::k_video, 0))); + EXPECT_FALSE(sel.contains(Track::Reference(Track::k_video, 1))); + EXPECT_TRUE(sel.contains(Track::Reference(Track::k_video, 2))); + EXPECT_TRUE(sel.contains(Track::Reference(Track::k_video, 3))); + EXPECT_TRUE(sel.contains(Track::Reference(Track::k_audio, 0))); } TEST(TimelineSelections, TrimInAndOutAdjustRangeEnds) { TimelineWidgetSelections in_sel; - const Track::Reference video0(Track::kVideo, 0); + const Track::Reference video0(Track::k_video, 0); in_sel.insert(video0, - TimeRangeList({ TimeRange(rational(0), rational(10)) })); - in_sel.TrimIn(rational(2)); - EXPECT_EQ(in_sel.value(video0).first().in(), rational(2)); - EXPECT_EQ(in_sel.value(video0).first().out(), rational(10)); + TimeRangeList({ TimeRange(Rational(0), Rational(10)) })); + in_sel.trim_in(Rational(2)); + EXPECT_EQ(in_sel.value(video0).first().in(), Rational(2)); + EXPECT_EQ(in_sel.value(video0).first().out(), Rational(10)); TimelineWidgetSelections out_sel; out_sel.insert(video0, - TimeRangeList({ TimeRange(rational(0), rational(10)) })); - out_sel.TrimOut(rational(-3)); - EXPECT_EQ(out_sel.value(video0).first().in(), rational(0)); - EXPECT_EQ(out_sel.value(video0).first().out(), rational(7)); + TimeRangeList({ TimeRange(Rational(0), Rational(10)) })); + out_sel.trim_out(Rational(-3)); + EXPECT_EQ(out_sel.value(video0).first().in(), Rational(0)); + EXPECT_EQ(out_sel.value(video0).first().out(), Rational(7)); } TEST(TimelineSelections, SubtractSplitsAndIgnoresForeignTracks) { TimelineWidgetSelections ours; - const Track::Reference video0(Track::kVideo, 0); + const Track::Reference video0(Track::k_video, 0); ours.insert(video0, - TimeRangeList({ TimeRange(rational(0), rational(10)) })); + TimeRangeList({ TimeRange(Rational(0), Rational(10)) })); TimelineWidgetSelections theirs; theirs.insert(video0, - TimeRangeList({ TimeRange(rational(3), rational(5)) })); - theirs.insert(Track::Reference(Track::kAudio, 0), - TimeRangeList({ TimeRange(rational(0), rational(99)) })); + TimeRangeList({ TimeRange(Rational(3), Rational(5)) })); + theirs.insert(Track::Reference(Track::k_audio, 0), + TimeRangeList({ TimeRange(Rational(0), Rational(99)) })); - TimelineWidgetSelections result = ours.Subtracted(theirs); + TimelineWidgetSelections result = ours.subtracted(theirs); // The original is untouched by the const version EXPECT_EQ(ours.value(video0).size(), 1); const TimeRangeList remaining = result.value(video0); ASSERT_EQ(remaining.size(), 2); - EXPECT_EQ(remaining.at(0), TimeRange(rational(0), rational(3))); - EXPECT_EQ(remaining.at(1), TimeRange(rational(5), rational(10))); + EXPECT_EQ(remaining.at(0), TimeRange(Rational(0), Rational(3))); + EXPECT_EQ(remaining.at(1), TimeRange(Rational(5), Rational(10))); // In-place Subtract drops the subtracted span as well - ours.Subtract(theirs); + ours.subtract(theirs); EXPECT_EQ(ours.value(video0).size(), 2); } TEST(NodeViewScene, AddAndRemoveContexts) { - ColorManager::SetUpDefaultConfig(); + ColorManager::set_up_default_config(); Project project; - project.Initialize(); + project.initialize(); auto *folder = new Folder(); folder->setParent(&project); NodeViewScene scene; EXPECT_TRUE(scene.context_map().isEmpty()); - NodeViewContext *ctx = scene.AddContext(folder); + NodeViewContext *ctx = scene.add_context(folder); ASSERT_NE(ctx, nullptr); EXPECT_TRUE(scene.context_map().contains(folder)); - EXPECT_EQ(ctx->GetContext(), folder); + EXPECT_EQ(ctx->get_context(), folder); EXPECT_TRUE(scene.items().contains(ctx)); // Re-adding the same node returns the existing context item - EXPECT_EQ(scene.AddContext(folder), ctx); + EXPECT_EQ(scene.add_context(folder), ctx); EXPECT_EQ(scene.context_map().size(), 1); - scene.RemoveContext(folder); + scene.remove_context(folder); EXPECT_TRUE(scene.context_map().isEmpty()); } TEST(NodeViewScene, FlowDirectionControlsOrientation) { NodeViewScene scene; - EXPECT_EQ(scene.GetFlowDirection(), NodeViewCommon::kLeftToRight); - EXPECT_EQ(scene.GetFlowOrientation(), Qt::Horizontal); + EXPECT_EQ(scene.get_flow_direction(), NodeViewCommon::k_left_to_right); + EXPECT_EQ(scene.get_flow_orientation(), Qt::Horizontal); - scene.SetFlowDirection(NodeViewCommon::kTopToBottom); - EXPECT_EQ(scene.GetFlowDirection(), NodeViewCommon::kTopToBottom); - EXPECT_EQ(scene.GetFlowOrientation(), Qt::Vertical); + scene.set_flow_direction(NodeViewCommon::k_top_to_bottom); + EXPECT_EQ(scene.get_flow_direction(), NodeViewCommon::k_top_to_bottom); + EXPECT_EQ(scene.get_flow_orientation(), Qt::Vertical); } class MulticamWidgetTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + ColorManager::set_up_default_config(); + ensure_app_singletons(); // The display widget pulls the render backend off RenderManager, // which the bare Core singleton does not create (Core::Start() // would); viewer_display_repro_test does the same created_render_manager_ = (RenderManager::instance() == nullptr); if (created_render_manager_) { - RenderManager::CreateInstance(); + RenderManager::create_instance(); } project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } void TearDown() override @@ -661,7 +661,7 @@ protected: // Leave the singleton the way we found it: render suites check // RenderManager::instance() for null in their own teardowns if (created_render_manager_) { - RenderManager::DestroyInstance(); + RenderManager::destroy_instance(); created_render_manager_ = false; } } @@ -673,8 +673,8 @@ protected: TEST_F(MulticamWidgetTest, ConstructionCreatesDisplay) { MulticamWidget widget; - EXPECT_NE(widget.GetDisplayWidget(), nullptr); - EXPECT_EQ(widget.GetConnectedNode(), nullptr); + EXPECT_NE(widget.get_display_widget(), nullptr); + EXPECT_EQ(widget.get_connected_node(), nullptr); } TEST_F(MulticamWidgetTest, SwitchWithoutTimestampAppliesImmediately) @@ -687,8 +687,8 @@ TEST_F(MulticamWidgetTest, SwitchWithoutTimestampAppliesImmediately) clip->setParent(project_.get()); MulticamWidget widget; - widget.SetMulticamNode(viewer, node, clip, rational()); - EXPECT_EQ(widget.GetConnectedNode(), viewer); + widget.set_multicam_node(viewer, node, clip, Rational()); + EXPECT_EQ(widget.get_connected_node(), viewer); } TEST_F(MulticamWidgetTest, FutureSwitchWaitsForPlayheadToAdvance) @@ -703,14 +703,14 @@ TEST_F(MulticamWidgetTest, FutureSwitchWaitsForPlayheadToAdvance) clip->setParent(project_.get()); MulticamWidget widget; - widget.SetMulticamNode(viewer_a, node, clip, rational()); - ASSERT_EQ(widget.GetConnectedNode(), viewer_a); + widget.set_multicam_node(viewer_a, node, clip, Rational()); + ASSERT_EQ(widget.get_connected_node(), viewer_a); // A switch stamped for a later time is queued, not applied - widget.SetMulticamNode(viewer_b, node, clip, rational(5)); - EXPECT_EQ(widget.GetConnectedNode(), viewer_a); + widget.set_multicam_node(viewer_b, node, clip, Rational(5)); + EXPECT_EQ(widget.get_connected_node(), viewer_a); // Once playback time advances, the queued switch takes effect - viewer_a->SetPlayhead(rational(1)); - EXPECT_EQ(widget.GetConnectedNode(), viewer_b); + viewer_a->set_playhead(Rational(1)); + EXPECT_EQ(widget.get_connected_node(), viewer_b); } diff --git a/tests/gtest/widget_projectexplorer_test.cpp b/tests/gtest/widget_projectexplorer_test.cpp index 1b2d611a4..82d58656b 100644 --- a/tests/gtest/widget_projectexplorer_test.cpp +++ b/tests/gtest/widget_projectexplorer_test.cpp @@ -25,13 +25,13 @@ namespace { // Renames and moves go through the global undo stack hosted by Core -void EnsureAppSingletons() +void ensure_app_singletons() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } @@ -41,16 +41,16 @@ class ProjectViewModelTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + ColorManager::set_up_default_config(); + ensure_app_singletons(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); model_.set_project(project_.get()); } - template T *AddItem(Folder *parent) + template T *add_item(Folder *parent) { auto *node = new T(); node->setParent(project_.get()); @@ -72,13 +72,13 @@ TEST_F(ProjectViewModelTest, ModelWithoutProjectIsEmpty) TEST_F(ProjectViewModelTest, HierarchyIndexesAndParents) { - Folder *folder = AddItem(project_->root()); - Footage *footage = AddItem(project_->root()); - Sequence *sequence = AddItem(project_->root()); - Footage *nested = AddItem(folder); + Folder *folder = add_item(project_->root()); + Footage *footage = add_item(project_->root()); + Sequence *sequence = add_item(project_->root()); + Footage *nested = add_item(folder); ASSERT_EQ(model_.rowCount(), 3); - EXPECT_EQ(model_.columnCount(), ProjectViewModel::kColumnCount); + EXPECT_EQ(model_.columnCount(), ProjectViewModel::k_column_count); // Root children appear in insertion order EXPECT_EQ(model_.index(0, 0).internalPointer(), folder); @@ -95,8 +95,8 @@ TEST_F(ProjectViewModelTest, HierarchyIndexesAndParents) EXPECT_EQ(model_.parent(nested_index), model_.index(0, 0)); // CreateIndexFromItem round-trips through the same object - EXPECT_EQ(model_.CreateIndexFromItem(footage), model_.index(1, 0)); - EXPECT_EQ(model_.CreateIndexFromItem(nested).internalPointer(), nested); + EXPECT_EQ(model_.create_index_from_item(footage), model_.index(1, 0)); + EXPECT_EQ(model_.create_index_from_item(nested).internalPointer(), nested); // Only folders report children, even when empty EXPECT_TRUE(model_.hasChildren(model_.index(0, 0))); @@ -110,7 +110,7 @@ TEST_F(ProjectViewModelTest, ItemInsertAndRemoveEmitModelSignals) QSignalSpy about_to_remove(&model_, &QAbstractItemModel::rowsAboutToBeRemoved); QSignalSpy removed(&model_, &QAbstractItemModel::rowsRemoved); - Footage *footage = AddItem(project_->root()); + Footage *footage = add_item(project_->root()); EXPECT_EQ(about_to_insert.count(), 1); EXPECT_EQ(inserted.count(), 1); EXPECT_EQ(model_.rowCount(), 1); @@ -124,56 +124,56 @@ TEST_F(ProjectViewModelTest, ItemInsertAndRemoveEmitModelSignals) TEST_F(ProjectViewModelTest, DataColumnsAndHeader) { - Folder *folder = AddItem(project_->root()); - folder->SetLabel(QStringLiteral("Media")); + Folder *folder = add_item(project_->root()); + folder->set_label(QStringLiteral("Media")); - QModelIndex name_index = model_.CreateIndexFromItem(folder, ProjectViewModel::kName); + QModelIndex name_index = model_.create_index_from_item(folder, ProjectViewModel::k_name); EXPECT_EQ(model_.data(name_index, Qt::DisplayRole).toString(), QStringLiteral("Media")); EXPECT_EQ(model_.data(name_index, Qt::EditRole).toString(), QStringLiteral("Media")); - EXPECT_EQ(model_.data(name_index, ProjectViewModel::kInnerTextRole).toString(), + EXPECT_EQ(model_.data(name_index, ProjectViewModel::k_inner_text_role).toString(), QStringLiteral("Media")); // A folder carries no duration/rate/timestamps - EXPECT_FALSE(model_.data(model_.CreateIndexFromItem(folder, ProjectViewModel::kDuration), + EXPECT_FALSE(model_.data(model_.create_index_from_item(folder, ProjectViewModel::k_duration), Qt::DisplayRole) .isValid()); - EXPECT_FALSE(model_.data(model_.CreateIndexFromItem(folder, ProjectViewModel::kRate), + EXPECT_FALSE(model_.data(model_.create_index_from_item(folder, ProjectViewModel::k_rate), Qt::DisplayRole) .isValid()); // EditRole is only served for the name column - EXPECT_FALSE(model_.data(model_.CreateIndexFromItem(folder, ProjectViewModel::kDuration), + EXPECT_FALSE(model_.data(model_.create_index_from_item(folder, ProjectViewModel::k_duration), Qt::EditRole) .isValid()); - EXPECT_EQ(model_.headerData(ProjectViewModel::kName, Qt::Horizontal).toString(), + EXPECT_EQ(model_.headerData(ProjectViewModel::k_name, Qt::Horizontal).toString(), QStringLiteral("Name")); - EXPECT_EQ(model_.headerData(ProjectViewModel::kDuration, Qt::Horizontal).toString(), + EXPECT_EQ(model_.headerData(ProjectViewModel::k_duration, Qt::Horizontal).toString(), QStringLiteral("Duration")); - EXPECT_EQ(model_.headerData(ProjectViewModel::kRate, Qt::Horizontal).toString(), + EXPECT_EQ(model_.headerData(ProjectViewModel::k_rate, Qt::Horizontal).toString(), QStringLiteral("Rate")); - EXPECT_EQ(model_.headerData(ProjectViewModel::kLastModified, Qt::Horizontal).toString(), + EXPECT_EQ(model_.headerData(ProjectViewModel::k_last_modified, Qt::Horizontal).toString(), QStringLiteral("Modified")); - EXPECT_EQ(model_.headerData(ProjectViewModel::kCreatedTime, Qt::Horizontal).toString(), + EXPECT_EQ(model_.headerData(ProjectViewModel::k_created_time, Qt::Horizontal).toString(), QStringLiteral("Created")); } TEST_F(ProjectViewModelTest, FlagsMarkNameEditableAndFoldersDroppable) { - Folder *folder = AddItem(project_->root()); - Footage *footage = AddItem(project_->root()); + Folder *folder = add_item(project_->root()); + Footage *footage = add_item(project_->root()); const Qt::ItemFlags folder_name_flags = - model_.flags(model_.CreateIndexFromItem(folder, ProjectViewModel::kName)); + model_.flags(model_.create_index_from_item(folder, ProjectViewModel::k_name)); EXPECT_TRUE(folder_name_flags & Qt::ItemIsEditable); EXPECT_TRUE(folder_name_flags & Qt::ItemIsDragEnabled); EXPECT_TRUE(folder_name_flags & Qt::ItemIsDropEnabled); // Non-name columns are not editable, non-folders do not accept drops const Qt::ItemFlags footage_duration_flags = - model_.flags(model_.CreateIndexFromItem(footage, ProjectViewModel::kDuration)); + model_.flags(model_.create_index_from_item(footage, ProjectViewModel::k_duration)); EXPECT_FALSE(footage_duration_flags & Qt::ItemIsEditable); EXPECT_FALSE(footage_duration_flags & Qt::ItemIsDropEnabled); @@ -183,45 +183,45 @@ TEST_F(ProjectViewModelTest, FlagsMarkNameEditableAndFoldersDroppable) TEST_F(ProjectViewModelTest, SetDataRenamesItemThroughUndoStack) { - Folder *folder = AddItem(project_->root()); - folder->SetLabel(QStringLiteral("Before")); + Folder *folder = add_item(project_->root()); + folder->set_label(QStringLiteral("Before")); QSignalSpy data_changed(&model_, &QAbstractItemModel::dataChanged); - QModelIndex name_index = model_.CreateIndexFromItem(folder, ProjectViewModel::kName); + QModelIndex name_index = model_.create_index_from_item(folder, ProjectViewModel::k_name); EXPECT_TRUE(model_.setData(name_index, QStringLiteral("After"), Qt::EditRole)); - EXPECT_EQ(folder->GetLabel(), QStringLiteral("After")); + EXPECT_EQ(folder->get_label(), QStringLiteral("After")); EXPECT_GE(data_changed.count(), 1); // The rename is a regular undo command Core::instance()->undo_stack()->undo(); - EXPECT_EQ(folder->GetLabel(), QStringLiteral("Before")); + EXPECT_EQ(folder->get_label(), QStringLiteral("Before")); Core::instance()->undo_stack()->clear(); // Empty names and other columns are rejected EXPECT_FALSE(model_.setData(name_index, QString(), Qt::EditRole)); - EXPECT_FALSE(model_.setData(model_.CreateIndexFromItem(folder, ProjectViewModel::kRate), + EXPECT_FALSE(model_.setData(model_.create_index_from_item(folder, ProjectViewModel::k_rate), QStringLiteral("After"), Qt::EditRole)); - EXPECT_EQ(folder->GetLabel(), QStringLiteral("Before")); + EXPECT_EQ(folder->get_label(), QStringLiteral("Before")); } TEST_F(ProjectViewModelTest, MimeDataEncodesEachRowOnce) { EXPECT_EQ(model_.mimeTypes(), - (QStringList{ Project::kItemMimeType, QStringLiteral("text/uri-list") })); + (QStringList{ Project::k_item_mime_type, QStringLiteral("text/uri-list") })); - Footage *footage = AddItem(project_->root()); - Folder *folder = AddItem(project_->root()); + Footage *footage = add_item(project_->root()); + Folder *folder = add_item(project_->root()); // Passing every column of two rows must still encode only two items - QModelIndexList indexes{ model_.CreateIndexFromItem(footage, ProjectViewModel::kName), - model_.CreateIndexFromItem(footage, ProjectViewModel::kDuration), - model_.CreateIndexFromItem(folder, ProjectViewModel::kName) }; + QModelIndexList indexes{ model_.create_index_from_item(footage, ProjectViewModel::k_name), + model_.create_index_from_item(footage, ProjectViewModel::k_duration), + model_.create_index_from_item(folder, ProjectViewModel::k_name) }; std::unique_ptr mime(model_.mimeData(indexes)); ASSERT_NE(mime, nullptr); - ASSERT_TRUE(mime->hasFormat(Project::kItemMimeType)); + ASSERT_TRUE(mime->hasFormat(Project::k_item_mime_type)); - QByteArray encoded = mime->data(Project::kItemMimeType); + QByteArray encoded = mime->data(Project::k_item_mime_type); QDataStream stream(&encoded, QIODevice::ReadOnly); QVector streams; quintptr ptr = 0; @@ -240,19 +240,19 @@ TEST_F(ProjectViewModelTest, MimeDataEncodesEachRowOnce) TEST_F(ProjectViewModelTest, DropMimeDataMovesItemIntoFolder) { - Folder *folder = AddItem(project_->root()); - Footage *footage = AddItem(project_->root()); + Folder *folder = add_item(project_->root()); + Footage *footage = add_item(project_->root()); ASSERT_EQ(model_.rowCount(), 2); std::unique_ptr mime( - model_.mimeData({ model_.CreateIndexFromItem(footage) })); + model_.mimeData({ model_.create_index_from_item(footage) })); ASSERT_NE(mime, nullptr); EXPECT_TRUE(model_.dropMimeData(mime.get(), Qt::CopyAction, -1, -1, - model_.CreateIndexFromItem(folder))); + model_.create_index_from_item(folder))); EXPECT_EQ(footage->folder(), folder); EXPECT_EQ(model_.rowCount(), 1); - EXPECT_EQ(model_.rowCount(model_.CreateIndexFromItem(folder)), 1); + EXPECT_EQ(model_.rowCount(model_.create_index_from_item(folder)), 1); // The move is undoable Core::instance()->undo_stack()->undo(); @@ -263,27 +263,27 @@ TEST_F(ProjectViewModelTest, DropMimeDataMovesItemIntoFolder) TEST_F(ProjectViewModelTest, DropRejectsNonFolderAndSelfNesting) { - Folder *folder = AddItem(project_->root()); - Folder *subfolder = AddItem(folder); - Footage *footage = AddItem(project_->root()); + Folder *folder = add_item(project_->root()); + Folder *subfolder = add_item(folder); + Footage *footage = add_item(project_->root()); // Cannot drop onto a non-folder item std::unique_ptr footage_mime( - model_.mimeData({ model_.CreateIndexFromItem(footage) })); + model_.mimeData({ model_.create_index_from_item(footage) })); EXPECT_FALSE(model_.dropMimeData(footage_mime.get(), Qt::CopyAction, -1, -1, - model_.CreateIndexFromItem(footage))); + model_.create_index_from_item(footage))); EXPECT_EQ(footage->folder(), project_->root()); // Dropping a folder into its own descendant is skipped as a no-op std::unique_ptr folder_mime( - model_.mimeData({ model_.CreateIndexFromItem(folder) })); + model_.mimeData({ model_.create_index_from_item(folder) })); EXPECT_TRUE(model_.dropMimeData(folder_mime.get(), Qt::CopyAction, -1, -1, - model_.CreateIndexFromItem(subfolder))); + model_.create_index_from_item(subfolder))); EXPECT_EQ(folder->folder(), project_->root()); // Dropping onto the background moves items to the root std::unique_ptr sub_mime( - model_.mimeData({ model_.CreateIndexFromItem(subfolder) })); + model_.mimeData({ model_.create_index_from_item(subfolder) })); EXPECT_TRUE(model_.dropMimeData(sub_mime.get(), Qt::CopyAction, -1, -1, QModelIndex())); EXPECT_EQ(subfolder->folder(), project_->root()); @@ -294,14 +294,14 @@ class ProjectExplorerTest : public ::testing::Test { protected: void SetUp() override { - ColorManager::SetUpDefaultConfig(); - EnsureAppSingletons(); + ColorManager::set_up_default_config(); + ensure_app_singletons(); project_ = std::make_unique(); - project_->Initialize(); + project_->initialize(); } - template T *AddItem(Folder *parent) + template T *add_item(Folder *parent) { auto *node = new T(); node->setParent(project_.get()); @@ -321,50 +321,50 @@ TEST_F(ProjectExplorerTest, SetProjectAndSwitchViewType) EXPECT_EQ(explorer.project(), project_.get()); // Tree view is the default - EXPECT_EQ(explorer.view_type(), ProjectToolbar::TreeView); + EXPECT_EQ(explorer.view_type(), ProjectToolbar::tree_view); - explorer.set_view_type(ProjectToolbar::ListView); - EXPECT_EQ(explorer.view_type(), ProjectToolbar::ListView); + explorer.set_view_type(ProjectToolbar::list_view); + EXPECT_EQ(explorer.view_type(), ProjectToolbar::list_view); - explorer.set_view_type(ProjectToolbar::IconView); - EXPECT_EQ(explorer.view_type(), ProjectToolbar::IconView); + explorer.set_view_type(ProjectToolbar::icon_view); + EXPECT_EQ(explorer.view_type(), ProjectToolbar::icon_view); } TEST_F(ProjectExplorerTest, GetSelectedFolderFallsBackToRoot) { - Folder *folder = AddItem(project_->root()); - Footage *footage = AddItem(project_->root()); + Folder *folder = add_item(project_->root()); + Footage *footage = add_item(project_->root()); ProjectExplorer explorer(nullptr); explorer.set_project(project_.get()); // No selection: heuristic returns the project root - EXPECT_EQ(explorer.GetSelectedFolder(), project_->root()); + EXPECT_EQ(explorer.get_selected_folder(), project_->root()); // A selected folder is returned directly - EXPECT_TRUE(explorer.SelectItem(folder)); - EXPECT_EQ(explorer.GetSelectedFolder(), folder); + EXPECT_TRUE(explorer.select_item(folder)); + EXPECT_EQ(explorer.get_selected_folder(), folder); // A selected non-folder resolves to its parent folder - EXPECT_TRUE(explorer.SelectItem(footage)); - EXPECT_EQ(explorer.GetSelectedFolder(), project_->root()); + EXPECT_TRUE(explorer.select_item(footage)); + EXPECT_EQ(explorer.get_selected_folder(), project_->root()); } TEST_F(ProjectExplorerTest, SelectItemUpdatesSelectedItems) { - Footage *footage = AddItem(project_->root()); + Footage *footage = add_item(project_->root()); ProjectExplorer explorer(nullptr); explorer.set_project(project_.get()); - EXPECT_TRUE(explorer.SelectedItems().isEmpty()); + EXPECT_TRUE(explorer.selected_items().isEmpty()); - EXPECT_TRUE(explorer.SelectItem(footage)); - EXPECT_EQ(explorer.SelectedItems().size(), 1); - EXPECT_EQ(explorer.SelectedItems().first(), footage); + EXPECT_TRUE(explorer.select_item(footage)); + EXPECT_EQ(explorer.selected_items().size(), 1); + EXPECT_EQ(explorer.selected_items().first(), footage); - explorer.DeselectAll(); - EXPECT_TRUE(explorer.SelectedItems().isEmpty()); + explorer.deselect_all(); + EXPECT_TRUE(explorer.selected_items().isEmpty()); } class ProjectToolbarTest : public ::testing::Test { @@ -378,9 +378,9 @@ TEST_F(ProjectToolbarTest, ActionButtonsEmitSignals) const QList buttons = toolbar.findChildren(); ASSERT_EQ(buttons.size(), 6); - QSignalSpy new_spy(&toolbar, &ProjectToolbar::NewClicked); - QSignalSpy open_spy(&toolbar, &ProjectToolbar::OpenClicked); - QSignalSpy save_spy(&toolbar, &ProjectToolbar::SaveClicked); + QSignalSpy new_spy(&toolbar, &ProjectToolbar::new_clicked); + QSignalSpy open_spy(&toolbar, &ProjectToolbar::open_clicked); + QSignalSpy save_spy(&toolbar, &ProjectToolbar::save_clicked); buttons.at(0)->click(); EXPECT_EQ(new_spy.count(), 1); @@ -399,7 +399,7 @@ TEST_F(ProjectToolbarTest, SearchFieldForwardsTextChanges) auto *search = toolbar.findChild(); ASSERT_NE(search, nullptr); - QSignalSpy search_spy(&toolbar, &ProjectToolbar::SearchChanged); + QSignalSpy search_spy(&toolbar, &ProjectToolbar::search_changed); search->setText(QStringLiteral("media")); ASSERT_EQ(search_spy.count(), 1); @@ -416,9 +416,9 @@ TEST_F(ProjectToolbarTest, ViewButtonsAreExclusiveAndEmitViewChanged) QPushButton *list_button = buttons.at(4); QPushButton *icon_button = buttons.at(5); - ProjectToolbar::ViewType received = ProjectToolbar::TreeView; + ProjectToolbar::ViewType received = ProjectToolbar::tree_view; int emissions = 0; - QObject::connect(&toolbar, &ProjectToolbar::ViewChanged, + QObject::connect(&toolbar, &ProjectToolbar::view_changed, [&received, &emissions](ProjectToolbar::ViewType type) { received = type; ++emissions; @@ -426,19 +426,19 @@ TEST_F(ProjectToolbarTest, ViewButtonsAreExclusiveAndEmitViewChanged) list_button->click(); EXPECT_EQ(emissions, 1); - EXPECT_EQ(received, ProjectToolbar::ListView); + EXPECT_EQ(received, ProjectToolbar::list_view); EXPECT_TRUE(list_button->isChecked()); EXPECT_FALSE(tree_button->isChecked()); EXPECT_FALSE(icon_button->isChecked()); icon_button->click(); EXPECT_EQ(emissions, 2); - EXPECT_EQ(received, ProjectToolbar::IconView); + EXPECT_EQ(received, ProjectToolbar::icon_view); EXPECT_TRUE(icon_button->isChecked()); EXPECT_FALSE(list_button->isChecked()); // SetView only checks the button; it does not re-emit ViewChanged - toolbar.SetView(ProjectToolbar::TreeView); + toolbar.set_view(ProjectToolbar::tree_view); EXPECT_EQ(emissions, 2); EXPECT_TRUE(tree_button->isChecked()); EXPECT_FALSE(icon_button->isChecked()); diff --git a/tests/gtest/widget_slider_test.cpp b/tests/gtest/widget_slider_test.cpp index b8f926636..dd199062d 100644 --- a/tests/gtest/widget_slider_test.cpp +++ b/tests/gtest/widget_slider_test.cpp @@ -14,37 +14,37 @@ namespace // without simulating mouse drags class ExposedFloatSlider : public olive::FloatSlider { public: - QString ValueToStringPublic(const QVariant &v) const + QString value_to_string_public(const QVariant &v) const { - return ValueToString(v); + return value_to_string(v); } - QVariant StringToValuePublic(const QString &s, bool *ok) const + QVariant string_to_value_public(const QString &s, bool *ok) const { - return StringToValue(s, ok); + return string_to_value(s, ok); } - QVariant AdjustDragPublic(const QVariant &start, const double &drag) const + QVariant adjust_drag_public(const QVariant &start, const double &drag) const { - return AdjustDragDistanceInternal(start, drag); + return adjust_drag_distance_internal(start, drag); } }; class ExposedIntegerSlider : public olive::IntegerSlider { public: - QString ValueToStringPublic(const QVariant &v) const + QString value_to_string_public(const QVariant &v) const { - return ValueToString(v); + return value_to_string(v); } - QVariant StringToValuePublic(const QString &s, bool *ok) const + QVariant string_to_value_public(const QString &s, bool *ok) const { - return StringToValue(s, ok); + return string_to_value(s, ok); } - QVariant AdjustDragPublic(const QVariant &start, const double &drag) const + QVariant adjust_drag_public(const QVariant &start, const double &drag) const { - return AdjustDragDistanceInternal(start, drag); + return adjust_drag_distance_internal(start, drag); } }; @@ -54,94 +54,94 @@ TEST(WidgetSlider, FloatToStringFormatsAndTrims) { using olive::DecimalSliderBase; - EXPECT_EQ(DecimalSliderBase::FloatToString(1.5, 2, false), + EXPECT_EQ(DecimalSliderBase::float_to_string(1.5, 2, false), QStringLiteral("1.50")); - EXPECT_EQ(DecimalSliderBase::FloatToString(1.5, 2, true), + EXPECT_EQ(DecimalSliderBase::float_to_string(1.5, 2, true), QStringLiteral("1.5")); // Trimming always leaves at least one decimal digit - EXPECT_EQ(DecimalSliderBase::FloatToString(2.0, 2, true), + EXPECT_EQ(DecimalSliderBase::float_to_string(2.0, 2, true), QStringLiteral("2.0")); - EXPECT_EQ(DecimalSliderBase::FloatToString(0.0, 3, true), + EXPECT_EQ(DecimalSliderBase::float_to_string(0.0, 3, true), QStringLiteral("0.0")); - EXPECT_EQ(DecimalSliderBase::FloatToString(-3.5, 1, false), + EXPECT_EQ(DecimalSliderBase::float_to_string(-3.5, 1, false), QStringLiteral("-3.5")); - EXPECT_EQ(DecimalSliderBase::FloatToString(1.234, 2, false), + EXPECT_EQ(DecimalSliderBase::float_to_string(1.234, 2, false), QStringLiteral("1.23")); } TEST(WidgetSlider, FloatSetValueClampsToRange) { olive::FloatSlider s; - EXPECT_DOUBLE_EQ(s.GetValue(), 0.0); + EXPECT_DOUBLE_EQ(s.get_value(), 0.0); - s.SetValue(1.25); - EXPECT_DOUBLE_EQ(s.GetValue(), 1.25); + s.set_value(1.25); + EXPECT_DOUBLE_EQ(s.get_value(), 1.25); - s.SetMinimum(0.0); - s.SetMaximum(2.0); + s.set_minimum(0.0); + s.set_maximum(2.0); - s.SetValue(-5.0); - EXPECT_DOUBLE_EQ(s.GetValue(), 0.0); + s.set_value(-5.0); + EXPECT_DOUBLE_EQ(s.get_value(), 0.0); - s.SetValue(10.0); - EXPECT_DOUBLE_EQ(s.GetValue(), 2.0); + s.set_value(10.0); + EXPECT_DOUBLE_EQ(s.get_value(), 2.0); } TEST(WidgetSlider, FloatRangeChangeClampsExistingValue) { olive::FloatSlider s; - s.SetValue(-3.0); - s.SetMinimum(0.0); - EXPECT_DOUBLE_EQ(s.GetValue(), 0.0); + s.set_value(-3.0); + s.set_minimum(0.0); + EXPECT_DOUBLE_EQ(s.get_value(), 0.0); - s.SetValue(5.0); - s.SetMaximum(1.0); - EXPECT_DOUBLE_EQ(s.GetValue(), 1.0); + s.set_value(5.0); + s.set_maximum(1.0); + EXPECT_DOUBLE_EQ(s.get_value(), 1.0); } TEST(WidgetSlider, FloatDisplayTransformRoundTrips) { EXPECT_DOUBLE_EQ( - olive::FloatSlider::TransformValueToDisplay(0.5, olive::FloatSlider::kPercentage), + olive::FloatSlider::transform_value_to_display(0.5, olive::FloatSlider::k_percentage), 50.0); EXPECT_DOUBLE_EQ( - olive::FloatSlider::TransformDisplayToValue(50.0, olive::FloatSlider::kPercentage), + olive::FloatSlider::transform_display_to_value(50.0, olive::FloatSlider::k_percentage), 0.5); EXPECT_DOUBLE_EQ( - olive::FloatSlider::TransformValueToDisplay(1.0, olive::FloatSlider::kDecibel), + olive::FloatSlider::transform_value_to_display(1.0, olive::FloatSlider::k_decibel), 0.0); EXPECT_NEAR( - olive::FloatSlider::TransformValueToDisplay(0.5, olive::FloatSlider::kDecibel), + olive::FloatSlider::transform_value_to_display(0.5, olive::FloatSlider::k_decibel), -6.0206, 0.001); EXPECT_NEAR( - olive::FloatSlider::TransformDisplayToValue( - olive::FloatSlider::TransformValueToDisplay(0.75, olive::FloatSlider::kDecibel), - olive::FloatSlider::kDecibel), + olive::FloatSlider::transform_display_to_value( + olive::FloatSlider::transform_value_to_display(0.75, olive::FloatSlider::k_decibel), + olive::FloatSlider::k_decibel), 0.75, 1e-12); EXPECT_DOUBLE_EQ( - olive::FloatSlider::TransformValueToDisplay(3.5, olive::FloatSlider::kNormal), + olive::FloatSlider::transform_value_to_display(3.5, olive::FloatSlider::k_normal), 3.5); EXPECT_DOUBLE_EQ( - olive::FloatSlider::TransformDisplayToValue(3.5, olive::FloatSlider::kNormal), + olive::FloatSlider::transform_display_to_value(3.5, olive::FloatSlider::k_normal), 3.5); } TEST(WidgetSlider, FloatStaticValueToStringRespectsDisplayType) { // Zero volume in decibel mode displays as an infinity symbol (U+221E) - EXPECT_EQ(olive::FloatSlider::ValueToString(0.0, olive::FloatSlider::kDecibel, 2, + EXPECT_EQ(olive::FloatSlider::value_to_string(0.0, olive::FloatSlider::k_decibel, 2, false), QString(QChar(0x221E))); - EXPECT_EQ(olive::FloatSlider::ValueToString(0.5, olive::FloatSlider::kPercentage, + EXPECT_EQ(olive::FloatSlider::value_to_string(0.5, olive::FloatSlider::k_percentage, 1, false), QStringLiteral("50.0")); - EXPECT_EQ(olive::FloatSlider::ValueToString(1.234, olive::FloatSlider::kNormal, + EXPECT_EQ(olive::FloatSlider::value_to_string(1.234, olive::FloatSlider::k_normal, 2, false), QStringLiteral("1.23")); } @@ -152,29 +152,29 @@ TEST(WidgetSlider, FloatLabelShowsFormattedValue) QLabel *label = s.findChild(); ASSERT_NE(label, nullptr); - s.SetValue(0.5); + s.set_value(0.5); EXPECT_EQ(label->text(), QStringLiteral("0.50")); - s.SetDisplayType(olive::FloatSlider::kPercentage); + s.set_display_type(olive::FloatSlider::k_percentage); EXPECT_EQ(label->text(), QStringLiteral("50.00%")); - s.SetFormat(QStringLiteral("%1 px")); + s.set_format(QStringLiteral("%1 px")); EXPECT_EQ(label->text(), QStringLiteral("50.00 px")); - s.ClearFormat(); - s.SetDisplayType(olive::FloatSlider::kNormal); + s.clear_format(); + s.set_display_type(olive::FloatSlider::k_normal); EXPECT_EQ(label->text(), QStringLiteral("0.50")); } TEST(WidgetSlider, FloatOffsetAppliesToDisplayAndParse) { ExposedFloatSlider s; - s.SetOffset(10.0); + s.set_offset(10.0); - EXPECT_EQ(s.ValueToStringPublic(2.0), QStringLiteral("12.00")); + EXPECT_EQ(s.value_to_string_public(2.0), QStringLiteral("12.00")); bool ok = false; - QVariant v = s.StringToValuePublic(QStringLiteral("12.5"), &ok); + QVariant v = s.string_to_value_public(QStringLiteral("12.5"), &ok); EXPECT_TRUE(ok); EXPECT_DOUBLE_EQ(v.toDouble(), 2.5); } @@ -184,17 +184,17 @@ TEST(WidgetSlider, FloatStringToValueRejectsGarbage) ExposedFloatSlider s; bool ok = true; - s.StringToValuePublic(QStringLiteral("not a number"), &ok); + s.string_to_value_public(QStringLiteral("not a number"), &ok); EXPECT_FALSE(ok); } TEST(WidgetSlider, FloatStringToValueRespectsDisplayType) { ExposedFloatSlider s; - s.SetDisplayType(olive::FloatSlider::kPercentage); + s.set_display_type(olive::FloatSlider::k_percentage); bool ok = false; - QVariant v = s.StringToValuePublic(QStringLiteral("50"), &ok); + QVariant v = s.string_to_value_public(QStringLiteral("50"), &ok); EXPECT_TRUE(ok); EXPECT_DOUBLE_EQ(v.toDouble(), 0.5); } @@ -204,17 +204,17 @@ TEST(WidgetSlider, FloatDragDistanceRespectsDisplayType) ExposedFloatSlider s; // Normal: plain addition - EXPECT_DOUBLE_EQ(s.AdjustDragPublic(1.0, 2.5).toDouble(), 3.5); + EXPECT_DOUBLE_EQ(s.adjust_drag_public(1.0, 2.5).toDouble(), 3.5); // Percentage: drag is scaled by 1/100 - s.SetDisplayType(olive::FloatSlider::kPercentage); - EXPECT_DOUBLE_EQ(s.AdjustDragPublic(0.5, 10.0).toDouble(), 0.6); + s.set_display_type(olive::FloatSlider::k_percentage); + EXPECT_DOUBLE_EQ(s.adjust_drag_public(0.5, 10.0).toDouble(), 0.6); // Decibel: drag happens in dB space - s.SetDisplayType(olive::FloatSlider::kDecibel); + s.set_display_type(olive::FloatSlider::k_decibel); const double expected = - olive::Decibel::toLinear(olive::Decibel::fromLinear(1.0) + 6.0); - EXPECT_DOUBLE_EQ(s.AdjustDragPublic(1.0, 6.0).toDouble(), expected); + olive::Decibel::to_linear(olive::Decibel::from_linear(1.0) + 6.0); + EXPECT_DOUBLE_EQ(s.adjust_drag_public(1.0, 6.0).toDouble(), expected); } TEST(WidgetSlider, TristateShowsDashesUntilValueSet) @@ -223,14 +223,14 @@ TEST(WidgetSlider, TristateShowsDashesUntilValueSet) QLabel *label = s.findChild(); ASSERT_NE(label, nullptr); - s.SetValue(1.0); - s.SetTristate(); - EXPECT_TRUE(s.IsTristate()); + s.set_value(1.0); + s.set_tristate(); + EXPECT_TRUE(s.is_tristate()); EXPECT_EQ(label->text(), QStringLiteral("---")); // Setting a value clears the tristate display - s.SetValue(2.0); - EXPECT_FALSE(s.IsTristate()); + s.set_value(2.0); + EXPECT_FALSE(s.is_tristate()); EXPECT_EQ(label->text(), QStringLiteral("2.00")); } @@ -240,30 +240,30 @@ TEST(WidgetSlider, LabelSubstitutionOverridesText) QLabel *label = s.findChild(); ASSERT_NE(label, nullptr); - s.SetValue(0.0); - s.InsertLabelSubstitution(0.0, QStringLiteral("Zero")); + s.set_value(0.0); + s.insert_label_substitution(0.0, QStringLiteral("Zero")); EXPECT_EQ(label->text(), QStringLiteral("Zero")); - s.SetValue(1.0); + s.set_value(1.0); EXPECT_EQ(label->text(), QStringLiteral("1.00")); } TEST(WidgetSlider, IntegerSetValueClampsToRange) { olive::IntegerSlider s; - EXPECT_EQ(s.GetValue(), 0); + EXPECT_EQ(s.get_value(), 0); - s.SetMinimum(0); - s.SetMaximum(10); + s.set_minimum(0); + s.set_maximum(10); - s.SetValue(-3); - EXPECT_EQ(s.GetValue(), 0); + s.set_value(-3); + EXPECT_EQ(s.get_value(), 0); - s.SetValue(42); - EXPECT_EQ(s.GetValue(), 10); + s.set_value(42); + EXPECT_EQ(s.get_value(), 10); - s.SetValue(7); - EXPECT_EQ(s.GetValue(), 7); + s.set_value(7); + EXPECT_EQ(s.get_value(), 7); } TEST(WidgetSlider, IntegerStringToValueRounds) @@ -271,25 +271,25 @@ TEST(WidgetSlider, IntegerStringToValueRounds) ExposedIntegerSlider s; bool ok = false; - EXPECT_EQ(s.StringToValuePublic(QStringLiteral("3.6"), &ok).toLongLong(), 4); + EXPECT_EQ(s.string_to_value_public(QStringLiteral("3.6"), &ok).toLongLong(), 4); EXPECT_TRUE(ok); - EXPECT_EQ(s.StringToValuePublic(QStringLiteral("-2.4"), &ok).toLongLong(), -2); + EXPECT_EQ(s.string_to_value_public(QStringLiteral("-2.4"), &ok).toLongLong(), -2); EXPECT_TRUE(ok); ok = true; - s.StringToValuePublic(QStringLiteral("junk"), &ok); + s.string_to_value_public(QStringLiteral("junk"), &ok); EXPECT_FALSE(ok); } TEST(WidgetSlider, IntegerOffsetAppliesToDisplayAndParse) { ExposedIntegerSlider s; - s.SetOffset(10); + s.set_offset(10); - EXPECT_EQ(s.ValueToStringPublic(2), QStringLiteral("12")); + EXPECT_EQ(s.value_to_string_public(2), QStringLiteral("12")); bool ok = false; - EXPECT_EQ(s.StringToValuePublic(QStringLiteral("12"), &ok).toLongLong(), 2); + EXPECT_EQ(s.string_to_value_public(QStringLiteral("12"), &ok).toLongLong(), 2); EXPECT_TRUE(ok); } @@ -297,6 +297,6 @@ TEST(WidgetSlider, IntegerDragRoundsToWhole) { ExposedIntegerSlider s; - EXPECT_EQ(s.AdjustDragPublic(2, 1.4).toLongLong(), 3); - EXPECT_EQ(s.AdjustDragPublic(2, -1.4).toLongLong(), 1); + EXPECT_EQ(s.adjust_drag_public(2, 1.4).toLongLong(), 3); + EXPECT_EQ(s.adjust_drag_public(2, -1.4).toLongLong(), 1); } diff --git a/tests/gtest/widget_timeruler_playback_test.cpp b/tests/gtest/widget_timeruler_playback_test.cpp index 5b154e096..d34bd45af 100644 --- a/tests/gtest/widget_timeruler_playback_test.cpp +++ b/tests/gtest/widget_timeruler_playback_test.cpp @@ -23,13 +23,13 @@ namespace { // PlaybackControls and playhead seeking talk to the Core singleton -void EnsureAppSingletons() +void ensure_app_singletons() { if (!olive::Core::instance()) { new olive::Core(olive::Core::CoreParams()); // intentionally leaked } if (!olive::DiskManager::instance()) { - olive::DiskManager::CreateInstance(); + olive::DiskManager::create_instance(); } } @@ -37,12 +37,12 @@ void EnsureAppSingletons() TEST(TimeRuler, ConstructionWithAndWithoutDecorations) { - EnsureAppSingletons(); + ensure_app_singletons(); // Text shown, cache status hidden TimeRuler plain; - EXPECT_EQ(plain.GetMarkers(), nullptr); - EXPECT_EQ(plain.GetWorkArea(), nullptr); + EXPECT_EQ(plain.get_markers(), nullptr); + EXPECT_EQ(plain.get_work_area(), nullptr); // Text hidden, cache status shown TimeRuler decorated(false, true); @@ -51,19 +51,19 @@ TEST(TimeRuler, ConstructionWithAndWithoutDecorations) // text height plus marker height always, another text height when text // is visible, and the cache indicator height when cache status is shown const QFontMetrics fm = plain.fontMetrics(); - const int marker_h = TimelineMarker::GetMarkerHeight(fm); + const int marker_h = TimelineMarker::get_marker_height(fm); EXPECT_EQ(plain.minimumHeight(), 2 * fm.height() + marker_h); EXPECT_EQ(plain.maximumHeight(), plain.minimumHeight()); EXPECT_EQ(decorated.minimumHeight(), - fm.height() + PlaybackCache::GetCacheIndicatorHeight() + marker_h); + fm.height() + PlaybackCache::get_cache_indicator_height() + marker_h); EXPECT_EQ(decorated.maximumHeight(), decorated.minimumHeight()); // Centered text only affects painting, not geometry - decorated.SetCenteredText(true); + decorated.set_centered_text(true); EXPECT_EQ(decorated.minimumHeight(), - fm.height() + PlaybackCache::GetCacheIndicatorHeight() + marker_h); + fm.height() + PlaybackCache::get_cache_indicator_height() + marker_h); } TEST(TimeRuler, TimebaseAndScaleDriveTimePixelConversion) @@ -71,67 +71,67 @@ TEST(TimeRuler, TimebaseAndScaleDriveTimePixelConversion) TimeRuler ruler; // Without a timebase everything collapses to zero - EXPECT_DOUBLE_EQ(ruler.TimeToScene(rational(1)), 0.0); + EXPECT_DOUBLE_EQ(ruler.time_to_scene(Rational(1)), 0.0); - ruler.SetTimebase(rational(1, 30)); - ruler.SetScale(100.0); + ruler.set_timebase(Rational(1, 30)); + ruler.set_scale(100.0); // One second at scale 100 lands at scene x=100, half a second at 50 - EXPECT_DOUBLE_EQ(ruler.TimeToScene(rational(1)), 100.0); - EXPECT_DOUBLE_EQ(ruler.TimeToScene(rational(1, 2)), 50.0); + EXPECT_DOUBLE_EQ(ruler.time_to_scene(Rational(1)), 100.0); + EXPECT_DOUBLE_EQ(ruler.time_to_scene(Rational(1, 2)), 50.0); // Inverse conversion returns whole frames in the ruler's timebase - EXPECT_EQ(ruler.SceneToTime(100.0), rational(1)); - EXPECT_EQ(ruler.SceneToTime(50.0), rational(1, 2)); + EXPECT_EQ(ruler.scene_to_time(100.0), Rational(1)); + EXPECT_EQ(ruler.scene_to_time(50.0), Rational(1, 2)); // Fractional positions floor to the frame below (or ceil when negative) - EXPECT_EQ(ruler.SceneToTime(51.0), rational(1, 2)); - EXPECT_EQ(ruler.SceneToTime(-51.0), rational(-1, 2)); + EXPECT_EQ(ruler.scene_to_time(51.0), Rational(1, 2)); + EXPECT_EQ(ruler.scene_to_time(-51.0), Rational(-1, 2)); // Rounding mode snaps to the nearest frame instead - EXPECT_EQ(ruler.SceneToTime(51.0, true), rational(1, 2)); - EXPECT_EQ(ruler.SceneToTime(80.0, true), rational(4, 5)); + EXPECT_EQ(ruler.scene_to_time(51.0, true), Rational(1, 2)); + EXPECT_EQ(ruler.scene_to_time(80.0, true), Rational(4, 5)); } TEST(TimeRuler, SeekToScenePointSeeksConnectedViewer) { - EnsureAppSingletons(); + ensure_app_singletons(); TimeRuler ruler; - ruler.SetTimebase(rational(1, 30)); - ruler.SetScale(100.0); + ruler.set_timebase(Rational(1, 30)); + ruler.set_scale(100.0); ViewerOutput viewer; - ruler.SetViewerNode(&viewer); + ruler.set_viewer_node(&viewer); - ruler.SeekToScenePoint(150.0); - EXPECT_EQ(viewer.GetPlayhead(), rational(3, 2)); + ruler.seek_to_scene_point(150.0); + EXPECT_EQ(viewer.get_playhead(), Rational(3, 2)); // Positions before zero clamp to zero - viewer.SetPlayhead(rational(5)); - ruler.SeekToScenePoint(-50.0); - EXPECT_EQ(viewer.GetPlayhead(), rational(0)); + viewer.set_playhead(Rational(5)); + ruler.seek_to_scene_point(-50.0); + EXPECT_EQ(viewer.get_playhead(), Rational(0)); } TEST(TimeRuler, SeekToScenePointWithoutTimebaseIsNoOp) { // No timebase and no viewer: must return before touching either TimeRuler ruler; - ruler.SeekToScenePoint(150.0); + ruler.seek_to_scene_point(150.0); SUCCEED(); } TEST(TimeRuler, SeekToScenePointWithoutViewerIsNoOp) { - EnsureAppSingletons(); + ensure_app_singletons(); // Timebase set but no viewer connected: previously dereferenced a null // GetViewerNode() and crashed. TimeRuler ruler; - ruler.SetTimebase(rational(1, 30)); - ruler.SetScale(100.0); + ruler.set_timebase(Rational(1, 30)); + ruler.set_scale(100.0); - ruler.SeekToScenePoint(150.0); + ruler.seek_to_scene_point(150.0); SUCCEED(); } @@ -139,12 +139,12 @@ class PlaybackControlsTest : public ::testing::Test { protected: void SetUp() override { - EnsureAppSingletons(); + ensure_app_singletons(); } // The play/pause stacked widget (SliderBase is also a QStackedWidget // and must be filtered out) - static QStackedWidget *PlayPauseStack(PlaybackControls *controls) + static QStackedWidget *play_pause_stack(PlaybackControls *controls) { foreach (QStackedWidget *s, controls->findChildren()) { if (!qobject_cast(s)) { @@ -155,21 +155,21 @@ protected: } // The play/pause buttons live inside the play/pause stacked widget - static void PlayPauseButtons(PlaybackControls *controls, + static void play_pause_buttons(PlaybackControls *controls, QPushButton **play_btn, QPushButton **pause_btn) { - QStackedWidget *stack = PlayPauseStack(controls); + QStackedWidget *stack = play_pause_stack(controls); *play_btn = qobject_cast(stack->widget(0)); *pause_btn = qobject_cast(stack->widget(1)); } // The remaining buttons in creation order: go-to-start, previous frame, // next frame, go-to-end, video drag, audio drag - static QList NavigationButtons(PlaybackControls *controls) + static QList navigation_buttons(PlaybackControls *controls) { QPushButton *play_btn; QPushButton *pause_btn; - PlayPauseButtons(controls, &play_btn, &pause_btn); + play_pause_buttons(controls, &play_btn, &pause_btn); QList buttons; foreach (QPushButton *b, controls->findChildren()) { @@ -186,35 +186,35 @@ TEST_F(PlaybackControlsTest, NullTimebaseDisablesWidget) PlaybackControls controls; EXPECT_FALSE(controls.isEnabled()); - controls.SetTimebase(rational(1, 30)); + controls.set_timebase(Rational(1, 30)); EXPECT_TRUE(controls.isEnabled()); - controls.SetTimebase(rational()); + controls.set_timebase(Rational()); EXPECT_FALSE(controls.isEnabled()); } TEST_F(PlaybackControlsTest, ButtonsEmitCorrespondingSignals) { PlaybackControls controls; - controls.SetTimebase(rational(1, 30)); + controls.set_timebase(Rational(1, 30)); QPushButton *play_btn; QPushButton *pause_btn; - PlayPauseButtons(&controls, &play_btn, &pause_btn); + play_pause_buttons(&controls, &play_btn, &pause_btn); ASSERT_NE(play_btn, nullptr); ASSERT_NE(pause_btn, nullptr); - const QList buttons = NavigationButtons(&controls); + const QList buttons = navigation_buttons(&controls); ASSERT_EQ(buttons.size(), 6); - QSignalSpy begin_spy(&controls, &PlaybackControls::BeginClicked); - QSignalSpy prev_spy(&controls, &PlaybackControls::PrevFrameClicked); - QSignalSpy play_spy(&controls, &PlaybackControls::PlayClicked); - QSignalSpy pause_spy(&controls, &PlaybackControls::PauseClicked); - QSignalSpy next_spy(&controls, &PlaybackControls::NextFrameClicked); - QSignalSpy end_spy(&controls, &PlaybackControls::EndClicked); - QSignalSpy video_spy(&controls, &PlaybackControls::VideoClicked); - QSignalSpy audio_spy(&controls, &PlaybackControls::AudioClicked); + QSignalSpy begin_spy(&controls, &PlaybackControls::begin_clicked); + QSignalSpy prev_spy(&controls, &PlaybackControls::prev_frame_clicked); + QSignalSpy play_spy(&controls, &PlaybackControls::play_clicked); + QSignalSpy pause_spy(&controls, &PlaybackControls::pause_clicked); + QSignalSpy next_spy(&controls, &PlaybackControls::next_frame_clicked); + QSignalSpy end_spy(&controls, &PlaybackControls::end_clicked); + QSignalSpy video_spy(&controls, &PlaybackControls::video_clicked); + QSignalSpy audio_spy(&controls, &PlaybackControls::audio_clicked); buttons.at(0)->click(); EXPECT_EQ(begin_spy.count(), 1); @@ -244,15 +244,15 @@ TEST_F(PlaybackControlsTest, ButtonsEmitCorrespondingSignals) TEST_F(PlaybackControlsTest, SetTimeUpdatesCurrentTimecodeWithoutEmitting) { PlaybackControls controls; - controls.SetTimebase(rational(1, 30)); + controls.set_timebase(Rational(1, 30)); auto *slider = controls.findChild(); ASSERT_NE(slider, nullptr); - QSignalSpy time_spy(&controls, &PlaybackControls::TimeChanged); + QSignalSpy time_spy(&controls, &PlaybackControls::time_changed); - controls.SetTime(rational(3, 2)); - EXPECT_EQ(slider->GetValue(), rational(3, 2)); + controls.set_time(Rational(3, 2)); + EXPECT_EQ(slider->get_value(), Rational(3, 2)); // Programmatic updates must not feed back into TimeChanged EXPECT_EQ(time_spy.count(), 0); @@ -261,7 +261,7 @@ TEST_F(PlaybackControlsTest, SetTimeUpdatesCurrentTimecodeWithoutEmitting) TEST_F(PlaybackControlsTest, SetEndTimeFormatsEndTimecodeLabel) { PlaybackControls controls; - controls.SetTimebase(rational(1, 30)); + controls.set_timebase(Rational(1, 30)); // The only plain QLabel is the end timecode; the current-time slider // uses a SliderLabel (a QLabel subclass) internally @@ -277,54 +277,54 @@ TEST_F(PlaybackControlsTest, SetEndTimeFormatsEndTimecodeLabel) // Pin the display mode so the expected strings don't depend on whatever // the config happens to hold const core::Timecode::Display saved_display = - Core::instance()->GetTimecodeDisplay(); - Core::instance()->SetTimecodeDisplay(core::Timecode::kTimecodeNonDropFrame); + Core::instance()->get_timecode_display(); + Core::instance()->set_timecode_display(core::Timecode::k_timecode_non_drop_frame); // 30 seconds at 30 fps is frame 900 = 30 seconds + 0 frames - controls.SetEndTime(rational(30)); + controls.set_end_time(Rational(30)); EXPECT_EQ(end_label->text(), QStringLiteral("00:00:30:00")); // 1.5 seconds at 30 fps is frame 45 = 1 second + 15 frames - controls.SetEndTime(rational(3, 2)); + controls.set_end_time(Rational(3, 2)); EXPECT_EQ(end_label->text(), QStringLiteral("00:00:01:15")); - Core::instance()->SetTimecodeDisplay(saved_display); + Core::instance()->set_timecode_display(saved_display); } TEST_F(PlaybackControlsTest, PlayPauseStackSwitchesVisibleButton) { PlaybackControls controls; - QStackedWidget *stack = PlayPauseStack(&controls); + QStackedWidget *stack = play_pause_stack(&controls); ASSERT_NE(stack, nullptr); QPushButton *play_btn; QPushButton *pause_btn; - PlayPauseButtons(&controls, &play_btn, &pause_btn); + play_pause_buttons(&controls, &play_btn, &pause_btn); ASSERT_NE(play_btn, nullptr); ASSERT_NE(pause_btn, nullptr); // The play button is the default page EXPECT_EQ(stack->currentWidget(), play_btn); - controls.ShowPauseButton(); + controls.show_pause_button(); EXPECT_EQ(stack->currentWidget(), pause_btn); - controls.ShowPlayButton(); + controls.show_play_button(); EXPECT_EQ(stack->currentWidget(), play_btn); } TEST_F(PlaybackControlsTest, AudioVideoDragButtonsToggleVisibility) { PlaybackControls controls; - const QList buttons = NavigationButtons(&controls); + const QList buttons = navigation_buttons(&controls); ASSERT_EQ(buttons.size(), 6); // Hidden by default (constructor passes false) EXPECT_TRUE(buttons.at(4)->isHidden()); EXPECT_TRUE(buttons.at(5)->isHidden()); - controls.SetAudioVideoDragButtonsVisible(true); + controls.set_audio_video_drag_buttons_visible(true); EXPECT_FALSE(buttons.at(4)->isHidden()); EXPECT_FALSE(buttons.at(5)->isHidden()); } diff --git a/tests/testutil.h b/tests/testutil.h index 8d995b2b8..641be6a24 100644 --- a/tests/testutil.h +++ b/tests/testutil.h @@ -23,16 +23,16 @@ #define OLIVE_TEST_SUCCESS -1 -#define OLIVE_ASSERT(x) \ +#define OAK_ASSERT(x) \ if (!(x)) \ return __LINE__ -#define OLIVE_ASSERT_EQUAL(x, y) \ +#define OAK_ASSERT_EQUAL(x, y) \ if (x != y) { \ std::cout << " - Equal assert failed: " << x << " != " << y; \ return __LINE__; \ } \ void() -#define OLIVE_TEST_END return OLIVE_TEST_SUCCESS +#define OAK_TEST_END return OLIVE_TEST_SUCCESS -#define OLIVE_ADD_TEST(x) int Test##x() +#define OAK_ADD_TEST(x) int Test##x() #define OLIVE_ADD_DISABLED_TEST(x) int Test##x() diff --git a/tests/timeline/timeline-tests.cpp b/tests/timeline/timeline-tests.cpp index 01dd6e426..5eef45c62 100644 --- a/tests/timeline/timeline-tests.cpp +++ b/tests/timeline/timeline-tests.cpp @@ -1,8 +1,8 @@ /*** - Olive - Non-Linear Video Editor - Copyright (C) 2022 Olive Team - Modifications Copyright (C) 2025 mikesolar + Olive - Non-Linear video Editor + Copyright (c) 2022 Olive Team + Modifications Copyright (c) 2025 mikesolar This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,12 +35,12 @@ namespace olive { #define TIMELINE_TEST_START \ - ColorManager::SetUpDefaultConfig(); \ + ColorManager::set_up_default_config(); \ Project project; \ Sequence sequence; \ sequence.setParent(&project) -OLIVE_ADD_TEST(AddTrack) +OAK_ADD_TEST(add_track) { TIMELINE_TEST_START; @@ -48,238 +48,238 @@ OLIVE_ADD_TEST(AddTrack) { // Test creating initial video track - first_video_track = TimelineAddTrackCommand::RunImmediately( - sequence.track_list(Track::kVideo)); + first_video_track = TimelineAddTrackCommand::run_immediately( + sequence.track_list(Track::k_video)); - OLIVE_ASSERT(sequence.GetConnectedOutput(Sequence::kTextureInput) == + OAK_ASSERT(sequence.get_connected_output(Sequence::k_texture_input) == first_video_track); - OLIVE_ASSERT(sequence.track_list(Track::kVideo)->GetTrackCount() == 1); - OLIVE_ASSERT(sequence.track_list(Track::kVideo)->GetTrackAt(0) == + OAK_ASSERT(sequence.track_list(Track::k_video)->get_track_count() == 1); + OAK_ASSERT(sequence.track_list(Track::k_video)->get_track_at(0) == first_video_track); } { // Test creating initial audio track - first_audio_track = TimelineAddTrackCommand::RunImmediately( - sequence.track_list(Track::kAudio)); + first_audio_track = TimelineAddTrackCommand::run_immediately( + sequence.track_list(Track::k_audio)); - OLIVE_ASSERT(sequence.GetConnectedOutput(Sequence::kSamplesInput) == + OAK_ASSERT(sequence.get_connected_output(Sequence::k_samples_input) == first_audio_track); - OLIVE_ASSERT(sequence.track_list(Track::kAudio)->GetTrackCount() == 1); - OLIVE_ASSERT(sequence.track_list(Track::kAudio)->GetTrackAt(0) == + OAK_ASSERT(sequence.track_list(Track::k_audio)->get_track_count() == 1); + OAK_ASSERT(sequence.track_list(Track::k_audio)->get_track_at(0) == first_audio_track); } { // Test creating second video track with merge - Track *second_video_track = TimelineAddTrackCommand::RunImmediately( - sequence.track_list(Track::kVideo), true); - OLIVE_ASSERT(sequence.GetConnectedOutput(Sequence::kTextureInput) != + Track *second_video_track = TimelineAddTrackCommand::run_immediately( + sequence.track_list(Track::k_video), true); + OAK_ASSERT(sequence.get_connected_output(Sequence::k_texture_input) != first_video_track); - OLIVE_ASSERT(sequence.GetConnectedOutput(Sequence::kTextureInput) != + OAK_ASSERT(sequence.get_connected_output(Sequence::k_texture_input) != second_video_track); - OLIVE_ASSERT(sequence.track_list(Track::kVideo)->GetTrackCount() == 2); - OLIVE_ASSERT(sequence.track_list(Track::kVideo)->GetTrackAt(1) == + OAK_ASSERT(sequence.track_list(Track::k_video)->get_track_count() == 2); + OAK_ASSERT(sequence.track_list(Track::k_video)->get_track_at(1) == second_video_track); MergeNode *merge = dynamic_cast( - sequence.GetConnectedOutput(Sequence::kTextureInput)); - OLIVE_ASSERT(merge); - OLIVE_ASSERT(merge->GetConnectedOutput(MergeNode::kBaseIn) == + sequence.get_connected_output(Sequence::k_texture_input)); + OAK_ASSERT(merge); + OAK_ASSERT(merge->get_connected_output(MergeNode::k_base_in) == first_video_track); - OLIVE_ASSERT(merge->GetConnectedOutput(MergeNode::kBlendIn) == + OAK_ASSERT(merge->get_connected_output(MergeNode::k_blend_in) == second_video_track); } { // Test creating second audio track with merge - Track *second_audio_track = TimelineAddTrackCommand::RunImmediately( - sequence.track_list(Track::kAudio), true); - OLIVE_ASSERT(sequence.GetConnectedOutput(Sequence::kSamplesInput) != + Track *second_audio_track = TimelineAddTrackCommand::run_immediately( + sequence.track_list(Track::k_audio), true); + OAK_ASSERT(sequence.get_connected_output(Sequence::k_samples_input) != first_audio_track); - OLIVE_ASSERT(sequence.GetConnectedOutput(Sequence::kSamplesInput) != + OAK_ASSERT(sequence.get_connected_output(Sequence::k_samples_input) != second_audio_track); - OLIVE_ASSERT(sequence.track_list(Track::kAudio)->GetTrackCount() == 2); - OLIVE_ASSERT(sequence.track_list(Track::kAudio)->GetTrackAt(1) == + OAK_ASSERT(sequence.track_list(Track::k_audio)->get_track_count() == 2); + OAK_ASSERT(sequence.track_list(Track::k_audio)->get_track_at(1) == second_audio_track); MathNode *merge = dynamic_cast( - sequence.GetConnectedOutput(Sequence::kSamplesInput)); - OLIVE_ASSERT(merge); - OLIVE_ASSERT(merge->GetConnectedOutput(MathNode::kParamAIn) == + sequence.get_connected_output(Sequence::k_samples_input)); + OAK_ASSERT(merge); + OAK_ASSERT(merge->get_connected_output(MathNode::k_param_a_in) == first_audio_track); - OLIVE_ASSERT(merge->GetConnectedOutput(MathNode::kParamBIn) == + OAK_ASSERT(merge->get_connected_output(MathNode::k_param_b_in) == second_audio_track); } - OLIVE_TEST_END; + OAK_TEST_END; } -OLIVE_ADD_TEST(SequenceDefaults) +OAK_ADD_TEST(SequenceDefaults) { TIMELINE_TEST_START; sequence.add_default_nodes(); - OLIVE_ASSERT(sequence.GetTracks().size() == 2); + OAK_ASSERT(sequence.get_tracks().size() == 2); Track *tex_connect = - dynamic_cast(sequence.GetConnectedTextureOutput()); - OLIVE_ASSERT(tex_connect); + dynamic_cast(sequence.get_connected_texture_output()); + OAK_ASSERT(tex_connect); Track *smp_connect = - dynamic_cast(sequence.GetConnectedSampleOutput()); - OLIVE_ASSERT(smp_connect); - OLIVE_ASSERT(tex_connect != smp_connect); - OLIVE_ASSERT(sequence.GetTracks().contains(tex_connect)); - OLIVE_ASSERT(sequence.GetTracks().contains(smp_connect)); + dynamic_cast(sequence.get_connected_sample_output()); + OAK_ASSERT(smp_connect); + OAK_ASSERT(tex_connect != smp_connect); + OAK_ASSERT(sequence.get_tracks().contains(tex_connect)); + OAK_ASSERT(sequence.get_tracks().contains(smp_connect)); - OLIVE_TEST_END; + OAK_TEST_END; } -OLIVE_ADD_TEST(Trim) +OAK_ADD_TEST(Trim) { TIMELINE_TEST_START; sequence.add_default_nodes(); - Track *track = sequence.GetTracks().first(); + Track *track = sequence.get_tracks().first(); ClipBlock *block1 = new ClipBlock(); block1->set_length_and_media_out(2); block1->setParent(&project); - track->AppendBlock(block1); + track->append_block(block1); ClipBlock *block2 = new ClipBlock(); block2->set_length_and_media_out(2); block2->setParent(&project); - track->AppendBlock(block2); + track->append_block(block2); // There should be two blocks right now - OLIVE_ASSERT(track->Blocks().size() == 2); + OAK_ASSERT(track->blocks().size() == 2); { // Trim out point of second block - BlockTrimCommand command(track, block2, 1, Timeline::kTrimOut); + BlockTrimCommand command(track, block2, 1, Timeline::k_trim_out); command.redo_now(); // No block should have been added - OLIVE_ASSERT(track->Blocks().size() == 2); - OLIVE_ASSERT(block2->length() == 1); - OLIVE_ASSERT(block1->length() == 2); + OAK_ASSERT(track->blocks().size() == 2); + OAK_ASSERT(block2->length() == 1); + OAK_ASSERT(block1->length() == 2); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 2); - OLIVE_ASSERT(block2->length() == 2); - OLIVE_ASSERT(block1->length() == 2); + OAK_ASSERT(track->blocks().size() == 2); + OAK_ASSERT(block2->length() == 2); + OAK_ASSERT(block1->length() == 2); } { // Trim in point of second block - BlockTrimCommand command(track, block2, 1, Timeline::kTrimIn); + BlockTrimCommand command(track, block2, 1, Timeline::k_trim_in); command.redo_now(); // Gap should be inserted in between - OLIVE_ASSERT(track->Blocks().size() == 3); - GapBlock *gap = dynamic_cast(track->Blocks().at(1)); - OLIVE_ASSERT(gap); - OLIVE_ASSERT(gap->length() == 1); - OLIVE_ASSERT(block2->length() == 1); - OLIVE_ASSERT(block1->length() == 2); - OLIVE_ASSERT(block1->next() == gap); - OLIVE_ASSERT(block2->previous() == gap); + OAK_ASSERT(track->blocks().size() == 3); + GapBlock *gap = dynamic_cast(track->blocks().at(1)); + OAK_ASSERT(gap); + OAK_ASSERT(gap->length() == 1); + OAK_ASSERT(block2->length() == 1); + OAK_ASSERT(block1->length() == 2); + OAK_ASSERT(block1->next() == gap); + OAK_ASSERT(block2->previous() == gap); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 2); - OLIVE_ASSERT(block2->length() == 2); - OLIVE_ASSERT(block1->length() == 2); + OAK_ASSERT(track->blocks().size() == 2); + OAK_ASSERT(block2->length() == 2); + OAK_ASSERT(block1->length() == 2); } { // Trim out point of first block - BlockTrimCommand command(track, block1, 1, Timeline::kTrimOut); + BlockTrimCommand command(track, block1, 1, Timeline::k_trim_out); command.redo_now(); // Gap should be inserted in between - OLIVE_ASSERT(track->Blocks().size() == 3); - GapBlock *gap = dynamic_cast(track->Blocks().at(1)); - OLIVE_ASSERT(gap); - OLIVE_ASSERT(gap->length() == 1); - OLIVE_ASSERT(block1->length() == 1); - OLIVE_ASSERT(block2->length() == 2); - OLIVE_ASSERT(block1->next() == gap); - OLIVE_ASSERT(block2->previous() == gap); + OAK_ASSERT(track->blocks().size() == 3); + GapBlock *gap = dynamic_cast(track->blocks().at(1)); + OAK_ASSERT(gap); + OAK_ASSERT(gap->length() == 1); + OAK_ASSERT(block1->length() == 1); + OAK_ASSERT(block2->length() == 2); + OAK_ASSERT(block1->next() == gap); + OAK_ASSERT(block2->previous() == gap); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 2); - OLIVE_ASSERT(block2->length() == 2); - OLIVE_ASSERT(block1->length() == 2); + OAK_ASSERT(track->blocks().size() == 2); + OAK_ASSERT(block2->length() == 2); + OAK_ASSERT(block1->length() == 2); } { // Trim in point of first block - BlockTrimCommand command(track, block1, 1, Timeline::kTrimIn); + BlockTrimCommand command(track, block1, 1, Timeline::k_trim_in); command.redo_now(); // Gap should be prepended to the start - OLIVE_ASSERT(track->Blocks().size() == 3); - GapBlock *gap = dynamic_cast(track->Blocks().at(0)); - OLIVE_ASSERT(gap); - OLIVE_ASSERT(gap->length() == 1); - OLIVE_ASSERT(block1->length() == 1); - OLIVE_ASSERT(block2->length() == 2); - OLIVE_ASSERT(block1->next() == block2); - OLIVE_ASSERT(block1->previous() == gap); + OAK_ASSERT(track->blocks().size() == 3); + GapBlock *gap = dynamic_cast(track->blocks().at(0)); + OAK_ASSERT(gap); + OAK_ASSERT(gap->length() == 1); + OAK_ASSERT(block1->length() == 1); + OAK_ASSERT(block2->length() == 2); + OAK_ASSERT(block1->next() == block2); + OAK_ASSERT(block1->previous() == gap); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 2); - OLIVE_ASSERT(block2->length() == 2); - OLIVE_ASSERT(block1->length() == 2); + OAK_ASSERT(track->blocks().size() == 2); + OAK_ASSERT(block2->length() == 2); + OAK_ASSERT(block1->length() == 2); } - OLIVE_TEST_END; + OAK_TEST_END; } -OLIVE_ADD_TEST(ReplaceBlockWithGap_ClipsOnly) +OAK_ADD_TEST(ReplaceBlockWithGap_ClipsOnly) { TIMELINE_TEST_START; - // Create a track that goes clip -> clip -> clip + // create a track that goes clip -> clip -> clip sequence.add_default_nodes(); - Track *track = sequence.track_list(Track::kVideo)->GetTracks().first(); + Track *track = sequence.track_list(Track::k_video)->get_tracks().first(); ClipBlock *a = new ClipBlock(); a->setParent(&project); - track->AppendBlock(a); + track->append_block(a); ClipBlock *b = new ClipBlock(); b->setParent(&project); - track->AppendBlock(b); + track->append_block(b); ClipBlock *c = new ClipBlock(); c->setParent(&project); - track->AppendBlock(c); + track->append_block(c); { - // Replace clip C with a gap + // Replace clip c with a gap TrackReplaceBlockWithGapCommand command(track, c); command.redo_now(); // Clip should be removed without any gap actually taking its place, since the clip is at the // end of the track - OLIVE_ASSERT(track->Blocks().size() == 2); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); + OAK_ASSERT(track->blocks().size() == 2); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); } { @@ -288,51 +288,51 @@ OLIVE_ADD_TEST(ReplaceBlockWithGap_ClipsOnly) command.redo_now(); // B should be replaced with a gap - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) != b); - OLIVE_ASSERT(dynamic_cast(track->Blocks().at(1))); - OLIVE_ASSERT(track->Blocks().at(1)->length() == b->length()); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) != b); + OAK_ASSERT(dynamic_cast(track->blocks().at(1))); + OAK_ASSERT(track->blocks().at(1)->length() == b->length()); + OAK_ASSERT(track->blocks().at(2) == c); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); } - OLIVE_TEST_END; + OAK_TEST_END; } -OLIVE_ADD_TEST(ReplaceBlockWithGap_ClipsAndGaps) +OAK_ADD_TEST(ReplaceBlockWithGap_ClipsAndGaps) { TIMELINE_TEST_START; - // Create a track that goes clip -> gap -> clip -> clip -> gap -> clip + // create a track that goes clip -> gap -> clip -> clip -> gap -> clip sequence.add_default_nodes(); - Track *track = sequence.track_list(Track::kVideo)->GetTracks().first(); + Track *track = sequence.track_list(Track::k_video)->get_tracks().first(); ClipBlock *a = new ClipBlock(); a->setParent(&project); - track->AppendBlock(a); + track->append_block(a); GapBlock *b = new GapBlock(); b->setParent(&project); - track->AppendBlock(b); + track->append_block(b); ClipBlock *c = new ClipBlock(); c->setParent(&project); - track->AppendBlock(c); + track->append_block(c); GapBlock *d = new GapBlock(); d->setParent(&project); - track->AppendBlock(d); + track->append_block(d); ClipBlock *e = new ClipBlock(); e->setParent(&project); - track->AppendBlock(e); + track->append_block(e); { // Replace clip E with a gap @@ -340,157 +340,157 @@ OLIVE_ADD_TEST(ReplaceBlockWithGap_ClipsAndGaps) command.redo_now(); // Both clips D and E should be removed because this command should remove any trailing gaps - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); // Test undo command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 5); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); - OLIVE_ASSERT(track->Blocks().at(3) == d); - OLIVE_ASSERT(track->Blocks().at(4) == e); + OAK_ASSERT(track->blocks().size() == 5); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); + OAK_ASSERT(track->blocks().at(3) == d); + OAK_ASSERT(track->blocks().at(4) == e); } { // Replace clip A with a gap - rational original_length_of_a = a->length(); - rational original_length_of_b = b->length(); + Rational original_length_of_a = a->length(); + Rational original_length_of_b = b->length(); TrackReplaceBlockWithGapCommand command(track, a); command.redo_now(); // A should be removed and B should take its place - OLIVE_ASSERT(track->Blocks().size() == 4); + OAK_ASSERT(track->blocks().size() == 4); - OLIVE_ASSERT(track->Blocks().at(0) == b); - OLIVE_ASSERT(track->Blocks().at(1) == c); - OLIVE_ASSERT(track->Blocks().at(2) == d); - OLIVE_ASSERT(track->Blocks().at(3) == e); - OLIVE_ASSERT(b->length() == + OAK_ASSERT(track->blocks().at(0) == b); + OAK_ASSERT(track->blocks().at(1) == c); + OAK_ASSERT(track->blocks().at(2) == d); + OAK_ASSERT(track->blocks().at(3) == e); + OAK_ASSERT(b->length() == original_length_of_a + original_length_of_b); // Test undo command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 5); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); - OLIVE_ASSERT(track->Blocks().at(3) == d); - OLIVE_ASSERT(track->Blocks().at(4) == e); - OLIVE_ASSERT(a->length() == original_length_of_a); - OLIVE_ASSERT(b->length() == original_length_of_b); + OAK_ASSERT(track->blocks().size() == 5); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); + OAK_ASSERT(track->blocks().at(3) == d); + OAK_ASSERT(track->blocks().at(4) == e); + OAK_ASSERT(a->length() == original_length_of_a); + OAK_ASSERT(b->length() == original_length_of_b); } { - // Replace clip C with a gap - rational original_length_of_b = b->length(); - rational original_length_of_c = c->length(); - rational original_length_of_d = d->length(); + // Replace clip c with a gap + Rational original_length_of_b = b->length(); + Rational original_length_of_c = c->length(); + Rational original_length_of_d = d->length(); TrackReplaceBlockWithGapCommand command(track, c); command.redo_now(); - // C and D should be removed, and B should take both of their places - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == e); - OLIVE_ASSERT(b->length() == original_length_of_b + + // c and D should be removed, and B should take both of their places + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == e); + OAK_ASSERT(b->length() == original_length_of_b + original_length_of_c + original_length_of_d); // Test undo command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 5); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); - OLIVE_ASSERT(track->Blocks().at(3) == d); - OLIVE_ASSERT(track->Blocks().at(4) == e); - OLIVE_ASSERT(b->length() == original_length_of_b); - OLIVE_ASSERT(c->length() == original_length_of_c); - OLIVE_ASSERT(d->length() == original_length_of_d); + OAK_ASSERT(track->blocks().size() == 5); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); + OAK_ASSERT(track->blocks().at(3) == d); + OAK_ASSERT(track->blocks().at(4) == e); + OAK_ASSERT(b->length() == original_length_of_b); + OAK_ASSERT(c->length() == original_length_of_c); + OAK_ASSERT(d->length() == original_length_of_d); } { - // Add a fourth clip at the end of the track + // add a fourth clip at the end of the track ClipBlock *f = new ClipBlock(); f->setParent(&project); - track->AppendBlock(f); + track->append_block(f); // Try replacing E with a block again TrackReplaceBlockWithGapCommand command(track, e); - rational original_length_of_d = d->length(); - rational original_length_of_e = e->length(); + Rational original_length_of_d = d->length(); + Rational original_length_of_e = e->length(); command.redo_now(); // E should be removed and D should have taken its place - OLIVE_ASSERT(track->Blocks().size() == 5); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); - OLIVE_ASSERT(track->Blocks().at(3) == d); - OLIVE_ASSERT(track->Blocks().at(4) == f); - OLIVE_ASSERT(d->length() == + OAK_ASSERT(track->blocks().size() == 5); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); + OAK_ASSERT(track->blocks().at(3) == d); + OAK_ASSERT(track->blocks().at(4) == f); + OAK_ASSERT(d->length() == original_length_of_d + original_length_of_e); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 6); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); - OLIVE_ASSERT(track->Blocks().at(3) == d); - OLIVE_ASSERT(track->Blocks().at(4) == e); - OLIVE_ASSERT(track->Blocks().at(5) == f); - OLIVE_ASSERT(d->length() == original_length_of_d); - OLIVE_ASSERT(e->length() == original_length_of_e); + OAK_ASSERT(track->blocks().size() == 6); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); + OAK_ASSERT(track->blocks().at(3) == d); + OAK_ASSERT(track->blocks().at(4) == e); + OAK_ASSERT(track->blocks().at(5) == f); + OAK_ASSERT(d->length() == original_length_of_d); + OAK_ASSERT(e->length() == original_length_of_e); } - OLIVE_TEST_END; + OAK_TEST_END; } #define UsingTransition CrossDissolveTransition -OLIVE_ADD_TEST(ReplaceBlockWithGap_ClipsAndTransitions) +OAK_ADD_TEST(ReplaceBlockWithGap_ClipsAndTransitions) { TIMELINE_TEST_START; - // Create a track that goes clip -> gap -> clip -> clip -> gap -> clip + // create a track that goes clip -> gap -> clip -> clip -> gap -> clip sequence.add_default_nodes(); - Track *track = sequence.track_list(Track::kVideo)->GetTracks().first(); + Track *track = sequence.track_list(Track::k_video)->get_tracks().first(); UsingTransition *a_in = new UsingTransition(); a_in->setParent(&project); - track->AppendBlock(a_in); + track->append_block(a_in); ClipBlock *a = new ClipBlock(); a->setParent(&project); - track->AppendBlock(a); + track->append_block(a); UsingTransition *a_to_b = new UsingTransition(); a_to_b->setParent(&project); - track->AppendBlock(a_to_b); + track->append_block(a_to_b); ClipBlock *b = new ClipBlock(); b->setParent(&project); - track->AppendBlock(b); + track->append_block(b); UsingTransition *b_out = new UsingTransition(); b_out->setParent(&project); - track->AppendBlock(b_out); + track->append_block(b_out); - Node::ConnectEdge(a, NodeInput(a_in, UsingTransition::kInBlockInput)); - Node::ConnectEdge(a, NodeInput(a_to_b, UsingTransition::kOutBlockInput)); - Node::ConnectEdge(b, NodeInput(a_to_b, UsingTransition::kInBlockInput)); - Node::ConnectEdge(b, NodeInput(b_out, UsingTransition::kOutBlockInput)); + Node::connect_edge(a, NodeInput(a_in, UsingTransition::k_in_block_input)); + Node::connect_edge(a, NodeInput(a_to_b, UsingTransition::k_out_block_input)); + Node::connect_edge(b, NodeInput(a_to_b, UsingTransition::k_in_block_input)); + Node::connect_edge(b, NodeInput(b_out, UsingTransition::k_out_block_input)); { // Replace A with gap @@ -499,134 +499,134 @@ OLIVE_ADD_TEST(ReplaceBlockWithGap_ClipsAndTransitions) // A should be replaced with a gap and so should A_IN since A was the only clip connected to it. // Also A_TO_B should only be connected to B now - OLIVE_ASSERT(track->Blocks().size() == 4); - OLIVE_ASSERT(dynamic_cast(track->Blocks().at(0))); - OLIVE_ASSERT(track->Blocks().at(1) == a_to_b); - OLIVE_ASSERT(track->Blocks().at(2) == b); - OLIVE_ASSERT(track->Blocks().at(3) == b_out); + OAK_ASSERT(track->blocks().size() == 4); + OAK_ASSERT(dynamic_cast(track->blocks().at(0))); + OAK_ASSERT(track->blocks().at(1) == a_to_b); + OAK_ASSERT(track->blocks().at(2) == b); + OAK_ASSERT(track->blocks().at(3) == b_out); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 5); - OLIVE_ASSERT(track->Blocks().at(0) == a_in); - OLIVE_ASSERT(track->Blocks().at(1) == a); - OLIVE_ASSERT(track->Blocks().at(2) == a_to_b); - OLIVE_ASSERT(track->Blocks().at(3) == b); - OLIVE_ASSERT(track->Blocks().at(4) == b_out); + OAK_ASSERT(track->blocks().size() == 5); + OAK_ASSERT(track->blocks().at(0) == a_in); + OAK_ASSERT(track->blocks().at(1) == a); + OAK_ASSERT(track->blocks().at(2) == a_to_b); + OAK_ASSERT(track->blocks().at(3) == b); + OAK_ASSERT(track->blocks().at(4) == b_out); } - OLIVE_TEST_END; + OAK_TEST_END; } -OLIVE_ADD_TEST(InsertGaps_SingleTrack) +OAK_ADD_TEST(InsertGaps_SingleTrack) { TIMELINE_TEST_START; sequence.add_default_nodes(); - TrackList *list = sequence.track_list(Track::kVideo); - Track *track = list->GetTracks().first(); + TrackList *list = sequence.track_list(Track::k_video); + Track *track = list->get_tracks().first(); ClipBlock *a = new ClipBlock(); a->set_length_and_media_out(1); a->setParent(&project); - track->AppendBlock(a); + track->append_block(a); ClipBlock *b = new ClipBlock(); b->set_length_and_media_out(1); b->setParent(&project); - track->AppendBlock(b); + track->append_block(b); ClipBlock *c = new ClipBlock(); c->set_length_and_media_out(1); c->setParent(&project); - track->AppendBlock(c); + track->append_block(c); - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); { - // Insert gap at the start of the track, all blocks should be unsplit and shifted to the right + // insert gap at the start of the track, all blocks should be unsplit and shifted to the right TrackListInsertGaps command(list, 0, 2); command.redo_now(); - OLIVE_ASSERT(track->Blocks().size() == 4); - OLIVE_ASSERT(dynamic_cast(track->Blocks().at(0))); - OLIVE_ASSERT(track->Blocks().at(0)->length() == 2); - OLIVE_ASSERT(track->Blocks().at(1) == a); - OLIVE_ASSERT(track->Blocks().at(2) == b); - OLIVE_ASSERT(track->Blocks().at(3) == c); + OAK_ASSERT(track->blocks().size() == 4); + OAK_ASSERT(dynamic_cast(track->blocks().at(0))); + OAK_ASSERT(track->blocks().at(0)->length() == 2); + OAK_ASSERT(track->blocks().at(1) == a); + OAK_ASSERT(track->blocks().at(2) == b); + OAK_ASSERT(track->blocks().at(3) == c); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); } { - // Insert gap in the middle of block A, block A should be halved with a copy at 2 and the gap at 1 - TrackListInsertGaps command(list, rational(1, 2), 2); + // insert gap in the middle of block A, block A should be halved with a copy at 2 and the gap at 1 + TrackListInsertGaps command(list, Rational(1, 2), 2); command.redo_now(); - OLIVE_ASSERT(track->Blocks().size() == 5); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(0)->length() == rational(1, 2)); - OLIVE_ASSERT(dynamic_cast(track->Blocks().at(1))); - OLIVE_ASSERT(dynamic_cast(track->Blocks().at(2))); - OLIVE_ASSERT(track->Blocks().at(3) == b); - OLIVE_ASSERT(track->Blocks().at(4) == c); + OAK_ASSERT(track->blocks().size() == 5); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(0)->length() == Rational(1, 2)); + OAK_ASSERT(dynamic_cast(track->blocks().at(1))); + OAK_ASSERT(dynamic_cast(track->blocks().at(2))); + OAK_ASSERT(track->blocks().at(3) == b); + OAK_ASSERT(track->blocks().at(4) == c); command.undo_now(); - OLIVE_ASSERT_EQUAL(track->Blocks().size(), 3); - OLIVE_ASSERT_EQUAL(track->Blocks().at(0), a); - OLIVE_ASSERT_EQUAL(track->Blocks().at(0)->length(), 1); - OLIVE_ASSERT_EQUAL(track->Blocks().at(1), b); - OLIVE_ASSERT_EQUAL(track->Blocks().at(2), c); + OAK_ASSERT_EQUAL(track->blocks().size(), 3); + OAK_ASSERT_EQUAL(track->blocks().at(0), a); + OAK_ASSERT_EQUAL(track->blocks().at(0)->length(), 1); + OAK_ASSERT_EQUAL(track->blocks().at(1), b); + OAK_ASSERT_EQUAL(track->blocks().at(2), c); } { - // Insert gap between block A and B, blocks should be unsplit with a gap at 1 + // insert gap between block A and B, blocks should be unsplit with a gap at 1 TrackListInsertGaps command(list, 1, 2); command.redo_now(); - OLIVE_ASSERT(track->Blocks().size() == 4); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(dynamic_cast(track->Blocks().at(1))); - OLIVE_ASSERT(track->Blocks().at(2) == b); - OLIVE_ASSERT(track->Blocks().at(3) == c); + OAK_ASSERT(track->blocks().size() == 4); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(dynamic_cast(track->blocks().at(1))); + OAK_ASSERT(track->blocks().at(2) == b); + OAK_ASSERT(track->blocks().at(3) == c); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); } { - // Insert gap at end, nothing should be added + // insert gap at end, nothing should be added TrackListInsertGaps command(list, 3, 2); command.redo_now(); - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); command.undo_now(); - OLIVE_ASSERT(track->Blocks().size() == 3); - OLIVE_ASSERT(track->Blocks().at(0) == a); - OLIVE_ASSERT(track->Blocks().at(1) == b); - OLIVE_ASSERT(track->Blocks().at(2) == c); + OAK_ASSERT(track->blocks().size() == 3); + OAK_ASSERT(track->blocks().at(0) == a); + OAK_ASSERT(track->blocks().at(1) == b); + OAK_ASSERT(track->blocks().at(2) == c); } - OLIVE_TEST_END; + OAK_TEST_END; } }